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.junit.Assert.assertNotNull;
21 import io.fd.honeycomb.translate.MappingContext;
22 import io.fd.honeycomb.translate.ModificationCache;
23 import io.fd.honeycomb.translate.read.ReadContext;
24 import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.mockito.Mock;
28 import org.mockito.Mockito;
29 import org.mockito.MockitoAnnotations;
30 import org.opendaylight.yangtools.concepts.Builder;
31 import org.opendaylight.yangtools.yang.binding.DataObject;
32 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
33 import org.openvpp.jvpp.core.future.FutureJVppCore;
36 * Generic test for classes implementing {@link ReaderCustomizer} interface.
38 * @param <D> Specific DataObject derived type (Identifiable), that is handled by this customizer
39 * @param <B> Specific Builder for handled type (D)
41 public abstract class ReaderCustomizerTest<D extends DataObject, B extends Builder<D>> {
44 protected FutureJVppCore api;
46 protected ReadContext ctx;
48 protected MappingContext mappingContext;
50 protected ModificationCache cache;
51 protected final Class<D> dataObjectClass;
52 private ReaderCustomizer<D, B> customizer;
54 protected ReaderCustomizerTest(Class<D> dataObjectClass) {
55 this.dataObjectClass = dataObjectClass;
59 public void setUpParent() throws Exception {
60 MockitoAnnotations.initMocks(this);
61 cache = new ModificationCache();
62 Mockito.doReturn(cache).when(ctx).getModificationCache();
63 Mockito.doReturn(mappingContext).when(ctx).getMappingContext();
65 customizer = initCustomizer();
69 * Optional setup for subclasses. Invoked before customizer is initialized.
71 protected void setUp() throws Exception {
74 protected abstract ReaderCustomizer<D, B> initCustomizer();
76 protected ReaderCustomizer<D, B> getCustomizer() {
81 public void testGetBuilder() throws Exception {
82 assertNotNull(customizer.getBuilder(InstanceIdentifier.create(dataObjectClass)));
85 // TODO HONEYCOMB-116: create generic testMerge()