summaryrefslogtreecommitdiffstats
path: root/vpp-common/vpp-translate-utils/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'vpp-common/vpp-translate-utils/src/test')
-rw-r--r--vpp-common/vpp-translate-utils/src/test/java/io/fd/hc2vpp/common/translate/util/NamingContextTest.java25
1 files changed, 20 insertions, 5 deletions
diff --git a/vpp-common/vpp-translate-utils/src/test/java/io/fd/hc2vpp/common/translate/util/NamingContextTest.java b/vpp-common/vpp-translate-utils/src/test/java/io/fd/hc2vpp/common/translate/util/NamingContextTest.java
index 1fe4da50a..df561c737 100644
--- a/vpp-common/vpp-translate-utils/src/test/java/io/fd/hc2vpp/common/translate/util/NamingContextTest.java
+++ b/vpp-common/vpp-translate-utils/src/test/java/io/fd/hc2vpp/common/translate/util/NamingContextTest.java
@@ -96,16 +96,31 @@ public class NamingContextTest implements InjectablesProcessor {
}
@Test
- public void addNameNextIndex() throws Exception {
+ public void addName() throws Exception {
namingContext.addName("name-3", mappingContext);
verify(mappingContext, times(1))
- .put(instanceIdentifierArgumentCaptor.capture(), mappingArgumentCaptor.capture());
+ .put(instanceIdentifierArgumentCaptor.capture(), mappingArgumentCaptor.capture());
assertEquals(instanceIdentifierArgumentCaptor.getValue(), parentKey("name-3"));
assertEquals(mappingArgumentCaptor.getValue(), new MappingBuilder()
- .setIndex(3)
- .setName("name-3")
- .build());
+ .setIndex(3)
+ .setName("name-3")
+ .build());
+ }
+
+ @Test
+ public void addNameNoMapings() throws Exception {
+ when(mappingContext.read(namingContextIid.child(Mappings.class))).thenReturn(Optional.absent());
+
+ namingContext.addName("name-0", mappingContext);
+ verify(mappingContext, times(1))
+ .put(instanceIdentifierArgumentCaptor.capture(), mappingArgumentCaptor.capture());
+
+ assertEquals(instanceIdentifierArgumentCaptor.getValue(), parentKey("name-0"));
+ assertEquals(mappingArgumentCaptor.getValue(), new MappingBuilder()
+ .setIndex(0)
+ .setName("name-0")
+ .build());
}
@Test(expected = IllegalArgumentException.class)