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.v4;
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.Ipv4;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.Ipv4Builder;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.Neighbor;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.NeighborBuilder;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces.state._interface.ipv4.NeighborKey;
32 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
34 import java.util.Arrays;
36 import static org.junit.Assert.assertEquals;
38 public class Ipv4NeighbourCustomizerTest extends ListReaderCustomizerTest<Neighbor, NeighborKey, NeighborBuilder>
39 implements InterfaceChildNodeTest {
41 private InstanceIdentifier<Neighbor> instanceIdentifier;
43 public Ipv4NeighbourCustomizerTest() {
44 super(Neighbor.class, Ipv4Builder.class);
48 protected void setUp() throws Exception {
49 instanceIdentifier = InstanceIdentifier.create(InterfacesState.class)
50 .child(Interface.class, new InterfaceKey(IFACE_NAME))
51 .augmentation(Interface2.class)
53 .child(Neighbor.class, new NeighborKey(IPV4_ONE_ADDRESS));
54 defineMapping(mappingContext, IFACE_NAME, IFACE_ID, INTERFACE_CONTEXT_NAME);
55 mockNeighborDump(api, dumpV4NeighborIfaceOne(), v4Neighbors());
59 public void testGetAll() throws ReadFailedException {
60 verifyList(Arrays.asList(new NeighborKey(IPV4_ONE_ADDRESS), new NeighborKey(IPV4_TWO_ADDRESS)),
61 getCustomizer().getAllIds(instanceIdentifier, ctx));
65 public void readCurrent() throws ReadFailedException {
66 final NeighborBuilder builder = new NeighborBuilder();
67 getCustomizer().readCurrentAttributes(instanceIdentifier, builder, ctx);
69 assertEquals(IPV4_ONE_ADDRESS, builder.getIp());
70 assertEquals(MAC_ONE_ADDRESS, builder.getLinkLayerAddress());
74 protected ReaderCustomizer<Neighbor, NeighborBuilder> initCustomizer() {
75 return new Ipv4NeighbourCustomizer(api, INTERFACE_CONTEXT);