X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=restconf%2Fsal-rest-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Frestconf%2Frest%2Fservices%2Fimpl%2FRestconfStreamsServiceTest.java;h=2ceacd91110622b9ee57c435872fb20ca8050680;hb=266c09557b7cc6d97879e1c7efa7a7e0503c855a;hp=8cc5d3b8dfd0196f92929621730783e705ded2a5;hpb=9d6c04fb735ad5aff2c0e5ebd2bb946154cfb8fa;p=netconf.git
diff --git a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/services/impl/RestconfStreamsServiceTest.java b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/services/impl/RestconfStreamsServiceTest.java
index 8cc5d3b8df..2ceacd9111 100644
--- a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/services/impl/RestconfStreamsServiceTest.java
+++ b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/services/impl/RestconfStreamsServiceTest.java
@@ -12,7 +12,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import static org.mockito.Mockito.when;
import static org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.EMPTY;
import com.google.common.collect.Iterables;
@@ -34,12 +33,11 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
-import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
-import org.opendaylight.netconf.sal.restconf.impl.RestconfError;
import org.opendaylight.netconf.sal.streams.listeners.Notificator;
import org.opendaylight.restconf.Draft18;
+import org.opendaylight.restconf.base.services.api.RestconfStreamsService;
+import org.opendaylight.restconf.base.services.impl.RestconfStreamsServiceImpl;
import org.opendaylight.restconf.handlers.SchemaContextHandler;
-import org.opendaylight.restconf.rest.services.api.RestconfStreamsService;
import org.opendaylight.restconf.utils.mapping.RestconfMappingNodeConstants;
import org.opendaylight.restconf.utils.mapping.RestconfMappingStreamConstants;
import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType;
@@ -154,111 +152,6 @@ public class RestconfStreamsServiceTest {
this.streamsService.getAvailableStreams(null);
}
- /**
- * Try to get all available streams supported by the server when Restconf module does not contain list stream
- * catching RestconfDocumentedException
. Error type, error tag and error status code are validated
- * against expected values.
- */
- @Test
- public void getAvailableStreamsMissingListStreamNegativeTest() {
- // prepare conditions - get Restconf module with missing list stream
- when(this.contextHandler.get()).thenReturn(this.mockSchemaContext);
- when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft18.RestconfModule.IETF_RESTCONF_QNAME
- .getNamespace(), Draft18.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
- .thenReturn(getTestingRestconfModule("restconf-module-with-missing-list-stream"));
-
- // make test and verify
- try {
- this.streamsService.getAvailableStreams(null);
- fail("Test is expected to fail due to missing list stream");
- } catch (final RestconfDocumentedException e) {
- assertEquals("Error type is not correct",
- RestconfError.ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
- assertEquals("Error tag is not correct",
- RestconfError.ErrorTag.DATA_MISSING, e.getErrors().get(0).getErrorTag());
- assertEquals("Error status code is not correct",
- 404, e.getErrors().get(0).getErrorTag().getStatusCode());
- }
- }
-
- /**
- * Try to get all available streams supported by the server when Restconf module does not contain container streams
- * catching RestconfDocumentedException
. Error type, error tag and error status code are validated
- * against expected values.
- */
- @Test
- public void getAvailableStreamsMissingContainerStreamsNegativeTest() {
- // prepare conditions - get Restconf module with missing container streams
- when(this.contextHandler.get()).thenReturn(this.mockSchemaContext);
- when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft18.RestconfModule.IETF_RESTCONF_QNAME
- .getNamespace(), Draft18.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
- .thenReturn(getTestingRestconfModule("restconf-module-with-missing-container-streams"));
-
- // make test and verify
- try {
- this.streamsService.getAvailableStreams(null);
- fail("Test is expected to fail due to missing container streams");
- } catch (final RestconfDocumentedException e) {
- assertEquals("Error type is not correct",
- RestconfError.ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
- assertEquals("Error tag is not correct",
- RestconfError.ErrorTag.DATA_MISSING, e.getErrors().get(0).getErrorTag());
- assertEquals("Error status code is not correct",
- 404, e.getErrors().get(0).getErrorTag().getStatusCode());
- }
- }
-
- /**
- * Try to get all available streams supported by the server when Restconf module contains node with name 'stream'
- * but it is not of type list. Test is expected to fail with IllegalStateException
.
- */
- @Test
- public void getAvailableStreamsIllegalListStreamNegativeTest() {
- // prepare conditions - get Restconf module with illegal list stream
- when(this.contextHandler.get()).thenReturn(this.mockSchemaContext);
- when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft18.RestconfModule.IETF_RESTCONF_QNAME
- .getNamespace(), Draft18.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
- .thenReturn(getTestingRestconfModule("restconf-module-with-illegal-list-stream"));
-
- // make test
- this.thrown.expect(IllegalStateException.class);
- this.streamsService.getAvailableStreams(null);
- }
-
- /**
- * Try to get all available streams supported by the server when Restconf module contains node with name 'streams'
- * but it is not of type container. Test is expected to fail with IllegalStateException
.
- */
- @Test
- public void getAvailableStreamsIllegalContainerStreamsNegativeTest() {
- // prepare conditions - get Restconf module with illegal container streams
- when(this.contextHandler.get()).thenReturn(this.mockSchemaContext);
- when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft18.RestconfModule.IETF_RESTCONF_QNAME
- .getNamespace(), Draft18.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
- .thenReturn(getTestingRestconfModule("restconf-module-with-illegal-container-streams"));
-
- // make test
- this.thrown.expect(IllegalStateException.class);
- this.streamsService.getAvailableStreams(null);
- }
-
- /**
- * Try to get all available streams supported by the server when node 'description' in list stream in Restconf
- * module is not of type leaf. Test is expected to fail with IllegalStateException
.
- */
- @Test
- public void getAvailableStreamsIllegalLeafDescriptionNegativeTest() {
- // prepare conditions - get Restconf module with illegal leaf description in list stream
- when(this.contextHandler.get()).thenReturn(this.mockSchemaContext);
- when(this.mockSchemaContext.findModuleByNamespaceAndRevision(Draft18.RestconfModule.IETF_RESTCONF_QNAME
- .getNamespace(), Draft18.RestconfModule.IETF_RESTCONF_QNAME.getRevision()))
- .thenReturn(getTestingRestconfModule("restconf-module-with-illegal-leaf-description"));
-
- // make test
- this.thrown.expect(IllegalStateException.class);
- this.streamsService.getAvailableStreams(null);
- }
-
/**
* There are multiple testing Restconf modules for different test cases. It is possible to distinguish them by
* name or by namespace. This method is looking for Restconf test module by its name.