summaryrefslogtreecommitdiffstats
path: root/vpp-common/vpp-translate-utils/src/test
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-12-13 17:15:53 +0100
committerMarek Gradzki <mgradzki@cisco.com>2017-12-13 16:45:04 +0000
commit4840c9fc6ab956d6210ac33d8e9c5b1abbc4172e (patch)
treeed12e09ac706e3c172a3a948a1528e173718d153 /vpp-common/vpp-translate-utils/src/test
parent938e017b9a471c078a3bbc2213b4638315b2f8df (diff)
(Multi)NamingContext: increment after computing max
Instead of incrementing all elements of stream and applying max, first compute max and then increment. Change-Id: I4e45ffa74d9b8685abd7bafaddc77d1d9850abdb Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
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)