24fd17eb8839230cc991b93f53fe78c212d5aa7f
[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.subinterface;
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.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.SubinterfaceStateAugmentation;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces.state._interface.SubInterfaces;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces.state._interface.sub.interfaces.SubInterface;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces.state._interface.sub.interfaces.SubInterfaceKey;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip6.attributes.Ipv6;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip6.attributes.Ipv6Builder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip6.attributes.ipv6.Neighbor;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip6.attributes.ipv6.NeighborBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip6.attributes.ipv6.NeighborKey;
35 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
36
37 import java.util.Arrays;
38
39 import static org.junit.Assert.assertEquals;
40
41 public class SubInterfaceIpv6NeighbourCustomizerTest extends ListReaderCustomizerTest<Neighbor, NeighborKey, NeighborBuilder>
42         implements InterfaceChildNodeTest {
43
44     private InstanceIdentifier<Neighbor> instanceIdentifier;
45
46     public SubInterfaceIpv6NeighbourCustomizerTest() {
47         super(Neighbor.class, Ipv6Builder.class);
48     }
49
50     @Override
51     protected void setUp() throws Exception {
52         instanceIdentifier = InstanceIdentifier.create(InterfacesState.class)
53                 .child(Interface.class, new InterfaceKey(IFACE_2_NAME))
54                 .augmentation(SubinterfaceStateAugmentation.class)
55                 .child(SubInterfaces.class)
56                 .child(SubInterface.class, new SubInterfaceKey((long) SUB_IFACE_2_ID))
57                 .child(Ipv6.class)
58                 .child(Neighbor.class, new NeighborKey(IPV6_TWO_ADDRESS_COMPRESSED));
59         defineMapping(mappingContext, IFACE_2_NAME, IFACE_2_ID, INTERFACE_CONTEXT_NAME);
60         defineMapping(mappingContext, SUB_IFACE_2_NAME, SUB_IFACE_2_ID, INTERFACE_CONTEXT_NAME);
61         mockNeighborDump(api, dumpV6NeighborsSubIfaceTwo(), v6Neighbors());
62     }
63
64     @Test
65     public void testGetAll() throws ReadFailedException {
66         verifyList(Arrays.asList(
67                 new NeighborKey(IPV6_ONE_ADDRESS_COMPRESSED),
68                 new NeighborKey(IPV6_TWO_ADDRESS_COMPRESSED)),
69                 getCustomizer().getAllIds(instanceIdentifier, ctx));
70     }
71
72     @Test
73     public void readCurrent() throws ReadFailedException {
74         NeighborBuilder builder = new NeighborBuilder();
75         getCustomizer().readCurrentAttributes(instanceIdentifier, builder, ctx);
76
77         assertEquals(IPV6_TWO_ADDRESS_COMPRESSED, builder.getIp());
78         assertEquals(MAC_FOUR_ADDRESS, builder.getLinkLayerAddress());
79     }
80
81     @Override
82     protected ReaderCustomizer<Neighbor, NeighborBuilder> initCustomizer() {
83         return new SubInterfaceIpv6NeighbourCustomizer(api, INTERFACE_CONTEXT);
84     }
85 }