diff options
author | 2016-09-26 08:20:34 +0200 | |
---|---|---|
committer | 2016-09-26 08:20:34 +0200 | |
commit | a7e61b5d5abc604df214cd268b8443138717e9af (patch) | |
tree | 5ccd62bd6afb5cc95198a45d6323c7c426b3e38f /vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java | |
parent | d3e26e08584c1ec07344a43479bf6b46b83a9dfe (diff) |
HONEYCOMB-116: generic merge test for reader customizers
Change-Id: I5c2505e6b3bcf622312f8dc324912507f6519a5b
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java')
-rw-r--r-- | vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java index 6486c8eb9..22dc2b6fd 100644 --- a/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java +++ b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java @@ -17,6 +17,8 @@ package io.fd.honeycomb.vpp.test.read; import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import io.fd.honeycomb.translate.MappingContext; import io.fd.honeycomb.translate.ModificationCache; @@ -26,6 +28,7 @@ import io.fd.honeycomb.translate.read.ReadContext; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; import io.fd.honeycomb.vpp.test.util.FutureProducer; import io.fd.honeycomb.vpp.test.util.NamingContextHelper; +import java.lang.reflect.Method; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -52,12 +55,16 @@ public abstract class ReaderCustomizerTest<D extends DataObject, B extends Build @Mock protected MappingContext mappingContext; - protected ModificationCache cache; + protected final Class<? extends Builder<? extends DataObject>> parentBuilderClass; protected final Class<D> dataObjectClass; + protected ModificationCache cache; protected ReaderCustomizer<D, B> customizer; - protected ReaderCustomizerTest(Class<D> dataObjectClass) { + public ReaderCustomizerTest( + final Class<D> dataObjectClass, + final Class<? extends Builder<? extends DataObject>> parentBuilderClass) { this.dataObjectClass = dataObjectClass; + this.parentBuilderClass = parentBuilderClass; } @Before @@ -87,5 +94,13 @@ public abstract class ReaderCustomizerTest<D extends DataObject, B extends Build assertNotNull(customizer.getBuilder(InstanceIdentifier.create(dataObjectClass))); } - // TODO HONEYCOMB-116: create generic testMerge() + @Test + public void testMerge() throws Exception { + final Builder<? extends DataObject> parentBuilder = mock(parentBuilderClass); + final D value = mock(dataObjectClass); + getCustomizer().merge(parentBuilder, value); + + final Method method = parentBuilderClass.getMethod("set" + dataObjectClass.getSimpleName(), dataObjectClass); + method.invoke(verify(parentBuilder), value); + } } |