HONEYCOMB-58 - Routing Api
[honeycomb.git] / lisp / lisp2vpp / src / test / java / io / fd / honeycomb / lisp / translate / read / LispStateCustomizerTest.java
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.lisp.translate.read;
18
19 import static org.junit.Assert.assertEquals;
20 import static org.mockito.Mockito.when;
21
22 import io.fd.honeycomb.translate.read.ReadFailedException;
23 import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
24 import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.mockito.Mockito;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.LispState;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev161214.LispStateBuilder;
30 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
31 import io.fd.vpp.jvpp.core.dto.ShowLispStatusReply;
32
33 public class LispStateCustomizerTest extends ReaderCustomizerTest<LispState, LispStateBuilder> {
34
35     private InstanceIdentifier<LispState> identifier;
36
37     public LispStateCustomizerTest() {
38         super(LispState.class, null);
39     }
40
41     @Before
42     public void init() {
43         identifier = InstanceIdentifier.create(LispState.class);
44         final ShowLispStatusReply reply = new ShowLispStatusReply();
45         reply.featureStatus = 1;
46
47         when(api.showLispStatus(Mockito.any())).thenReturn(future(reply));
48     }
49
50     @Test
51     public void testReadCurrentAttributes() throws ReadFailedException {
52
53         LispStateBuilder builder = new LispStateBuilder();
54         getCustomizer().readCurrentAttributes(identifier, builder, ctx);
55
56         assertEquals(true, builder.build().isEnable());
57     }
58
59     @Override
60     protected ReaderCustomizer<LispState, LispStateBuilder> initCustomizer() {
61         return new LispStateCustomizer(api);
62     }
63
64     @Override
65     public void testMerge() throws Exception {
66         //LispState is root node, so there is no way to implement merge(it is also not needed)
67     }
68 }