6f5a08abbdd8255073ef8d5fd0ce5c287b4481f3
[hc2vpp.git] /
1 /*
2  * Copyright (c) 2017 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 package io.fd.hc2vpp.v3po.interfacesstate.ip.v6;
17
18 import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest;
19 import io.fd.hc2vpp.v3po.interfacesstate.ip.InterfaceChildNodeTest;
20 import io.fd.honeycomb.translate.read.ReadFailedException;
21 import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
22 import org.junit.Test;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.Interface2;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.Ipv6;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.Ipv6Builder;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv6.Neighbor;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv6.NeighborBuilder;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv6.NeighborKey;
32 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
33
34 import java.util.Arrays;
35
36 import static org.junit.Assert.assertEquals;
37
38
39 public class Ipv6NeighbourCustomizerTest extends ListReaderCustomizerTest<Neighbor, NeighborKey, NeighborBuilder>
40         implements InterfaceChildNodeTest {
41
42     private InstanceIdentifier<Neighbor> instanceIdentifier;
43
44     public Ipv6NeighbourCustomizerTest() {
45         super(Neighbor.class, Ipv6Builder.class);
46     }
47
48     @Override
49     protected void setUp() throws Exception {
50         instanceIdentifier = InstanceIdentifier.create(InterfacesState.class)
51                 .child(Interface.class, new InterfaceKey(IFACE_NAME))
52                 .augmentation(Interface2.class)
53                 .child(Ipv6.class)
54                 .child(Neighbor.class, new NeighborKey(IPV6_ONE_ADDRESS_COMPRESSED));
55         defineMapping(mappingContext, IFACE_NAME, IFACE_ID, INTERFACE_CONTEXT_NAME);
56         mockNeighborDump(api, dumpV6NeighborsIfaceOne(), v6Neighbors());
57     }
58
59     @Test
60     public void testGetAll() throws ReadFailedException {
61         verifyList(Arrays.asList(
62                 new NeighborKey(IPV6_ONE_ADDRESS_COMPRESSED),
63                 new NeighborKey(IPV6_TWO_ADDRESS_COMPRESSED)),
64                 getCustomizer().getAllIds(instanceIdentifier, ctx));
65     }
66
67     @Test
68     public void readCurrent() throws ReadFailedException {
69         final NeighborBuilder builder = new NeighborBuilder();
70         getCustomizer().readCurrentAttributes(instanceIdentifier, builder, ctx);
71
72         assertEquals(IPV6_ONE_ADDRESS_COMPRESSED, builder.getIp());
73         assertEquals(MAC_THREE_ADDRESS, builder.getLinkLayerAddress());
74     }
75
76     @Override
77     protected ReaderCustomizer<Neighbor, NeighborBuilder> initCustomizer() {
78         return new Ipv6NeighbourCustomizer(api, INTERFACE_CONTEXT);
79     }
80 }