Bug 5679 - implement ietf-restconf-monitoring - capabilities
[netconf.git] / restconf / sal-rest-connector / src / test / java / org / opendaylight / restconf / rest / services / impl / RestconfStreamsServiceTest.java
index 8cc5d3b8dfd0196f92929621730783e705ded2a5..2ceacd91110622b9ee57c435872fb20ca8050680 100644 (file)
@@ -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 <code>RestconfDocumentedException</code>. 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 <code>RestconfDocumentedException</code>. 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 <code>IllegalStateException</code>.
-     */
-    @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 <code>IllegalStateException</code>.
-     */
-    @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 <code>IllegalStateException</code>.
-     */
-    @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.