summaryrefslogtreecommitdiffstats
path: root/infra/translate-utils/src/test
diff options
context:
space:
mode:
authorMichal Cmarada <mcmarada@cisco.com>2019-04-08 11:37:45 +0200
committerMichal Cmarada <mcmarada@cisco.com>2019-04-08 11:37:45 +0200
commitb16cea20258ba537db7c0755208c82ab93331ff7 (patch)
tree8a5a3c87069b9ce700c34323e75ff434e7acae97 /infra/translate-utils/src/test
parent23979469bcf8cd312cb3ec9e9e548003110f68f4 (diff)
HONEYCOMB-443: ODL bump to Neon
- bumps ODL dependencies to neon - migrates guava optional to java.utils.optional Change-Id: Ibdaa365c7e21a341103aba88dfd67277e40d2969 Signed-off-by: Michal Cmarada <mcmarada@cisco.com>
Diffstat (limited to 'infra/translate-utils/src/test')
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/impl/write/util/TransactionWriteContextTest.java22
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/RealtimeMappingContextTest.java50
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/TransactionMappingContextTest.java24
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/BindingBrokerReaderTest.java19
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/ReflexiveListReaderCustomizerTest.java2
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/cache/DumpCacheManagerTest.java2
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/BindingBrokerWriterTest.java15
7 files changed, 67 insertions, 67 deletions
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 cbf509827..f74a0a41a 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
@@ -27,20 +27,20 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.Futures;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.util.DataObjects;
import io.fd.honeycomb.translate.util.write.TransactionWriteContext;
import java.util.Map;
+import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -51,9 +51,9 @@ public class TransactionWriteContextTest {
@Mock
private BindingNormalizedNodeSerializer serializer;
@Mock
- private DOMDataReadOnlyTransaction beforeTx;
+ private DOMDataTreeReadTransaction beforeTx;
@Mock
- private DOMDataReadOnlyTransaction afterTx;
+ private DOMDataTreeReadTransaction afterTx;
@Mock
private Map.Entry entry;
@Mock
@@ -73,7 +73,7 @@ public class TransactionWriteContextTest {
@Test
public void testReadBeforeNoData() throws Exception {
when(beforeTx.read(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class))).thenReturn(
- Futures.immediateCheckedFuture(Optional.absent()));
+ FluentFutures.immediateFluentFuture(Optional.empty()));
final InstanceIdentifier<DataObjects.DataObject1> instanceId =
InstanceIdentifier.create(DataObjects.DataObject1.class);
@@ -89,7 +89,7 @@ public class TransactionWriteContextTest {
@Test
public void testReadBefore() throws Exception {
when(beforeTx.read(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class))).thenReturn(
- Futures.immediateCheckedFuture(Optional.of(mock(NormalizedNode.class))));
+ FluentFutures.immediateFluentFuture(Optional.of(mock(NormalizedNode.class))));
final InstanceIdentifier<DataObjects.DataObject1> instanceId =
InstanceIdentifier.create(DataObjects.DataObject1.class);
@@ -107,14 +107,14 @@ public class TransactionWriteContextTest {
@Test(expected = IllegalStateException.class)
public void testReadBeforeFailed() throws Exception {
when(beforeTx.read(LogicalDatastoreType.CONFIGURATION, yangId)).thenReturn(
- Futures.immediateFailedCheckedFuture(mock(ReadFailedException.class)));
+ FluentFutures.immediateFailedFluentFuture(mock(ReadFailedException.class)));
transactionWriteContext.readBefore(mock(InstanceIdentifier.class));
}
@Test(expected = IllegalStateException.class)
public void testReadAfterFailed() throws Exception {
when(afterTx.read(LogicalDatastoreType.CONFIGURATION, yangId)).thenReturn(
- Futures.immediateFailedCheckedFuture(mock(ReadFailedException.class)));
+ FluentFutures.immediateFailedFluentFuture(mock(ReadFailedException.class)));
transactionWriteContext.readAfter(mock(InstanceIdentifier.class));
}
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/RealtimeMappingContextTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/RealtimeMappingContextTest.java
index d6da2f368..d922d1454 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/RealtimeMappingContextTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/RealtimeMappingContextTest.java
@@ -21,19 +21,18 @@ import static org.junit.Assert.assertSame;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.FluentFuture;
+import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -44,7 +43,7 @@ public class RealtimeMappingContextTest {
private RealtimeMappingContext ctx;
private InstanceIdentifier<DataObject> id = InstanceIdentifier.create(DataObject.class);
@Mock
- private ReadOnlyTransaction readTx;
+ private ReadTransaction readTx;
@Mock
private WriteTransaction writeTx;
@Mock
@@ -58,59 +57,60 @@ public class RealtimeMappingContextTest {
when(broker.newReadOnlyTransaction()).thenReturn(readTx);
when(broker.newWriteOnlyTransaction()).thenReturn(writeTx);
- when(writeTx.submit()).thenReturn(Futures.immediateCheckedFuture(null));
+ when(writeTx.commit()).thenReturn(FluentFutures.immediateNullFluentFuture());
}
@Test
- public void testRead() throws Exception {
- final CheckedFuture<Optional<DataObject>, ReadFailedException> futureData =
- Futures.immediateCheckedFuture(Optional.of((data)));
+ public void testRead() {
+ final FluentFuture<Optional<DataObject>> futureData =
+ FluentFutures.immediateFluentFuture(Optional.of((data)));
when(readTx.read(LogicalDatastoreType.OPERATIONAL, id)).thenReturn(futureData);
assertSame(ctx.read(id).get(), data);
verify(broker).newReadOnlyTransaction();
verify(readTx).read(LogicalDatastoreType.OPERATIONAL, id);
- when(readTx.read(LogicalDatastoreType.OPERATIONAL, id)).thenReturn(Futures.immediateCheckedFuture(Optional.absent()));
+ when(readTx.read(LogicalDatastoreType.OPERATIONAL, id))
+ .thenReturn(FluentFutures.immediateFluentFuture(Optional.empty()));
assertFalse(ctx.read(id).isPresent());
}
@Test
- public void testMerge() throws Exception {
+ public void testMerge() {
ctx.merge(id, data);
verify(broker).newWriteOnlyTransaction();
- verify(writeTx).merge(LogicalDatastoreType.OPERATIONAL, id, data, true);
+ verify(writeTx).mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, id, data);
}
@Test(expected = IllegalStateException.class)
public void testMergeFailure() throws Exception {
- when(writeTx.submit()).thenReturn(Futures.immediateFailedCheckedFuture(ex));
+ when(writeTx.commit()).thenReturn(FluentFutures.immediateFailedFluentFuture(ex));
ctx.merge(id, data);
}
@Test
- public void testPut() throws Exception {
+ public void testPut() {
ctx.put(id, data);
verify(broker).newWriteOnlyTransaction();
- verify(writeTx).put(LogicalDatastoreType.OPERATIONAL, id, data, true);
+ verify(writeTx).mergeParentStructurePut(LogicalDatastoreType.OPERATIONAL, id, data);
}
@Test(expected = IllegalStateException.class)
- public void testPutFailure() throws Exception {
- when(writeTx.submit()).thenReturn(Futures.immediateFailedCheckedFuture(ex));
+ public void testPutFailure() {
+ when(writeTx.commit()).thenReturn(FluentFutures.immediateFailedFluentFuture(ex));
ctx.put(id, data);
}
@Test
- public void testDelete() throws Exception {
+ public void testDelete() {
ctx.delete(id);
verify(broker).newWriteOnlyTransaction();
verify(writeTx).delete(LogicalDatastoreType.OPERATIONAL, id);
}
@Test(expected = IllegalStateException.class)
- public void testDeleteFailure() throws Exception {
- when(writeTx.submit()).thenReturn(Futures.immediateFailedCheckedFuture(ex));
+ public void testDeleteFailure() {
+ when(writeTx.commit()).thenReturn(FluentFutures.immediateFailedFluentFuture(ex));
ctx.delete(id);
}
} \ No newline at end of file
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/TransactionMappingContextTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/TransactionMappingContextTest.java
index 2dcee889a..a9747d0af 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/TransactionMappingContextTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/TransactionMappingContextTest.java
@@ -21,16 +21,16 @@ import static org.junit.Assert.assertSame;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.FluentFuture;
+import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -49,27 +49,27 @@ public class TransactionMappingContextTest {
MockitoAnnotations.initMocks(this);
ctx = new TransactionMappingContext(writeTx);
- when(writeTx.submit()).thenReturn(Futures.immediateCheckedFuture(null));
+ when(writeTx.commit()).thenReturn(FluentFutures.immediateNullFluentFuture());
}
@Test
public void testRead() throws Exception {
- final CheckedFuture<Optional<DataObject>, ReadFailedException> futureData =
- Futures.immediateCheckedFuture(Optional.of((data)));
+ final FluentFuture<Optional<DataObject>> futureData = FluentFutures.immediateFluentFuture(Optional.of((data)));
when(writeTx.read(LogicalDatastoreType.OPERATIONAL, id)).thenReturn(futureData);
assertSame(ctx.read(id).get(), data);
verify(writeTx).read(LogicalDatastoreType.OPERATIONAL, id);
- when(writeTx.read(LogicalDatastoreType.OPERATIONAL, id)).thenReturn(Futures.immediateCheckedFuture(Optional.absent()));
+ when(writeTx.read(LogicalDatastoreType.OPERATIONAL, id))
+ .thenReturn(FluentFutures.immediateFluentFuture(Optional.empty()));
assertFalse(ctx.read(id).isPresent());
}
@Test(expected = IllegalStateException.class)
public void testReadFailure() throws Exception {
- final CheckedFuture<Optional<DataObject>, ReadFailedException> futureData =
- Futures.immediateFailedCheckedFuture(ex);
+ final FluentFuture<Optional<DataObject>> futureData =
+ FluentFutures.immediateFailedFluentFuture(ex);
when(writeTx.read(LogicalDatastoreType.OPERATIONAL, id)).thenReturn(futureData);
assertSame(ctx.read(id).get(), data);
}
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/BindingBrokerReaderTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/BindingBrokerReaderTest.java
index b6af72125..18ba1bd6a 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/BindingBrokerReaderTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/BindingBrokerReaderTest.java
@@ -23,18 +23,18 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.Futures;
import io.fd.honeycomb.translate.read.ReadContext;
+import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -46,7 +46,7 @@ public class BindingBrokerReaderTest {
@Mock
private ReadContext ctx;
@Mock
- private ReadOnlyTransaction tx;
+ private ReadTransaction tx;
@Mock
private DataObject data;
private BindingBrokerReader<DataObject, DataObjectBuilder> bbReader;
@@ -55,7 +55,8 @@ public class BindingBrokerReaderTest {
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(broker.newReadOnlyTransaction()).thenReturn(tx);
- when(tx.read(LogicalDatastoreType.CONFIGURATION, id)).thenReturn(Futures.immediateCheckedFuture(Optional.of(data)));
+ when(tx.read(LogicalDatastoreType.CONFIGURATION, id))
+ .thenReturn(FluentFutures.immediateFluentFuture(Optional.of(data)));
bbReader = new BindingBrokerReader<>(id, broker, LogicalDatastoreType.CONFIGURATION, DataObjectBuilder.class);
}
@@ -72,7 +73,7 @@ public class BindingBrokerReaderTest {
@Test(expected = io.fd.honeycomb.translate.read.ReadFailedException.class)
public void testFailedRead() throws Exception {
when(tx.read(LogicalDatastoreType.CONFIGURATION, id))
- .thenReturn(Futures.immediateFailedCheckedFuture(new ReadFailedException("failing")));
+ .thenReturn(FluentFutures.immediateFailedFluentFuture(new ReadFailedException("failing")));
bbReader.read(id, ctx);
}
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/ReflexiveListReaderCustomizerTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/ReflexiveListReaderCustomizerTest.java
index aa1d0f925..d884176f6 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/ReflexiveListReaderCustomizerTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/ReflexiveListReaderCustomizerTest.java
@@ -59,7 +59,7 @@ public class ReflexiveListReaderCustomizerTest {
final TestingListObjectBuilder builder = new TestingListObjectBuilder();
final InstanceIdentifier<TestingListObject> id =
(InstanceIdentifier<TestingListObject>) InstanceIdentifier.create(
- Collections.singletonList(new InstanceIdentifier.IdentifiableItem<>(TestingListObject.class, keyOne)));
+ Collections.singletonList(InstanceIdentifier.IdentifiableItem.of(TestingListObject.class, keyOne)));
customizer.readCurrentAttributes(id, builder, readContext);
assertEquals(keyOne, builder.getKey());
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/cache/DumpCacheManagerTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/cache/DumpCacheManagerTest.java
index 5f9362458..e52583d2b 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/cache/DumpCacheManagerTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/cache/DumpCacheManagerTest.java
@@ -21,12 +21,12 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
-import com.google.common.base.Optional;
import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.read.ReadFailedException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
+import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/BindingBrokerWriterTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/BindingBrokerWriterTest.java
index 9e09112c9..49b76ce95 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/BindingBrokerWriterTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/BindingBrokerWriterTest.java
@@ -20,16 +20,15 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import com.google.common.util.concurrent.Futures;
import io.fd.honeycomb.translate.write.WriteContext;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -50,7 +49,7 @@ public class BindingBrokerWriterTest {
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(broker.newWriteOnlyTransaction()).thenReturn(tx);
- when(tx.submit()).thenReturn(Futures.immediateCheckedFuture(null));
+ when(tx.commit()).thenReturn(FluentFutures.immediateNullFluentFuture());
bbWriter = new BindingBrokerWriter<>(id, broker);
}
@@ -61,12 +60,12 @@ public class BindingBrokerWriterTest {
bbWriter.processModification(id, data, data, ctx);
verify(broker).newWriteOnlyTransaction();
verify(tx).put(LogicalDatastoreType.CONFIGURATION, id, data);
- verify(tx).submit();
+ verify(tx).commit();
}
@Test(expected = io.fd.honeycomb.translate.write.WriteFailedException.class)
public void testFailedWrite() throws Exception {
- when(tx.submit()).thenReturn(Futures.immediateFailedCheckedFuture(new TransactionCommitFailedException("failing")));
+ when(tx.commit()).thenReturn(FluentFutures.immediateFailedFluentFuture(new InterruptedException("failing")));
bbWriter.processModification(id, data, data, ctx);
}
} \ No newline at end of file