2218ee1884f29e8479eee9d6d101f5c59ce09bf1
[yangtools.git] / yang / yang-data-api / src / test / java / org / opendaylight / yangtools / yang / data / api / ModifyActionTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  *
8  */
9
10 package org.opendaylight.yangtools.yang.data.api;
11
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertFalse;
14 import static org.junit.Assert.assertTrue;
15 import static org.junit.Assert.fail;
16
17 import org.junit.Test;
18
19 public class ModifyActionTest {
20
21     @Test
22     public void testModifyAction() {
23         final ModifyAction modifyAction = ModifyAction.fromXmlValue("create");
24         assertEquals(ModifyAction.CREATE, modifyAction);
25         assertEquals(ModifyAction.DELETE, ModifyAction.fromXmlValue("delete"));
26         assertEquals(ModifyAction.MERGE, ModifyAction.fromXmlValue("merge"));
27         assertEquals(ModifyAction.NONE, ModifyAction.fromXmlValue("none"));
28         assertEquals(ModifyAction.REMOVE, ModifyAction.fromXmlValue("remove"));
29         assertEquals(ModifyAction.REPLACE, ModifyAction.fromXmlValue("replace"));
30         assertFalse(modifyAction.isAsDefaultPermitted());
31         assertTrue(modifyAction.isOnElementPermitted());
32
33         try {
34             ModifyAction.fromXmlValue("exception call");
35             fail();
36         } catch (IllegalArgumentException e) {
37         }
38     }
39 }