X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-dom-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Ftest%2Fbugfix%2FFlagsSerializationTest.java;h=30c7af705f2ccba4a25e3b1d19f8261e3439386a;hp=023bd795af8779d0805748d294745c969a6246c8;hb=171c9e24058f9633c8f7e54cf09a237fff1e8ab3;hpb=94d0d20b41d64bb6696c2a573ec367fcfddc44e9 diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/FlagsSerializationTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/FlagsSerializationTest.java index 023bd795af..30c7af705f 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/FlagsSerializationTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/FlagsSerializationTest.java @@ -7,7 +7,15 @@ */ package org.opendaylight.controller.sal.binding.test.bugfix; -import com.google.common.collect.ImmutableSet; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + import org.junit.Test; import org.opendaylight.controller.md.sal.common.api.TransactionStatus; import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; @@ -44,14 +52,7 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import com.google.common.collect.ImmutableSet; public class FlagsSerializationTest extends AbstractDataServiceTest { @@ -65,7 +66,7 @@ public class FlagsSerializationTest extends AbstractDataServiceTest { private static final NodeKey NODE_KEY = new NodeKey(new NodeId(NODE_ID)); private static final FlowKey FLOW_KEY = new FlowKey(new FlowId(FLOW_ID)); private static final TableKey TABLE_KEY = new TableKey(TABLE_ID); - + private static final Map NODE_KEY_BI = Collections. singletonMap(NODE_ID_QNAME, NODE_ID); @@ -83,12 +84,12 @@ public class FlagsSerializationTest extends AbstractDataServiceTest { // private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier FLOW_INSTANCE_ID_BI = // // org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() // -// +// // .node(Flows.QNAME) // // .nodeWithKey(Flow.QNAME, FLOW_KEY_BI) // // .toInstance(); private static final InstanceIdentifier FLOW_INSTANCE_ID_BA = // - InstanceIdentifier.builder(NODE_INSTANCE_ID_BA) // + NODE_INSTANCE_ID_BA.builder() // .augmentation(FlowCapableNode.class) .child(Table.class,TABLE_KEY) .child(Flow.class, FLOW_KEY) // @@ -101,34 +102,34 @@ public class FlagsSerializationTest extends AbstractDataServiceTest { FlowModFlags checkOverlapFlags = new FlowModFlags(true,false,false,false,false); ImmutableSet domCheckOverlapFlags = ImmutableSet.of("CHECK_OVERLAP"); testFlags(checkOverlapFlags,domCheckOverlapFlags); - - - + + + FlowModFlags allFalseFlags = new FlowModFlags(false,false,false,false,false); ImmutableSet domAllFalseFlags = ImmutableSet.of(); testFlags(allFalseFlags,domAllFalseFlags); - + FlowModFlags allTrueFlags = new FlowModFlags(true,true,true,true,true); ImmutableSet domAllTrueFlags = ImmutableSet.of("CHECK_OVERLAP","NO_BYT_COUNTS", "NO_PKT_COUNTS", "RESET_COUNTS", "SEND_FLOW_REM"); testFlags(allTrueFlags,domAllTrueFlags); - + FlowModFlags nullFlags = null; ImmutableSet domNullFlags = null; testFlags(null,null); - - + + } private void testFlags(FlowModFlags flagsToTest, ImmutableSet domFlags) throws Exception { Flow flow = createFlow(flagsToTest); assertNotNull(flow); - + CompositeNode domFlow = biDataService.readConfigurationData(mappingService.toDataDom(FLOW_INSTANCE_ID_BA)); - + assertNotNull(domFlow); org.opendaylight.yangtools.yang.data.api.Node readedFlags = domFlow.getFirstSimpleByName(FLOW_FLAGS_QNAME); - + if(domFlags != null) { assertNotNull(readedFlags); assertEquals(domFlags,readedFlags.getValue()); @@ -136,12 +137,12 @@ public class FlagsSerializationTest extends AbstractDataServiceTest { assertNull(readedFlags); } assertEquals(flagsToTest, flow.getFlags()); - + DataModificationTransaction transaction = baDataService.beginTransaction(); transaction.removeConfigurationData(FLOW_INSTANCE_ID_BA); RpcResult result = transaction.commit().get(); assertEquals(TransactionStatus.COMMITED, result.getResult()); - + } private Flow createFlow(FlowModFlags flagsToTest) throws Exception { @@ -158,12 +159,12 @@ public class FlagsSerializationTest extends AbstractDataServiceTest { flow.setKey(FLOW_KEY); flow.setMatch(match.build()); - + flow.setFlags(flagsToTest); - + InstructionsBuilder instructions = new InstructionsBuilder(); InstructionBuilder instruction = new InstructionBuilder(); - + instruction.setOrder(10); ApplyActionsBuilder applyActions = new ApplyActionsBuilder(); List actionList = new ArrayList<>();