2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.honeycomb.vpp.test.read;
19 import static org.mockito.Mockito.mock;
20 import static org.mockito.Mockito.verify;
22 import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
23 import java.lang.reflect.Method;
24 import java.util.List;
25 import org.opendaylight.yangtools.concepts.Builder;
26 import org.opendaylight.yangtools.yang.binding.DataObject;
27 import org.opendaylight.yangtools.yang.binding.Identifiable;
28 import org.opendaylight.yangtools.yang.binding.Identifier;
31 * Generic test for classes implementing {@link ListReaderCustomizer} interface.
33 * @param <D> Specific DataObject derived type (Identifiable), that is handled by this customizer
34 * @param <K> Specific Identifier for handled type (D)
35 * @param <B> Specific Builder for handled type (D)
37 public abstract class ListReaderCustomizerTest<D extends DataObject & Identifiable<K>, K extends Identifier<D>, B extends Builder<D>> extends
38 ReaderCustomizerTest<D, B> {
40 protected ListReaderCustomizerTest(
41 final Class<D> dataObjectClass,
42 final Class<? extends Builder<? extends DataObject>> parentBuilderClass) {
43 super(dataObjectClass, parentBuilderClass);
47 protected ListReaderCustomizer<D, K, B> getCustomizer() {
48 return ListReaderCustomizer.class.cast(super.getCustomizer());
52 public void testMerge() throws Exception {
53 final Builder<? extends DataObject> parentBuilder = mock(parentBuilderClass);
54 final List<D> value = (List<D>) mock(List.class);
55 getCustomizer().merge(parentBuilder, value);
57 final Method method = parentBuilderClass.getMethod("set" + dataObjectClass.getSimpleName(), List.class);
58 method.invoke(verify(parentBuilder), value);