2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.restconf.rest.services.impl;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13 import static org.junit.Assert.fail;
14 import static org.mockito.Mockito.mock;
15 import static org.mockito.Mockito.spy;
16 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.ALLOWED_KEYWORDS;
17 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.MOUNT_POINT;
18 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.NOT_EXISTING_MODULE;
19 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.NOT_EXISTING_MODULE_BEHIND_MOUNT_POINT;
20 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.NOT_REGISTERED_MOUNT_POINT;
21 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.TEST_MODULE;
22 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.TEST_MODULE_BEHIND_MOUNT_POINT;
23 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.TEST_MODULE_BEHIND_NOT_REGISTERED_MOUNT_POINT;
24 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.getExpectedModules;
25 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.getExpectedModulesBehindMountPoint;
26 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.setupCustomRestconfModule;
27 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.setupCustomRestconfModuleMountPoint;
28 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.setupMissingRestconfModule;
29 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.setupMissingRestconfModuleMountPoint;
30 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.setupNormal;
31 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.setupNormalMountPoint;
32 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.setupNullMountPointService;
33 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.verifyModule;
34 import static org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.verifyModules;
36 import java.util.AbstractMap.SimpleImmutableEntry;
37 import java.util.Collection;
38 import java.util.Collections;
39 import java.util.HashSet;
40 import java.util.Iterator;
41 import java.util.Map.Entry;
43 import org.junit.Rule;
44 import org.junit.Test;
45 import org.junit.rules.ExpectedException;
46 import org.opendaylight.netconf.sal.restconf.impl.NormalizedNodeContext;
47 import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
48 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorTag;
49 import org.opendaylight.netconf.sal.restconf.impl.RestconfError.ErrorType;
50 import org.opendaylight.restconf.Draft18.RestconfModule;
51 import org.opendaylight.restconf.base.services.api.RestconfModulesService;
52 import org.opendaylight.restconf.base.services.impl.RestconfModulesServiceImpl;
53 import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
54 import org.opendaylight.restconf.handlers.SchemaContextHandler;
55 import org.opendaylight.restconf.rest.services.impl.RestconfModulesServiceTestUtils.TestModule;
56 import org.opendaylight.restconf.utils.RestconfConstants;
57 import org.opendaylight.restconf.utils.mapping.RestconfMappingNodeConstants;
58 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
59 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
60 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
61 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
62 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
63 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerAttrNode;
64 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
65 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
68 * Unit tests of the {@link RestconfModulesServiceImpl}
71 public class RestconfModulesServiceTest {
72 @Rule public ExpectedException thrown = ExpectedException.none();
75 * Test non-null init of {@link RestconfModulesServiceImpl}.
78 public void restconfModulesServiceImplInitTest() {
79 assertNotNull("Modules service should be initialized and not null",
80 new RestconfModulesServiceImpl(mock(SchemaContextHandler.class),
81 mock(DOMMountPointServiceHandler.class)));
85 * Test getting all modules supported by the server. Retrieved modules are verified by the name, namespace and
89 public void getModulesTest() throws Exception {
90 // load schema context with testing modules and correct Restconf module
91 final RestconfModulesService modulesService = setupNormal();
94 final NormalizedNodeContext nodeContext = modulesService.getModules(null);
96 // check if expected modules were loaded
97 assertNotNull("Node context cannot be null", nodeContext);
98 final Collection<?> modules = (Collection<?>) ((ContainerNode) nodeContext .getData())
99 .getValue().iterator().next().getValue();
100 final Set<TestModule> loadedModules = new HashSet<>();
102 for (final Object node : modules) {
103 final Iterator mapEntries = ((AbstractImmutableDataContainerAttrNode) node).getChildren().entrySet()
105 final TestModule loadedModule = new TestModule();
107 while (mapEntries.hasNext()) {
108 final Entry e = ((SimpleImmutableEntry) mapEntries.next());
109 final String key = ((NodeIdentifier) e.getKey()).getNodeType().getLocalName();
111 assertTrue("Not allowed keyword", ALLOWED_KEYWORDS.contains(key));
114 case RestconfMappingNodeConstants.NAME:
115 loadedModule.setName((String) ((LeafNode) e.getValue()).getValue());
117 case RestconfMappingNodeConstants.NAMESPACE:
118 loadedModule.setNamespace((String) ((LeafNode) e.getValue()).getValue());
120 case RestconfMappingNodeConstants.REVISION:
121 loadedModule.setRevision((String) ((LeafNode) e.getValue()).getValue());
123 case RestconfMappingNodeConstants.FEATURE:
128 loadedModules.add(loadedModule);
131 verifyModules(getExpectedModules(), loadedModules);
135 * Test getting all modules supported by the mount point. Retrieved modules are verified by the name, namespace and
139 public void getModulesMountPointTest() throws Exception {
140 // load testing modules and correct Restconf module behind mount point
141 final RestconfModulesService modulesService = setupNormalMountPoint();
144 final NormalizedNodeContext nodeContext = modulesService.getModules(MOUNT_POINT, null);
146 // check if expected modules were loaded, use module name as map key
147 assertNotNull("Node context cannot be null", nodeContext);
148 final Collection<?> modules = (Collection<?>) ((ContainerNode) nodeContext .getData())
149 .getValue().iterator().next().getValue();
150 final Set<TestModule> loadedModules = new HashSet<>();
152 for (final Object node : modules) {
153 final Iterator mapEntries = ((AbstractImmutableDataContainerAttrNode) node).getChildren().entrySet()
155 final TestModule loadedModule = new TestModule();
157 while (mapEntries.hasNext()) {
158 final Entry e = ((SimpleImmutableEntry) mapEntries.next());
159 final String key = ((NodeIdentifier) e.getKey()).getNodeType().getLocalName();
161 assertTrue("Not allowed keyword", ALLOWED_KEYWORDS.contains(key));
164 case RestconfMappingNodeConstants.NAME:
165 loadedModule.setName((String) ((LeafNode) e.getValue()).getValue());
167 case RestconfMappingNodeConstants.NAMESPACE:
168 loadedModule.setNamespace((String) ((LeafNode) e.getValue()).getValue());
170 case RestconfMappingNodeConstants.REVISION:
171 loadedModule.setRevision((String) ((LeafNode) e.getValue()).getValue());
173 case RestconfMappingNodeConstants.FEATURE:
178 loadedModules.add(loadedModule);
181 verifyModules(getExpectedModulesBehindMountPoint(), loadedModules);
185 * Test getting the specific module supported by the server. Module name, revision, namespace and features are
186 * compared to have expected values.
189 public void getModuleTest() throws Exception {
191 final RestconfModulesService modulesService = setupNormal();
194 final NormalizedNodeContext nodeContext = modulesService.getModule(TEST_MODULE, null);
196 // verify loaded module
197 assertNotNull("Node context cannot be null", nodeContext);
198 final MapEntryNode node = ((MapNode) nodeContext.getData()).getValue().iterator().next();
199 final Iterator mapEntries = ((AbstractImmutableDataContainerAttrNode) node).getChildren().entrySet().iterator();
200 verifyModule("module1", "module:1", "2014-01-01", Collections.emptySet(), mapEntries);
204 * Test getting the specific module supported by the mount point.
207 public void getModuleMountPointTest() throws Exception {
209 final RestconfModulesService modulesService = setupNormalMountPoint();
211 // get test module schemaContextBehindMountPoint mount point
212 final NormalizedNodeContext nodeContext = modulesService.getModule(TEST_MODULE_BEHIND_MOUNT_POINT, null);
214 // verify loaded module
215 assertNotNull("Node context cannot be null", nodeContext);
216 final MapEntryNode node = ((MapNode) nodeContext.getData()).getValue().iterator().next();
217 final Iterator mapEntries = ((AbstractImmutableDataContainerAttrNode) node).getChildren().entrySet().iterator();
218 verifyModule("module1-behind-mount-point", "module:1:behind:mount:point", "2014-02-03",
219 Collections.emptySet(), mapEntries);
223 * Test getting all modules supported by the server if Restconf module is <code>null</code>. Test is expected to
224 * fail with <code>NullPointerException</code>.
227 public void getModulesWithoutRestconfModuleNegativeTest() throws Exception {
229 final RestconfModulesService modulesService = setupMissingRestconfModule();
232 this.thrown.expect(NullPointerException.class);
233 modulesService.getModules(null);
237 * Test getting all modules supported by the mount point if Restconf module is <code>null</code>. Test is expected
238 * to fail with <code>NullPointerException</code>.
241 public void getModulesWithoutRestconfModuleMountPointNegativeTest() throws Exception {
243 final RestconfModulesService modulesService = setupMissingRestconfModuleMountPoint();
246 this.thrown.expect(NullPointerException.class);
247 modulesService.getModules(MOUNT_POINT, null);
251 * Test getting all modules supported by the mount point with <code>null</code> value of
252 * identifier for mount point. Test is expected to fail with <code>NullPointerException</code>.
255 public void getModulesWithNullIdentifierOfMountPointNegativeTest() throws Exception {
257 final RestconfModulesService modulesService = setupNormalMountPoint();
260 this.thrown.expect(NullPointerException.class);
261 modulesService.getModules(null, null);
265 * Test getting all modules supported by the mount point if identifier does
266 * not contains {@link RestconfConstants#MOUNT}. Catching
267 * {@link RestconfDocumentedException} and testing error tyupe, error tag and error status code.
270 public void getModulesWithoutMountConstantInMountPointIdentifierNegativeTest() throws Exception {
272 final RestconfModulesService modulesService = setupNormalMountPoint();
275 modulesService.getModules(MOUNT_POINT.replace("/" + RestconfConstants.MOUNT + "/", ""), null);
276 fail("Test should fail due to missing " + RestconfConstants.MOUNT + " constant in mount point identifier");
277 } catch (final RestconfDocumentedException e) {
278 assertEquals("Error type is not correct", ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
279 assertEquals("Error tag is not correct", ErrorTag.INVALID_VALUE, e.getErrors().get(0).getErrorTag());
280 assertEquals("Error status code is not correct", 400, e.getErrors().get(0).getErrorTag().getStatusCode());
285 * Test getting all modules supported by the server when Restconf module does not contain node with name
286 * {@link RestconfModule#MODULES_CONTAINER_SCHEMA_NODE}. Test is expected to fail with
287 * <code>RestconfDocumentedException</code> and error type, error tag and error status code are compared to
291 public void getModulesRestconfModuleWithMissingContainerModulesNegativeTest() throws Exception {
293 final RestconfModulesService modulesService = setupCustomRestconfModule(
294 "restconf-module-with-missing-container-modules");
298 modulesService.getModules(null);
299 fail("Test should fail due to missing " + RestconfModule.MODULES_CONTAINER_SCHEMA_NODE
300 + " node in Restconf module");
301 } catch (final RestconfDocumentedException e) {
302 assertEquals("Error type is not correct", ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
303 assertEquals("Error tag is not correct", ErrorTag.DATA_MISSING, e.getErrors().get(0).getErrorTag());
304 assertEquals("Error status code is not correct", 404, e.getErrors().get(0).getErrorTag().getStatusCode());
309 * Test getting all modules supported by the server when Restconf module contains node with name
310 * {@link RestconfModule#MODULES_CONTAINER_SCHEMA_NODE} but it is not of type {@link ContainerSchemaNode}. Test is
311 * expected to fail with <code>IllegalStateException</code>.
314 public void getModulesRestconfModuleWithIllegalContainerModulesNegativeTest() throws Exception {
316 final RestconfModulesService modulesService = setupCustomRestconfModule(
317 "restconf-module-with-illegal-container-modules");
320 this.thrown.expect(IllegalStateException.class);
321 modulesService.getModules(null);
325 * Test getting all modules supported by the mount point when Restconf module does not contain node with name
326 * {@link RestconfModule#MODULES_CONTAINER_SCHEMA_NODE}. Test is expected to fail with
327 * <code>RestconfDocumentedException</code> and error type, error tag and error status code are compared to
331 public void getModulesRestconfModuleWithMissingContainerModulesMountPointNegativeTest() throws Exception {
333 final RestconfModulesService modulesService = setupCustomRestconfModuleMountPoint(
334 "restconf-module-with-missing-container-modules");
337 modulesService.getModules(MOUNT_POINT, null);
338 fail("Test should fail due to missing " + RestconfModule.MODULES_CONTAINER_SCHEMA_NODE
339 + " node in Restconf module");
340 } catch (final RestconfDocumentedException e) {
341 assertEquals("Error type is not correct", ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
342 assertEquals("Error tag is not correct", ErrorTag.DATA_MISSING, e.getErrors().get(0).getErrorTag());
343 assertEquals("Error status code is not correct", 404, e.getErrors().get(0).getErrorTag().getStatusCode());
348 * Test getting all modules supported by the mount point when Restconf module contains node with name
349 * {@link RestconfModule#MODULES_CONTAINER_SCHEMA_NODE} but it is not of type {@link ContainerSchemaNode}. Test
350 * is expected to fail with <code>IllegalStateException</code>.
353 public void getModulesRestconfModuleWithIllegalContainerModulesMountPointNegativeTest() throws Exception {
355 final RestconfModulesService modulesService = setupCustomRestconfModuleMountPoint(
356 "restconf-module-with-illegal-container-modules");
359 this.thrown.expect(IllegalStateException.class);
360 modulesService.getModules(MOUNT_POINT, null);
364 * Test of getting specific module supported by the server/mount point with <code>null</code> identifier. Test is
365 * expected to fail with <code>NullPointerException</code>.
368 public void getModuleWithNullIdentifierNegativeTest() throws Exception {
370 final RestconfModulesService modulesService = spy(new RestconfModulesServiceImpl(
371 mock(SchemaContextHandler.class),
372 mock(DOMMountPointServiceHandler.class)));
375 this.thrown.expect(NullPointerException.class);
376 modulesService.getModule(null, null);
380 * Testing getting specific module supported by the server with module identifier which
381 * does not exist in <code>SchemaContext</code>. Catching {@link RestconfDocumentedException}
382 * and testing error type, error tag and error status code.
385 public void getModuleNotExistModuleNegativeTest() throws Exception {
387 final RestconfModulesService modulesService = setupNormal();
391 modulesService.getModule(NOT_EXISTING_MODULE, null);
392 fail("Test should fail due to searching for not-existing module");
393 } catch (final RestconfDocumentedException e) {
394 assertEquals("Error type is not correct", ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
395 assertEquals("Error tag is not correct", ErrorTag.UNKNOWN_ELEMENT, e.getErrors().get(0).getErrorTag());
396 assertEquals("Error code is not correct", 400, e.getErrors().get(0).getErrorTag().getStatusCode());
401 * Testing getting specific module supported by the mount point with module identifier which
402 * does not exist in <code>SchemaContext</code>. Catching {@link RestconfDocumentedException}
403 * and testing error type, error tag and error status code.
406 public void getModuleNotExistModuleMountPointNegativeTest() throws Exception {
408 final RestconfModulesService modulesService = setupNormalMountPoint();
412 modulesService.getModule(NOT_EXISTING_MODULE_BEHIND_MOUNT_POINT, null);
413 fail("Test should fail due to searching for not-existing module");
414 } catch (final RestconfDocumentedException e) {
415 assertEquals("Error type is not correct", ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
416 assertEquals("Error tag is not correct", ErrorTag.UNKNOWN_ELEMENT, e.getErrors().get(0).getErrorTag());
417 assertEquals("Error code is not correct", 400, e.getErrors().get(0).getErrorTag().getStatusCode());
422 * Test getting specific module supported by the server when Restconf module is null. Test is expected to fail
423 * with <code>NullPointerException</code>.
426 public void getModuleWithoutRestconfModuleNegativeTest() throws Exception {
427 // prepare conditions
428 final RestconfModulesService modulesService = setupMissingRestconfModule();
430 this.thrown.expect(NullPointerException.class);
431 modulesService.getModule(TEST_MODULE, null);
435 * Test getting specific module supported by the mount point when Restconf module is null. Test is expected to fail
436 * with <code>NullPointerException</code>.
439 public void getModuleWithoutRestconfModuleMountPointNegativeTest() throws Exception {
440 // prepare conditions
441 final RestconfModulesService modulesService = setupMissingRestconfModuleMountPoint();
443 this.thrown.expect(NullPointerException.class);
444 modulesService.getModule(TEST_MODULE_BEHIND_MOUNT_POINT, null);
448 * Test getting specific module supported by the server when Restconf module does not contain node with
449 * name {@link RestconfModule#MODULE_LIST_SCHEMA_NODE}. Test is expected to fail with
450 * <code>RestconfDocumentedException</code> and error type, error tag and error status code are compared to
454 public void getModuleRestconfModuleWithMissingListModuleNegativeTest() throws Exception {
456 final RestconfModulesService modulesService =
457 setupCustomRestconfModule("restconf-module-with-missing-list-module");
461 modulesService.getModule(TEST_MODULE, null);
462 fail("Test should fail due to missing " + RestconfModule.MODULE_LIST_SCHEMA_NODE
463 + " node in Restconf module");
464 } catch (final RestconfDocumentedException e) {
465 assertEquals("Error type is not correct", ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
466 assertEquals("Error tag is not correct", ErrorTag.DATA_MISSING, e.getErrors().get(0).getErrorTag());
467 assertEquals("Error code is not correct", 404, e.getErrors().get(0).getErrorTag().getStatusCode());
472 * Test getting specific module supported by the server when Restconf module contains node with name
473 * {@link RestconfModule#MODULE_LIST_SCHEMA_NODE} but it is not of type {@link ListSchemaNode}. Test is expected
474 * to fail with <code>IllegalStateException</code>.
477 public void getModuleRestconfModuleWitIllegalListSchemaNodeNegativeTest() throws Exception {
479 final RestconfModulesService modulesService = setupCustomRestconfModule(
480 "restconf-module-with-illegal-list-module");
483 this.thrown.expect(IllegalStateException.class);
484 modulesService.getModule(TEST_MODULE, null);
488 * Test getting specific module supported by the mount point when Restconf module does not contain node with
489 * name {@link RestconfModule#MODULE_LIST_SCHEMA_NODE}. Test is expected to fail with
490 * <code>RestconfDocumentedException</code> and error type, error tag and error status code are compared to
494 public void getModuleRestconfModuleWithMissingListModuleMountPointNegativeTest() throws Exception {
496 final RestconfModulesService modulesService =
497 setupCustomRestconfModuleMountPoint("restconf-module-with-missing-list-module");
501 modulesService.getModule(TEST_MODULE_BEHIND_MOUNT_POINT, null);
502 fail("Test should fail due to missing " + RestconfModule.MODULE_LIST_SCHEMA_NODE
503 + " node in Restconf module");
504 } catch (final RestconfDocumentedException e) {
505 assertEquals("Error type is not correct", ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
506 assertEquals("Error tag is not correct", ErrorTag.DATA_MISSING, e.getErrors().get(0).getErrorTag());
507 assertEquals("Error code is not correct", 404, e.getErrors().get(0).getErrorTag().getStatusCode());
512 * Test getting specific module supported by the mount point when Restconf module contains node with name
513 * {@link RestconfModule#MODULE_LIST_SCHEMA_NODE} but it is not of type {@link ListSchemaNode}. Test is expected
514 * to fail with <code>IllegalStateException</code>.
517 public void getModuleRestconfModuleWitIllegalListModuleMountPointNegativeTest() throws Exception {
519 final RestconfModulesService modulesService = setupCustomRestconfModuleMountPoint(
520 "restconf-module-with-illegal-list-module");
523 this.thrown.expect(IllegalStateException.class);
524 modulesService.getModule(TEST_MODULE_BEHIND_MOUNT_POINT, null);
528 * Negative test of specific module supported by the mount point when <code>DOMMountPointServiceHandler</code>
529 * contains <code>null</code> reference to <code>DOMMountPointService</code>. Test is expected to fail with
530 * <code>NullPointerException</code>.
533 public void getModuleMissingMountPointServiceNegativeTest() throws Exception {
534 // prepare conditions
535 final RestconfModulesService modulesService = setupNullMountPointService();
538 this.thrown.expect(NullPointerException.class);
539 modulesService.getModule(TEST_MODULE_BEHIND_MOUNT_POINT, null);
543 * Negative test of getting all modules supported by the mount point when <code>DOMMountPointServiceHandler</code>
544 * contains <code>null</code> reference to <code>DOMMountPointService</code>. Test is expected to fail with
545 * <code>NullPointerException</code>.
548 public void getModulesMissingMountPointServiceNegativeTest() throws Exception {
549 // prepare conditions
550 final RestconfModulesService modulesService = setupNullMountPointService();
553 this.thrown.expect(NullPointerException.class);
554 modulesService.getModules(MOUNT_POINT, null);
558 * Negative test of getting specific module supported by the mount point when specified mount point is not found
559 * (it is not registered in <code>DOMMountPointService</code>). Test is expected to fail with
560 * <code>RestconfDocumentedException</code> and error type, error tag and error status code are compared to
564 public void getModuleMountPointNotFoundNegativeTest() throws Exception {
565 // prepare conditions
566 final RestconfModulesService modulesService = setupNormalMountPoint();
570 modulesService.getModule(TEST_MODULE_BEHIND_NOT_REGISTERED_MOUNT_POINT, null);
571 fail("Test should fail due to missing mount point");
572 } catch (final RestconfDocumentedException e) {
573 assertEquals("Error type is not correct", ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
574 assertEquals("Error tag is not correct", ErrorTag.DATA_MISSING, e.getErrors().get(0).getErrorTag());
575 assertEquals("Error code is not correct", 404, e.getErrors().get(0).getErrorTag().getStatusCode());
580 * Negative test of getting all modules supported by the mount point when specified mount point is not found (it
581 * is not registered in <code>DOMMountPointService</code>). Test is expected to fail with
582 * <code>RestconfDocumentedException</code> and error type, error tag and error status code are compared to
586 public void getModulesMountPointNotFoundNegativeTest() throws Exception {
587 // prepare conditions
588 final RestconfModulesService modulesService = setupNormalMountPoint();
592 modulesService.getModules(NOT_REGISTERED_MOUNT_POINT, null);
593 fail("Test should fail due to missing mount point");
594 } catch (final RestconfDocumentedException e) {
595 assertEquals("Error type is not correct", ErrorType.PROTOCOL, e.getErrors().get(0).getErrorType());
596 assertEquals("Error tag is not correct", ErrorTag.DATA_MISSING, e.getErrors().get(0).getErrorTag());
597 assertEquals("Error code is not correct", 404, e.getErrors().get(0).getErrorTag().getStatusCode());