6c345223eca3d440f48beb48f92089f92c41b87c
[honeycomb.git] / lisp / lisp2vpp / src / test / java / io / fd / honeycomb / lisp / translate / read / PitrCfgCustomizerTest.java
1 package io.fd.honeycomb.lisp.translate.read;
2
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotNull;
5 import static org.mockito.Matchers.any;
6 import static org.mockito.Mockito.when;
7
8 import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
9 import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
10 import java.nio.charset.StandardCharsets;
11 import org.junit.Before;
12 import org.junit.Test;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispStateBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.lisp.feature.data.grouping.LispFeatureDataBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfg;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfgBuilder;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
18 import io.fd.vpp.jvpp.core.dto.ShowLispPitrReply;
19
20
21 public class PitrCfgCustomizerTest extends ReaderCustomizerTest<PitrCfg, PitrCfgBuilder> {
22
23     private static final byte[] LOC_SET_NAME_BYTES = "loc-set".getBytes(StandardCharsets.UTF_8);
24
25     private InstanceIdentifier<PitrCfg> emptyId;
26
27     public PitrCfgCustomizerTest() {
28         super(PitrCfg.class, LispFeatureDataBuilder.class);
29     }
30
31     @Before
32     public void init() {
33         emptyId = InstanceIdentifier.create(PitrCfg.class);
34
35         mockDumpData();
36     }
37
38     @Test
39     public void readCurrentAttributes() throws Exception {
40         PitrCfgBuilder builder = new PitrCfgBuilder();
41         getCustomizer().readCurrentAttributes(emptyId, builder, ctx);
42
43         final PitrCfg cfg = builder.build();
44
45         assertNotNull(cfg);
46         assertEquals("loc-set", cfg.getLocatorSet());
47     }
48
49     private void mockDumpData() {
50         ShowLispPitrReply replyDump = new ShowLispPitrReply();
51         replyDump.locatorSetName = LOC_SET_NAME_BYTES;
52         replyDump.status = 1;
53
54         when(api.showLispPitr(any())).thenReturn(future(replyDump));
55     }
56
57     @Override
58     protected ReaderCustomizer<PitrCfg, PitrCfgBuilder> initCustomizer() {
59         return new PitrCfgCustomizer(api);
60     }
61 }