diff options
author | Maros Marsalek <mmarsale@cisco.com> | 2016-11-08 10:13:36 +0100 |
---|---|---|
committer | Maros Marsalek <mmarsale@cisco.com> | 2016-11-08 13:17:57 +0100 |
commit | 757222979bc02d0aaba1870eea36413383d15bde (patch) | |
tree | 3fe2a502026fbfa9a4ae5627e1a453a057f6c1fa /infra/it/it-test/src/test/java/io | |
parent | 03a638b95da83e150d4f69451c8733b5f09c37aa (diff) |
HONEYCOMB-270 Add isPresent() to Readers/Customizers
So that they can influence whether empty data is to be considered as present
+ Move registries implementations from util to impl
+ Introduce DelegatingReader trait
+ Extend GenericReader where possible to reduce duplication
Change-Id: I5a416acd0c4eab1fbc30fcbe585719991dbe9215
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'infra/it/it-test/src/test/java/io')
3 files changed, 14 insertions, 6 deletions
diff --git a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombReadInfraTest.java b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombReadInfraTest.java index 5ec2b55ba..6d4c9e6f3 100644 --- a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombReadInfraTest.java +++ b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombReadInfraTest.java @@ -24,6 +24,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyListOf; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.atMost; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.inOrder; @@ -36,6 +37,8 @@ import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import com.google.common.util.concurrent.CheckedFuture; import io.fd.honeycomb.translate.impl.read.GenericListReader; +import io.fd.honeycomb.translate.impl.read.GenericReader; +import io.fd.honeycomb.translate.impl.read.registry.CompositeReaderRegistryBuilder; import io.fd.honeycomb.translate.read.ListReader; import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.read.ReadFailedException; @@ -43,8 +46,7 @@ import io.fd.honeycomb.translate.read.Reader; import io.fd.honeycomb.translate.read.registry.ReaderRegistry; import io.fd.honeycomb.translate.util.RWUtils; import io.fd.honeycomb.translate.util.read.ReflexiveListReaderCustomizer; -import io.fd.honeycomb.translate.util.read.ReflexiveReader; -import io.fd.honeycomb.translate.util.read.registry.CompositeReaderRegistryBuilder; +import io.fd.honeycomb.translate.util.read.ReflexiveReaderCustomizer; import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.stream.Collectors; @@ -185,8 +187,11 @@ public class HoneycombReadInfraTest extends AbstractInfraTest { } } - private <D extends DataObject, B extends Builder<D>> void verifyNoMoreReadInteractions(final Reader<D, B> reader) { + private <D extends DataObject, B extends Builder<D>> void verifyNoMoreReadInteractions(final Reader<D, B> reader) + throws ReadFailedException { verify(reader, atLeastOnce()).getManagedDataObjectType(); + // Just mark all the isPresent calls as verified + verify(reader, atMost(100)).isPresent(any(InstanceIdentifier.class), any(), any()); verifyNoMoreInteractions(reader); } @@ -254,7 +259,8 @@ public class HoneycombReadInfraTest extends AbstractInfraTest { static <D extends DataObject, B extends Builder<D>> Reader<D, B> mockReader(InstanceIdentifier<D> id, CurrentAttributesReader<D, B> currentAttributesReader, Class<B> builderClass) { - final ReflexiveReader<D, B> reflex = new ReflexiveReader<D, B>(id, builderClass) { + final Reader<D, B> reflex = new GenericReader<D, B>(id, + new ReflexiveReaderCustomizer<>(id.getTargetType(), builderClass)) { @Override public void readCurrentAttributes(@Nonnull final InstanceIdentifier<D> id, @@ -270,6 +276,7 @@ public class HoneycombReadInfraTest extends AbstractInfraTest { final Reader<D, B> mock = mock(Reader.class); try { doAnswer(i -> reflexiveAnswer(reflex, i)).when(mock).read(any(InstanceIdentifier.class), any(ReadContext.class)); + doAnswer(i -> reflexiveAnswer(reflex, i)).when(mock).isPresent(any(InstanceIdentifier.class), any(), any()); doAnswer(i -> reflexiveAnswer(reflex, i)).when(mock) .readCurrentAttributes(any(InstanceIdentifier.class), any(builderClass), any(ReadContext.class)); doAnswer(i -> reflexiveAnswer(reflex, i)).when(mock).merge(any(Builder.class), any(id.getTargetType())); @@ -311,6 +318,7 @@ public class HoneycombReadInfraTest extends AbstractInfraTest { // not using eq(id) instead using any(InstanceIdentifier.class) due to InstanceIdentifier.equals weird behavior // with wildcarded instance identifiers for lists doAnswer(i -> reflexiveAnswer(reflex, i)).when(mock).read(any(InstanceIdentifier.class), any(ReadContext.class)); + doAnswer(i -> reflexiveAnswer(reflex, i)).when(mock).isPresent(any(InstanceIdentifier.class), any(), any()); doAnswer(i -> reflexiveAnswer(reflex, i)).when(mock) .readCurrentAttributes(any(InstanceIdentifier.class), any(builderClass), any(ReadContext.class)); doAnswer(i -> reflexiveAnswer(reflex, i)).when(mock).merge(any(Builder.class), any(id.getTargetType())); diff --git a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombSubtreeReadInfraTest.java b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombSubtreeReadInfraTest.java index 5bb81b477..1894f4942 100644 --- a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombSubtreeReadInfraTest.java +++ b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombSubtreeReadInfraTest.java @@ -32,7 +32,7 @@ import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.read.Reader; import io.fd.honeycomb.translate.read.registry.ReaderRegistry; import io.fd.honeycomb.translate.util.read.ReflexiveListReaderCustomizer; -import io.fd.honeycomb.translate.util.read.registry.CompositeReaderRegistryBuilder; +import io.fd.honeycomb.translate.impl.read.registry.CompositeReaderRegistryBuilder; import java.util.List; import java.util.stream.Collectors; import javax.annotation.Nonnull; diff --git a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombWriteInfraTest.java b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombWriteInfraTest.java index 12ae6568d..bd51e39de 100644 --- a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombWriteInfraTest.java +++ b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombWriteInfraTest.java @@ -29,7 +29,7 @@ import static org.mockito.Mockito.when; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import io.fd.honeycomb.data.DataModification; -import io.fd.honeycomb.translate.util.write.registry.FlatWriterRegistryBuilder; +import io.fd.honeycomb.translate.impl.write.registry.FlatWriterRegistryBuilder; import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.honeycomb.translate.write.WriteContext; import io.fd.honeycomb.translate.write.Writer; |