2 * Copyright (c) 2017 ZTE Corporation. 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.extension.api;
10 import java.util.Collections;
11 import org.junit.Assert;
12 import org.junit.Test;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetField;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlowWriteActionsSetField;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlowWriteActionsSetFieldBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchRpcAddFlowWriteActionsSetField;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchRpcAddFlowWriteActionsSetFieldBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionListGrouping;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionListBuilder;
24 public class SetFieldExtensionTest {
26 public void testGetExtension() {
27 GroupingLooseResolver<GeneralExtensionListGrouping> eqGroup =
28 new GroupingLooseResolver<>(GeneralExtensionListGrouping.class);
29 eqGroup.add(GeneralAugMatchRpcAddFlowWriteActionsSetField.class);
30 eqGroup.add(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class);
32 SetFieldBuilder sb1 = new SetFieldBuilder();
33 ExtensionList extension1 = new ExtensionListBuilder().setExtensionKey(ZVendorExt1.class).build();
34 GeneralAugMatchRpcAddFlowWriteActionsSetField odlxxx1 =
35 new GeneralAugMatchRpcAddFlowWriteActionsSetFieldBuilder()
36 .setExtensionList(Collections.singletonList(extension1)).build();
37 SetField setField1 = sb1.addAugmentation(GeneralAugMatchRpcAddFlowWriteActionsSetField.class, odlxxx1).build();
39 SetFieldBuilder sb2 = new SetFieldBuilder();
40 ExtensionList extension2 = new ExtensionListBuilder().setExtensionKey(ZVendorExt2.class).build();
41 GeneralAugMatchNodesNodeTableFlowWriteActionsSetField odlxxx2 =
42 new GeneralAugMatchNodesNodeTableFlowWriteActionsSetFieldBuilder()
43 .setExtensionList(Collections.singletonList(extension2)).build();
44 SetField setField2 = sb2.addAugmentation(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class,
47 Assert.assertEquals(ZVendorExt1.class,
48 eqGroup.getExtension(setField1).get().nonnullExtensionList().values().iterator().next()
50 Assert.assertEquals(ZVendorExt2.class,
51 eqGroup.getExtension(setField2).get().nonnullExtensionList().values().iterator().next()
55 private interface ZVendorExt1 extends ExtensionKey {
59 private interface ZVendorExt2 extends ExtensionKey {