X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-model-util%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fmodel%2Futil%2FSchemaContextUtilTest.java;h=8e7ab07580b591bf93a488c123606486989f06c8;hb=bb60da5fe2d1928defb46ed92b290cfff93dcd81;hp=b47e541232039def5f55fb3798e7893dbd8bb318;hpb=0c48f313a0e06974816cf0d114a83ad1139219b4;p=yangtools.git diff --git a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SchemaContextUtilTest.java b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SchemaContextUtilTest.java index b47e541232..8e7ab07580 100644 --- a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SchemaContextUtilTest.java +++ b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SchemaContextUtilTest.java @@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.model.util; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -37,15 +38,15 @@ import org.opendaylight.yangtools.yang.model.util.type.BaseTypes; @RunWith(MockitoJUnitRunner.StrictStubs.class) public class SchemaContextUtilTest { - private static final Splitter SPACE_SPLITTER = Splitter.on(' '); - private static final URI NAMESPACE = URI.create("abc"); + public static final Splitter SPACE_SPLITTER = Splitter.on(' '); + public static final URI NAMESPACE = URI.create("abc"); @Mock - private SchemaContext mockSchemaContext; + public SchemaContext mockSchemaContext; @Mock - private Module mockModule; + public Module mockModule; @Mock - private SchemaNode schemaNode; + public SchemaNode schemaNode; @Before public void before() { @@ -54,9 +55,7 @@ public class SchemaContextUtilTest { doReturn("test").when(mockModule).getName(); doReturn("test").when(mockModule).getPrefix(); - doReturn(NAMESPACE).when(mockModule).getNamespace(); doReturn(QNameModule.create(NAMESPACE)).when(mockModule).getQNameModule(); - doReturn(Optional.empty()).when(mockModule).getRevision(); } @Test @@ -88,56 +87,60 @@ public class SchemaContextUtilTest { assertNull("Should be null.", SchemaContextUtil.findParentModule(mockSchemaContext, int32node)); } - @Test(expected = NullPointerException.class) + @Test public void findDataSchemaNodeFromXPathIllegalArgumentTest() { - SchemaContextUtil.findDataSchemaNode(mock(SchemaContext.class), mock(Module.class), null); + assertThrows(NullPointerException.class, + () -> SchemaContextUtil.findDataSchemaNode(mock(SchemaContext.class), mock(Module.class), null)); } - @Test(expected = NullPointerException.class) + @Test public void findDataSchemaNodeFromXPathIllegalArgumentTest2() { final SchemaContext mockContext = mock(SchemaContext.class); final PathExpression xpath = new PathExpressionImpl("my:my-grouping/my:my-leaf-in-gouping2", true); - SchemaContextUtil.findDataSchemaNode(mockContext, null, xpath); + assertThrows(NullPointerException.class, () -> SchemaContextUtil.findDataSchemaNode(mockContext, null, xpath)); } - @Test(expected = NullPointerException.class) + @Test public void findDataSchemaNodeFromXPathIllegalArgumentTest3() { final Module module = mock(Module.class); final PathExpression xpath = new PathExpressionImpl("my:my-grouping/my:my-leaf-in-gouping2", true); - SchemaContextUtil.findDataSchemaNode(null, module, xpath); + assertThrows(NullPointerException.class, () -> SchemaContextUtil.findDataSchemaNode(null, module, xpath)); } - @Test(expected = IllegalArgumentException.class) + @Test public void findDataSchemaNodeFromXPathIllegalArgumentTest4() { final SchemaContext mockContext = mock(SchemaContext.class); final Module module = mock(Module.class); final PathExpression xpath = new PathExpressionImpl("my:my-grouping[@con='NULL']/my:my-leaf-in-gouping2", true); - SchemaContextUtil.findDataSchemaNode(mockContext, module, xpath); + assertThrows(IllegalArgumentException.class, + () -> SchemaContextUtil.findDataSchemaNode(mockContext, module, xpath)); } - @Test(expected = NullPointerException.class) + @Test public void findParentModuleIllegalArgumentTest() { - SchemaContextUtil.findParentModule(mock(SchemaContext.class), null); + assertThrows(NullPointerException.class, + () -> SchemaContextUtil.findParentModule(mock(SchemaContext.class), null)); } - @Test(expected = NullPointerException.class) + @Test public void findParentModuleIllegalArgumentTest2() { doReturn(SchemaPath.create(true, QName.create("foo", "bar"))).when(schemaNode).getPath(); - SchemaContextUtil.findParentModule(null, schemaNode); + assertThrows(NullPointerException.class, () -> SchemaContextUtil.findParentModule(null, schemaNode)); } - @Test(expected = NullPointerException.class) + @Test public void findDataSchemaNodeIllegalArgumentTest() { - SchemaContextUtil.findDataSchemaNode(mock(SchemaContext.class), (SchemaPath) null); + assertThrows(NullPointerException.class, + () -> SchemaContextUtil.findDataSchemaNode(mock(SchemaContext.class), (SchemaPath) null)); } - @Test(expected = NullPointerException.class) + @Test public void findDataSchemaNodeIllegalArgumentTest2() { - SchemaContextUtil.findDataSchemaNode(null, SchemaPath.create(true, - QName.create(URI.create("uri:my-module"), Revision.of("2014-10-07"), "foo"))); + assertThrows(NullPointerException.class, () -> SchemaContextUtil.findDataSchemaNode(null, + SchemaPath.create(true, QName.create(URI.create("uri:my-module"), Revision.of("2014-10-07"), "foo")))); } @Test