summaryrefslogtreecommitdiffstats
path: root/v3po/impl/src/test/java/io
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/impl/src/test/java/io')
-rw-r--r--v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java7
-rw-r--r--v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppOperationalDataTreeTest.java24
-rw-r--r--v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/vppstate/VppStateTest.java5
3 files changed, 27 insertions, 9 deletions
diff --git a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java
index 782a7b6fe..5ac1f0130 100644
--- a/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java
+++ b/v3po/impl/src/test/java/io/fd/honeycomb/v3po/impl/data/VppDataBrokerInitializationProviderTest.java
@@ -26,6 +26,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.util.concurrent.CheckedFuture;
+import io.fd.honeycomb.v3po.impl.trans.r.ReaderRegistry;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@@ -41,14 +42,16 @@ public class VppDataBrokerInitializationProviderTest {
private DataBroker bindingBroker;
@Mock
private WriteTransaction writeTx;
+ @Mock
+ private ReaderRegistry readerRegistry;
- private VppDataBrokerInitializationProvider provider;
+ private VppDataBrokerInitializationProvider provider;
@Before
public void setUp() throws Exception {
initMocks(this);
doReturn(writeTx).when(bindingBroker).newWriteOnlyTransaction();
- provider = new VppDataBrokerInitializationProvider(bindingBroker);
+ provider = new VppDataBrokerInitializationProvider(bindingBroker, readerRegistry);
}
@Test
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 9a3377563..62ddf5ca0 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
@@ -18,6 +18,7 @@ package io.fd.honeycomb.v3po.impl.data;
import static junit.framework.Assert.assertEquals;
import static junit.framework.TestCase.assertTrue;
+import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -26,7 +27,8 @@ import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
-import io.fd.honeycomb.v3po.impl.trans0.VppReader;
+import io.fd.honeycomb.v3po.impl.trans.r.ReaderRegistry;
+import java.util.Collections;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
@@ -35,15 +37,19 @@ import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public class VppOperationalDataTreeTest {
@Mock
private BindingNormalizedNodeSerializer serializer;
@Mock
- private VppReader reader;
+ private ReaderRegistry reader;
private VppOperationalDataTree operationalData;
@@ -51,24 +57,32 @@ public class VppOperationalDataTreeTest {
private InstanceIdentifier<DataObject> id;
@Mock
private Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> entry;
+ @Mock
+ private SchemaContext globalContext;
+ @Mock
+ private DataSchemaNode schemaNode;
@Before
public void setUp() {
initMocks(this);
- operationalData = new VppOperationalDataTree(serializer, reader);
+ operationalData = new VppOperationalDataTree(serializer, globalContext, reader);
}
@Test
public void testRead() throws Exception {
final YangInstanceIdentifier yangId = mock(YangInstanceIdentifier.class);
+ final YangInstanceIdentifier.PathArgument pArg = mock(YangInstanceIdentifier.PathArgument.class);
+ doReturn(pArg).when(yangId).getLastPathArgument();
+ doReturn(QName.create("namespace", "2012-12-12", "local")).when(pArg).getNodeType();
+ doReturn(schemaNode).when(globalContext).getDataChildByName(any(QName.class));
doReturn(id).when(serializer).fromYangInstanceIdentifier(yangId);
final DataObject dataObject = mock(DataObject.class);
- when(reader.read(id)).thenReturn(dataObject);
+ doReturn(Collections.singletonList(dataObject)).when(reader).read(id);
when(serializer.toNormalizedNode(id, dataObject)).thenReturn(entry);
- final NormalizedNode<?, ?> expectedValue = mock(NormalizedNode.class);
+ final DataContainerChild<?, ?> expectedValue = mock(DataContainerChild.class);
doReturn(expectedValue).when(entry).getValue();
final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> future = operationalData.read(yangId);
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 66831c77a..cdb3024d8 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
@@ -22,6 +22,7 @@ import static org.mockito.Matchers.anyString;
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.VppReader;
import io.fd.honeycomb.v3po.impl.trans.r.impl.CompositeRootVppReader;
import io.fd.honeycomb.v3po.impl.trans.r.util.DelegatingReaderRegistry;
@@ -140,9 +141,9 @@ public class VppStateTest {
@Test
public void testReadAll() throws Exception {
- final List<? extends DataObject> dataObjects = readerRegistry.readAll();
+ final Multimap<InstanceIdentifier<? extends DataObject>, ? extends DataObject> dataObjects = readerRegistry.readAll();
assertEquals(dataObjects.size(), 1);
- final DataObject dataObject = dataObjects.get(0);
+ final DataObject dataObject = Iterables.getOnlyElement(dataObjects.get(Iterables.getOnlyElement(dataObjects.keySet())));
assertTrue(dataObject instanceof VppState);
assertVersion((VppState) dataObject);
assertEquals(2, ((VppState) dataObject).getBridgeDomains().getBridgeDomain().size());