X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=restconf%2Fsal-rest-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Frestconf%2Frest%2Fservices%2Fimpl%2FRestconfModulesServiceTest.java;h=c5e9057848e18add8eced1214683f2ff0ebabdac;hb=80c05797ae434791471ba69cfec946790ae40ed0;hp=f821e1551942bffde555aa3f27d15b2ae8163197;hpb=72fa00b36dff4b41997f5935daa5a77e1afd1b52;p=netconf.git diff --git a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/services/impl/RestconfModulesServiceTest.java b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/services/impl/RestconfModulesServiceTest.java index f821e15519..c5e9057848 100644 --- a/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/services/impl/RestconfModulesServiceTest.java +++ b/restconf/sal-rest-connector/src/test/java/org/opendaylight/restconf/rest/services/impl/RestconfModulesServiceTest.java @@ -47,10 +47,11 @@ import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext; import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException; import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag; import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType; -import org.opendaylight.restconf.Draft16.RestconfModule; +import org.opendaylight.restconf.Draft18.RestconfModule; +import org.opendaylight.restconf.base.services.api.RestconfModulesService; +import org.opendaylight.restconf.base.services.impl.RestconfModulesServiceImpl; import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler; import org.opendaylight.restconf.handlers.SchemaContextHandler; -import org.opendaylight.restconf.rest.services.api.RestconfModulesService; import org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.TestModule; import org.opendaylight.restconf.utils.RestconfConstants; import org.opendaylight.restconf.utils.mapping.RestconfMappingNodeConstants; @@ -556,7 +557,8 @@ public class RestconfModulesServiceTest { /** * Negative test of getting specific module supported by the mount point when specified mount point is not found * (it is not registered in DOMMountPointService). Test is expected to fail with - * IllegalStateException. + * RestconfDocumentedException and error type, error tag and error status code are compared to + * expected values. */ @Test public void getModuleMountPointNotFoundNegativeTest() throws Exception { @@ -564,14 +566,21 @@ public class RestconfModulesServiceTest { final RestconfModulesService modulesService = setupNormalMountPoint(); // make test - this.thrown.expect(IllegalStateException.class); - modulesService.getModule(TEST_MODULE_BEHIND_NOT_REGISTERED_MOUNT_POINT, null); + try { + modulesService.getModule(TEST_MODULE_BEHIND_NOT_REGISTERED_MOUNT_POINT, null); + fail("Test should fail due to missing mount point"); + } catch (final RestconfDocumentedException e) { + assertEquals("Error type is not correct", ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType()); + assertEquals("Error tag is not correct", ErrorTag.DATA_MISSING, e.getErrors().get(0).getErrorTag()); + assertEquals("Error code is not correct", 404, e.getErrors().get(0).getErrorTag().getStatusCode()); + } } /** * Negative test of getting all modules supported by the mount point when specified mount point is not found (it * is not registered in DOMMountPointService). Test is expected to fail with - * IllegalStateException. + * RestconfDocumentedException and error type, error tag and error status code are compared to + * expected values. */ @Test public void getModulesMountPointNotFoundNegativeTest() throws Exception { @@ -579,7 +588,13 @@ public class RestconfModulesServiceTest { final RestconfModulesService modulesService = setupNormalMountPoint(); // make test - this.thrown.expect(IllegalStateException.class); - modulesService.getModules(NOT_REGISTERED_MOUNT_POINT, null); + try { + modulesService.getModules(NOT_REGISTERED_MOUNT_POINT, null); + fail("Test should fail due to missing mount point"); + } catch (final RestconfDocumentedException e) { + assertEquals("Error type is not correct", ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType()); + assertEquals("Error tag is not correct", ErrorTag.DATA_MISSING, e.getErrors().get(0).getErrorTag()); + assertEquals("Error code is not correct", 404, e.getErrors().get(0).getErrorTag().getStatusCode()); + } } }