From 05f8db12159673d0e0a95642fe86e62c14b7dc7b Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 28 Apr 2020 19:23:50 +0200 Subject: [PATCH] Update MRI projects for Aluminium This bumps versions to the following: - odlparent-7.0.1 - yangtools-5.0.1 - mdsal-6.0.0 - controller-2.0.0 Change-Id: I4f23c953622f39186f82ac1da487f00f3a9707ab Signed-off-by: Somashekhar Javalagi --- applications/arbitratorreconciliation/pom.xml | 2 +- .../bulk/o/matic/FlowWriterConcurrent.java | 6 +- .../bulk/o/matic/FlowWriterDirectOFRpc.java | 6 +- .../bulk/o/matic/FlowWriterSequential.java | 6 +- .../bulk/o/matic/FlowWriterTxChain.java | 6 +- .../bulk/o/matic/SalBulkFlowServiceImpl.java | 11 +- .../bulk/o/matic/TableWriter.java | 2 +- .../o/matic/FlowWriterConcurrentTest.java | 5 +- .../o/matic/FlowWriterDirectOFRpcTest.java | 11 +- .../o/matic/FlowWriterSequentialTest.java | 5 +- .../bulk/o/matic/FlowWriterTxChainTest.java | 5 +- .../o/matic/SalBulkFlowServiceImplTest.java | 4 +- .../bulk/o/matic/TableWriterTest.java | 5 +- applications/forwardingrules-manager/pom.xml | 10 ++ .../applications/frm/impl/FlowForwarder.java | 2 +- .../frm/impl/FlowNodeReconciliationImpl.java | 39 ++--- .../applications/frm/impl/GroupForwarder.java | 2 +- .../applications/frm/impl/MeterForwarder.java | 2 +- .../applications/frm/util/FrmUtil.java | 10 +- .../impl/SimplifiedOperationalListener.java | 5 +- .../frsync/impl/SyncReactorImpl.java | 25 ++-- .../SyncPlanPushStrategyFlatBatchImpl.java | 6 +- .../frsync/util/FlowCapableNodeLookups.java | 10 +- .../frsync/util/ReconcileUtil.java | 28 ++-- .../frsync/impl/DSInputFactory.java | 3 + .../SimplifiedOperationalListenerTest.java | 6 +- .../impl/strategy/TableForwarderTest.java | 6 +- .../frsync/util/ReconcileUtilTest.java | 3 + ...ectorStatNotificationSupplierImplTest.java | 3 +- ...QueueStatNotificationSupplierImplTest.java | 3 +- applications/pom.xml | 2 +- .../ReconciliationServiceImpl.java | 3 +- .../cli/ReconciliationCount.java | 4 +- .../southboundcli/util/ShellUtil.java | 12 +- .../LLDPDataTreeChangeListenerTest.java | 2 +- .../lldp/utils/LLDPDiscoveryUtils.java | 3 +- .../topology/manager/TopologyManagerUtil.java | 4 +- .../FlowCapableTopologyExporterTest.java | 4 +- .../manager/NodeChangeListenerImplTest.java | 6 +- ...erminationPointChangeListenerImplTest.java | 12 +- .../topology/manager/TestUtils.java | 4 +- artifacts/pom.xml | 2 +- distribution/karaf/pom.xml | 2 +- .../features-openflowplugin-extension/pom.xml | 2 +- .../pom.xml | 2 +- .../odl-openflowplugin-nxm-extensions/pom.xml | 2 +- .../odl-openflowplugin-onf-extensions/pom.xml | 2 +- .../features-extension-aggregator/pom.xml | 2 +- .../api/GroupingLooseResolverTest.java | 4 +- .../extension/api/GroupingResolverTest.java | 4 +- .../extension/api/SetFieldExtensionTest.java | 6 +- .../Icmpv6NDOptionsTypeConvertorTest.java | 4 +- .../match/Icmpv6NDReservedConvertorTest.java | 4 +- .../converter/BundleAddMessageConverter.java | 10 +- .../BundleAddMessageConverterTest.java | 4 +- .../converter/BundleControlConverterTest.java | 2 +- .../BundleControlFactoryTest.java | 2 +- extension/pom.xml | 2 +- .../features-openflowplugin/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../odl-openflowplugin-app-topology/pom.xml | 2 +- .../odl-openflowplugin-drop-test/pom.xml | 2 +- .../pom.xml | 2 +- .../odl-openflowplugin-flow-services/pom.xml | 2 +- .../odl-openflowplugin-libraries/pom.xml | 2 +- .../src/main/feature/feature.xml | 2 +- .../odl-openflowplugin-nsf-model/pom.xml | 8 +- .../odl-openflowplugin-southbound/pom.xml | 6 +- features-aggregator/pom.xml | 2 +- libraries/liblldp/pom.xml | 4 +- libraries/pom.xml | 2 +- model/pom.xml | 2 +- .../features-openflowjava/pom.xml | 2 +- .../odl-openflowjava-protocol/pom.xml | 4 +- .../features-openflowjava-aggregator/pom.xml | 2 +- .../src/main/yang/openflow-instruction.yang | 2 +- .../factories/HelloMessageFactoryTest.java | 4 +- .../OF10FeaturesReplyMessageFactoryTest.java | 2 +- .../multipart/MultipartReplyFlowTest.java | 2 +- .../multipart/MultipartReplyPortDescTest.java | 2 +- .../MultipartReplyTableFeaturesTest.java | 2 +- .../txchain/TransactionChainManager.java | 12 +- .../multipart/FlowStatsMultipartWriter.java | 2 +- .../multipart/GroupDescMultipartWriter.java | 2 +- .../multipart/GroupStatsMultipartWriter.java | 2 +- .../multipart/MeterConfigMultipartWriter.java | 2 +- .../multipart/MeterStatsMultipartWriter.java | 2 +- .../multipart/PortStatsMultipartWriter.java | 2 +- .../multipart/QueueStatsMultipartWriter.java | 2 +- .../TableFeaturesMultipartWriter.java | 2 +- .../multipart/TableStatsMultipartWriter.java | 2 +- .../impl/device/DeviceContextImpl.java | 4 +- .../lifecycle/ContextChainHolderImpl.java | 6 +- .../messages/MeterMessageDeserializer.java | 5 +- .../MultipartReplyFlowStatsDeserializer.java | 4 + .../AbstractActionInstructionSerializer.java | 4 +- .../serialization/match/MatchSerializer.java | 23 +-- .../messages/FlowMessageSerializer.java | 25 ++-- .../messages/GroupMessageSerializer.java | 6 +- .../messages/MeterMessageSerializer.java | 2 +- ...ltipartRequestTableFeaturesSerializer.java | 8 +- ...plyActionsMissTablePropertySerializer.java | 2 +- .../ApplyActionsTablePropertySerializer.java | 3 +- ...lySetfieldMissTablePropertySerializer.java | 2 +- .../ApplySetfieldTablePropertySerializer.java | 2 +- ...structionsMissTablePropertySerializer.java | 4 +- .../InstructionsTablePropertySerializer.java | 2 +- .../MatchTablePropertySerializer.java | 2 +- .../WildcardsTablePropertySerializer.java | 2 +- ...iteActionsMissTablePropertySerializer.java | 2 +- .../WriteActionsTablePropertySerializer.java | 3 +- ...teSetfieldMissTablePropertySerializer.java | 2 +- .../WriteSetfieldTablePropertySerializer.java | 2 +- .../registry/flow/DeviceFlowRegistryImpl.java | 4 +- .../registry/flow/FlowRegistryKeyFactory.java | 4 +- .../services/AbstractRequestCallback.java | 4 +- .../services/batch/FlatBatchFlowAdapters.java | 2 +- .../batch/FlatBatchGroupAdapters.java | 2 +- .../batch/FlatBatchMeterAdapters.java | 2 +- .../services/sal/SalFlatBatchServiceImpl.java | 2 +- .../sal/SalFlowsBatchServiceImpl.java | 12 +- .../sal/SalGroupsBatchServiceImpl.java | 8 +- .../sal/SalMetersBatchServiceImpl.java | 8 +- .../impl/services/sal/SalPortServiceImpl.java | 2 +- .../SingleLayerTableMultipartService.java | 2 +- .../statistics/StatisticsGatheringUtils.java | 2 +- .../MessageIntelligenceAgencyImpl.java | 3 +- .../services/AllMeterConfigStatsService.java | 14 +- .../services/GroupDescriptionService.java | 17 ++- ...upStatisticsToNotificationTransformer.java | 15 +- ...erStatisticsToNotificationTransformer.java | 14 +- ...orStatisticsToNotificationTransformer.java | 15 +- ...ueStatisticsToNotificationTransformer.java | 14 +- .../FlowDirectStatisticsService.java | 2 +- .../GroupDirectStatisticsService.java | 2 +- .../MeterDirectStatisticsService.java | 2 +- .../PortDirectStatisticsService.java | 4 +- .../QueueDirectStatisticsService.java | 2 +- .../translator/PacketReceivedTranslator.java | 5 +- .../impl/util/AddressNormalizationUtil.java | 39 ++--- .../impl/util/FlatBatchUtil.java | 37 ++--- .../openflowplugin/impl/util/FlowUtil.java | 9 +- .../openflowplugin/impl/util/MatchUtil.java | 5 +- .../device/TransactionChainManagerTest.java | 14 +- ...plyActionsInstructionDeserializerTest.java | 2 +- ...iteActionsInstructionDeserializerTest.java | 2 +- .../messages/FlowMessageDeserializerTest.java | 5 +- .../GroupMessageDeserializerTest.java | 6 +- .../MeterMessageDeserializerTest.java | 12 +- ...ltipartReplyFlowStatsDeserializerTest.java | 16 +- ...rtReplyFlowTableStatsDeserializerTest.java | 12 +- ...ltipartReplyGroupDescDeserializerTest.java | 16 +- ...tipartReplyGroupStatsDeserializerTest.java | 18 ++- ...MultipartReplyMessageDeserializerTest.java | 8 +- ...ipartReplyMeterConfigDeserializerTest.java | 15 +- ...tipartReplyMeterStatsDeserializerTest.java | 6 +- ...ltipartReplyPortStatsDeserializerTest.java | 2 +- ...tipartReplyQueueStatsDeserializerTest.java | 2 +- ...artReplyTableFeaturesDeserializerTest.java | 85 ++++++----- .../messages/FlowMessageSerializerTest.java | 8 +- .../messages/MeterMessageSerializerTest.java | 5 +- .../flow/DeviceFlowRegistryImplTest.java | 12 +- .../flow/FlowRegistryKeyFactoryTest.java | 4 +- .../impl/registry/flow/TestFlowHelper.java | 3 + .../batch/FlatBatchFlowAdaptersTest.java | 30 ++-- .../batch/FlatBatchGroupAdaptersTest.java | 27 ++-- .../batch/FlatBatchMeterAdaptersTest.java | 33 +++-- ...lExperimenterMpMessageServiceImplTest.java | 1 - .../sal/SalFlatBatchServiceImplTest.java | 64 +++++--- .../sal/SalFlowsBatchServiceImplTest.java | 31 ++-- .../sal/SalGroupsBatchServiceImplTest.java | 32 ++-- .../sal/SalMetersBatchServiceImplTest.java | 32 ++-- .../SingleLayerTableMultipartServiceTest.java | 2 +- .../MultipartReplyTranslatorTest.java | 20 ++- .../FlowDirectStatisticsServiceTest.java | 11 +- .../GroupDirectStatisticsServiceTest.java | 17 +-- .../MeterDirectStatisticsServiceTest.java | 15 +- ...eConnectorDirectStatisticsServiceTest.java | 10 +- .../QueueDirectStatisticsServiceTest.java | 19 ++- .../FlowDirectStatisticsServiceTest.java | 9 +- .../GroupDirectStatisticsServiceTest.java | 13 +- .../MeterDirectStatisticsServiceTest.java | 12 +- ...eConnectorDirectStatisticsServiceTest.java | 11 +- .../QueueDirectStatisticsServiceTest.java | 18 ++- .../translator/PortUpdateTranslatorTest.java | 7 +- .../impl/util/FlatBatchUtilTest.java | 125 ++++++++++++++-- .../impl/util/FlowUtilTest.java | 25 +++- .../impl/util/GroupUtilTest.java | 19 +-- .../impl/util/MeterUtilTest.java | 27 ++-- .../core/extension/MatchExtensionHelper.java | 21 ++- .../core/sal/convertor/ConvertorExecutor.java | 14 ++ .../core/sal/convertor/ConvertorManager.java | 30 ++++ .../md/core/sal/convertor/GroupConvertor.java | 31 ++-- .../GroupDescStatsResponseConvertor.java | 2 +- .../GroupStatsResponseConvertor.java | 4 +- .../MeterConfigStatsResponseConvertor.java | 8 +- .../md/core/sal/convertor/MeterConvertor.java | 8 +- .../MeterStatsResponseConvertor.java | 2 +- .../sal/convertor/PacketOutConvertor.java | 11 +- .../sal/convertor/TableFeaturesConvertor.java | 98 ++++++------- .../sal/convertor/action/ActionConvertor.java | 6 +- .../sal/convertor/flow/FlowConvertor.java | 27 ++-- .../flow/FlowStatsResponseConvertor.java | 2 +- .../sal/convertor/match/MatchConvertor.java | 3 +- .../match/MatchResponseConvertor.java | 2 +- .../extension/MatchExtensionHelperTest.java | 57 +++++--- .../sal/convertor/GroupConvertorTest.java | 11 +- .../GroupDescStatsResponseConvertorTest.java | 28 ++-- .../GroupStatsResponseConvertorTest.java | 23 +-- .../sal/convertor/MeterConvertorTest.java | 11 ++ .../MeterStatsResponseConvertorTest.java | 4 +- .../sal/convertor/PacketOutConvertorTest.java | 8 +- .../convertor/TableFeaturesConvertorTest.java | 67 +++++---- .../TableFeaturesResponseConvertorTest.java | 138 ++++++++++-------- .../sal/convertor/flow/FlowConvertorTest.java | 6 +- .../match/MatchResponseConvertor2Test.java | 8 +- parent/pom.xml | 6 +- .../learningswitch/FlowCommitWrapperImpl.java | 2 +- samples/pom.xml | 2 +- samples/simple-client/pom.xml | 4 +- .../testcommon/DropTestCommiter.java | 2 +- ...lowPluginBulkGroupTransactionProvider.java | 10 +- ...OpenflowPluginBulkTransactionProvider.java | 48 +++--- ...penflowpluginGroupTestCommandProvider.java | 8 +- ...penflowpluginMeterTestCommandProvider.java | 15 +- ...penflowpluginStatsTestCommandProvider.java | 46 +++--- ...luginTableFeaturesTestCommandProvider.java | 29 +--- .../OpenflowpluginTestCommandProvider.java | 10 +- 239 files changed, 1468 insertions(+), 1038 deletions(-) diff --git a/applications/arbitratorreconciliation/pom.xml b/applications/arbitratorreconciliation/pom.xml index ee63977225..58fb10a360 100644 --- a/applications/arbitratorreconciliation/pom.xml +++ b/applications/arbitratorreconciliation/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent odlparent-lite - 6.0.4 + 7.0.1 diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrent.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrent.java index ae73a6248c..1cca45eaf2 100644 --- a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrent.java +++ b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrent.java @@ -150,7 +150,11 @@ public class FlowWriterConcurrent implements FlowCounterMBean { Flow flow, Integer sourceIp, Short tableId) { if (add) { LOG.trace("Adding flow for flowId: {}, flowIid: {}", flowId, flowIid); - writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowIid, flow, isCreateParents); + if (isCreateParents) { + writeTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, flowIid, flow); + } else { + writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowIid, flow); + } } else { LOG.trace("Deleting flow for flowId: {}, flowIid: {}", flowId, flowIid); writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, flowIid); diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpc.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpc.java index 02bc9bd88c..7755fcf44c 100644 --- a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpc.java +++ b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpc.java @@ -7,9 +7,9 @@ */ package org.opendaylight.openflowplugin.applications.bulk.o.matic; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Optional; import java.util.Set; import java.util.concurrent.ExecutionException; @@ -77,8 +77,8 @@ public class FlowWriterDirectOFRpc { try (ReadTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction()) { Optional nodesDataNode = readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, nodes).get(); if (nodesDataNode.isPresent()) { - List nodesCollection = nodesDataNode.get().getNode(); - if (nodesCollection != null && !nodesCollection.isEmpty()) { + Collection nodesCollection = nodesDataNode.get().nonnullNode().values(); + if (!nodesCollection.isEmpty()) { for (Node node : nodesCollection) { LOG.info("Switch with ID {} discovered !!", node.getId().getValue()); nodeIds.add(node.getId().getValue()); diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequential.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequential.java index 7a319c5b5f..987d73de6e 100644 --- a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequential.java +++ b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequential.java @@ -140,7 +140,11 @@ public class FlowWriterSequential implements FlowCounterMBean { Flow flow) { if (add) { LOG.trace("Adding flow for flowId: {}, flowIid: {}", flowId, flowIid); - writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowIid, flow, isCreateParents); + if (isCreateParents) { + writeTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, flowIid, flow); + } else { + writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowIid, flow); + } } else { LOG.trace("Deleting flow for flowId: {}, flowIid: {}", flowId, flowIid); writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, flowIid); diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChain.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChain.java index b6e0b2664e..9f7a7024ab 100644 --- a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChain.java +++ b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChain.java @@ -176,7 +176,11 @@ public class FlowWriterTxChain implements FlowCounterMBean { Flow flow, Integer sourceIp, Short tableId) { if (add) { LOG.trace("Adding flow for flowId: {}, flowIid: {}", flowId, flowIid); - writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowIid, flow, isCreateParents); + if (isCreateParents) { + writeTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, flowIid, flow); + } else { + writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowIid, flow); + } } else { LOG.trace("Deleting flow for flowId: {}, flowIid: {}", flowId, flowIid); writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, flowIid); diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java index 9a238dc03e..48356e0891 100644 --- a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java +++ b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImpl.java @@ -28,7 +28,6 @@ import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.management.NotCompliantMBeanException; import javax.management.ObjectName; - import org.opendaylight.infrautils.utils.concurrent.LoggingFutures; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.WriteTransaction; @@ -106,8 +105,14 @@ public class SalBulkFlowServiceImpl implements SalBulkFlowService { FlowBuilder flowBuilder = new FlowBuilder(bulkFlow); flowBuilder.setTableId(bulkFlow.getTableId()); flowBuilder.setId(new FlowId(bulkFlow.getFlowId())); - writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getFlowInstanceIdentifier(bulkFlow), - flowBuilder.build(), createParents); + if (createParents) { + writeTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, + getFlowInstanceIdentifier(bulkFlow), + flowBuilder.build()); + } else { + writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getFlowInstanceIdentifier(bulkFlow), + flowBuilder.build()); + } createParents = createParentsNextTime; } FluentFuture submitFuture = writeTransaction.commit(); diff --git a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriter.java b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriter.java index 54f7906b97..1e2bc3a5a0 100644 --- a/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriter.java +++ b/applications/bulk-o-matic/src/main/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriter.java @@ -91,7 +91,7 @@ public class TableWriter implements FlowCounterMBean { InstanceIdentifier tableIId = BulkOMaticUtils.getTableId(tableId, dpId); if (isAdd) { - wtx.put(LogicalDatastoreType.CONFIGURATION, tableIId, table, true); + wtx.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, tableIId, table); } else { wtx.delete(LogicalDatastoreType.CONFIGURATION, tableIId); } diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrentTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrentTest.java index 7b41b34f25..b3f4be40ba 100644 --- a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrentTest.java +++ b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterConcurrentTest.java @@ -59,9 +59,8 @@ public class FlowWriterConcurrentTest { @Test public void testAddFlows() { flowWriterConcurrent.addFlows(1, FLOWS_PER_DPN, 10, 10, 10, (short) 0, (short) 1, true); - Mockito.verify(writeTransaction, Mockito.times(FLOWS_PER_DPN)).put(ArgumentMatchers.any(), - ArgumentMatchers.any(), ArgumentMatchers.any(), - ArgumentMatchers.anyBoolean()); + Mockito.verify(writeTransaction, Mockito.times(FLOWS_PER_DPN)).mergeParentStructurePut(ArgumentMatchers.any(), + ArgumentMatchers.any(), ArgumentMatchers.any()); } @Test diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpcTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpcTest.java index 53d007f75f..2de02cdce8 100644 --- a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpcTest.java +++ b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterDirectOFRpcTest.java @@ -11,8 +11,8 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; -import java.util.ArrayList; -import java.util.List; +import java.util.HashMap; +import java.util.Map; import java.util.Optional; import java.util.concurrent.ExecutorService; import org.junit.Before; @@ -30,6 +30,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -65,11 +66,11 @@ public class FlowWriterDirectOFRpcTest { NodeBuilder nodeBuilder = new NodeBuilder() .setId(new NodeId("1")); - final List nodes = new ArrayList<>(); + final Map nodes = new HashMap<>(); final Node node = nodeBuilder.build(); - nodes.add(node); + nodes.put(node.key(), node); - when(mockNodes.getNode()).thenReturn(nodes); + when(mockNodes.nonnullNode()).thenReturn(nodes); doReturn(FluentFutures.immediateFluentFuture(Optional.of(mockNodes))).when(readOnlyTransaction) .read(any(LogicalDatastoreType.class), any()); diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequentialTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequentialTest.java index d6fcf0fe76..f9c510df33 100644 --- a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequentialTest.java +++ b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterSequentialTest.java @@ -57,9 +57,8 @@ public class FlowWriterSequentialTest { @Test public void testAddFlows() { flowWriterSequential.addFlows(1, FLOWS_PER_DPN, 10, 10, (short) 0, (short) 1, true); - Mockito.verify(writeTransaction, Mockito.times(FLOWS_PER_DPN)).put(ArgumentMatchers.any(), - ArgumentMatchers.any(), ArgumentMatchers.any(), - ArgumentMatchers.anyBoolean()); + Mockito.verify(writeTransaction, Mockito.times(FLOWS_PER_DPN)).mergeParentStructurePut(ArgumentMatchers.any(), + ArgumentMatchers.any(), ArgumentMatchers.any()); } @Test diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChainTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChainTest.java index 6a1ec183f2..5ed37cb015 100644 --- a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChainTest.java +++ b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/FlowWriterTxChainTest.java @@ -64,9 +64,8 @@ public class FlowWriterTxChainTest { @Test public void testAddFlows() { flowWriterTxChain.addFlows(1, FLOWS_PER_DPN, 10, 10, 10, (short) 0, (short) 1, true); - Mockito.verify(writeTransaction, Mockito.times(FLOWS_PER_DPN)).put(ArgumentMatchers.any(), - ArgumentMatchers.any(), ArgumentMatchers.any(), - ArgumentMatchers.anyBoolean()); + Mockito.verify(writeTransaction, Mockito.times(FLOWS_PER_DPN)).mergeParentStructurePut(ArgumentMatchers.any(), + ArgumentMatchers.any(), ArgumentMatchers.any()); } @Test diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImplTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImplTest.java index 254515d5de..f293547075 100644 --- a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImplTest.java +++ b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/SalBulkFlowServiceImplTest.java @@ -125,8 +125,8 @@ public class SalBulkFlowServiceImplTest { salBulkFlowService.addFlowsDs(addFlowsDsInput); verify(writeTransaction).commit(); - verify(writeTransaction).put(ArgumentMatchers.any(), ArgumentMatchers.any(), - flowArgumentCaptor.capture(), Mockito.anyBoolean()); + verify(writeTransaction).mergeParentStructurePut(ArgumentMatchers.any(), ArgumentMatchers.any(), + flowArgumentCaptor.capture()); Flow flow = flowArgumentCaptor.getValue(); Assert.assertEquals("1", flow.getId().getValue()); diff --git a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriterTest.java b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriterTest.java index 9294e60769..6d359a555e 100644 --- a/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriterTest.java +++ b/applications/bulk-o-matic/src/test/java/org/opendaylight/openflowplugin/applications/bulk/o/matic/TableWriterTest.java @@ -60,9 +60,8 @@ public class TableWriterTest { public void testAddTables() { tableWriter.addTables(DPN_COUNT, START_TABLE_ID, END_TABLE_ID); Mockito.verify(writeTransaction, Mockito.times(TABLES_PER_DPN)) - .put(ArgumentMatchers.any(), - ArgumentMatchers.any(), ArgumentMatchers.any(), - ArgumentMatchers.anyBoolean()); + .mergeParentStructurePut(ArgumentMatchers.any(), + ArgumentMatchers.any(), ArgumentMatchers.any()); } @Test diff --git a/applications/forwardingrules-manager/pom.xml b/applications/forwardingrules-manager/pom.xml index 0836f2f497..4f2ea62f24 100644 --- a/applications/forwardingrules-manager/pom.xml +++ b/applications/forwardingrules-manager/pom.xml @@ -88,6 +88,16 @@ blueprint-maven-plugin-annotation true + + org.opendaylight.mdsal + mdsal-binding-runtime-spi + test + + + org.opendaylight.mdsal + mdsal-binding-generator-impl + test + diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java index b8cc16736a..cd4219f437 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowForwarder.java @@ -305,7 +305,7 @@ public class FlowForwarder extends AbstractListeningCommiter { private void persistStaleFlow(StaleFlow staleFlow, InstanceIdentifier nodeIdent) { WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getStaleFlowInstanceIdentifier(staleFlow, nodeIdent), - staleFlow, false); + staleFlow); FluentFuture submitFuture = writeTransaction.commit(); handleStaleFlowResultFuture(submitFuture); diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java index 5976cbb353..9859e9cce4 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java @@ -278,8 +278,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { }, service); /* Bundles not supported for meters */ - List meters = flowNode.get().getMeter() != null ? flowNode.get().getMeter() - : Collections.emptyList(); + Collection meters = flowNode.get().nonnullMeter().values(); Futures.transformAsync(commitBundleFuture, rpcResult -> { if (rpcResult.isSuccessful()) { @@ -384,9 +383,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { //put the dpn info into the map reconciliationStates.put(dpnId.toString(), reconciliationState); LOG.debug("Triggering reconciliation for node {} with state: {}", dpnId, STARTED); - List tableList = flowNode.get().getTableFeatures() != null - ? flowNode.get().getTableFeatures() - : Collections.emptyList(); + Collection tableList = flowNode.get().nonnullTableFeatures().values(); for (TableFeatures tableFeaturesItem : tableList) { TableFeaturesKey tableKey = tableFeaturesItem.key(); KeyedInstanceIdentifier tableFeaturesII = nodeIdentity @@ -395,8 +392,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { } /* Groups - have to be first */ - List groups = flowNode.get().getGroup() != null ? flowNode.get().getGroup() - : Collections.emptyList(); + Collection groups = flowNode.get().nonnullGroup().values(); List toBeInstalledGroups = new ArrayList<>(); toBeInstalledGroups.addAll(groups); // new list for suspected groups pointing to ports .. when the ports come up @@ -420,12 +416,12 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { Group group = iterator.next(); boolean okToInstall = true; Buckets buckets = group.getBuckets(); - List bucketList = buckets == null ? null : buckets.getBucket(); + Collection bucketList = buckets == null ? null : buckets.nonnullBucket().values(); if (bucketList == null) { bucketList = Collections.emptyList(); } for (Bucket bucket : bucketList) { - List actions = bucket.getAction(); + Collection actions = bucket.nonnullAction().values(); if (actions == null) { actions = Collections.emptyList(); } @@ -497,8 +493,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { } } /* Meters */ - List meters = flowNode.get().getMeter() != null ? flowNode.get().getMeter() - : Collections.emptyList(); + Collection meters = flowNode.get().nonnullMeter().values(); for (Meter meter : meters) { final KeyedInstanceIdentifier meterIdent = nodeIdentity.child(Meter.class, meter.key()); @@ -510,13 +505,13 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { awaitGroups(node, groupFutures.values()); /* Flows */ - List
tables = flowNode.get().getTable() != null ? flowNode.get().getTable() + Collection
tables = flowNode.get().getTable() != null ? flowNode.get().nonnullTable().values() : Collections.
emptyList(); int flowCount = 0; for (Table table : tables) { final KeyedInstanceIdentifier tableIdent = nodeIdentity.child(Table.class, table.key()); - List flows = table.getFlow() != null ? table.getFlow() : Collections.emptyList(); + Collection flows = table.nonnullFlow().values(); flowCount += flows.size(); for (Flow flow : flows) { final KeyedInstanceIdentifier flowIdent = tableIdent.child(Flow.class, @@ -624,13 +619,11 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { LOG.debug("Proceeding with deletion of stale-marked Flows on switch {} using Openflow interface", nodeIdent); /* Stale-Flows - Stale-marked Flows have to be removed first for safety */ - List
tables = flowNode.get().getTable() != null ? flowNode.get().getTable() - : Collections.
emptyList(); + Collection
tables = flowNode.get().nonnullTable().values(); for (Table table : tables) { final KeyedInstanceIdentifier tableIdent = nodeIdent.child(Table.class, table.key()); - List staleFlows = table.getStaleFlow() != null ? table.getStaleFlow() - : Collections.emptyList(); + Collection staleFlows = table.nonnullStaleFlow().values(); for (StaleFlow staleFlow : staleFlows) { FlowBuilder flowBuilder = new FlowBuilder(staleFlow); @@ -653,8 +646,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { // before attempting to delete groups - just in case there are references /* Stale-marked Groups - Can be deleted after flows */ - List staleGroups = flowNode.get().getStaleGroup() != null ? flowNode.get().getStaleGroup() - : Collections.emptyList(); + Collection staleGroups = flowNode.get().nonnullStaleGroup().values(); for (StaleGroup staleGroup : staleGroups) { GroupBuilder groupBuilder = new GroupBuilder(staleGroup); @@ -671,8 +663,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { LOG.debug("Proceeding with deletion of stale-marked Meters for switch {} using Openflow interface", nodeIdent); /* Stale-marked Meters - can be deleted anytime - so least priority */ - List staleMeters = flowNode.get().getStaleMeter() != null ? flowNode.get().getStaleMeter() - : Collections.emptyList(); + Collection staleMeters = flowNode.get().getStaleMeter().values(); for (StaleMeter staleMeter : staleMeters) { @@ -756,14 +747,14 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation { final BundleId bundleIdValue, final InstanceIdentifier nodeIdentity) { List>> futureList = new ArrayList<>(); - for (Group group : flowNode.nonnullGroup()) { + for (Group group : flowNode.nonnullGroup().values()) { final KeyedInstanceIdentifier groupIdent = nodeIdentity.child(Group.class, group.key()); futureList.add(provider.getBundleGroupListener().add(groupIdent, group, nodeIdentity, bundleIdValue)); } - for (Table table : flowNode.nonnullTable()) { + for (Table table : flowNode.nonnullTable().values()) { final KeyedInstanceIdentifier tableIdent = nodeIdentity.child(Table.class, table.key()); - for (Flow flow : table.nonnullFlow()) { + for (Flow flow : table.nonnullFlow().values()) { final KeyedInstanceIdentifier flowIdent = tableIdent.child(Flow.class, flow.key()); futureList.add(provider.getBundleFlowListener().add(flowIdent, flow, nodeIdentity, bundleIdValue)); } diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java index 79b12067e9..cbb28503d7 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/GroupForwarder.java @@ -219,7 +219,7 @@ public class GroupForwarder extends AbstractListeningCommiter { private void persistStaleGroup(StaleGroup staleGroup, InstanceIdentifier nodeIdent) { WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getStaleGroupInstanceIdentifier(staleGroup, nodeIdent), - staleGroup, false); + staleGroup); FluentFuture submitFuture = writeTransaction.commit(); handleStaleGroupResultFuture(submitFuture); diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/MeterForwarder.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/MeterForwarder.java index ef8d5d7d97..09282388d4 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/MeterForwarder.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/MeterForwarder.java @@ -162,7 +162,7 @@ public class MeterForwarder extends AbstractListeningCommiter { private void persistStaleMeter(StaleMeter staleMeter, InstanceIdentifier nodeIdent) { WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getStaleMeterInstanceIdentifier(staleMeter, nodeIdent), - staleMeter, false); + staleMeter); FluentFuture submitFuture = writeTransaction.commit(); handleStaleMeterResultFuture(submitFuture); diff --git a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/util/FrmUtil.java b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/util/FrmUtil.java index 6cd40cab71..c7f4cbba01 100644 --- a/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/util/FrmUtil.java +++ b/applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/util/FrmUtil.java @@ -9,8 +9,8 @@ package org.opendaylight.openflowplugin.applications.frm.util; import java.math.BigInteger; +import java.util.Collection; import java.util.Collections; -import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -86,17 +86,17 @@ public final class FrmUtil { public static Uint32 isFlowDependentOnGroup(final Flow flow) { LOG.debug("Check if flow {} is dependent on group", flow); if (flow.getInstructions() != null) { - List instructions = flow.getInstructions().getInstruction(); + Collection instructions = flow.getInstructions().nonnullInstruction().values(); for (Instruction instruction : instructions) { - List actions = Collections.emptyList(); + Collection actions = Collections.emptyList(); if (instruction.getInstruction().implementedInterface() .equals(ActionType.APPLY_ACTION.getActionType())) { actions = ((ApplyActionsCase) instruction.getInstruction()) - .getApplyActions().getAction(); + .getApplyActions().nonnullAction().values(); } else if (instruction.getInstruction().implementedInterface() .equals(ActionType.WRITE_ACTION.getActionType())) { actions = ((WriteActionsCase)instruction.getInstruction()) - .getWriteActions().getAction(); + .getWriteActions().nonnullAction().values(); } for (Action action : actions) { if (action.getAction().implementedInterface() diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListener.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListener.java index 08dee38766..3448b160b7 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListener.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListener.java @@ -12,7 +12,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Collection; import java.util.Date; -import java.util.List; +import java.util.Map; import java.util.Optional; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.binding.api.DataObjectModification; @@ -32,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.sn import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -213,7 +214,7 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener if (node == null) { return true; } - final List nodeConnectors = node.getNodeConnector(); + final Map nodeConnectors = node.getNodeConnector(); return nodeConnectors == null || nodeConnectors.isEmpty(); } diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImpl.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImpl.java index 6b9c9523b7..ca965e9669 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImpl.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorImpl.java @@ -14,6 +14,7 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; @@ -117,8 +118,8 @@ public class SyncReactorImpl implements SyncReactor { @VisibleForTesting private static List> extractGroupsToAddOrUpdate(final NodeId nodeId, final FlowCapableNode flowCapableNodeConfigured, final FlowCapableNode flowCapableNodeOperational) { - final List groupsConfigured = ReconcileUtil.safeGroups(flowCapableNodeConfigured); - final List groupsOperational = ReconcileUtil.safeGroups(flowCapableNodeOperational); + final Collection groupsConfigured = ReconcileUtil.safeGroups(flowCapableNodeConfigured); + final Collection groupsOperational = ReconcileUtil.safeGroups(flowCapableNodeOperational); final Map groupOperationalMap = FlowCapableNodeLookups.wrapGroupsToMap(groupsOperational); final List pendingGroups = new ArrayList<>(); @@ -131,8 +132,8 @@ public class SyncReactorImpl implements SyncReactor { private static ItemSyncBox extractMetersToAddOrUpdate(final NodeId nodeId, final FlowCapableNode flowCapableNodeConfigured, final FlowCapableNode flowCapableNodeOperational) { - final List metersConfigured = ReconcileUtil.safeMeters(flowCapableNodeConfigured); - final List metersOperational = ReconcileUtil.safeMeters(flowCapableNodeOperational); + final Collection metersConfigured = ReconcileUtil.safeMeters(flowCapableNodeConfigured); + final Collection metersOperational = ReconcileUtil.safeMeters(flowCapableNodeOperational); final Map meterOperationalMap = FlowCapableNodeLookups.wrapMetersToMap(metersOperational); return ReconcileUtil.resolveMeterDiffs(nodeId, meterOperationalMap, metersConfigured, true); @@ -141,12 +142,12 @@ public class SyncReactorImpl implements SyncReactor { @VisibleForTesting private static Map> extractFlowsToAddOrUpdate(final NodeId nodeId, final FlowCapableNode flowCapableNodeConfigured, final FlowCapableNode flowCapableNodeOperational) { - final List
tablesConfigured = ReconcileUtil.safeTables(flowCapableNodeConfigured); + final Collection
tablesConfigured = ReconcileUtil.safeTables(flowCapableNodeConfigured); if (tablesConfigured.isEmpty()) { return Collections.emptyMap(); } - final List
tablesOperational = ReconcileUtil.safeTables(flowCapableNodeOperational); + final Collection
tablesOperational = ReconcileUtil.safeTables(flowCapableNodeOperational); final Map tableOperationalMap = FlowCapableNodeLookups.wrapTablesToMap(tablesOperational); return ReconcileUtil.resolveFlowDiffsInAllTables(nodeId, tableOperationalMap, tablesConfigured, true); @@ -155,12 +156,12 @@ public class SyncReactorImpl implements SyncReactor { @VisibleForTesting private static Map> extractFlowsToRemove(final NodeId nodeId, final FlowCapableNode flowCapableNodeConfigured, final FlowCapableNode flowCapableNodeOperational) { - final List
tablesOperational = ReconcileUtil.safeTables(flowCapableNodeOperational); + final Collection
tablesOperational = ReconcileUtil.safeTables(flowCapableNodeOperational); if (tablesOperational.isEmpty()) { return Collections.emptyMap(); } - final List
tablesConfigured = ReconcileUtil.safeTables(flowCapableNodeConfigured); + final Collection
tablesConfigured = ReconcileUtil.safeTables(flowCapableNodeConfigured); final Map tableConfiguredMap = FlowCapableNodeLookups.wrapTablesToMap(tablesConfigured); return ReconcileUtil.resolveFlowDiffsInAllTables(nodeId, tableConfiguredMap, tablesOperational, false); @@ -170,8 +171,8 @@ public class SyncReactorImpl implements SyncReactor { private static ItemSyncBox extractMetersToRemove(final NodeId nodeId, final FlowCapableNode flowCapableNodeConfigured, final FlowCapableNode flowCapableNodeOperational) { - final List metersConfigured = ReconcileUtil.safeMeters(flowCapableNodeConfigured); - final List metersOperational = ReconcileUtil.safeMeters(flowCapableNodeOperational); + final Collection metersConfigured = ReconcileUtil.safeMeters(flowCapableNodeConfigured); + final Collection metersOperational = ReconcileUtil.safeMeters(flowCapableNodeOperational); final Map meterConfiguredMap = FlowCapableNodeLookups.wrapMetersToMap(metersConfigured); return ReconcileUtil.resolveMeterDiffs(nodeId, meterConfiguredMap, metersOperational, false); @@ -181,8 +182,8 @@ public class SyncReactorImpl implements SyncReactor { private static List> extractGroupsToRemove(final NodeId nodeId, final FlowCapableNode flowCapableNodeConfigured, final FlowCapableNode flowCapableNodeOperational) { - final List groupsConfigured = ReconcileUtil.safeGroups(flowCapableNodeConfigured); - final List groupsOperational = ReconcileUtil.safeGroups(flowCapableNodeOperational); + final Collection groupsConfigured = ReconcileUtil.safeGroups(flowCapableNodeConfigured); + final Collection groupsOperational = ReconcileUtil.safeGroups(flowCapableNodeOperational); final Map groupConfiguredMap = FlowCapableNodeLookups.wrapGroupsToMap(groupsConfigured); final List pendingGroups = new ArrayList<>(); diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java index 3c85a7d7ed..ff8fa87a9b 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java @@ -17,6 +17,7 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.ArrayList; +import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -163,7 +164,8 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { if (!result.isSuccessful() && result.getResult() != null && !result.getResult().getBatchFailure().isEmpty()) { Map, Batch> batchMap = mapBatchesToRanges(inputBatchBag, failureIndexLimit); - decrementBatchFailuresCounters(result.getResult().getBatchFailure(), batchMap, counters); + decrementBatchFailuresCounters(result.getResult().nonnullBatchFailure().values(), batchMap, + counters); } } @@ -176,7 +178,7 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "https://github.com/spotbugs/spotbugs/issues/811") - private static void decrementBatchFailuresCounters(final List batchFailures, + private static void decrementBatchFailuresCounters(final Collection batchFailures, final Map, Batch> batchMap, final SyncCrudCounters counters) { for (BatchFailure batchFailure : batchFailures) { diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowCapableNodeLookups.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowCapableNodeLookups.java index 9fdb17d070..cf85bc277a 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowCapableNodeLookups.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowCapableNodeLookups.java @@ -7,9 +7,9 @@ */ package org.opendaylight.openflowplugin.applications.frsync.util; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.List; import java.util.Map; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; @@ -36,7 +36,7 @@ public final class FlowCapableNodeLookups { } @NonNull - public static Map wrapTablesToMap(@Nullable final List
tables) { + public static Map wrapTablesToMap(@Nullable final Collection
tables) { final Map tableMap; if (tables == null) { @@ -53,7 +53,7 @@ public final class FlowCapableNodeLookups { } @NonNull - public static Map wrapFlowsToMap(@Nullable final List flows) { + public static Map wrapFlowsToMap(@Nullable final Collection flows) { final Map flowMap; if (flows == null) { @@ -74,7 +74,7 @@ public final class FlowCapableNodeLookups { } @NonNull - public static Map wrapMetersToMap(@Nullable final List meters) { + public static Map wrapMetersToMap(@Nullable final Collection meters) { final Map meterMap; if (meters == null) { @@ -91,7 +91,7 @@ public final class FlowCapableNodeLookups { } @NonNull - public static Map wrapGroupsToMap(@Nullable final List groups) { + public static Map wrapGroupsToMap(@Nullable final Collection groups) { final Map groupMap; if (groups == null) { diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtil.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtil.java index cc5db45dd1..0d3799768d 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtil.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtil.java @@ -224,8 +224,8 @@ public final class ReconcileUtil { public static boolean checkGroupPrecondition(final Set installedGroupIds, final Group pendingGroup) { boolean okToInstall = true; // check each bucket in the pending group - for (Bucket bucket : pendingGroup.getBuckets().getBucket()) { - for (Action action : bucket.getAction()) { + for (Bucket bucket : pendingGroup.getBuckets().nonnullBucket().values()) { + for (Action action : bucket.nonnullAction().values()) { // if the output action is a group if (GroupActionCase.class.equals(action.getAction().implementedInterface())) { Uint32 groupId = ((GroupActionCase) action.getAction()).getGroupAction().getGroupId(); @@ -271,7 +271,7 @@ public final class ReconcileUtil { */ public static ItemSyncBox resolveMeterDiffs(final NodeId nodeId, final Map meterOperationalMap, - final List metersConfigured, + final Collection metersConfigured, final boolean gatherUpdates) { LOG.trace("resolving meters for {}", nodeId.getValue()); final ItemSyncBox syncBox = new ItemSyncBox<>(); @@ -297,7 +297,7 @@ public final class ReconcileUtil { * @param gatherUpdates check content of pending item if present on device (and create update task eventually) * @return list of safe synchronization steps */ - private static ItemSyncBox resolveFlowDiffsInTable(final List flowsConfigured, + private static ItemSyncBox resolveFlowDiffsInTable(final Collection flowsConfigured, final Map flowOperationalMap, final boolean gatherUpdates) { final ItemSyncBox flowsSyncBox = new ItemSyncBox<>(); @@ -327,13 +327,13 @@ public final class ReconcileUtil { * @return map : key={@link TableKey}, value={@link ItemSyncBox} of safe synchronization steps */ public static Map> resolveFlowDiffsInAllTables(final NodeId nodeId, - final Map tableOperationalMap, final List
tablesConfigured, + final Map tableOperationalMap, final Collection
tablesConfigured, final boolean gatherUpdates) { LOG.trace("resolving flows in tables for {}", nodeId.getValue()); final Map> tableFlowSyncBoxes = new HashMap<>(); for (final Table tableConfigured : tablesConfigured) { - final List flowsConfigured = tableConfigured.getFlow(); - if (flowsConfigured == null || flowsConfigured.isEmpty()) { + final Collection flowsConfigured = tableConfigured.nonnullFlow().values(); + if (flowsConfigured.isEmpty()) { continue; } @@ -342,7 +342,7 @@ public final class ReconcileUtil { // wrap existing (on device) flows in current table into map final Map flowOperationalMap = FlowCapableNodeLookups.wrapFlowsToMap( tableOperational != null - ? tableOperational.getFlow() + ? tableOperational.nonnullFlow().values() : null); @@ -355,15 +355,15 @@ public final class ReconcileUtil { return tableFlowSyncBoxes; } - public static List safeGroups(FlowCapableNode node) { - return node == null ? Collections.emptyList() : node.nonnullGroup(); + public static Collection safeGroups(FlowCapableNode node) { + return node == null ? Collections.emptyList() : node.nonnullGroup().values(); } - public static List
safeTables(FlowCapableNode node) { - return node == null ? Collections.emptyList() : node.nonnullTable(); + public static Collection
safeTables(FlowCapableNode node) { + return node == null ? Collections.emptyList() : node.nonnullTable().values(); } - public static List safeMeters(FlowCapableNode node) { - return node == null ? Collections.emptyList() : node.nonnullMeter(); + public static Collection safeMeters(FlowCapableNode node) { + return node == null ? Collections.emptyList() : node.nonnullMeter().values(); } } diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/DSInputFactory.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/DSInputFactory.java index 97068a9ac2..2fdf406259 100644 --- a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/DSInputFactory.java +++ b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/DSInputFactory.java @@ -19,6 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder; @@ -133,6 +134,7 @@ public final class DSInputFactory { public static Group createGroupWithPreconditions(final long groupIdValue, final long... requiredId) { final List actionBag = new ArrayList<>(); + int key = 0; for (long groupIdPrecondition : requiredId) { final GroupAction groupAction = new GroupActionBuilder() .setGroupId(groupIdPrecondition) @@ -142,6 +144,7 @@ public final class DSInputFactory { .build(); final Action action = new ActionBuilder() .setAction(groupActionCase) + .withKey(new ActionKey(key++)) .build(); actionBag.add(action); } diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListenerTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListenerTest.java index dab4687d7a..0a4d143af5 100644 --- a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListenerTest.java +++ b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListenerTest.java @@ -11,7 +11,7 @@ import com.google.common.util.concurrent.Futures; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Collections; -import java.util.List; +import java.util.Map; import java.util.Optional; import org.junit.Assert; import org.junit.Before; @@ -41,6 +41,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.Fl import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.snapshot.gathering.status.grouping.SnapshotGatheringStatusEnd; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.opendaylight.yangtools.util.concurrent.FluentFutures; @@ -83,7 +85,7 @@ public class SimplifiedOperationalListenerTest { @Mock private DeviceMastershipManager deviceMastershipManager; @Mock - private List nodeConnector; + private Map nodeConnector; @Mock private Node operationalNodeEmpty; diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/TableForwarderTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/TableForwarderTest.java index b99cdaabf2..c8c85bf742 100644 --- a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/TableForwarderTest.java +++ b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/TableForwarderTest.java @@ -110,8 +110,10 @@ public class TableForwarderTest { Assert.assertEquals(nodePath, updateTableInput.getNode().getValue()); Assert.assertEquals(1, updateTableInput.getOriginalTable().getTableFeatures().size()); - Assert.assertEquals("test-table", updateTableInput.getOriginalTable().getTableFeatures().get(0).getName()); + Assert.assertEquals("test-table", updateTableInput.getOriginalTable().nonnullTableFeatures().values() + .iterator().next().getName()); Assert.assertEquals(1, updateTableInput.getUpdatedTable().getTableFeatures().size()); - Assert.assertEquals("another-table", updateTableInput.getUpdatedTable().getTableFeatures().get(0).getName()); + Assert.assertEquals("another-table", updateTableInput.getUpdatedTable().nonnullTableFeatures().values() + .iterator().next().getName()); } } \ No newline at end of file diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtilTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtilTest.java index 9d1deecbc6..a4cd934b74 100644 --- a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtilTest.java +++ b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtilTest.java @@ -38,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.FlowCapableTransactionService; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierOutput; @@ -254,6 +255,7 @@ public class ReconcileUtilTest { private static Group createGroupWithPreconditions(final long groupIdValue, final long... requiredId) { final List actionBag = new ArrayList<>(); + int key = 0; for (long groupIdPrecondition : requiredId) { final GroupAction groupAction = new GroupActionBuilder() .setGroupId(groupIdPrecondition) @@ -263,6 +265,7 @@ public class ReconcileUtilTest { .build(); final Action action = new ActionBuilder() .setAction(groupActionCase) + .withKey(new ActionKey(key++)) .build(); actionBag.add(action); } diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/NodeConnectorStatNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/NodeConnectorStatNotificationSupplierImplTest.java index 12ac9bf778..95de7e23d1 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/NodeConnectorStatNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/NodeConnectorStatNotificationSupplierImplTest.java @@ -76,7 +76,8 @@ public class NodeConnectorStatNotificationSupplierImplTest { .createNotification(createTestConnectorStat(), createTestConnectorStatPath()); assertNotNull(notification); assertEquals(FLOW_NODE_ID, notification.getId().getValue()); - assertEquals(FLOW_CODE_CONNECTOR_ID, notification.getNodeConnector().get(0).getId().getValue()); + assertEquals(FLOW_CODE_CONNECTOR_ID, notification.nonnullNodeConnector().values().iterator().next().getId() + .getValue()); } @Test diff --git a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/QueueStatNotificationSupplierImplTest.java b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/QueueStatNotificationSupplierImplTest.java index a13987a58b..0337834e90 100644 --- a/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/QueueStatNotificationSupplierImplTest.java +++ b/applications/notification-supplier/src/test/java/org/opendaylight/openflowplugin/applications/notification/supplier/impl/item/stat/QueueStatNotificationSupplierImplTest.java @@ -78,7 +78,8 @@ public class QueueStatNotificationSupplierImplTest { .createNotification(createTestQueueStat(), createTestQueueStatPath()); assertNotNull(notification); assertEquals(FLOW_NODE_ID, notification.getId().getValue()); - assertEquals(FLOW_CODE_CONNECTOR_ID, notification.getNodeConnector().get(0).getId().getValue()); + assertEquals(FLOW_CODE_CONNECTOR_ID, notification.nonnullNodeConnector().values().iterator().next().getId() + .getValue()); } @Test diff --git a/applications/pom.xml b/applications/pom.xml index bf99da451c..e2f1d4887f 100644 --- a/applications/pom.xml +++ b/applications/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent odlparent-lite - 6.0.4 + 7.0.1 diff --git a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java index 30bfd73598..6680c58c11 100644 --- a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java +++ b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java @@ -228,7 +228,8 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo } } try { - tx.merge(LogicalDatastoreType.OPERATIONAL, instanceIdentifier, counterBuilder.build(), true); + tx.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, instanceIdentifier, + counterBuilder.build()); tx.commit().get(); } catch (InterruptedException | ExecutionException e) { LOG.error("Exception while submitting counter for {}", nodeId, e); diff --git a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/ReconciliationCount.java b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/ReconciliationCount.java index d2b783d8aa..8290d79969 100644 --- a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/ReconciliationCount.java +++ b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/cli/ReconciliationCount.java @@ -8,8 +8,8 @@ package org.opendaylight.openflowplugin.applications.southboundcli.cli; +import java.util.Collection; import java.util.Formatter; -import java.util.List; import org.apache.karaf.shell.commands.Command; import org.apache.karaf.shell.console.OsgiCommandSupport; import org.opendaylight.mdsal.binding.api.DataBroker; @@ -29,7 +29,7 @@ public class ReconciliationCount extends OsgiCommandSupport { @SuppressWarnings("checkstyle:RegexpSinglelineJava") @Override protected Object doExecute() { - List result = ShellUtil.getReconcileCount(dataBroker); + Collection result = ShellUtil.getReconcileCount(dataBroker); if (result.isEmpty()) { System.out.println("Reconciliation count not yet available for openflow nodes."); } else { diff --git a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/util/ShellUtil.java b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/util/ShellUtil.java index 4eb6735ec9..d72029bf36 100644 --- a/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/util/ShellUtil.java +++ b/applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/util/ShellUtil.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowplugin.applications.southboundcli.util; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; @@ -79,8 +80,8 @@ public final class ShellUtil { Optional result = tx.read(LogicalDatastoreType.OPERATIONAL, path).get(); if (result.isPresent()) { Node node = result.get(); - String name = null; - List nodeConnectors = null; + String name; + Collection nodeConnectors = node.nonnullNodeConnector().values(); List portList = new ArrayList<>(); FlowCapableNode flowCapableNode = node.augmentation(FlowCapableNode.class); if (flowCapableNode != null) { @@ -89,7 +90,6 @@ public final class ShellUtil { LOG.error("Error while converting OFNode:{} to FlowCapableNode", node.getId()); return null; } - nodeConnectors = node.getNodeConnector(); for (NodeConnector nodeConnector : nodeConnectors) { FlowCapableNodeConnector flowCapableNodeConnector = nodeConnector.augmentation(FlowCapableNodeConnector.class); @@ -112,15 +112,15 @@ public final class ShellUtil { return ofNode; } - public static List getReconcileCount(final DataBroker dataBroker) { + public static Collection getReconcileCount(final DataBroker dataBroker) { InstanceIdentifier instanceIdentifier = InstanceIdentifier .builder(ReconciliationCounter.class).build(); - List output = Collections.emptyList(); + Collection output = Collections.emptyList(); try (ReadTransaction tx = dataBroker.newReadOnlyTransaction()) { Optional result = tx.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier).get(); if (result.isPresent()) { - output = result.get().getReconcileCounter(); + output = result.get().nonnullReconcileCounter().values(); } } catch (ExecutionException | InterruptedException | NullPointerException e) { LOG.error("Error reading reconciliation counter from datastore", e); diff --git a/applications/table-miss-enforcer/src/test/java/org/opendaylight/openflowplugin/applications/tablemissenforcer/LLDPDataTreeChangeListenerTest.java b/applications/table-miss-enforcer/src/test/java/org/opendaylight/openflowplugin/applications/tablemissenforcer/LLDPDataTreeChangeListenerTest.java index 26d9ba9558..42a67955f3 100644 --- a/applications/table-miss-enforcer/src/test/java/org/opendaylight/openflowplugin/applications/tablemissenforcer/LLDPDataTreeChangeListenerTest.java +++ b/applications/table-miss-enforcer/src/test/java/org/opendaylight/openflowplugin/applications/tablemissenforcer/LLDPDataTreeChangeListenerTest.java @@ -105,7 +105,7 @@ public class LLDPDataTreeChangeListenerTest { } private static void evaluateInstruction(final Instruction instruction) { - if (instruction.getInstruction() instanceof ApplyActionsCase) { + if (instruction != null && instruction.getInstruction() instanceof ApplyActionsCase) { ApplyActionsCase applyActionsCase = (ApplyActionsCase) instruction.getInstruction(); assertNotNull(applyActionsCase.getApplyActions().getAction()); assertEquals(1, applyActionsCase.getApplyActions().getAction().size()); diff --git a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/utils/LLDPDiscoveryUtils.java b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/utils/LLDPDiscoveryUtils.java index 817499eb5f..8f5e8eac23 100644 --- a/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/utils/LLDPDiscoveryUtils.java +++ b/applications/topology-lldp-discovery/src/main/java/org/opendaylight/openflowplugin/applications/topology/lldp/utils/LLDPDiscoveryUtils.java @@ -18,7 +18,6 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Optional; -import org.apache.commons.lang3.ArrayUtils; import org.opendaylight.mdsal.eos.binding.api.Entity; import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService; import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState; @@ -205,7 +204,7 @@ public final class LLDPDiscoveryUtils { boolean secAuthenticatorOk = false; if (hashLldptlv != null) { byte[] rawTlvValue = hashLldptlv.getValue(); - byte[] lldpCustomSecurityHash = ArrayUtils.subarray(rawTlvValue, 4, rawTlvValue.length); + byte[] lldpCustomSecurityHash = Arrays.copyOfRange(rawTlvValue, 4, rawTlvValue.length); byte[] calculatedHash = getValueForLLDPPacketIntegrityEnsuring(srcNodeConnectorId); secAuthenticatorOk = Arrays.equals(calculatedHash, lldpCustomSecurityHash); } else { diff --git a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TopologyManagerUtil.java b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TopologyManagerUtil.java index 2193a13576..c2605a334e 100644 --- a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TopologyManagerUtil.java +++ b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TopologyManagerUtil.java @@ -47,7 +47,7 @@ final class TopologyManagerUtil { return; } - for (Link link : topologyOptional.get().nonnullLink()) { + for (Link link : topologyOptional.get().nonnullLink().values()) { if (id.equals(link.getSource().getSourceNode()) || id.equals(link.getDestination().getDestNode())) { manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, linkPath(link, topology)); } @@ -75,7 +75,7 @@ final class TopologyManagerUtil { return; } - for (Link link : topologyOptional.get().nonnullLink()) { + for (Link link : topologyOptional.get().nonnullLink().values()) { if (id.equals(link.getSource().getSourceTp()) || id.equals(link.getDestination().getDestTp())) { manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, linkPath(link, topology)); } diff --git a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyExporterTest.java b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyExporterTest.java index 7ca06ca0c3..34ac9ae806 100644 --- a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyExporterTest.java +++ b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/FlowCapableTopologyExporterTest.java @@ -109,9 +109,9 @@ public class FlowCapableTopologyExporterTest { waitForSubmit(submitLatch); ArgumentCaptor mergedNode = ArgumentCaptor.forClass(Link.class); - verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(topologyIID.child( + verify(mockTx).mergeParentStructureMerge(eq(LogicalDatastoreType.OPERATIONAL), eq(topologyIID.child( Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId())))), - mergedNode.capture(), eq(true)); + mergedNode.capture()); assertEquals("Source node ID", "sourceNode", mergedNode.getValue().getSource().getSourceNode().getValue()); assertEquals("Dest TP ID", "sourceTP", diff --git a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/NodeChangeListenerImplTest.java b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/NodeChangeListenerImplTest.java index 162a4c74de..bc7f67b8a0 100644 --- a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/NodeChangeListenerImplTest.java +++ b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/NodeChangeListenerImplTest.java @@ -69,7 +69,7 @@ public class NodeChangeListenerImplTest extends DataTreeChangeListenerBase { List linkList = Arrays.asList( newLink("link1", newSourceNode("node1"), newDestNode("dest")), newLink("link2", newSourceNode("source"), newDestNode("node1")), - newLink("link2", newSourceNode("source2"), newDestNode("dest2"))); + newLink("link3", newSourceNode("source2"), newDestNode("dest2"))); final Topology topology = new TopologyBuilder().setLink(linkList).build(); final InstanceIdentifier[] expDeletedIIDs = { @@ -174,8 +174,8 @@ public class NodeChangeListenerImplTest extends DataTreeChangeListenerBase { ArgumentCaptor mergedNode = ArgumentCaptor.forClass(Node.class); NodeId expNodeId = new NodeId("node1"); - verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(topologyIID.child(Node.class, - new NodeKey(expNodeId))), mergedNode.capture(), eq(true)); + verify(mockTx).mergeParentStructureMerge(eq(LogicalDatastoreType.OPERATIONAL), eq(topologyIID.child(Node.class, + new NodeKey(expNodeId))), mergedNode.capture()); assertEquals("getNodeId", expNodeId, mergedNode.getValue().getNodeId()); InventoryNode augmentation = mergedNode.getValue().augmentation(InventoryNode.class); assertNotNull("Missing augmentation", augmentation); diff --git a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImplTest.java b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImplTest.java index c4bc396e00..92ab192d3b 100644 --- a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImplTest.java +++ b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImplTest.java @@ -197,8 +197,8 @@ public class TerminationPointChangeListenerImplTest extends DataTreeChangeListen InstanceIdentifier expTpPath = topologyIID.child( Node.class, new NodeKey(expNodeId)).child(TerminationPoint.class, new TerminationPointKey(expTpId)); - verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath), - mergedNode.capture(), eq(true)); + verify(mockTx).mergeParentStructureMerge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath), + mergedNode.capture()); assertEquals("getTpId", expTpId, mergedNode.getValue().getTpId()); InventoryNodeConnector augmentation = mergedNode.getValue().augmentation( InventoryNodeConnector.class); @@ -245,8 +245,8 @@ public class TerminationPointChangeListenerImplTest extends DataTreeChangeListen Node.class, new NodeKey(new NodeId("node1"))).child(TerminationPoint.class, new TerminationPointKey(new TpId("tp1"))); - verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath), - any(TerminationPoint.class), eq(true)); + verify(mockTx).mergeParentStructureMerge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath), + any(TerminationPoint.class)); assertDeletedIDs(new InstanceIdentifier[]{topologyIID.child(Link.class, linkList.get(0).key())}, deletedLinkIDs); @@ -290,8 +290,8 @@ public class TerminationPointChangeListenerImplTest extends DataTreeChangeListen Node.class, new NodeKey(new NodeId("node1"))).child(TerminationPoint.class, new TerminationPointKey(new TpId("tp1"))); - verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath), - any(TerminationPoint.class), eq(true)); + verify(mockTx).mergeParentStructureMerge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath), + any(TerminationPoint.class)); assertDeletedIDs(new InstanceIdentifier[]{topologyIID.child(Link.class, linkList.get(0).key())}, deletedLinkIDs); diff --git a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TestUtils.java b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TestUtils.java index 33cb82e5df..f7569d28c1 100644 --- a/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TestUtils.java +++ b/applications/topology-manager/src/test/java/org/opendaylight/openflowplugin/applications/topology/manager/TestUtils.java @@ -42,6 +42,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology. import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkBuilder; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; @@ -123,7 +124,8 @@ public final class TestUtils { } static Link newLink(String id, Source source, Destination dest) { - return new LinkBuilder().setLinkId(new LinkId(id)).setSource(source).setDestination(dest).build(); + return new LinkBuilder().setLinkId(new LinkId(id)).setSource(source).setDestination(dest) + .withKey(new LinkKey(new LinkId(id))).build(); } static Destination newDestTp(String id) { diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 182763bb52..9d217c1917 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -13,7 +13,7 @@ org.opendaylight.odlparent odlparent-lite - 6.0.4 + 7.0.1 diff --git a/distribution/karaf/pom.xml b/distribution/karaf/pom.xml index ee94fdd9fe..f649f64f00 100644 --- a/distribution/karaf/pom.xml +++ b/distribution/karaf/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent karaf4-parent - 6.0.4 + 7.0.1 org.opendaylight.openflowplugin openflowplugin-karaf diff --git a/extension/features-extension-aggregator/features-openflowplugin-extension/pom.xml b/extension/features-extension-aggregator/features-openflowplugin-extension/pom.xml index 7303d73238..c9d1e519e7 100644 --- a/extension/features-extension-aggregator/features-openflowplugin-extension/pom.xml +++ b/extension/features-extension-aggregator/features-openflowplugin-extension/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent feature-repo-parent - 6.0.4 + 7.0.1 diff --git a/extension/features-extension-aggregator/odl-openflowplugin-eric-extensions/pom.xml b/extension/features-extension-aggregator/odl-openflowplugin-eric-extensions/pom.xml index 2090d0477c..f4b211cd7f 100644 --- a/extension/features-extension-aggregator/odl-openflowplugin-eric-extensions/pom.xml +++ b/extension/features-extension-aggregator/odl-openflowplugin-eric-extensions/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/extension/features-extension-aggregator/odl-openflowplugin-nxm-extensions/pom.xml b/extension/features-extension-aggregator/odl-openflowplugin-nxm-extensions/pom.xml index 52e8d9c443..a210ae9902 100644 --- a/extension/features-extension-aggregator/odl-openflowplugin-nxm-extensions/pom.xml +++ b/extension/features-extension-aggregator/odl-openflowplugin-nxm-extensions/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/extension/features-extension-aggregator/odl-openflowplugin-onf-extensions/pom.xml b/extension/features-extension-aggregator/odl-openflowplugin-onf-extensions/pom.xml index 9ce686b8e3..124ed3e6f2 100644 --- a/extension/features-extension-aggregator/odl-openflowplugin-onf-extensions/pom.xml +++ b/extension/features-extension-aggregator/odl-openflowplugin-onf-extensions/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/extension/features-extension-aggregator/pom.xml b/extension/features-extension-aggregator/pom.xml index dcab50ae12..be0ab2c7a0 100644 --- a/extension/features-extension-aggregator/pom.xml +++ b/extension/features-extension-aggregator/pom.xml @@ -3,7 +3,7 @@ org.opendaylight.odlparent odlparent-lite - 6.0.4 + 7.0.1 4.0.0 diff --git a/extension/openflowplugin-extension-api/src/test/java/org/opendaylight/openflowplugin/extension/api/GroupingLooseResolverTest.java b/extension/openflowplugin-extension-api/src/test/java/org/opendaylight/openflowplugin/extension/api/GroupingLooseResolverTest.java index 6c3a6819fa..d0dd60f4e8 100644 --- a/extension/openflowplugin-extension-api/src/test/java/org/opendaylight/openflowplugin/extension/api/GroupingLooseResolverTest.java +++ b/extension/openflowplugin-extension-api/src/test/java/org/opendaylight/openflowplugin/extension/api/GroupingLooseResolverTest.java @@ -49,9 +49,9 @@ public class GroupingLooseResolverTest { mb2.addAugmentation(GeneralAugMatchNotifPacketIn.class, odlxxx2).build(); Assert.assertEquals(JoachimTheBig.class, - eqGroup.getExtension(match1).get().getExtensionList().get(0).getExtensionKey()); + eqGroup.getExtension(match1).get().nonnullExtensionList().values().iterator().next().getExtensionKey()); Assert.assertEquals(JoachimTheTiny.class, - eqGroup.getExtension(match2).get().getExtensionList().get(0).getExtensionKey()); + eqGroup.getExtension(match2).get().nonnullExtensionList().values().iterator().next().getExtensionKey()); } private interface JoachimTheBig extends ExtensionKey { diff --git a/extension/openflowplugin-extension-api/src/test/java/org/opendaylight/openflowplugin/extension/api/GroupingResolverTest.java b/extension/openflowplugin-extension-api/src/test/java/org/opendaylight/openflowplugin/extension/api/GroupingResolverTest.java index 4ddc915780..43c1e2998f 100644 --- a/extension/openflowplugin-extension-api/src/test/java/org/opendaylight/openflowplugin/extension/api/GroupingResolverTest.java +++ b/extension/openflowplugin-extension-api/src/test/java/org/opendaylight/openflowplugin/extension/api/GroupingResolverTest.java @@ -49,9 +49,9 @@ public class GroupingResolverTest { Match match2 = mb2.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, odlxxx2).build(); Assert.assertEquals(JoachimTheBig.class, - eqGroup.getExtension(match1).get().getExtensionList().get(0).getExtensionKey()); + eqGroup.getExtension(match1).get().nonnullExtensionList().values().iterator().next().getExtensionKey()); Assert.assertEquals(JoachimTheTiny.class, - eqGroup.getExtension(match2).get().getExtensionList().get(0).getExtensionKey()); + eqGroup.getExtension(match2).get().nonnullExtensionList().values().iterator().next().getExtensionKey()); } private interface JoachimTheBig extends ExtensionKey { diff --git a/extension/openflowplugin-extension-api/src/test/java/org/opendaylight/openflowplugin/extension/api/SetFieldExtensionTest.java b/extension/openflowplugin-extension-api/src/test/java/org/opendaylight/openflowplugin/extension/api/SetFieldExtensionTest.java index f47fd103e0..4e49367b43 100755 --- a/extension/openflowplugin-extension-api/src/test/java/org/opendaylight/openflowplugin/extension/api/SetFieldExtensionTest.java +++ b/extension/openflowplugin-extension-api/src/test/java/org/opendaylight/openflowplugin/extension/api/SetFieldExtensionTest.java @@ -45,9 +45,11 @@ public class SetFieldExtensionTest { odlxxx2).build(); Assert.assertEquals(ZVendorExt1.class, - eqGroup.getExtension(setField1).get().getExtensionList().get(0).getExtensionKey()); + eqGroup.getExtension(setField1).get().nonnullExtensionList().values().iterator().next() + .getExtensionKey()); Assert.assertEquals(ZVendorExt2.class, - eqGroup.getExtension(setField2).get().getExtensionList().get(0).getExtensionKey()); + eqGroup.getExtension(setField2).get().nonnullExtensionList().values().iterator().next() + .getExtensionKey()); } private interface ZVendorExt1 extends ExtensionKey { diff --git a/extension/openflowplugin-extension-eric/src/test/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDOptionsTypeConvertorTest.java b/extension/openflowplugin-extension-eric/src/test/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDOptionsTypeConvertorTest.java index 7d96d23778..2e7328352c 100644 --- a/extension/openflowplugin-extension-eric/src/test/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDOptionsTypeConvertorTest.java +++ b/extension/openflowplugin-extension-eric/src/test/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDOptionsTypeConvertorTest.java @@ -142,8 +142,8 @@ public class Icmpv6NDOptionsTypeConvertorTest { SetField setField = sb.addAugmentation(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class, ndOptionsTypeSetField).build(); - Assert.assertEquals(Icmpv6NdOptionsTypeKey.class, eqGroup.getExtension(setField).get().getExtensionList().get(0) - .getExtensionKey()); + Assert.assertEquals(Icmpv6NdOptionsTypeKey.class, eqGroup.getExtension(setField).get().nonnullExtensionList() + .values().iterator().next().getExtensionKey()); } } \ No newline at end of file diff --git a/extension/openflowplugin-extension-eric/src/test/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDReservedConvertorTest.java b/extension/openflowplugin-extension-eric/src/test/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDReservedConvertorTest.java index a6d4c26b7f..38b757bd1c 100644 --- a/extension/openflowplugin-extension-eric/src/test/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDReservedConvertorTest.java +++ b/extension/openflowplugin-extension-eric/src/test/java/org/opendaylight/openflowplugin/extension/vendor/eric/convertor/match/Icmpv6NDReservedConvertorTest.java @@ -142,8 +142,8 @@ public class Icmpv6NDReservedConvertorTest { SetField setField = sb.addAugmentation(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class, ndReservedSetField).build(); - Assert.assertEquals(Icmpv6NdReservedKey.class, eqGroup.getExtension(setField).get().getExtensionList().get(0) - .getExtensionKey()); + Assert.assertEquals(Icmpv6NdReservedKey.class, eqGroup.getExtension(setField).get().nonnullExtensionList() + .values().iterator().next().getExtensionKey()); } } \ No newline at end of file diff --git a/extension/openflowplugin-extension-onf/src/main/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleAddMessageConverter.java b/extension/openflowplugin-extension-onf/src/main/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleAddMessageConverter.java index 5fef298dce..c90e21d50c 100644 --- a/extension/openflowplugin-extension-onf/src/main/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleAddMessageConverter.java +++ b/extension/openflowplugin-extension-onf/src/main/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleAddMessageConverter.java @@ -8,6 +8,7 @@ package org.opendaylight.openflowplugin.extension.onf.converter; +import java.util.Collection; import java.util.List; import java.util.Optional; import org.opendaylight.openflowplugin.extension.api.ConverterMessageToOFJava; @@ -22,7 +23,7 @@ import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.XidCo import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder; @@ -178,9 +179,10 @@ public class BundleAddMessageConverter implements Optional portModInput = Optional.empty(); final Class clazz = messageCase.implementedInterface(); if (clazz.equals(BundleUpdatePortCase.class)) { - portModInput = CONVERTER_EXECUTOR.convert(new PortBuilder( - ((BundleUpdatePortCase) messageCase).getUpdatePortCaseData().getPort().getPort().get(0)).build(), - data); + Collection ports + = ((BundleUpdatePortCase) messageCase).getUpdatePortCaseData().getPort().nonnullPort().values(); + Port port = ports.iterator().next(); + portModInput = CONVERTER_EXECUTOR.convert(port, data); } if (portModInput.isPresent()) { diff --git a/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleAddMessageConverterTest.java b/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleAddMessageConverterTest.java index 1ee9b7f6e7..220fe7b00d 100644 --- a/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleAddMessageConverterTest.java +++ b/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleAddMessageConverterTest.java @@ -26,6 +26,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.P import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.PortBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; @@ -151,6 +152,7 @@ public class BundleAddMessageConverterTest { .setAdvertisedFeatures(Mockito.mock(PortFeatures.class)) .setPortNumber(new PortNumberUni(Uint32.ZERO)) .setHardwareAddress(Mockito.mock(MacAddress.class)) + .withKey(new PortKey(Uint32.ZERO)) .build())) .build()).build()) .build(), BundlePortModCase.class); @@ -194,7 +196,7 @@ public class BundleAddMessageConverterTest { convertedProperty.getBundlePropertyExperimenterData()); } else { Assert.assertTrue("Properties not empty", - converted.getOnfAddMessageGroupingData().getBundleProperty().isEmpty()); + converted.getOnfAddMessageGroupingData().nonnullBundleProperty().isEmpty()); } } diff --git a/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleControlConverterTest.java b/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleControlConverterTest.java index 2afe830f48..a659a9e2ce 100644 --- a/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleControlConverterTest.java +++ b/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleControlConverterTest.java @@ -118,7 +118,7 @@ public class BundleControlConverterTest { Assert.assertTrue("Properties not empty", ofjMessage .getOnfControlGroupingData() - .getBundleProperty() + .nonnullBundleProperty() .isEmpty()); } } diff --git a/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/deserializer/BundleControlFactoryTest.java b/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/deserializer/BundleControlFactoryTest.java index 1b20384eec..4b83b238e7 100644 --- a/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/deserializer/BundleControlFactoryTest.java +++ b/extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/deserializer/BundleControlFactoryTest.java @@ -57,7 +57,7 @@ public class BundleControlFactoryTest { Assert.assertEquals("Wrong type", BundleControlType.ONFBCTOPENREPLY, builtByFactory.getOnfControlGroupingData().getType()); Assert.assertTrue("Properties not empty", - builtByFactory.getOnfControlGroupingData().getBundleProperty().isEmpty()); + builtByFactory.getOnfControlGroupingData().nonnullBundleProperty().isEmpty()); } @Test diff --git a/extension/pom.xml b/extension/pom.xml index 403cb8d3f1..e17e1221b0 100644 --- a/extension/pom.xml +++ b/extension/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent odlparent-lite - 6.0.4 + 7.0.1 diff --git a/features-aggregator/features-openflowplugin/pom.xml b/features-aggregator/features-openflowplugin/pom.xml index d7412d3dc3..fb58022b3e 100644 --- a/features-aggregator/features-openflowplugin/pom.xml +++ b/features-aggregator/features-openflowplugin/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent feature-repo-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-app-arbitratorreconciliation/pom.xml b/features-aggregator/odl-openflowplugin-app-arbitratorreconciliation/pom.xml index deab0e6239..6e46eaad2b 100644 --- a/features-aggregator/odl-openflowplugin-app-arbitratorreconciliation/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-arbitratorreconciliation/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-app-bulk-o-matic/pom.xml b/features-aggregator/odl-openflowplugin-app-bulk-o-matic/pom.xml index 332294dd14..73e686b329 100644 --- a/features-aggregator/odl-openflowplugin-app-bulk-o-matic/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-bulk-o-matic/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-app-config-pusher/pom.xml b/features-aggregator/odl-openflowplugin-app-config-pusher/pom.xml index a2aeaf8db8..b71fb3ebc7 100644 --- a/features-aggregator/odl-openflowplugin-app-config-pusher/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-config-pusher/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-app-forwardingrules-manager/pom.xml b/features-aggregator/odl-openflowplugin-app-forwardingrules-manager/pom.xml index abf34f6808..ccdfe259e6 100644 --- a/features-aggregator/odl-openflowplugin-app-forwardingrules-manager/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-forwardingrules-manager/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-app-forwardingrules-sync/pom.xml b/features-aggregator/odl-openflowplugin-app-forwardingrules-sync/pom.xml index e009af619c..57ea296603 100644 --- a/features-aggregator/odl-openflowplugin-app-forwardingrules-sync/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-forwardingrules-sync/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-app-lldp-speaker/pom.xml b/features-aggregator/odl-openflowplugin-app-lldp-speaker/pom.xml index 2da600b4c0..bc1d89d64a 100644 --- a/features-aggregator/odl-openflowplugin-app-lldp-speaker/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-lldp-speaker/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-app-notifications/pom.xml b/features-aggregator/odl-openflowplugin-app-notifications/pom.xml index 6a6b3aafba..acbddad438 100644 --- a/features-aggregator/odl-openflowplugin-app-notifications/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-notifications/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-app-reconciliation-framework/pom.xml b/features-aggregator/odl-openflowplugin-app-reconciliation-framework/pom.xml index ddae6474af..0d48560611 100644 --- a/features-aggregator/odl-openflowplugin-app-reconciliation-framework/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-reconciliation-framework/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-app-southbound-cli/pom.xml b/features-aggregator/odl-openflowplugin-app-southbound-cli/pom.xml index 34b6cf11fe..92dac0d1e9 100644 --- a/features-aggregator/odl-openflowplugin-app-southbound-cli/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-southbound-cli/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-app-table-miss-enforcer/pom.xml b/features-aggregator/odl-openflowplugin-app-table-miss-enforcer/pom.xml index 46d63bcedd..49753b47e9 100644 --- a/features-aggregator/odl-openflowplugin-app-table-miss-enforcer/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-table-miss-enforcer/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-app-topology-lldp-discovery/pom.xml b/features-aggregator/odl-openflowplugin-app-topology-lldp-discovery/pom.xml index 039eef3a77..3cb4dfcc9a 100644 --- a/features-aggregator/odl-openflowplugin-app-topology-lldp-discovery/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-topology-lldp-discovery/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-app-topology-manager/pom.xml b/features-aggregator/odl-openflowplugin-app-topology-manager/pom.xml index 334f544a2c..a50badf495 100644 --- a/features-aggregator/odl-openflowplugin-app-topology-manager/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-topology-manager/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-app-topology/pom.xml b/features-aggregator/odl-openflowplugin-app-topology/pom.xml index 9d9f0f323d..8e597103c6 100644 --- a/features-aggregator/odl-openflowplugin-app-topology/pom.xml +++ b/features-aggregator/odl-openflowplugin-app-topology/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-drop-test/pom.xml b/features-aggregator/odl-openflowplugin-drop-test/pom.xml index 6bd0482fad..224aeee3d0 100644 --- a/features-aggregator/odl-openflowplugin-drop-test/pom.xml +++ b/features-aggregator/odl-openflowplugin-drop-test/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-flow-services-rest/pom.xml b/features-aggregator/odl-openflowplugin-flow-services-rest/pom.xml index ddd7d57aa6..381645206d 100644 --- a/features-aggregator/odl-openflowplugin-flow-services-rest/pom.xml +++ b/features-aggregator/odl-openflowplugin-flow-services-rest/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-flow-services/pom.xml b/features-aggregator/odl-openflowplugin-flow-services/pom.xml index dd74cc0733..1c201554f8 100644 --- a/features-aggregator/odl-openflowplugin-flow-services/pom.xml +++ b/features-aggregator/odl-openflowplugin-flow-services/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-libraries/pom.xml b/features-aggregator/odl-openflowplugin-libraries/pom.xml index 66a193cef2..43f86e33e8 100644 --- a/features-aggregator/odl-openflowplugin-libraries/pom.xml +++ b/features-aggregator/odl-openflowplugin-libraries/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 diff --git a/features-aggregator/odl-openflowplugin-libraries/src/main/feature/feature.xml b/features-aggregator/odl-openflowplugin-libraries/src/main/feature/feature.xml index be208d6d90..912b3205d6 100644 --- a/features-aggregator/odl-openflowplugin-libraries/src/main/feature/feature.xml +++ b/features-aggregator/odl-openflowplugin-libraries/src/main/feature/feature.xml @@ -1,6 +1,6 @@ - odl-guava + odl-guava diff --git a/features-aggregator/odl-openflowplugin-nsf-model/pom.xml b/features-aggregator/odl-openflowplugin-nsf-model/pom.xml index 5981c39bb9..c005a08294 100644 --- a/features-aggregator/odl-openflowplugin-nsf-model/pom.xml +++ b/features-aggregator/odl-openflowplugin-nsf-model/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 @@ -21,7 +21,7 @@ org.opendaylight.mdsal mdsal-artifacts - 5.0.9 + 6.0.0 import pom @@ -29,8 +29,8 @@ org.opendaylight.controller - mdsal-artifacts - 1.11.0 + controller-artifacts + 2.0.0 import pom diff --git a/features-aggregator/odl-openflowplugin-southbound/pom.xml b/features-aggregator/odl-openflowplugin-southbound/pom.xml index f609b37c2c..4af51145b4 100644 --- a/features-aggregator/odl-openflowplugin-southbound/pom.xml +++ b/features-aggregator/odl-openflowplugin-southbound/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 @@ -28,8 +28,8 @@ org.opendaylight.controller - mdsal-artifacts - 1.11.0 + controller-artifacts + 2.0.0 import pom diff --git a/features-aggregator/pom.xml b/features-aggregator/pom.xml index 956f688478..21c9d3d881 100644 --- a/features-aggregator/pom.xml +++ b/features-aggregator/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent odlparent-lite - 6.0.4 + 7.0.1 diff --git a/libraries/liblldp/pom.xml b/libraries/liblldp/pom.xml index 3b034d95f1..e9768e91a1 100644 --- a/libraries/liblldp/pom.xml +++ b/libraries/liblldp/pom.xml @@ -37,8 +37,8 @@ guava - javax.xml.bind - jaxb-api + jakarta.xml.bind + jakarta.xml.bind-api diff --git a/libraries/pom.xml b/libraries/pom.xml index 2d2471929b..4eca7fa923 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent odlparent-lite - 6.0.4 + 7.0.1 diff --git a/model/pom.xml b/model/pom.xml index 92661c1898..be13979fef 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -6,7 +6,7 @@ org.opendaylight.odlparent odlparent-lite - 6.0.4 + 7.0.1 diff --git a/openflowjava/features-openflowjava-aggregator/features-openflowjava/pom.xml b/openflowjava/features-openflowjava-aggregator/features-openflowjava/pom.xml index 812fc4916d..bd2e1c0314 100644 --- a/openflowjava/features-openflowjava-aggregator/features-openflowjava/pom.xml +++ b/openflowjava/features-openflowjava-aggregator/features-openflowjava/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent feature-repo-parent - 6.0.4 + 7.0.1 diff --git a/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/pom.xml b/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/pom.xml index 3dd50ff4f7..e9fd5b6a04 100644 --- a/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/pom.xml +++ b/openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent single-feature-parent - 6.0.4 + 7.0.1 @@ -33,7 +33,7 @@ org.opendaylight.mdsal mdsal-artifacts - 5.0.9 + 6.0.0 import pom diff --git a/openflowjava/features-openflowjava-aggregator/pom.xml b/openflowjava/features-openflowjava-aggregator/pom.xml index 0fb9e991eb..29d1387864 100644 --- a/openflowjava/features-openflowjava-aggregator/pom.xml +++ b/openflowjava/features-openflowjava-aggregator/pom.xml @@ -4,7 +4,7 @@ org.opendaylight.odlparent odlparent-lite - 6.0.4 + 7.0.1 diff --git a/openflowjava/openflow-protocol-api/src/main/yang/openflow-instruction.yang b/openflowjava/openflow-protocol-api/src/main/yang/openflow-instruction.yang index afa06e501a..bca6e3611a 100644 --- a/openflowjava/openflow-protocol-api/src/main/yang/openflow-instruction.yang +++ b/openflowjava/openflow-protocol-api/src/main/yang/openflow-instruction.yang @@ -24,7 +24,7 @@ grouping instructions-grouping { list instruction { config false; - key "experimenter-id"; + ordered-by user; uses instruction-grouping; leaf experimenter-id { type oft:experimenter-id; diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java index a5034cef1e..98fbbe3b18 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/HelloMessageFactoryTest.java @@ -101,10 +101,10 @@ public class HelloMessageFactoryTest extends DefaultDeserializerFactoryTest createElement(int lengthInByte, int type) { + private static List createElement(final int lengthInByte, final int type) { final ElementsBuilder elementsBuilder = new ElementsBuilder(); final List elementsList = new ArrayList<>(); List booleanList = new ArrayList<>(); diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java index 4322bd6433..dff63a275c 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactoryTest.java @@ -128,6 +128,6 @@ public class OF10FeaturesReplyMessageFactoryTest { builtByFactory.getCapabilitiesV10()); Assert.assertEquals("Wrong actions", new ActionTypeV10(false, false, false, false, false, false, false, false, false, false, false, false, false), builtByFactory.getActionsV10()); - Assert.assertEquals("Wrong ports size", 0, builtByFactory.getPhyPort().size()); + Assert.assertEquals("Wrong ports size", 0, builtByFactory.nonnullPhyPort().size()); } } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java index 9091dbcc15..4b69ebebf3 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java @@ -59,7 +59,7 @@ public class MultipartReplyFlowTest { Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); - Assert.assertEquals("Wrong flow stats size", 0, message.getFlowStats().size()); + Assert.assertEquals("Wrong flow stats size", 0, message.nonnullFlowStats().size()); } /** diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java index b5fb6b37f4..bdce927379 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java @@ -44,7 +44,7 @@ public class MultipartReplyPortDescTest { Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody(); MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc(); - Assert.assertEquals("Wrong table features size", 0, message.getPorts().size()); + Assert.assertEquals("Wrong table features size", 0, message.nonnullPorts().size()); } /** diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java index de679d9ef8..52276a087e 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java @@ -46,7 +46,7 @@ public class MultipartReplyTableFeaturesTest { MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); - Assert.assertEquals("Wrong table features size", 0, message.getTableFeatures().size()); + Assert.assertEquals("Wrong table features size", 0, message.nonnullTableFeatures().size()); } /** diff --git a/openflowplugin-common/src/main/java/org/opendaylight/openflowplugin/common/txchain/TransactionChainManager.java b/openflowplugin-common/src/main/java/org/opendaylight/openflowplugin/common/txchain/TransactionChainManager.java index 9230d3582a..4fda051948 100755 --- a/openflowplugin-common/src/main/java/org/opendaylight/openflowplugin/common/txchain/TransactionChainManager.java +++ b/openflowplugin-common/src/main/java/org/opendaylight/openflowplugin/common/txchain/TransactionChainManager.java @@ -242,7 +242,11 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl throw new TransactionChainClosedException(CANNOT_WRITE_INTO_TRANSACTION); } - writeTx.put(store, path, data, createParents); + if (createParents) { + writeTx.mergeParentStructurePut(store, path, data); + } else { + writeTx.put(store, path, data); + } } } @@ -257,7 +261,11 @@ public class TransactionChainManager implements TransactionChainListener, AutoCl throw new TransactionChainClosedException(CANNOT_WRITE_INTO_TRANSACTION); } - writeTx.merge(store, path, data, createParents); + if (createParents) { + writeTx.mergeParentStructureMerge(store, path, data); + } else { + writeTx.merge(store, path, data); + } } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/FlowStatsMultipartWriter.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/FlowStatsMultipartWriter.java index 742af3588c..7695b0eddb 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/FlowStatsMultipartWriter.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/FlowStatsMultipartWriter.java @@ -46,7 +46,7 @@ public class FlowStatsMultipartWriter extends AbstractMultipartWriter { final FlowBuilder flow = new FlowBuilder(stat) .addAugmentation( diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/GroupDescMultipartWriter.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/GroupDescMultipartWriter.java index c1be2a889e..331ba90b63 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/GroupDescMultipartWriter.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/GroupDescMultipartWriter.java @@ -38,7 +38,7 @@ public class GroupDescMultipartWriter extends AbstractMultipartWriter { writeToTransaction( getInstanceIdentifier() diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/GroupStatsMultipartWriter.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/GroupStatsMultipartWriter.java index 80d8446c95..08d5099fb7 100755 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/GroupStatsMultipartWriter.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/GroupStatsMultipartWriter.java @@ -37,7 +37,7 @@ public class GroupStatsMultipartWriter extends AbstractMultipartWriter { writeToTransaction( getInstanceIdentifier() diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/MeterConfigMultipartWriter.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/MeterConfigMultipartWriter.java index ef24c9d0f0..8dba87b2ff 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/MeterConfigMultipartWriter.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/MeterConfigMultipartWriter.java @@ -38,7 +38,7 @@ public class MeterConfigMultipartWriter extends AbstractMultipartWriter { writeToTransaction( getInstanceIdentifier() diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/MeterStatsMultipartWriter.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/MeterStatsMultipartWriter.java index 5abd7850fc..9ae90ba698 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/MeterStatsMultipartWriter.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/MeterStatsMultipartWriter.java @@ -32,7 +32,7 @@ public class MeterStatsMultipartWriter extends AbstractMultipartWriter writeToTransaction( getInstanceIdentifier() .augmentation(FlowCapableNode.class) diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/PortStatsMultipartWriter.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/PortStatsMultipartWriter.java index d7ba87d282..28e9dbdb5c 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/PortStatsMultipartWriter.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/PortStatsMultipartWriter.java @@ -42,7 +42,7 @@ public class PortStatsMultipartWriter extends AbstractMultipartWriter { final OpenflowVersion openflowVersion = OpenflowVersion.get(features.getVersion()); final Uint32 port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(openflowVersion, diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/QueueStatsMultipartWriter.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/QueueStatsMultipartWriter.java index 61eab1453a..9d902e2ac1 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/QueueStatsMultipartWriter.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/QueueStatsMultipartWriter.java @@ -47,7 +47,7 @@ public class QueueStatsMultipartWriter extends AbstractMultipartWriter { final Uint32 port = InventoryDataServiceUtil .portNumberfromNodeConnectorId(openflowVersion, stat.getNodeConnectorId()); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/TableFeaturesMultipartWriter.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/TableFeaturesMultipartWriter.java index f839ac352e..89d21546e2 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/TableFeaturesMultipartWriter.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/TableFeaturesMultipartWriter.java @@ -34,7 +34,7 @@ public class TableFeaturesMultipartWriter extends AbstractMultipartWriter { writeToTransaction(getInstanceIdentifier() .augmentation(FlowCapableNode.class) diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/TableStatsMultipartWriter.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/TableStatsMultipartWriter.java index 95758ab906..9e7adafeaf 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/TableStatsMultipartWriter.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/datastore/multipart/TableStatsMultipartWriter.java @@ -33,7 +33,7 @@ public class TableStatsMultipartWriter extends AbstractMultipartWriter writeToTransaction( getInstanceIdentifier() .augmentation(FlowCapableNode.class) diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java index b9ba548654..80da7d4174 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java @@ -764,9 +764,9 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi if (result != null) { for (Optional optNode : result) { if (optNode.isPresent()) { - flowCount += optNode.get().nonnullTable().stream() + flowCount += optNode.get().nonnullTable().values().stream() .filter(Objects::nonNull) - .flatMap(table -> table.nonnullFlow().stream()) + .flatMap(table -> table.nonnullFlow().values().stream()) .filter(Objects::nonNull) .count(); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java index 4393b96537..f9f4eaac98 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java @@ -216,8 +216,7 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker } @Override - public void onNotAbleToStartMastership(@NonNull final DeviceInfo deviceInfo, @NonNull final String reason, - final boolean mandatory) { + public void onNotAbleToStartMastership(final DeviceInfo deviceInfo, final String reason, final boolean mandatory) { LOG.warn("Not able to set MASTER role on device {}, reason: {}", deviceInfo, reason); if (!mandatory) { @@ -232,8 +231,7 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker } @Override - public void onMasterRoleAcquired(@NonNull final DeviceInfo deviceInfo, - @NonNull final ContextChainMastershipState mastershipState) { + public void onMasterRoleAcquired(final DeviceInfo deviceInfo, final ContextChainMastershipState mastershipState) { Optional.ofNullable(contextChainMap.get(deviceInfo)).ifPresent(contextChain -> { if (!ContextChainMastershipState.INITIAL_SUBMIT.equals(mastershipState)) { if (contextChain.isMastered(mastershipState, true)) { diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/MeterMessageDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/MeterMessageDeserializer.java index e1e0679ef5..f7fcc9641b 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/MeterMessageDeserializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/MeterMessageDeserializer.java @@ -16,6 +16,7 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegi import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId; @@ -27,6 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band. import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand; import org.slf4j.Logger; @@ -51,6 +53,7 @@ public class MeterMessageDeserializer implements OFDeserializer, D .setMeterId(new MeterId(message.readUnsignedInt())); final List bands = new ArrayList<>(); + long key = 0; while (message.readableBytes() > 0) { final MeterBandHeaderBuilder bandBuilder = new MeterBandHeaderBuilder(); @@ -104,7 +107,7 @@ public class MeterMessageDeserializer implements OFDeserializer, D // no operation } - bands.add(bandBuilder.build()); + bands.add(bandBuilder.withKey(new MeterBandHeaderKey(new BandId(key++))).build()); } return builder diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowStatsDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowStatsDeserializer.java index 694ab0beff..8f944e0532 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowStatsDeserializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowStatsDeserializer.java @@ -25,8 +25,10 @@ import org.opendaylight.openflowplugin.impl.protocol.deserialization.util.Instru import org.opendaylight.openflowplugin.impl.util.MatchUtil; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags; @@ -52,6 +54,7 @@ public class MultipartReplyFlowStatsDeserializer implements OFDeserializer items = new ArrayList<>(); + int key = 0; while (message.readableBytes() > 0) { final FlowAndStatisticsMapListBuilder itemBuilder = new FlowAndStatisticsMapListBuilder(); @@ -115,6 +118,7 @@ public class MultipartReplyFlowStatsDeserializer implements OFDeserializer * @param startIndex start index of byte buffer */ protected void writeActions(ActionList actions, short version, ByteBuf outBuffer, int startIndex) { - Optional.ofNullable(actions).flatMap(as -> Optional.ofNullable(as.getAction())).map(as -> { + Optional.ofNullable(actions).flatMap(as -> Optional.ofNullable(as.nonnullAction())).map(as -> { final int lengthIndex = outBuffer.writerIndex(); outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); - as.stream().sorted(OrderComparator.build()).forEach(a -> ActionUtil + as.values().stream().sorted(OrderComparator.build()).forEach(a -> ActionUtil .writeAction(a.getAction(), version, registry, outBuffer)); outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex); return actions; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MatchSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MatchSerializer.java index 8586446f10..ecbffaaf69 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MatchSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MatchSerializer.java @@ -8,8 +8,8 @@ package org.opendaylight.openflowplugin.impl.protocol.serialization.match; import io.netty.buffer.ByteBuf; +import java.util.Collection; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; import java.util.Optional; import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; @@ -43,7 +43,7 @@ public class MatchSerializer implements OFSerializer, HeaderSerializer, HeaderSerializer, HeaderSerializer Optional.ofNullable(extensions.getExtensionList())) - .ifPresent(extensionList -> serializeExtensionList(extensionList, outBuffer)); + .flatMap(extensions -> Optional.ofNullable(extensions.nonnullExtensionList())) + .ifPresent(extensionList -> serializeExtensionList(extensionList.values(), outBuffer)); } - private void serializeExtensionList(final List extensionList, final ByteBuf outBuffer) { + private void serializeExtensionList(final Collection extensionList, final ByteBuf outBuffer) { // TODO: Remove also extension converters extensionList.forEach(extension -> { final ConverterExtensionKey converterExtensionKey = @@ -121,13 +121,14 @@ public class MatchSerializer implements OFSerializer, HeaderSerializer, HeaderSerializer protocol = Optional @@ -191,8 +190,8 @@ public class FlowMessageSerializer extends AbstractMessageSerializer Optional.ofNullable(is.getInstruction())) - .ifPresent(is -> is.stream() + .flatMap(is -> Optional.ofNullable(is.nonnullInstruction())) + .ifPresent(is -> is.values().stream() .filter(Objects::nonNull) .sorted(OrderComparator.build()) .map(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types @@ -214,10 +213,11 @@ public class FlowMessageSerializer extends AbstractMessageSerializer Optional.ofNullable(aa.getAction())) + .flatMap(aa -> Optional.ofNullable(aa.nonnullAction())) .map(as -> new ApplyActionsCaseBuilder() .setApplyActions(new ApplyActionsBuilder() .setAction(as + .values() .stream() .filter(Objects::nonNull) .map(a -> updateSetTpActions(a, protocol)) @@ -276,7 +276,7 @@ public class FlowMessageSerializer extends AbstractMessageSerializer updateSetVlanIdAction(final FlowMessage message) { - return message.getInstructions().getInstruction() + return message.getInstructions().nonnullInstruction().values() .stream() .map(i -> { final int[] offset = {0}; @@ -284,8 +284,8 @@ public class FlowMessageSerializer extends AbstractMessageSerializer Optional.ofNullable(as.getAction())) - .map(a -> a.stream() + .flatMap(as -> Optional.ofNullable(as.nonnullAction())) + .map(a -> a.values().stream() .sorted(OrderComparator.build()) .flatMap(action -> { final List 0 ? new ActionBuilder(action).setOrder(action.getOrder() + offset[0]) + .withKey(new ActionKey(action.getOrder() + offset[0])) .build() : action); @@ -374,16 +375,16 @@ public class FlowMessageSerializer extends AbstractMessageSerializer Optional.ofNullable(is.getInstruction())) - .flatMap(is -> is.stream() + .flatMap(is -> Optional.ofNullable(is.nonnullInstruction())) + .flatMap(is -> is.values().stream() .map(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types .rev131026.Instruction::getInstruction) .filter(ApplyActionsCase.class::isInstance) .map(i -> ((ApplyActionsCase) i).getApplyActions()) .filter(Objects::nonNull) - .map(ActionList::getAction) + .map(ActionList::nonnullAction) .filter(Objects::nonNull) - .flatMap(Collection::stream) + .flatMap(map -> map.values().stream()) .map(Action::getAction) .filter(SetVlanIdActionCase.class::isInstance) .findFirst()) diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/GroupMessageSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/GroupMessageSerializer.java index 6593c307dc..f46b3da8df 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/GroupMessageSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/GroupMessageSerializer.java @@ -66,8 +66,8 @@ public class GroupMessageSerializer extends AbstractMessageSerializer !GroupModCommand.OFPGCDELETE.equals(message.getCommand())) - .flatMap(b -> Optional.ofNullable(b.getBucket())) - .ifPresent(b -> b.stream() + .flatMap(b -> Optional.ofNullable(b.nonnullBucket())) + .ifPresent(b -> b.values().stream() .sorted(COMPARATOR) .forEach(bucket -> { final int bucketIndex = outBuffer.writerIndex(); @@ -79,7 +79,7 @@ public class GroupMessageSerializer extends AbstractMessageSerializer as + Optional.ofNullable(bucket.nonnullAction()).ifPresent(as -> as.values() .stream() .sorted(OrderComparator.build()) .forEach(a -> ActionUtil.writeAction( diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/MeterMessageSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/MeterMessageSerializer.java index bcf92cbbed..8b44016902 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/MeterMessageSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/MeterMessageSerializer.java @@ -58,7 +58,7 @@ public class MeterMessageSerializer extends AbstractMessageSerializer + meterBandHeaders.nonnullMeterBandHeader().values().forEach(meterBandHeader -> Optional.ofNullable(meterBandHeader.getMeterBandTypes()) .flatMap(m -> Optional.ofNullable(m.getFlags())) .ifPresent(flags -> Optional.ofNullable(meterBandHeader.getBandType()).ifPresent(type -> { diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializer.java index 3939f8a14e..66b4c50322 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestTableFeaturesSerializer.java @@ -32,8 +32,8 @@ public class MultipartRequestTableFeaturesSerializer implements OFSerializer tableFeatures + .ofNullable(multipartRequestTableFeatures.nonnullTableFeatures()) + .ifPresent(tableFeatures -> tableFeatures.values() .stream() .filter(Objects::nonNull) .forEach(tableFeature -> { @@ -56,8 +56,8 @@ public class MultipartRequestTableFeaturesSerializer implements OFSerializer Optional.ofNullable(properties.getTableFeatureProperties())) - .ifPresent(properties -> properties + .flatMap(properties -> Optional.ofNullable(properties.nonnullTableFeatureProperties())) + .ifPresent(properties -> properties.values() .stream() .filter(Objects::nonNull) .forEach(property -> { diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsMissTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsMissTablePropertySerializer.java index 2396950218..52734f8e5c 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsMissTablePropertySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsMissTablePropertySerializer.java @@ -27,7 +27,7 @@ public class ApplyActionsMissTablePropertySerializer extends protected void serializeProperty(final ApplyActionsMiss property, final ByteBuf byteBuf) { property .getApplyActionsMiss() - .getAction() + .nonnullAction().values() .stream() .sorted(OrderComparator.build()) .map(Action::getAction) diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsTablePropertySerializer.java index 796fee6b91..2bda2d9eba 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsTablePropertySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplyActionsTablePropertySerializer.java @@ -27,7 +27,8 @@ public class ApplyActionsTablePropertySerializer extends AbstractTablePropertySe protected void serializeProperty(final ApplyActions property, final ByteBuf byteBuf) { property .getApplyActions() - .getAction() + .nonnullAction() + .values() .stream() .sorted(OrderComparator.build()) .map(Action::getAction) diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldMissTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldMissTablePropertySerializer.java index 8d79ffcea8..22a51ec358 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldMissTablePropertySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldMissTablePropertySerializer.java @@ -29,7 +29,7 @@ public class ApplySetfieldMissTablePropertySerializer extends protected void serializeProperty(final ApplySetfieldMiss property, final ByteBuf byteBuf) { property .getApplySetfieldMiss() - .getSetFieldMatch() + .nonnullSetFieldMatch().values() .forEach(setFieldMatch -> Preconditions.checkNotNull(registry) .>getSerializer( new MessageTypeKey<>( diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldTablePropertySerializer.java index 0d09e54b5c..0ce17c1d8a 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldTablePropertySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/ApplySetfieldTablePropertySerializer.java @@ -29,7 +29,7 @@ public class ApplySetfieldTablePropertySerializer extends AbstractTablePropertyS protected void serializeProperty(final ApplySetfield property, final ByteBuf byteBuf) { property .getApplySetfield() - .getSetFieldMatch() + .nonnullSetFieldMatch().values() .forEach(setFieldMatch -> Preconditions.checkNotNull(registry) .>getSerializer( new MessageTypeKey<>( diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsMissTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsMissTablePropertySerializer.java index ad855a0d96..6c97371bc5 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsMissTablePropertySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsMissTablePropertySerializer.java @@ -27,8 +27,8 @@ public class InstructionsMissTablePropertySerializer extends protected void serializeProperty(final InstructionsMiss property, final ByteBuf byteBuf) { property .getInstructionsMiss() - .getInstruction() - .stream() + .nonnullInstruction() + .values().stream() .sorted(OrderComparator.build()) .map(Instruction::getInstruction) .forEach(instruction -> InstructionUtil diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsTablePropertySerializer.java index b4ed106ce1..cf900fb058 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsTablePropertySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/InstructionsTablePropertySerializer.java @@ -27,7 +27,7 @@ public class InstructionsTablePropertySerializer extends AbstractTablePropertySe protected void serializeProperty(final Instructions property, final ByteBuf byteBuf) { property .getInstructions() - .getInstruction() + .nonnullInstruction().values() .stream() .sorted(OrderComparator.build()) .map(Instruction::getInstruction) diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/MatchTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/MatchTablePropertySerializer.java index 55de662876..cf7072137c 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/MatchTablePropertySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/MatchTablePropertySerializer.java @@ -29,7 +29,7 @@ public class MatchTablePropertySerializer extends AbstractTablePropertySerialize protected void serializeProperty(final Match property, final ByteBuf byteBuf) { property .getMatchSetfield() - .getSetFieldMatch() + .nonnullSetFieldMatch().values() .forEach(setFieldMatch -> Preconditions.checkNotNull(registry) .>getSerializer( new MessageTypeKey<>( diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WildcardsTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WildcardsTablePropertySerializer.java index f7f24aa1de..88c01dd3bb 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WildcardsTablePropertySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WildcardsTablePropertySerializer.java @@ -29,7 +29,7 @@ public class WildcardsTablePropertySerializer extends AbstractTablePropertySeria protected void serializeProperty(final Wildcards property, final ByteBuf byteBuf) { property .getWildcardSetfield() - .getSetFieldMatch() + .nonnullSetFieldMatch().values() .forEach(setFieldMatch -> Preconditions.checkNotNull(registry) .>getSerializer( new MessageTypeKey<>( diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsMissTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsMissTablePropertySerializer.java index 437aadbc36..30bd3d874b 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsMissTablePropertySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsMissTablePropertySerializer.java @@ -27,7 +27,7 @@ public class WriteActionsMissTablePropertySerializer extends protected void serializeProperty(final WriteActionsMiss property, final ByteBuf byteBuf) { property .getWriteActionsMiss() - .getAction() + .nonnullAction().values() .stream() .sorted(OrderComparator.build()) .map(Action::getAction) diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsTablePropertySerializer.java index 5b9d2f3c9c..f990fba6ce 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsTablePropertySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteActionsTablePropertySerializer.java @@ -27,7 +27,8 @@ public class WriteActionsTablePropertySerializer extends AbstractTablePropertySe protected void serializeProperty(final WriteActions property, final ByteBuf byteBuf) { property .getWriteActions() - .getAction() + .nonnullAction() + .values() .stream() .sorted(OrderComparator.build()) .map(Action::getAction) diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldMissTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldMissTablePropertySerializer.java index 02f7e34e81..ce8d2bee75 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldMissTablePropertySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldMissTablePropertySerializer.java @@ -29,7 +29,7 @@ public class WriteSetfieldMissTablePropertySerializer extends protected void serializeProperty(final WriteSetfieldMiss property, final ByteBuf byteBuf) { property .getWriteSetfieldMiss() - .getSetFieldMatch() + .nonnullSetFieldMatch().values() .forEach(setFieldMatch -> Preconditions.checkNotNull(registry) .>getSerializer( new MessageTypeKey<>( diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldTablePropertySerializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldTablePropertySerializer.java index fe571b6200..d69e7a0805 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldTablePropertySerializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/tablefeatures/WriteSetfieldTablePropertySerializer.java @@ -29,7 +29,7 @@ public class WriteSetfieldTablePropertySerializer extends AbstractTablePropertyS protected void serializeProperty(final WriteSetfield property, final ByteBuf byteBuf) { property .getWriteSetfield() - .getSetFieldMatch() + .nonnullSetFieldMatch().values() .forEach(setFieldMatch -> Preconditions.checkNotNull(registry) .>getSerializer( new MessageTypeKey<>( diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java index a71a738ecc..0fee0d39aa 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImpl.java @@ -116,9 +116,9 @@ public class DeviceFlowRegistryImpl implements DeviceFlowRegistry { @Override public void onSuccess(final Optional result) { result.ifPresent(flowCapableNode -> { - flowCapableNode.nonnullTable().stream() + flowCapableNode.nonnullTable().values().stream() .filter(Objects::nonNull) - .flatMap(table -> table.nonnullFlow().stream()) + .flatMap(table -> table.nonnullFlow().values().stream()) .filter(Objects::nonNull) .filter(flow -> flow.getId() != null) .forEach(flowConsumer); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java index 05f18c2396..f796080517 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactory.java @@ -122,8 +122,8 @@ public final class FlowRegistryKeyFactory { if (!Objects.equals(match.getVlanMatch(), input.getVlanMatch())) { return false; } - for (ExtensionList inputExtensionList : inputAug.getExtensionList()) { - if (!thisAug.getExtensionList().contains(inputExtensionList)) { + for (ExtensionList inputExtensionList : inputAug.nonnullExtensionList().values()) { + if (!thisAug.nonnullExtensionList().containsValue(inputExtensionList)) { return false; } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallback.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallback.java index a146d8bda3..0181afee89 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallback.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallback.java @@ -28,7 +28,7 @@ public abstract class AbstractRequestCallback implements FutureCallback context; private final Class requestType; private final MessageSpy spy; - private EventIdentifier eventIdentifier; + private final EventIdentifier eventIdentifier; AbstractRequestCallback(final RequestContext context, final Class requestType, @@ -54,7 +54,7 @@ public abstract class AbstractRequestCallback implements FutureCallback builder; if (null != eventIdentifier) { EventsTimeCounter.markEnd(eventIdentifier); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdapters.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdapters.java index 943d61a556..ef734d242f 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdapters.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdapters.java @@ -141,7 +141,7 @@ public final class FlatBatchFlowAdapters { final RpcResult input, final int stepOffset) { final List batchFailures = new ArrayList<>(); if (input.getResult().getBatchFailedFlowsOutput() != null) { - for (BatchFailedFlowsOutput stepOutput : input.getResult().getBatchFailedFlowsOutput()) { + for (BatchFailedFlowsOutput stepOutput : input.getResult().nonnullBatchFailedFlowsOutput().values()) { final BatchFailure batchFailure = new BatchFailureBuilder() .setBatchOrder(stepOffset + stepOutput.getBatchOrder().toJava()) .setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder() diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdapters.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdapters.java index 90d4c6805a..5ea9999fac 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdapters.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdapters.java @@ -140,7 +140,7 @@ public final class FlatBatchGroupAdapters { final RpcResult input, final int stepOffset) { final List batchFailures = new ArrayList<>(); if (input.getResult().getBatchFailedGroupsOutput() != null) { - for (BatchFailedGroupsOutput stepOutput : input.getResult().getBatchFailedGroupsOutput()) { + for (BatchFailedGroupsOutput stepOutput : input.getResult().nonnullBatchFailedGroupsOutput().values()) { final BatchFailure batchFailure = new BatchFailureBuilder() .setBatchOrder(stepOffset + stepOutput.getBatchOrder().toJava()) .setBatchItemIdChoice(new FlatBatchFailureGroupIdCaseBuilder() diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdapters.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdapters.java index f679823eda..85fdacfd9f 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdapters.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdapters.java @@ -140,7 +140,7 @@ public final class FlatBatchMeterAdapters { final RpcResult input, final int stepOffset) { final List batchFailures = new ArrayList<>(); if (input.getResult().getBatchFailedMetersOutput() != null) { - for (BatchFailedMetersOutput stepOutput : input.getResult().getBatchFailedMetersOutput()) { + for (BatchFailedMetersOutput stepOutput : input.getResult().nonnullBatchFailedMetersOutput().values()) { final BatchFailure batchFailure = new BatchFailureBuilder() .setBatchOrder(stepOffset + stepOutput.getBatchOrder().toJava()) .setBatchItemIdChoice(new FlatBatchFailureMeterIdCaseBuilder() diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImpl.java index f4e0c4be80..f61665e406 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImpl.java @@ -78,7 +78,7 @@ public class SalFlatBatchServiceImpl implements SalFlatBatchService { PathUtil.extractNodeId(input.getNode()).getValue(), input.getBatch().size()); // create plan - final List batchPlan = FlatBatchUtil.assembleBatchPlan(input.getBatch()); + final List batchPlan = FlatBatchUtil.assembleBatchPlan(input.nonnullBatch().values()); // add barriers where needed FlatBatchUtil.markBarriersWhereNeeded(batchPlan); // prepare chain elements diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImpl.java index cbc28902ed..40245358f9 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImpl.java @@ -70,7 +70,7 @@ public class SalFlowsBatchServiceImpl implements SalFlowsBatchService { PathUtil.extractNodeId(input.getNode()), input.getBatchRemoveFlows().size()); final ArrayList>> resultsLot = new ArrayList<>(); - for (BatchFlowInputGrouping batchFlow : input.getBatchRemoveFlows()) { + for (BatchFlowInputGrouping batchFlow : input.nonnullBatchRemoveFlows().values()) { final RemoveFlowInput removeFlowInput = new RemoveFlowInputBuilder(batchFlow) .setFlowRef(createFlowRef(input.getNode(), batchFlow)) .setNode(input.getNode()) @@ -80,7 +80,7 @@ public class SalFlowsBatchServiceImpl implements SalFlowsBatchService { final ListenableFuture>> commonResult = Futures.transform(Futures.successfulAsList(resultsLot), - FlowUtil.createCumulatingFunction(input.getBatchRemoveFlows()), + FlowUtil.createCumulatingFunction(input.nonnullBatchRemoveFlows().values()), MoreExecutors.directExecutor()); ListenableFuture> removeFlowsBulkFuture = @@ -98,7 +98,7 @@ public class SalFlowsBatchServiceImpl implements SalFlowsBatchService { public ListenableFuture> addFlowsBatch(final AddFlowsBatchInput input) { LOG.trace("Adding flows @ {} : {}", PathUtil.extractNodeId(input.getNode()), input.getBatchAddFlows().size()); final ArrayList>> resultsLot = new ArrayList<>(); - for (BatchFlowInputGrouping batchFlow : input.getBatchAddFlows()) { + for (BatchFlowInputGrouping batchFlow : input.nonnullBatchAddFlows().values()) { final AddFlowInput addFlowInput = new AddFlowInputBuilder(batchFlow) .setFlowRef(createFlowRef(input.getNode(), batchFlow)) .setNode(input.getNode()) @@ -108,7 +108,7 @@ public class SalFlowsBatchServiceImpl implements SalFlowsBatchService { final ListenableFuture>> commonResult = Futures.transform(Futures.successfulAsList(resultsLot), - FlowUtil.createCumulatingFunction(input.getBatchAddFlows()), + FlowUtil.createCumulatingFunction(input.nonnullBatchAddFlows().values()), MoreExecutors.directExecutor()); ListenableFuture> addFlowsBulkFuture = @@ -138,7 +138,7 @@ public class SalFlowsBatchServiceImpl implements SalFlowsBatchService { PathUtil.extractNodeId(input.getNode()), input.getBatchUpdateFlows().size()); final ArrayList>> resultsLot = new ArrayList<>(); - for (BatchUpdateFlows batchFlow : input.getBatchUpdateFlows()) { + for (BatchUpdateFlows batchFlow : input.nonnullBatchUpdateFlows().values()) { final UpdateFlowInput updateFlowInput = new UpdateFlowInputBuilder(input) .setOriginalFlow(new OriginalFlowBuilder(batchFlow.getOriginalBatchedFlow()).build()) .setUpdatedFlow(new UpdatedFlowBuilder(batchFlow.getUpdatedBatchedFlow()).build()) @@ -150,7 +150,7 @@ public class SalFlowsBatchServiceImpl implements SalFlowsBatchService { final ListenableFuture>> commonResult = Futures.transform(Futures.successfulAsList(resultsLot), - FlowUtil.createCumulatingFunction(input.getBatchUpdateFlows()), + FlowUtil.createCumulatingFunction(input.nonnullBatchUpdateFlows().values()), MoreExecutors.directExecutor()); ListenableFuture> updateFlowsBulkFuture = diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImpl.java index fcfd26c788..7cf3c4dc0e 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImpl.java @@ -106,7 +106,7 @@ public class SalGroupsBatchServiceImpl implements SalGroupsBatchService { public ListenableFuture> addGroupsBatch(final AddGroupsBatchInput input) { LOG.trace("Adding groups @ {} : {}", PathUtil.extractNodeId(input.getNode()), input.getBatchAddGroups().size()); final ArrayList>> resultsLot = new ArrayList<>(); - for (BatchAddGroups addGroup : input.getBatchAddGroups()) { + for (BatchAddGroups addGroup : input.nonnullBatchAddGroups().values()) { final AddGroupInput addGroupInput = new AddGroupInputBuilder(addGroup) .setGroupRef(createGroupRef(input.getNode(), addGroup)).setNode(input.getNode()).build(); resultsLot.add(salGroupService.addGroup(addGroupInput)); @@ -114,7 +114,7 @@ public class SalGroupsBatchServiceImpl implements SalGroupsBatchService { final ListenableFuture>> commonResult = Futures .transform(Futures.allAsList(resultsLot), - GroupUtil.createCumulatingFunction(input.getBatchAddGroups()), + GroupUtil.createCumulatingFunction(input.nonnullBatchAddGroups().values()), MoreExecutors.directExecutor()); ListenableFuture> addGroupsBulkFuture = Futures @@ -133,7 +133,7 @@ public class SalGroupsBatchServiceImpl implements SalGroupsBatchService { LOG.trace("Removing groups @ {} : {}", PathUtil.extractNodeId(input.getNode()), input.getBatchRemoveGroups().size()); final ArrayList>> resultsLot = new ArrayList<>(); - for (BatchRemoveGroups addGroup : input.getBatchRemoveGroups()) { + for (BatchRemoveGroups addGroup : input.nonnullBatchRemoveGroups().values()) { final RemoveGroupInput removeGroupInput = new RemoveGroupInputBuilder(addGroup) .setGroupRef(createGroupRef(input.getNode(), addGroup)).setNode(input.getNode()).build(); resultsLot.add(salGroupService.removeGroup(removeGroupInput)); @@ -141,7 +141,7 @@ public class SalGroupsBatchServiceImpl implements SalGroupsBatchService { final ListenableFuture>> commonResult = Futures .transform(Futures.allAsList(resultsLot), - GroupUtil.createCumulatingFunction(input.getBatchRemoveGroups()), + GroupUtil.createCumulatingFunction(input.nonnullBatchRemoveGroups().values()), MoreExecutors.directExecutor()); ListenableFuture> removeGroupsBulkFuture = Futures diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImpl.java index 90e83399ba..174cb4db77 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImpl.java @@ -108,7 +108,7 @@ public class SalMetersBatchServiceImpl implements SalMetersBatchService { public ListenableFuture> addMetersBatch(final AddMetersBatchInput input) { LOG.trace("Adding meters @ {} : {}", PathUtil.extractNodeId(input.getNode()), input.getBatchAddMeters().size()); final ArrayList>> resultsLot = new ArrayList<>(); - for (BatchAddMeters addMeter : input.getBatchAddMeters()) { + for (BatchAddMeters addMeter : input.nonnullBatchAddMeters().values()) { final AddMeterInput addMeterInput = new AddMeterInputBuilder(addMeter) .setMeterRef(createMeterRef(input.getNode(), addMeter)) .setNode(input.getNode()) @@ -118,7 +118,7 @@ public class SalMetersBatchServiceImpl implements SalMetersBatchService { final ListenableFuture>> commonResult = Futures.transform(Futures.allAsList(resultsLot), - MeterUtil.createCumulativeFunction(input.getBatchAddMeters()), + MeterUtil.createCumulativeFunction(input.nonnullBatchAddMeters().values()), MoreExecutors.directExecutor()); ListenableFuture> addMetersBulkFuture = @@ -138,7 +138,7 @@ public class SalMetersBatchServiceImpl implements SalMetersBatchService { PathUtil.extractNodeId(input.getNode()), input.getBatchRemoveMeters().size()); final ArrayList>> resultsLot = new ArrayList<>(); - for (BatchRemoveMeters addMeter : input.getBatchRemoveMeters()) { + for (BatchRemoveMeters addMeter : input.nonnullBatchRemoveMeters().values()) { final RemoveMeterInput removeMeterInput = new RemoveMeterInputBuilder(addMeter) .setMeterRef(createMeterRef(input.getNode(), addMeter)) .setNode(input.getNode()) @@ -148,7 +148,7 @@ public class SalMetersBatchServiceImpl implements SalMetersBatchService { final ListenableFuture>> commonResult = Futures.transform(Futures.allAsList(resultsLot), - MeterUtil.createCumulativeFunction(input.getBatchRemoveMeters()), + MeterUtil.createCumulativeFunction(input.nonnullBatchRemoveMeters().values()), MoreExecutors.directExecutor()); ListenableFuture> removeMetersBulkFuture = diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalPortServiceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalPortServiceImpl.java index 1f6a6e2ac9..975389fdf4 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalPortServiceImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalPortServiceImpl.java @@ -61,6 +61,6 @@ public final class SalPortServiceImpl } private Port getPortFromInput(final UpdatePortInput input) { - return input.getUpdatedPort().getPort().getPort().get(0); + return input.getUpdatedPort().getPort().nonnullPort().values().iterator().next(); } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java index fe4fbb99fd..32df00eb9a 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartService.java @@ -86,7 +86,7 @@ public class SingleLayerTableMultipartService extends AbstractTableMultipartServ .map(MultipartReply::getMultipartReplyBody) .filter(MultipartReplyTableFeatures.class::isInstance) .flatMap(multipartReplyBody -> ((MultipartReplyTableFeatures) multipartReplyBody) - .getTableFeatures() + .nonnullTableFeatures().values() .stream()) .collect(Collectors.toList())); } catch (Exception e) { diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java index 5296890d2c..5d62f7209e 100755 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java @@ -184,7 +184,7 @@ public final class StatisticsGatheringUtils { // we have to read actual tables with all information before we set empty Flow list, // merge is expensive and not applicable for lists if (flowCapNodeOpt != null && flowCapNodeOpt.isPresent()) { - for (final Table tableData : flowCapNodeOpt.get().getTable()) { + for (final Table tableData : flowCapNodeOpt.get().nonnullTable().values()) { final Table table = new TableBuilder(tableData).setFlow(Collections.emptyList()).build(); final InstanceIdentifier
iiToTable = instanceIdentifier .child(Table.class, tableData.key()); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/ofpspecific/MessageIntelligenceAgencyImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/ofpspecific/MessageIntelligenceAgencyImpl.java index f14fc41f48..9e7cd4383a 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/ofpspecific/MessageIntelligenceAgencyImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/ofpspecific/MessageIntelligenceAgencyImpl.java @@ -16,7 +16,6 @@ import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicLongFieldUpdater; -import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageIntelligenceAgency; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,7 +55,7 @@ public class MessageIntelligenceAgencyImpl implements MessageIntelligenceAgency, new ConcurrentHashMap<>(); @Override - public void spyMessage(@NonNull final Class message, final StatisticsGroup statGroup) { + public void spyMessage(final Class message, final StatisticsGroup statGroup) { Preconditions.checkNotNull(message, "Message can't be null."); getCounters(message, statGroup).increment(); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterConfigStatsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterConfigStatsService.java index 8cc7ceeb48..c3ef683e87 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterConfigStatsService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllMeterConfigStatsService.java @@ -7,10 +7,14 @@ */ package org.opendaylight.openflowplugin.impl.statistics.services; +import com.google.common.collect.Lists; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; import org.opendaylight.openflowjava.protocol.api.util.BinContent; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; @@ -97,7 +101,15 @@ final class AllMeterConfigStatsService final Optional> meterConfigStatsList = convertorExecutor.convert(replyBody.getMeterConfig(), data); - meterConfigStatsList.ifPresent(meterConfigStats -> message.getMeterConfigStats().addAll(meterConfigStats)); + meterConfigStatsList.ifPresent(meterConfigStats -> { + if (message.getMeterConfigStats() == null) { + message.setMeterConfigStats(Lists.newArrayList(meterConfigStats)); + } else { + Set stats = new HashSet<>(message.getMeterConfigStats().values()); + stats.addAll(meterConfigStats); + message.setMeterConfigStats(stats.stream().collect(Collectors.toList())); + } + }); } return message.build(); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupDescriptionService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupDescriptionService.java index bd95ee2ddb..47b0dc5510 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupDescriptionService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/GroupDescriptionService.java @@ -7,10 +7,14 @@ */ package org.opendaylight.openflowplugin.impl.statistics.services; +import com.google.common.collect.Lists; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack; import org.opendaylight.openflowplugin.api.openflow.device.Xid; @@ -79,7 +83,18 @@ final class GroupDescriptionService final Optional> groupDescStatsList = convertorExecutor.convert( replyBody.getGroupDesc(), data); - groupDescStatsList.ifPresent(groupDescStats -> notification.getGroupDescStats().addAll(groupDescStats)); + groupDescStatsList.ifPresent(groupDescStats -> { + if (notification.getGroupDescStats() == null) { + List stats = Lists.newArrayList(groupDescStats); + notification.setGroupDescStats(stats); + } else { + Set stats = new HashSet<>(notification.getGroupDescStats().values()); + stats.addAll(groupDescStats); + notification.setGroupDescStats(stats.stream().collect(Collectors.toList())); + } + }); + + } return notification.build(); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/GroupStatisticsToNotificationTransformer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/GroupStatisticsToNotificationTransformer.java index ed4c31cced..147c738b27 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/GroupStatisticsToNotificationTransformer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/GroupStatisticsToNotificationTransformer.java @@ -8,9 +8,13 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility; +import com.google.common.collect.Lists; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData; @@ -58,7 +62,16 @@ public final class GroupStatisticsToNotificationTransformer { final Optional> groupStatsList = convertorExecutor.convert( replyBody.getGroupStats(), data); - groupStatsList.ifPresent(groupStats -> notification.getGroupStats().addAll(groupStats)); + groupStatsList.ifPresent(groupStats -> { + if (notification.getGroupStats() == null) { + List stats = Lists.newArrayList(groupStats); + notification.setGroupStats(stats); + } else { + Set stats = new HashSet<>(notification.getGroupStats().values()); + stats.addAll(groupStats); + notification.setGroupStats(stats.stream().collect(Collectors.toList())); + } + }); } return notification.build(); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/MeterStatisticsToNotificationTransformer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/MeterStatisticsToNotificationTransformer.java index 3b40c01316..de3788bb93 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/MeterStatisticsToNotificationTransformer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/MeterStatisticsToNotificationTransformer.java @@ -8,9 +8,13 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility; +import com.google.common.collect.Lists; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor; @@ -61,7 +65,15 @@ public final class MeterStatisticsToNotificationTransformer { final Optional> meterStatsList = convertorExecutor.convert(replyBody.getMeterStats(), data); - meterStatsList.ifPresent(meterStats -> notification.getMeterStats().addAll(meterStats)); + meterStatsList.ifPresent(meterStats -> { + if (notification.getMeterStats() == null) { + notification.setMeterStats(Lists.newArrayList(meterStats)); + } else { + Set stats = new HashSet<>(notification.getMeterStats().values()); + stats.addAll(meterStats); + notification.setMeterStats(stats.stream().collect(Collectors.toList())); + } + }); } return notification.build(); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/NodeConnectorStatisticsToNotificationTransformer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/NodeConnectorStatisticsToNotificationTransformer.java index a4a8605580..f1adb5798d 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/NodeConnectorStatisticsToNotificationTransformer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/NodeConnectorStatisticsToNotificationTransformer.java @@ -9,8 +9,12 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility; import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.Lists; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil; @@ -25,6 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdateBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey; @@ -65,7 +70,15 @@ public final class NodeConnectorStatisticsToNotificationTransformer { for (PortStats portStats : replyBody.getPortStats()) { NodeConnectorStatisticsAndPortNumberMapBuilder statsBuilder = processSingleNodeConnectorStats(deviceInfo, ofVersion, portStats); - notification.getNodeConnectorStatisticsAndPortNumberMap().add(statsBuilder.build()); + if (notification.getNodeConnectorStatisticsAndPortNumberMap() != null) { + Set stats + = new HashSet<>(notification.getNodeConnectorStatisticsAndPortNumberMap().values()); + stats.add(statsBuilder.build()); + notification.setNodeConnectorStatisticsAndPortNumberMap( + stats.stream().collect(Collectors.toList())); + } else { + notification.setNodeConnectorStatisticsAndPortNumberMap(Lists.newArrayList(statsBuilder.build())); + } } } return notification.build(); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/QueueStatisticsToNotificationTransformer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/QueueStatisticsToNotificationTransformer.java index 160e9d345b..4e118f93b2 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/QueueStatisticsToNotificationTransformer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/compatibility/QueueStatisticsToNotificationTransformer.java @@ -8,8 +8,12 @@ package org.opendaylight.openflowplugin.impl.statistics.services.compatibility; +import com.google.common.collect.Lists; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil; @@ -24,6 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdate; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdateBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder; /** @@ -79,7 +84,14 @@ public final class QueueStatisticsToNotificationTransformer { statsBuilder.setQueueId(new QueueId(queueStats.getQueueId())); - notification.getQueueIdAndStatisticsMap().add(statsBuilder.build()); + if (notification.getQueueIdAndStatisticsMap() == null) { + notification.setQueueIdAndStatisticsMap(Lists.newArrayList(statsBuilder.build())); + } else { + Set stats + = new HashSet<>(notification.getQueueIdAndStatisticsMap().values()); + stats.add(statsBuilder.build()); + notification.setQueueIdAndStatisticsMap(stats.stream().collect(Collectors.toList())); + } } } return notification.build(); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsService.java index 1a0303317d..27271d4429 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsService.java @@ -44,7 +44,7 @@ public class FlowDirectStatisticsService extends AbstractFlowDirectStatisticsSer .setFlowAndStatisticsMapList(input .stream() .flatMap(multipartReply -> ((MultipartReplyFlowStats) multipartReply.getMultipartReplyBody()) - .getFlowAndStatisticsMapList() + .nonnullFlowAndStatisticsMapList().values() .stream()) .map(flowAndStatisticsMapList -> { final FlowId flowId = new FlowId(generateFlowId(flowAndStatisticsMapList)); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsService.java index 8dafbd6b8c..d8be05856f 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsService.java @@ -40,7 +40,7 @@ public class GroupDirectStatisticsService extends AbstractGroupDirectStatisticsS .setGroupStats(input .stream() .flatMap(multipartReply -> ((MultipartReplyGroupStats) multipartReply.getMultipartReplyBody()) - .getGroupStats() + .nonnullGroupStats().values() .stream()) .collect(Collectors.toList())) .build(); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsService.java index c0193904cd..d12461f374 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsService.java @@ -40,7 +40,7 @@ public class MeterDirectStatisticsService extends AbstractMeterDirectStatisticsS .setMeterStats(input .stream() .flatMap(multipartReply -> ((MultipartReplyMeterStats) multipartReply.getMultipartReplyBody()) - .getMeterStats() + .nonnullMeterStats().values() .stream()) .collect(Collectors.toList())) .build(); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/PortDirectStatisticsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/PortDirectStatisticsService.java index 52b2bc7522..6f12bcc603 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/PortDirectStatisticsService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/PortDirectStatisticsService.java @@ -40,8 +40,8 @@ public class PortDirectStatisticsService extends AbstractPortDirectStatisticsSer .setNodeConnectorStatisticsAndPortNumberMap(input .stream() .flatMap(multipartReply -> ((MultipartReplyPortStats) multipartReply.getMultipartReplyBody()) - .getNodeConnectorStatisticsAndPortNumberMap() - .stream()) + .nonnullNodeConnectorStatisticsAndPortNumberMap() + .values().stream()) .collect(Collectors.toList())) .build(); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsService.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsService.java index a3e09bebee..e8e118723d 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsService.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsService.java @@ -40,7 +40,7 @@ public class QueueDirectStatisticsService extends AbstractQueueDirectStatisticsS .setQueueIdAndStatisticsMap(input .stream() .flatMap(multipartReply -> ((MultipartReplyQueueStats) multipartReply.getMultipartReplyBody()) - .getQueueIdAndStatisticsMap() + .nonnullQueueIdAndStatisticsMap().values() .stream()) .collect(Collectors.toList())) .build(); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslator.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslator.java index 6d32df52a3..9fee75d23e 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslator.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslator.java @@ -88,9 +88,8 @@ public class PacketReceivedTranslator implements MessageTranslator - matchExtensionWrap = MatchExtensionHelper - .processAllExtensions(input.getMatch().getMatchEntry(), OpenflowVersion.get(input.getVersion()), - MatchPath.PACKET_RECEIVED_MATCH); + matchExtensionWrap = MatchExtensionHelper.processAllExtensions(input.getMatch().nonnullMatchEntry(), + OpenflowVersion.get(input.getVersion()), MatchPath.PACKET_RECEIVED_MATCH); if (matchExtensionWrap != null) { matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(), diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/AddressNormalizationUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/AddressNormalizationUtil.java index 15681a1a6f..70a1c95546 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/AddressNormalizationUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/AddressNormalizationUtil.java @@ -47,8 +47,7 @@ public final class AddressNormalizationUtil { * @param protocolVersion the OpenFLow protocol version * @return normalized uri */ - @Nullable - public static Uri normalizeProtocolAgnosticPort(@Nullable final Uri port, final short protocolVersion) { + public static @Nullable Uri normalizeProtocolAgnosticPort(@Nullable final Uri port, final short protocolVersion) { if (port == null) { return null; } @@ -65,8 +64,7 @@ public final class AddressNormalizationUtil { * @param ipv6Prefix the Ipv6 prefix * @return normalized Ipv6 prefix */ - @Nullable - public static Ipv6Prefix normalizeIpv6Prefix(@Nullable final Ipv6Prefix ipv6Prefix) { + public static @Nullable Ipv6Prefix normalizeIpv6Prefix(@Nullable final Ipv6Prefix ipv6Prefix) { if (ipv6Prefix == null) { return null; } @@ -84,9 +82,8 @@ public final class AddressNormalizationUtil { * @param ipv4Mask the Ipv4 mask * @return normalized Ipv6 prefix */ - @Nullable - public static Ipv6Prefix normalizeIpv6Arbitrary(@Nullable final Ipv6Address ipv6Address, - @Nullable final Ipv6ArbitraryMask ipv4Mask) { + public static @Nullable Ipv6Prefix normalizeIpv6Arbitrary(@Nullable final Ipv6Address ipv6Address, + @Nullable final Ipv6ArbitraryMask ipv4Mask) { if (ipv6Address == null) { return null; } @@ -102,8 +99,7 @@ public final class AddressNormalizationUtil { * @param ipv6Address the Ipv6 address * @return normalized Ipv6 address */ - @Nullable - public static Ipv6Address normalizeIpv6AddressWithoutMask(@Nullable final Ipv6Address ipv6Address) { + public static @Nullable Ipv6Address normalizeIpv6AddressWithoutMask(@Nullable final Ipv6Address ipv6Address) { final Ipv6Prefix ipv6Prefix = normalizeIpv6Arbitrary(ipv6Address, null); return ipv6Prefix == null ? null : new Ipv6Address(ipv6Prefix.getValue().split(PREFIX_SEPARATOR)[0]); } @@ -114,8 +110,7 @@ public final class AddressNormalizationUtil { * @param ipv4Prefix the Ipv4 prefix * @return normalized Ipv4 prefix */ - @Nullable - public static Ipv4Prefix normalizeIpv4Prefix(@Nullable final Ipv4Prefix ipv4Prefix) { + public static @Nullable Ipv4Prefix normalizeIpv4Prefix(@Nullable final Ipv4Prefix ipv4Prefix) { if (ipv4Prefix == null) { return null; } @@ -133,9 +128,8 @@ public final class AddressNormalizationUtil { * @param ipv4Mask the Ipv4 mask * @return normalized Ipv4 prefix */ - @Nullable - public static Ipv4Prefix normalizeIpv4Arbitrary(@Nullable final Ipv4Address ipv4Address, - @Nullable final DottedQuad ipv4Mask) { + public static @Nullable Ipv4Prefix normalizeIpv4Arbitrary(@Nullable final Ipv4Address ipv4Address, + @Nullable final DottedQuad ipv4Mask) { if (ipv4Address == null) { return null; } @@ -152,8 +146,8 @@ public final class AddressNormalizationUtil { * @param mask Ipv4 mask byte array * @return normalized Ipv4 prefix */ - @Nullable - public static Ipv4Prefix normalizeIpv4Address(@Nullable final byte[] address, @Nullable final byte[] mask) { + public static @Nullable Ipv4Prefix normalizeIpv4Address(final byte @Nullable [] address, + final byte @Nullable [] mask) { final String addressPrefix = normalizeInetAddressWithMask(normalizeIpAddress(address, mask), mask); if (addressPrefix == null) { @@ -171,8 +165,8 @@ public final class AddressNormalizationUtil { * @param mask Ipv6 mask byte array * @return normalized Ipv6 prefix */ - @Nullable - public static Ipv6Prefix normalizeIpv6Address(@Nullable final byte[] address, @Nullable final byte[] mask) { + public static @Nullable Ipv6Prefix normalizeIpv6Address(final byte @Nullable [] address, + final byte @Nullable [] mask) { final String addressPrefix = normalizeInetAddressWithMask(normalizeIpAddress(address, mask), mask); if (addressPrefix == null) { @@ -189,8 +183,8 @@ public final class AddressNormalizationUtil { * @param mask mask byte array * @return normalized Inet address */ - @Nullable - public static InetAddress normalizeIpAddress(@Nullable final byte[] address, @Nullable final byte[] mask) { + public static @Nullable InetAddress normalizeIpAddress(final byte @Nullable [] address, + final byte @Nullable [] mask) { if (address == null) { return null; } @@ -216,9 +210,8 @@ public final class AddressNormalizationUtil { * @param mask the mask * @return the string */ - @Nullable - public static String normalizeInetAddressWithMask(@Nullable final InetAddress address, - @Nullable final byte[] mask) { + public static @Nullable String normalizeInetAddressWithMask(final @Nullable InetAddress address, + final byte @Nullable [] mask) { if (address == null) { return null; } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtil.java index 03071d2e79..292af59b73 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtil.java @@ -14,6 +14,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; import java.util.ArrayList; +import java.util.Collection; import java.util.EnumSet; import java.util.List; import org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep; @@ -77,14 +78,14 @@ public final class FlatBatchUtil { } private static boolean isGroupBarrierNeeded(final EnumSet previousTypes, final BatchStepType type) { - return (type == BatchStepType.GROUP_ADD + return type == BatchStepType.GROUP_ADD && (previousTypes.contains(BatchStepType.GROUP_ADD) - || previousTypes.contains(BatchStepType.GROUP_UPDATE))) - || (type == BatchStepType.GROUP_REMOVE + || previousTypes.contains(BatchStepType.GROUP_UPDATE)) + || type == BatchStepType.GROUP_REMOVE && (previousTypes.contains(BatchStepType.FLOW_REMOVE) || previousTypes.contains(BatchStepType.FLOW_UPDATE) || previousTypes.contains(BatchStepType.GROUP_REMOVE) - || previousTypes.contains(BatchStepType.GROUP_UPDATE))); + || previousTypes.contains(BatchStepType.GROUP_UPDATE)); } private static boolean isMeterBarrierNeeded(final EnumSet previousTypes, final BatchStepType type) { @@ -93,7 +94,7 @@ public final class FlatBatchUtil { || previousTypes.contains(BatchStepType.FLOW_UPDATE)); } - public static List assembleBatchPlan(List batches) { + public static List assembleBatchPlan(final Collection batches) { final List plan = new ArrayList<>(); BatchPlanStep planStep; @@ -110,36 +111,36 @@ public final class FlatBatchUtil { return plan; } - private static List extractBatchData(final BatchStepType batchStepType, + private static Collection extractBatchData(final BatchStepType batchStepType, final BatchChoice batchChoice) { - final List batchData; + final Collection batchData; switch (batchStepType) { case FLOW_ADD: - batchData = ((FlatBatchAddFlowCase) batchChoice).getFlatBatchAddFlow(); + batchData = ((FlatBatchAddFlowCase) batchChoice).nonnullFlatBatchAddFlow().values(); break; case FLOW_REMOVE: - batchData = ((FlatBatchRemoveFlowCase) batchChoice).getFlatBatchRemoveFlow(); + batchData = ((FlatBatchRemoveFlowCase) batchChoice).nonnullFlatBatchRemoveFlow().values(); break; case FLOW_UPDATE: - batchData = ((FlatBatchUpdateFlowCase) batchChoice).getFlatBatchUpdateFlow(); + batchData = ((FlatBatchUpdateFlowCase) batchChoice).nonnullFlatBatchUpdateFlow().values(); break; case GROUP_ADD: - batchData = ((FlatBatchAddGroupCase) batchChoice).getFlatBatchAddGroup(); + batchData = ((FlatBatchAddGroupCase) batchChoice).nonnullFlatBatchAddGroup().values(); break; case GROUP_REMOVE: - batchData = ((FlatBatchRemoveGroupCase) batchChoice).getFlatBatchRemoveGroup(); + batchData = ((FlatBatchRemoveGroupCase) batchChoice).nonnullFlatBatchRemoveGroup().values(); break; case GROUP_UPDATE: - batchData = ((FlatBatchUpdateGroupCase) batchChoice).getFlatBatchUpdateGroup(); + batchData = ((FlatBatchUpdateGroupCase) batchChoice).nonnullFlatBatchUpdateGroup().values(); break; case METER_ADD: - batchData = ((FlatBatchAddMeterCase) batchChoice).getFlatBatchAddMeter(); + batchData = ((FlatBatchAddMeterCase) batchChoice).nonnullFlatBatchAddMeter().values(); break; case METER_REMOVE: - batchData = ((FlatBatchRemoveMeterCase) batchChoice).getFlatBatchRemoveMeter(); + batchData = ((FlatBatchRemoveMeterCase) batchChoice).nonnullFlatBatchRemoveMeter().values(); break; case METER_UPDATE: - batchData = ((FlatBatchUpdateMeterCase) batchChoice).getFlatBatchUpdateMeter(); + batchData = ((FlatBatchUpdateMeterCase) batchChoice).nonnullFlatBatchUpdateMeter().values(); break; default: throw new IllegalArgumentException("Unsupported batch step type obtained: " + batchStepType); @@ -186,9 +187,9 @@ public final class FlatBatchUtil { for (RpcResult jobResult : jobsResults) { if (jobResult != null) { - isSuccessful = (isSuccessful && jobResult.isSuccessful()); + isSuccessful = isSuccessful && jobResult.isSuccessful(); rpcErrors.addAll(jobResult.getErrors()); - batchFailures.addAll(jobResult.getResult().getBatchFailure()); + batchFailures.addAll(jobResult.getResult().nonnullBatchFailure().values()); } } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/FlowUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/FlowUtil.java index 44719b77b1..34ed1e2bd6 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/FlowUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/FlowUtil.java @@ -17,7 +17,6 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; import org.apache.commons.lang3.tuple.Pair; -import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table; @@ -196,19 +195,19 @@ public final class FlowUtil { * @return static reusable function */ public static Function>, RpcResult>> createCumulatingFunction( - final List inputBatchFlows) { + final Collection inputBatchFlows) { return new CumulatingFunction(inputBatchFlows).invoke(); } private static class CumulatingFunction { - private final List inputBatchFlows; + private final Collection inputBatchFlows; - CumulatingFunction(final List inputBatchFlows) { + CumulatingFunction(final Collection inputBatchFlows) { this.inputBatchFlows = inputBatchFlows; } public Function>, RpcResult>> invoke() { - return (@NonNull final List> innerInput) -> { + return (final List> innerInput) -> { final int sizeOfFutures = innerInput.size(); final int sizeOfInputBatch = inputBatchFlows.size(); Preconditions.checkArgument(sizeOfFutures == sizeOfInputBatch, diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MatchUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MatchUtil.java index 47500a30b5..ce4f5b7d93 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MatchUtil.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/MatchUtil.java @@ -12,6 +12,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.function.Function; +import java.util.stream.Collectors; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionResolvers; @@ -159,6 +160,8 @@ public final class MatchUtil { return ExtensionResolvers .getMatchExtensionResolver() .getExtension(match) - .flatMap(matchExtension -> Optional.ofNullable(matchExtension.getExtensionList())); + .flatMap(matchExtension -> + Optional.ofNullable(matchExtension.nonnullExtensionList().values() + .stream().collect(Collectors.toList()))); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java index 8f1d6e173a..5610f5e2a0 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java @@ -84,7 +84,7 @@ public class TransactionChainManagerTest { txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false); Mockito.verify(txChain).newReadWriteTransaction(); - Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false); + Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data); } /** @@ -98,7 +98,7 @@ public class TransactionChainManagerTest { txChainManager.submitTransaction(); Mockito.verify(txChain).newReadWriteTransaction(); - Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false); + Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data); Mockito.verify(writeTx).commit(); } @@ -112,7 +112,7 @@ public class TransactionChainManagerTest { txChainManager.submitTransaction(); Mockito.verify(txChain).newReadWriteTransaction(); - Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false); + Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data); Mockito.verify(writeTx, Mockito.never()).commit(); } @@ -126,7 +126,7 @@ public class TransactionChainManagerTest { txChainManager.submitTransaction(); Mockito.verify(txChain).newReadWriteTransaction(); - Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false); + Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data); Mockito.verify(writeTx).commit(); } @@ -140,7 +140,7 @@ public class TransactionChainManagerTest { txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false); Mockito.verify(txChain).newReadWriteTransaction(); - Mockito.verify(writeTx, Mockito.times(2)).put(LogicalDatastoreType.CONFIGURATION, path, data, false); + Mockito.verify(writeTx, Mockito.times(2)).put(LogicalDatastoreType.CONFIGURATION, path, data); Mockito.verify(writeTx, Mockito.never()).commit(); } @@ -182,7 +182,7 @@ public class TransactionChainManagerTest { txChainManager.deactivateTransactionManager(); Mockito.verify(txChain).newReadWriteTransaction(); - Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false); + Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data); Mockito.verify(writeTx, Mockito.never()).commit(); Mockito.verify(writeTx).cancel(); Mockito.verify(txChain).close(); @@ -196,7 +196,7 @@ public class TransactionChainManagerTest { txChainManager.shuttingDown(); Mockito.verify(txChain).newReadWriteTransaction(); - Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false); + Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data); Mockito.verify(writeTx).commit(); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/instruction/ApplyActionsInstructionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/instruction/ApplyActionsInstructionDeserializerTest.java index c13c4d2cea..ad567f3220 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/instruction/ApplyActionsInstructionDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/instruction/ApplyActionsInstructionDeserializerTest.java @@ -58,7 +58,7 @@ public class ApplyActionsInstructionDeserializerTest extends AbstractInstruction assertEquals(ApplyActionsCase.class, instruction.implementedInterface()); final ApplyActionsCase actionCase = (ApplyActionsCase) instruction; assertEquals(1, actionCase.getApplyActions().getAction().size()); - assertEquals(PopPbbActionCase.class, actionCase.getApplyActions().getAction().get(0) + assertEquals(PopPbbActionCase.class, actionCase.getApplyActions().nonnullAction().values().iterator().next() .getAction().implementedInterface()); assertEquals(0, in.readableBytes()); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/instruction/WriteActionsInstructionDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/instruction/WriteActionsInstructionDeserializerTest.java index 35e32747ba..be39ff50ba 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/instruction/WriteActionsInstructionDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/instruction/WriteActionsInstructionDeserializerTest.java @@ -58,7 +58,7 @@ public class WriteActionsInstructionDeserializerTest extends AbstractInstruction assertEquals(WriteActionsCase.class, instruction.implementedInterface()); final WriteActionsCase actionCase = (WriteActionsCase) instruction; assertEquals(1, actionCase.getWriteActions().getAction().size()); - assertEquals(PopPbbActionCase.class, actionCase.getWriteActions().getAction().get(0) + assertEquals(PopPbbActionCase.class, actionCase.getWriteActions().nonnullAction().values().iterator().next() .getAction().implementedInterface()); assertEquals(0, in.readableBytes()); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/FlowMessageDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/FlowMessageDeserializerTest.java index 5d61becb2f..8457bc7ed6 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/FlowMessageDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/FlowMessageDeserializerTest.java @@ -129,12 +129,13 @@ public class FlowMessageDeserializerTest extends AbstractDeserializerTest { assertEquals(MPLS_LABEL, message.getMatch().getProtocolMatchFields().getMplsLabel().intValue()); assertEquals(1, message.getInstructions().getInstruction().size()); - final Instruction instruction = message.getInstructions().getInstruction().get(0).getInstruction(); + final Instruction instruction = message.getInstructions().nonnullInstruction().values().iterator().next() + .getInstruction(); assertEquals(ApplyActionsCase.class, instruction.implementedInterface()); final ApplyActionsCase applyActions = (ApplyActionsCase) instruction; assertEquals(1, applyActions.getApplyActions().getAction().size()); - assertEquals(PopPbbActionCase.class, applyActions.getApplyActions().getAction().get(0) + assertEquals(PopPbbActionCase.class, applyActions.getApplyActions().nonnullAction().values().iterator().next() .getAction().implementedInterface()); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/GroupMessageDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/GroupMessageDeserializerTest.java index 949294cdd1..81f52b80ed 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/GroupMessageDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/GroupMessageDeserializerTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.deserialization.messages; import static org.junit.Assert.assertEquals; @@ -79,12 +78,13 @@ public class GroupMessageDeserializerTest extends AbstractDeserializerTest { assertEquals(GROUP_TYPE.getIntValue(), message.getGroupType().getIntValue()); assertEquals(1, message.getBuckets().getBucket().size()); - final Bucket bucket = message.getBuckets().getBucket().get(0); + final Bucket bucket = message.getBuckets().nonnullBucket().values().iterator().next(); assertEquals(WEIGHT, bucket.getWeight().shortValue()); assertEquals(WATCH_PORT, bucket.getWatchPort().intValue()); assertEquals(WATCH_GROUP, bucket.getWatchGroup().intValue()); assertEquals(1, bucket.getAction().size()); - assertEquals(PopPbbActionCase.class, bucket.getAction().get(0).getAction().implementedInterface()); + assertEquals(PopPbbActionCase.class, + bucket.nonnullAction().values().iterator().next().getAction().implementedInterface()); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/MeterMessageDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/MeterMessageDeserializerTest.java index 56d82f0989..c0268b652d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/MeterMessageDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/MeterMessageDeserializerTest.java @@ -13,7 +13,8 @@ import static org.junit.Assert.assertTrue; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import java.util.List; +import java.util.Iterator; +import java.util.Map; import org.junit.Test; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.util.ByteBufUtils; @@ -22,6 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemark; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand; public class MeterMessageDeserializerTest extends AbstractDeserializerTest { @@ -85,11 +87,13 @@ public class MeterMessageDeserializerTest extends AbstractDeserializerTest { assertEquals(message.getFlags().isMeterStats(), IS_STATS); assertEquals(message.getMeterId().getValue().intValue(), ID); - final List meterBandHeader = message.getMeterBandHeaders().getMeterBandHeader(); + final Map meterBandHeader = + message.getMeterBandHeaders().nonnullMeterBandHeader(); assertEquals(meterBandHeader.size(), 2); + final Iterator meterBandHeaderIt = meterBandHeader.values().iterator(); // Drop band - final MeterBandHeader dropHeader = meterBandHeader.get(0); + final MeterBandHeader dropHeader = meterBandHeaderIt.next(); assertEquals(Drop.class, dropHeader.getBandType().implementedInterface()); assertTrue(dropHeader.getMeterBandTypes().getFlags().isOfpmbtDrop()); @@ -98,7 +102,7 @@ public class MeterMessageDeserializerTest extends AbstractDeserializerTest { assertEquals(DROP_BURST, drop.getDropBurstSize().intValue()); // Dscp band - final MeterBandHeader dscpHeader = meterBandHeader.get(1); + final MeterBandHeader dscpHeader = meterBandHeaderIt.next(); assertEquals(DscpRemark.class, dscpHeader.getBandType().implementedInterface()); assertTrue(dscpHeader.getMeterBandTypes().getFlags().isOfpmbtDscpRemark()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowStatsDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowStatsDeserializerTest.java index 5db27f9bab..3e4dbd174c 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowStatsDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowStatsDeserializerTest.java @@ -129,7 +129,8 @@ public class MultipartReplyFlowStatsDeserializerTest extends AbstractMultipartDe buffer.setShort(instructionLengthIndex, buffer.writerIndex() - instructionStartIndex); final MultipartReplyFlowStats reply = (MultipartReplyFlowStats) deserializeMultipart(buffer); - final FlowAndStatisticsMapList flowAndStatisticsMapList = reply.getFlowAndStatisticsMapList().get(0); + final FlowAndStatisticsMapList flowAndStatisticsMapList = + reply.nonnullFlowAndStatisticsMapList().values().iterator().next(); assertEquals(TABLE_ID, flowAndStatisticsMapList.getTableId().shortValue()); assertEquals(SECOND, flowAndStatisticsMapList.getDuration().getSecond().getValue().intValue()); assertEquals(NANOSECOND, flowAndStatisticsMapList.getDuration().getNanosecond().getValue().intValue()); @@ -142,23 +143,22 @@ public class MultipartReplyFlowStatsDeserializerTest extends AbstractMultipartDe assertEquals(PACKET_COUNT, flowAndStatisticsMapList.getPacketCount().getValue().longValue()); assertEquals(2, flowAndStatisticsMapList.getInstructions().getInstruction().size()); + final var instructionIter = flowAndStatisticsMapList.getInstructions().nonnullInstruction().values().iterator(); - final Instruction instruction = - flowAndStatisticsMapList.getInstructions().getInstruction().get(0).getInstruction(); + final Instruction instruction = instructionIter.next().getInstruction(); assertEquals(ApplyActionsCase.class, instruction.implementedInterface()); final ApplyActionsCase applyActions = (ApplyActionsCase) instruction; - assertEquals(1, applyActions.getApplyActions().getAction().size()); - assertEquals(PopPbbActionCase.class, applyActions.getApplyActions().getAction().get(0) + assertEquals(1, applyActions.getApplyActions().nonnullAction().size()); + assertEquals(PopPbbActionCase.class, applyActions.getApplyActions().nonnullAction().values().iterator().next() .getAction().implementedInterface()); - final Instruction instruction1 = - flowAndStatisticsMapList.getInstructions().getInstruction().get(1).getInstruction(); + final Instruction instruction1 = instructionIter.next().getInstruction(); assertEquals(WriteActionsCase.class, instruction1.implementedInterface()); final WriteActionsCase writeActions = (WriteActionsCase) instruction1; assertEquals(1, writeActions.getWriteActions().getAction().size()); - assertEquals(PopVlanActionCase.class, writeActions.getWriteActions().getAction().get(0) + assertEquals(PopVlanActionCase.class, writeActions.getWriteActions().nonnullAction().values().iterator().next() .getAction().implementedInterface()); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowTableStatsDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowTableStatsDeserializerTest.java index f3902ce0a5..1f65b045f3 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowTableStatsDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowTableStatsDeserializerTest.java @@ -12,6 +12,7 @@ import static org.junit.Assert.assertEquals; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; @@ -32,12 +33,11 @@ public class MultipartReplyFlowTableStatsDeserializerTest extends AbstractMultip buffer.writeLong(PACKETS_MATCHED); final MultipartReplyFlowTableStats reply = (MultipartReplyFlowTableStats) deserializeMultipart(buffer); - assertEquals(TABLE_ID, reply.getFlowTableAndStatisticsMap().get(0).getTableId().getValue().byteValue()); - assertEquals(ACTIVE_FLOWS, reply.getFlowTableAndStatisticsMap().get(0).getActiveFlows().getValue().intValue()); - assertEquals(PACKETS_LOOKEDUP, reply.getFlowTableAndStatisticsMap().get(0).getPacketsLookedUp().getValue() - .longValue()); - assertEquals(PACKETS_MATCHED, reply.getFlowTableAndStatisticsMap().get(0).getPacketsMatched().getValue() - .longValue()); + final FlowTableAndStatisticsMap first = reply.nonnullFlowTableAndStatisticsMap().values().iterator().next(); + assertEquals(TABLE_ID, first.getTableId().getValue().byteValue()); + assertEquals(ACTIVE_FLOWS, first.getActiveFlows().getValue().intValue()); + assertEquals(PACKETS_LOOKEDUP, first.getPacketsLookedUp().getValue().longValue()); + assertEquals(PACKETS_MATCHED, first.getPacketsMatched().getValue().longValue()); assertEquals(0, buffer.readableBytes()); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupDescDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupDescDeserializerTest.java index 464583f332..45a3a1fc5d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupDescDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupDescDeserializerTest.java @@ -16,6 +16,8 @@ import org.junit.Test; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupDesc; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; public class MultipartReplyGroupDescDeserializerTest extends AbstractMultipartDeserializerTest { @@ -48,14 +50,14 @@ public class MultipartReplyGroupDescDeserializerTest extends AbstractMultipartDe buffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER); final MultipartReplyGroupDesc reply = (MultipartReplyGroupDesc) deserializeMultipart(buffer); + final GroupDescStats firstGroupDescStats = reply.nonnullGroupDescStats().values().iterator().next(); + assertEquals(GROUP_ID, firstGroupDescStats.getGroupId().getValue().intValue()); + assertEquals(GROUP_TYPE, firstGroupDescStats.getGroupType().getIntValue()); - assertEquals(GROUP_ID, reply.getGroupDescStats().get(0).getGroupId().getValue().intValue()); - assertEquals(WEIGHT, reply.getGroupDescStats().get(0).getBuckets().getBucket().get(0).getWeight().intValue()); - assertEquals(WATCH_PORT, reply.getGroupDescStats().get(0).getBuckets().getBucket().get(0).getWatchPort() - .intValue()); - assertEquals(WATCH_GROUP, reply.getGroupDescStats().get(0).getBuckets().getBucket().get(0).getWatchGroup() - .intValue()); - assertEquals(GROUP_TYPE, reply.getGroupDescStats().get(0).getGroupType().getIntValue()); + final Bucket firstBucket = firstGroupDescStats.getBuckets().nonnullBucket().values().iterator().next(); + assertEquals(WEIGHT, firstBucket.getWeight().intValue()); + assertEquals(WATCH_PORT, firstBucket.getWatchPort().intValue()); + assertEquals(WATCH_GROUP, firstBucket.getWatchGroup().intValue()); assertEquals(0, buffer.readableBytes()); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupStatsDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupStatsDeserializerTest.java index f6a00986e9..30e1d47442 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupStatsDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupStatsDeserializerTest.java @@ -14,6 +14,7 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; public class MultipartReplyGroupStatsDeserializerTest extends AbstractMultipartDeserializerTest { @@ -44,14 +45,15 @@ public class MultipartReplyGroupStatsDeserializerTest extends AbstractMultipartD buffer.writeLong(BYTE_COUNT); final MultipartReplyGroupStats reply = (MultipartReplyGroupStats) deserializeMultipart(buffer); - assertEquals(GROUP_ID, reply.getGroupStats().get(0).getGroupId().getValue().intValue()); - assertEquals(REF_COUNT, reply.getGroupStats().get(0).getRefCount().getValue().intValue()); - assertEquals(PACKET_COUNT, reply.getGroupStats().get(0).getPacketCount().getValue().longValue()); - assertEquals(BYTE_COUNT, reply.getGroupStats().get(0).getByteCount().getValue().longValue()); - assertEquals(SECOND, reply.getGroupStats().get(0).getDuration().getSecond().getValue().intValue()); - assertEquals(NANOSECOND, reply.getGroupStats().get(0).getDuration().getNanosecond().getValue().intValue()); - assertEquals(PACKET_COUNT, reply.getGroupStats().get(0).getPacketCount().getValue().longValue()); - assertEquals(BYTE_COUNT, reply.getGroupStats().get(0).getByteCount().getValue().longValue()); + final GroupStats firstGroupStats = reply.nonnullGroupStats().values().iterator().next(); + assertEquals(GROUP_ID, firstGroupStats.getGroupId().getValue().intValue()); + assertEquals(REF_COUNT, firstGroupStats.getRefCount().getValue().intValue()); + assertEquals(PACKET_COUNT, firstGroupStats.getPacketCount().getValue().longValue()); + assertEquals(BYTE_COUNT, firstGroupStats.getByteCount().getValue().longValue()); + assertEquals(SECOND, firstGroupStats.getDuration().getSecond().getValue().intValue()); + assertEquals(NANOSECOND, firstGroupStats.getDuration().getNanosecond().getValue().intValue()); + assertEquals(PACKET_COUNT, firstGroupStats.getPacketCount().getValue().longValue()); + assertEquals(BYTE_COUNT, firstGroupStats.getByteCount().getValue().longValue()); assertEquals(0, buffer.readableBytes()); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMessageDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMessageDeserializerTest.java index 70d4672ff9..eb2bc28cb4 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMessageDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMessageDeserializerTest.java @@ -134,7 +134,8 @@ public class MultipartReplyMessageDeserializerTest extends AbstractDeserializerT final MultipartReplyFlowStats reply = (MultipartReplyFlowStats) message.getMultipartReplyBody(); assertEquals(XID, message.getXid().intValue()); - final FlowAndStatisticsMapList flowAndStatisticsMapList = reply.getFlowAndStatisticsMapList().get(0); + final FlowAndStatisticsMapList flowAndStatisticsMapList = + reply.nonnullFlowAndStatisticsMapList().values().iterator().next(); assertEquals(TABLE_ID, flowAndStatisticsMapList.getTableId().shortValue()); assertEquals(SECOND, flowAndStatisticsMapList.getDuration().getSecond().getValue().intValue()); assertEquals(NANOSECOND, flowAndStatisticsMapList.getDuration().getNanosecond().getValue().intValue()); @@ -149,12 +150,13 @@ public class MultipartReplyMessageDeserializerTest extends AbstractDeserializerT assertEquals(1, flowAndStatisticsMapList.getInstructions().getInstruction().size()); final Instruction instruction = - flowAndStatisticsMapList.getInstructions().getInstruction().get(0).getInstruction(); + flowAndStatisticsMapList.getInstructions().nonnullInstruction().values().iterator().next() + .getInstruction(); assertEquals(ApplyActionsCase.class, instruction.implementedInterface()); final ApplyActionsCase applyActions = (ApplyActionsCase) instruction; assertEquals(1, applyActions.getApplyActions().getAction().size()); - assertEquals(PopPbbActionCase.class, applyActions.getApplyActions().getAction().get(0) + assertEquals(PopPbbActionCase.class, applyActions.getApplyActions().nonnullAction().values().iterator().next() .getAction().implementedInterface()); } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMeterConfigDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMeterConfigDeserializerTest.java index 3de6d6443c..bff961fee3 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMeterConfigDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMeterConfigDeserializerTest.java @@ -51,10 +51,11 @@ public class MultipartReplyMeterConfigDeserializerTest extends AbstractMultipart final MultipartReplyMeterConfig reply = (MultipartReplyMeterConfig) deserializeMultipart(buffer); - assertEquals(METER_ID, reply.getMeterConfigStats().get(0).getMeterId().getValue().intValue()); - assertEquals(FLAGS, reply.getMeterConfigStats().get(0).getFlags()); - final Drop drop = (Drop) reply.getMeterConfigStats().get(0) - .getMeterBandHeaders().getMeterBandHeader().get(0).getBandType(); + assertEquals(METER_ID, + reply.nonnullMeterConfigStats().values().iterator().next().getMeterId().getValue().intValue()); + assertEquals(FLAGS, reply.nonnullMeterConfigStats().values().iterator().next().getFlags()); + final Drop drop = (Drop) reply.nonnullMeterConfigStats().values().iterator().next() + .getMeterBandHeaders().nonnullMeterBandHeader().values().iterator().next().getBandType(); assertEquals(DROP_RATE, drop.getDropRate().intValue()); assertEquals(DROP_BURST_SIZE, drop.getDropBurstSize().intValue()); } @@ -72,8 +73,8 @@ public class MultipartReplyMeterConfigDeserializerTest extends AbstractMultipart final MultipartReplyMeterConfig reply = (MultipartReplyMeterConfig) deserializeMultipart(buffer); - final DscpRemark dscpRemark = (DscpRemark) reply.getMeterConfigStats().get(0) - .getMeterBandHeaders().getMeterBandHeader().get(0).getBandType(); + final DscpRemark dscpRemark = (DscpRemark) reply.nonnullMeterConfigStats().values().iterator().next() + .getMeterBandHeaders().nonnullMeterBandHeader().values().iterator().next().getBandType(); assertEquals(DSCP_REMARK_RATE, dscpRemark.getDscpRemarkRate().intValue()); assertEquals(DSCP_REMARK_BURST_SIZE, dscpRemark.getDscpRemarkBurstSize().intValue()); assertEquals(PREC_LEVEL, dscpRemark.getPrecLevel().byteValue()); @@ -84,7 +85,7 @@ public class MultipartReplyMeterConfigDeserializerTest extends AbstractMultipart return MultipartType.OFPMPMETERCONFIG.getIntValue(); } - private void writeCommonAtributes(ByteBuf buffer) { + private void writeCommonAtributes(final ByteBuf buffer) { buffer.writeShort(ITEM_LENGTH); buffer.writeShort(ByteBufUtils.fillBitMask(0, FLAGS.isMeterKbps(), diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMeterStatsDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMeterStatsDeserializerTest.java index 725d4d7ff7..c4b4f64ebb 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMeterStatsDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMeterStatsDeserializerTest.java @@ -45,7 +45,7 @@ public class MultipartReplyMeterStatsDeserializerTest extends AbstractMultipartD final MultipartReplyMeterStats reply = (MultipartReplyMeterStats) deserializeMultipart(buffer); - final MeterStats meterStats = reply.getMeterStats().get(0); + final MeterStats meterStats = reply.nonnullMeterStats().values().iterator().next(); assertEquals(METER_ID, meterStats.getMeterId().getValue().intValue()); assertEquals(FLOW_COUNT, meterStats.getFlowCount().getValue().intValue()); @@ -53,9 +53,9 @@ public class MultipartReplyMeterStatsDeserializerTest extends AbstractMultipartD assertEquals(BYTE_IN_COUNT, meterStats.getByteInCount().getValue().intValue()); assertEquals(SECOND, meterStats.getDuration().getSecond().getValue().intValue()); assertEquals(NANOSECOND, meterStats.getDuration().getNanosecond().getValue().intValue()); - assertEquals(PACKET_BAND_COUNT, meterStats.getMeterBandStats().getBandStat().get(0) + assertEquals(PACKET_BAND_COUNT, meterStats.getMeterBandStats().nonnullBandStat().values().iterator().next() .getPacketBandCount().getValue().longValue()); - assertEquals(BYTE_BAND_COUNT, meterStats.getMeterBandStats().getBandStat().get(0) + assertEquals(BYTE_BAND_COUNT, meterStats.getMeterBandStats().nonnullBandStat().values().iterator().next() .getByteBandCount().getValue().longValue()); assertEquals(0, buffer.readableBytes()); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyPortStatsDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyPortStatsDeserializerTest.java index e325e00b59..2dcf012ff2 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyPortStatsDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyPortStatsDeserializerTest.java @@ -58,7 +58,7 @@ public class MultipartReplyPortStatsDeserializerTest extends AbstractMultipartDe final MultipartReplyPortStats reply = (MultipartReplyPortStats) deserializeMultipart(buffer); final NodeConnectorStatisticsAndPortNumberMap portStats = - reply.getNodeConnectorStatisticsAndPortNumberMap().get(0); + reply.nonnullNodeConnectorStatisticsAndPortNumberMap().values().iterator().next(); assertEquals(PACKETS_RECEIVED, portStats.getPackets().getReceived().longValue()); assertEquals(PACKETS_TRANSMITTED, portStats.getPackets().getTransmitted().longValue()); assertEquals(BYTES_RECEIVED, portStats.getBytes().getReceived().longValue()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyQueueStatsDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyQueueStatsDeserializerTest.java index feb8a0ef9a..39649ba99a 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyQueueStatsDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyQueueStatsDeserializerTest.java @@ -39,7 +39,7 @@ public class MultipartReplyQueueStatsDeserializerTest extends AbstractMultipartD final MultipartReplyQueueStats reply = (MultipartReplyQueueStats) deserializeMultipart(buffer); - final QueueIdAndStatisticsMap queueStats = reply.getQueueIdAndStatisticsMap().get(0); + final QueueIdAndStatisticsMap queueStats = reply.nonnullQueueIdAndStatisticsMap().values().iterator().next(); assertEquals(QUEUE_ID, queueStats.getQueueId().getValue().intValue()); assertEquals(TRANSMITTED_BYTES, queueStats.getTransmittedBytes().getValue().longValue()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializerTest.java index e13577ad81..1d0f626248 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializerTest.java @@ -33,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures; public class MultipartReplyTableFeaturesDeserializerTest extends AbstractMultipartDeserializerTest { @@ -67,95 +68,111 @@ public class MultipartReplyTableFeaturesDeserializerTest extends AbstractMultipa writeValues(buffer, OFPTFPT_INSTRUCTIONS); MultipartReplyTableFeatures reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer); - assertEquals(TABLE_ID, reply.getTableFeatures().get(0).getTableId().byteValue()); - assertEquals(METADATA_MATCH, reply.getTableFeatures().get(0).getMetadataMatch().longValue()); - assertEquals(METADATA_WRITE, reply.getTableFeatures().get(0).getMetadataWrite().longValue()); - assertEquals(MAX_ENTRIES, reply.getTableFeatures().get(0).getMaxEntries().longValue()); - assertEquals(MAX_ENTRIES, reply.getTableFeatures().get(0).getMaxEntries().longValue()); - assertEquals(Instructions.class, reply.getTableFeatures().get(0).getTableProperties() - .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface()); + TableFeatures firstTableFeature = reply.nonnullTableFeatures().values().iterator().next(); + assertEquals(TABLE_ID, firstTableFeature.getTableId().byteValue()); + assertEquals(METADATA_MATCH, firstTableFeature.getMetadataMatch().longValue()); + assertEquals(METADATA_WRITE, firstTableFeature.getMetadataWrite().longValue()); + assertEquals(MAX_ENTRIES, firstTableFeature.getMaxEntries().longValue()); + assertEquals(MAX_ENTRIES, firstTableFeature.getMaxEntries().longValue()); + assertEquals(Instructions.class, firstTableFeature.getTableProperties() + .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType() + .implementedInterface()); writeValues(buffer, OFPTFPT_INSTRUCTIONS_MISS); reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer); - assertEquals(InstructionsMiss.class, reply.getTableFeatures().get(0).getTableProperties() - .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface()); + assertEquals(InstructionsMiss.class, reply.nonnullTableFeatures().values().iterator().next() + .getTableProperties().nonnullTableFeatureProperties().values().iterator().next() + .getTableFeaturePropType().implementedInterface()); writeValues(buffer, OFPTFPT_NEXT_TABLES); reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer); - assertEquals(NextTable.class, reply.getTableFeatures().get(0).getTableProperties() - .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface()); + assertEquals(NextTable.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties() + .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType() + .implementedInterface()); writeValues(buffer, OFPTFPT_NEXT_TABLES_MISS); reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer); - assertEquals(NextTableMiss.class, reply.getTableFeatures().get(0).getTableProperties() - .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface()); + assertEquals(NextTableMiss.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties() + .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType() + .implementedInterface()); writeValues(buffer, OFPTFPT_WRITE_ACTIONS); reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer); - assertEquals(WriteActions.class, reply.getTableFeatures().get(0).getTableProperties() - .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface()); + assertEquals(WriteActions.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties() + .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType() + .implementedInterface()); writeValues(buffer, OFPTFPT_WRITE_ACTIONS_MISS); reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer); - assertEquals(WriteActionsMiss.class, reply.getTableFeatures().get(0).getTableProperties() - .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface()); + assertEquals(WriteActionsMiss.class, reply.nonnullTableFeatures().values().iterator().next() + .getTableProperties().nonnullTableFeatureProperties().values().iterator().next() + .getTableFeaturePropType().implementedInterface()); writeValues(buffer, OFPTFPT_APPLY_ACTIONS); reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer); - assertEquals(ApplyActions.class, reply.getTableFeatures().get(0).getTableProperties() - .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface()); + assertEquals(ApplyActions.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties() + .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType() + .implementedInterface()); writeValues(buffer, OFPTFPT_APPLY_ACTIONS_MISS); reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer); - assertEquals(ApplyActionsMiss.class, reply.getTableFeatures().get(0).getTableProperties() - .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface()); + assertEquals(ApplyActionsMiss.class, reply.nonnullTableFeatures().values().iterator().next() + .getTableProperties().nonnullTableFeatureProperties().values().iterator().next() + .getTableFeaturePropType().implementedInterface()); writeValues(buffer, OFPTFPT_MATCH); reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer); - assertEquals(Match.class, reply.getTableFeatures().get(0).getTableProperties() - .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface()); + assertEquals(Match.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties() + .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType() + .implementedInterface()); writeValues(buffer, OFPTFPT_WILDCARDS); reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer); - assertEquals(Wildcards.class, reply.getTableFeatures().get(0).getTableProperties() - .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface()); + assertEquals(Wildcards.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties() + .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType() + .implementedInterface()); writeValues(buffer, OFPTFPT_WRITE_SETFIELD); reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer); - assertEquals(WriteSetfield.class, reply.getTableFeatures().get(0).getTableProperties() - .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface()); + assertEquals(WriteSetfield.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties() + .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType() + .implementedInterface()); writeValues(buffer, OFPTFPT_WRITE_SETFIELD_MISS); reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer); - assertEquals(WriteSetfieldMiss.class, reply.getTableFeatures().get(0).getTableProperties() - .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface()); + assertEquals(WriteSetfieldMiss.class, reply.nonnullTableFeatures().values().iterator().next() + .getTableProperties().nonnullTableFeatureProperties().values().iterator().next() + .getTableFeaturePropType().implementedInterface()); writeValues(buffer, OFPTFPT_APPLY_SETFIELD); reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer); - assertEquals(ApplySetfield.class, reply.getTableFeatures().get(0).getTableProperties() - .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface()); + assertEquals(ApplySetfield.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties() + .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType() + .implementedInterface()); writeValues(buffer, OFPTFPT_APPLY_SETFIELD_MISS); reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer); - assertEquals(ApplySetfieldMiss.class, reply.getTableFeatures().get(0).getTableProperties() - .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface()); + assertEquals(ApplySetfieldMiss.class, reply.nonnullTableFeatures().values().iterator().next() + .getTableProperties().nonnullTableFeatureProperties().values().iterator().next() + .getTableFeaturePropType().implementedInterface()); assertEquals(0, buffer.readableBytes()); } - private void writeValues(ByteBuf buffer, int propertyType) { + + private static void writeValues(final ByteBuf buffer, final int propertyType) { buffer.clear(); final int replyIndex = buffer.readerIndex(); buffer.writeShort(EncodeConstants.EMPTY_LENGTH); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializerTest.java index 4d68b23683..cf9a024d8c 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializerTest.java @@ -113,8 +113,8 @@ public class FlowMessageSerializerTest extends AbstractSerializerTest { .setInstruction(new ApplyActionsCaseBuilder() .setApplyActions(new ApplyActionsBuilder() .setAction(Collections.singletonList(new ActionBuilder() - .setOrder(0) - .withKey(new ActionKey(0)) + .setOrder(1) + .withKey(new ActionKey(1)) .setAction(new SetTpDstActionCaseBuilder() .setSetTpDstAction(new SetTpDstActionBuilder() .setIpProtocol(IP_PROTOCOL) @@ -131,8 +131,8 @@ public class FlowMessageSerializerTest extends AbstractSerializerTest { .setInstruction(new ApplyActionsCaseBuilder() .setApplyActions(new ApplyActionsBuilder() .setAction(Collections.singletonList(new ActionBuilder() - .setOrder(0) - .withKey(new ActionKey(0)) + .setOrder(2) + .withKey(new ActionKey(2)) .setAction(new SetTpSrcActionCaseBuilder() .setSetTpSrcAction(new SetTpSrcActionBuilder() .setIpProtocol(IP_PROTOCOL) diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/MeterMessageSerializerTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/MeterMessageSerializerTest.java index ec98addc64..6786b2bae3 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/MeterMessageSerializerTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/MeterMessageSerializerTest.java @@ -27,6 +27,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band. import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand; @@ -77,7 +78,7 @@ public class MeterMessageSerializerTest extends AbstractSerializerTest { .meter.types.rev130918.MeterBandType(true, false, false)) .build()) .setBandBurstSize(BAND_BURST_SIZE) - .setBandId(new BandId(BAND_ID)) + .withKey(new MeterBandHeaderKey(new BandId(BAND_ID))) .setBandRate(BAND_RATE) .setBandType(new DropBuilder() .setDropRate(DROP_RATE) @@ -90,7 +91,7 @@ public class MeterMessageSerializerTest extends AbstractSerializerTest { .meter.types.rev130918.MeterBandType(false, true, false)) .build()) .setBandBurstSize(BAND_BURST_SIZE) - .setBandId(new BandId(BAND_ID)) + .withKey(new MeterBandHeaderKey(new BandId(BAND_ID + 1))) .setBandRate(BAND_RATE) .setBandType(new DscpRemarkBuilder() .setDscpRemarkBurstSize(DSCP_BURST_SIZE) diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java index b661294a2f..01751cf99a 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/DeviceFlowRegistryImplTest.java @@ -126,23 +126,19 @@ public class DeviceFlowRegistryImplTest { fillRegistry(path, null); - fillRegistry(path, new FlowCapableNodeBuilder() - .setTable(null) - .build()); + fillRegistry(path, new FlowCapableNodeBuilder().build()); fillRegistry(path, new FlowCapableNodeBuilder() - .setTable(Collections.singletonList(null)) + .setTable(Collections.EMPTY_LIST) .build()); fillRegistry(path, new FlowCapableNodeBuilder() - .setTable(Collections.singletonList(new TableBuilder() - .setFlow(null) - .build())) + .setTable(Collections.singletonList(new TableBuilder().build())) .build()); fillRegistry(path, new FlowCapableNodeBuilder() .setTable(Collections.singletonList(new TableBuilder() - .setFlow(Collections.singletonList(null)) + .setFlow(Collections.EMPTY_LIST) .build())) .build()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactoryTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactoryTest.java index 0a00ece93b..ae03f75565 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactoryTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/FlowRegistryKeyFactoryTest.java @@ -72,7 +72,7 @@ public class FlowRegistryKeyFactoryTest { FlowsStatisticsUpdate flowStats = FLOWS_STATISTICS_UPDATE_BUILDER.build(); HashSet flowRegistryKeys = new HashSet<>(); - for (FlowAndStatisticsMapList item : flowStats.getFlowAndStatisticsMapList()) { + for (FlowAndStatisticsMapList item : flowStats.nonnullFlowAndStatisticsMapList().values()) { final FlowRegistryKey key1 = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), item); final FlowRegistryKey key2 = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), item); flowRegistryKeys.add(key1); @@ -178,7 +178,7 @@ public class FlowRegistryKeyFactoryTest { public void testGetHash() { FlowsStatisticsUpdate flowStats = FLOWS_STATISTICS_UPDATE_BUILDER.build(); - for (FlowAndStatisticsMapList item : flowStats.getFlowAndStatisticsMapList()) { + for (FlowAndStatisticsMapList item : flowStats.nonnullFlowAndStatisticsMapList().values()) { FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), item); FlowRegistryKey lastHash = null; if (null != lastHash) { diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/TestFlowHelper.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/TestFlowHelper.java index 599242e1d9..0b838129f1 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/TestFlowHelper.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/registry/flow/TestFlowHelper.java @@ -10,7 +10,9 @@ package org.opendaylight.openflowplugin.impl.registry.flow; import java.math.BigInteger; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder; @@ -51,6 +53,7 @@ public final class TestFlowHelper { matchBuilder.setEthernetMatch(ethernetMatchBuilder.build()); flowAndStatisticsMapListBuilder.setMatch(matchBuilder.build()); + flowAndStatisticsMapListBuilder.withKey(new FlowAndStatisticsMapListKey(new FlowId(String.valueOf(index)))); return flowAndStatisticsMapListBuilder; } } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdaptersTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdaptersTest.java index 401bac4856..ab836d1405 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdaptersTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchFlowAdaptersTest.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowplugin.impl.services.batch; import com.google.common.collect.Lists; +import java.util.Iterator; import org.junit.Assert; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput; @@ -28,8 +29,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.Add import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.BatchFlowOutputListGrouping; import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.RemoveFlowsBatchInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.UpdateFlowsBatchInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.add.flows.batch.input.BatchAddFlows; import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.remove.flows.batch.input.BatchRemoveFlows; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.update.flows.batch.input.BatchUpdateFlows; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; @@ -59,11 +63,12 @@ public class FlatBatchFlowAdaptersTest { createAddFlowBatch("2"))); final AddFlowsBatchInput addFlowsBatchInput = FlatBatchFlowAdapters.adaptFlatBatchAddFlow(planStep, NODE_REF); + Iterator iterator = addFlowsBatchInput.nonnullBatchAddFlows().values().iterator(); Assert.assertTrue(addFlowsBatchInput.isBarrierAfter()); Assert.assertEquals(2, addFlowsBatchInput.getBatchAddFlows().size()); - Assert.assertEquals("1", addFlowsBatchInput.getBatchAddFlows().get(0).getFlowId().getValue()); - Assert.assertEquals("2", addFlowsBatchInput.getBatchAddFlows().get(1).getFlowId().getValue()); + Assert.assertEquals("1", iterator.next().getFlowId().getValue()); + Assert.assertEquals("2", iterator.next().getFlowId().getValue()); } private FlatBatchAddFlow createAddFlowBatch(final String flowIdValue) { @@ -94,11 +99,12 @@ public class FlatBatchFlowAdaptersTest { final RemoveFlowsBatchInput removeFlowsBatchInput = FlatBatchFlowAdapters.adaptFlatBatchRemoveFlow(planStep, NODE_REF); + Iterator iterator = removeFlowsBatchInput.nonnullBatchRemoveFlows().values().iterator(); Assert.assertTrue(removeFlowsBatchInput.isBarrierAfter()); Assert.assertEquals(2, removeFlowsBatchInput.getBatchRemoveFlows().size()); - Assert.assertEquals("1", removeFlowsBatchInput.getBatchRemoveFlows().get(0).getFlowId().getValue()); - Assert.assertEquals("2", removeFlowsBatchInput.getBatchRemoveFlows().get(1).getFlowId().getValue()); + Assert.assertEquals("1", iterator.next().getFlowId().getValue()); + Assert.assertEquals("2", iterator.next().getFlowId().getValue()); } @Test @@ -111,11 +117,12 @@ public class FlatBatchFlowAdaptersTest { final UpdateFlowsBatchInput updateFlowsBatchInput = FlatBatchFlowAdapters.adaptFlatBatchUpdateFlow(planStep, NODE_REF); + Iterator iterator = updateFlowsBatchInput.nonnullBatchUpdateFlows().values().iterator(); Assert.assertTrue(updateFlowsBatchInput.isBarrierAfter()); Assert.assertEquals(2, updateFlowsBatchInput.getBatchUpdateFlows().size()); - Assert.assertEquals("1", updateFlowsBatchInput.getBatchUpdateFlows().get(0).getFlowId().getValue()); - Assert.assertEquals("2", updateFlowsBatchInput.getBatchUpdateFlows().get(1).getFlowId().getValue()); + Assert.assertEquals("1", iterator.next().getFlowId().getValue()); + Assert.assertEquals("2", iterator.next().getFlowId().getValue()); } @Test @@ -132,14 +139,17 @@ public class FlatBatchFlowAdaptersTest { final RpcResult rpcResult = FlatBatchFlowAdapters .convertBatchFlowResult(3).apply(input); + Iterator iterator = rpcResult.getResult().nonnullBatchFailure().values().iterator(); Assert.assertFalse(rpcResult.isSuccessful()); Assert.assertEquals(1, rpcResult.getErrors().size()); Assert.assertEquals(2, rpcResult.getResult().getBatchFailure().size()); - Assert.assertEquals(3, rpcResult.getResult().getBatchFailure().get(0).getBatchOrder().intValue()); - Assert.assertEquals(4, rpcResult.getResult().getBatchFailure().get(1).getBatchOrder().intValue()); + Assert.assertEquals(3, iterator.next() + .getBatchOrder().intValue()); + BatchFailure secondBatchFailure = iterator.next(); + Assert.assertEquals(4, secondBatchFailure.getBatchOrder().intValue()); Assert.assertEquals("f2", - ((FlatBatchFailureFlowIdCase) rpcResult.getResult().getBatchFailure().get(1).getBatchItemIdChoice()) + ((FlatBatchFailureFlowIdCase) secondBatchFailure.getBatchItemIdChoice()) .getFlowId().getValue()); } @@ -154,7 +164,7 @@ public class FlatBatchFlowAdaptersTest { Assert.assertTrue(rpcResult.isSuccessful()); Assert.assertEquals(0, rpcResult.getErrors().size()); - Assert.assertEquals(0, rpcResult.getResult().getBatchFailure().size()); + Assert.assertEquals(0, rpcResult.getResult().nonnullBatchFailure().size()); } private BatchFailedFlowsOutput createBatchFailedFlowsOutput(final Integer batchOrder, final String flowIdValue) { diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdaptersTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdaptersTest.java index e3a403caa5..4a6126f307 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdaptersTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchGroupAdaptersTest.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowplugin.impl.services.batch; import com.google.common.collect.Lists; +import java.util.Iterator; import org.junit.Assert; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput; @@ -28,10 +29,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.Ad import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.BatchGroupOutputListGrouping; import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.RemoveGroupsBatchInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.UpdateGroupsBatchInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.add.groups.batch.input.BatchAddGroups; import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.input.update.grouping.OriginalBatchedGroupBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.input.update.grouping.UpdatedBatchedGroupBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.output.list.grouping.BatchFailedGroupsOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.output.list.grouping.BatchFailedGroupsOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.remove.groups.batch.input.BatchRemoveGroups; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; @@ -62,11 +65,12 @@ public class FlatBatchGroupAdaptersTest { final AddGroupsBatchInput addGroupsBatchInput = FlatBatchGroupAdapters.adaptFlatBatchAddGroup(planStep, NODE_REF); + Iterator iterator = addGroupsBatchInput.nonnullBatchAddGroups().values().iterator(); Assert.assertTrue(addGroupsBatchInput.isBarrierAfter()); Assert.assertEquals(2, addGroupsBatchInput.getBatchAddGroups().size()); - Assert.assertEquals(1L, addGroupsBatchInput.getBatchAddGroups().get(0).getGroupId().getValue().longValue()); - Assert.assertEquals(2L, addGroupsBatchInput.getBatchAddGroups().get(1).getGroupId().getValue().longValue()); + Assert.assertEquals(1L, iterator.next().getGroupId().getValue().longValue()); + Assert.assertEquals(2L, iterator.next().getGroupId().getValue().longValue()); } private FlatBatchAddGroup createAddGroupBatch(final long groupIdValue) { @@ -102,13 +106,12 @@ public class FlatBatchGroupAdaptersTest { final RemoveGroupsBatchInput removeGroupsBatchInput = FlatBatchGroupAdapters.adaptFlatBatchRemoveGroup(planStep, NODE_REF); + Iterator iterator = removeGroupsBatchInput.nonnullBatchRemoveGroups().values().iterator(); Assert.assertTrue(removeGroupsBatchInput.isBarrierAfter()); Assert.assertEquals(2, removeGroupsBatchInput.getBatchRemoveGroups().size()); - Assert.assertEquals(1L, - removeGroupsBatchInput.getBatchRemoveGroups().get(0).getGroupId().getValue().longValue()); - Assert.assertEquals(2L, - removeGroupsBatchInput.getBatchRemoveGroups().get(1).getGroupId().getValue().longValue()); + Assert.assertEquals(1L, iterator.next().getGroupId().getValue().longValue()); + Assert.assertEquals(2L, iterator.next().getGroupId().getValue().longValue()); } @Test @@ -144,13 +147,15 @@ public class FlatBatchGroupAdaptersTest { final RpcResult rpcResult = FlatBatchGroupAdapters .convertBatchGroupResult(3).apply(input); + Iterator iterator = rpcResult.getResult().nonnullBatchFailure().values().iterator(); Assert.assertFalse(rpcResult.isSuccessful()); Assert.assertEquals(1, rpcResult.getErrors().size()); - Assert.assertEquals(2, rpcResult.getResult().getBatchFailure().size()); - Assert.assertEquals(3, rpcResult.getResult().getBatchFailure().get(0).getBatchOrder().intValue()); - Assert.assertEquals(4, rpcResult.getResult().getBatchFailure().get(1).getBatchOrder().intValue()); - Assert.assertEquals(2L, ((FlatBatchFailureGroupIdCase) rpcResult.getResult().getBatchFailure().get(1) + Assert.assertEquals(2, rpcResult.getResult().nonnullBatchFailure().size()); + Assert.assertEquals(3, iterator.next().getBatchOrder().intValue()); + BatchFailure secondBatchFailure = iterator.next(); + Assert.assertEquals(4, secondBatchFailure.getBatchOrder().intValue()); + Assert.assertEquals(2L, ((FlatBatchFailureGroupIdCase) secondBatchFailure .getBatchItemIdChoice()).getGroupId().getValue().longValue()); } @@ -165,7 +170,7 @@ public class FlatBatchGroupAdaptersTest { Assert.assertTrue(rpcResult.isSuccessful()); Assert.assertEquals(0, rpcResult.getErrors().size()); - Assert.assertEquals(0, rpcResult.getResult().getBatchFailure().size()); + Assert.assertEquals(0, rpcResult.getResult().nonnullBatchFailure().size()); } private BatchFailedGroupsOutput createBatchFailedGroupsOutput(final Integer batchOrder, final long groupIdValue) { diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdaptersTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdaptersTest.java index bf487d3e7e..ff9f50740f 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdaptersTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/batch/FlatBatchMeterAdaptersTest.java @@ -5,10 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.services.batch; import com.google.common.collect.Lists; +import java.util.Iterator; import org.junit.Assert; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput; @@ -33,10 +33,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.Ad import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.BatchMeterOutputListGrouping; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.RemoveMetersBatchInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.UpdateMetersBatchInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.add.meters.batch.input.BatchAddMeters; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.input.update.grouping.OriginalBatchedMeterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.input.update.grouping.UpdatedBatchedMeterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.remove.meters.batch.input.BatchRemoveMeters; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -64,9 +66,11 @@ public class FlatBatchMeterAdaptersTest { FlatBatchMeterAdapters.adaptFlatBatchAddMeter(planStep, NODE_REF); Assert.assertTrue(addMetersBatchInput.isBarrierAfter()); - Assert.assertEquals(2, addMetersBatchInput.getBatchAddMeters().size()); - Assert.assertEquals(1L, addMetersBatchInput.getBatchAddMeters().get(0).getMeterId().getValue().longValue()); - Assert.assertEquals(2L, addMetersBatchInput.getBatchAddMeters().get(1).getMeterId().getValue().longValue()); + Assert.assertEquals(2, addMetersBatchInput.nonnullBatchAddMeters().size()); + final Iterator it = addMetersBatchInput.nonnullBatchAddMeters().values().iterator(); + + Assert.assertEquals(1L, it.next().getMeterId().getValue().longValue()); + Assert.assertEquals(2L, it.next().getMeterId().getValue().longValue()); } private FlatBatchAddMeter createAddMeterBatch(final long groupIdValue) { @@ -102,13 +106,12 @@ public class FlatBatchMeterAdaptersTest { final RemoveMetersBatchInput removeMetersBatchInput = FlatBatchMeterAdapters.adaptFlatBatchRemoveMeter(planStep, NODE_REF); + Iterator iterator = removeMetersBatchInput.nonnullBatchRemoveMeters().values().iterator(); Assert.assertTrue(removeMetersBatchInput.isBarrierAfter()); - Assert.assertEquals(2, removeMetersBatchInput.getBatchRemoveMeters().size()); - Assert.assertEquals(1L, - removeMetersBatchInput.getBatchRemoveMeters().get(0).getMeterId().getValue().longValue()); - Assert.assertEquals(2L, - removeMetersBatchInput.getBatchRemoveMeters().get(1).getMeterId().getValue().longValue()); + Assert.assertEquals(2, removeMetersBatchInput.nonnullBatchRemoveMeters().size()); + Assert.assertEquals(1L, iterator.next().getMeterId().getValue().longValue()); + Assert.assertEquals(2L, iterator.next().getMeterId().getValue().longValue()); } @Test @@ -144,13 +147,15 @@ public class FlatBatchMeterAdaptersTest { final RpcResult rpcResult = FlatBatchMeterAdapters .convertBatchMeterResult(3).apply(input); + Iterator iterator = rpcResult.getResult().nonnullBatchFailure().values().iterator(); Assert.assertFalse(rpcResult.isSuccessful()); Assert.assertEquals(1, rpcResult.getErrors().size()); - Assert.assertEquals(2, rpcResult.getResult().getBatchFailure().size()); - Assert.assertEquals(3, rpcResult.getResult().getBatchFailure().get(0).getBatchOrder().intValue()); - Assert.assertEquals(4, rpcResult.getResult().getBatchFailure().get(1).getBatchOrder().intValue()); - Assert.assertEquals(2L, ((FlatBatchFailureMeterIdCase) rpcResult.getResult().getBatchFailure().get(1) + Assert.assertEquals(2, rpcResult.getResult().nonnullBatchFailure().size()); + Assert.assertEquals(3, iterator.next().getBatchOrder().intValue()); + BatchFailure secondBatchFailure = iterator.next(); + Assert.assertEquals(4, secondBatchFailure.getBatchOrder().intValue()); + Assert.assertEquals(2L, ((FlatBatchFailureMeterIdCase) secondBatchFailure .getBatchItemIdChoice()).getMeterId().getValue().longValue()); } @@ -165,7 +170,7 @@ public class FlatBatchMeterAdaptersTest { Assert.assertTrue(rpcResult.isSuccessful()); Assert.assertEquals(0, rpcResult.getErrors().size()); - Assert.assertEquals(0, rpcResult.getResult().getBatchFailure().size()); + Assert.assertEquals(0, rpcResult.getResult().nonnullBatchFailure().size()); } private BatchFailedMetersOutput createBatchFailedMetersOutput(final Integer batchOrder, final long groupIdValue) { diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalExperimenterMpMessageServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalExperimenterMpMessageServiceImplTest.java index 133ba53c61..47fcbea795 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalExperimenterMpMessageServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalExperimenterMpMessageServiceImplTest.java @@ -22,7 +22,6 @@ public class SalExperimenterMpMessageServiceImplTest extends ServiceMocking { private SalExperimenterMpMessageServiceImpl salExperimenterMpMessageService; @Override - @SuppressWarnings("unchecked") protected void setup() { this.>mockSuccessfulFuture(); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImplTest.java index 6b1752637c..dc02350ad6 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlatBatchServiceImplTest.java @@ -13,6 +13,7 @@ import com.google.common.util.concurrent.AsyncFunction; import com.google.common.util.concurrent.ListenableFuture; import java.util.ArrayList; import java.util.Collections; +import java.util.Iterator; import java.util.List; import java.util.concurrent.Future; import org.junit.After; @@ -37,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev16032 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.BatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.BatchKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddFlowCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddGroupCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddMeterCaseBuilder; @@ -48,6 +50,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev16032 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateMeterCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroupBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlowBuilder; @@ -162,9 +165,9 @@ public class SalFlatBatchServiceImplTest { createGroupRemoveBatch(4, 2L), createGroupUpdateBatch(5, 3L), - createMeterAddBatch(3, 1L), - createMeterRemoveBatch(4, 2L), - createMeterUpdateBatch(5, 3L) + createMeterAddBatch(6, 1L), + createMeterRemoveBatch(7, 2L), + createMeterUpdateBatch(8, 3L) )) .setExitOnFirstError(true) .build(); @@ -175,7 +178,7 @@ public class SalFlatBatchServiceImplTest { final RpcResult rpcResult = rpcResultFuture.get(); Assert.assertTrue(rpcResult.isSuccessful()); Assert.assertTrue(rpcResult.getErrors().isEmpty()); - Assert.assertTrue(rpcResult.getResult().getBatchFailure().isEmpty()); + Assert.assertTrue(rpcResult.getResult().nonnullBatchFailure().isEmpty()); final InOrder inOrder = Mockito.inOrder(salFlowsBatchService, salGroupsBatchService, salMetersBatchService); inOrder.verify(salFlowsBatchService).addFlowsBatch(ArgumentMatchers.any()); @@ -220,8 +223,9 @@ public class SalFlatBatchServiceImplTest { final RpcResult rpcResult = rpcResultFuture.get(); Assert.assertFalse(rpcResult.isSuccessful()); Assert.assertEquals(1, rpcResult.getErrors().size()); - Assert.assertEquals(1, rpcResult.getResult().getBatchFailure().size()); - Assert.assertEquals(3, rpcResult.getResult().getBatchFailure().get(0).getBatchOrder().intValue()); + Assert.assertEquals(1, rpcResult.getResult().nonnullBatchFailure().size()); + Assert.assertEquals(3, rpcResult.getResult().nonnullBatchFailure().values().iterator().next() + .getBatchOrder().intValue()); final InOrder inOrder = Mockito.inOrder(salFlowsBatchService, salGroupsBatchService, salMetersBatchService); inOrder.verify(salFlowsBatchService).addFlowsBatch(ArgumentMatchers.any()); @@ -259,8 +263,9 @@ public class SalFlatBatchServiceImplTest { final RpcResult rpcResult = rpcResultFuture.get(); Assert.assertFalse(rpcResult.isSuccessful()); Assert.assertEquals(1, rpcResult.getErrors().size()); - Assert.assertEquals(1, rpcResult.getResult().getBatchFailure().size()); - Assert.assertEquals(3, rpcResult.getResult().getBatchFailure().get(0).getBatchOrder().intValue()); + Assert.assertEquals(1, rpcResult.getResult().nonnullBatchFailure().size()); + Assert.assertEquals(3, rpcResult.getResult().nonnullBatchFailure().values().iterator().next() + .getBatchOrder().intValue()); final InOrder inOrder = Mockito.inOrder(salFlowsBatchService, salGroupsBatchService, salMetersBatchService); inOrder.verify(salFlowsBatchService).addFlowsBatch(ArgumentMatchers.any()); @@ -312,17 +317,26 @@ public class SalFlatBatchServiceImplTest { return createFlowAddBatch(batchOrder, flowIdValue, 1); } - private Batch createFlowAddBatch(final int batchOrder, final String flowIdValue, int amount) { + private Batch createFlowAddBatch(final int batchOrder, final String flowIdValue, final int amount) { return new BatchBuilder() .setBatchOrder(batchOrder) .setBatchChoice(new FlatBatchAddFlowCaseBuilder() - .setFlatBatchAddFlow(repeatInList(new FlatBatchAddFlowBuilder() - .setFlowId(new FlowId(flowIdValue)) - .build(), amount)) + .setFlatBatchAddFlow(repeatFlatBatchAddFlowInList(flowIdValue, amount)) .build()) .build(); } + private List repeatFlatBatchAddFlowInList(final String flowIdValue, final int amount) { + final List list = new ArrayList<>(); + for (int i = 0; i < amount; i++) { + list.add(new FlatBatchAddFlowBuilder() + .setFlowId(new FlowId(flowIdValue + i)) + .withKey(new FlatBatchAddFlowKey(i)) + .build()); + } + return list; + } + private List repeatInList(final T item, final int amount) { final List list = new ArrayList<>(); for (int i = 0; i < amount; i++) { @@ -345,6 +359,7 @@ public class SalFlatBatchServiceImplTest { private Batch createFlowUpdateBatch(final int batchOrder, final String flowIdValue) { return new BatchBuilder() .setBatchOrder(batchOrder) + .withKey(new BatchKey(batchOrder)) .setBatchChoice(new FlatBatchUpdateFlowCaseBuilder() .setFlatBatchUpdateFlow(Collections.singletonList(new FlatBatchUpdateFlowBuilder() .setFlowId(new FlowId(flowIdValue)) @@ -468,9 +483,12 @@ public class SalFlatBatchServiceImplTest { final RpcResult rpcResult = rpcResultFuture.get(); Assert.assertFalse(rpcResult.isSuccessful()); Assert.assertEquals(1, rpcResult.getErrors().size()); - Assert.assertEquals(2, rpcResult.getResult().getBatchFailure().size()); + Assert.assertEquals(2, rpcResult.getResult().nonnullBatchFailure().size()); + Iterator iterator = rpcResult.getResult().nonnullBatchFailure().values().iterator(); + //Moving iterator two get second element + iterator.next(); Assert.assertEquals("f2", - ((FlatBatchFailureFlowIdCase) rpcResult.getResult().getBatchFailure().get(1).getBatchItemIdChoice()) + ((FlatBatchFailureFlowIdCase) iterator.next().getBatchItemIdChoice()) .getFlowId().getValue()); } @@ -483,7 +501,7 @@ public class SalFlatBatchServiceImplTest { .build(); } - private ProcessFlatBatchOutput createFlatBatchOutput(BatchFailure... batchFailures) { + private ProcessFlatBatchOutput createFlatBatchOutput(final BatchFailure... batchFailures) { return new ProcessFlatBatchOutputBuilder() .setBatchFailure(Lists.newArrayList(batchFailures)) .build(); @@ -491,11 +509,14 @@ public class SalFlatBatchServiceImplTest { @Test public void testPrepareBatchPlan_success() throws Exception { - final FlatBatchAddFlow flatBatchAddFlow = new FlatBatchAddFlowBuilder() + final FlatBatchAddFlow flatBatchAddFlow_1 = new FlatBatchAddFlowBuilder() .setFlowId(new FlowId("f1")) .build(); + final FlatBatchAddFlow flatBatchAddFlow_2 = new FlatBatchAddFlowBuilder() + .setFlowId(new FlowId("f2")) + .build(); final BatchPlanStep batchPlanStep = new BatchPlanStep(BatchStepType.FLOW_ADD); - batchPlanStep.getTaskBag().addAll(Lists.newArrayList(flatBatchAddFlow, flatBatchAddFlow)); + batchPlanStep.getTaskBag().addAll(Lists.newArrayList(flatBatchAddFlow_1, flatBatchAddFlow_2)); final List batchPlan = Lists.newArrayList(batchPlanStep); final List batchChain = salFlatBatchService.prepareBatchChain(batchPlan, NODE_REF, true); @@ -513,18 +534,21 @@ public class SalFlatBatchServiceImplTest { final RpcResult rpcResult = rpcResultFuture.get(); Assert.assertTrue(rpcResult.isSuccessful()); Assert.assertEquals(0, rpcResult.getErrors().size()); - Assert.assertEquals(0, rpcResult.getResult().getBatchFailure().size()); + Assert.assertEquals(0, rpcResult.getResult().nonnullBatchFailure().size()); Mockito.verify(salFlowsBatchService).addFlowsBatch(ArgumentMatchers.any()); } @Test public void testPrepareBatchPlan_failure() throws Exception { - final FlatBatchAddFlow flatBatchAddFlow = new FlatBatchAddFlowBuilder() + final FlatBatchAddFlow flatBatchAddFlow_1 = new FlatBatchAddFlowBuilder() .setFlowId(new FlowId("f1")) .build(); + final FlatBatchAddFlow flatBatchAddFlow_2 = new FlatBatchAddFlowBuilder() + .setFlowId(new FlowId("f2")) + .build(); final BatchPlanStep batchPlanStep = new BatchPlanStep(BatchStepType.FLOW_ADD); - batchPlanStep.getTaskBag().addAll(Lists.newArrayList(flatBatchAddFlow, flatBatchAddFlow)); + batchPlanStep.getTaskBag().addAll(Lists.newArrayList(flatBatchAddFlow_1, flatBatchAddFlow_2)); final List batchPlan = Lists.newArrayList(batchPlanStep, batchPlanStep); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImplTest.java index c1766abe72..145d802a25 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowsBatchServiceImplTest.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowplugin.impl.services.sal; import com.google.common.collect.Lists; +import java.util.Iterator; import java.util.List; import java.util.concurrent.Future; import org.junit.After; @@ -50,6 +51,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.add import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.add.flows.batch.input.BatchAddFlowsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.input.update.grouping.OriginalBatchedFlowBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.input.update.grouping.UpdatedBatchedFlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.remove.flows.batch.input.BatchRemoveFlows; import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.remove.flows.batch.input.BatchRemoveFlowsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.update.flows.batch.input.BatchUpdateFlows; @@ -130,7 +132,7 @@ public class SalFlowsBatchServiceImplTest { final RpcResult rpcResult = resultFuture.get(); Assert.assertTrue(rpcResult.isSuccessful()); final RemoveFlowsBatchOutput result = rpcResult.getResult(); - Assert.assertEquals(0, result.getBatchFailedFlowsOutput().size()); + Assert.assertEquals(0, result.nonnullBatchFailedFlowsOutput().size()); final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService); @@ -165,9 +167,10 @@ public class SalFlowsBatchServiceImplTest { final RpcResult rpcResult = resultFuture.get(); Assert.assertFalse(rpcResult.isSuccessful()); final RemoveFlowsBatchOutput result = rpcResult.getResult(); - Assert.assertEquals(2, result.getBatchFailedFlowsOutput().size()); - Assert.assertEquals(FLOW_ID_VALUE_1, result.getBatchFailedFlowsOutput().get(0).getFlowId().getValue()); - Assert.assertEquals(FLOW_ID_VALUE_2, result.getBatchFailedFlowsOutput().get(1).getFlowId().getValue()); + Iterator iterator = result.nonnullBatchFailedFlowsOutput().values().iterator(); + Assert.assertEquals(2, result.nonnullBatchFailedFlowsOutput().size()); + Assert.assertEquals(FLOW_ID_VALUE_1, iterator.next().getFlowId().getValue()); + Assert.assertEquals(FLOW_ID_VALUE_2, iterator.next().getFlowId().getValue()); final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService); @@ -253,14 +256,14 @@ public class SalFlowsBatchServiceImplTest { .build(); final Future> resultFuture = salFlowsBatchService.addFlowsBatch(input); + Iterator iterator = resultFuture.get().getResult().nonnullBatchFailedFlowsOutput() + .values().iterator(); Assert.assertTrue(resultFuture.isDone()); Assert.assertFalse(resultFuture.get().isSuccessful()); - Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedFlowsOutput().size()); - Assert.assertEquals(FLOW_ID_VALUE_1, - resultFuture.get().getResult().getBatchFailedFlowsOutput().get(0).getFlowId().getValue()); - Assert.assertEquals(FLOW_ID_VALUE_2, - resultFuture.get().getResult().getBatchFailedFlowsOutput().get(1).getFlowId().getValue()); + Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedFlowsOutput().size()); + Assert.assertEquals(FLOW_ID_VALUE_1, iterator.next().getFlowId().getValue()); + Assert.assertEquals(FLOW_ID_VALUE_2, iterator.next().getFlowId().getValue()); Assert.assertEquals(2, resultFuture.get().getErrors().size()); final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService); @@ -321,15 +324,15 @@ public class SalFlowsBatchServiceImplTest { .build(); final Future> resultFuture = salFlowsBatchService.updateFlowsBatch(input); + Iterator iterator = resultFuture.get().getResult().nonnullBatchFailedFlowsOutput() + .values().iterator(); Assert.assertTrue(resultFuture.isDone()); Assert.assertFalse(resultFuture.get().isSuccessful()); Assert.assertFalse(resultFuture.get().isSuccessful()); - Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedFlowsOutput().size()); - Assert.assertEquals(FLOW_ID_VALUE_1, - resultFuture.get().getResult().getBatchFailedFlowsOutput().get(0).getFlowId().getValue()); - Assert.assertEquals(FLOW_ID_VALUE_2, - resultFuture.get().getResult().getBatchFailedFlowsOutput().get(1).getFlowId().getValue()); + Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedFlowsOutput().size()); + Assert.assertEquals(FLOW_ID_VALUE_1, iterator.next().getFlowId().getValue()); + Assert.assertEquals(FLOW_ID_VALUE_2, iterator.next().getFlowId().getValue()); Assert.assertEquals(2, resultFuture.get().getErrors().size()); final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImplTest.java index ec0576f9d4..ba70b49515 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupsBatchServiceImplTest.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowplugin.impl.services.sal; import com.google.common.collect.Lists; +import java.util.Iterator; import java.util.List; import java.util.concurrent.Future; import org.junit.After; @@ -49,6 +50,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.ad import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.add.groups.batch.input.BatchAddGroupsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.input.update.grouping.OriginalBatchedGroupBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.input.update.grouping.UpdatedBatchedGroupBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.output.list.grouping.BatchFailedGroupsOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.remove.groups.batch.input.BatchRemoveGroups; import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.remove.groups.batch.input.BatchRemoveGroupsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.update.groups.batch.input.BatchUpdateGroups; @@ -147,14 +149,14 @@ public class SalGroupsBatchServiceImplTest { .build(); final Future> resultFuture = salGroupsBatchService.updateGroupsBatch(input); + Iterator iterator = resultFuture.get().getResult().nonnullBatchFailedGroupsOutput() + .values().iterator(); Assert.assertTrue(resultFuture.isDone()); Assert.assertFalse(resultFuture.get().isSuccessful()); - Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedGroupsOutput().size()); - Assert.assertEquals(43L, - resultFuture.get().getResult().getBatchFailedGroupsOutput().get(0).getGroupId().getValue().longValue()); - Assert.assertEquals(45L, - resultFuture.get().getResult().getBatchFailedGroupsOutput().get(1).getGroupId().getValue().longValue()); + Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedGroupsOutput().size()); + Assert.assertEquals(43L, iterator.next().getGroupId().getValue().longValue()); + Assert.assertEquals(45L, iterator.next().getGroupId().getValue().longValue()); Assert.assertEquals(2, resultFuture.get().getErrors().size()); @@ -215,14 +217,14 @@ public class SalGroupsBatchServiceImplTest { .build(); final Future> resultFuture = salGroupsBatchService.addGroupsBatch(input); + Iterator iterator = resultFuture.get().getResult().nonnullBatchFailedGroupsOutput() + .values().iterator(); Assert.assertTrue(resultFuture.isDone()); Assert.assertFalse(resultFuture.get().isSuccessful()); - Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedGroupsOutput().size()); - Assert.assertEquals(42L, - resultFuture.get().getResult().getBatchFailedGroupsOutput().get(0).getGroupId().getValue().longValue()); - Assert.assertEquals(43L, - resultFuture.get().getResult().getBatchFailedGroupsOutput().get(1).getGroupId().getValue().longValue()); + Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedGroupsOutput().size()); + Assert.assertEquals(42L, iterator.next().getGroupId().getValue().longValue()); + Assert.assertEquals(43L, iterator.next().getGroupId().getValue().longValue()); Assert.assertEquals(2, resultFuture.get().getErrors().size()); @@ -281,14 +283,14 @@ public class SalGroupsBatchServiceImplTest { .build(); final Future> resultFuture = salGroupsBatchService.removeGroupsBatch(input); + Iterator iterator = resultFuture.get().getResult().nonnullBatchFailedGroupsOutput() + .values().iterator(); Assert.assertTrue(resultFuture.isDone()); Assert.assertFalse(resultFuture.get().isSuccessful()); - Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedGroupsOutput().size()); - Assert.assertEquals(42L, - resultFuture.get().getResult().getBatchFailedGroupsOutput().get(0).getGroupId().getValue().longValue()); - Assert.assertEquals(43L, - resultFuture.get().getResult().getBatchFailedGroupsOutput().get(1).getGroupId().getValue().longValue()); + Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedGroupsOutput().size()); + Assert.assertEquals(42L, iterator.next().getGroupId().getValue().longValue()); + Assert.assertEquals(43L, iterator.next().getGroupId().getValue().longValue()); Assert.assertEquals(2, resultFuture.get().getErrors().size()); final InOrder inOrder = Mockito.inOrder(salGroupService, transactionService); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImplTest.java index f5343fd5bc..e19e022e5a 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMetersBatchServiceImplTest.java @@ -11,6 +11,7 @@ package org.opendaylight.openflowplugin.impl.services.sal; import static org.mockito.ArgumentMatchers.any; import com.google.common.collect.Lists; +import java.util.Iterator; import java.util.List; import java.util.concurrent.Future; import org.junit.After; @@ -56,6 +57,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.ad import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.add.meters.batch.input.BatchAddMetersBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.input.update.grouping.OriginalBatchedMeterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.input.update.grouping.UpdatedBatchedMeterBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.remove.meters.batch.input.BatchRemoveMeters; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.remove.meters.batch.input.BatchRemoveMetersBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.update.meters.batch.input.BatchUpdateMeters; @@ -148,14 +150,14 @@ public class SalMetersBatchServiceImplTest { .build(); final Future> resultFuture = salMetersBatchService.updateMetersBatch(input); + Iterator iterator = resultFuture.get().getResult().nonnullBatchFailedMetersOutput() + .values().iterator(); Assert.assertTrue(resultFuture.isDone()); Assert.assertFalse(resultFuture.get().isSuccessful()); - Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedMetersOutput().size()); - Assert.assertEquals(43L, - resultFuture.get().getResult().getBatchFailedMetersOutput().get(0).getMeterId().getValue().longValue()); - Assert.assertEquals(45L, - resultFuture.get().getResult().getBatchFailedMetersOutput().get(1).getMeterId().getValue().longValue()); + Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedMetersOutput().size()); + Assert.assertEquals(43L, iterator.next().getMeterId().getValue().longValue()); + Assert.assertEquals(45L,iterator.next().getMeterId().getValue().longValue()); Assert.assertEquals(2, resultFuture.get().getErrors().size()); @@ -216,14 +218,14 @@ public class SalMetersBatchServiceImplTest { .build(); final Future> resultFuture = salMetersBatchService.addMetersBatch(input); + Iterator iterator = resultFuture.get().getResult().nonnullBatchFailedMetersOutput() + .values().iterator(); Assert.assertTrue(resultFuture.isDone()); Assert.assertFalse(resultFuture.get().isSuccessful()); - Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedMetersOutput().size()); - Assert.assertEquals(42L, - resultFuture.get().getResult().getBatchFailedMetersOutput().get(0).getMeterId().getValue().longValue()); - Assert.assertEquals(43L, - resultFuture.get().getResult().getBatchFailedMetersOutput().get(1).getMeterId().getValue().longValue()); + Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedMetersOutput().size()); + Assert.assertEquals(42L, iterator.next().getMeterId().getValue().longValue()); + Assert.assertEquals(43L,iterator.next().getMeterId().getValue().longValue()); Assert.assertEquals(2, resultFuture.get().getErrors().size()); @@ -282,14 +284,14 @@ public class SalMetersBatchServiceImplTest { .build(); final Future> resultFuture = salMetersBatchService.removeMetersBatch(input); + Iterator iterator = resultFuture.get().getResult().nonnullBatchFailedMetersOutput() + .values().iterator(); Assert.assertTrue(resultFuture.isDone()); Assert.assertFalse(resultFuture.get().isSuccessful()); - Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedMetersOutput().size()); - Assert.assertEquals(42L, - resultFuture.get().getResult().getBatchFailedMetersOutput().get(0).getMeterId().getValue().longValue()); - Assert.assertEquals(43L, - resultFuture.get().getResult().getBatchFailedMetersOutput().get(1).getMeterId().getValue().longValue()); + Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedMetersOutput().size()); + Assert.assertEquals(42L, iterator.next().getMeterId().getValue().longValue()); + Assert.assertEquals(43L, iterator.next().getMeterId().getValue().longValue()); Assert.assertEquals(2, resultFuture.get().getErrors().size()); final InOrder inOrder = Mockito.inOrder(salMeterService, transactionService); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartServiceTest.java index 624c6b44b6..50005bd334 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerTableMultipartServiceTest.java @@ -55,7 +55,7 @@ public class SingleLayerTableMultipartServiceTest extends ServiceMocking { final MultipartRequestTableFeatures result = (MultipartRequestTableFeatures) ((MultipartRequest) ofHeader) .getMultipartRequestBody(); - assertEquals(MAX_ENTRIES, result.getTableFeatures().get(0).getMaxEntries().longValue()); + assertEquals(MAX_ENTRIES, result.nonnullTableFeatures().values().iterator().next().getMaxEntries().longValue()); } @Test diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/MultipartReplyTranslatorTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/MultipartReplyTranslatorTest.java index 482cc61172..59a6b272ea 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/MultipartReplyTranslatorTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/MultipartReplyTranslatorTest.java @@ -14,7 +14,7 @@ import static org.mockito.Mockito.when; import com.google.common.collect.Lists; import java.util.Collections; -import java.util.List; +import java.util.Map; import org.junit.Before; import org.junit.Test; import org.opendaylight.openflowplugin.api.OFConstants; @@ -29,6 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupStatisticsReply; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.AggregateFlowStatistics; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType; @@ -145,11 +146,11 @@ public class MultipartReplyTranslatorTest { org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsAndPortNumberMap nodeConnectorStatisticsUpdate = (org.opendaylight.yang.gen.v1.urn .opendaylight.port.statistics.rev131214.NodeConnectorStatisticsAndPortNumberMap) dataObject; - List nodeConnectorStatisticsAndPortNumberMaps = - nodeConnectorStatisticsUpdate.getNodeConnectorStatisticsAndPortNumberMap(); + var nodeConnectorStatisticsAndPortNumberMaps = + nodeConnectorStatisticsUpdate.nonnullNodeConnectorStatisticsAndPortNumberMap(); assertEquals(1, nodeConnectorStatisticsAndPortNumberMaps.size()); NodeConnectorStatisticsAndPortNumberMap nodeConnectorStatisticsAndPortNumberMap = - nodeConnectorStatisticsAndPortNumberMaps.get(0); + nodeConnectorStatisticsAndPortNumberMaps.values().iterator().next(); assertEquals("openflow:" + DUMMY_DATAPATH_ID + ":" + DUMMY_PORT_NO, nodeConnectorStatisticsAndPortNumberMap.getNodeConnectorId().getValue()); assertEquals(DUMMY_RX_BYTES, nodeConnectorStatisticsAndPortNumberMap.getBytes().getReceived()); @@ -182,12 +183,9 @@ public class MultipartReplyTranslatorTest { DataContainer dataObject = validateOutput(result); assertTrue(dataObject instanceof GroupStatisticsReply); GroupStatisticsReply groupStatisticsUpdate = (GroupStatisticsReply)dataObject; - List groupStats = - groupStatisticsUpdate.getGroupStats(); + var groupStats = groupStatisticsUpdate.nonnullGroupStats(); assertEquals(1, groupStats.size()); - org.opendaylight.yang.gen.v1.urn - .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats groupStat = groupStats.get(0); + var groupStat = groupStats.values().iterator().next(); assertEquals(DUMMY_BYTE_COUNT, groupStat.getByteCount().getValue()); assertEquals(DUMMY_DURATION_SEC, groupStat.getDuration().getSecond().getValue()); @@ -213,9 +211,9 @@ public class MultipartReplyTranslatorTest { DataContainer dataObject = validateOutput(result); assertTrue(dataObject instanceof GroupDescStatsReply); GroupDescStatsReply groupStatistics = (GroupDescStatsReply) dataObject; - List groupDescStats = groupStatistics.getGroupDescStats(); + Map groupDescStats = groupStatistics.nonnullGroupDescStats(); assertEquals(1, groupDescStats.size()); - GroupDescStats groupDescStat = groupDescStats.get(0); + GroupDescStats groupDescStat = groupDescStats.values().iterator().next(); assertEquals(DUMMY_GROUP_ID.getValue(),groupDescStat.getGroupId().getValue()); assertEquals(DUMMY_GROUPS_TYPE,groupDescStat.getGroupType()); } diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java index a0798eeb48..cf941cb1bd 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/FlowDirectStatisticsServiceTest.java @@ -18,6 +18,7 @@ import static org.mockito.Mockito.when; import java.math.BigInteger; import java.util.Collections; import java.util.List; +import java.util.Map; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry; @@ -28,6 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowAndStatisticsMap; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; @@ -98,9 +100,9 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer when(reply.getMultipartReplyBody()).thenReturn(flowCase); final GetFlowStatisticsOutput output = service.buildReply(input, true); - assertTrue(output.getFlowAndStatisticsMapList().size() > 0); + assertTrue(output.nonnullFlowAndStatisticsMapList().size() > 0); - final FlowAndStatisticsMap stats = output.getFlowAndStatisticsMapList().get(0); + final FlowAndStatisticsMap stats = output.nonnullFlowAndStatisticsMapList().values().iterator().next(); assertEquals(stats.getTableId(), TABLE_NO); } @@ -111,9 +113,10 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer when(stat.getTableId()).thenReturn(TABLE_NO); when(stat.getMatch()).thenReturn(new MatchBuilder().build()); - final List stats = Collections.singletonList(stat); + final Map stats + = Collections.singletonMap(stat.key(), stat); final GetFlowStatisticsOutput output = mock(GetFlowStatisticsOutput.class); - when(output.getFlowAndStatisticsMapList()).thenReturn(stats); + when(output.nonnullFlowAndStatisticsMapList()).thenReturn(stats); multipartWriterProvider.lookup(MultipartType.OFPMPFLOW).get().write(output, true); verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java index 204d1a2a2c..bfab2a3667 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/GroupDirectStatisticsServiceTest.java @@ -91,24 +91,19 @@ public class GroupDirectStatisticsServiceTest extends AbstractDirectStatisticsSe assertTrue(output.getGroupStats().size() > 0); final org.opendaylight.yang.gen.v1.urn - .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stats = output.getGroupStats().get(0); + .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stats = + output.nonnullGroupStats().values().iterator().next(); assertEquals(stats.getGroupId().getValue(), GROUP_NO); } @Override public void testStoreStatistics() { - final org.opendaylight.yang.gen.v1.urn - .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stat = - mock(org.opendaylight.yang.gen.v1.urn - .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats.class); - when(stat.getGroupId()).thenReturn(new GroupId(GROUP_NO)); - - final List - stats = Collections.singletonList(stat); + final var stat = new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply + .GroupStatsBuilder().setGroupId(new GroupId(GROUP_NO)).build(); + final GetGroupStatisticsOutput output = mock(GetGroupStatisticsOutput.class); - when(output.getGroupStats()).thenReturn(stats); + when(output.nonnullGroupStats()).thenReturn(Collections.singletonMap(stat.key(), stat)); multipartWriterProvider.lookup(MultipartType.OFPMPGROUP).get().write(output, true); verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java index 6b323f3a21..b793bdfe7f 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/MeterDirectStatisticsServiceTest.java @@ -18,12 +18,14 @@ import static org.mockito.Mockito.when; import java.math.BigInteger; import java.util.Collections; import java.util.List; +import java.util.Map; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; @@ -77,10 +79,10 @@ public class MeterDirectStatisticsServiceTest extends AbstractDirectStatisticsSe when(reply.getMultipartReplyBody()).thenReturn(MeterCase); final GetMeterStatisticsOutput output = service.buildReply(input, true); - assertTrue(output.getMeterStats().size() > 0); + assertTrue(output.nonnullMeterStats().size() > 0); final org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats - stats = output.getMeterStats().get(0); + stats = output.nonnullMeterStats().values().iterator().next(); assertEquals(stats.getMeterId().getValue(), METER_NO); } @@ -91,13 +93,14 @@ public class MeterDirectStatisticsServiceTest extends AbstractDirectStatisticsSe = mock( org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats .class); + when(stat.key()).thenReturn(new MeterStatsKey(new MeterId(METER_NO))); when(stat.getMeterId()).thenReturn(new MeterId(METER_NO)); - final List - stats = Collections.singletonList(stat); + final Map + stats = Collections.singletonMap(stat.key(), stat); final GetMeterStatisticsOutput output = mock(GetMeterStatisticsOutput.class); - when(output.getMeterStats()).thenReturn(stats); + when(output.nonnullMeterStats()).thenReturn(stats); multipartWriterProvider.lookup(MultipartType.OFPMPMETER).get().write(output, true); verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/NodeConnectorDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/NodeConnectorDirectStatisticsServiceTest.java index e702635e74..2f3a5c2bdb 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/NodeConnectorDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/NodeConnectorDirectStatisticsServiceTest.java @@ -18,6 +18,7 @@ import static org.mockito.Mockito.when; import java.util.Collections; import java.util.List; +import java.util.Map; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest; @@ -32,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap; +import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey; import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint64; @@ -92,7 +94,7 @@ public class NodeConnectorDirectStatisticsServiceTest extends AbstractDirectStat assertTrue(output.getNodeConnectorStatisticsAndPortNumberMap().size() > 0); final NodeConnectorStatisticsAndPortNumberMap stats = - output.getNodeConnectorStatisticsAndPortNumberMap().get(0); + output.nonnullNodeConnectorStatisticsAndPortNumberMap().values().iterator().next(); assertEquals(stats.getNodeConnectorId(), nodeConnectorId); } @@ -100,11 +102,13 @@ public class NodeConnectorDirectStatisticsServiceTest extends AbstractDirectStat @Override public void testStoreStatistics() { final NodeConnectorStatisticsAndPortNumberMap stat = mock(NodeConnectorStatisticsAndPortNumberMap.class); + when(stat.key()).thenReturn(new NodeConnectorStatisticsAndPortNumberMapKey(nodeConnectorId)); when(stat.getNodeConnectorId()).thenReturn(nodeConnectorId); - final List stats = Collections.singletonList(stat); + final Map stats + = Collections.singletonMap(stat.key(), stat); final GetNodeConnectorStatisticsOutput output = mock(GetNodeConnectorStatisticsOutput.class); - when(output.getNodeConnectorStatisticsAndPortNumberMap()).thenReturn(stats); + when(output.nonnullNodeConnectorStatisticsAndPortNumberMap()).thenReturn(stats); multipartWriterProvider.lookup(MultipartType.OFPMPPORTSTATS).get().write(output, true); verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/QueueDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/QueueDirectStatisticsServiceTest.java index 3af233d84e..5427613e2d 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/QueueDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/multilayer/QueueDirectStatisticsServiceTest.java @@ -18,6 +18,7 @@ import static org.mockito.Mockito.when; import java.util.Collections; import java.util.List; +import java.util.Map; import org.junit.Test; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; @@ -35,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueue; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap; +import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapKey; import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint64; @@ -90,9 +92,9 @@ public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsSe when(queueStat.getDurationNsec()).thenReturn(Uint32.ZERO); final GetQueueStatisticsOutput output = service.buildReply(input, true); - assertTrue(output.getQueueIdAndStatisticsMap().size() > 0); + assertTrue(output.nonnullQueueIdAndStatisticsMap().size() > 0); - final QueueIdAndStatisticsMap map = output.getQueueIdAndStatisticsMap().get(0); + final QueueIdAndStatisticsMap map = output.nonnullQueueIdAndStatisticsMap().values().iterator().next(); assertEquals(map.getQueueId().getValue(), QUEUE_NO); assertEquals(map.getNodeConnectorId(), nodeConnectorId); } @@ -102,10 +104,12 @@ public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsSe final QueueIdAndStatisticsMap map = mock(QueueIdAndStatisticsMap.class); when(map.getQueueId()).thenReturn(new QueueId(QUEUE_NO)); when(map.getNodeConnectorId()).thenReturn(new NodeConnectorId("1")); + when(map.key()).thenReturn(new QueueIdAndStatisticsMapKey(new NodeConnectorId("1"), new QueueId(QUEUE_NO))); - final List maps = Collections.singletonList(map); + final Map maps + = Collections.singletonMap(map.key(), map); final GetQueueStatisticsOutput output = mock(GetQueueStatisticsOutput.class); - when(output.getQueueIdAndStatisticsMap()).thenReturn(maps); + when(output.nonnullQueueIdAndStatisticsMap()).thenReturn(maps); multipartWriterProvider.lookup(MultipartType.OFPMPQUEUE).get().write(output, true); verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any()); @@ -116,10 +120,13 @@ public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsSe final QueueIdAndStatisticsMap map = mock(QueueIdAndStatisticsMap.class); when(map.getQueueId()).thenReturn(new QueueId(QUEUE_NO)); when(map.getNodeConnectorId()).thenReturn(new NodeConnectorId("openflow:1:1")); + when(map.key()).thenReturn(new QueueIdAndStatisticsMapKey(new NodeConnectorId("openflow:1:1"), + new QueueId(QUEUE_NO))); - final List maps = Collections.singletonList(map); + final Map maps + = Collections.singletonMap(map.key(), map); final GetQueueStatisticsOutput output = mock(GetQueueStatisticsOutput.class); - when(output.getQueueIdAndStatisticsMap()).thenReturn(maps); + when(output.nonnullQueueIdAndStatisticsMap()).thenReturn(maps); multipartWriterProvider.lookup(MultipartType.OFPMPQUEUE).get().write(output, true); verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java index 23ab51a41d..06753337c0 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java @@ -18,6 +18,7 @@ import static org.mockito.Mockito.when; import java.math.BigInteger; import java.util.Collections; import java.util.List; +import java.util.Map; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry; @@ -31,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.Fl import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowAndStatisticsMap; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder; @@ -96,7 +98,7 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer final GetFlowStatisticsOutput output = service.buildReply(input, true); assertTrue(output.getFlowAndStatisticsMapList().size() > 0); - final FlowAndStatisticsMap stats = output.getFlowAndStatisticsMapList().get(0); + final FlowAndStatisticsMap stats = output.nonnullFlowAndStatisticsMapList().values().iterator().next(); assertEquals(stats.getTableId(), TABLE_NO); } @@ -107,9 +109,10 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer when(stat.getTableId()).thenReturn(TABLE_NO); when(stat.getMatch()).thenReturn(new MatchBuilder().build()); - final List stats = Collections.singletonList(stat); + final Map stats + = Collections.singletonMap(stat.key(), stat); final GetFlowStatisticsOutput output = mock(GetFlowStatisticsOutput.class); - when(output.getFlowAndStatisticsMapList()).thenReturn(stats); + when(output.nonnullFlowAndStatisticsMapList()).thenReturn(stats); multipartWriterProvider.lookup(MultipartType.OFPMPFLOW).get().write(output, true); verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java index dce3d3ea5e..5087f4b09a 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/GroupDirectStatisticsServiceTest.java @@ -18,6 +18,7 @@ import static org.mockito.Mockito.when; import java.util.Collections; import java.util.List; +import java.util.Map; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest; @@ -28,6 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111. import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply; import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequest; @@ -75,10 +77,11 @@ public class GroupDirectStatisticsServiceTest extends AbstractDirectStatisticsSe final List input = Collections.singletonList(reply); final GetGroupStatisticsOutput output = service.buildReply(input, true); - assertTrue(output.getGroupStats().size() > 0); + assertTrue(output.nonnullGroupStats().size() > 0); final org.opendaylight.yang.gen.v1.urn - .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stats = output.getGroupStats().get(0); + .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stats = + output.nonnullGroupStats().values().iterator().next(); assertEquals(stats.getGroupId().getValue(), GROUP_NO); } @@ -91,11 +94,9 @@ public class GroupDirectStatisticsServiceTest extends AbstractDirectStatisticsSe .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats.class); when(stat.getGroupId()).thenReturn(new GroupId(GROUP_NO)); - final List - stats = Collections.singletonList(stat); + final Map stats = Collections.singletonMap(stat.key(), stat); final GetGroupStatisticsOutput output = mock(GetGroupStatisticsOutput.class); - when(output.getGroupStats()).thenReturn(stats); + when(output.nonnullGroupStats()).thenReturn(stats); multipartWriterProvider.lookup(MultipartType.OFPMPGROUP).get().write(output, true); verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java index d61b1cf118..4af0163a39 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/MeterDirectStatisticsServiceTest.java @@ -19,6 +19,7 @@ import static org.mockito.Mockito.when; import java.math.BigInteger; import java.util.Collections; import java.util.List; +import java.util.Map; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest; @@ -33,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.MeterBandStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply; import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequest; @@ -88,9 +90,9 @@ public class MeterDirectStatisticsServiceTest extends AbstractDirectStatisticsSe final List input = Collections.singletonList(reply); final GetMeterStatisticsOutput output = service.buildReply(input, true); - assertTrue(output.getMeterStats().size() > 0); + assertTrue(output.nonnullMeterStats().size() > 0); - final MeterStats stats = output.getMeterStats().get(0); + final MeterStats stats = output.nonnullMeterStats().values().iterator().next(); assertEquals(stats.getMeterId().getValue(), METER_NO); } @@ -102,11 +104,11 @@ public class MeterDirectStatisticsServiceTest extends AbstractDirectStatisticsSe .opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats.class); when(stat.getMeterId()).thenReturn(new MeterId(METER_NO)); - final List - stats = Collections.singletonList(stat); + stats = Collections.singletonMap(stat.key(), stat); final GetMeterStatisticsOutput output = mock(GetMeterStatisticsOutput.class); - when(output.getMeterStats()).thenReturn(stats); + when(output.nonnullMeterStats()).thenReturn(stats); multipartWriterProvider.lookup(MultipartType.OFPMPMETER).get().write(output, true); verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/NodeConnectorDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/NodeConnectorDirectStatisticsServiceTest.java index 932f659898..53e1986ea8 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/NodeConnectorDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/NodeConnectorDirectStatisticsServiceTest.java @@ -18,6 +18,7 @@ import static org.mockito.Mockito.when; import java.util.Collections; import java.util.List; +import java.util.Map; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest; @@ -31,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.m import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.request.multipart.request.body.MultipartRequestPortStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap; import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey; import org.opendaylight.yangtools.yang.common.Uint32; public class NodeConnectorDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { @@ -72,10 +74,10 @@ public class NodeConnectorDirectStatisticsServiceTest extends AbstractDirectStat final List input = Collections.singletonList(reply); final GetNodeConnectorStatisticsOutput output = service.buildReply(input, true); - assertTrue(output.getNodeConnectorStatisticsAndPortNumberMap().size() > 0); + assertTrue(output.nonnullNodeConnectorStatisticsAndPortNumberMap().size() > 0); final NodeConnectorStatisticsAndPortNumberMap stats = - output.getNodeConnectorStatisticsAndPortNumberMap().get(0); + output.nonnullNodeConnectorStatisticsAndPortNumberMap().values().iterator().next(); assertEquals(stats.getNodeConnectorId(), nodeConnectorId); } @@ -85,9 +87,10 @@ public class NodeConnectorDirectStatisticsServiceTest extends AbstractDirectStat final NodeConnectorStatisticsAndPortNumberMap stat = mock(NodeConnectorStatisticsAndPortNumberMap.class); when(stat.getNodeConnectorId()).thenReturn(nodeConnectorId); - final List stats = Collections.singletonList(stat); + final Map stats + = Collections.singletonMap(stat.key(), stat); final GetNodeConnectorStatisticsOutput output = mock(GetNodeConnectorStatisticsOutput.class); - when(output.getNodeConnectorStatisticsAndPortNumberMap()).thenReturn(stats); + when(output.nonnullNodeConnectorStatisticsAndPortNumberMap()).thenReturn(stats); multipartWriterProvider.lookup(MultipartType.OFPMPPORTSTATS).get().write(output, true); verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java index bb50e72972..0ea3df60de 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/QueueDirectStatisticsServiceTest.java @@ -19,6 +19,7 @@ import static org.mockito.Mockito.when; import java.math.BigInteger; import java.util.Collections; import java.util.List; +import java.util.Map; import org.junit.Test; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.openflowplugin.api.openflow.device.Xid; @@ -36,6 +37,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216. import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.request.multipart.request.body.MultipartRequestQueueStats; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap; import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapKey; import org.opendaylight.yangtools.yang.common.Uint32; public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest { @@ -84,9 +86,9 @@ public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsSe final List input = Collections.singletonList(reply); final GetQueueStatisticsOutput output = service.buildReply(input, true); - assertTrue(output.getQueueIdAndStatisticsMap().size() > 0); + assertTrue(output.nonnullQueueIdAndStatisticsMap().size() > 0); - final QueueIdAndStatisticsMap map = output.getQueueIdAndStatisticsMap().get(0); + final QueueIdAndStatisticsMap map = output.nonnullQueueIdAndStatisticsMap().values().iterator().next(); assertEquals(map.getQueueId().getValue(), QUEUE_NO); assertEquals(map.getNodeConnectorId().getValue(), PORT_NO.toString()); } @@ -96,10 +98,12 @@ public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsSe final QueueIdAndStatisticsMap map = mock(QueueIdAndStatisticsMap.class); when(map.getQueueId()).thenReturn(new QueueId(QUEUE_NO)); when(map.getNodeConnectorId()).thenReturn(new NodeConnectorId("1")); + when(map.key()).thenReturn( + new QueueIdAndStatisticsMapKey(new NodeConnectorId("1"), new QueueId(QUEUE_NO))); - final List maps = Collections.singletonList(map); final GetQueueStatisticsOutput output = mock(GetQueueStatisticsOutput.class); - when(output.getQueueIdAndStatisticsMap()).thenReturn(maps); + Map stats = Collections.singletonMap(map.key(), map); + when(output.nonnullQueueIdAndStatisticsMap()).thenReturn(stats); multipartWriterProvider.lookup(MultipartType.OFPMPQUEUE).get().write(output, true); verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any()); @@ -110,10 +114,12 @@ public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsSe final QueueIdAndStatisticsMap map = mock(QueueIdAndStatisticsMap.class); when(map.getQueueId()).thenReturn(new QueueId(QUEUE_NO)); when(map.getNodeConnectorId()).thenReturn(new NodeConnectorId("openflow:1:1")); + when(map.key()).thenReturn( + new QueueIdAndStatisticsMapKey(new NodeConnectorId("openflow:1:1"), new QueueId(QUEUE_NO))); - final List maps = Collections.singletonList(map); + final Map maps = Collections.singletonMap(map.key(), map); final GetQueueStatisticsOutput output = mock(GetQueueStatisticsOutput.class); - when(output.getQueueIdAndStatisticsMap()).thenReturn(maps); + when(output.nonnullQueueIdAndStatisticsMap()).thenReturn(maps); multipartWriterProvider.lookup(MultipartType.OFPMPQUEUE).get().write(output, true); verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslatorTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslatorTest.java index 5f687db198..46febc66c9 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslatorTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslatorTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.translator; import org.junit.Assert; @@ -76,10 +75,10 @@ public class PortUpdateTranslatorTest { Assert.assertEquals(portFeatures, nodeConnector.getPeerFeatures()); Assert.assertEquals(portFeatures, nodeConnector.getSupported()); Assert.assertEquals(portStateBld.build(), nodeConnector.getState()); - Assert.assertTrue(nodeConnector.getQueue().isEmpty()); + Assert.assertNull(nodeConnector.getQueue()); } - private void commonCheck(FlowCapableNodeConnector nodeConnector) { + private static void commonCheck(final FlowCapableNodeConnector nodeConnector) { Assert.assertEquals(84L, nodeConnector.getCurrentSpeed().longValue()); Assert.assertEquals(84L * 2, nodeConnector.getMaximumSpeed().longValue()); Assert.assertEquals("utPortName:21", nodeConnector.getName()); @@ -110,7 +109,7 @@ public class PortUpdateTranslatorTest { Assert.assertNull(nodeConnector.getQueue()); } - private PortStatusMessageBuilder assemblePortStatusMessage(long portNoValue, long speed) { + private static PortStatusMessageBuilder assemblePortStatusMessage(final long portNoValue, final long speed) { final PortFeatures portFeatures13 = PortFeatures.getDefaultInstance("_100gbFd"); final PortFeaturesV10 portFeatures10 = PortFeaturesV10.getDefaultInstance("_100mbFd"); final PortConfig portConfig13 = PortConfig.getDefaultInstance("noFwd"); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtilTest.java index 545066a0b6..6c99feb20a 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlatBatchUtilTest.java @@ -30,22 +30,42 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev16032 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateFlowCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateGroupCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateMeterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroup; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroupBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroupKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeter; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeterBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeterKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlow; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlowKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.group._case.FlatBatchRemoveGroup; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.group._case.FlatBatchRemoveGroupBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.group._case.FlatBatchRemoveGroupKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeter; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeterBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeterKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlow; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlowKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.group._case.FlatBatchUpdateGroup; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.group._case.FlatBatchUpdateGroupBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.group._case.FlatBatchUpdateGroupKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.meter._case.FlatBatchUpdateMeter; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.meter._case.FlatBatchUpdateMeterBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.meter._case.FlatBatchUpdateMeterKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailureBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailureKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.batch.failure.batch.item.id.choice.FlatBatchFailureFlowIdCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -206,47 +226,47 @@ public class FlatBatchUtilTest { switch (type) { case FLOW_ADD: batchCase = new FlatBatchAddFlowCaseBuilder() - .setFlatBatchAddFlow(repeatIntoList(new FlatBatchAddFlowBuilder().build(), size)) + .setFlatBatchAddFlow(repeatFlatBatchAddFlowIntoList(size)) .build(); break; case FLOW_REMOVE: batchCase = new FlatBatchRemoveFlowCaseBuilder() - .setFlatBatchRemoveFlow(repeatIntoList(new FlatBatchRemoveFlowBuilder().build(), size)) + .setFlatBatchRemoveFlow(repeatFlatBatchRemoveFlowIntoList(size)) .build(); break; case FLOW_UPDATE: batchCase = new FlatBatchUpdateFlowCaseBuilder() - .setFlatBatchUpdateFlow(repeatIntoList(new FlatBatchUpdateFlowBuilder().build(), size)) + .setFlatBatchUpdateFlow(repeatFlatBatchUpdateFlowIntoList(size)) .build(); break; case GROUP_ADD: batchCase = new FlatBatchAddGroupCaseBuilder() - .setFlatBatchAddGroup(repeatIntoList(new FlatBatchAddGroupBuilder().build(), size)) + .setFlatBatchAddGroup(repeatFlatBatchAddGroupIntoList(size)) .build(); break; case GROUP_REMOVE: batchCase = new FlatBatchRemoveGroupCaseBuilder() - .setFlatBatchRemoveGroup(repeatIntoList(new FlatBatchRemoveGroupBuilder().build(), size)) + .setFlatBatchRemoveGroup(repeatFlatBatchRemoveGroupIntoList(size)) .build(); break; case GROUP_UPDATE: batchCase = new FlatBatchUpdateGroupCaseBuilder() - .setFlatBatchUpdateGroup(repeatIntoList(new FlatBatchUpdateGroupBuilder().build(), size)) + .setFlatBatchUpdateGroup(repeatFlatBatchUpdateGroupIntoList(size)) .build(); break; case METER_ADD: batchCase = new FlatBatchAddMeterCaseBuilder() - .setFlatBatchAddMeter(repeatIntoList(new FlatBatchAddMeterBuilder().build(), size)) + .setFlatBatchAddMeter(repeatFlatBatchAddMeterIntoList(size)) .build(); break; case METER_REMOVE: batchCase = new FlatBatchRemoveMeterCaseBuilder() - .setFlatBatchRemoveMeter(repeatIntoList(new FlatBatchRemoveMeterBuilder().build(), size)) + .setFlatBatchRemoveMeter(repeatFlatBatchRemoveMeterIntoList(size)) .build(); break; case METER_UPDATE: batchCase = new FlatBatchUpdateMeterCaseBuilder() - .setFlatBatchUpdateMeter(repeatIntoList(new FlatBatchUpdateMeterBuilder().build(), size)) + .setFlatBatchUpdateMeter(repeatFlatBatchUpdateMeterIntoList(size)) .build(); break; default: @@ -259,10 +279,74 @@ public class FlatBatchUtilTest { .build(); } - private List repeatIntoList(final T element, final int size) { - final List list = new ArrayList<>(); + private List repeatFlatBatchAddGroupIntoList(final int size) { + final List list = new ArrayList<>(); for (int i = 0; i < size; i++) { - list.add(element); + list.add(new FlatBatchAddGroupBuilder().withKey(new FlatBatchAddGroupKey(i)).build()); + } + return list; + } + + private List repeatFlatBatchUpdateGroupIntoList(final int size) { + final List list = new ArrayList<>(); + for (int i = 0; i < size; i++) { + list.add(new FlatBatchUpdateGroupBuilder().withKey(new FlatBatchUpdateGroupKey(i)).build()); + } + return list; + } + + private List repeatFlatBatchRemoveGroupIntoList(final int size) { + final List list = new ArrayList<>(); + for (int i = 0; i < size; i++) { + list.add(new FlatBatchRemoveGroupBuilder().withKey(new FlatBatchRemoveGroupKey(i)).build()); + } + return list; + } + + private List repeatFlatBatchAddFlowIntoList(final int size) { + final List list = new ArrayList<>(); + for (int i = 0; i < size; i++) { + list.add(new FlatBatchAddFlowBuilder().withKey(new FlatBatchAddFlowKey(i)).build()); + } + return list; + } + + private List repeatFlatBatchUpdateFlowIntoList(final int size) { + final List list = new ArrayList<>(); + for (int i = 0; i < size; i++) { + list.add(new FlatBatchUpdateFlowBuilder().withKey(new FlatBatchUpdateFlowKey(i)).build()); + } + return list; + } + + private List repeatFlatBatchRemoveFlowIntoList(final int size) { + final List list = new ArrayList<>(); + for (int i = 0; i < size; i++) { + list.add(new FlatBatchRemoveFlowBuilder().withKey(new FlatBatchRemoveFlowKey(i)).build()); + } + return list; + } + + private List repeatFlatBatchAddMeterIntoList(final int size) { + final List list = new ArrayList<>(); + for (int i = 0; i < size; i++) { + list.add(new FlatBatchAddMeterBuilder().withKey(new FlatBatchAddMeterKey(i)).build()); + } + return list; + } + + private List repeatFlatBatchUpdateMeterIntoList(final int size) { + final List list = new ArrayList<>(); + for (int i = 0; i < size; i++) { + list.add(new FlatBatchUpdateMeterBuilder().withKey(new FlatBatchUpdateMeterKey(i)).build()); + } + return list; + } + + private List repeatFlatBatchRemoveMeterIntoList(final int size) { + final List list = new ArrayList<>(); + for (int i = 0; i < size; i++) { + list.add(new FlatBatchRemoveMeterBuilder().withKey(new FlatBatchRemoveMeterKey(i)).build()); } return list; } @@ -274,14 +358,29 @@ public class FlatBatchUtilTest { .setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder() .setFlowId(new FlowId("11")) .build()) + .withKey(new BatchFailureKey(Uint16.ZERO)) + .build(); + final BatchFailure batchFailure_1 = new BatchFailureBuilder() + .setBatchOrder(9) + .setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder() + .setFlowId(new FlowId("11")) + .build()) + .withKey(new BatchFailureKey(Uint16.ONE)) .build(); final ProcessFlatBatchOutput output = new ProcessFlatBatchOutputBuilder().setBatchFailure(Lists.newArrayList(batchFailure)).build(); + final ProcessFlatBatchOutput output_1 + = new ProcessFlatBatchOutputBuilder().setBatchFailure(Lists.newArrayList(batchFailure_1)).build(); + final RpcResult rpcResultFailed = RpcResultBuilder.failed() .withError(RpcError.ErrorType.APPLICATION, "ut-rpcError") .withResult(output).build(); + + final RpcResult rpcResultFailed_1 = RpcResultBuilder.failed() + .withError(RpcError.ErrorType.APPLICATION, "ut-rpcError") + .withResult(output_1).build(); final RpcResult rpcResultSuccess = RpcResultBuilder.success() .withResult(new ProcessFlatBatchOutputBuilder().setBatchFailure(new ArrayList<>())).build(); @@ -291,7 +390,7 @@ public class FlatBatchUtilTest { Assert.assertFalse(rpcResult1.isSuccessful()); final RpcResult rpcResult2 - = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultFailed, rpcResultFailed)); + = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultFailed, rpcResultFailed_1)); Assert.assertEquals(2, rpcResult2.getErrors().size()); Assert.assertFalse(rpcResult2.isSuccessful()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java index 244a1142c3..83b1653833 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/FlowUtilTest.java @@ -11,6 +11,7 @@ package org.opendaylight.openflowplugin.impl.util; import com.google.common.collect.Lists; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.function.Function; import org.apache.commons.lang3.tuple.Pair; import org.junit.Assert; @@ -27,6 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.Bat import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.BatchFlowOutputListGrouping; import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutputKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; @@ -120,17 +122,19 @@ public class FlowUtilTest { private void checkBatchSuccessOutcomeTransformation( final RpcResult output) { Assert.assertTrue(output.isSuccessful()); - Assert.assertEquals(0, output.getResult().getBatchFailedFlowsOutput().size()); + Map failedFlows + = output.getResult().nonnullBatchFailedFlowsOutput(); + Assert.assertEquals(0, failedFlows.size()); Assert.assertEquals(0, output.getErrors().size()); } - private RpcResult> createEmptyBatchOutcome() { + private static RpcResult> createEmptyBatchOutcome() { return RpcResultBuilder .success(Collections.emptyList()) .build(); } - private RpcResult> createBatchOutcomeWithError() { + private static RpcResult> createBatchOutcomeWithError() { return RpcResultBuilder.>failed() .withError(RpcError.ErrorType.APPLICATION, "ut-flowAddFail") .withResult(Collections.singletonList(new BatchFailedFlowsOutputBuilder() @@ -139,11 +143,12 @@ public class FlowUtilTest { .build(); } - private void checkBatchErrorOutcomeTransformation( + private static void checkBatchErrorOutcomeTransformation( final RpcResult output) { Assert.assertFalse(output.isSuccessful()); - Assert.assertEquals(1, output.getResult().getBatchFailedFlowsOutput().size()); - Assert.assertEquals(DUMMY_FLOW_ID, output.getResult().getBatchFailedFlowsOutput().get(0).getFlowId()); + Assert.assertEquals(1, output.getResult().nonnullBatchFailedFlowsOutput().size()); + Assert.assertEquals(DUMMY_FLOW_ID, + output.getResult().nonnullBatchFailedFlowsOutput().values().iterator().next().getFlowId()); Assert.assertEquals(1, output.getErrors().size()); } @@ -161,7 +166,9 @@ public class FlowUtilTest { Assert.assertTrue(composite.isSuccessful()); Assert.assertEquals(0, composite.getErrors().size()); - Assert.assertEquals(0, composite.getResult().getBatchFailedFlowsOutput().size()); + Map failedFlows + = composite.getResult().nonnullBatchFailedFlowsOutput(); + Assert.assertEquals(0, failedFlows.size()); } @Test @@ -193,7 +200,9 @@ public class FlowUtilTest { Assert.assertFalse(composite.isSuccessful()); Assert.assertEquals(1, composite.getErrors().size()); - Assert.assertEquals(0, composite.getResult().getBatchFailedFlowsOutput().size()); + Map failedFlows + = composite.getResult().nonnullBatchFailedFlowsOutput(); + Assert.assertEquals(0, failedFlows.size()); } @Test diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java index 9384121a97..9185c4a428 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/GroupUtilTest.java @@ -120,20 +120,20 @@ public class GroupUtilTest { checkBatchSuccessOutcomeTransformation(GroupUtil.GROUP_UPDATE_TRANSFORM.apply(input)); } - private void checkBatchSuccessOutcomeTransformation( + private static void checkBatchSuccessOutcomeTransformation( final RpcResult output) { Assert.assertTrue(output.isSuccessful()); - Assert.assertEquals(0, output.getResult().getBatchFailedGroupsOutput().size()); + Assert.assertEquals(0, output.getResult().nonnullBatchFailedGroupsOutput().size()); Assert.assertEquals(0, output.getErrors().size()); } - private RpcResult> createEmptyBatchOutcome() { + private static RpcResult> createEmptyBatchOutcome() { return RpcResultBuilder .success(Collections.emptyList()) .build(); } - private RpcResult> createBatchOutcomeWithError() { + private static RpcResult> createBatchOutcomeWithError() { return RpcResultBuilder.>failed() .withError(RpcError.ErrorType.APPLICATION, "ut-flowAddFail") .withResult(Collections.singletonList(new BatchFailedGroupsOutputBuilder() @@ -142,11 +142,12 @@ public class GroupUtilTest { .build(); } - private void checkBatchErrorOutcomeTransformation( + private static void checkBatchErrorOutcomeTransformation( final RpcResult output) { Assert.assertFalse(output.isSuccessful()); - Assert.assertEquals(1, output.getResult().getBatchFailedGroupsOutput().size()); - Assert.assertEquals(DUMMY_GROUP_ID, output.getResult().getBatchFailedGroupsOutput().get(0).getGroupId()); + Assert.assertEquals(1, output.getResult().nonnullBatchFailedGroupsOutput().size()); + Assert.assertEquals(DUMMY_GROUP_ID, + output.getResult().nonnullBatchFailedGroupsOutput().values().iterator().next().getGroupId()); Assert.assertEquals(1, output.getErrors().size()); } @@ -164,7 +165,7 @@ public class GroupUtilTest { Assert.assertTrue(composite.isSuccessful()); Assert.assertEquals(0, composite.getErrors().size()); - Assert.assertEquals(0, composite.getResult().getBatchFailedGroupsOutput().size()); + Assert.assertEquals(0, composite.getResult().nonnullBatchFailedGroupsOutput().size()); } @Test @@ -196,7 +197,7 @@ public class GroupUtilTest { Assert.assertFalse(composite.isSuccessful()); Assert.assertEquals(1, composite.getErrors().size()); - Assert.assertEquals(0, composite.getResult().getBatchFailedGroupsOutput().size()); + Assert.assertEquals(0, composite.getResult().nonnullBatchFailedGroupsOutput().size()); } @Test diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MeterUtilTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MeterUtilTest.java index 7fa7ebcb02..a822c71d01 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MeterUtilTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/MeterUtilTest.java @@ -12,6 +12,7 @@ import com.google.common.base.Function; import com.google.common.collect.Lists; import java.util.Collections; import java.util.List; +import java.util.Map; import org.apache.commons.lang3.tuple.Pair; import org.junit.Assert; import org.junit.Test; @@ -29,6 +30,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.Ad import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.BatchMeterOutputListGrouping; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutputKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -117,20 +119,20 @@ public class MeterUtilTest { checkBatchSuccessOutcomeTransformation(MeterUtil.METER_UPDATE_TRANSFORM.apply(input)); } - private void checkBatchSuccessOutcomeTransformation( + private static void checkBatchSuccessOutcomeTransformation( final RpcResult output) { Assert.assertTrue(output.isSuccessful()); - Assert.assertEquals(0, output.getResult().getBatchFailedMetersOutput().size()); + Assert.assertEquals(0, output.getResult().nonnullBatchFailedMetersOutput().size()); Assert.assertEquals(0, output.getErrors().size()); } - private RpcResult> createEmptyBatchOutcome() { + private static RpcResult> createEmptyBatchOutcome() { return RpcResultBuilder .success(Collections.emptyList()) .build(); } - private RpcResult> createBatchOutcomeWithError() { + private static RpcResult> createBatchOutcomeWithError() { return RpcResultBuilder.>failed() .withError(RpcError.ErrorType.APPLICATION, "ut-flowAddFail") .withResult(Collections.singletonList(new BatchFailedMetersOutputBuilder() @@ -139,11 +141,12 @@ public class MeterUtilTest { .build(); } - private void checkBatchErrorOutcomeTransformation( + private static void checkBatchErrorOutcomeTransformation( final RpcResult output) { Assert.assertFalse(output.isSuccessful()); - Assert.assertEquals(1, output.getResult().getBatchFailedMetersOutput().size()); - Assert.assertEquals(DUMMY_METER_ID, output.getResult().getBatchFailedMetersOutput().get(0).getMeterId()); + Assert.assertEquals(1, output.getResult().nonnullBatchFailedMetersOutput().size()); + Assert.assertEquals(DUMMY_METER_ID, + output.getResult().nonnullBatchFailedMetersOutput().values().iterator().next().getMeterId()); Assert.assertEquals(1, output.getErrors().size()); } @@ -161,7 +164,9 @@ public class MeterUtilTest { Assert.assertTrue(composite.isSuccessful()); Assert.assertEquals(0, composite.getErrors().size()); - Assert.assertEquals(0, composite.getResult().getBatchFailedMetersOutput().size()); + Map failedMeters + = composite.getResult().nonnullBatchFailedMetersOutput(); + Assert.assertEquals(0, failedMeters.size()); } @Test @@ -193,7 +198,9 @@ public class MeterUtilTest { Assert.assertFalse(composite.isSuccessful()); Assert.assertEquals(1, composite.getErrors().size()); - Assert.assertEquals(0, composite.getResult().getBatchFailedMetersOutput().size()); + Map failedMeters + = composite.getResult().nonnullBatchFailedMetersOutput(); + Assert.assertEquals(0, failedMeters.size()); } @Test @@ -221,7 +228,7 @@ public class MeterUtilTest { private RpcResult createAddMetersBatchSuccessOutput() { return RpcResultBuilder .success(new AddMetersBatchOutputBuilder() - .setBatchFailedMetersOutput(Collections.emptyList()) + .setBatchFailedMetersOutput(Collections.emptyMap()) .build()) .build(); } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/extension/MatchExtensionHelper.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/extension/MatchExtensionHelper.java index 46ff894ff8..afc7db0ca7 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/extension/MatchExtensionHelper.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/extension/MatchExtensionHelper.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowplugin.openflow.md.core.extension; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Optional; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -68,13 +69,15 @@ public final class MatchExtensionHelper { final ExtensionListBuilder extBuilder = processExtension(matchEntry, ofVersion, matchPath); + // TODO: remove the Optional.ofNullable() here, which will result more performant and easier to understand code final GeneralAugMatchNodesNodeTableFlowBuilder builder = Optional .ofNullable(matchBuilder.augmentation(GeneralAugMatchNodesNodeTableFlow.class)) .map(GeneralAugMatchNodesNodeTableFlowBuilder::new) - .orElse(new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(new ArrayList<>())); + .orElse(new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(new HashMap<>())); if (extBuilder != null) { - builder.getExtensionList().add(extBuilder.build()); + final ExtensionList ext = extBuilder.build(); + builder.getExtensionList().put(ext.key(), ext); } else { LOG.warn("Convertor for {} for version {} with match path {} not found.", matchEntry, ofVersion, matchPath.name()); @@ -97,13 +100,15 @@ public final class MatchExtensionHelper { final Collection matchEntries, final OpenflowVersion ofVersion, final MatchPath matchPath) { List extensionsList = new ArrayList<>(); - for (MatchEntry matchEntry : matchEntries) { - ExtensionListBuilder extensionListBld = processExtension(matchEntry, ofVersion.getVersion(), matchPath); - if (extensionListBld == null) { - continue; - } + if (matchEntries != null) { + for (MatchEntry matchEntry : matchEntries) { + ExtensionListBuilder extensionListBld = processExtension(matchEntry, ofVersion.getVersion(), matchPath); + if (extensionListBld == null) { + continue; + } - extensionsList.add(extensionListBld.build()); + extensionsList.add(extensionListBld.build()); + } } AugmentTuple augmentTuple = null; diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorExecutor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorExecutor.java index a1a77da697..0478447971 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorExecutor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorExecutor.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor; import java.util.Collection; +import java.util.Map; import java.util.Optional; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorData; @@ -36,4 +37,17 @@ public interface ConvertorExecutor { * @return the result (can be empty, if no convertor was found) */ Optional convert(Collection source, D data); + + /** + * Lookup and use convertor by specified type, then converts source collection and returns converted result. + * + * @param the source key type + * @param the source value type + * @param the result type + * @param the data type + * @param source the source collection + * @param data convertor data + * @return the result (can be empty, if no convertor was found) + */ + Optional convert(Map source, D data); } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManager.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManager.java index 69382d0010..42c6af9f7b 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManager.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManager.java @@ -96,6 +96,36 @@ public class ConvertorManager implements ConvertorExecutor, ConvertorRegistrator return findConvertor(data.getVersion(), type).map(convertor -> (T)convertor.convert(source, data)); } + @Override + @SuppressWarnings("unchecked") + public Optional convert(final Map source, final D data) { + Optional result = Optional.empty(); + + if (source == null) { + LOG.trace("Cannot extract type from null source"); + return result; + } + + final Optional firstOptional = source.values().stream().findFirst(); + + if (!firstOptional.isPresent()) { + LOG.trace("Cannot extract type from empty collection"); + return result; + } + + final F first = firstOptional.get(); + + final Class type = first instanceof DataContainer ? ((DataContainer) first).implementedInterface() + : first.getClass(); + + if (type == null) { + LOG.warn("Cannot extract type from {}, because implementedInterface() returns null", source); + return result; + } + + return findConvertor(data.getVersion(), type).map(convertor -> (T)convertor.convert(source.values(), data)); + } + @Override @SuppressWarnings("unchecked") public Optional convert(final Collection source, final D data) { diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertor.java index 84fa9a3b4d..3432d6964d 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertor.java @@ -14,6 +14,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.Map; import java.util.Optional; import org.opendaylight.openflowjava.protocol.api.util.BinContent; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData; @@ -25,9 +26,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.gro import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand; @@ -83,14 +83,14 @@ public class GroupConvertor extends Convertor salToOFBucketList(final Buckets buckets, final short version, final int groupType, + private List salToOFBucketList(final List buckets, final short version, final int groupType, final Uint64 datapathid) { final List bucketLists = new ArrayList<>(); final ActionConvertorData data = new ActionConvertorData(version); data.setDatapathId(datapathid); for (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket groupBucket : - buckets.getBucket()) { + buckets) { BucketsListBuilder bucketBuilder = new BucketsListBuilder(); salToOFBucketListWeight(groupBucket, bucketBuilder, groupType); @@ -182,17 +182,18 @@ public class GroupConvertor extends Convertor bucketList = new ArrayList<>(source.getBuckets().getBucket()); - Group group = new GroupBuilder(source) - .setBuckets(new BucketsBuilder().setBucket(bucketList).build()) - .build(); - Collections.sort(group.getBuckets().getBucket(), COMPARATOR); - - List bucketLists = salToOFBucketList(group.getBuckets(), data.getVersion(), - group.getGroupType().getIntValue(), data.getDatapathId()); - groupModInputBuilder.setBucketsList(bucketLists); + final Buckets buckets = source.getBuckets(); + if (buckets != null) { + final Map bucket = buckets.nonnullBucket(); + if (!bucket.isEmpty()) { + // TODO: we should be able to just sort the resulting the resulting list and not go through + // two copies + List bucketList = new ArrayList<>(bucket.values()); + Collections.sort(bucketList, COMPARATOR); + List bucketLists = salToOFBucketList(bucketList, data.getVersion(), + source.getGroupType().getIntValue(), data.getDatapathId()); + groupModInputBuilder.setBucketsList(bucketLists); + } } } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupDescStatsResponseConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupDescStatsResponseConvertor.java index c82a569469..b4f715de97 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupDescStatsResponseConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupDescStatsResponseConvertor.java @@ -111,7 +111,7 @@ public class GroupDescStatsResponseConvertor extends Convertor, for (GroupDesc groupDesc : source) { GroupDescStatsBuilder salGroupDescStats = new GroupDescStatsBuilder(); - salGroupDescStats.setBuckets(toSALBucketsDesc(groupDesc.getBucketsList(), data.getVersion())); + salGroupDescStats.setBuckets(toSALBucketsDesc(groupDesc.nonnullBucketsList(), data.getVersion())); salGroupDescStats.setGroupId(new GroupId(groupDesc.getGroupId().getValue())); salGroupDescStats.setGroupType(GroupTypes.forValue(groupDesc.getType().getIntValue())); salGroupDescStats.withKey(new GroupDescStatsKey(salGroupDescStats.getGroupId())); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupStatsResponseConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupStatsResponseConvertor.java index 8e7a0ecd73..591ffa06bd 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupStatsResponseConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupStatsResponseConvertor.java @@ -52,7 +52,7 @@ public class GroupStatsResponseConvertor extends Convertor< .openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart .reply.group.GroupStats.class); - private Buckets toSALBuckets(List bucketStats) { + private static Buckets toSALBuckets(List bucketStats) { BucketsBuilder salBuckets = new BucketsBuilder(); List allBucketStats = new ArrayList<>(); @@ -88,7 +88,7 @@ public class GroupStatsResponseConvertor extends Convertor< .body.multipart.reply.group._case.multipart.reply.group.GroupStats groupStats : source) { GroupStatsBuilder salGroupStats = new GroupStatsBuilder(); - salGroupStats.setBuckets(toSALBuckets(groupStats.getBucketStats())); + salGroupStats.setBuckets(toSALBuckets(groupStats.nonnullBucketStats())); salGroupStats.setByteCount(new Counter64(groupStats.getByteCount())); DurationBuilder time = new DurationBuilder(); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConfigStatsResponseConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConfigStatsResponseConvertor.java index dbcdc32a36..dd12e99f04 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConfigStatsResponseConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConfigStatsResponseConvertor.java @@ -62,7 +62,7 @@ public class MeterConfigStatsResponseConvertor extends Convertor convert(List source, VersionConvertorData data) { + public List convert(final List source, final VersionConvertorData data) { List listMeterConfigStats = new ArrayList<>(); for (MeterConfig meterConfig : source) { @@ -70,7 +70,6 @@ public class MeterConfigStatsResponseConvertor extends Convertor bands = meterConfig.getBands(); MeterFlags meterFlags = new MeterFlags(meterConfig.getFlags().isOFPMFBURST(), meterConfig.getFlags().isOFPMFKBPS(), @@ -81,7 +80,7 @@ public class MeterConfigStatsResponseConvertor extends Convertor listBandHeaders = new ArrayList<>(); int bandKey = 0; - for (Bands band : bands) { + for (Bands band : meterConfig.nonnullBands()) { MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder(); if (band.getMeterBand() instanceof MeterBandDropCase) { MeterBandDropCase dropCaseBand = (MeterBandDropCase) band.getMeterBand(); @@ -120,6 +119,7 @@ public class MeterConfigStatsResponseConvertor extends Convertor bands) { - for (MeterBandHeader meterBandHeader : meterBandHeaders.getMeterBandHeader()) { + private static void getBandsFromSAL(final MeterBandHeaders meterBandHeaders, final List bands) { + for (MeterBandHeader meterBandHeader : meterBandHeaders.nonnullMeterBandHeader().values()) { // The band types :drop,DSCP_Remark or experimenter. if (null != meterBandHeader.getMeterBandTypes() && null != meterBandHeader.getMeterBandTypes().getFlags()) { if (meterBandHeader.getMeterBandTypes().getFlags().isOfpmbtDrop()) { @@ -152,7 +152,7 @@ public class MeterConvertor extends Convertor bands = new ArrayList<>(); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterStatsResponseConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterStatsResponseConvertor.java index 39d1dc7141..5fb610cfcb 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterStatsResponseConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterStatsResponseConvertor.java @@ -78,7 +78,7 @@ public class MeterStatsResponseConvertor extends Convertor< salMeterStats.setPacketInCount(new Counter64(meterStats.getPacketInCount())); salMeterStats.withKey(new MeterStatsKey(salMeterStats.getMeterId())); - List allMeterBandStats = meterStats.getMeterBandStats(); + List allMeterBandStats = meterStats.nonnullMeterBandStats(); MeterBandStatsBuilder meterBandStatsBuilder = new MeterBandStatsBuilder(); List listAllBandStats = new ArrayList<>(); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertor.java index 24679eadb3..dbdec7239b 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertor.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.Set; import org.opendaylight.controller.sal.common.util.Arguments; @@ -120,11 +121,12 @@ public class PacketOutConvertor extends Convertor actions = new ArrayList<>(); - List inputActions = - source.getAction(); + final List actions; + Map inputActions = + source.nonnullAction(); - if (inputActions != null) { + if (!inputActions.isEmpty()) { final ActionConvertorData actionConvertorData = new ActionConvertorData(data.getVersion()); actionConvertorData.setDatapathId(data.getDatapathId()); @@ -142,6 +144,7 @@ public class PacketOutConvertor extends Convertor(); actions.add(actionBuild.build()); } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java index f508f02d9f..c09d1e87b4 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java @@ -42,10 +42,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder; @@ -129,6 +128,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss; @@ -250,7 +251,7 @@ public class TableFeaturesConvertor extends Convertor< List sortedTableProperties = TABLE_FEATURE_PROPS_ORDERING.sortedCopy( - tableProperties.getTableFeatureProperties()); + tableProperties.nonnullTableFeatureProperties().values()); for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table .properties.TableFeatureProperties property : sortedTableProperties) { @@ -304,107 +305,95 @@ public class TableFeaturesConvertor extends Convertor< private static void setTableFeatureProperty(final ApplySetfieldMiss propType, final TableFeaturePropertiesBuilder propBuilder) { - List - setFieldMatch = null; + Map setFieldMatch = null; org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop .type.apply.setfield.miss.ApplySetfieldMiss applySetfieldMiss = propType.getApplySetfieldMiss(); if (null != applySetfieldMiss) { - setFieldMatch = applySetfieldMiss.getSetFieldMatch(); + setFieldMatch = applySetfieldMiss.nonnullSetFieldMatch(); } setSetFieldTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, - setFieldMatch == null ? new ArrayList<>() - : setFieldMatch); + setFieldMatch == null ? Collections.emptyMap() : setFieldMatch); } private static void setTableFeatureProperty(final ApplySetfield propType, final TableFeaturePropertiesBuilder propBuilder) { - List - setFieldMatch = null; + Map setFieldMatch = null; org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop .type.apply.setfield.ApplySetfield applySetfield = propType.getApplySetfield(); if (null != applySetfield) { - setFieldMatch = applySetfield.getSetFieldMatch(); + setFieldMatch = applySetfield.nonnullSetFieldMatch(); } setSetFieldTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, - setFieldMatch == null ? new ArrayList<>() - : setFieldMatch); + setFieldMatch == null ? Collections.emptyMap() : setFieldMatch); } private static void setTableFeatureProperty(final WriteSetfieldMiss propType, final TableFeaturePropertiesBuilder propBuilder) { - List - setFieldMatch = null; + Map setFieldMatch = null; org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop .type.write.setfield.miss.WriteSetfieldMiss writeSetfieldMiss = propType.getWriteSetfieldMiss(); if (null != writeSetfieldMiss) { - setFieldMatch = writeSetfieldMiss.getSetFieldMatch(); + setFieldMatch = writeSetfieldMiss.nonnullSetFieldMatch(); } setSetFieldTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, - setFieldMatch == null ? new ArrayList<>() - : setFieldMatch); + setFieldMatch == null ? Collections.emptyMap() : setFieldMatch); } private static void setTableFeatureProperty(final WriteSetfield propType, final TableFeaturePropertiesBuilder propBuilder) { - List - setFieldMatch = null; + Map setFieldMatch = null; org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop .type.write.setfield.WriteSetfield writeSetField = propType.getWriteSetfield(); if (null != writeSetField) { - setFieldMatch = writeSetField.getSetFieldMatch(); + setFieldMatch = writeSetField.nonnullSetFieldMatch(); } setSetFieldTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTWRITESETFIELD, - setFieldMatch == null ? new ArrayList<>() - : setFieldMatch); + setFieldMatch == null ? Collections.emptyMap() : setFieldMatch); } private static void setTableFeatureProperty(final Wildcards propType, final TableFeaturePropertiesBuilder propBuilder) { - List - setFieldMatch = null; + Map setFieldMatch = null; WildcardSetfield wildcardSetField = propType.getWildcardSetfield(); if (null != wildcardSetField) { - setFieldMatch = wildcardSetField.getSetFieldMatch(); + setFieldMatch = wildcardSetField.nonnullSetFieldMatch(); } setSetFieldTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTWILDCARDS, - setFieldMatch == null ? new ArrayList<>() - : setFieldMatch); + setFieldMatch == null ? Collections.emptyMap() : setFieldMatch); } private static void setTableFeatureProperty(final Match propType, final TableFeaturePropertiesBuilder propBuilder) { MatchSetfield matchSetField = propType.getMatchSetfield(); - List - setFieldMatch = null; + Map setFieldMatch = null; if (null != matchSetField) { - setFieldMatch = matchSetField.getSetFieldMatch(); + setFieldMatch = matchSetField.nonnullSetFieldMatch(); } setSetFieldTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTMATCH, - setFieldMatch == null ? new ArrayList<>() - : setFieldMatch); + setFieldMatch == null ? Collections.emptyMap() : setFieldMatch); } private static void setTableFeatureProperty(final ApplyActionsMiss propType, @@ -414,8 +403,7 @@ public class TableFeaturesConvertor extends Convertor< setActionTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, - applyActionsMiss == null ? new ArrayList<>() - : applyActionsMiss.getAction()); + applyActionsMiss == null ? Collections.emptyMap() : applyActionsMiss.nonnullAction()); } private static void setTableFeatureProperty(final ApplyActions propType, @@ -425,8 +413,7 @@ public class TableFeaturesConvertor extends Convertor< setActionTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTAPPLYACTIONS, - applyActions == null ? new ArrayList<>() - : applyActions.getAction()); + applyActions == null ? Collections.emptyMap() : applyActions.nonnullAction()); } private static void setTableFeatureProperty(final WriteActionsMiss propType, @@ -436,8 +423,7 @@ public class TableFeaturesConvertor extends Convertor< setActionTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, - writeActionsMiss == null ? new ArrayList<>() - : writeActionsMiss.getAction()); + writeActionsMiss == null ? Collections.emptyMap() : writeActionsMiss.nonnullAction()); } private static void setTableFeatureProperty(final WriteActions propType, @@ -447,8 +433,7 @@ public class TableFeaturesConvertor extends Convertor< setActionTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTWRITEACTIONS, - writeActions == null ? new ArrayList<>() - : writeActions.getAction()); + writeActions == null ? Collections.emptyMap() : writeActions.nonnullAction()); } private static void setTableFeatureProperty(final NextTableMiss propType, @@ -471,7 +456,7 @@ public class TableFeaturesConvertor extends Convertor< org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop .type.instructions.miss.InstructionsMiss instructions = propType.getInstructionsMiss(); setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, - instructions == null ? new ArrayList<>() : instructions.getInstruction()); + instructions == null ? Collections.emptyMap() : instructions.nonnullInstruction()); } private static void setTableFeatureProperty(final Instructions propType, @@ -479,15 +464,15 @@ public class TableFeaturesConvertor extends Convertor< org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop .type.instructions.Instructions instructions = propType.getInstructions(); setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONS, - instructions == null ? new ArrayList<>() : instructions.getInstruction()); + instructions == null ? Collections.emptyMap() : instructions.nonnullInstruction()); } private static void setInstructionTableFeatureProperty(final TableFeaturePropertiesBuilder builder, - final TableFeaturesPropType type, final List instructionList) { + final TableFeaturesPropType type, final Map instructionList) { List instructionTypeList = new ArrayList<>(); + .Instruction> instructionTypeList = new ArrayList<>(instructionList.size()); - for (Instruction currInstruction : instructionList) { + for (Instruction currInstruction : instructionList.values()) { InstructionBuilder instructionType = new InstructionBuilder(); org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction instruction = @@ -520,7 +505,7 @@ public class TableFeaturesConvertor extends Convertor< InstructionRelatedTableFeaturePropertyBuilder propBuilder = new InstructionRelatedTableFeaturePropertyBuilder(); propBuilder.setInstruction(instructionTypeList); builder.setType(type); - builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, propBuilder.build()); + builder.addAugmentation(propBuilder.build()); } private static void setNextTableFeatureProperty(final TableFeaturePropertiesBuilder builder, @@ -541,13 +526,14 @@ public class TableFeaturesConvertor extends Convertor< private static void setActionTableFeatureProperty(final TableFeaturePropertiesBuilder builder, final TableFeaturesPropType type, - final List - salActions) { + final Map + salActions) { - List actionList = new ArrayList<>(); + List actionList = new ArrayList<>(salActions.size()); for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action currAction : - salActions) { + salActions.values()) { org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionType = currAction .getAction(); ActionBuilder actionBuilder = new ActionBuilder(); @@ -609,18 +595,16 @@ public class TableFeaturesConvertor extends Convertor< ActionRelatedTableFeaturePropertyBuilder propBuilder = new ActionRelatedTableFeaturePropertyBuilder(); propBuilder.setAction(actionList); builder.setType(type); - builder.addAugmentation(ActionRelatedTableFeatureProperty.class, propBuilder.build()); + builder.addAugmentation(propBuilder.build()); } private static void setSetFieldTableFeatureProperty( final TableFeaturePropertiesBuilder builder, final TableFeaturesPropType type, - final List setFields) { + final Map setFields) { List matchEntriesList = new ArrayList<>(); - for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch - currMatch : setFields) { + for (SetFieldMatch currMatch : setFields.values()) { Class currMatchType = currMatch.getMatchType(); MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); @@ -661,7 +645,7 @@ public class TableFeaturesConvertor extends Convertor< TableFeaturesBuilder ofTableFeatures = new TableFeaturesBuilder(); for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures - salTableFeatures : source.getTableFeatures()) { + salTableFeatures : source.nonnullTableFeatures().values()) { ofTableFeatures.setTableId(salTableFeatures.getTableId()); ofTableFeatures.setName(salTableFeatures.getName()); ofTableFeatures.setMetadataMatch(salTableFeatures.getMetadataMatch()); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionConvertor.java index a8995ca118..b60b517bc2 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionConvertor.java @@ -77,8 +77,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1 * */ public final class ActionConvertor extends Convertor< - List, - List, + Collection, + Collection, ActionConvertorData> { private static final ConvertorProcessor convert(List convert(Collection source, ActionConvertorData data) { // Prepare list of converted actions final List result = new ArrayList<>(); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertor.java index e6ecda79d6..d43253d087 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertor.java @@ -17,6 +17,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData; @@ -37,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput; @@ -312,7 +314,7 @@ public class FlowConvertor extends Convertor, Ve Instructions instructions = flow.getInstructions(); for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction - instruction : instructions.getInstruction()) { + instruction : instructions.nonnullInstruction().values()) { org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction.getInstruction(); @@ -329,7 +331,7 @@ public class FlowConvertor extends Convertor, Ve private List getActions(final short version, final Uint64 datapathid, final Flow flow) { Instructions instructions = flow.getInstructions(); List - sortedInstructions = INSTRUCTION_ORDERING.sortedCopy(instructions.getInstruction()); + sortedInstructions = INSTRUCTION_ORDERING.sortedCopy(instructions.nonnullInstruction().values()); for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : sortedInstructions) { @@ -360,7 +362,7 @@ public class FlowConvertor extends Convertor, Ve // If yes,then we would need to two flows if (flow.getInstructions() != null && flow.getInstructions().getInstruction() != null) { for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction - instruction : flow.getInstructions().getInstruction()) { + instruction : flow.getInstructions().nonnullInstruction().values()) { org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction.getInstruction(); @@ -371,7 +373,7 @@ public class FlowConvertor extends Convertor, Ve .rev131026.instruction.instruction.ApplyActionsCase) curInstruction; ApplyActions applyActions = applyActionscase.getApplyActions(); for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action - action : applyActions.getAction()) { + action : applyActions.nonnullAction().values()) { if (action.getAction() instanceof SetVlanIdActionCase) { return true; } @@ -470,8 +472,9 @@ public class FlowConvertor extends Convertor, Ve private static List injectPushActionToInstruction(final Flow sourceFlow) { - List - srcInstructionList = sourceFlow.getInstructions().getInstruction(); + Map + srcInstructionList = sourceFlow.getInstructions().nonnullInstruction(); List targetInstructionList = new ArrayList<>(srcInstructionList.size()); @@ -483,7 +486,7 @@ public class FlowConvertor extends Convertor, Ve .list.InstructionBuilder(); for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction - srcInstruction : srcInstructionList) { + srcInstruction : srcInstructionList.values()) { org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curSrcInstruction = srcInstruction.getInstruction(); @@ -493,12 +496,13 @@ public class FlowConvertor extends Convertor, Ve .ApplyActionsCase applyActionscase = (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types .rev131026.instruction.instruction.ApplyActionsCase) curSrcInstruction; ApplyActions applyActions = applyActionscase.getApplyActions(); - List - srcActionList = applyActions.getAction(); + Map + srcActionList = applyActions.nonnullAction(); int offset = 0; for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action - actionItem : srcActionList) { + actionItem : srcActionList.values()) { // check if its a set-vlan-action. If yes, then add the injected-action if (actionItem.getAction() instanceof SetVlanIdActionCase) { @@ -527,7 +531,8 @@ public class FlowConvertor extends Convertor, Ve // we need to increment the order for all the actions added after injection ActionBuilder actionBuilder = new ActionBuilder(actionItem); - actionBuilder.setOrder(actionItem.getOrder() + offset); + actionBuilder.setOrder(actionItem.getOrder() + offset) + .withKey(new ActionKey(actionItem.key().getOrder() + offset)); actionItem = actionBuilder.build(); } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowStatsResponseConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowStatsResponseConvertor.java index 5d100f5939..0f61101c08 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowStatsResponseConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowStatsResponseConvertor.java @@ -156,7 +156,7 @@ public class FlowStatsResponseConvertor extends Convertor, List< final AugmentTuple matchExtensionWrap = MatchExtensionHelper.processAllExtensions( - flowStats.getMatch().getMatchEntry(), + flowStats.getMatch().nonnullMatchEntry(), OpenflowVersion.get(data.getVersion()), data.getMatchPath()); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertor.java index 6901fe2583..61bf949563 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchConvertor.java @@ -652,8 +652,7 @@ public class MatchConvertor extends Convertor, VersionCo Optional extensionListOpt = ExtensionResolvers.getMatchExtensionResolver().getExtension(source); if (extensionListOpt.isPresent()) { - List extensionListList = extensionListOpt.get().getExtensionList(); - for (ExtensionList extensionItem : extensionListList) { + for (ExtensionList extensionItem : extensionListOpt.get().nonnullExtensionList().values()) { // TODO: get real version ConverterExtensionKey key = new ConverterExtensionKey<>(extensionItem.getExtensionKey(), OFConstants.OFP_VERSION_1_3); diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor.java index b5908b7377..e410408297 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor.java @@ -178,7 +178,7 @@ public class MatchResponseConvertor extends Convertor KEY = - new MatchEntrySerializerKey<>(OpenflowVersion.OF13.getVersion(), MockOxmClassBase.class, MockMatchField.class); + private static final MatchEntrySerializerKey KEY_1 = + new MatchEntrySerializerKey<>(OpenflowVersion.OF13.getVersion(), MockOxmClassBase.class, MockMatchField1.class); + private static final MatchEntrySerializerKey KEY_2 = + new MatchEntrySerializerKey<>(OpenflowVersion.OF13.getVersion(), MockOxmClassBase.class, MockMatchField2.class); @Before public void setup() { OFSessionUtil.getSessionManager().setExtensionConverterProvider(extensionConverterProvider); - when(extensionConverterProvider.getConverter(KEY)) - .thenReturn((input, path) -> { - MockAugmentation mockAugmentation = new MockAugmentation(); - return new ExtensionAugment<>(MockAugmentation.class, mockAugmentation, MockExtensionKey.class); - }); + when(extensionConverterProvider.getConverter(KEY_1)) + .thenReturn((input, path) -> { + MockAugmentation mockAugmentation = new MockAugmentation(); + return new ExtensionAugment<>(MockAugmentation.class, mockAugmentation, MockExtensionKey1.class); + }); + when(extensionConverterProvider.getConverter(KEY_2)) + .thenReturn((input, path) -> { + MockAugmentation mockAugmentation = new MockAugmentation(); + return new ExtensionAugment<>(MockAugmentation.class, mockAugmentation, MockExtensionKey2.class); + }); } @@ -79,14 +84,19 @@ public class MatchExtensionHelperTest { private static List createMatchEntrieses() { + MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); + matchEntryBuilder.setHasMask(true); + matchEntryBuilder.setOxmClass(MockOxmClassBase.class); + matchEntryBuilder.setOxmMatchField(MockMatchField1.class); List matchEntries = new ArrayList<>(); - for (int i = 0; i < PRESET_COUNT; i++) { - MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder(); - matchEntryBuilder.setHasMask(true); - matchEntryBuilder.setOxmClass(MockOxmClassBase.class); - matchEntryBuilder.setOxmMatchField(MockMatchField.class); - matchEntries.add(matchEntryBuilder.build()); - } + matchEntries.add(matchEntryBuilder.build()); + + + MatchEntryBuilder matchEntryBuilder1 = new MatchEntryBuilder(); + matchEntryBuilder1.setHasMask(true); + matchEntryBuilder1.setOxmClass(MockOxmClassBase.class); + matchEntryBuilder1.setOxmMatchField(MockMatchField2.class); + matchEntries.add(matchEntryBuilder1.build()); return matchEntries; } @@ -94,15 +104,24 @@ public class MatchExtensionHelperTest { } - private interface MockMatchField extends MatchField { + private class MockMatchField1 implements MatchField { + } + + private class MockMatchField2 implements MatchField { + } + + private interface MockExtensionKey1 extends ExtensionKey { } - private interface MockExtensionKey extends ExtensionKey { + private interface MockExtensionKey2 extends ExtensionKey { } private final class MockAugmentation implements Augmentation { - + @Override + public Class implementedInterface() { + return MockAugmentation.class; + } } } diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertorTest.java index 4caf09709d..a4f291f71a 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupConvertorTest.java @@ -40,6 +40,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket; import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; @@ -102,6 +103,7 @@ public class GroupConvertorTest { bucketB.setWeight(10); bucketB.setWatchPort(20L); bucketB.setWatchGroup(22L); + bucketB.withKey(new BucketKey(new BucketId(Uint32.ZERO))); bucketB.setAction(actionsList); final Bucket bucket = bucketB.build(); @@ -112,6 +114,7 @@ public class GroupConvertorTest { bucketB1.setWeight(50); bucketB1.setWatchPort(60L); bucketB1.setWatchGroup(70L); + bucketB1.withKey(new BucketKey(new BucketId(Uint32.ONE))); // Action1 final CopyTtlInBuilder copyTtlB = new CopyTtlInBuilder(); @@ -231,7 +234,7 @@ public class GroupConvertorTest { final BucketBuilder bucketB = new BucketBuilder(); - bucketB.setAction(actionsList); + bucketB.setAction(actionsList).withKey(new BucketKey(new BucketId(Uint32.ZERO))); final Bucket bucket = bucketB.build(); bucketList.add(bucket); // List of bucket @@ -244,7 +247,7 @@ public class GroupConvertorTest { // Action2: actionsList1.add(assembleSetMplsTtlActionBuilder(actionOrder++).build()); - bucketB1.setAction(actionsList1); + bucketB1.setAction(actionsList1).withKey(new BucketKey(new BucketId(Uint32.ONE))); final Bucket bucket1 = bucketB1.build(); // second bucket @@ -459,7 +462,7 @@ public class GroupConvertorTest { final BucketBuilder bucketB = new BucketBuilder(); - bucketB.setAction(actionsList); + bucketB.setAction(actionsList).withKey(new BucketKey(new BucketId(Uint32.ZERO))); final Bucket bucket = bucketB.build(); bucketList.add(bucket); // List of bucket @@ -471,7 +474,7 @@ public class GroupConvertorTest { // Action2: actionsList1.add(assembleSetMplsTtlActionBuilder(actionOrder++).build()); - bucketB1.setAction(actionsList); + bucketB1.setAction(actionsList).withKey(new BucketKey(new BucketId(Uint32.ONE))); final Bucket bucket1 = bucketB1.build(); // second bucket diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupDescStatsResponseConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupDescStatsResponseConvertorTest.java index 48d171ab7d..6e51f5d770 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupDescStatsResponseConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupDescStatsResponseConvertorTest.java @@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor; import java.util.ArrayList; import java.util.Collections; +import java.util.Iterator; import java.util.List; import java.util.Optional; import org.junit.Assert; @@ -79,7 +80,7 @@ public class GroupDescStatsResponseConvertorTest { Assert.assertEquals("Wrong type", GroupTypes.GroupAll, stat.getGroupType()); Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue()); Assert.assertEquals("Wrong key", 42, stat.key().getGroupId().getValue().intValue()); - Assert.assertEquals("Wrong buckets size", 0, stat.getBuckets().getBucket().size()); + Assert.assertEquals("Wrong buckets size", 0, stat.getBuckets().nonnullBucket().size()); } /** @@ -179,10 +180,11 @@ public class GroupDescStatsResponseConvertorTest { Assert.assertEquals("Wrong type", GroupTypes.GroupFf, stat.getGroupType()); Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue()); Assert.assertEquals("Wrong key", 42, stat.key().getGroupId().getValue().intValue()); - Assert.assertEquals("Wrong buckets size", 1, stat.getBuckets().getBucket().size()); + Assert.assertEquals("Wrong buckets size", 1, stat.getBuckets().nonnullBucket().size()); // Test first bucket for first group desc - Bucket bucket = stat.getBuckets().getBucket().get(0); + Iterator bucketIt = stat.getBuckets().nonnullBucket().values().iterator(); + Bucket bucket = bucketIt.next(); Assert.assertEquals("Wrong type", 0, bucket.key().getBucketId().getValue().intValue()); Assert.assertEquals("Wrong type", 0, bucket.getBucketId().getValue().intValue()); Assert.assertEquals("Wrong type", 16, bucket.getWeight().intValue()); @@ -192,7 +194,7 @@ public class GroupDescStatsResponseConvertorTest { // Test first action for first bucket for first group desc org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list - .Action action = bucket.getAction().get(0); + .Action action = bucket.nonnullAction().values().iterator().next(); Assert.assertEquals("Wrong type", 0, action.getOrder().intValue()); Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112" + ".action.action.CopyTtlInCase", action.getAction().implementedInterface().getName()); @@ -204,43 +206,45 @@ public class GroupDescStatsResponseConvertorTest { Assert.assertEquals("Wrong type", GroupTypes.GroupIndirect, stat.getGroupType()); Assert.assertEquals("Wrong group-id", 50, stat.getGroupId().getValue().intValue()); Assert.assertEquals("Wrong key", 50, stat.key().getGroupId().getValue().intValue()); - Assert.assertEquals("Wrong buckets size", 2, stat.getBuckets().getBucket().size()); + Assert.assertEquals("Wrong buckets size", 2, stat.getBuckets().nonnullBucket().size()); // Test first bucket for second group desc - bucket = stat.getBuckets().getBucket().get(0); + bucketIt = stat.getBuckets().nonnullBucket().values().iterator(); + bucket = bucketIt.next(); Assert.assertEquals("Wrong type", 0, bucket.key().getBucketId().getValue().intValue()); Assert.assertEquals("Wrong type", 0, bucket.getBucketId().getValue().intValue()); Assert.assertEquals("Wrong type", 100, bucket.getWeight().intValue()); Assert.assertEquals("Wrong type", 400, bucket.getWatchGroup().intValue()); Assert.assertEquals("Wrong type", 200, bucket.getWatchPort().intValue()); - Assert.assertEquals("Wrong type", 3, bucket.getAction().size()); + Assert.assertEquals("Wrong type", 3, bucket.nonnullAction().size()); // Test first action for first bucket of second group desc - action = bucket.getAction().get(0); + var actionIt = bucket.nonnullAction().values().iterator(); + action = actionIt.next(); Assert.assertEquals("Wrong type", 0, action.getOrder().intValue()); Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112" + ".action.action.CopyTtlOutCase", action.getAction().implementedInterface().getName()); // Test second action for first bucket of second group desc - action = bucket.getAction().get(1); + action = actionIt.next(); Assert.assertEquals("Wrong type", 1, action.getOrder().intValue()); Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112" + ".action.action.DecNwTtlCase", action.getAction().implementedInterface().getName()); // Test third action for first bucket of second group desc - action = bucket.getAction().get(2); + action = actionIt.next(); Assert.assertEquals("Wrong type", 2, action.getOrder().intValue()); Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112" + ".action.action.PopPbbActionCase", action.getAction().implementedInterface().getName()); // Test second bucket for second group desc - bucket = stat.getBuckets().getBucket().get(1); + bucket = bucketIt.next(); Assert.assertEquals("Wrong type", 1, bucket.key().getBucketId().getValue().intValue()); Assert.assertEquals("Wrong type", 1, bucket.getBucketId().getValue().intValue()); Assert.assertEquals("Wrong type", 5, bucket.getWeight().intValue()); Assert.assertEquals("Wrong type", 15, bucket.getWatchGroup().intValue()); Assert.assertEquals("Wrong type", 10, bucket.getWatchPort().intValue()); - Assert.assertEquals("Wrong type", 0, bucket.getAction().size()); + Assert.assertEquals("Wrong type", 0, bucket.nonnullAction().size()); } private List convert(List groupDescStats,VersionConvertorData data) { diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupStatsResponseConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupStatsResponseConvertorTest.java index 5f065b3df2..48b7c16ed4 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupStatsResponseConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupStatsResponseConvertorTest.java @@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor; import java.math.BigInteger; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Optional; import org.junit.Assert; @@ -83,7 +84,7 @@ public class GroupStatsResponseConvertorTest { Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue()); Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue()); Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue()); - Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size()); + Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().nonnullBucketCounter().size()); } /** @@ -129,7 +130,7 @@ public class GroupStatsResponseConvertorTest { Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue()); Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue()); Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue()); - Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size()); + Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().nonnullBucketCounter().size()); stat = salGroupStats.get(1); Assert.assertEquals("Wrong group-id", 4, stat.getGroupId().getValue().intValue()); Assert.assertEquals("Wrong key", 4, stat.key().getGroupId().getValue().intValue()); @@ -138,7 +139,7 @@ public class GroupStatsResponseConvertorTest { Assert.assertEquals("Wrong byte count", 1, stat.getByteCount().getValue().intValue()); Assert.assertEquals("Wrong duration sec", 3, stat.getDuration().getSecond().getValue().intValue()); Assert.assertEquals("Wrong duration n sec", 2, stat.getDuration().getNanosecond().getValue().intValue()); - Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size()); + Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().nonnullBucketCounter().size()); } /** @@ -184,12 +185,14 @@ public class GroupStatsResponseConvertorTest { Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue()); Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue()); Assert.assertEquals("Wrong bucket stats", 2, stat.getBuckets().getBucketCounter().size()); - List list = stat.getBuckets().getBucketCounter(); - Assert.assertEquals("Wrong bucket-id", 0, list.get(0).getBucketId().getValue().intValue()); - Assert.assertEquals("Wrong bucket packet count", 654, list.get(0).getPacketCount().getValue().intValue()); - Assert.assertEquals("Wrong bucket byte count", 987, list.get(0).getByteCount().getValue().intValue()); - Assert.assertEquals("Wrong bucket-id", 1, list.get(1).getBucketId().getValue().intValue()); - Assert.assertEquals("Wrong bucket packet count", 456, list.get(1).getPacketCount().getValue().intValue()); - Assert.assertEquals("Wrong bucket byte count", 123, list.get(1).getByteCount().getValue().intValue()); + Iterator it = stat.getBuckets().nonnullBucketCounter().values().iterator(); + BucketCounter counter = it.next(); + Assert.assertEquals("Wrong bucket-id", 0, counter.getBucketId().getValue().intValue()); + Assert.assertEquals("Wrong bucket packet count", 654, counter.getPacketCount().getValue().intValue()); + Assert.assertEquals("Wrong bucket byte count", 987, counter.getByteCount().getValue().intValue()); + counter = it.next(); + Assert.assertEquals("Wrong bucket-id", 1, counter.getBucketId().getValue().intValue()); + Assert.assertEquals("Wrong bucket packet count", 456, counter.getPacketCount().getValue().intValue()); + Assert.assertEquals("Wrong bucket byte count", 123, counter.getByteCount().getValue().intValue()); } } diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConvertorTest.java index cfc09ce8d5..f35904150b 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterConvertorTest.java @@ -19,6 +19,7 @@ import org.junit.Test; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFlags; @@ -32,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMeterBand; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand; @@ -69,6 +71,7 @@ public class MeterConvertorTest { MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder(); meterBandHeaderBuilder.setBandType(drp); meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesB.build()); + meterBandHeaderBuilder.withKey(new MeterBandHeaderKey(new BandId(Uint32.ZERO))); final MeterBandHeader meterBH = meterBandHeaderBuilder.build(); @@ -90,6 +93,7 @@ public class MeterConvertorTest { MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder(); meterBandHeaderBuilder1.setBandType(dscpRemark); meterBandHeaderBuilder1.setMeterBandTypes(meterBandTypesB1.build()); + meterBandHeaderBuilder1.withKey(new MeterBandHeaderKey(new BandId(Uint32.ONE))); final MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build(); @@ -111,6 +115,7 @@ public class MeterConvertorTest { MeterBandHeaderBuilder meterBandHeaderBuilder2 = new MeterBandHeaderBuilder(); meterBandHeaderBuilder2.setBandType(experimenter); meterBandHeaderBuilder2.setMeterBandTypes(meterBandTypesB2.build()); + meterBandHeaderBuilder.withKey(new MeterBandHeaderKey(new BandId(Uint32.TWO))); MeterBandHeader meterBH2 = meterBandHeaderBuilder2.build(); List meterBandList = new ArrayList<>(); @@ -200,6 +205,7 @@ public class MeterConvertorTest { MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder(); meterBandHeaderBuilder.setBandType(drp); meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesB.build()); + meterBandHeaderBuilder.withKey(new MeterBandHeaderKey(new BandId(Uint32.ZERO))); final MeterBandHeader meterBH = meterBandHeaderBuilder.build(); @@ -222,6 +228,7 @@ public class MeterConvertorTest { MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder(); meterBandHeaderBuilder1.setBandType(dscpRemark); meterBandHeaderBuilder1.setMeterBandTypes(meterBandTypesB1.build()); + meterBandHeaderBuilder1.withKey(new MeterBandHeaderKey(new BandId(Uint32.ONE))); final MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build(); @@ -244,6 +251,7 @@ public class MeterConvertorTest { MeterBandHeaderBuilder meterBandHeaderBuilder2 = new MeterBandHeaderBuilder(); meterBandHeaderBuilder2.setBandType(experimenter); meterBandHeaderBuilder2.setMeterBandTypes(meterBandTypesB2.build()); + meterBandHeaderBuilder2.withKey(new MeterBandHeaderKey(new BandId(Uint32.TWO))); MeterBandHeader meterBH2 = meterBandHeaderBuilder2.build(); List meterBandList = new ArrayList<>(); @@ -349,6 +357,7 @@ public class MeterConvertorTest { meterBandTypesB.setFlags(bandFlag);// _ofpmbtDrop meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesB.build()); + meterBandHeaderBuilder.withKey(new MeterBandHeaderKey(new BandId(Uint32.ZERO))); final MeterBandHeader meterBH = meterBandHeaderBuilder.build(); @@ -366,6 +375,7 @@ public class MeterConvertorTest { MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder(); meterBandHeaderBuilder1.setBandType(dscpRemark); meterBandHeaderBuilder1.setMeterBandTypes(meterBandTypesB1.build()); + meterBandHeaderBuilder1.withKey(new MeterBandHeaderKey(new BandId(Uint32.ONE))); final MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build(); @@ -382,6 +392,7 @@ public class MeterConvertorTest { MeterBandTypesBuilder meterBandTypesB2 = new MeterBandTypesBuilder(); meterBandHeaderBuilder2.setMeterBandTypes(meterBandTypesB2.build()); + meterBandHeaderBuilder2.withKey(new MeterBandHeaderKey(new BandId(Uint32.TWO))); MeterBandHeader meterBH2 = meterBandHeaderBuilder2.build(); List meterBandList = new ArrayList<>(); diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterStatsResponseConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterStatsResponseConvertorTest.java index 853f05df09..9d924cb8fd 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterStatsResponseConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterStatsResponseConvertorTest.java @@ -81,9 +81,9 @@ public class MeterStatsResponseConvertorTest { assertEquals(Uint32.valueOf(cnt), meterStats.getFlowCount().getValue()); assertEquals(Uint64.valueOf(cnt), meterStats.getByteInCount().getValue()); - assertEquals(PRESET_COUNT, meterStats.getMeterBandStats().getBandStat().size()); + assertEquals(PRESET_COUNT, meterStats.getMeterBandStats().nonnullBandStat().size()); int bandStatCount = 0; - for (BandStat bandStat : meterStats.getMeterBandStats().getBandStat()) { + for (BandStat bandStat : meterStats.getMeterBandStats().nonnullBandStat().values()) { assertEquals(Uint64.valueOf(bandStatCount), bandStat.getByteBandCount().getValue()); assertEquals(Uint64.valueOf(bandStatCount), bandStat.getPacketBandCount().getValue()); bandStatCount++; diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertorTest.java index 7a78c11c20..c3fc45ca8e 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PacketOutConvertorTest.java @@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor; import java.math.BigInteger; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Optional; import org.junit.Assert; @@ -70,8 +69,6 @@ public class PacketOutConvertorTest { TransmitPacketInputBuilder transmitPacketInputBuilder = new TransmitPacketInputBuilder(); - Long bufferId = null; - String nodeId = "0"; String port = "0"; @@ -80,9 +77,8 @@ public class PacketOutConvertorTest { NodeConnectorRef egressConfRef = new NodeConnectorRef( createNodeConnRef(nodeId, nodeConnKey)); - transmitPacketInputBuilder.setBufferId(bufferId); + transmitPacketInputBuilder.setBufferId((Uint32) null); transmitPacketInputBuilder.setConnectionCookie(null); - transmitPacketInputBuilder.setAction(null); transmitPacketInputBuilder.setNode(ref); transmitPacketInputBuilder.setPayload(null); transmitPacketInputBuilder.setEgress(egressConfRef); @@ -185,7 +181,7 @@ public class PacketOutConvertorTest { Optional> actionsOptional = convertorManager.convert(actionList, actionConvertorData); - List actions = actionsOptional.orElse(Collections.emptyList()); + List actions = actionsOptional.orElse(null); Assert.assertEquals(actions, message.getAction()); Assert.assertArrayEquals(transmitPacketInput.getPayload(), message.getData()); } diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertorTest.java index 4b96254de6..1bc75a1445 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertorTest.java @@ -13,6 +13,7 @@ import static org.junit.Assert.assertNotNull; import java.math.BigInteger; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -84,6 +85,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey; public class TableFeaturesConvertorTest { private static final TablePropertiesBuilder TABLE_PROPERTIES_BUILDER = new TablePropertiesBuilder(); @@ -106,6 +108,7 @@ public class TableFeaturesConvertorTest { } private static void setupFieldTableFeatures() { + int order = 0; SetFieldMatchBuilder setFieldMatchBuilder = new SetFieldMatchBuilder(); setFieldMatchBuilder.setHasMask(true); setFieldMatchBuilder @@ -220,7 +223,7 @@ public class TableFeaturesConvertorTest { .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class); FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build()); setFieldMatchBuilder - .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class); + .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class); FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build()); setFieldMatchBuilder .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class); @@ -243,53 +246,54 @@ public class TableFeaturesConvertorTest { org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder actionBuilder = new ActionBuilder(); + int order = 0; OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(outputActionCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(outputActionCaseBuilder.build()).build()); GroupActionCaseBuilder groupActionCaseBuilder = new GroupActionCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(groupActionCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(groupActionCaseBuilder.build()).build()); CopyTtlOutCaseBuilder copyTtlOutCaseBuilder = new CopyTtlOutCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(copyTtlOutCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(copyTtlOutCaseBuilder.build()).build()); CopyTtlInCaseBuilder copyTtlInCaseBuilder = new CopyTtlInCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(copyTtlInCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(copyTtlInCaseBuilder.build()).build()); SetMplsTtlActionCaseBuilder setMplsTtlActionCaseBuilder = new SetMplsTtlActionCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(setMplsTtlActionCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(setMplsTtlActionCaseBuilder.build()).build()); DecMplsTtlCaseBuilder decMplsTtlCaseBuilder = new DecMplsTtlCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(decMplsTtlCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(decMplsTtlCaseBuilder.build()).build()); PushVlanActionCaseBuilder pushVlanActionCaseBuilder = new PushVlanActionCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(pushVlanActionCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(pushVlanActionCaseBuilder.build()).build()); PopVlanActionCaseBuilder popVlanActionCaseBuilder = new PopVlanActionCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(popVlanActionCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(popVlanActionCaseBuilder.build()).build()); PushMplsActionCaseBuilder pushMplsActionCaseBuilder = new PushMplsActionCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(pushMplsActionCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(pushMplsActionCaseBuilder.build()).build()); PopMplsActionCaseBuilder popMplsActionCaseBuilder = new PopMplsActionCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(popMplsActionCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(popMplsActionCaseBuilder.build()).build()); SetQueueActionCaseBuilder setQueueActionCaseBuilder = new SetQueueActionCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(setQueueActionCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(setQueueActionCaseBuilder.build()).build()); SetNwTtlActionCaseBuilder setNwTtlActionCaseBuilder = new SetNwTtlActionCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(setNwTtlActionCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(setNwTtlActionCaseBuilder.build()).build()); DecNwTtlCaseBuilder decNwTtlCaseBuilder = new DecNwTtlCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(decNwTtlCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(decNwTtlCaseBuilder.build()).build()); SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(setFieldCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(setFieldCaseBuilder.build()).build()); PushPbbActionCaseBuilder pushPbbActionCaseBuilder = new PushPbbActionCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(pushPbbActionCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(pushPbbActionCaseBuilder.build()).build()); PopPbbActionCaseBuilder popPbbActionCaseBuilder = new PopPbbActionCaseBuilder(); - ACTIONS.add(actionBuilder.setAction(popPbbActionCaseBuilder.build()).build()); + ACTIONS.add(actionBuilder.setOrder(order++).setAction(popPbbActionCaseBuilder.build()).build()); } @@ -300,10 +304,11 @@ public class TableFeaturesConvertorTest { setupFieldTableFeatures(); InstructionsBuilder instructionsBuilder = new InstructionsBuilder(); List instructions = new ArrayList<>(); - for (int i = 0; i < INSTRUCTIONS_LIST.size(); i++) { - InstructionBuilder instructionBuilder = new InstructionBuilder(); - instructionBuilder.setInstruction(INSTRUCTIONS_LIST.get(i)); - instructions.add(instructionBuilder.build()); + int order = 0; + for (var element : INSTRUCTIONS_LIST) { + instructions.add(new InstructionBuilder() + .setOrder(order++) + .setInstruction(element).build()); } org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature .prop.type.instructions.InstructionsBuilder instructionsBuilder1 = @@ -403,19 +408,18 @@ public class TableFeaturesConvertorTest { assertNotNull(tableFeatures); assertEquals(10, tableFeatures.getTableFeatures().size()); - List tableFeaturePropertieses = tableFeatures.getTableFeatures().get(0) - .getTableProperties().getTableFeatureProperties(); + Collection tableFeaturePropertieses = tableFeatures.nonnullTableFeatures().values() + .iterator().next().getTableProperties().nonnullTableFeatureProperties().values(); assertEquals(AUGMENTATIONS_MAP.size() + 1, tableFeaturePropertieses.size()); org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature .prop.type.ApplyActionsMiss applyActionsMiss = null; - for (int i = 0; i < tableFeaturePropertieses.size(); i++) { - if (tableFeaturePropertieses.get(i).getTableFeaturePropType().implementedInterface().isAssignableFrom( - org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table - .feature.prop.type.ApplyActionsMiss.class)) { + for (var featureProp : tableFeaturePropertieses) { + var prop = featureProp.getTableFeaturePropType(); + if (prop.implementedInterface().isAssignableFrom(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types + .rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss.class)) { applyActionsMiss = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature - .prop.type.table.feature.prop.type.ApplyActionsMiss) tableFeaturePropertieses.get(i) - .getTableFeaturePropType(); + .prop.type.table.feature.prop.type.ApplyActionsMiss) prop; break; } } @@ -429,13 +433,16 @@ public class TableFeaturesConvertorTest { TableFeaturePropertiesBuilder tableFeaturePropertiesBuilder = new TableFeaturePropertiesBuilder(); List tableFeaturePropertieses = new ArrayList<>(); int counter = 0; + int order = 0; for (Entry, TableFeaturePropType> entry : AUGMENTATIONS_MAP.entrySet()) { counter++; tableFeaturePropertiesBuilder.setTableFeaturePropType(entry.getValue()); tableFeaturePropertiesBuilder.setOrder(counter); + tableFeaturePropertiesBuilder.withKey(new TableFeaturePropertiesKey(order++)); tableFeaturePropertieses.add(tableFeaturePropertiesBuilder.build()); } - tableFeaturePropertieses.add(tableFeaturePropertiesBuilder.build()); + tableFeaturePropertieses.add( + tableFeaturePropertiesBuilder.withKey(new TableFeaturePropertiesKey(order++)).build()); TABLE_PROPERTIES_BUILDER.setTableFeatureProperties(tableFeaturePropertieses); return TABLE_PROPERTIES_BUILDER.build(); } diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertorTest.java index 7e8be640a3..f7ac01471f 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertorTest.java @@ -9,7 +9,9 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; +import java.util.Iterator; import java.util.List; import java.util.Optional; import org.junit.Assert; @@ -170,7 +172,7 @@ public class TableFeaturesResponseConvertorTest { Assert.assertEquals("Wrong metadata write", Uint64.valueOf("08090A0B0C0D0E0F", 16), feature.getMetadataWrite()); Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK()); Assert.assertEquals("Wrong max-entries", 42, feature.getMaxEntries().intValue()); - Assert.assertEquals("Wrong properties", 0, feature.getTableProperties().getTableFeatureProperties().size()); + Assert.assertEquals("Wrong properties", 0, feature.getTableProperties().nonnullTableFeatureProperties().size()); } /** @@ -555,10 +557,11 @@ public class TableFeaturesResponseConvertorTest { Assert.assertEquals("Wrong metadata write",Uint64.valueOf("08090A0B0C0D0E0F", 16), feature.getMetadataWrite()); Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK()); Assert.assertEquals("Wrong max-entries", 42, feature.getMaxEntries().intValue()); - Assert.assertEquals("Wrong properties", 4, feature.getTableProperties().getTableFeatureProperties().size()); + Assert.assertEquals("Wrong properties", 4, feature.getTableProperties().nonnullTableFeatureProperties().size()); + + var featProps = feature.getTableProperties().getTableFeatureProperties().values().iterator(); org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table - .properties.TableFeatureProperties property = feature.getTableProperties().getTableFeatureProperties() - .get(0); + .properties.TableFeatureProperties property = featProps.next(); Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.NextTable", property.getTableFeaturePropType().implementedInterface().getName()); @@ -567,7 +570,7 @@ public class TableFeaturesResponseConvertorTest { Assert.assertEquals("Wrong next table-id size", 2, ids.size()); Assert.assertEquals("Wrong next-registry-id", 1, ids.get(0).intValue()); Assert.assertEquals("Wrong next-registry-id", 2, ids.get(1).intValue()); - property = feature.getTableProperties().getTableFeatureProperties().get(1); + property = featProps.next(); Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss", property.getTableFeaturePropType().implementedInterface().getName()); @@ -576,42 +579,43 @@ public class TableFeaturesResponseConvertorTest { Assert.assertEquals("Wrong next table-id size", 1, ids.size()); Assert.assertEquals("Wrong next-registry-id", 3, ids.get(0).intValue()); - property = feature.getTableProperties().getTableFeatureProperties().get(2); + property = featProps.next(); Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.Instructions", property.getTableFeaturePropType().implementedInterface().getName()); Instructions propType3 = (Instructions) property.getTableFeaturePropType(); - List instructionIds = propType3.getInstructions().getInstruction(); + var instructionIds = propType3.getInstructions().nonnullInstruction().values(); Assert.assertEquals("Wrong instruction-ids size", 2, instructionIds.size()); + var instructionIt = instructionIds.iterator(); Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.WriteActionsCase", - instructionIds.get(0).getInstruction().implementedInterface().getName()); + instructionIt.next().getInstruction().implementedInterface().getName()); Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.GoToTableCase", - instructionIds.get(1).getInstruction().implementedInterface().getName()); - property = feature.getTableProperties().getTableFeatureProperties().get(3); + instructionIt.next().getInstruction().implementedInterface().getName()); + property = featProps.next(); Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss", property.getTableFeaturePropType().implementedInterface().getName()); InstructionsMiss propType4 = (InstructionsMiss) property.getTableFeaturePropType(); - instructionIds = propType4.getInstructionsMiss().getInstruction(); + instructionIds = propType4.getInstructionsMiss().nonnullInstruction().values(); Assert.assertEquals("Wrong instruction-ids size", 5, instructionIds.size()); + instructionIt = instructionIds.iterator(); Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.WriteMetadataCase", - instructionIds.get(0).getInstruction().implementedInterface().getName()); + instructionIt.next().getInstruction().implementedInterface().getName()); Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.ApplyActionsCase", - instructionIds.get(1).getInstruction().implementedInterface().getName()); + instructionIt.next().getInstruction().implementedInterface().getName()); Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.MeterCase", - instructionIds.get(2).getInstruction().implementedInterface().getName()); + instructionIt.next().getInstruction().implementedInterface().getName()); Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.ClearActionsCase", - instructionIds.get(3).getInstruction().implementedInterface().getName()); + instructionIt.next().getInstruction().implementedInterface().getName()); Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.GoToTableCase", - instructionIds.get(4).getInstruction().implementedInterface().getName()); + instructionIt.next().getInstruction().implementedInterface().getName()); feature = list.get(1); Assert.assertEquals("Wrong table-id", 6, feature.getTableId().intValue()); @@ -621,122 +625,130 @@ public class TableFeaturesResponseConvertorTest { Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK()); Assert.assertEquals("Wrong max-entries", 24, feature.getMaxEntries().intValue()); Assert.assertEquals("Wrong properties", 12, feature.getTableProperties().getTableFeatureProperties().size()); - property = feature.getTableProperties().getTableFeatureProperties().get(0); + featProps = feature.getTableProperties().nonnullTableFeatureProperties().values().iterator(); + property = featProps.next(); Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.Match", property.getTableFeaturePropType().implementedInterface().getName()); Match propType5 = (Match) property.getTableFeaturePropType(); - List fieldMatch = propType5.getMatchSetfield().getSetFieldMatch(); + Collection fieldMatch = propType5.getMatchSetfield().nonnullSetFieldMatch().values(); Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size()); + Iterator fieldIt = fieldMatch.iterator(); Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." - + "rev131026.InPhyPort", fieldMatch.get(0).getMatchType().getName()); + + "rev131026.InPhyPort", fieldIt.next().getMatchType().getName()); Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." - + "rev131026.InPort", fieldMatch.get(1).getMatchType().getName()); - property = feature.getTableProperties().getTableFeatureProperties().get(1); + + "rev131026.InPort", fieldIt.next().getMatchType().getName()); + property = featProps.next(); Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield", property.getTableFeaturePropType().implementedInterface().getName()); ApplySetfield propType6 = (ApplySetfield) property.getTableFeaturePropType(); - fieldMatch = propType6.getApplySetfield().getSetFieldMatch(); + fieldMatch = propType6.getApplySetfield().nonnullSetFieldMatch().values(); Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size()); + fieldIt = fieldMatch.iterator(); Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto", - fieldMatch.get(0).getMatchType().getName()); + fieldIt.next().getMatchType().getName()); Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn", - fieldMatch.get(1).getMatchType().getName()); - property = feature.getTableProperties().getTableFeatureProperties().get(2); + fieldIt.next().getMatchType().getName()); + property = featProps.next(); Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield", property.getTableFeaturePropType().implementedInterface().getName()); WriteSetfield propType7 = (WriteSetfield) property.getTableFeaturePropType(); - fieldMatch = propType7.getWriteSetfield().getSetFieldMatch(); + fieldMatch = propType7.getWriteSetfield().nonnullSetFieldMatch().values(); Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size()); + fieldIt = fieldMatch.iterator(); Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr", - fieldMatch.get(0).getMatchType().getName()); + fieldIt.next().getMatchType().getName()); Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid", - fieldMatch.get(1).getMatchType().getName()); - property = feature.getTableProperties().getTableFeatureProperties().get(3); + fieldIt.next().getMatchType().getName()); + property = featProps.next(); Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss", property.getTableFeaturePropType().implementedInterface().getName()); WriteSetfieldMiss propType8 = (WriteSetfieldMiss) property.getTableFeaturePropType(); - fieldMatch = propType8.getWriteSetfieldMiss().getSetFieldMatch(); + fieldMatch = propType8.getWriteSetfieldMiss().nonnullSetFieldMatch().values(); Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size()); + fieldIt = fieldMatch.iterator(); Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp", - fieldMatch.get(0).getMatchType().getName()); + fieldIt.next().getMatchType().getName()); Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc", - fieldMatch.get(1).getMatchType().getName()); - property = feature.getTableProperties().getTableFeatureProperties().get(4); + fieldIt.next().getMatchType().getName()); + property = featProps.next(); Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss", property.getTableFeaturePropType().implementedInterface().getName()); ApplySetfieldMiss propType9 = (ApplySetfieldMiss) property.getTableFeaturePropType(); - fieldMatch = propType9.getApplySetfieldMiss().getSetFieldMatch(); + fieldMatch = propType9.getApplySetfieldMiss().nonnullSetFieldMatch().values(); Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size()); + fieldIt = fieldMatch.iterator(); Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc", - fieldMatch.get(0).getMatchType().getName()); + fieldIt.next().getMatchType().getName()); Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst", - fieldMatch.get(1).getMatchType().getName()); - property = feature.getTableProperties().getTableFeatureProperties().get(5); + fieldIt.next().getMatchType().getName()); + property = featProps.next(); Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards", property.getTableFeaturePropType().implementedInterface().getName()); Wildcards propType10 = (Wildcards) property.getTableFeaturePropType(); - fieldMatch = propType10.getWildcardSetfield().getSetFieldMatch(); + fieldMatch = propType10.getWildcardSetfield().nonnullSetFieldMatch().values(); Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size()); + fieldIt = fieldMatch.iterator(); Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc", - fieldMatch.get(0).getMatchType().getName()); + fieldIt.next().getMatchType().getName()); Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst", - fieldMatch.get(1).getMatchType().getName()); + fieldIt.next().getMatchType().getName()); - property = feature.getTableProperties().getTableFeatureProperties().get(6); + property = featProps.next(); Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions", property.getTableFeaturePropType().implementedInterface().getName()); org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop .type.ApplyActions propType11 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table .feature.prop.type.table.feature.prop.type.ApplyActions) property.getTableFeaturePropType(); - List actionsList = - propType11.getApplyActions().getAction(); + var actionsList = propType11.getApplyActions().nonnullAction().values(); Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size()); + var actionsIt = actionsList.iterator(); Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase", - actionsList.get(0).getAction().implementedInterface().getName()); + actionsIt.next().getAction().implementedInterface().getName()); Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase", - actionsList.get(1).getAction().implementedInterface().getName()); + actionsIt.next().getAction().implementedInterface().getName()); Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase", - actionsList.get(2).getAction().implementedInterface().getName()); + actionsIt.next().getAction().implementedInterface().getName()); - property = feature.getTableProperties().getTableFeatureProperties().get(7); + property = featProps.next(); Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss", property.getTableFeaturePropType().implementedInterface().getName()); org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop .type.ApplyActionsMiss propType12 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026 .table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss) property.getTableFeaturePropType(); - actionsList = propType12.getApplyActionsMiss().getAction(); + actionsList = propType12.getApplyActionsMiss().nonnullAction().values(); Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size()); + actionsIt = actionsList.iterator(); Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase", - actionsList.get(0).getAction().implementedInterface().getName()); + actionsIt.next().getAction().implementedInterface().getName()); Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase", - actionsList.get(1).getAction().implementedInterface().getName()); + actionsIt.next().getAction().implementedInterface().getName()); Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase", - actionsList.get(2).getAction().implementedInterface().getName()); - property = feature.getTableProperties().getTableFeatureProperties().get(8); + actionsIt.next().getAction().implementedInterface().getName()); + property = featProps.next(); Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions", property.getTableFeaturePropType().implementedInterface().getName()); @@ -744,18 +756,19 @@ public class TableFeaturesResponseConvertorTest { org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop .type.WriteActions propType13 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table .feature.prop.type.table.feature.prop.type.WriteActions) property.getTableFeaturePropType(); - actionsList = propType13.getWriteActions().getAction(); + actionsList = propType13.getWriteActions().nonnullAction().values(); Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size()); + actionsIt = actionsList.iterator(); Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase", - actionsList.get(0).getAction().implementedInterface().getName()); + actionsIt.next().getAction().implementedInterface().getName()); Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase", - actionsList.get(1).getAction().implementedInterface().getName()); + actionsIt.next().getAction().implementedInterface().getName()); Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase", - actionsList.get(2).getAction().implementedInterface().getName()); - property = feature.getTableProperties().getTableFeatureProperties().get(9); + actionsIt.next().getAction().implementedInterface().getName()); + property = featProps.next(); Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss", property.getTableFeaturePropType().implementedInterface().getName()); @@ -763,17 +776,18 @@ public class TableFeaturesResponseConvertorTest { org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop .type.WriteActionsMiss propType14 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026 .table.feature.prop.type.table.feature.prop.type.WriteActionsMiss) property.getTableFeaturePropType(); - actionsList = propType14.getWriteActionsMiss().getAction(); + actionsList = propType14.getWriteActionsMiss().nonnullAction().values(); Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size()); + actionsIt = actionsList.iterator(); Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase", - actionsList.get(0).getAction().implementedInterface().getName()); + actionsIt.next().getAction().implementedInterface().getName()); Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase", - actionsList.get(1).getAction().implementedInterface().getName()); + actionsIt.next().getAction().implementedInterface().getName()); Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase", - actionsList.get(2).getAction().implementedInterface().getName()); + actionsIt.next().getAction().implementedInterface().getName()); } private static SetNwSrcCase createSetNwSrcAction() { diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertorTest.java index 868fc81340..e8d20f28c5 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowConvertorTest.java @@ -129,7 +129,7 @@ public class FlowConvertorTest { Assert.assertEquals("Wrong match", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType", flowMod.get(0).getMatch().getType().getName()); - Assert.assertEquals("Wrong match entries size", 0, flowMod.get(0).getMatch().getMatchEntry().size()); + Assert.assertEquals("Wrong match entries size", 0, flowMod.get(0).getMatch().nonnullMatchEntry().size()); } /** @@ -246,13 +246,13 @@ public class FlowConvertorTest { + ".instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase", instruction.getInstructionChoice().implementedInterface().getName()); WriteActionsCase writeActionsCase = (WriteActionsCase) instruction.getInstructionChoice(); - Assert.assertEquals("Wrong actions size", 0, writeActionsCase.getWriteActions().getAction().size()); + Assert.assertEquals("Wrong actions size", 0, writeActionsCase.getWriteActions().nonnullAction().size()); instruction = flowMod.get(0).getInstruction().get(3); Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase", instruction.getInstructionChoice().implementedInterface().getName()); ApplyActionsCase applyActionsCase = (ApplyActionsCase) instruction.getInstructionChoice(); - Assert.assertEquals("Wrong actions size", 0, applyActionsCase.getApplyActions().getAction().size()); + Assert.assertEquals("Wrong actions size", 0, applyActionsCase.getApplyActions().nonnullAction().size()); instruction = flowMod.get(0).getInstruction().get(4); Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase", diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor2Test.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor2Test.java index e31d4fa2d1..3e413a22dc 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor2Test.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/match/MatchResponseConvertor2Test.java @@ -180,12 +180,12 @@ public class MatchResponseConvertor2Test { /** * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}. */ - @Test(expected = NullPointerException.class) public void testEmptyMatch() { final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); - convert(new MatchBuilder().build(), datapathIdConvertorData); + // Empty null match is the same as empty match + Assert.assertNotNull(convert(new MatchBuilder().build(), datapathIdConvertorData)); } /** @@ -204,8 +204,8 @@ public class MatchResponseConvertor2Test { new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3); datapathIdConvertorData.setDatapathId(Uint64.valueOf(42)); - final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow - .MatchBuilder salMatch = convert(match, datapathIdConvertorData); + final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder salMatch = + convert(match, datapathIdConvertorData); final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build(); diff --git a/parent/pom.xml b/parent/pom.xml index 67fe22b5df..b36688edd0 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -12,7 +12,7 @@ org.opendaylight.mdsal binding-parent - 5.0.9 + 6.0.0 @@ -40,8 +40,8 @@ org.opendaylight.controller - mdsal-artifacts - 1.11.0 + controller-artifacts + 2.0.0 pom import diff --git a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowCommitWrapperImpl.java b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowCommitWrapperImpl.java index 0b44181f7e..a6dd4ded3b 100644 --- a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowCommitWrapperImpl.java +++ b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/FlowCommitWrapperImpl.java @@ -25,7 +25,7 @@ public class FlowCommitWrapperImpl implements FlowCommitWrapper { @Override public ListenableFuture writeFlowToConfig(InstanceIdentifier flowPath, Flow flowBody) { ReadWriteTransaction addFlowTransaction = dataBrokerService.newReadWriteTransaction(); - addFlowTransaction.put(LogicalDatastoreType.CONFIGURATION, flowPath, flowBody, true); + addFlowTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, flowPath, flowBody); return addFlowTransaction.commit(); } diff --git a/samples/pom.xml b/samples/pom.xml index 40b002542a..8c7b7dfc62 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent odlparent-lite - 6.0.4 + 7.0.1 diff --git a/samples/simple-client/pom.xml b/samples/simple-client/pom.xml index 358cb3b1bb..a300cb349c 100644 --- a/samples/simple-client/pom.xml +++ b/samples/simple-client/pom.xml @@ -47,8 +47,8 @@ argparse4j - javax.xml.bind - jaxb-api + jakarta.xml.bind + jakarta.xml.bind-api diff --git a/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestCommiter.java b/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestCommiter.java index 32c8a05047..82fedc5a0c 100644 --- a/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestCommiter.java +++ b/test-common/src/main/java/org/opendaylight/openflowplugin/testcommon/DropTestCommiter.java @@ -109,7 +109,7 @@ public class DropTestCommiter extends AbstractDropTest { if (LOG.isDebugEnabled()) { LOG.debug("onPacketReceived - About to write flow {}", flow); } - transaction.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow, true); + transaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow); transaction.commit(); LOG.debug("onPacketReceived - About to write flow commited"); } diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkGroupTransactionProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkGroupTransactionProvider.java index e183029cf8..bfc7e90de1 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkGroupTransactionProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkGroupTransactionProvider.java @@ -705,14 +705,16 @@ public class OpenflowPluginBulkGroupTransactionProvider implements CommandProvid InstanceIdentifier path1 = InstanceIdentifier.create(Nodes.class) .child(Node.class, testNode12.key()).augmentation(FlowCapableNode.class) .child(Group.class, new GroupKey(group.getGroupId())); - modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12), testNode12, true); - modification.merge(LogicalDatastoreType.CONFIGURATION, path1, group, true); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12), + testNode12); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, group); InstanceIdentifier path2 = InstanceIdentifier.create(Nodes.class) .child(Node.class, testNode12.key()).augmentation(FlowCapableNode.class) .child(Group.class, new GroupKey(group1.getGroupId())); - modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12), testNode12, true); - modification.merge(LogicalDatastoreType.CONFIGURATION, path2, group1, true); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12), + testNode12); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path2, group1); modification.commit().addCallback(new FutureCallback() { @Override public void onSuccess(Object notUsed) { diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkTransactionProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkTransactionProvider.java index 6c2c130012..6cf574b720 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkTransactionProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowPluginBulkTransactionProvider.java @@ -668,41 +668,41 @@ public class OpenflowPluginBulkTransactionProvider implements CommandProvider { InstanceIdentifier path1 = InstanceIdentifier.create(Nodes.class) .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class) .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.key()); - modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), - true); - modification.merge(LogicalDatastoreType.OPERATIONAL, path1, flow.build(), true); - modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), - nodeBuilder.build(), true); - modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true); + modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), + nodeBuilder.build()); + modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path1, flow.build()); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), + nodeBuilder.build()); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, flow.build()); InstanceIdentifier path2 = InstanceIdentifier.create(Nodes.class) .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class) .child(Table.class, new TableKey(flow1.getTableId())).child(Flow.class, flow1.key()); - modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), - true); - modification.merge(LogicalDatastoreType.OPERATIONAL, path2, flow1.build(), true); - modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), - nodeBuilder.build(), true); - modification.merge(LogicalDatastoreType.CONFIGURATION, path2, flow1.build(), true); + modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), + nodeBuilder.build()); + modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path2, flow1.build()); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), + nodeBuilder.build()); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path2, flow1.build()); InstanceIdentifier path3 = InstanceIdentifier.create(Nodes.class) .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class) .child(Table.class, new TableKey(flow2.getTableId())).child(Flow.class, flow2.key()); - modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), - true); - modification.merge(LogicalDatastoreType.OPERATIONAL, path3, flow2.build(), true); - modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), - nodeBuilder.build(), true); - modification.merge(LogicalDatastoreType.CONFIGURATION, path3, flow2.build(), true); + modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), + nodeBuilder.build()); + modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path3, flow2.build()); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), + nodeBuilder.build()); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path3, flow2.build()); InstanceIdentifier path4 = InstanceIdentifier.create(Nodes.class) .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class) .child(Table.class, new TableKey(flow3.getTableId())).child(Flow.class, flow3.key()); - modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), - true); - modification.merge(LogicalDatastoreType.OPERATIONAL, path4, flow3.build(), true); - modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), - nodeBuilder.build(), true); - modification.merge(LogicalDatastoreType.CONFIGURATION, path4, flow3.build(), true); + modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), + nodeBuilder.build()); + modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path4, flow3.build()); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), + nodeBuilder.build()); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path4, flow3.build()); modification.commit().addCallback(new FutureCallback() { @Override public void onSuccess(Object notUsed) { diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestCommandProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestCommandProvider.java index 2c47a55b8a..03226cecd3 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestCommandProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestCommandProvider.java @@ -11,6 +11,7 @@ import com.google.common.base.Preconditions; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.MoreExecutors; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; @@ -209,7 +210,7 @@ public class OpenflowpluginGroupTestCommandProvider implements CommandProvider { bucket.setAction(createInportOutputAction()); break; case "a24": - bucket.setAction(null); + bucket.setAction(Collections.EMPTY_LIST); break; case "a25": bucket.setAction(createNonAppyOutputAction()); @@ -613,8 +614,9 @@ public class OpenflowpluginGroupTestCommandProvider implements CommandProvider { InstanceIdentifier path1 = InstanceIdentifier.create(Nodes.class) .child(Node.class, testNode.key()).augmentation(FlowCapableNode.class) .child(Group.class, new GroupKey(group.getGroupId())); - modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true); - modification.merge(LogicalDatastoreType.CONFIGURATION, path1, group, true); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), + testNode); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, group); modification.commit().addCallback(new FutureCallback() { @Override public void onSuccess(Object notUsed) { diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestCommandProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestCommandProvider.java index 98f9aa22c6..f385405a12 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestCommandProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestCommandProvider.java @@ -377,8 +377,9 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider { ReadWriteTransaction modification = dataBroker.newReadWriteTransaction(); InstanceIdentifier path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.key()) .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter.getMeterId())); - modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true); - modification.merge(LogicalDatastoreType.CONFIGURATION, path1, meter, true); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), + testNode); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, meter); modification.commit().addCallback(new FutureCallback() { @Override public void onSuccess(Object notUsed) { @@ -396,12 +397,14 @@ public class OpenflowpluginMeterTestCommandProvider implements CommandProvider { ReadWriteTransaction modification = dataBroker.newReadWriteTransaction(); InstanceIdentifier path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.key()) .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter.getMeterId())); - modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true); - modification.merge(LogicalDatastoreType.CONFIGURATION, path1, meter, true); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), + testNode); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, meter); InstanceIdentifier path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.key()) .augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter1.getMeterId())); - modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true); - modification.merge(LogicalDatastoreType.CONFIGURATION, path2, meter1, true); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), + testNode); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path2, meter1); modification.commit().addCallback(new FutureCallback() { @Override diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginStatsTestCommandProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginStatsTestCommandProvider.java index 3c04d436f2..f598e1f3a9 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginStatsTestCommandProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginStatsTestCommandProvider.java @@ -8,7 +8,7 @@ package org.opendaylight.openflowplugin.test; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.util.List; +import java.util.Collection; import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; import org.opendaylight.mdsal.binding.api.DataBroker; @@ -61,7 +61,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { public void _portStats(CommandInterpreter ci) { int nodeConnectorCount = 0; int nodeConnectorStatsCount = 0; - List nodes = getNodes(); + Collection nodes = getNodes(); for (Node node2 : nodes) { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey); @@ -69,7 +69,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { Node node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { if (node.getNodeConnector() != null) { - List ports = node.getNodeConnector(); + Collection ports = node.nonnullNodeConnector().values(); for (NodeConnector nodeConnector2 : ports) { nodeConnectorCount++; @@ -102,7 +102,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { public void _portDescStats(CommandInterpreter ci) { int nodeConnectorCount = 0; int nodeConnectorDescStatsCount = 0; - List nodes = getNodes(); + Collection nodes = getNodes(); for (Node node2 : nodes) { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey); @@ -111,7 +111,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { Node node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { if (node.getNodeConnector() != null) { - List ports = node.getNodeConnector(); + Collection ports = node.nonnullNodeConnector().values(); for (NodeConnector nodeConnector2 : ports) { nodeConnectorCount++; NodeConnectorKey nodeConnectorKey = nodeConnector2.key(); @@ -147,7 +147,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { public void _flowStats(CommandInterpreter ci) { int flowCount = 0; int flowStatsCount = 0; - List nodes = getNodes(); + Collection nodes = getNodes(); for (Node node2 : nodes) { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class) @@ -157,7 +157,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { - List
tables = node.getTable(); + Collection
tables = node.nonnullTable().values(); for (Table table2 : tables) { TableKey tableKey = table2.key(); InstanceIdentifier
tableRef = InstanceIdentifier.create(Nodes.class) @@ -166,7 +166,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { Table table = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, tableRef); if (table != null) { if (table.getFlow() != null) { - List flows = table.getFlow(); + Collection flows = table.nonnullFlow().values(); for (Flow flow2 : flows) { flowCount++; FlowKey flowKey = flow2.key(); @@ -202,7 +202,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { public void _tableStats(CommandInterpreter ci) { int tableCount = 0; int tableStatsCount = 0; - List nodes = getNodes(); + Collection nodes = getNodes(); for (Node node2 : nodes) { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class) @@ -211,7 +211,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { - List
tables = node.getTable(); + Collection
tables = node.nonnullTable().values(); for (Table table2 : tables) { tableCount++; TableKey tableKey = table2.key(); @@ -242,7 +242,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { int groupCount = 0; int groupStatsCount = 0; NodeGroupStatistics data = null; - List nodes = getNodes(); + Collection nodes = getNodes(); for (Node node2 : nodes) { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class) @@ -251,7 +251,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { if (node.getGroup() != null) { - List groups = node.getGroup(); + Collection groups = node.nonnullGroup().values(); for (Group group2 : groups) { groupCount++; GroupKey groupKey = group2.key(); @@ -283,7 +283,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { int groupCount = 0; int groupDescStatsCount = 0; NodeGroupDescStats data = null; - List nodes = getNodes(); + Collection nodes = getNodes(); for (Node node2 : nodes) { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class) @@ -293,7 +293,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { if (node != null) { if (node.getGroup() != null) { - List groups = node.getGroup(); + Collection groups = node.nonnullGroup().values(); for (Group group2 : groups) { groupCount++; GroupKey groupKey = group2.key(); @@ -325,7 +325,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { int meterCount = 0; int meterStatsCount = 0; NodeMeterStatistics data = null; - List nodes = getNodes(); + Collection nodes = getNodes(); for (Node node2 : nodes) { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class) @@ -334,7 +334,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { if (node.getMeter() != null) { - List meters = node.getMeter(); + Collection meters = node.nonnullMeter().values(); for (Meter meter2 : meters) { meterCount++; MeterKey meterKey = meter2.key(); @@ -366,7 +366,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { int meterCount = 0; int meterConfigStatsCount = 0; NodeMeterConfigStats data = null; - List nodes = getNodes(); + Collection nodes = getNodes(); for (Node node2 : nodes) { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class) @@ -375,7 +375,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { if (node.getMeter() != null) { - List meters = node.getMeter(); + Collection meters = node.nonnullMeter().values(); for (Meter meter2 : meters) { meterCount++; MeterKey meterKey = meter2.key(); @@ -407,7 +407,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { public void _aggregateStats(CommandInterpreter ci) { int aggregateFlowCount = 0; int aggerateFlowStatsCount = 0; - List nodes = getNodes(); + Collection nodes = getNodes(); for (Node node2 : nodes) { NodeKey nodeKey = node2.key(); InstanceIdentifier nodeRef = InstanceIdentifier.create(Nodes.class) @@ -415,7 +415,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef); if (node != null) { - List
tables = node.getTable(); + Collection
tables = node.nonnullTable().values(); for (Table table2 : tables) { aggregateFlowCount++; TableKey tableKey = table2.key(); @@ -445,7 +445,7 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { public void _descStats(CommandInterpreter ci) { int descCount = 0; int descStatsCount = 0; - List nodes = getNodes(); + Collection nodes = getNodes(); for (Node node2 : nodes) { descCount++; NodeKey nodeKey = node2.key(); @@ -469,14 +469,14 @@ public class OpenflowpluginStatsTestCommandProvider implements CommandProvider { } - private List getNodes() { + private Collection getNodes() { ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction(); InstanceIdentifier nodesID = InstanceIdentifier.create(Nodes.class); Nodes nodes = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodesID); if (nodes == null) { throw new RuntimeException("nodes are not found, pls add the node."); } - return nodes.getNode(); + return nodes.nonnullNode().values(); } @Override diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java index 5a47b1a491..282c3f4b65 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestCommandProvider.java @@ -28,8 +28,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; @@ -277,12 +275,6 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr private TableFeaturePropertiesBuilder createInstructionsTblFeatureProp() { - InstructionBuilder ib = new InstructionBuilder(); - ib.setOrder(1); - ib.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction - .instruction.ApplyActionsCaseBuilder().build()); - ib.withKey(new InstructionKey(1)); - List instLst = new ArrayList<>(); TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder(); tableFeatureProperty.setTableFeaturePropType( @@ -303,18 +295,6 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr private TableFeaturePropertiesBuilder createInstructionsMissTblFeatureProp() { // To set the instructions miss -- "t7" - InstructionBuilder ib1 = new InstructionBuilder(); - ib1.setOrder(1); - ib1.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction - .instruction.WriteMetadataCaseBuilder().build()); - ib1.withKey(new InstructionKey(1)); - - InstructionBuilder ib2 = new InstructionBuilder(); - ib2.setOrder(2); - ib2.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction - .instruction.MeterCaseBuilder().build()); - ib2.withKey(new InstructionKey(2)); - List instLst = new ArrayList<>(); TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder(); tableFeatureProperty.setTableFeaturePropType( @@ -595,10 +575,11 @@ public class OpenflowpluginTableFeaturesTestCommandProvider implements CommandPr .child(Node.class, testNode.key()).augmentation(FlowCapableNode.class) .child(TableFeatures.class, new TableFeaturesKey(tableFeatures.getTableId())); - modification.merge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode, true); - modification.merge(LogicalDatastoreType.OPERATIONAL, path1, tableFeatures, true); - modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true); - modification.merge(LogicalDatastoreType.CONFIGURATION, path1, tableFeatures, true); + modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode); + modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path1, tableFeatures); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), + testNode); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, tableFeatures); modification.commit().addCallback(new FutureCallback() { @Override public void onSuccess(Object notUsed) { diff --git a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java index c36ed44ced..d4de894d66 100644 --- a/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java +++ b/test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestCommandProvider.java @@ -1661,8 +1661,6 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider { final List actionList = new ArrayList<>(); final ActionBuilder ab = new ActionBuilder(); - final SetFieldBuilder setFieldBuilder = new SetFieldBuilder(); - setFieldBuilder.setInPort(new NodeConnectorId(nodeId + ":2")); ab.withKey(new ActionKey(0)); actionList.add(ab.build()); @@ -2206,7 +2204,7 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider { setFieldBuilder1.setLayer4Match(tcpmatch1.build()); ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build()); ab1.withKey(new ActionKey(1)); - actionList.add(ab.build()); + actionList.add(ab1.build()); final ApplyActionsBuilder aab = new ApplyActionsBuilder(); aab.setAction(actionList); @@ -3184,9 +3182,9 @@ public class OpenflowpluginTestCommandProvider implements CommandProvider { final InstanceIdentifier path1 = InstanceIdentifier.create(Nodes.class) .child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class) .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.key()); - modification.merge(LogicalDatastoreType.CONFIGURATION, - nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true); - modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, + nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build()); + modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, flow.build()); modification.commit().addCallback(new FutureCallback() { @Override public void onSuccess(final Object notUsed) { -- 2.36.6