2 * Copyright (c) 2017 Cisco and/or its affiliates.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package io.fd.hc2vpp.v3po.interfacesstate.ip.v6;
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;
34 import java.util.Arrays;
36 import static org.junit.Assert.assertEquals;
39 public class Ipv6NeighbourCustomizerTest extends ListReaderCustomizerTest<Neighbor, NeighborKey, NeighborBuilder>
40 implements InterfaceChildNodeTest {
42 private InstanceIdentifier<Neighbor> instanceIdentifier;
44 public Ipv6NeighbourCustomizerTest() {
45 super(Neighbor.class, Ipv6Builder.class);
49 protected void setUp() throws Exception {
50 instanceIdentifier = InstanceIdentifier.create(InterfacesState.class)
51 .child(Interface.class, new InterfaceKey(IFACE_NAME))
52 .augmentation(Interface2.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());
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));
68 public void readCurrent() throws ReadFailedException {
69 final NeighborBuilder builder = new NeighborBuilder();
70 getCustomizer().readCurrentAttributes(instanceIdentifier, builder, ctx);
72 assertEquals(IPV6_ONE_ADDRESS_COMPRESSED, builder.getIp());
73 assertEquals(MAC_THREE_ADDRESS, builder.getLinkLayerAddress());
77 protected ReaderCustomizer<Neighbor, NeighborBuilder> initCustomizer() {
78 return new Ipv6NeighbourCustomizer(api, INTERFACE_CONTEXT);