summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/test/java/io/fd
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-05-13 10:04:11 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-05-17 17:13:08 +0200
commit02b2183a113214039611373f84352da4a5f57e2c (patch)
tree8091ad507e54de75366698c0860be9a0d7980d9b /v3po/v3po2vpp/src/test/java/io/fd
parent7ebd4ac29fb72b80af0b481f8ea604085ded1bc8 (diff)
Check expected interface type in sub-Interface nodes
+ Pass full WriteContext to the write customizers, making them more flexible Change-Id: I75c55aed02f9300eee20eabb4a3e84e294ed1e0f Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/test/java/io/fd')
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceTypeTestUtils.java39
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizerTest.java19
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizerTest.java20
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java18
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizerTest.java6
5 files changed, 75 insertions, 27 deletions
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceTypeTestUtils.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceTypeTestUtils.java
new file mode 100644
index 000000000..ff96131b1
--- /dev/null
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/InterfaceTypeTestUtils.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.v3po.translate.v3po.interfaces;
+
+import static org.mockito.Mockito.doReturn;
+
+import com.google.common.base.Optional;
+import io.fd.honeycomb.v3po.translate.Context;
+import io.fd.honeycomb.v3po.translate.write.WriteContext;
+import org.mockito.Matchers;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+final class InterfaceTypeTestUtils {
+
+ private InterfaceTypeTestUtils() {}
+
+ static void setupWriteContext(final WriteContext writeContext, final Class<? extends InterfaceType> ifcType) {
+ doReturn(new Context()).when(writeContext).getContext();
+ doReturn(Optional.of(new InterfaceBuilder()
+ .setType(ifcType)
+ .build())).when(writeContext).readAfter(Matchers.any(InstanceIdentifier.class));
+ }
+}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizerTest.java
index 668eed4cf..8ae04f017 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/TapCustomizerTest.java
@@ -24,8 +24,8 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import io.fd.honeycomb.v3po.translate.Context;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.v3po.translate.write.WriteContext;
import java.util.concurrent.CompletableFuture;
import org.junit.Before;
import org.junit.Test;
@@ -53,12 +53,17 @@ public class TapCustomizerTest {
@Mock
private FutureJVpp vppApi;
+ @Mock
+ private WriteContext writeContext;
+
private NamingContext ctx;
private TapCustomizer tapCustomizer;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
+ InterfaceTypeTestUtils.setupWriteContext(writeContext,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap.class);
ctx = new NamingContext("ifcintest");
tapCustomizer = new TapCustomizer(vppApi, ctx);
}
@@ -80,8 +85,8 @@ public class TapCustomizerTest {
}
}).when(vppApi).tapConnect(any(TapConnect.class));
- tapCustomizer.writeCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), new Context());
- tapCustomizer.writeCurrentAttributes(getTapId("tap2"), getTapData("tap2", "ff:ff:ff:ff:ff:ff"), new Context());
+ tapCustomizer.writeCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), writeContext);
+ tapCustomizer.writeCurrentAttributes(getTapId("tap2"), getTapData("tap2", "ff:ff:ff:ff:ff:ff"), writeContext);
verify(vppApi, times(2)).tapConnect(any(TapConnect.class));
assertTrue(ctx.containsIndex("tap"));
@@ -103,8 +108,8 @@ public class TapCustomizerTest {
replyModif.complete(tmodif);
doReturn(replyModif).when(vppApi).tapModify(any(TapModify.class));
- tapCustomizer.writeCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), new Context());
- tapCustomizer.updateCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), getTapData("tap", "ff:ff:ff:ff:ff:f1"), new Context());
+ tapCustomizer.writeCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), writeContext);
+ tapCustomizer.updateCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), getTapData("tap", "ff:ff:ff:ff:ff:f1"), writeContext);
verify(vppApi).tapConnect(any(TapConnect.class));
verify(vppApi).tapModify(any(TapModify.class));
@@ -126,8 +131,8 @@ public class TapCustomizerTest {
replyDelete.complete(tmodif);
doReturn(replyDelete).when(vppApi).tapDelete(any(TapDelete.class));
- tapCustomizer.writeCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), new Context());
- tapCustomizer.deleteCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), new Context());
+ tapCustomizer.writeCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), writeContext);
+ tapCustomizer.deleteCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), writeContext);
verify(vppApi).tapConnect(any(TapConnect.class));
verify(vppApi).tapDelete(any(TapDelete.class));
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizerTest.java
index 076df6783..15b2a75c1 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VhostUserCustomizerTest.java
@@ -29,10 +29,10 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
-import io.fd.honeycomb.v3po.translate.Context;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
import io.fd.honeycomb.v3po.translate.v3po.utils.V3poUtils;
+import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
@@ -62,7 +62,7 @@ public class VhostUserCustomizerTest {
@Mock
private FutureJVpp api;
@Mock
- private Context ctx;
+ private WriteContext writeContext;
private NamingContext namingContext;
private VhostUserCustomizer customizer;
@@ -75,6 +75,8 @@ public class VhostUserCustomizerTest {
@Before
public void setUp() throws Exception {
initMocks(this);
+ InterfaceTypeTestUtils.setupWriteContext(writeContext,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser.class);
namingContext = new NamingContext("generatedInterfaceName");
// TODO create base class for tests using vppApi
customizer = new VhostUserCustomizer(api, namingContext);
@@ -182,7 +184,7 @@ public class VhostUserCustomizerTest {
whenCreateVhostUserIfThenSuccess();
- customizer.writeCurrentAttributes(ID, vhostUser, ctx);
+ customizer.writeCurrentAttributes(ID, vhostUser, writeContext);
verifyCreateVhostUserIfWasInvoked(vhostUser);
assertTrue(namingContext.containsIndex(IFACE_NAME));
}
@@ -194,7 +196,7 @@ public class VhostUserCustomizerTest {
whenVxlanAddDelTunnelThenFailure();
try {
- customizer.writeCurrentAttributes(ID, vhostUser, ctx);
+ customizer.writeCurrentAttributes(ID, vhostUser, writeContext);
} catch (WriteFailedException.CreateFailedException e) {
assertEquals(VppApiInvocationException.class, e.getCause().getClass());
verifyCreateVhostUserIfWasInvoked(vhostUser);
@@ -212,7 +214,7 @@ public class VhostUserCustomizerTest {
whenModifyVhostUserIfThenSuccess();
- customizer.updateCurrentAttributes(ID, vhostUserBefore, vhostUserAfter, ctx);
+ customizer.updateCurrentAttributes(ID, vhostUserBefore, vhostUserAfter, writeContext);
verifyModifyVhostUserIfWasInvoked(vhostUserAfter, IFACE_ID);
}
@@ -220,7 +222,7 @@ public class VhostUserCustomizerTest {
public void testUpdateCurrentAttributesNoUpdate() throws Exception {
final VhostUser vhostUserBefore = generateVhostUser(VhostUserRole.Server, "socketName");
final VhostUser vhostUserAfter = generateVhostUser(VhostUserRole.Server, "socketName");
- customizer.updateCurrentAttributes(ID, vhostUserBefore, vhostUserAfter, ctx);
+ customizer.updateCurrentAttributes(ID, vhostUserBefore, vhostUserAfter, writeContext);
verify(api, never()).modifyVhostUserIf(any(ModifyVhostUserIf.class));
}
@@ -233,7 +235,7 @@ public class VhostUserCustomizerTest {
whenModifyVhostUserIfThenFailure();
try {
- customizer.updateCurrentAttributes(ID, vhostUserBefore, vhostUserAfter, ctx);
+ customizer.updateCurrentAttributes(ID, vhostUserBefore, vhostUserAfter, writeContext);
} catch (WriteFailedException.UpdateFailedException e) {
assertEquals(VppApiInvocationException.class, e.getCause().getClass());
verifyModifyVhostUserIfWasInvoked(vhostUserAfter, IFACE_ID);
@@ -249,7 +251,7 @@ public class VhostUserCustomizerTest {
whenDeleteVhostUserIfThenSuccess();
- customizer.deleteCurrentAttributes(ID, vhostUser, ctx);
+ customizer.deleteCurrentAttributes(ID, vhostUser, writeContext);
verifyDeleteVhostUserIfWasInvoked(IFACE_ID);
assertFalse(namingContext.containsIndex(IFACE_NAME));
}
@@ -262,7 +264,7 @@ public class VhostUserCustomizerTest {
whenDeleteVhostUserIfThenFailure();
try {
- customizer.deleteCurrentAttributes(ID, vhostUser, ctx);
+ customizer.deleteCurrentAttributes(ID, vhostUser, writeContext);
} catch (WriteFailedException.DeleteFailedException e) {
assertEquals(VppApiInvocationException.class, e.getCause().getClass());
verifyDeleteVhostUserIfWasInvoked(IFACE_ID);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java
index a599d7565..af7b4df17 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/interfaces/VxlanCustomizerTest.java
@@ -29,9 +29,9 @@ import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.net.InetAddresses;
-import io.fd.honeycomb.v3po.translate.Context;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
import io.fd.honeycomb.v3po.translate.v3po.util.VppApiInvocationException;
+import io.fd.honeycomb.v3po.translate.write.WriteContext;
import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
@@ -62,7 +62,7 @@ public class VxlanCustomizerTest {
@Mock
private FutureJVpp api;
@Mock
- private Context ctx;
+ private WriteContext writeContext;
private VxlanCustomizer customizer;
private NamingContext namingContext;
@@ -72,6 +72,8 @@ public class VxlanCustomizerTest {
@Before
public void setUp() throws Exception {
initMocks(this);
+ InterfaceTypeTestUtils.setupWriteContext(writeContext,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanTunnel.class);
// TODO create base class for tests using vppApi
namingContext = new NamingContext("generateInterfaceNAme");
customizer = new VxlanCustomizer(api, namingContext);
@@ -140,7 +142,7 @@ public class VxlanCustomizerTest {
whenVxlanAddDelTunnelThenSuccess();
- customizer.writeCurrentAttributes(id, vxlan, ctx);
+ customizer.writeCurrentAttributes(id, vxlan, writeContext);
verifyVxlanAddWasInvoked(vxlan);
assertTrue(namingContext.containsIndex(ifaceName));
}
@@ -152,7 +154,7 @@ public class VxlanCustomizerTest {
whenVxlanAddDelTunnelThenFailure();
try {
- customizer.writeCurrentAttributes(id, vxlan, ctx);
+ customizer.writeCurrentAttributes(id, vxlan, writeContext);
} catch (WriteFailedException.CreateFailedException e) {
assertEquals(VppApiInvocationException.class, e.getCause().getClass());
verifyVxlanAddWasInvoked(vxlan);
@@ -165,7 +167,7 @@ public class VxlanCustomizerTest {
@Test
public void testUpdateCurrentAttributes() throws Exception {
try {
- customizer.updateCurrentAttributes(id, generateVxlan(10), generateVxlan(11), ctx);
+ customizer.updateCurrentAttributes(id, generateVxlan(10), generateVxlan(11), writeContext);
} catch (WriteFailedException.UpdateFailedException e) {
assertEquals(UnsupportedOperationException.class, e.getCause().getClass());
return;
@@ -175,7 +177,7 @@ public class VxlanCustomizerTest {
@Test
public void testUpdateCurrentAttributesNoUpdate() throws Exception {
- customizer.updateCurrentAttributes(id, generateVxlan(), generateVxlan(), ctx);
+ customizer.updateCurrentAttributes(id, generateVxlan(), generateVxlan(), writeContext);
verify(api, never()).vxlanAddDelTunnel(any(VxlanAddDelTunnel.class));
}
@@ -186,7 +188,7 @@ public class VxlanCustomizerTest {
whenVxlanAddDelTunnelThenSuccess();
namingContext.addName(1, ifaceName);
- customizer.deleteCurrentAttributes(id, vxlan, ctx);
+ customizer.deleteCurrentAttributes(id, vxlan, writeContext);
verifyVxlanDeleteWasInvoked(vxlan);
assertFalse(namingContext.containsIndex(ifaceName));
}
@@ -199,7 +201,7 @@ public class VxlanCustomizerTest {
namingContext.addName(1, ifaceName);
try {
- customizer.deleteCurrentAttributes(id, vxlan, ctx);
+ customizer.deleteCurrentAttributes(id, vxlan, writeContext);
} catch (WriteFailedException.DeleteFailedException e) {
assertEquals(VppApiInvocationException.class, e.getCause().getClass());
verifyVxlanDeleteWasInvoked(vxlan);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizerTest.java
index 6e449070f..f5b19a7be 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vpp/BridgeDomainCustomizerTest.java
@@ -24,9 +24,9 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
-import io.fd.honeycomb.v3po.translate.Context;
-import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.v3po.translate.write.WriteContext;
+import io.fd.honeycomb.v3po.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
@@ -49,7 +49,7 @@ public class BridgeDomainCustomizerTest {
private FutureJVpp api;
@Mock
- private Context ctx;
+ private WriteContext ctx;
private BridgeDomainCustomizer customizer;
private NamingContext namingContext;