summaryrefslogtreecommitdiffstats
path: root/v3po/impl/src/test/java
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-04-12 10:13:06 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-04-12 10:13:06 +0200
commit4a3dce3e0e59df4e091b4f8d4efc3e20831bf22f (patch)
treeba355a04f76692df51ab0fabba612e15ae3f49b5 /v3po/impl/src/test/java
parent5947a575539402344e450fd34b03f555b84523be (diff)
HONEYCOMB-9: Add Read context
Change-Id: I42179d5c7244bfe4c62ee1efffad414a1cfe4b0b Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'v3po/impl/src/test/java')
-rw-r--r--v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTreeTest.java18
-rw-r--r--v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/vppstate/VppStateTest.java31
2 files changed, 29 insertions, 20 deletions
diff --git a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTreeTest.java b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTreeTest.java
index 8939f8f52..493a01912 100644
--- a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTreeTest.java
+++ b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTreeTest.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.same;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
@@ -33,6 +34,7 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.util.concurrent.CheckedFuture;
+import io.fd.honeycomb.v3po.impl.trans.r.ReadContext;
import io.fd.honeycomb.v3po.impl.trans.r.ReaderRegistry;
import java.util.Map;
import org.junit.Before;
@@ -68,6 +70,8 @@ public class VppOperationalDataTreeTest {
private SchemaContext globalContext;
@Mock
private DataSchemaNode schemaNode;
+ @Mock
+ private ReadContext readCtx;
@Before
public void setUp() {
@@ -86,7 +90,7 @@ public class VppOperationalDataTreeTest {
doReturn(id).when(serializer).fromYangInstanceIdentifier(yangId);
final DataObject dataObject = mock(DataObject.class);
- doReturn(Optional.of(dataObject)).when(reader).read(id);
+ doReturn(Optional.of(dataObject)).when(reader).read(same(id), any(ReadContext.class));
when(serializer.toNormalizedNode(id, dataObject)).thenReturn(entry);
final DataContainerChild<?, ?> expectedValue = mock(DataContainerChild.class);
@@ -95,7 +99,7 @@ public class VppOperationalDataTreeTest {
final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> future = operationalData.read(yangId);
verify(serializer).fromYangInstanceIdentifier(yangId);
- verify(reader).read(id);
+ verify(reader).read(same(id), any(ReadContext.class));
final Optional<NormalizedNode<?, ?>> result = future.get();
assertTrue(result.isPresent());
assertEquals(expectedValue, result.get());
@@ -105,19 +109,19 @@ public class VppOperationalDataTreeTest {
public void testReadNonExistingNode() throws Exception {
final YangInstanceIdentifier yangId = mock(YangInstanceIdentifier.class);
doReturn(id).when(serializer).fromYangInstanceIdentifier(yangId);
- doReturn(Optional.absent()).when(reader).read(id);
+ doReturn(Optional.absent()).when(reader).read(same(id), any(ReadContext.class));
final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> future = operationalData.read(yangId);
verify(serializer).fromYangInstanceIdentifier(yangId);
- verify(reader).read(id);
+ verify(reader).read(same(id), any(ReadContext.class));
final Optional<NormalizedNode<?, ?>> result = future.get();
assertFalse(result.isPresent());
}
@Test
public void testReadFailed() throws Exception{
- doThrow(io.fd.honeycomb.v3po.impl.trans.ReadFailedException.class).when(reader).readAll();
+ doThrow(io.fd.honeycomb.v3po.impl.trans.ReadFailedException.class).when(reader).readAll(any(ReadContext.class));
final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> future =
operationalData.read( YangInstanceIdentifier.EMPTY);
@@ -138,7 +142,7 @@ public class VppOperationalDataTreeTest {
final VppState vppState = mock(VppState.class);
Multimap<InstanceIdentifier<?>, DataObject> dataObjects = LinkedListMultimap.create();
dataObjects.put(vppStateII, vppState);
- doReturn(dataObjects).when(reader).readAll();
+ doReturn(dataObjects).when(reader).readAll(any(ReadContext.class));
// Init serializer
final YangInstanceIdentifier vppYangId = YangInstanceIdentifier.builder().node(VppState.QNAME).build();
@@ -152,7 +156,7 @@ public class VppOperationalDataTreeTest {
final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> future =
operationalData.read(YangInstanceIdentifier.EMPTY);
- verify(reader).readAll();
+ verify(reader).readAll(any(ReadContext.class));
verify(serializer).toYangInstanceIdentifier(vppStateII);
verify(serializer).toNormalizedNode(vppStateII, vppState);
diff --git a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/vppstate/VppStateTest.java b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/vppstate/VppStateTest.java
index f44ca52c8..5cb678e3a 100644
--- a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/vppstate/VppStateTest.java
+++ b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/vppstate/VppStateTest.java
@@ -20,11 +20,13 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap;
+import io.fd.honeycomb.v3po.impl.trans.r.ReadContext;
import io.fd.honeycomb.v3po.impl.trans.r.VppReader;
import io.fd.honeycomb.v3po.impl.trans.r.impl.CompositeListVppReader;
import io.fd.honeycomb.v3po.impl.trans.r.impl.CompositeRootVppReader;
@@ -73,11 +75,14 @@ public class VppStateTest {
private DelegatingReaderRegistry readerRegistry;
private vppBridgeDomainDetails bdDetails;
private vppBridgeDomainDetails bdDetails2;
+ private ReadContext ctx;
@Before
public void setUp() throws Exception {
api = PowerMockito.mock(vppApi.class);
+ ctx = mock(ReadContext.class);
+
bdDetails = new vppBridgeDomainDetails();
setIfcs(bdDetails);
setBaseAttrs(bdDetails, "bdn1", 1);
@@ -145,7 +150,7 @@ public class VppStateTest {
@Test
public void testReadAll() throws Exception {
- final Multimap<InstanceIdentifier<? extends DataObject>, ? extends DataObject> dataObjects = readerRegistry.readAll();
+ final Multimap<InstanceIdentifier<? extends DataObject>, ? extends DataObject> dataObjects = readerRegistry.readAll(ctx);
assertEquals(dataObjects.size(), 1);
final DataObject dataObject = Iterables.getOnlyElement(dataObjects.get(Iterables.getOnlyElement(dataObjects.keySet())));
assertTrue(dataObject instanceof VppState);
@@ -166,17 +171,17 @@ public class VppStateTest {
@Test
public void testReadSpecific() throws Exception {
- final Optional<? extends DataObject> read = readerRegistry.read(InstanceIdentifier.create(VppState.class));
+ final Optional<? extends DataObject> read = readerRegistry.read(InstanceIdentifier.create(VppState.class), ctx);
assertTrue(read.isPresent());
assertVersion((VppState) read.get());
}
@Test
public void testReadBridgeDomains() throws Exception {
- VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class)).get();
+ VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class), ctx).get();
Optional<? extends DataObject> read =
- readerRegistry.read(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class));
+ readerRegistry.read(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class), ctx);
assertTrue(read.isPresent());
assertEquals(readRoot.getBridgeDomains(), read.get());
}
@@ -190,38 +195,38 @@ public class VppStateTest {
Optional<? extends DataObject> read =
readerRegistry.read(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child(
BridgeDomain.class, new BridgeDomainKey("bdn1"))
- .child(L2Fib.class, new L2FibKey(new PhysAddress("01:02:03:04:05:06"))));
+ .child(L2Fib.class, new L2FibKey(new PhysAddress("01:02:03:04:05:06"))), ctx);
assertTrue(read.isPresent());
// non existing l2fib
read =
readerRegistry.read(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child(
BridgeDomain.class, new BridgeDomainKey("bdn1"))
- .child(L2Fib.class, new L2FibKey(new PhysAddress("FF:FF:FF:04:05:06"))));
+ .child(L2Fib.class, new L2FibKey(new PhysAddress("FF:FF:FF:04:05:06"))), ctx);
assertFalse(read.isPresent());
}
@Test
public void testReadBridgeDomainAll() throws Exception {
- VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class)).get();
+ VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class), ctx).get();
final CompositeListVppReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> bridgeDomainReader =
VppStateUtils.getBridgeDomainReader(api);
final List<BridgeDomain> read =
bridgeDomainReader.readList(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child(
- BridgeDomain.class));
+ BridgeDomain.class), ctx);
assertEquals(readRoot.getBridgeDomains().getBridgeDomain(), read);
}
@Test
public void testReadBridgeDomain() throws Exception {
- VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class)).get();
+ VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class), ctx).get();
final Optional<? extends DataObject> read =
readerRegistry.read(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child(
- BridgeDomain.class, new BridgeDomainKey("bdn1")));
+ BridgeDomain.class, new BridgeDomainKey("bdn1")), ctx);
assertTrue(read.isPresent());
assertEquals(Iterables.find(readRoot.getBridgeDomains().getBridgeDomain(), new Predicate<BridgeDomain>() {
@@ -238,16 +243,16 @@ public class VppStateTest {
public void testReadBridgeDomainNotExisting() throws Exception {
final Optional<? extends DataObject> read =
readerRegistry.read(InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child(
- BridgeDomain.class, new BridgeDomainKey("NOT EXISTING")));
+ BridgeDomain.class, new BridgeDomainKey("NOT EXISTING")), ctx);
assertFalse(read.isPresent());
}
@Test
public void testReadVersion() throws Exception {
- VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class)).get();
+ VppState readRoot = (VppState) readerRegistry.read(InstanceIdentifier.create(VppState.class), ctx).get();
Optional<? extends DataObject> read =
- readerRegistry.read(InstanceIdentifier.create(VppState.class).child(Version.class));
+ readerRegistry.read(InstanceIdentifier.create(VppState.class).child(Version.class), ctx);
assertTrue(read.isPresent());
assertEquals(readRoot.getVersion(), read.get());
}