summaryrefslogtreecommitdiffstats
path: root/vpp-common/vpp-translate-test/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'vpp-common/vpp-translate-test/src/main')
-rw-r--r--vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializationTest.java54
-rw-r--r--vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingListReaderCustomizerTest.java17
-rw-r--r--vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingReaderCustomizerTest.java12
3 files changed, 79 insertions, 4 deletions
diff --git a/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializationTest.java b/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializationTest.java
new file mode 100644
index 000000000..5ea1257ce
--- /dev/null
+++ b/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializationTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017 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.hc2vpp.common.test.read;
+
+
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.spi.read.Initialized;
+import io.fd.honeycomb.translate.spi.read.InitializingCustomizer;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import javax.annotation.Nonnull;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+interface InitializationTest<D extends DataObject> {
+
+ /**
+ * Invokes initialization test
+ *
+ * @param customizer initialization capable customizer
+ * @param ctx read context
+ * @param operationalPath paths passed to initialization
+ * @param operationalData data passed to initialization
+ * @param configPath expected data path
+ * @param configData expected data
+ */
+ default void invokeInit(@Nonnull final InitializingCustomizer<D> customizer,
+ @Nonnull final ReadContext ctx,
+ @Nonnull final InstanceIdentifier<D> operationalPath,
+ @Nonnull final D operationalData,
+ @Nonnull final InstanceIdentifier<?> configPath,
+ @Nonnull final Object configData) {
+ final Initialized<? extends DataObject> init = customizer.init(operationalPath, operationalData, ctx);
+ assertNotNull(init);
+ assertEquals(configPath, init.getId());
+ assertEquals(configData, init.getData());
+ }
+}
diff --git a/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingListReaderCustomizerTest.java b/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingListReaderCustomizerTest.java
index b6089c4da..7ad2055c7 100644
--- a/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingListReaderCustomizerTest.java
+++ b/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingListReaderCustomizerTest.java
@@ -21,6 +21,9 @@ import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.Identifiable;
import org.opendaylight.yangtools.yang.binding.Identifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import javax.annotation.Nonnull;
/**
* Generic test for classes implementing {@link InitializingListReaderCustomizer} interface.
@@ -30,11 +33,12 @@ import org.opendaylight.yangtools.yang.binding.Identifier;
* @param <B> Specific Builder for handled type (D)
*/
public abstract class InitializingListReaderCustomizerTest<D extends DataObject & Identifiable<K>, K extends Identifier<D>, B extends Builder<D>> extends
- ListReaderCustomizerTest<D, K, B> {
+ ListReaderCustomizerTest<D, K, B> implements InitializationTest<D> {
+
protected InitializingListReaderCustomizerTest(
- final Class<D> dataObjectClass,
- final Class<? extends Builder<? extends DataObject>> parentBuilderClass) {
+ final Class<D> dataObjectClass,
+ final Class<? extends Builder<? extends DataObject>> parentBuilderClass) {
super(dataObjectClass, parentBuilderClass);
}
@@ -42,4 +46,11 @@ public abstract class InitializingListReaderCustomizerTest<D extends DataObject
protected InitializingListReaderCustomizer<D, K, B> getCustomizer() {
return InitializingListReaderCustomizer.class.cast(super.getCustomizer());
}
+
+ protected void invokeInitTest(@Nonnull InstanceIdentifier<D> operationalPath,
+ @Nonnull D operationalData,
+ @Nonnull InstanceIdentifier<?> configPath,
+ @Nonnull Object configData) {
+ invokeInit(getCustomizer(), ctx, operationalPath, operationalData, configPath, configData);
+ }
}
diff --git a/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingReaderCustomizerTest.java b/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingReaderCustomizerTest.java
index e102ef827..69fd6abac 100644
--- a/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingReaderCustomizerTest.java
+++ b/vpp-common/vpp-translate-test/src/main/java/io/fd/hc2vpp/common/test/read/InitializingReaderCustomizerTest.java
@@ -19,6 +19,9 @@ package io.fd.hc2vpp.common.test.read;
import io.fd.honeycomb.translate.spi.read.InitializingReaderCustomizer;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import javax.annotation.Nonnull;
/**
* Generic test for classes implementing {@link InitializingReaderCustomizer} interface.
@@ -27,7 +30,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
* @param <B> Specific Builder for handled type (D)
*/
public abstract class InitializingReaderCustomizerTest<D extends DataObject, B extends Builder<D>> extends
- ReaderCustomizerTest<D, B> {
+ ReaderCustomizerTest<D, B> implements InitializationTest<D> {
protected InitializingReaderCustomizerTest(
final Class<D> dataObjectClass,
@@ -39,4 +42,11 @@ public abstract class InitializingReaderCustomizerTest<D extends DataObject, B e
protected InitializingReaderCustomizer<D, B> getCustomizer() {
return InitializingReaderCustomizer.class.cast(super.getCustomizer());
}
+
+ protected void invokeInitTest(@Nonnull InstanceIdentifier<D> operationalPath,
+ @Nonnull D operationalData,
+ @Nonnull InstanceIdentifier<?> configPath,
+ @Nonnull Object configData) {
+ invokeInit(getCustomizer(), ctx, operationalPath, operationalData, configPath, configData);
+ }
}