summaryrefslogtreecommitdiffstats
path: root/infra/translate-utils/src/test
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-07-29 16:27:12 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-07-29 16:32:17 +0200
commite3c31cee916480b2d9d169c1f5afb1c42efaabe1 (patch)
treec88b0ca3e7296dd7e68628db6d5f33ffd1e1b55e /infra/translate-utils/src/test
parent0578156b721fa01c8c645b8f9625ecebdb6449e4 (diff)
HONEYCOMB-130: Rename infra packages(remove vpp/v3po)
Change-Id: Ic5b90e397e3743623d01b206bc60bc5c7df6b981 Signed-off-by: Maros Marsalek <mmarsale@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.java (renamed from infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/impl/write/util/TransactionWriteContextTest.java)10
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/DataObjects.java (renamed from infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/DataObjects.java)2
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/JsonUtilsTest.java (renamed from infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/JsonUtilsTest.java)2
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/registry/CompositeReaderRegistryBuilderTest.java (renamed from infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/read/registry/CompositeReaderRegistryBuilderTest.java)8
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/registry/SubtreeReaderTest.java (renamed from infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/read/registry/SubtreeReaderTest.java)8
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/registry/TypeHierarchyTest.java72
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/registry/FlatWriterRegistryBuilderTest.java (renamed from infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/write/registry/FlatWriterRegistryBuilderTest.java)6
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/registry/FlatWriterRegistryTest.java (renamed from infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/write/registry/FlatWriterRegistryTest.java)125
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/registry/SubtreeWriterTest.java (renamed from infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/write/registry/SubtreeWriterTest.java)6
-rw-r--r--infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/read/registry/TypeHierarchyTest.java69
10 files changed, 156 insertions, 152 deletions
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/impl/write/util/TransactionWriteContextTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/impl/write/util/TransactionWriteContextTest.java
index 7c93e992a..001e5567a 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/impl/write/util/TransactionWriteContextTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/impl/write/util/TransactionWriteContextTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.fd.honeycomb.v3po.translate.impl.write.util;
+package io.fd.honeycomb.translate.impl.write.util;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -29,10 +29,10 @@ import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.Futures;
-import io.fd.honeycomb.v3po.translate.MappingContext;
-import io.fd.honeycomb.v3po.translate.ModificationCache;
-import io.fd.honeycomb.v3po.translate.util.DataObjects;
-import io.fd.honeycomb.v3po.translate.util.write.TransactionWriteContext;
+import io.fd.honeycomb.translate.ModificationCache;
+import io.fd.honeycomb.translate.util.DataObjects;
+import io.fd.honeycomb.translate.util.write.TransactionWriteContext;
+import io.fd.honeycomb.translate.MappingContext;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/DataObjects.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/DataObjects.java
index d823465bd..e602adbb6 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/DataObjects.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/DataObjects.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.fd.honeycomb.v3po.translate.util;
+package io.fd.honeycomb.translate.util;
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.binding.DataObject;
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/JsonUtilsTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/JsonUtilsTest.java
index bd48cb446..9c97ac503 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/JsonUtilsTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/JsonUtilsTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.fd.honeycomb.v3po.translate.util;
+package io.fd.honeycomb.translate.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/read/registry/CompositeReaderRegistryBuilderTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/registry/CompositeReaderRegistryBuilderTest.java
index e57dcee43..d742575be 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/read/registry/CompositeReaderRegistryBuilderTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/registry/CompositeReaderRegistryBuilderTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.fd.honeycomb.v3po.translate.util.read.registry;
+package io.fd.honeycomb.translate.util.read.registry;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -23,9 +23,9 @@ import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
-import io.fd.honeycomb.v3po.translate.read.Reader;
-import io.fd.honeycomb.v3po.translate.read.registry.ReaderRegistry;
-import io.fd.honeycomb.v3po.translate.util.DataObjects;
+import io.fd.honeycomb.translate.read.Reader;
+import io.fd.honeycomb.translate.read.registry.ReaderRegistry;
+import io.fd.honeycomb.translate.util.DataObjects;
import java.util.List;
import java.util.Map;
import org.junit.Test;
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/read/registry/SubtreeReaderTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/registry/SubtreeReaderTest.java
index 324d71daa..799b9553f 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/read/registry/SubtreeReaderTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/registry/SubtreeReaderTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.fd.honeycomb.v3po.translate.util.read.registry;
+package io.fd.honeycomb.translate.util.read.registry;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -25,9 +25,9 @@ import static org.mockito.Mockito.verify;
import com.google.common.base.Optional;
import com.google.common.collect.Sets;
-import io.fd.honeycomb.v3po.translate.read.ReadContext;
-import io.fd.honeycomb.v3po.translate.read.Reader;
-import io.fd.honeycomb.v3po.translate.util.DataObjects;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.Reader;
+import io.fd.honeycomb.translate.util.DataObjects;
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/read/registry/TypeHierarchyTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/registry/TypeHierarchyTest.java
new file mode 100644
index 000000000..3b3ea3a35
--- /dev/null
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/read/registry/TypeHierarchyTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.translate.util.read.registry;
+
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.hasItems;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+import com.google.common.collect.Sets;
+import io.fd.honeycomb.translate.util.DataObjects;
+import org.hamcrest.CoreMatchers;
+import org.junit.Test;
+
+public class TypeHierarchyTest {
+
+ @Test
+ public void testHierarchy() throws Exception {
+ final TypeHierarchy typeHierarchy = TypeHierarchy.create(Sets.newHashSet(
+ DataObjects.DataObject4.DataObject41.DataObject411.IID,
+ DataObjects.DataObject4.DataObject41.IID,/* Included in previous already */
+ DataObjects.DataObject1.IID,
+ DataObjects.DataObject3.DataObject31.IID));
+
+ // Roots
+ assertThat(typeHierarchy.getRoots().size(), is(3));
+ assertThat(typeHierarchy.getRoots(), CoreMatchers
+ .hasItems(DataObjects.DataObject1.IID, DataObjects.DataObject3.IID, DataObjects.DataObject4.IID));
+
+ // Leaves
+ assertThat(typeHierarchy.getDirectChildren(DataObjects.DataObject1.IID).size(), is(0));
+ assertThat(typeHierarchy.getDirectChildren(DataObjects.DataObject3.DataObject31.IID).size(), is(0));
+ assertThat(typeHierarchy.getDirectChildren(DataObjects.DataObject4.DataObject41.DataObject411.IID).size(), is(0));
+
+ // Intermediate leaves
+ assertThat(typeHierarchy.getDirectChildren(DataObjects.DataObject3.IID).size(), is(1));
+ assertThat(typeHierarchy.getDirectChildren(DataObjects.DataObject3.IID), CoreMatchers
+ .hasItem(DataObjects.DataObject3.DataObject31.IID));
+ assertEquals(typeHierarchy.getDirectChildren(DataObjects.DataObject3.IID), typeHierarchy.getAllChildren(
+ DataObjects.DataObject3.IID));
+
+ assertThat(typeHierarchy.getDirectChildren(DataObjects.DataObject4.DataObject41.IID).size(), is(1));
+ assertThat(typeHierarchy.getDirectChildren(DataObjects.DataObject4.DataObject41.IID), CoreMatchers.hasItem(
+ DataObjects.DataObject4.DataObject41.DataObject411.IID));
+ assertEquals(typeHierarchy.getDirectChildren(DataObjects.DataObject4.DataObject41.IID), typeHierarchy.getAllChildren(
+ DataObjects.DataObject4.DataObject41.IID));
+
+ assertThat(typeHierarchy.getDirectChildren(DataObjects.DataObject4.IID).size(), is(1));
+ assertThat(typeHierarchy.getDirectChildren(DataObjects.DataObject4.IID), CoreMatchers
+ .hasItem(DataObjects.DataObject4.DataObject41.IID));
+ assertThat(typeHierarchy.getAllChildren(DataObjects.DataObject4.IID).size(), is(2));
+ assertTrue(typeHierarchy.getAllChildren(DataObjects.DataObject4.IID).contains(DataObjects.DataObject4.DataObject41.IID));
+ assertTrue(typeHierarchy.getAllChildren(DataObjects.DataObject4.IID).contains(DataObjects.DataObject4.DataObject41.DataObject411.IID));
+ }
+}
+
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/write/registry/FlatWriterRegistryBuilderTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/registry/FlatWriterRegistryBuilderTest.java
index 743d84cbf..79590a5a0 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/write/registry/FlatWriterRegistryBuilderTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/registry/FlatWriterRegistryBuilderTest.java
@@ -1,4 +1,4 @@
-package io.fd.honeycomb.v3po.translate.util.write.registry;
+package io.fd.honeycomb.translate.util.write.registry;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.equalTo;
@@ -13,8 +13,8 @@ import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-import io.fd.honeycomb.v3po.translate.util.DataObjects;
-import io.fd.honeycomb.v3po.translate.write.Writer;
+import io.fd.honeycomb.translate.util.DataObjects;
+import io.fd.honeycomb.translate.write.Writer;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/write/registry/FlatWriterRegistryTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/registry/FlatWriterRegistryTest.java
index a72cb4fa7..6b75f923e 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/write/registry/FlatWriterRegistryTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/registry/FlatWriterRegistryTest.java
@@ -1,4 +1,4 @@
-package io.fd.honeycomb.v3po.translate.util.write.registry;
+package io.fd.honeycomb.translate.util.write.registry;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
@@ -17,13 +17,13 @@ import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
-import io.fd.honeycomb.v3po.translate.util.DataObjects.DataObject1;
-import io.fd.honeycomb.v3po.translate.util.DataObjects.DataObject2;
-import io.fd.honeycomb.v3po.translate.util.DataObjects.DataObject3;
-import io.fd.honeycomb.v3po.translate.write.DataObjectUpdate;
-import io.fd.honeycomb.v3po.translate.write.WriteContext;
-import io.fd.honeycomb.v3po.translate.write.Writer;
-import io.fd.honeycomb.v3po.translate.write.registry.WriterRegistry;
+import io.fd.honeycomb.translate.util.DataObjects;
+import io.fd.honeycomb.translate.write.DataObjectUpdate;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.Writer;
+import io.fd.honeycomb.translate.util.DataObjects.DataObject1;
+import io.fd.honeycomb.translate.write.registry.WriterRegistry;
+import org.hamcrest.CoreMatchers;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InOrder;
@@ -37,31 +37,31 @@ public class FlatWriterRegistryTest {
@Mock
private Writer<DataObject1> writer1;
@Mock
- private Writer<DataObject2> writer2;
+ private Writer<DataObjects.DataObject2> writer2;
@Mock
- private Writer<DataObject3> writer3;
+ private Writer<DataObjects.DataObject3> writer3;
@Mock
private WriteContext ctx;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- when(writer1.getManagedDataObjectType()).thenReturn(DataObject1.IID);
- when(writer2.getManagedDataObjectType()).thenReturn(DataObject2.IID);
- when(writer3.getManagedDataObjectType()).thenReturn(DataObject3.IID);
+ when(writer1.getManagedDataObjectType()).thenReturn(DataObjects.DataObject1.IID);
+ when(writer2.getManagedDataObjectType()).thenReturn(DataObjects.DataObject2.IID);
+ when(writer3.getManagedDataObjectType()).thenReturn(DataObjects.DataObject3.IID);
}
@Test
public void testMultipleUpdatesForSingleWriter() throws Exception {
final FlatWriterRegistry flatWriterRegistry =
- new FlatWriterRegistry(ImmutableMap.of(DataObject1.IID, writer1, DataObject2.IID, writer2));
+ new FlatWriterRegistry(ImmutableMap.of(DataObjects.DataObject1.IID, writer1, DataObjects.DataObject2.IID, writer2));
final Multimap<InstanceIdentifier<?>, DataObjectUpdate> updates = HashMultimap.create();
- final InstanceIdentifier<DataObject1> iid = InstanceIdentifier.create(DataObject1.class);
- final InstanceIdentifier<DataObject1> iid2 = InstanceIdentifier.create(DataObject1.class);
- final DataObject1 dataObject = mock(DataObject1.class);
- updates.put(DataObject1.IID, DataObjectUpdate.create(iid, dataObject, dataObject));
- updates.put(DataObject1.IID, DataObjectUpdate.create(iid2, dataObject, dataObject));
+ final InstanceIdentifier<DataObjects.DataObject1> iid = InstanceIdentifier.create(DataObjects.DataObject1.class);
+ final InstanceIdentifier<DataObjects.DataObject1> iid2 = InstanceIdentifier.create(DataObjects.DataObject1.class);
+ final DataObjects.DataObject1 dataObject = mock(DataObjects.DataObject1.class);
+ updates.put(DataObjects.DataObject1.IID, DataObjectUpdate.create(iid, dataObject, dataObject));
+ updates.put(DataObjects.DataObject1.IID, DataObjectUpdate.create(iid2, dataObject, dataObject));
flatWriterRegistry.update(new WriterRegistry.DataObjectUpdates(updates, ImmutableMultimap.of()), ctx);
verify(writer1).update(iid, dataObject, dataObject, ctx);
@@ -74,15 +74,15 @@ public class FlatWriterRegistryTest {
@Test
public void testMultipleUpdatesForMultipleWriters() throws Exception {
final FlatWriterRegistry flatWriterRegistry =
- new FlatWriterRegistry(ImmutableMap.of(DataObject1.IID, writer1, DataObject2.IID, writer2));
+ new FlatWriterRegistry(ImmutableMap.of(DataObjects.DataObject1.IID, writer1, DataObjects.DataObject2.IID, writer2));
final Multimap<InstanceIdentifier<?>, DataObjectUpdate> updates = HashMultimap.create();
- final InstanceIdentifier<DataObject1> iid = InstanceIdentifier.create(DataObject1.class);
- final DataObject1 dataObject = mock(DataObject1.class);
- updates.put(DataObject1.IID, DataObjectUpdate.create(iid, dataObject, dataObject));
- final InstanceIdentifier<DataObject2> iid2 = InstanceIdentifier.create(DataObject2.class);
- final DataObject2 dataObject2 = mock(DataObject2.class);
- updates.put(DataObject2.IID, DataObjectUpdate.create(iid2, dataObject2, dataObject2));
+ final InstanceIdentifier<DataObjects.DataObject1> iid = InstanceIdentifier.create(DataObjects.DataObject1.class);
+ final DataObjects.DataObject1 dataObject = mock(DataObjects.DataObject1.class);
+ updates.put(DataObjects.DataObject1.IID, DataObjectUpdate.create(iid, dataObject, dataObject));
+ final InstanceIdentifier<DataObjects.DataObject2> iid2 = InstanceIdentifier.create(DataObjects.DataObject2.class);
+ final DataObjects.DataObject2 dataObject2 = mock(DataObjects.DataObject2.class);
+ updates.put(DataObjects.DataObject2.IID, DataObjectUpdate.create(iid2, dataObject2, dataObject2));
flatWriterRegistry.update(new WriterRegistry.DataObjectUpdates(updates, ImmutableMultimap.of()), ctx);
final InOrder inOrder = inOrder(writer1, writer2);
@@ -96,15 +96,15 @@ public class FlatWriterRegistryTest {
@Test
public void testMultipleDeletesForMultipleWriters() throws Exception {
final FlatWriterRegistry flatWriterRegistry =
- new FlatWriterRegistry(ImmutableMap.of(DataObject1.IID, writer1, DataObject2.IID, writer2));
+ new FlatWriterRegistry(ImmutableMap.of(DataObjects.DataObject1.IID, writer1, DataObjects.DataObject2.IID, writer2));
final Multimap<InstanceIdentifier<?>, DataObjectUpdate.DataObjectDelete> deletes = HashMultimap.create();
- final InstanceIdentifier<DataObject1> iid = InstanceIdentifier.create(DataObject1.class);
- final DataObject1 dataObject = mock(DataObject1.class);
- deletes.put(DataObject1.IID, ((DataObjectUpdate.DataObjectDelete) DataObjectUpdate.create(iid, dataObject, null)));
- final InstanceIdentifier<DataObject2> iid2 = InstanceIdentifier.create(DataObject2.class);
- final DataObject2 dataObject2 = mock(DataObject2.class);
- deletes.put(DataObject2.IID, ((DataObjectUpdate.DataObjectDelete) DataObjectUpdate.create(iid2, dataObject2, null)));
+ final InstanceIdentifier<DataObjects.DataObject1> iid = InstanceIdentifier.create(DataObjects.DataObject1.class);
+ final DataObjects.DataObject1 dataObject = mock(DataObjects.DataObject1.class);
+ deletes.put(DataObjects.DataObject1.IID, ((DataObjectUpdate.DataObjectDelete) DataObjectUpdate.create(iid, dataObject, null)));
+ final InstanceIdentifier<DataObjects.DataObject2> iid2 = InstanceIdentifier.create(DataObjects.DataObject2.class);
+ final DataObjects.DataObject2 dataObject2 = mock(DataObjects.DataObject2.class);
+ deletes.put(DataObjects.DataObject2.IID, ((DataObjectUpdate.DataObjectDelete) DataObjectUpdate.create(iid2, dataObject2, null)));
flatWriterRegistry.update(new WriterRegistry.DataObjectUpdates(ImmutableMultimap.of(), deletes), ctx);
final InOrder inOrder = inOrder(writer1, writer2);
@@ -119,22 +119,22 @@ public class FlatWriterRegistryTest {
@Test
public void testMultipleUpdatesAndDeletesForMultipleWriters() throws Exception {
final FlatWriterRegistry flatWriterRegistry =
- new FlatWriterRegistry(ImmutableMap.of(DataObject1.IID, writer1, DataObject2.IID, writer2));
+ new FlatWriterRegistry(ImmutableMap.of(DataObjects.DataObject1.IID, writer1, DataObjects.DataObject2.IID, writer2));
final Multimap<InstanceIdentifier<?>, DataObjectUpdate.DataObjectDelete> deletes = HashMultimap.create();
final Multimap<InstanceIdentifier<?>, DataObjectUpdate> updates = HashMultimap.create();
- final InstanceIdentifier<DataObject1> iid = InstanceIdentifier.create(DataObject1.class);
- final DataObject1 dataObject = mock(DataObject1.class);
+ final InstanceIdentifier<DataObjects.DataObject1> iid = InstanceIdentifier.create(DataObjects.DataObject1.class);
+ final DataObjects.DataObject1 dataObject = mock(DataObjects.DataObject1.class);
// Writer 1 delete
- deletes.put(DataObject1.IID, ((DataObjectUpdate.DataObjectDelete) DataObjectUpdate.create(iid, dataObject, null)));
+ deletes.put(DataObjects.DataObject1.IID, ((DataObjectUpdate.DataObjectDelete) DataObjectUpdate.create(iid, dataObject, null)));
// Writer 1 update
- updates.put(DataObject1.IID, DataObjectUpdate.create(iid, dataObject, dataObject));
- final InstanceIdentifier<DataObject2> iid2 = InstanceIdentifier.create(DataObject2.class);
- final DataObject2 dataObject2 = mock(DataObject2.class);
+ updates.put(DataObjects.DataObject1.IID, DataObjectUpdate.create(iid, dataObject, dataObject));
+ final InstanceIdentifier<DataObjects.DataObject2> iid2 = InstanceIdentifier.create(DataObjects.DataObject2.class);
+ final DataObjects.DataObject2 dataObject2 = mock(DataObjects.DataObject2.class);
// Writer 2 delete
- deletes.put(DataObject2.IID, ((DataObjectUpdate.DataObjectDelete) DataObjectUpdate.create(iid2, dataObject2, null)));
+ deletes.put(DataObjects.DataObject2.IID, ((DataObjectUpdate.DataObjectDelete) DataObjectUpdate.create(iid2, dataObject2, null)));
// Writer 2 update
- updates.put(DataObject2.IID, DataObjectUpdate.create(iid2, dataObject2, dataObject2));
+ updates.put(DataObjects.DataObject2.IID, DataObjectUpdate.create(iid2, dataObject2, dataObject2));
flatWriterRegistry.update(new WriterRegistry.DataObjectUpdates(updates, deletes), ctx);
final InOrder inOrder = inOrder(writer1, writer2);
@@ -152,34 +152,34 @@ public class FlatWriterRegistryTest {
@Test(expected = IllegalArgumentException.class)
public void testMultipleUpdatesOneMissing() throws Exception {
final FlatWriterRegistry flatWriterRegistry =
- new FlatWriterRegistry(ImmutableMap.of(DataObject1.IID, writer1));
+ new FlatWriterRegistry(ImmutableMap.of(DataObjects.DataObject1.IID, writer1));
final Multimap<InstanceIdentifier<?>, DataObjectUpdate> updates = HashMultimap.create();
- addUpdate(updates, DataObject1.class);
- addUpdate(updates, DataObject2.class);
+ addUpdate(updates, DataObjects.DataObject1.class);
+ addUpdate(updates, DataObjects.DataObject2.class);
flatWriterRegistry.update(new WriterRegistry.DataObjectUpdates(updates, ImmutableMultimap.of()), ctx);
}
@Test
public void testMultipleUpdatesOneFailing() throws Exception {
final FlatWriterRegistry flatWriterRegistry =
- new FlatWriterRegistry(ImmutableMap.of(DataObject1.IID, writer1, DataObject2.IID, writer2));
+ new FlatWriterRegistry(ImmutableMap.of(DataObjects.DataObject1.IID, writer1, DataObjects.DataObject2.IID, writer2));
// Writer1 always fails
doThrow(new RuntimeException()).when(writer1)
.update(any(InstanceIdentifier.class), any(DataObject.class), any(DataObject.class), any(WriteContext.class));
final Multimap<InstanceIdentifier<?>, DataObjectUpdate> updates = HashMultimap.create();
- addUpdate(updates, DataObject1.class);
- addUpdate(updates, DataObject2.class);
+ addUpdate(updates, DataObjects.DataObject1.class);
+ addUpdate(updates, DataObjects.DataObject2.class);
try {
flatWriterRegistry.update(new WriterRegistry.DataObjectUpdates(updates, ImmutableMultimap.of()), ctx);
fail("Bulk update should have failed on writer1");
} catch (WriterRegistry.BulkUpdateException e) {
assertThat(e.getFailedIds().size(), is(2));
- assertThat(e.getFailedIds(), hasItem(InstanceIdentifier.create(DataObject2.class)));
- assertThat(e.getFailedIds(), hasItem(InstanceIdentifier.create(DataObject1.class)));
+ assertThat(e.getFailedIds(), CoreMatchers.hasItem(InstanceIdentifier.create(DataObjects.DataObject2.class)));
+ assertThat(e.getFailedIds(), CoreMatchers.hasItem(InstanceIdentifier.create(DataObjects.DataObject1.class)));
}
}
@@ -187,19 +187,19 @@ public class FlatWriterRegistryTest {
public void testMultipleUpdatesOneFailingThenRevertWithSuccess() throws Exception {
final FlatWriterRegistry flatWriterRegistry =
new FlatWriterRegistry(
- ImmutableMap.of(DataObject1.IID, writer1, DataObject2.IID, writer2, DataObject3.IID, writer3));
+ ImmutableMap.of(DataObjects.DataObject1.IID, writer1, DataObjects.DataObject2.IID, writer2, DataObjects.DataObject3.IID, writer3));
// Writer1 always fails
doThrow(new RuntimeException()).when(writer3)
.update(any(InstanceIdentifier.class), any(DataObject.class), any(DataObject.class), any(WriteContext.class));
final Multimap<InstanceIdentifier<?>, DataObjectUpdate> updates = HashMultimap.create();
- addUpdate(updates, DataObject1.class);
- addUpdate(updates, DataObject3.class);
- final InstanceIdentifier<DataObject2> iid2 = InstanceIdentifier.create(DataObject2.class);
- final DataObject2 before2 = mock(DataObject2.class);
- final DataObject2 after2 = mock(DataObject2.class);
- updates.put(DataObject2.IID, DataObjectUpdate.create(iid2, before2, after2));
+ addUpdate(updates, DataObjects.DataObject1.class);
+ addUpdate(updates, DataObjects.DataObject3.class);
+ final InstanceIdentifier<DataObjects.DataObject2> iid2 = InstanceIdentifier.create(DataObjects.DataObject2.class);
+ final DataObjects.DataObject2 before2 = mock(DataObjects.DataObject2.class);
+ final DataObjects.DataObject2 after2 = mock(DataObjects.DataObject2.class);
+ updates.put(DataObjects.DataObject2.IID, DataObjectUpdate.create(iid2, before2, after2));
try {
flatWriterRegistry.update(new WriterRegistry.DataObjectUpdates(updates, ImmutableMultimap.of()), ctx);
@@ -229,16 +229,16 @@ public class FlatWriterRegistryTest {
public void testMultipleUpdatesOneFailingThenRevertWithFail() throws Exception {
final FlatWriterRegistry flatWriterRegistry =
new FlatWriterRegistry(
- ImmutableMap.of(DataObject1.IID, writer1, DataObject2.IID, writer2, DataObject3.IID, writer3));
+ ImmutableMap.of(DataObjects.DataObject1.IID, writer1, DataObjects.DataObject2.IID, writer2, DataObjects.DataObject3.IID, writer3));
// Writer1 always fails
doThrow(new RuntimeException()).when(writer3)
.update(any(InstanceIdentifier.class), any(DataObject.class), any(DataObject.class), any(WriteContext.class));
final Multimap<InstanceIdentifier<?>, DataObjectUpdate> updates = HashMultimap.create();
- addUpdate(updates, DataObject1.class);
- addUpdate(updates, DataObject2.class);
- addUpdate(updates, DataObject3.class);
+ addUpdate(updates, DataObjects.DataObject1.class);
+ addUpdate(updates, DataObjects.DataObject2.class);
+ addUpdate(updates, DataObjects.DataObject3.class);
try {
flatWriterRegistry.update(new WriterRegistry.DataObjectUpdates(updates, ImmutableMultimap.of()), ctx);
@@ -251,7 +251,8 @@ public class FlatWriterRegistryTest {
e.revertChanges();
} catch (WriterRegistry.Reverter.RevertFailedException e1) {
assertThat(e1.getNotRevertedChanges().size(), is(1));
- assertThat(e1.getNotRevertedChanges(), hasItem(InstanceIdentifier.create(DataObject1.class)));
+ assertThat(e1.getNotRevertedChanges(), CoreMatchers
+ .hasItem(InstanceIdentifier.create(DataObjects.DataObject1.class)));
}
}
}
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/write/registry/SubtreeWriterTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/registry/SubtreeWriterTest.java
index 627c69c92..313dd34a8 100644
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/write/registry/SubtreeWriterTest.java
+++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/util/write/registry/SubtreeWriterTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.fd.honeycomb.v3po.translate.util.write.registry;
+package io.fd.honeycomb.translate.util.write.registry;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertEquals;
@@ -22,8 +22,8 @@ import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
import com.google.common.collect.Sets;
-import io.fd.honeycomb.v3po.translate.util.DataObjects;
-import io.fd.honeycomb.v3po.translate.write.Writer;
+import io.fd.honeycomb.translate.util.DataObjects;
+import io.fd.honeycomb.translate.write.Writer;
import java.util.Collections;
import org.junit.Before;
import org.junit.Test;
diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/read/registry/TypeHierarchyTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/read/registry/TypeHierarchyTest.java
deleted file mode 100644
index 7a664eef1..000000000
--- a/infra/translate-utils/src/test/java/io/fd/honeycomb/v3po/translate/util/read/registry/TypeHierarchyTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.honeycomb.v3po.translate.util.read.registry;
-
-import static org.hamcrest.CoreMatchers.hasItem;
-import static org.hamcrest.CoreMatchers.hasItems;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-import com.google.common.collect.Sets;
-import io.fd.honeycomb.v3po.translate.util.DataObjects.DataObject1;
-import io.fd.honeycomb.v3po.translate.util.DataObjects.DataObject3;
-import io.fd.honeycomb.v3po.translate.util.DataObjects.DataObject4;
-import org.junit.Test;
-
-public class TypeHierarchyTest {
-
- @Test
- public void testHierarchy() throws Exception {
- final TypeHierarchy typeHierarchy = TypeHierarchy.create(Sets.newHashSet(
- DataObject4.DataObject41.DataObject411.IID,
- DataObject4.DataObject41.IID,/* Included in previous already */
- DataObject1.IID,
- DataObject3.DataObject31.IID));
-
- // Roots
- assertThat(typeHierarchy.getRoots().size(), is(3));
- assertThat(typeHierarchy.getRoots(), hasItems(DataObject1.IID, DataObject3.IID, DataObject4.IID));
-
- // Leaves
- assertThat(typeHierarchy.getDirectChildren(DataObject1.IID).size(), is(0));
- assertThat(typeHierarchy.getDirectChildren(DataObject3.DataObject31.IID).size(), is(0));
- assertThat(typeHierarchy.getDirectChildren(DataObject4.DataObject41.DataObject411.IID).size(), is(0));
-
- // Intermediate leaves
- assertThat(typeHierarchy.getDirectChildren(DataObject3.IID).size(), is(1));
- assertThat(typeHierarchy.getDirectChildren(DataObject3.IID), hasItem(DataObject3.DataObject31.IID));
- assertEquals(typeHierarchy.getDirectChildren(DataObject3.IID), typeHierarchy.getAllChildren(DataObject3.IID));
-
- assertThat(typeHierarchy.getDirectChildren(DataObject4.DataObject41.IID).size(), is(1));
- assertThat(typeHierarchy.getDirectChildren(DataObject4.DataObject41.IID), hasItem(
- DataObject4.DataObject41.DataObject411.IID));
- assertEquals(typeHierarchy.getDirectChildren(DataObject4.DataObject41.IID), typeHierarchy.getAllChildren(
- DataObject4.DataObject41.IID));
-
- assertThat(typeHierarchy.getDirectChildren(DataObject4.IID).size(), is(1));
- assertThat(typeHierarchy.getDirectChildren(DataObject4.IID), hasItem(DataObject4.DataObject41.IID));
- assertThat(typeHierarchy.getAllChildren(DataObject4.IID).size(), is(2));
- assertTrue(typeHierarchy.getAllChildren(DataObject4.IID).contains(DataObject4.DataObject41.IID));
- assertTrue(typeHierarchy.getAllChildren(DataObject4.IID).contains(DataObject4.DataObject41.DataObject411.IID));
- }
-}
-