21ffdc943cbbbffca2d73b8e1ea72f8c3d8e8382
[hc2vpp.git] /
1 // FIXME new vlan model
2 ///*
3 // * Copyright (c) 2016 Cisco and/or its affiliates.
4 // *
5 // * Licensed under the Apache License, Version 2.0 (the "License");
6 // * you may not use this file except in compliance with the License.
7 // * You may obtain a copy of the License at:
8 // *
9 // *     http://www.apache.org/licenses/LICENSE-2.0
10 // *
11 // * Unless required by applicable law or agreed to in writing, software
12 // * distributed under the License is distributed on an "AS IS" BASIS,
13 // * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // * See the License for the specific language governing permissions and
15 // * limitations under the License.
16 // */
17 //
18 //package io.fd.honeycomb.v3po.translate.v3po.interfacesstate;
19 //
20 //import static io.fd.honeycomb.v3po.translate.v3po.ContextTestUtils.getMapping;
21 //import static io.fd.honeycomb.v3po.translate.v3po.ContextTestUtils.getMappingIid;
22 //import static org.mockito.Matchers.any;
23 //import static org.mockito.Matchers.anyString;
24 //import static org.mockito.Mockito.doReturn;
25 //import static org.mockito.Mockito.mock;
26 //import static org.mockito.Mockito.never;
27 //import static org.mockito.Mockito.verify;
28 //
29 //import com.google.common.base.Optional;
30 //import com.google.common.collect.Lists;
31 //import io.fd.honeycomb.v3po.translate.read.ReadFailedException;
32 //import io.fd.honeycomb.v3po.translate.spi.read.ChildReaderCustomizer;
33 //import io.fd.honeycomb.v3po.translate.v3po.test.ChildReaderCustomizerTest;
34 //import io.fd.honeycomb.v3po.translate.v3po.util.NamingContext;
35 //import java.util.HashMap;
36 //import java.util.List;
37 //import java.util.Map;
38 //import org.junit.Test;
39 //import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.naming.context.Mappings;
40 //import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.naming.context.MappingsBuilder;
41 //import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.naming.context.mappings.Mapping;
42 //import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.naming.context.mappings.MappingKey;
43 //import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
44 //import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
45 //import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
46 //import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VlanType;
47 //import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentation;
48 //import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceStateAugmentationBuilder;
49 //import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.SubInterface;
50 //import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces.state._interface.SubInterfaceBuilder;
51 //import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
52 //import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
53 //import org.openvpp.jvpp.dto.SwInterfaceDetails;
54 //
55 //public class SubInterfaceCustomizerTest extends ChildReaderCustomizerTest<SubInterface, SubInterfaceBuilder> {
56 //
57 //    private NamingContext interfacesContext;
58 //
59 //    public SubInterfaceCustomizerTest() {
60 //        super(SubInterface.class);
61 //    }
62 //
63 //    @Override
64 //    protected ChildReaderCustomizer<SubInterface, SubInterfaceBuilder> initCustomizer() {
65 //        return new SubInterfaceCustomizer(api, interfacesContext);
66 //    }
67 //
68 //    @Override
69 //    public void setUpBefore() {
70 //        interfacesContext = new NamingContext("generatedIfaceName", "test-instance");
71 //    }
72 //
73 //    private InstanceIdentifier<SubInterface> getSubInterfaceId(final String name) {
74 //        return InstanceIdentifier.create(InterfacesState.class).child(Interface.class, new InterfaceKey(name)).augmentation(
75 //                VppInterfaceStateAugmentation.class).child(
76 //                SubInterface.class);
77 //    }
78 //
79 //    @Test
80 //    public void testMerge() {
81 //        final VppInterfaceStateAugmentationBuilder builder = mock(VppInterfaceStateAugmentationBuilder.class);
82 //        final SubInterface value = mock(SubInterface.class);
83 //        getCustomizer().merge(builder, value);
84 //        verify(builder).setSubInterface(value);
85 //    }
86 //
87 //    @Test
88 //    public void testRead() throws ReadFailedException {
89 //        final Map<Integer, SwInterfaceDetails> cachedInterfaceDump = new HashMap<>();
90 //        final int ifId = 1;
91 //        final String ifName = "eth0.sub0";
92 //
93 //        final KeyedInstanceIdentifier<Mapping, MappingKey> ifcIid = getMappingIid(ifName, "test-instance");
94 //        doReturn(getMapping(ifName, ifId)).when(mappingContext).read(ifcIid);
95 //        final KeyedInstanceIdentifier<Mapping, MappingKey> superIfcIid = getMappingIid("super", "test-instance");
96 //        doReturn(getMapping("super", 0)).when(mappingContext).read(superIfcIid);
97 //
98 //        final List<Mapping> allMappings = Lists.newArrayList(getMapping(ifName, ifId).get(), getMapping("super", 0).get());
99 //        final Mappings allMappingsBaObject = new MappingsBuilder().setMapping(allMappings).build();
100 //        doReturn(Optional.of(allMappingsBaObject)).when(mappingContext).read(ifcIid.firstIdentifierOf(Mappings.class));
101 //
102 //        final SwInterfaceDetails ifaceDetails = new SwInterfaceDetails();
103 //        ifaceDetails.subId = ifId;
104 //        ifaceDetails.interfaceName = ifName.getBytes();
105 //        ifaceDetails.subDot1Ad = 1;
106 //        cachedInterfaceDump.put(ifId, ifaceDetails);
107 //        cache.put(InterfaceCustomizer.DUMPED_IFCS_CONTEXT_KEY, cachedInterfaceDump);
108 //
109 //        final SubInterfaceBuilder builder = mock(SubInterfaceBuilder.class);
110 //        getCustomizer().readCurrentAttributes(getSubInterfaceId(ifName), builder, ctx);
111 //
112 //        verify(builder).setIdentifier((long)ifId);
113 //        verify(builder).setSuperInterface(anyString());
114 //        verify(builder).setNumberOfTags((short)0);
115 //        verify(builder).setVlanType(VlanType._802dot1ad);
116 //        verify(builder, never()).setExactMatch(any());
117 //        verify(builder, never()).setDefaultSubif(any());
118 //        verify(builder, never()).setMatchAnyOuterId(any());
119 //        verify(builder, never()).setMatchAnyInnerId(any());
120 //        verify(builder, never()).setInnerId(any());
121 //        verify(builder, never()).setOuterId(any());
122 //    }
123 //}