a0877f7c4e9f1935c013fb88fe69a6af9c30f4bd
[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 package org.opendaylight.yangtools.yang.data.api;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
13 import static org.junit.Assert.fail;
14
15 import org.junit.Test;
16
17 public class ModifyActionTest {
18
19     @Test
20     public void testModifyAction() {
21         final ModifyAction modifyAction = ModifyAction.fromXmlValue("create");
22         assertEquals(ModifyAction.CREATE, modifyAction);
23         assertEquals(ModifyAction.DELETE, ModifyAction.fromXmlValue("delete"));
24         assertEquals(ModifyAction.MERGE, ModifyAction.fromXmlValue("merge"));
25         assertEquals(ModifyAction.NONE, ModifyAction.fromXmlValue("none"));
26         assertEquals(ModifyAction.REMOVE, ModifyAction.fromXmlValue("remove"));
27         assertEquals(ModifyAction.REPLACE, ModifyAction.fromXmlValue("replace"));
28         assertFalse(modifyAction.isAsDefaultPermitted());
29         assertTrue(modifyAction.isOnElementPermitted());
30
31         try {
32             ModifyAction.fromXmlValue("exception call");
33             fail();
34         } catch (IllegalArgumentException e) {
35         }
36     }
37 }