summaryrefslogtreecommitdiffstats
path: root/infra/data-impl/src/test/java
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-10-05 15:03:33 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-10-14 05:42:54 +0000
commit0c5820220a4e7ebc3245259085d00551d2687e32 (patch)
treea36bee0753035be5d68f97130bf016feaeb9d2c0 /infra/data-impl/src/test/java
parentc54ae4ac74d6b8ab71c7e166f10ca6b080ffa558 (diff)
HONEYCOMB-229 Introduce NAT to HC
Reflects SNAT from VPP: - 1:1 Static IPv4 mapping - interface in/out NAT feature management Bonus: - Support presence containers in infra Change-Id: Ieb38526f83edbae5e605d5c7e39bb22bbafc50e5 Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'infra/data-impl/src/test/java')
-rw-r--r--infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModificationDiffTest.java32
1 files changed, 30 insertions, 2 deletions
diff --git a/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModificationDiffTest.java b/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModificationDiffTest.java
index 2fa82043b..cc00f2dc6 100644
--- a/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModificationDiffTest.java
+++ b/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/ModificationDiffTest.java
@@ -1,9 +1,12 @@
package io.fd.honeycomb.data.impl;
+import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.hasItems;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import com.google.common.base.Optional;
import java.util.Map;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
@@ -45,10 +48,11 @@ public class ModificationDiffTest {
static final QName IN_CASE1_LEAF_QNAME = QName.create(WITH_CHOICE_CONTAINER_QNAME, "in-case1");
static final QName IN_CASE2_LEAF_QNAME = QName.create(WITH_CHOICE_CONTAINER_QNAME, "in-case2");
+ static final QName PRESENCE_CONTAINER_QNAME = QName.create(TOP_CONTAINER_QNAME, "presence");
+
static final YangInstanceIdentifier TOP_CONTAINER_ID = YangInstanceIdentifier.of(TOP_CONTAINER_QNAME);
static final YangInstanceIdentifier NESTED_LIST_ID = TOP_CONTAINER_ID.node(new YangInstanceIdentifier.NodeIdentifier(NESTED_LIST_QNAME));
-
@Test
public void testInitialWrite() throws Exception {
final TipProducingDataTree dataTree = getDataTree();
@@ -66,6 +70,30 @@ public class ModificationDiffTest {
}
@Test
+ public void testWritePresenceEmptyContainer() throws Exception {
+ final TipProducingDataTree dataTree = getDataTree();
+ final DataTreeModification dataTreeModification = getModification(dataTree);
+ final NormalizedNode<?, ?> presenceContainer = Builders.containerBuilder()
+ .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(PRESENCE_CONTAINER_QNAME))
+ .build();
+ final YangInstanceIdentifier PRESENCE_CONTAINER_ID = YangInstanceIdentifier.of(PRESENCE_CONTAINER_QNAME);
+ dataTreeModification.write(PRESENCE_CONTAINER_ID, presenceContainer);
+ final DataTreeCandidateTip prepare = prepareModification(dataTree, dataTreeModification);
+
+ final ModificationDiff modificationDiff = getModificationDiff(prepare);
+
+ dataTree.commit(prepare);
+
+ final Optional<NormalizedNode<?, ?>> presenceAfter = getModification(dataTree).readNode(PRESENCE_CONTAINER_ID);
+ assertTrue(presenceAfter.isPresent());
+ assertThat(presenceAfter.get(), equalTo(presenceContainer));
+
+ assertThat(modificationDiff.getUpdates().size(), is(1));
+ assertThat(modificationDiff.getUpdates().values().size(), is(1));
+ assertUpdate(modificationDiff.getUpdates().values().iterator().next(), PRESENCE_CONTAINER_ID, null, presenceContainer);
+ }
+
+ @Test
public void testInitialWriteForContainerWithChoice() throws Exception {
final TipProducingDataTree dataTree = getDataTree();
final DataTreeModification dataTreeModification = getModification(dataTree);
@@ -132,7 +160,7 @@ public class ModificationDiffTest {
}
private ModificationDiff getModificationDiff(final DataTreeCandidateTip prepare) {
- return ModificationDiff.recursivelyFromCandidate(YangInstanceIdentifier.EMPTY, prepare.getRootNode());
+ return ModificationDiff.recursivelyFromCandidateRoot(prepare.getRootNode());
}
@Test