summaryrefslogtreecommitdiffstats
path: root/infra
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-10-28 13:12:19 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-11-01 20:59:57 +0100
commitb8f86e7069a67031514c43caf8022e8553159fa7 (patch)
treed112017e36341e114fea4cdefdc5b2a8a90b2030 /infra
parent80804f713cdd8d3c30c7e2dd19cbc2a61a1a70c0 (diff)
HONEYCOMB-272: bump mockito version to 2.2.9
ArgumentMatchers.any() does not match null anymore, so some of the tests has been updated. Change-Id: I5de0fdfe87fc8e5c8ce24bfae8daeaba032195ff Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'infra')
-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
5 files changed, 33 insertions, 15 deletions
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)