2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
13 import java.util.ArrayList;
14 import java.util.Collection;
15 import java.util.HashMap;
16 import java.util.List;
18 import java.util.Map.Entry;
19 import java.util.Optional;
20 import org.junit.Test;
21 import org.opendaylight.openflowplugin.api.OFConstants;
22 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchKey;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Instructions;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.MatchBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTable;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WildcardsBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
89 import org.opendaylight.yangtools.yang.binding.util.BindingMap;
90 import org.opendaylight.yangtools.yang.common.Uint32;
91 import org.opendaylight.yangtools.yang.common.Uint64;
92 import org.opendaylight.yangtools.yang.common.Uint8;
94 public class TableFeaturesConvertorTest {
95 private static final Map<SetFieldMatchKey, SetFieldMatch> FIELD_TABLE_FEATURES =
96 BindingMap.<SetFieldMatchKey, SetFieldMatch>ordered(
97 new SetFieldMatchBuilder().setHasMask(true)
98 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.VALUE)
100 new SetFieldMatchBuilder().setHasMask(true)
101 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.VALUE)
103 new SetFieldMatchBuilder().setHasMask(true)
104 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.VALUE)
106 new SetFieldMatchBuilder().setHasMask(true)
107 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.VALUE)
109 new SetFieldMatchBuilder().setHasMask(true)
110 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.VALUE)
112 new SetFieldMatchBuilder().setHasMask(true)
113 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.VALUE)
115 new SetFieldMatchBuilder().setHasMask(true)
116 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.VALUE)
118 new SetFieldMatchBuilder().setHasMask(true)
119 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.VALUE)
121 new SetFieldMatchBuilder().setHasMask(true)
122 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.VALUE)
124 new SetFieldMatchBuilder().setHasMask(true)
125 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.VALUE)
127 new SetFieldMatchBuilder().setHasMask(true)
128 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.VALUE)
130 new SetFieldMatchBuilder().setHasMask(true)
131 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.VALUE)
133 new SetFieldMatchBuilder().setHasMask(true)
134 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.VALUE)
136 new SetFieldMatchBuilder().setHasMask(true)
137 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.VALUE)
139 new SetFieldMatchBuilder().setHasMask(true)
140 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.VALUE)
142 new SetFieldMatchBuilder().setHasMask(true)
143 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.VALUE)
145 new SetFieldMatchBuilder().setHasMask(true)
146 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.VALUE)
148 new SetFieldMatchBuilder().setHasMask(true)
149 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.VALUE)
151 new SetFieldMatchBuilder().setHasMask(true)
152 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.VALUE)
154 new SetFieldMatchBuilder().setHasMask(true)
155 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.VALUE)
157 new SetFieldMatchBuilder().setHasMask(true)
158 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.VALUE)
160 new SetFieldMatchBuilder().setHasMask(true)
161 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.VALUE)
163 new SetFieldMatchBuilder().setHasMask(true)
164 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.VALUE)
166 new SetFieldMatchBuilder().setHasMask(true)
167 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.VALUE)
169 new SetFieldMatchBuilder().setHasMask(true)
170 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.VALUE)
172 new SetFieldMatchBuilder().setHasMask(true)
173 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.VALUE)
175 new SetFieldMatchBuilder().setHasMask(true)
176 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.VALUE)
178 new SetFieldMatchBuilder().setHasMask(true)
179 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.VALUE)
181 new SetFieldMatchBuilder().setHasMask(true)
182 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.VALUE)
184 new SetFieldMatchBuilder().setHasMask(true)
185 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.VALUE)
187 new SetFieldMatchBuilder().setHasMask(true)
188 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.VALUE)
190 new SetFieldMatchBuilder().setHasMask(true)
191 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.VALUE)
193 new SetFieldMatchBuilder().setHasMask(true)
194 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.VALUE)
196 new SetFieldMatchBuilder().setHasMask(true)
197 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.VALUE)
199 new SetFieldMatchBuilder().setHasMask(true)
200 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.VALUE)
202 new SetFieldMatchBuilder().setHasMask(true)
203 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.VALUE)
205 new SetFieldMatchBuilder().setHasMask(true)
206 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.VALUE)
208 new SetFieldMatchBuilder().setHasMask(true)
209 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.VALUE)
211 new SetFieldMatchBuilder().setHasMask(true)
212 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.VALUE)
214 new SetFieldMatchBuilder().setHasMask(true)
215 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.VALUE)
217 new SetFieldMatchBuilder().setHasMask(true)
218 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpFlags.VALUE)
220 new SetFieldMatchBuilder().setHasMask(true)
221 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst.VALUE)
223 new SetFieldMatchBuilder().setHasMask(true)
224 .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Src.VALUE)
227 private static final Map<Class<? extends TableFeaturePropType>, TableFeaturePropType> AUGMENTATIONS_MAP =
231 var instructions = BindingMap.<InstructionKey, Instruction>ordered(
232 new InstructionBuilder().setOrder(0).setInstruction(new GoToTableCaseBuilder().build()).build(),
233 new InstructionBuilder().setOrder(1).setInstruction(new WriteMetadataCaseBuilder().build()).build(),
234 new InstructionBuilder().setOrder(2).setInstruction(new WriteActionsCaseBuilder().build()).build(),
235 new InstructionBuilder().setOrder(3).setInstruction(new ApplyActionsCaseBuilder().build()).build(),
236 new InstructionBuilder().setOrder(4).setInstruction(new ClearActionsCaseBuilder().build()).build(),
237 new InstructionBuilder().setOrder(5).setInstruction(new MeterCaseBuilder().build()).build());
239 AUGMENTATIONS_MAP.put(Instructions.class, new InstructionsBuilder()
240 .setInstructions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop
241 .type.table.feature.prop.type.instructions.InstructionsBuilder()
242 .setInstruction(instructions)
245 AUGMENTATIONS_MAP.put(InstructionsMiss.class, new InstructionsMissBuilder()
246 .setInstructionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature
247 .prop.type.table.feature.prop.type.instructions.miss.InstructionsMissBuilder()
248 .setInstruction(instructions)
251 AUGMENTATIONS_MAP.put(NextTable.class, new NextTableBuilder().build());
252 AUGMENTATIONS_MAP.put(NextTableMiss.class, new NextTableMissBuilder().build());
253 AUGMENTATIONS_MAP.put(WriteActions.class, new WriteActionsBuilder().build());
254 AUGMENTATIONS_MAP.put(WriteActionsMiss.class, new WriteActionsMissBuilder().build());
255 AUGMENTATIONS_MAP.put(ApplyActions.class, new ApplyActionsBuilder().build());
256 AUGMENTATIONS_MAP.put(ApplyActionsMiss.class, new ApplyActionsMissBuilder()
257 .setApplyActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature
258 .prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder()
259 .setAction(BindingMap.ordered(
260 new ActionBuilder().setOrder(0).setAction(new OutputActionCaseBuilder().build()).build(),
261 new ActionBuilder().setOrder(1).setAction(new GroupActionCaseBuilder().build()).build(),
262 new ActionBuilder().setOrder(2).setAction(new CopyTtlOutCaseBuilder().build()).build(),
263 new ActionBuilder().setOrder(3).setAction(new CopyTtlInCaseBuilder().build()).build(),
264 new ActionBuilder().setOrder(4).setAction(new SetMplsTtlActionCaseBuilder().build()).build(),
265 new ActionBuilder().setOrder(5).setAction(new DecMplsTtlCaseBuilder().build()).build(),
266 new ActionBuilder().setOrder(6).setAction(new PushVlanActionCaseBuilder().build()).build(),
267 new ActionBuilder().setOrder(7).setAction(new PopVlanActionCaseBuilder().build()).build(),
268 new ActionBuilder().setOrder(8).setAction(new PushMplsActionCaseBuilder().build()).build(),
269 new ActionBuilder().setOrder(9).setAction(new PopMplsActionCaseBuilder().build()).build(),
270 new ActionBuilder().setOrder(10).setAction(new SetQueueActionCaseBuilder().build()).build(),
271 new ActionBuilder().setOrder(11).setAction(new SetNwTtlActionCaseBuilder().build()).build(),
272 new ActionBuilder().setOrder(12).setAction(new DecNwTtlCaseBuilder().build()).build(),
273 new ActionBuilder().setOrder(13).setAction(new SetFieldCaseBuilder().build()).build(),
274 new ActionBuilder().setOrder(14).setAction(new PushPbbActionCaseBuilder().build()).build(),
275 new ActionBuilder().setOrder(15).setAction(new PopPbbActionCaseBuilder().build()).build()))
278 AUGMENTATIONS_MAP.put(Match.class, new MatchBuilder().build());
279 AUGMENTATIONS_MAP.put(Wildcards.class, new WildcardsBuilder().build());
280 AUGMENTATIONS_MAP.put(WriteSetfield.class, new WriteSetfieldBuilder().build());
281 AUGMENTATIONS_MAP.put(WriteSetfieldMiss.class, new WriteSetfieldMissBuilder().build());
282 AUGMENTATIONS_MAP.put(ApplySetfield.class, new ApplySetfieldBuilder()
283 .setApplySetfield(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop
284 .type.table.feature.prop.type.apply.setfield.ApplySetfieldBuilder()
285 .setSetFieldMatch(FIELD_TABLE_FEATURES)
288 AUGMENTATIONS_MAP.put(ApplySetfieldMiss.class, new ApplySetfieldMissBuilder().build());
292 public void testToTableFeaturesRequest() {
293 List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures>
294 tableFeaturesList = new ArrayList<>();
295 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder
296 tableFeaturesBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
297 .features.TableFeaturesBuilder();
298 for (int i = 0; i < 10; i++) {
299 tableFeaturesBuilder.setTableId(Uint8.valueOf(i));
300 tableFeaturesBuilder.setName(String.format("table:%d", i));
301 tableFeaturesBuilder.setMetadataMatch(Uint64.ONE);
302 tableFeaturesBuilder.setMetadataWrite(Uint64.ONE);
303 tableFeaturesBuilder.setMaxEntries(Uint32.valueOf(1 + 10 * i));
304 tableFeaturesBuilder.setConfig(new TableConfig(false));
305 tableFeaturesBuilder.setTableProperties(getTableProperties());
306 tableFeaturesList.add(tableFeaturesBuilder.build());
309 TableFeatures tableFeatures = new UpdatedTableBuilder()
310 .setTableFeatures(BindingMap.ordered(tableFeaturesList))
313 // FIXME: this seems to be completely unused!
314 final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
315 Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request
316 .multipart.request.body.multipart.request.table.features._case.multipart.request.table.features
317 .TableFeatures>> tableFeaturesesOptional =
318 convertorManager.convert(tableFeatures, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
320 assertNotNull(tableFeatures);
321 assertEquals(10, tableFeatures.nonnullTableFeatures().size());
322 Collection<TableFeatureProperties> tableFeaturePropertieses = tableFeatures.nonnullTableFeatures().values()
323 .iterator().next().getTableProperties().nonnullTableFeatureProperties().values();
324 assertEquals(AUGMENTATIONS_MAP.size() + 1, tableFeaturePropertieses.size());
326 org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature
327 .prop.type.ApplyActionsMiss applyActionsMiss = null;
328 for (var featureProp : tableFeaturePropertieses) {
329 var prop = featureProp.getTableFeaturePropType();
330 if (prop.implementedInterface().isAssignableFrom(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types
331 .rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss.class)) {
332 applyActionsMiss = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature
333 .prop.type.table.feature.prop.type.ApplyActionsMiss) prop;
338 assertNotNull(applyActionsMiss);
339 assertEquals(16, applyActionsMiss.getApplyActionsMiss().getAction().size());
342 private static TableProperties getTableProperties() {
343 TableFeaturePropertiesBuilder tableFeaturePropertiesBuilder = new TableFeaturePropertiesBuilder();
344 List<TableFeatureProperties> tableFeaturePropertieses = new ArrayList<>();
347 for (Entry<Class<? extends TableFeaturePropType>, TableFeaturePropType> entry : AUGMENTATIONS_MAP.entrySet()) {
349 tableFeaturePropertiesBuilder.setTableFeaturePropType(entry.getValue());
350 tableFeaturePropertiesBuilder.setOrder(counter);
351 tableFeaturePropertiesBuilder.withKey(new TableFeaturePropertiesKey(order++));
352 tableFeaturePropertieses.add(tableFeaturePropertiesBuilder.build());
354 tableFeaturePropertieses.add(
355 tableFeaturePropertiesBuilder.withKey(new TableFeaturePropertiesKey(order++)).build());
356 return new TablePropertiesBuilder()
357 .setTableFeatureProperties(BindingMap.ordered(tableFeaturePropertieses))