e09d7b617afb55f98d0f1d58b320a3c9d739fde0
[hc2vpp.git] /
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
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:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package io.fd.honeycomb.vpp.test.write;
18
19 import io.fd.honeycomb.translate.MappingContext;
20 import io.fd.honeycomb.translate.ModificationCache;
21 import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
22 import io.fd.honeycomb.translate.write.WriteContext;
23 import io.fd.honeycomb.vpp.test.util.FutureProducer;
24 import org.junit.Before;
25 import org.mockito.Mock;
26 import org.mockito.Mockito;
27 import org.mockito.MockitoAnnotations;
28 import org.openvpp.jvpp.core.future.FutureJVppCore;
29
30 /**
31  * Generic test for classes implementing {@link WriterCustomizer} interface.
32  */
33 public abstract class WriterCustomizerTest implements FutureProducer {
34
35     @Mock
36     protected FutureJVppCore api;
37     @Mock
38     protected WriteContext writeContext;
39     @Mock
40     protected MappingContext mappingContext;
41
42     protected ModificationCache cache;
43
44     protected WriterCustomizerTest() {
45     }
46
47     @Before
48     public void setUpParent() throws Exception {
49         MockitoAnnotations.initMocks(this);
50         cache = new ModificationCache();
51         Mockito.doReturn(cache).when(writeContext).getModificationCache();
52         Mockito.doReturn(mappingContext).when(writeContext).getMappingContext();
53         setUp();
54     }
55
56     /**
57      * Optional setup for subclasses. Invoked after parent initialization.
58      */
59     protected void setUp() throws Exception {
60     }
61 }