"multiple-items-yang:lst");
assertNotNull(normalizedNodeContext);
- assertEquals("lst", normalizedNodeContext.getData().getNodeType()
- .getLocalName());
+ assertEquals("lst", normalizedNodeContext.getData().getIdentifier().getNodeType().getLocalName());
verityMultipleItemsInList(normalizedNodeContext);
}
"/json-to-nn/array-with-null.json", "array-with-null-yang:cont");
assertNotNull(normalizedNodeContext);
- assertEquals("cont", normalizedNodeContext.getData().getNodeType()
- .getLocalName());
+ assertEquals("cont", normalizedNodeContext.getData().getIdentifier().getNodeType().getLocalName());
- final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
- .getData());
+ final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext.getData());
assertTrue(dataTree.contains("lf"));
assertTrue(dataTree.contains("empty"));
}
"/json-to-nn/empty-data.json", "array-with-null-yang:cont");
assertNotNull(normalizedNodeContext);
- assertEquals("cont", normalizedNodeContext.getData().getNodeType()
- .getLocalName());
+ assertEquals("cont", normalizedNodeContext.getData().getIdentifier().getNodeType().getLocalName());
- final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
- .getData());
+ final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext.getData());
assertTrue(dataTree.contains("lflst1"));
RestconfDocumentedException exception = null;
mockBodyReader("array-with-null-yang:cont", this.jsonBodyReader, false);
- final InputStream inputStream = this.getClass().getResourceAsStream(
- "/json-to-nn/empty-data.json1");
+ final InputStream inputStream = this.getClass().getResourceAsStream("/json-to-nn/empty-data.json1");
try {
- this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null,
- inputStream);
+ this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null,inputStream);
} catch (final RestconfDocumentedException e) {
exception = e;
}
assertNotNull(exception);
- assertEquals("Error parsing input: null", exception.getErrors().get(0)
- .getErrorMessage());
+ assertEquals("Error parsing input: null", exception.getErrors().get(0).getErrorMessage());
}
@Test
public void testJsonBlankInput() throws Exception {
- final NormalizedNodeContext normalizedNodeContext = prepareNNC("",
- "array-with-null-yang:cont");
+ final NormalizedNodeContext normalizedNodeContext = prepareNNC("", "array-with-null-yang:cont");
assertNull(normalizedNodeContext);
}
public void notSupplyNamespaceIfAlreadySupplied()throws Exception {
final String uri = "simple-list-yang1" + ":" + "lst";
- final NormalizedNodeContext normalizedNodeContext = prepareNNC(
- "/json-to-nn/simple-list.json", uri);
+ final NormalizedNodeContext normalizedNodeContext = prepareNNC("/json-to-nn/simple-list.json", uri);
assertNotNull(normalizedNodeContext);
verifyNormaluizedNodeContext(normalizedNodeContext, "lst");
mockBodyReader("simple-list-yang2:lst", this.jsonBodyReader, false);
- final InputStream inputStream = this.getClass().getResourceAsStream(
- "/json-to-nn/simple-list.json");
+ final InputStream inputStream = this.getClass().getResourceAsStream("/json-to-nn/simple-list.json");
try {
- this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null,
- inputStream);
+ this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
fail("NormalizedNodeContext should not be create because of different namespace");
} catch (final RestconfDocumentedException e) {
LOG.warn("Read from InputStream failed. Message: {}. Status: {}", e.getMessage(), e.getStatus());
@Test
public void dataAugmentedTest() throws Exception {
- NormalizedNodeContext normalizedNodeContext = prepareNNC(
- "/common/augment/json/dataa.json", "main:cont");
+ NormalizedNodeContext normalizedNodeContext = prepareNNC("/common/augment/json/dataa.json", "main:cont");
assertNotNull(normalizedNodeContext);
- assertEquals("cont", normalizedNodeContext.getData().getNodeType()
- .getLocalName());
+ assertEquals("cont", normalizedNodeContext.getData().getIdentifier().getNodeType().getLocalName());
String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
.getData());
assertTrue(dataTree.contains("cont1"));
assertTrue(dataTree.contains("lf11 lf11 value from a"));
- normalizedNodeContext = prepareNNC("/common/augment/json/datab.json",
- "main:cont");
+ normalizedNodeContext = prepareNNC("/common/augment/json/datab.json", "main:cont");
assertNotNull(normalizedNodeContext);
- assertEquals("cont", normalizedNodeContext.getData().getNodeType()
- .getLocalName());
- dataTree = NormalizedNodes
- .toStringTree(normalizedNodeContext.getData());
+ assertEquals("cont", normalizedNodeContext.getData().getIdentifier().getNodeType().getLocalName());
+ dataTree = NormalizedNodes.toStringTree(normalizedNodeContext.getData());
assertTrue(dataTree.contains("cont1"));
assertTrue(dataTree.contains("lf11 lf11 value from b"));
}
private NormalizedNodeContext prepareNNC(final String jsonPath, final String uri) throws Exception {
try {
mockBodyReader(uri, this.jsonBodyReader, false);
- } catch (NoSuchFieldException | SecurityException
- | IllegalArgumentException | IllegalAccessException e) {
+ } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
LOG.warn("Operation failed due to: {}", e.getMessage());
}
final InputStream inputStream = this.getClass().getResourceAsStream(jsonPath);
NormalizedNodeContext normalizedNodeContext = null;
try {
- normalizedNodeContext = this.jsonBodyReader.readFrom(null, null, null,
- this.mediaType, null, inputStream);
+ normalizedNodeContext = this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
} catch (WebApplicationException e) {
// TODO Auto-generated catch block
}
private static void verifyNormaluizedNodeContext(final NormalizedNodeContext normalizedNodeContext,
final String topLevelElementName) {
- assertEquals(topLevelElementName, normalizedNodeContext.getData()
- .getNodeType().getLocalName());
+ assertEquals(topLevelElementName, normalizedNodeContext.getData().getIdentifier().getNodeType().getLocalName());
- final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
- .getData());
+ final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext.getData());
assertTrue(dataTree.contains("cont1"));
assertTrue(dataTree.contains("lst1"));
assertTrue(dataTree.contains("lflst1"));
}
private static void verityMultipleItemsInList(final NormalizedNodeContext normalizedNodeContext) {
-
- final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
- .getData());
+ final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext.getData());
assertTrue(dataTree.contains("lf11"));
assertTrue(dataTree.contains("lf11_1"));
assertTrue(dataTree.contains("lflst11"));
public void unsupportedDataFormatTest() throws Exception {
mockBodyReader("simple-list-yang1:lst", this.jsonBodyReader, false);
- final InputStream inputStream = this.getClass().getResourceAsStream(
- "/json-to-nn/unsupported-json-format.json");
+ final InputStream inputStream = this.getClass().getResourceAsStream("/json-to-nn/unsupported-json-format.json");
RestconfDocumentedException exception = null;
try {
- this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null,
- inputStream);
+ this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
} catch (final RestconfDocumentedException e) {
exception = e;
}
LOG.info(exception.getErrors().get(0).getErrorMessage());
- assertTrue(exception.getErrors().get(0).getErrorMessage()
- .contains("is not a simple type"));
+ assertTrue(exception.getErrors().get(0).getErrorMessage().contains("is not a simple type"));
}
@Test
null, null, null, this.mediaType, null, inputStream);
assertNotNull(normalizedNodeContext);
- assertEquals("cont", normalizedNodeContext.getData().getNodeType()
- .getLocalName());
+ assertEquals("cont", normalizedNodeContext.getData().getIdentifier().getNodeType().getLocalName());
- final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext
- .getData());
+ final String dataTree = NormalizedNodes.toStringTree(normalizedNodeContext.getData());
assertTrue(dataTree.contains("lf1 module<Name:value lf1"));
assertTrue(dataTree.contains("lf2 module>Name:value lf2"));
}