summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/honeycomb-parent/pom.xml2
-rw-r--r--infra/cfg-init/src/test/java/io/fd/honeycomb/data/init/RestoringInitializerTest.java10
-rw-r--r--infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/PersistingDataTreeAdapterTest.java9
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/impl/write/util/TransactionWriteContextTest.java9
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/KeepaliveReaderWrapperTest.java5
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/registry/FlatWriterRegistryBuilderTest.java15
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAclCustomizerTest.java45
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java7
8 files changed, 41 insertions, 61 deletions
diff --git a/common/honeycomb-parent/pom.xml b/common/honeycomb-parent/pom.xml
index d050a919d..e6340286c 100644
--- a/common/honeycomb-parent/pom.xml
+++ b/common/honeycomb-parent/pom.xml
@@ -53,7 +53,7 @@
<!-- dependencies -->
<junit.version>4.11</junit.version>
- <mockito.version>1.10.19</mockito.version>
+ <mockito.version>2.2.9</mockito.version>
<hamcrest.version>1.3</hamcrest.version>
<guava.version>18.0</guava.version>
diff --git a/infra/cfg-init/src/test/java/io/fd/honeycomb/data/init/RestoringInitializerTest.java b/infra/cfg-init/src/test/java/io/fd/honeycomb/data/init/RestoringInitializerTest.java
index e4f163901..85ecc6c4e 100644
--- a/infra/cfg-init/src/test/java/io/fd/honeycomb/data/init/RestoringInitializerTest.java
+++ b/infra/cfg-init/src/test/java/io/fd/honeycomb/data/init/RestoringInitializerTest.java
@@ -16,7 +16,6 @@
package io.fd.honeycomb.data.init;
-import static org.mockito.Matchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
@@ -46,6 +45,8 @@ public class RestoringInitializerTest {
@Mock
private SchemaService schemaService;
@Mock
+ private SchemaContext schemaContext;
+ @Mock
private DOMDataBroker dataTree;
@Mock
private RestoringInitializer.JsonReader jsonReader;
@@ -61,7 +62,8 @@ public class RestoringInitializerTest {
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
path = Files.createTempFile("hc", "restoretest");
- when(jsonReader.readData(any(SchemaContext.class), any(Path.class))).thenReturn(data);
+ when(schemaService.getGlobalContext()).thenReturn(schemaContext);
+ when(jsonReader.readData(schemaContext, path)).thenReturn(data);
when(dataTree.newWriteOnlyTransaction()).thenReturn(writeTx);
when(writeTx.submit()).thenReturn(Futures.immediateCheckedFuture(null));
when(data.getValue()).thenReturn(Collections.singleton(data));
@@ -86,7 +88,7 @@ public class RestoringInitializerTest {
init.initialize();
verify(schemaService).getGlobalContext();
- verify(jsonReader).readData(any(SchemaContext.class), any(Path.class));
+ verify(jsonReader).readData(schemaContext, path);
verify(dataTree).newWriteOnlyTransaction();
verify(writeTx).put(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.create(nodeId), data);
@@ -118,7 +120,7 @@ public class RestoringInitializerTest {
@Test(expected = DataTreeInitializer.InitializeException.class)
public void testFail() throws Exception {
- when(jsonReader.readData(any(SchemaContext.class), any(Path.class))).thenThrow(new IOException("t"));
+ when(jsonReader.readData(schemaContext, path)).thenThrow(new IOException("t"));
final RestoringInitializer init =
new RestoringInitializer(schemaService, path, dataTree,
diff --git a/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/PersistingDataTreeAdapterTest.java b/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/PersistingDataTreeAdapterTest.java
index 8430073ac..ed3529530 100644
--- a/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/PersistingDataTreeAdapterTest.java
+++ b/infra/data-impl/src/test/java/io/fd/honeycomb/data/impl/PersistingDataTreeAdapterTest.java
@@ -22,8 +22,10 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import com.google.common.base.Optional;
import java.io.IOException;
@@ -69,7 +71,7 @@ public class PersistingDataTreeAdapterTest {
doThrow(new IllegalStateException("testing errors")).when(delegatingDataTree).commit(any(DataTreeCandidate.class));
try {
- persistingDataTreeAdapter.commit(null);
+ persistingDataTreeAdapter.commit(mock(DataTreeCandidate.class));
fail("Exception expected");
} catch (IllegalStateException e) {
verify(delegatingDataTree, times(0)).takeSnapshot();
@@ -80,7 +82,10 @@ public class PersistingDataTreeAdapterTest {
@Test
public void testPersist() throws Exception {
persistingDataTreeAdapter = new PersistingDataTreeAdapter(delegatingDataTree, persister);
- persistingDataTreeAdapter.commit(null);
+ final DataTreeSnapshot snapshot = mock(DataTreeSnapshot.class);
+ when(snapshot.readNode(any())).thenReturn(Optional.absent());
+ when(delegatingDataTree.takeSnapshot()).thenReturn(snapshot);
+ persistingDataTreeAdapter.commit(mock(DataTreeCandidate.class));
verify(delegatingDataTree).takeSnapshot();
verify(persister).persistCurrentData(any(Optional.class));
}
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/impl/write/util/TransactionWriteContextTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/impl/write/util/TransactionWriteContextTest.java
index 79155bdd6..182375bfc 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/impl/write/util/TransactionWriteContextTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/impl/write/util/TransactionWriteContextTest.java
@@ -60,11 +60,14 @@ public class TransactionWriteContextTest {
private MappingContext contextBroker;
private TransactionWriteContext transactionWriteContext;
+ private YangInstanceIdentifier yangId;
@Before
public void setUp() {
initMocks(this);
transactionWriteContext = new TransactionWriteContext(serializer, beforeTx, afterTx, contextBroker);
+ yangId = YangInstanceIdentifier.builder().node(QName.create("n", "d")).build();
+ when(serializer.toYangInstanceIdentifier(any(InstanceIdentifier.class))).thenReturn(yangId);
}
@Test
@@ -90,8 +93,6 @@ public class TransactionWriteContextTest {
final InstanceIdentifier<DataObjects.DataObject1> instanceId =
InstanceIdentifier.create(DataObjects.DataObject1.class);
- final YangInstanceIdentifier yangId = YangInstanceIdentifier.builder().node(QName.create("n", "d")).build();
- when(serializer.toYangInstanceIdentifier(any(InstanceIdentifier.class))).thenReturn(yangId);
when(serializer.fromNormalizedNode(eq(yangId), any(NormalizedNode.class))).thenReturn(entry);
when(entry.getValue()).thenReturn(mock(DataObjects.DataObject1.class));
@@ -105,14 +106,14 @@ public class TransactionWriteContextTest {
@Test(expected = IllegalStateException.class)
public void testReadBeforeFailed() throws Exception {
- when(beforeTx.read(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class))).thenReturn(
+ when(beforeTx.read(LogicalDatastoreType.CONFIGURATION, yangId)).thenReturn(
Futures.immediateFailedCheckedFuture(mock(ReadFailedException.class)));
transactionWriteContext.readBefore(mock(InstanceIdentifier.class));
}
@Test(expected = IllegalStateException.class)
public void testReadAfterFailed() throws Exception {
- when(afterTx.read(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class))).thenReturn(
+ when(afterTx.read(LogicalDatastoreType.CONFIGURATION, yangId)).thenReturn(
Futures.immediateFailedCheckedFuture(mock(ReadFailedException.class)));
transactionWriteContext.readAfter(mock(InstanceIdentifier.class));
}
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/KeepaliveReaderWrapperTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/KeepaliveReaderWrapperTest.java
index ca2872139..738e715b0 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/KeepaliveReaderWrapperTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/KeepaliveReaderWrapperTest.java
@@ -18,6 +18,7 @@ package io.fd.honeycomb.translate.util.read;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -41,6 +42,7 @@ public class KeepaliveReaderWrapperTest {
@Mock
private ReadContext ctx;
+ private InstanceIdentifier<DataObject> iid = InstanceIdentifier.create(DataObject.class);
@Mock
private Reader<DataObject, Builder<DataObject>> delegate;
@Mock
@@ -53,7 +55,8 @@ public class KeepaliveReaderWrapperTest {
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
exec = Executors.newScheduledThreadPool(1);
- when(delegate.read(any(InstanceIdentifier.class), any(ReadContext.class))).thenThrow(TestingException.class);
+ when(delegate.getManagedDataObjectType()).thenReturn(iid);
+ when(delegate.read(eq(iid), any(ReadContext.class))).thenThrow(TestingException.class);
}
@After
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/registry/FlatWriterRegistryBuilderTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/registry/FlatWriterRegistryBuilderTest.java
index 48c6e8ea3..7822c8926 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/registry/FlatWriterRegistryBuilderTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/registry/FlatWriterRegistryBuilderTest.java
@@ -23,7 +23,7 @@ import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -74,15 +74,22 @@ public class FlatWriterRegistryBuilderTest {
final Writer<? extends DataObject> writer = mockWriter(DataObjects.DataObject3.class);
flatWriterRegistryBuilder.add(writer);
final WriterRegistry build = flatWriterRegistryBuilder.build();
+
final InstanceIdentifier<DataObjects.DataObject3> id = InstanceIdentifier.create(DataObjects.DataObject3.class);
final DataObjectUpdate update = mock(DataObjectUpdate.class);
+ doReturn(id).when(update).getId();
+ final DataObjects.DataObject3 before = mock(DataObjects.DataObject3.class);
+ final DataObjects.DataObject3 after = mock(DataObjects.DataObject3.class);
+ when(update.getDataBefore()).thenReturn(before);
+ when(update.getDataAfter()).thenReturn(after);
+
WriterRegistry.DataObjectUpdates updates = new WriterRegistry.DataObjectUpdates(
Multimaps.forMap(Collections.singletonMap(id, update)),
Multimaps.forMap(Collections.emptyMap()));
- build.update(updates, mock(WriteContext.class));
+ final WriteContext ctx = mock(WriteContext.class);
+ build.update(updates, ctx);
- verify(writer)
- .update(any(InstanceIdentifier.class), any(DataObject.class), any(DataObject.class), any(WriteContext.class));
+ verify(writer).update(id, before, after, ctx);
}
@Test(expected = IllegalArgumentException.class)
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAclCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAclCustomizerTest.java
index ccf1f83b3..8a4e9213d 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAclCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAclCustomizerTest.java
@@ -35,10 +35,8 @@ import io.fd.vpp.jvpp.core.dto.InputAclSetInterface;
import io.fd.vpp.jvpp.core.dto.InputAclSetInterfaceReply;
import java.util.Arrays;
import java.util.Collections;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
-import org.hamcrest.Matcher;
import org.junit.Test;
+import org.mockito.ArgumentMatcher;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
@@ -129,44 +127,13 @@ public class IetfAclCustomizerTest extends WriterCustomizerTest {
inOrder.verify(api).inputAclSetInterface(inputAclSetInterfaceWriteRequest()); // assignment
}
- private Matcher<ClassifyAddDelTable> actionOnMissEquals(final int action) {
- return new BaseMatcher<ClassifyAddDelTable>() {
- public Object item;
-
- @Override
- public void describeTo(final Description description) {
- description.appendText("Expected ClassifyAddDelTable[missNextIndex=" + action + "] but was " + item);
- }
-
- @Override
- public boolean matches(final Object item) {
- this.item = item;
- if (item instanceof ClassifyAddDelTable) {
- return ((ClassifyAddDelTable) item).missNextIndex == action;
- }
- return false;
- }
- };
+ private ArgumentMatcher<ClassifyAddDelTable> actionOnMissEquals(final int action) {
+ return table -> table.missNextIndex == action;
}
- private Matcher<ClassifyAddDelSession> actionOnHitEquals(final int action) {
- return new BaseMatcher<ClassifyAddDelSession>() {
- public Object item;
-
- @Override
- public void describeTo(final Description description) {
- description.appendText("Expected ClassifyAddDelSession[hitNextIndex=" + action + "] but was " + item);
- }
-
- @Override
- public boolean matches(final Object item) {
- this.item = item;
- if (item instanceof ClassifyAddDelSession) {
- return ((ClassifyAddDelSession) item).hitNextIndex == action;
- }
- return false;
- }
- };
+
+ private ArgumentMatcher<ClassifyAddDelSession> actionOnHitEquals(final int action) {
+ return session -> session.hitNextIndex == action;
}
private Deny deny() {
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java
index 522ab7297..00b424d9d 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java
@@ -182,12 +182,7 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
private static ArgumentMatcher<InstanceIdentifier<?>> matchInstanceIdentifier(
Class<?> desiredClass) {
- return new ArgumentMatcher<InstanceIdentifier<?>>() {
- @Override
- public boolean matches(final Object o) {
- return o instanceof InstanceIdentifier && ((InstanceIdentifier) o).getTargetType().equals(desiredClass);
- }
- };
+ return o -> o instanceof InstanceIdentifier && (o.getTargetType().equals(desiredClass));
}
@Test(expected = WriteFailedException.UpdateFailedException.class)