summaryrefslogtreecommitdiffstats
path: root/vpp-common/vpp-translate-utils/src/test/java/io/fd
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:52 +0000
commit594d4f62ec8684e61314bce6e042cf3910e77e4e (patch)
tree6ec4818d67341d94a869843e58d27a68383a2e6d /vpp-common/vpp-translate-utils/src/test/java/io/fd
parent8931ab48b5ff8684aa56372c883ff660f13ec719 (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> (cherry picked from commit 4840c9fc6ab956d6210ac33d8e9c5b1abbc4172e)
Diffstat (limited to 'vpp-common/vpp-translate-utils/src/test/java/io/fd')
-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)