X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=restconf%2Frestconf-nb-bierman02%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2Ftest%2FRestPostOperationTest.java;h=3aa6a9c8cbff7276aae39c69579f091110a37cc1;hb=09c1d18add7cfc310f3d190a1a02a523159162ce;hp=df5f423e014a8beeb7e4785c62f8e4d60a8d81de;hpb=b7537d2482ffb05582749ce80a7ca44c64a5ad6c;p=netconf.git diff --git a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java index df5f423e01..3aa6a9c8cb 100644 --- a/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java +++ b/restconf/restconf-nb-bierman02/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URISyntaxException; import java.text.ParseException; +import java.util.Optional; import javax.ws.rs.client.Entity; import javax.ws.rs.core.Application; import javax.ws.rs.core.MediaType; @@ -35,6 +36,8 @@ import org.mockito.ArgumentCaptor; import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils; import org.opendaylight.mdsal.common.api.CommitInfo; import org.opendaylight.mdsal.dom.api.DOMMountPoint; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService; import org.opendaylight.netconf.sal.rest.api.Draft02; import org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader; import org.opendaylight.netconf.sal.rest.impl.NormalizedNodeJsonBodyWriter; @@ -46,8 +49,7 @@ import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; public class RestPostOperationTest extends JerseyTest { @@ -55,9 +57,9 @@ public class RestPostOperationTest extends JerseyTest { private static String xmlData3; private static String xmlData4; - private static SchemaContext schemaContextYangsIetf; - private static SchemaContext schemaContextTestModule; - private static SchemaContext schemaContext; + private static EffectiveModelContext schemaContextYangsIetf; + private static EffectiveModelContext schemaContextTestModule; + private static EffectiveModelContext schemaContext; private BrokerFacade brokerFacade; private RestconfImpl restconfImpl; @@ -65,7 +67,7 @@ public class RestPostOperationTest extends JerseyTest { private DOMMountPoint mountInstance; @BeforeClass - public static void init() throws URISyntaxException, IOException, ReactorException { + public static void init() throws URISyntaxException, IOException { schemaContextYangsIetf = TestUtils.loadSchemaContext("/full-versions/yangs"); schemaContextTestModule = TestUtils.loadSchemaContext("/full-versions/test-module"); schemaContext = TestUtils.loadSchemaContext("/test-config-data/yang1"); @@ -93,7 +95,7 @@ public class RestPostOperationTest extends JerseyTest { return resourceConfig; } - private void setSchemaControllerContext(final SchemaContext schema) { + private void setSchemaControllerContext(final EffectiveModelContext schema) { controllerContext.setSchemas(schema); } @@ -105,7 +107,8 @@ public class RestPostOperationTest extends JerseyTest { when(brokerFacade.commitConfigurationDataPost(any(DOMMountPoint.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), null, null)).thenReturn(mock(FluentFuture.class)); - when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule); + when(mountInstance.getService(DOMSchemaService.class)) + .thenReturn(Optional.of(FixedDOMSchemaService.of(schemaContextTestModule))); String uri = "/config/ietf-interfaces:interfaces/interface/0/"; assertEquals(204, post(uri, Draft02.MediaTypes.DATA + XML, xmlData4)); @@ -120,13 +123,12 @@ public class RestPostOperationTest extends JerseyTest { @Ignore //jenkins has problem with JerseyTest // - we expecting problems with singletons ControllerContext as schemaContext holder public void createConfigurationDataTest() throws UnsupportedEncodingException, ParseException { - when(brokerFacade.commitConfigurationDataPost((SchemaContext) null, any(YangInstanceIdentifier.class), + when(brokerFacade.commitConfigurationDataPost((EffectiveModelContext) null, any(YangInstanceIdentifier.class), any(NormalizedNode.class), null, null)) .thenReturn(mock(FluentFuture.class)); final ArgumentCaptor instanceIdCaptor = ArgumentCaptor.forClass(YangInstanceIdentifier.class); - @SuppressWarnings("rawtypes") final ArgumentCaptor compNodeCaptor = ArgumentCaptor.forClass(NormalizedNode.class); @@ -142,8 +144,8 @@ public class RestPostOperationTest extends JerseyTest { // FIXME : NEVER test a nr. of call some service in complex test suite // verify(brokerFacade, times(2)) verify(brokerFacade, times(1)) - .commitConfigurationDataPost((SchemaContext) null, instanceIdCaptor.capture(), compNodeCaptor.capture(), - null, null); + .commitConfigurationDataPost((EffectiveModelContext) null, instanceIdCaptor.capture(), + compNodeCaptor.capture(), null, null); // identifier = "[(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interfaces," + // "(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)block]"; assertEquals(identifier, ImmutableList.copyOf(instanceIdCaptor.getValue().getPathArguments()).toString()); @@ -152,7 +154,7 @@ public class RestPostOperationTest extends JerseyTest { @Test public void createConfigurationDataNullTest() throws UnsupportedEncodingException { doReturn(CommitInfo.emptyFluentFuture()).when(brokerFacade).commitConfigurationDataPost( - any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), isNull(), + any(EffectiveModelContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), isNull(), isNull()); //FIXME : find who is set schemaContext