Merge "Bug 1125: Added regression test"
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / RestGetAugmentedElementWhenEqualNamesTest.java
index a6391894c2f044dd13d98518db473c952e44d1e8..bab06e92451985b5a0d95032e99174adb91ba4b0 100644 (file)
@@ -9,25 +9,25 @@ package org.opendaylight.controller.sal.restconf.impl.test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.FileNotFoundException;
-
 import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
 import org.opendaylight.controller.sal.restconf.impl.InstanceIdWithSchemaNode;
-import org.opendaylight.controller.sal.restconf.impl.ResponseException;
+import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public class RestGetAugmentedElementWhenEqualNamesTest {
-    
+
     private static ControllerContext controllerContext = ControllerContext.getInstance();
-    
+
     @Rule
     public ExpectedException exception = ExpectedException.none();
-    
+
     @BeforeClass
     public static void init() throws FileNotFoundException {
         SchemaContext schemaContextTestModule = TestUtils.loadSchemaContext("/common/augment/yang");
@@ -41,17 +41,14 @@ public class RestGetAugmentedElementWhenEqualNamesTest {
         iiWithData = controllerContext.toInstanceIdentifier("main:cont/augment-main-b:cont1");
         assertEquals("ns:augment:main:b", iiWithData.getSchemaNode().getQName().getNamespace().toString());
     }
-    
+
     @Test
     public void nodeWithoutNamespaceHasMoreAugments() {
-        boolean exceptionCaught = false;
         try {
             controllerContext.toInstanceIdentifier("main:cont/cont1");
-        } catch (ResponseException e) {
-            assertTrue(((String) e.getResponse().getEntity()).contains("is added as augment from more than one module"));
-            exceptionCaught = true;
+            fail("Expected exception");
+        } catch (RestconfDocumentedException e) {
+            assertTrue(e.getErrors().get(0).getErrorMessage().contains("is added as augment from more than one module"));
         }
-        assertTrue(exceptionCaught);
     }
-
 }