From: Robert Varga Date: Mon, 14 Mar 2022 07:54:01 +0000 (+0100) Subject: Bump MRI upstreams X-Git-Tag: release/sulfur~5 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=19face1c20178f24fbe9caa81bac69938e853ab4;p=lispflowmapping.git Bump MRI upstreams Adopt the following versions: - odlparent-10.0.0 - infrautils-3.0.0 - yangtools-8.0.2 - mdsal-9.0.1 - controller-5.0.1 - aaa-0.15.1 - netconf-3.0.0 Change-Id: Ia4cd90ea1a8aa4f56a3e1853cb3363d40752e2b6 Signed-off-by: Robert Varga --- diff --git a/artifacts/pom.xml b/artifacts/pom.xml index f6fd7d7f7..d513cb31e 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.odlparent odlparent-lite - 9.0.13 + 10.0.0 diff --git a/commons/parent/pom.xml b/commons/parent/pom.xml index f1e4269dd..79eb742e3 100644 --- a/commons/parent/pom.xml +++ b/commons/parent/pom.xml @@ -15,7 +15,7 @@ for plugin configuration etc. --> org.opendaylight.odlparent odlparent - 9.0.13 + 10.0.0 @@ -46,9 +46,9 @@ org.opendaylight.mdsal mdsal-artifacts - 8.0.11 + 9.0.1 pom - import + import junit-addons @@ -68,7 +68,7 @@ org.opendaylight.controller controller-artifacts - 4.0.10 + 5.0.1 pom import diff --git a/features/features-lispflowmapping/pom.xml b/features/features-lispflowmapping/pom.xml index ee018fbc9..5a75051af 100644 --- a/features/features-lispflowmapping/pom.xml +++ b/features/features-lispflowmapping/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.odlparent feature-repo-parent - 9.0.13 + 10.0.0 diff --git a/features/odl-lispflowmapping-inmemorydb/pom.xml b/features/odl-lispflowmapping-inmemorydb/pom.xml index ad9b27ff5..f0129e350 100644 --- a/features/odl-lispflowmapping-inmemorydb/pom.xml +++ b/features/odl-lispflowmapping-inmemorydb/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 @@ -24,11 +24,28 @@ and is available at http://www.eclipse.org/legal/epl-v10.html build failure. Please do not modify this unless you have a good reason. --> ODL :: lispflowmapping :: ${project.artifactId} + + + + org.opendaylight.controller + controller-artifacts + 5.0.1 + pom + import + + + + + + org.opendaylight.controller + odl-controller-blueprint + xml + features + org.opendaylight.controller odl-mdsal-broker - 4.0.10 xml features diff --git a/features/odl-lispflowmapping-inmemorydb/src/main/feature/feature.xml b/features/odl-lispflowmapping-inmemorydb/src/main/feature/feature.xml index 297723a5b..c1466b173 100644 --- a/features/odl-lispflowmapping-inmemorydb/src/main/feature/feature.xml +++ b/features/odl-lispflowmapping-inmemorydb/src/main/feature/feature.xml @@ -8,6 +8,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL --> - odl-mdsal-broker + odl-mdsal-broker + odl-controller-blueprint diff --git a/features/odl-lispflowmapping-mappingservice-shell/pom.xml b/features/odl-lispflowmapping-mappingservice-shell/pom.xml index f498ff985..84f64df59 100644 --- a/features/odl-lispflowmapping-mappingservice-shell/pom.xml +++ b/features/odl-lispflowmapping-mappingservice-shell/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/features/odl-lispflowmapping-mappingservice/pom.xml b/features/odl-lispflowmapping-mappingservice/pom.xml index 9adf2f4be..7007eb5a9 100644 --- a/features/odl-lispflowmapping-mappingservice/pom.xml +++ b/features/odl-lispflowmapping-mappingservice/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 @@ -28,7 +28,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.netconf odl-restconf - 2.0.14 + 3.0.0 xml features diff --git a/features/odl-lispflowmapping-models/pom.xml b/features/odl-lispflowmapping-models/pom.xml index fbdf4a984..f114562a0 100644 --- a/features/odl-lispflowmapping-models/pom.xml +++ b/features/odl-lispflowmapping-models/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 @@ -29,7 +29,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.mdsal mdsal-artifacts - 8.0.11 + 9.0.1 pom import diff --git a/features/odl-lispflowmapping-models/src/main/feature/feature.xml b/features/odl-lispflowmapping-models/src/main/feature/feature.xml index 788751c84..0a5c3c9f0 100644 --- a/features/odl-lispflowmapping-models/src/main/feature/feature.xml +++ b/features/odl-lispflowmapping-models/src/main/feature/feature.xml @@ -8,7 +8,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL --> - odl-apache-commons-lang3 - odl-mdsal-model-rfc6991 + odl-apache-commons-lang3 + odl-mdsal-model-rfc6991 diff --git a/features/odl-lispflowmapping-msmr/pom.xml b/features/odl-lispflowmapping-msmr/pom.xml index 06d601ca4..256e0fe42 100644 --- a/features/odl-lispflowmapping-msmr/pom.xml +++ b/features/odl-lispflowmapping-msmr/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 diff --git a/features/odl-lispflowmapping-southbound/pom.xml b/features/odl-lispflowmapping-southbound/pom.xml index 0f8a88fb8..824bd80d2 100644 --- a/features/odl-lispflowmapping-southbound/pom.xml +++ b/features/odl-lispflowmapping-southbound/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.odlparent single-feature-parent - 9.0.13 + 10.0.0 @@ -28,14 +28,14 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.netconf odl-restconf - 2.0.14 + 3.0.0 xml features org.opendaylight.controller odl-mdsal-broker - 4.0.10 + 5.0.1 xml features diff --git a/features/odl-lispflowmapping-southbound/src/main/feature/feature.xml b/features/odl-lispflowmapping-southbound/src/main/feature/feature.xml index 657eaf0f6..729aae01d 100644 --- a/features/odl-lispflowmapping-southbound/src/main/feature/feature.xml +++ b/features/odl-lispflowmapping-southbound/src/main/feature/feature.xml @@ -8,7 +8,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL --> - odl-netty-4 - odl-mdsal-broker + odl-netty-4 + odl-mdsal-broker diff --git a/features/pom.xml b/features/pom.xml index 3d29369de..1f0db8a18 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.odlparent odlparent-lite - 9.0.13 + 10.0.0 diff --git a/integrationtest/pom.xml b/integrationtest/pom.xml index 8c5f5b363..bbe23f17f 100644 --- a/integrationtest/pom.xml +++ b/integrationtest/pom.xml @@ -11,7 +11,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.controller mdsal-it-parent - 4.0.10 + 5.0.1 diff --git a/integrationtest/src/test/java/org/opendaylight/lispflowmapping/integrationtest/MappingServiceIntegrationTest.java b/integrationtest/src/test/java/org/opendaylight/lispflowmapping/integrationtest/MappingServiceIntegrationTest.java index 8e84a6859..f78241564 100644 --- a/integrationtest/src/test/java/org/opendaylight/lispflowmapping/integrationtest/MappingServiceIntegrationTest.java +++ b/integrationtest/src/test/java/org/opendaylight/lispflowmapping/integrationtest/MappingServiceIntegrationTest.java @@ -33,6 +33,7 @@ import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configure import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut; import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import java.io.File; @@ -47,6 +48,7 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Set; import javax.inject.Inject; @@ -505,9 +507,9 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase { final MapReply mapReply1 = lms.handleMapRequest( new MapRequestBuilder(requests1.get(0)) .setSourceEid(new SourceEidBuilder().setEid(subscriberEid).build()) - .setItrRloc(Lists.newArrayList(new ItrRlocBuilder() + .setItrRloc(List.of(new ItrRlocBuilder() .setRloc(LispAddressUtil.asIpv4Rloc(subscriberSrcRloc1)).build())) - .setEidItem(Lists.newArrayList(new EidItemBuilder().setEid(eid1).build())) + .setEidItem(List.of(new EidItemBuilder().setEid(eid1).build())) .setSmrInvoked(true) .setSmr(false).build()); @@ -517,9 +519,9 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase { final MapReply mapReply2 = lms.handleMapRequest( new MapRequestBuilder(requests2.get(0)) .setSourceEid(new SourceEidBuilder().setEid(subscriberEid).build()) - .setItrRloc(Lists.newArrayList(new ItrRlocBuilder() + .setItrRloc(List.of(new ItrRlocBuilder() .setRloc(LispAddressUtil.asIpv4Rloc(subscriberSrcRloc2)).build())) - .setEidItem(Lists.newArrayList(new EidItemBuilder().setEid(eid1).build())) + .setEidItem(List.of(new EidItemBuilder().setEid(eid1).build())) .setSmrInvoked(true) .setSmr(false).build()); @@ -554,7 +556,7 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase { LOG.error("Unknown address {}.", address, e); } - final List requests = Lists.newArrayList(); + final List requests = new ArrayList<>(); byte[][] buffers = reader.getBuffers(expectedSmrs); for (byte[] buf : buffers) { ByteBuffer packet = ByteBuffer.wrap(buf); @@ -2595,11 +2597,10 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase { cleanUP(); String macString = "01:02:03:04:05:06"; String ipString = "10.20.255.30"; - List addresses = new ArrayList(); - addresses.add(new SimpleAddress(new IpAddress(new Ipv4Address(ipString)))); - addresses.add(new SimpleAddress(new MacAddress(macString))); AfiListBuilder listbuilder = new AfiListBuilder(); - listbuilder.setAddressList(addresses); + listbuilder.setAddressList(ImmutableSet.of( + new SimpleAddress(new IpAddress(new Ipv4Address(ipString))), + new SimpleAddress(new MacAddress(macString)))); EidBuilder eb = new EidBuilder(); eb.setAddressType(AfiListLcaf.class); @@ -2614,8 +2615,9 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase { assertEquals(AfiListLcaf.class, receivedAddress.getAddressType()); AfiList listAddrFromNetwork = (AfiList) receivedAddress.getAddress(); - SimpleAddress receivedAddr1 = (SimpleAddress) listAddrFromNetwork.getAfiList().getAddressList().get(0); - SimpleAddress receivedAddr2 = (SimpleAddress) listAddrFromNetwork.getAfiList().getAddressList().get(1); + Iterator addrList = listAddrFromNetwork.getAfiList().getAddressList().iterator(); + SimpleAddress receivedAddr1 = addrList.next(); + SimpleAddress receivedAddr2 = addrList.next(); assertNotNull(receivedAddr1.getIpAddress().getIpv4Address()); assertNotNull(receivedAddr2.getMacAddress()); @@ -2675,8 +2677,8 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase { ExplicitLocatorPath receivedAddress = (ExplicitLocatorPath) reply.getMappingRecordItem().get(0) .getMappingRecord().getEid().getAddress(); - Hop receivedHop1 = (Hop) receivedAddress.getExplicitLocatorPath().getHop().get(0); - Hop receivedHop2 = (Hop) receivedAddress.getExplicitLocatorPath().getHop().get(1); + Hop receivedHop1 = receivedAddress.getExplicitLocatorPath().getHop().get(0); + Hop receivedHop2 = receivedAddress.getExplicitLocatorPath().getHop().get(1); assertEquals(true, receivedHop1.getLrsBits().getLookup()); assertEquals(false, receivedHop1.getLrsBits().getRlocProbe()); diff --git a/lispflowmapping-karaf/pom.xml b/lispflowmapping-karaf/pom.xml index 102f549ea..670ec1c1d 100644 --- a/lispflowmapping-karaf/pom.xml +++ b/lispflowmapping-karaf/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.odlparent karaf4-parent - 9.0.13 + 10.0.0 diff --git a/mappingservice/api/pom.xml b/mappingservice/api/pom.xml index dea3de379..58f1832b0 100644 --- a/mappingservice/api/pom.xml +++ b/mappingservice/api/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.mdsal binding-parent - 8.0.11 + 9.0.1 diff --git a/mappingservice/config/pom.xml b/mappingservice/config/pom.xml index a9c247ecc..9514fc67f 100644 --- a/mappingservice/config/pom.xml +++ b/mappingservice/config/pom.xml @@ -17,7 +17,7 @@ org.osgi - osgi.core + org.osgi.framework org.opendaylight.lispflowmapping diff --git a/mappingservice/dsbackend/pom.xml b/mappingservice/dsbackend/pom.xml index a99c77d7c..932b5005c 100644 --- a/mappingservice/dsbackend/pom.xml +++ b/mappingservice/dsbackend/pom.xml @@ -44,13 +44,23 @@ junit-addons junit-addons + + org.mockito + mockito-core + 3.12.4 + test + org.powermock powermock-api-mockito2 + 2.0.9 + test org.powermock powermock-module-junit4 + 2.0.9 + test diff --git a/mappingservice/dsbackend/src/main/java/org/opendaylight/lispflowmapping/dsbackend/DataStoreBackEnd.java b/mappingservice/dsbackend/src/main/java/org/opendaylight/lispflowmapping/dsbackend/DataStoreBackEnd.java index 91c92d6e6..f68297731 100644 --- a/mappingservice/dsbackend/src/main/java/org/opendaylight/lispflowmapping/dsbackend/DataStoreBackEnd.java +++ b/mappingservice/dsbackend/src/main/java/org/opendaylight/lispflowmapping/dsbackend/DataStoreBackEnd.java @@ -12,6 +12,7 @@ import static java.util.Objects.requireNonNull; import com.google.common.util.concurrent.FutureCallback; 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.Date; import java.util.List; @@ -54,6 +55,7 @@ public class DataStoreBackEnd implements TransactionChainListener { private final DataBroker broker; private TransactionChain txChain; + @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "Non-final for mocking") public DataStoreBackEnd(DataBroker broker) { this.broker = broker; createTransactionChain(); diff --git a/mappingservice/implementation/pom.xml b/mappingservice/implementation/pom.xml index ae3f9c444..1078cff5e 100644 --- a/mappingservice/implementation/pom.xml +++ b/mappingservice/implementation/pom.xml @@ -21,7 +21,7 @@ org.osgi - osgi.core + org.osgi.framework ${project.groupId} @@ -51,13 +51,23 @@ junit-addons junit-addons + + org.mockito + mockito-core + 3.12.4 + test + org.powermock powermock-api-mockito2 + 2.0.9 + test org.powermock powermock-module-junit4 + 2.0.9 + test org.opendaylight.lispflowmapping diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/MappingService.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/MappingService.java index 86040aa35..c4cf63f57 100644 --- a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/MappingService.java +++ b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/MappingService.java @@ -9,7 +9,6 @@ package org.opendaylight.lispflowmapping.implementation; import static java.util.Objects.requireNonNull; -import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import java.util.ArrayList; import java.util.List; @@ -91,7 +90,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev15090 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateMappingOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateMappingsInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateMappingsOutput; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorTag; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -110,8 +110,6 @@ import org.slf4j.LoggerFactory; */ public class MappingService implements OdlMappingserviceService, IMappingService, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(MappingService.class); - private static final String NOT_FOUND_TAG = "data-missing"; - private static final String DATA_EXISTS_TAG = "data-exists"; private MappingSystem mappingSystem; private DataStoreBackEnd dsbe; @@ -168,7 +166,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService @Override public ListenableFuture> addKey(AddKeyInput input) { requireNonNull(input, "add-key RPC input must be not null!"); - LOG.trace("RPC received to add the following key: " + input.toString()); + LOG.trace("RPC received to add the following key: {}", input); RpcResultBuilder rpcResultBuilder; @@ -177,20 +175,20 @@ public class MappingService implements OdlMappingserviceService, IMappingService if (key != null) { String message = "Key already exists! Please use update-key if you want to change it."; rpcResultBuilder = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.PROTOCOL, DATA_EXISTS_TAG, message); - return Futures.immediateFuture(rpcResultBuilder.build()); + .withError(ErrorType.PROTOCOL, ErrorTag.DATA_EXISTS, message); + return rpcResultBuilder.buildFuture(); } dsbe.addAuthenticationKey(RPCInputConvertorUtil.toAuthenticationKey(input)); rpcResultBuilder = RpcResultBuilder.success(new AddKeyOutputBuilder().build()); - return Futures.immediateFuture(rpcResultBuilder.build()); + return rpcResultBuilder.buildFuture(); } @Override public ListenableFuture> addMapping(AddMappingInput input) { requireNonNull(input, "add-mapping RPC input must be not null!"); - LOG.trace("RPC received to add the following mapping: " + input.toString()); + LOG.trace("RPC received to add the following mapping: {}", input); dsbe.addMapping(RPCInputConvertorUtil.toMapping(input)); @@ -198,7 +196,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService rpcResultBuilder = RpcResultBuilder.success(new AddMappingOutputBuilder().build()); - return Futures.immediateFuture(rpcResultBuilder.build()); + return rpcResultBuilder.buildFuture(); } @Override @@ -230,7 +228,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService @Override public ListenableFuture> getKey(GetKeyInput input) { requireNonNull(input, "get-key RPC input must be not null!"); - LOG.trace("RPC received to get the following key: " + input.toString()); + LOG.trace("RPC received to get the following key: {}", input); RpcResultBuilder rpcResultBuilder; @@ -239,18 +237,18 @@ public class MappingService implements OdlMappingserviceService, IMappingService if (key == null) { String message = "Key was not found in the mapping database"; rpcResultBuilder = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, NOT_FOUND_TAG, message); + .withError(ErrorType.APPLICATION, ErrorTag.DATA_MISSING, message); } else { - rpcResultBuilder = RpcResultBuilder.success(new GetKeyOutputBuilder().setMappingAuthkey(key)); + rpcResultBuilder = RpcResultBuilder.success(new GetKeyOutputBuilder().setMappingAuthkey(key).build()); } - return Futures.immediateFuture(rpcResultBuilder.build()); + return rpcResultBuilder.buildFuture(); } @Override public ListenableFuture> getMapping(GetMappingInput input) { requireNonNull(input, "get-mapping RPC input must be not null!"); - LOG.trace("RPC received to get the following mapping: " + input.toString()); + LOG.trace("RPC received to get the following mapping: {}", input); RpcResultBuilder rpcResultBuilder; @@ -259,13 +257,14 @@ public class MappingService implements OdlMappingserviceService, IMappingService if (reply == null) { String message = "No mapping was found in the mapping database"; rpcResultBuilder = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, NOT_FOUND_TAG, message); + .withError(ErrorType.APPLICATION, ErrorTag.DATA_MISSING, message); } else { final MappingRecord convertedReply = convertFromBinaryIfNecessary(reply.getRecord()); - rpcResultBuilder = RpcResultBuilder.success(new GetMappingOutputBuilder().setMappingRecord(convertedReply)); + rpcResultBuilder = RpcResultBuilder.success( + new GetMappingOutputBuilder().setMappingRecord(convertedReply).build()); } - return Futures.immediateFuture(rpcResultBuilder.build()); + return rpcResultBuilder.buildFuture(); } @Override @@ -296,7 +295,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService @Override public ListenableFuture> getMappingWithXtrId(GetMappingWithXtrIdInput input) { requireNonNull(input, "get-mapping RPC input must be not null!"); - LOG.trace("RPC received to get the following mapping: " + input.toString()); + LOG.trace("RPC received to get the following mapping: {}", input); RpcResultBuilder rpcResultBuilder; @@ -306,20 +305,20 @@ public class MappingService implements OdlMappingserviceService, IMappingService if (reply == null) { String message = "No mapping was found in the mapping database"; rpcResultBuilder = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, NOT_FOUND_TAG, message); + .withError(ErrorType.APPLICATION, ErrorTag.DATA_MISSING, message); } else { final MappingRecord convertedReply = convertFromBinaryIfNecessary(reply.getRecord()); rpcResultBuilder = RpcResultBuilder.success(new GetMappingWithXtrIdOutputBuilder() - .setMappingRecord(convertedReply)); + .setMappingRecord(convertedReply).build()); } - return Futures.immediateFuture(rpcResultBuilder.build()); + return rpcResultBuilder.buildFuture(); } @Override public ListenableFuture> removeKey(RemoveKeyInput input) { requireNonNull(input, "remove-key RPC input must be not null!"); - LOG.trace("RPC received to remove the following key: " + input.toString()); + LOG.trace("RPC received to remove the following key: {}", input); RpcResultBuilder rpcResultBuilder; @@ -327,13 +326,13 @@ public class MappingService implements OdlMappingserviceService, IMappingService rpcResultBuilder = RpcResultBuilder.success(new RemoveKeyOutputBuilder().build()); - return Futures.immediateFuture(rpcResultBuilder.build()); + return rpcResultBuilder.buildFuture(); } @Override public ListenableFuture> removeMapping(RemoveMappingInput input) { requireNonNull(input, "remove-mapping RPC input must be not null!"); - LOG.trace("RPC received to remove the following mapping: " + input.toString()); + LOG.trace("RPC received to remove the following mapping: {}", input); RpcResultBuilder rpcResultBuilder; @@ -341,7 +340,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService rpcResultBuilder = RpcResultBuilder.success(new RemoveMappingOutputBuilder().build()); - return Futures.immediateFuture(rpcResultBuilder.build()); + return rpcResultBuilder.buildFuture(); } @Override @@ -355,7 +354,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService @Override public ListenableFuture> updateKey(UpdateKeyInput input) { requireNonNull(input, "update-key RPC input must be not null!"); - LOG.trace("RPC received to update the following key: " + input.toString()); + LOG.trace("RPC received to update the following key: {}", input); RpcResultBuilder rpcResultBuilder; @@ -364,19 +363,19 @@ public class MappingService implements OdlMappingserviceService, IMappingService if (key == null) { String message = "Key doesn't exist! Please use add-key if you want to create a new authentication key."; rpcResultBuilder = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.PROTOCOL, NOT_FOUND_TAG, message); - return Futures.immediateFuture(rpcResultBuilder.build()); + .withError(ErrorType.PROTOCOL, ErrorTag.DATA_MISSING, message); + return rpcResultBuilder.buildFuture(); } dsbe.updateAuthenticationKey(RPCInputConvertorUtil.toAuthenticationKey(input)); rpcResultBuilder = RpcResultBuilder.success(new UpdateKeyOutputBuilder().build()); - return Futures.immediateFuture(rpcResultBuilder.build()); + return rpcResultBuilder.buildFuture(); } @Override public ListenableFuture> updateMapping(UpdateMappingInput input) { - LOG.trace("RPC received to update the following mapping: " + input.toString()); + LOG.trace("RPC received to update the following mapping: {}", input); requireNonNull(input, "update-mapping RPC input must be not null!"); RpcResultBuilder rpcResultBuilder; @@ -385,7 +384,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService rpcResultBuilder = RpcResultBuilder.success(new UpdateMappingOutputBuilder().build()); - return Futures.immediateFuture(rpcResultBuilder.build()); + return rpcResultBuilder.buildFuture(); } @Override @@ -477,7 +476,7 @@ public class MappingService implements OdlMappingserviceService, IMappingService rpcResultBuilder = RpcResultBuilder.success(new RemoveAllOperationalContentOutputBuilder().build()); - return Futures.immediateFuture(rpcResultBuilder.build()); + return rpcResultBuilder.buildFuture(); } @Override diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java index 9d70f1c65..f17ad7ec7 100644 --- a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java +++ b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java @@ -241,7 +241,7 @@ public class MapServer implements IMapServerAsync, OdlMappingserviceListener, IS return; } final MapRequestBuilder mrb = MapRequestUtil.prepareSMR(eid, LispAddressUtil.toRloc(getLocalAddress())); - LOG.trace("Built SMR packet template (EID field will be set later): " + mrb.build().toString()); + LOG.trace("Built SMR packet template (EID field will be set later): {}", mrb.build()); scheduler.scheduleSmrs(mrb, subscribers.iterator()); } @@ -251,7 +251,7 @@ public class MapServer implements IMapServerAsync, OdlMappingserviceListener, IS Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterface current = interfaces.nextElement(); - LOG.trace("Interface " + current.toString()); + LOG.trace("Interface {}", current); if (!current.isUp() || current.isLoopback() || current.isVirtual()) { continue; } @@ -300,7 +300,7 @@ public class MapServer implements IMapServerAsync, OdlMappingserviceListener, IS while (subscribers.hasNext()) { Subscriber subscriber = subscribers.next(); if (subscriber.timedOut()) { - LOG.debug("Lazy removing expired subscriber entry " + subscriber.getString()); + LOG.debug("Lazy removing expired subscriber entry {}", subscriber.getString()); subscribers.remove(); } else { final ScheduledFuture future = executor.scheduleAtFixedRate(new CancellableRunnable( diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/DSBEInputUtil.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/DSBEInputUtil.java index 22aa89148..41495ec7f 100644 --- a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/DSBEInputUtil.java +++ b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/DSBEInputUtil.java @@ -10,8 +10,7 @@ package org.opendaylight.lispflowmapping.implementation.util; import static java.util.Objects.requireNonNull; import edu.umd.cs.findbugs.annotations.Nullable; -import java.util.Arrays; -import java.util.List; +import java.util.Set; import org.opendaylight.lispflowmapping.lisp.type.MappingData; import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.SiteId; @@ -41,7 +40,7 @@ public final class DSBEInputUtil { public static Mapping toMapping(MappingOrigin origin, Eid key, SiteId siteId, MappingData mappingData) { MappingRecord record = mappingData != null ? mappingData.getRecord() : null; - List siteIds = siteId != null ? Arrays.asList(siteId) : null; + Set siteIds = siteId != null ? Set.of(siteId) : null; return new MappingBuilder() .setEidUri(new EidUri(LispAddressStringifier.getURIString(key))) .setOrigin(origin) @@ -53,7 +52,7 @@ public final class DSBEInputUtil { MappingRecord record = mappingData != null ? mappingData.getRecord() : new MappingRecordBuilder().setEid(key).build(); SiteId siteId = record != null ? record.getSiteId() : null; - List siteIds = siteId != null ? Arrays.asList(siteId) : null; + Set siteIds = siteId != null ? Set.of(siteId) : null; return new MappingBuilder() .setEidUri(new EidUri(LispAddressStringifier.getURIString(key))) .setOrigin(origin) diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/LispNotificationHelper.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/LispNotificationHelper.java index c05660701..3f5155e2b 100644 --- a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/LispNotificationHelper.java +++ b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/LispNotificationHelper.java @@ -14,6 +14,7 @@ import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Set; import org.opendaylight.lispflowmapping.lisp.type.LispMessage; import org.opendaylight.lispflowmapping.lisp.util.LispAddressStringifier; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; @@ -127,12 +128,9 @@ public final class LispNotificationHelper { return mappings; } - public static List getSiteId(MapRegister mapRegister) { + public static Set getSiteId(MapRegister mapRegister) { if (mapRegister.getXtrSiteIdPresent()) { - List siteIds = new ArrayList<>(); - SiteId siteId = new SiteId(mapRegister.getSiteId()); - siteIds.add(siteId); - return siteIds; + return Set.of(new SiteId(mapRegister.getSiteId())); } else { return null; } diff --git a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/MappingSystemTest.java b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/MappingSystemTest.java index cebcb93d5..867d8a874 100644 --- a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/MappingSystemTest.java +++ b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/MappingSystemTest.java @@ -19,6 +19,7 @@ import java.util.Arrays; import java.util.Date; import java.util.EnumMap; import java.util.List; +import java.util.Set; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -162,7 +163,7 @@ public class MappingSystemTest { /** * This method changes the lookup policy. */ - private static void setLookupPolicy(IMappingService.LookupPolicy policy) throws NoSuchFieldException, + private static void setLookupPolicy(final IMappingService.LookupPolicy policy) throws NoSuchFieldException, IllegalAccessException { final Field lookupPolicy = ConfigIni.class.getDeclaredField("lookupPolicy"); lookupPolicy.setAccessible(true); @@ -182,7 +183,7 @@ public class MappingSystemTest { final Mapping mapping = new MappingBuilder() .setEidUri(new EidUri("ipv4:" + IPV4_DST)) .setOrigin(MappingOrigin.Southbound) - .setSiteId(Lists.newArrayList(SITE_ID)) + .setSiteId(Set.of(SITE_ID)) .setMappingRecord(mappingData.getRecord()).build(); assertNull(mappingSystem.getMapping(EID_IPV4_SRC, EID_IPV4_DST)); @@ -354,7 +355,7 @@ public class MappingSystemTest { final Mapping mapping = new MappingBuilder() .setEidUri(new EidUri("ipv4:" + IPV4_DST)) .setOrigin(MappingOrigin.Southbound) - .setSiteId(Lists.newArrayList(SITE_ID)) + .setSiteId(Set.of(SITE_ID)) .setMappingRecord(mappingRecord).build(); assertEquals(nbMappingData, mappingSystem.getMapping(EID_IPV4_SRC, EID_IPV4_DST)); @@ -594,7 +595,7 @@ public class MappingSystemTest { .setEid(EID_IPV4_DST); } - private static ServicePath getDefaultServicePath(short index) { + private static ServicePath getDefaultServicePath(final short index) { org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address .service.path.ServicePathBuilder servicePathBuilder = new org.opendaylight.yang.gen.v1.urn.ietf.params .xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.service.path.ServicePathBuilder(); diff --git a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MappingServiceTest.java b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MappingServiceTest.java index 66622b28d..af644bd2a 100644 --- a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MappingServiceTest.java +++ b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/lisp/MappingServiceTest.java @@ -83,6 +83,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev15090 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateMappingOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateMappingOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.UpdateMappingsInput; +import org.opendaylight.yangtools.yang.common.ErrorTag; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -130,7 +132,7 @@ public class MappingServiceTest { Mockito.when(mappingSystem.getAuthenticationKey(IPV4_EID)).thenReturn(MAPPING_AUTHKEY); // input - final RpcResult rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.PROTOCOL, "data-exists", + final RpcResult rpc = RpcResultBuilder.failed().withError(ErrorType.PROTOCOL, ErrorTag.DATA_EXISTS, "Key already exists! Please use update-key if you want to change it.").build(); // equals() not implemented int RpcError final RpcError error = rpc.getErrors().iterator().next(); @@ -211,7 +213,7 @@ public class MappingServiceTest { Mockito.when(mappingSystem.getAuthenticationKey(getKeyInput.getEid())).thenReturn(null); final RpcResult rpc = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "data-missing", "Key was not found in the mapping database") + .withError(ErrorType.APPLICATION, ErrorTag.DATA_MISSING, "Key was not found in the mapping database") .build(); final RpcError error = rpc.getErrors().iterator().next(); @@ -245,7 +247,7 @@ public class MappingServiceTest { Mockito.when(mappingSystem.getMapping(getMappingInput.getEid())).thenReturn(mappingData); final RpcResult rpc = RpcResultBuilder - .success(new GetMappingOutputBuilder().setMappingRecord(nonBinaryMappingRecord)).build(); + .success(new GetMappingOutputBuilder().setMappingRecord(nonBinaryMappingRecord).build()).build(); //result final Future> result = mappingService.getMapping(getMappingInput); @@ -265,8 +267,8 @@ public class MappingServiceTest { final GetMappingInput getMappingInput = new GetMappingInputBuilder().setEid(IPV4_EID).build(); Mockito.when(mappingSystem.getMapping(getMappingInput.getEid())).thenReturn(null); - final RpcResult rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.APPLICATION, - "data-missing", "No mapping was found in the mapping database").build(); + final RpcResult rpc = RpcResultBuilder.failed().withError(ErrorType.APPLICATION, ErrorTag.DATA_MISSING, + "No mapping was found in the mapping database").build(); final RpcError error = rpc.getErrors().iterator().next(); //result @@ -340,7 +342,7 @@ public class MappingServiceTest { Mockito.when(mappingSystem.getAuthenticationKey(IPV4_EID)).thenReturn(null); // input - final RpcResult rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.PROTOCOL, "data-missing", + final RpcResult rpc = RpcResultBuilder.failed().withError(ErrorType.PROTOCOL, ErrorTag.DATA_MISSING, "Key doesn't exist! Please use add-key if you want to create a new authentication key.").build(); final RpcError error = rpc.getErrors().iterator().next(); diff --git a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/util/LispNotificationHelperTest.java b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/util/LispNotificationHelperTest.java index 8d036a809..c3f3a275b 100644 --- a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/util/LispNotificationHelperTest.java +++ b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/util/LispNotificationHelperTest.java @@ -14,6 +14,7 @@ import com.google.common.collect.Lists; import com.google.common.net.InetAddresses; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.Set; import org.junit.Test; import org.opendaylight.lispflowmapping.lisp.type.LispMessage; import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil; @@ -231,13 +232,13 @@ public class LispNotificationHelperTest { .setMappingRecord(new MappingRecordBuilder().setEid(EID_IPV4).build()) .setEidUri(new EidUri("ipv4:" + IPV4_STRING)) .setOrigin(MappingOrigin.Southbound) - .setSiteId(Lists.newArrayList(SITE_ID)); + .setSiteId(Set.of(SITE_ID)); final MappingBuilder mappingBuilder_2 = new MappingBuilder() .setMappingRecord(new MappingRecordBuilder().setEid(EID_IPV6).build()) .setEidUri(new EidUri("ipv6:" + IPV6_STRING)) .setOrigin(MappingOrigin.Southbound) - .setSiteId(Lists.newArrayList(SITE_ID)); + .setSiteId(Set.of(SITE_ID)); assertEquals(Lists.newArrayList(mappingBuilder_1.build(), mappingBuilder_2.build()), LispNotificationHelper.getMapping(getDefaultAddMapping(true))); @@ -298,7 +299,7 @@ public class LispNotificationHelperTest { .build(); } - private static AddMapping getDefaultAddMapping(boolean isXtrSiteIdPresent) { + private static AddMapping getDefaultAddMapping(final boolean isXtrSiteIdPresent) { final MappingRecordItem mappingRecordItem_1 = new MappingRecordItemBuilder() .withKey(new MappingRecordItemKey(IPV4_STRING)) .setMappingRecord(new MappingRecordBuilder().setEid(EID_IPV4).build()).build(); diff --git a/mappingservice/lisp-proto/pom.xml b/mappingservice/lisp-proto/pom.xml index 476631469..5430999ca 100644 --- a/mappingservice/lisp-proto/pom.xml +++ b/mappingservice/lisp-proto/pom.xml @@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.mdsal binding-parent - 8.0.11 + 9.0.1 diff --git a/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/serializer/address/AfiListSerializer.java b/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/serializer/address/AfiListSerializer.java index c47a6edbd..6bf628812 100644 --- a/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/serializer/address/AfiListSerializer.java +++ b/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/serializer/address/AfiListSerializer.java @@ -7,9 +7,9 @@ */ package org.opendaylight.lispflowmapping.lisp.serializer.address; +import com.google.common.collect.ImmutableSet; import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; +import java.util.Set; import org.opendaylight.lispflowmapping.lisp.type.LispCanonicalAddressFormatEnum; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.afn.safi.rev130704.AddressFamily; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.AfiListLcaf; @@ -42,8 +42,8 @@ public final class AfiListSerializer extends LcafSerializer { @Override protected short getLcafLength(LispAddress lispAddress) { short totalSize = 0; - AfiList afiList = (((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105 - .lisp.address.address.AfiList) lispAddress.getAddress()).getAfiList()); + AfiList afiList = ((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105 + .lisp.address.address.AfiList) lispAddress.getAddress()).getAfiList(); for (SimpleAddress address : afiList.getAddressList()) { totalSize += SimpleAddressSerializer.getInstance().getAddressSize(address); } @@ -82,14 +82,21 @@ public final class AfiListSerializer extends LcafSerializer { return rb.build(); } - private Address deserializeData(ByteBuffer buffer, short lcafLength, LispAddressSerializerContext ctx) { - List addresses = new ArrayList(); - short length = lcafLength; - while (length > 0) { - SimpleAddress address = SimpleAddressSerializer.getInstance().deserialize(buffer, ctx); - length -= SimpleAddressSerializer.getInstance().getAddressSize(address); - addresses.add(address); + private static Address deserializeData(ByteBuffer buffer, short lcafLength, LispAddressSerializerContext ctx) { + final Set addresses; + if (lcafLength > 0) { + ImmutableSet.Builder builder = ImmutableSet.builderWithExpectedSize(lcafLength); + short length = lcafLength; + while (length > 0) { + SimpleAddress address = SimpleAddressSerializer.getInstance().deserialize(buffer, ctx); + length -= SimpleAddressSerializer.getInstance().getAddressSize(address); + builder.add(address); + } + addresses = builder.build(); + } else { + addresses = Set.of(); } + return new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp .address.address.AfiListBuilder().setAfiList(new AfiListBuilder().setAddressList(addresses).build()) .build(); diff --git a/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/serializer/address/NoAddressSerializer.java b/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/serializer/address/NoAddressSerializer.java index 082652dfc..6ee4fd911 100644 --- a/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/serializer/address/NoAddressSerializer.java +++ b/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/serializer/address/NoAddressSerializer.java @@ -47,7 +47,7 @@ public final class NoAddressSerializer extends LispAddressSerializer { EidBuilder eb = new EidBuilder(); eb.setAddressType(NoAddressAfi.class); eb.setVirtualNetworkId(getVni(ctx)); - eb.setAddress(new NoAddressBuilder().setNoAddress(Empty.getInstance()).build()); + eb.setAddress(new NoAddressBuilder().setNoAddress(Empty.value()).build()); return eb.build(); } @@ -56,7 +56,7 @@ public final class NoAddressSerializer extends LispAddressSerializer { RlocBuilder rb = new RlocBuilder(); rb.setAddressType(NoAddressAfi.class); rb.setVirtualNetworkId(null); - rb.setAddress(new NoAddressBuilder().setNoAddress(Empty.getInstance()).build()); + rb.setAddress(new NoAddressBuilder().setNoAddress(Empty.value()).build()); return rb.build(); } diff --git a/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressStringifier.java b/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressStringifier.java index 390f5d1bc..eb110a093 100644 --- a/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressStringifier.java +++ b/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressStringifier.java @@ -324,10 +324,9 @@ public final class LispAddressStringifier { // AFI 16387, LCAF Type 1; Address List // Example rendering: // {192.0.2.1,192.0.2.2,2001:db8::1} - List addresses = addr.getAfiList().getAddressList(); StringBuilder sb = new StringBuilder("{"); boolean needComma = false; - for (SimpleAddress a : addresses) { + for (SimpleAddress a : addr.getAfiList().getAddressList()) { if (needComma) { sb.append(","); } diff --git a/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressUtil.java b/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressUtil.java index f7fac320f..295d4b85f 100644 --- a/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressUtil.java +++ b/mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressUtil.java @@ -770,7 +770,7 @@ public final class LispAddressUtil { EidBuilder builder = new EidBuilder(); builder.setAddressType(NoAddressAfi.class); builder.setVirtualNetworkId(null); - builder.setAddress(new NoAddressBuilder().setNoAddress(Empty.getInstance()).build()); + builder.setAddress(new NoAddressBuilder().setNoAddress(Empty.value()).build()); return builder.build(); } diff --git a/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressStringifierTest.java b/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressStringifierTest.java index f35546ed0..90700b6bf 100644 --- a/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressStringifierTest.java +++ b/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressStringifierTest.java @@ -12,7 +12,9 @@ import static org.junit.Assert.assertNull; import com.google.common.io.BaseEncoding; import java.util.ArrayList; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; @@ -154,13 +156,14 @@ public class LispAddressStringifierTest { private static final LispAddress LISP_AS_NUMBER = new EidBuilder().setAddress(AS_NUMBER_LISP_TYPE).build(); // NoAddress - private static final NoAddress NO_ADDRESS = new NoAddressBuilder().setNoAddress(Empty.getInstance()).build(); + private static final NoAddress NO_ADDRESS = new NoAddressBuilder().setNoAddress(Empty.value()).build(); private static final LispAddress LISP_NO_ADDRESS = new EidBuilder().setAddress(NO_ADDRESS).build(); // AfiList private static final SimpleAddress SIMPLE_ADDRESS_1 = new SimpleAddress(new IpAddress(IPV4_ADDRESS)); private static final SimpleAddress SIMPLE_ADDRESS_2 = new SimpleAddress(new IpAddress(IPV6_ADDRESS)); - private static final List ADDRESS_LIST = new ArrayList<>(); + // FIXME: this is ugly as hell, this Set should be immutable + private static final Set ADDRESS_LIST = new LinkedHashSet<>(); private static final AfiList AFI_LIST = new AfiListBuilder().setAfiList(new org.opendaylight.yang.gen.v1.urn.ietf .params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.afi.list.AfiListBuilder() .setAddressList(ADDRESS_LIST).build()).build(); diff --git a/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressUtilTest.java b/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressUtilTest.java index 0793d7c4c..33c0e2af5 100644 --- a/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressUtilTest.java +++ b/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressUtilTest.java @@ -1275,7 +1275,7 @@ public class LispAddressUtilTest { final Eid noAddressEid = LispAddressUtil.getNoAddressEid(); assertEquals(NoAddressAfi.class, noAddressEid.getAddressType()); assertNull(noAddressEid.getVirtualNetworkId()); - assertEquals(((NoAddress) noAddressEid.getAddress()).getNoAddress(), Empty.getInstance()); + assertEquals(((NoAddress) noAddressEid.getAddress()).getNoAddress(), Empty.value()); } /** diff --git a/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/serializer/address/AfiListSerializerTest.java b/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/serializer/address/AfiListSerializerTest.java index 83d90d6c5..864ec1fec 100644 --- a/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/serializer/address/AfiListSerializerTest.java +++ b/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/serializer/address/AfiListSerializerTest.java @@ -9,9 +9,10 @@ package org.opendaylight.lispflowmapping.serializer.address; import static org.junit.Assert.assertEquals; +import com.google.common.collect.ImmutableSet; import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; +import java.util.Iterator; +import java.util.Set; import junitx.framework.ArrayAssert; import junitx.framework.Assert; import org.junit.Test; @@ -38,11 +39,12 @@ public class AfiListSerializerTest extends BaseTestCase { assertEquals(AfiListLcaf.class, address.getAddressType()); AfiList afiList = (AfiList) address.getAddress(); - List addressList = afiList.getAfiList().getAddressList(); + Set addressList = afiList.getAfiList().getAddressList(); assertEquals(2, addressList.size()); - assertEquals("170.187.204.221", addressList.get(0).stringValue()); - assertEquals("1122:3344:1122:3344:1122:3344:1122:3344", addressList.get(1).stringValue()); + Iterator it = addressList.iterator(); + assertEquals("170.187.204.221", it.next().stringValue()); + assertEquals("1122:3344:1122:3344:1122:3344:1122:3344", it.next().stringValue()); } @Test @@ -53,8 +55,7 @@ public class AfiListSerializerTest extends BaseTestCase { assertEquals(AfiListLcaf.class, address.getAddressType()); AfiList afiList = (AfiList) address.getAddress(); - List addressList = afiList.getAfiList().getAddressList(); - assertEquals(0, addressList.size()); + assertEquals(Set.of(), afiList.getAfiList().getAddressList()); } @Test(expected = LispSerializationException.class) @@ -74,10 +75,9 @@ public class AfiListSerializerTest extends BaseTestCase { @Test public void serialize__Simple() throws Exception { AfiListBuilder listBuilder = new AfiListBuilder(); - List addressList = new ArrayList<>(); - addressList.add(SimpleAddressBuilder.getDefaultInstance("170.187.204.221")); - addressList.add(SimpleAddressBuilder.getDefaultInstance("1122:3344:1122:3344:1122:3344:1122:3344")); - listBuilder.setAddressList(addressList); + listBuilder.setAddressList(ImmutableSet.of( + SimpleAddressBuilder.getDefaultInstance("170.187.204.221"), + SimpleAddressBuilder.getDefaultInstance("1122:3344:1122:3344:1122:3344:1122:3344"))); RlocBuilder rb = new RlocBuilder(); rb.setAddressType(AfiListLcaf.class); @@ -98,8 +98,7 @@ public class AfiListSerializerTest extends BaseTestCase { @Test public void serialize__NoAddresses() throws Exception { AfiListBuilder listBuilder = new AfiListBuilder(); - List addressList = new ArrayList<>(); - listBuilder.setAddressList(addressList); + listBuilder.setAddressList(Set.of()); RlocBuilder rb = new RlocBuilder(); rb.setAddressType(AfiListLcaf.class); @@ -120,17 +119,14 @@ public class AfiListSerializerTest extends BaseTestCase { final SimpleAddress ip1 = SimpleAddressBuilder.getDefaultInstance("0:0:0:0:0:0:0:1"); final SimpleAddress ip2 = SimpleAddressBuilder.getDefaultInstance("0:0:0:0:0:0:0:2"); - AfiListBuilder listBuilder = new AfiListBuilder().setAddressList(new ArrayList()); + AfiListBuilder listBuilder = new AfiListBuilder().setAddressList(Set.of(ip1)); - listBuilder.getAddressList().add(ip1); final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105 .lisp.address.address.afi.list.AfiList address1 = listBuilder.build(); - listBuilder.setAddressList(new ArrayList()); - listBuilder.getAddressList().add(ip1); + listBuilder.setAddressList(Set.of(ip1)); final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105 .lisp.address.address.afi.list.AfiList address2 = listBuilder.build(); - listBuilder.setAddressList(new ArrayList()); - listBuilder.getAddressList().add(ip2); + listBuilder.setAddressList(Set.of(ip2)); final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105 .lisp.address.address.afi.list.AfiList address3 = listBuilder.build(); diff --git a/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/serializer/address/DistinguishedNameSerializerTest.java b/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/serializer/address/DistinguishedNameSerializerTest.java index dede1175f..e09b4e47f 100644 --- a/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/serializer/address/DistinguishedNameSerializerTest.java +++ b/mappingservice/lisp-proto/src/test/java/org/opendaylight/lispflowmapping/serializer/address/DistinguishedNameSerializerTest.java @@ -56,7 +56,7 @@ public class DistinguishedNameSerializerTest extends BaseTestCase { + "00 11 64 61 76 69 64 00"), null); assertEquals(AfiListLcaf.class, address.getAddressType()); - assertEquals("david", ((AfiList) address.getAddress()).getAfiList().getAddressList().get(0) + assertEquals("david", ((AfiList) address.getAddress()).getAfiList().getAddressList().iterator().next() .getDistinguishedNameType().getValue()); } diff --git a/mappingservice/mapcache/src/test/java/org/opendaylight/lispflowmapping/mapcache/MultiTableMapCacheTest.java b/mappingservice/mapcache/src/test/java/org/opendaylight/lispflowmapping/mapcache/MultiTableMapCacheTest.java index de5712241..fee9bc83a 100644 --- a/mappingservice/mapcache/src/test/java/org/opendaylight/lispflowmapping/mapcache/MultiTableMapCacheTest.java +++ b/mappingservice/mapcache/src/test/java/org/opendaylight/lispflowmapping/mapcache/MultiTableMapCacheTest.java @@ -11,14 +11,13 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.junit.Before; import org.junit.Test; -import org.mockito.Mockito; import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO; import org.opendaylight.lispflowmapping.interfaces.dao.MappingEntry; import org.opendaylight.lispflowmapping.interfaces.dao.SubKeys; @@ -205,8 +204,8 @@ public class MultiTableMapCacheTest { when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(null); multiTableMapCache.removeMapping(EID_SOURCE_DEST_KEY_TYPE); - verifyZeroInteractions(tableDaoMock); - verifyZeroInteractions(dbMock); + verifyNoInteractions(tableDaoMock); + verifyNoInteractions(dbMock); } /** @@ -300,7 +299,7 @@ public class MultiTableMapCacheTest { when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(null); multiTableMapCache.removeData(EID_TEST, SubKeys.RECORD); - Mockito.verifyZeroInteractions(tableDaoMock); + verifyNoInteractions(tableDaoMock); } /** diff --git a/mappingservice/pom.xml b/mappingservice/pom.xml index e2b77dd14..60dc52dc5 100644 --- a/mappingservice/pom.xml +++ b/mappingservice/pom.xml @@ -5,7 +5,7 @@ org.opendaylight.odlparent odlparent - 9.0.13 + 10.0.0 @@ -38,7 +38,7 @@ org.opendaylight.mdsal mdsal-artifacts - 8.0.11 + 9.0.1 pom import diff --git a/mappingservice/shell/pom.xml b/mappingservice/shell/pom.xml index f679dd9d3..ae88209c8 100644 --- a/mappingservice/shell/pom.xml +++ b/mappingservice/shell/pom.xml @@ -17,7 +17,7 @@ org.osgi - osgi.core + org.osgi.framework org.apache.karaf.shell diff --git a/mappingservice/southbound/pom.xml b/mappingservice/southbound/pom.xml index 487e062f3..8e3fb4cb2 100644 --- a/mappingservice/southbound/pom.xml +++ b/mappingservice/southbound/pom.xml @@ -21,7 +21,7 @@ org.osgi - osgi.core + org.osgi.framework ${project.groupId} diff --git a/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundRPC.java b/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundRPC.java index a6da05536..b71906978 100644 --- a/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundRPC.java +++ b/mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundRPC.java @@ -40,7 +40,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ctrl. import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.ctrl.msg.stats.ControlMessageBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.get.stats.output.ControlMessageStatsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.get.stats.output.MapRegisterCacheStatsBuilder; -import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.ErrorTag; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -134,7 +135,7 @@ public class LispSouthboundRPC implements OdlLispSbService { if (stats == null) { rpcResultBuilder = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "data-missing", "No stats found"); + .withError(ErrorType.APPLICATION, ErrorTag.DATA_MISSING, "No stats found"); } else { rpcResultBuilder = RpcResultBuilder.success(createGetStatsOutput(stats)); } @@ -149,7 +150,7 @@ public class LispSouthboundRPC implements OdlLispSbService { if (stats == null) { return Futures.immediateFuture(RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "data-missing", "No stats found") + .withError(ErrorType.APPLICATION, ErrorTag.DATA_MISSING, "No stats found") .build()); } else { stats.resetStats(); diff --git a/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPluginTest.java b/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPluginTest.java index 00a29d55f..c175ec99a 100644 --- a/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPluginTest.java +++ b/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPluginTest.java @@ -144,8 +144,8 @@ public class LispSouthboundPluginTest { injectField("bootstrap", BOOTSTRAP_MOCK); lispSouthboundPlugin.setLispAddress(ADDRESS_1); - Mockito.verifyZeroInteractions(BOOTSTRAP_MOCK); - Mockito.verifyZeroInteractions(channel); + Mockito.verifyNoInteractions(BOOTSTRAP_MOCK); + Mockito.verifyNoInteractions(channel); } /** @@ -165,7 +165,7 @@ public class LispSouthboundPluginTest { public void shouldListenOnXtrPortTest_false() throws NoSuchFieldException, IllegalAccessException { lispSouthboundPlugin.shouldListenOnXtrPort(false); - Mockito.verifyZeroInteractions(xtrChannel); + Mockito.verifyNoInteractions(xtrChannel); } /** diff --git a/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundRpcTest.java b/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundRpcTest.java index 06592a9f5..130c75599 100644 --- a/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundRpcTest.java +++ b/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundRpcTest.java @@ -46,6 +46,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendM import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapReplyInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.SendMapRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.get.stats.output.ControlMessageStats; +import org.opendaylight.yangtools.yang.common.ErrorTag; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -59,7 +61,7 @@ public class LispSouthboundRpcTest { private static final RpcResult RPC_RESULT_FAILURE = RpcResultBuilder.failed().build(); private static final RpcResult RPC_RESULT_SUCCESS = RpcResultBuilder.success().build(); private static final RpcResult RPC_RESULT_ERROR = RpcResultBuilder.failed() - .withError(RpcError.ErrorType.APPLICATION, "data-missing", "No stats found").build(); + .withError(ErrorType.APPLICATION, ErrorTag.DATA_MISSING, "No stats found").build(); /** * Tests {@link LispSouthboundRPC#sendMapNotify} method. @@ -88,7 +90,7 @@ public class LispSouthboundRpcTest { assertEquals(RPC_RESULT_FAILURE.isSuccessful(), lispSouthboundRPC.sendMapNotify(null).get().isSuccessful()); - Mockito.verifyZeroInteractions(lispSouthboundPlugin); + Mockito.verifyNoInteractions(lispSouthboundPlugin); } /** @@ -118,7 +120,7 @@ public class LispSouthboundRpcTest { assertEquals(RPC_RESULT_FAILURE.isSuccessful(), lispSouthboundRPC.sendMapReply(null).get().isSuccessful()); - Mockito.verifyZeroInteractions(lispSouthboundPlugin); + Mockito.verifyNoInteractions(lispSouthboundPlugin); } /** @@ -148,7 +150,7 @@ public class LispSouthboundRpcTest { assertEquals(RPC_RESULT_FAILURE.isSuccessful(), lispSouthboundRPC.sendMapRequest(null).get().isSuccessful()); - Mockito.verifyZeroInteractions(lispSouthboundPlugin); + Mockito.verifyNoInteractions(lispSouthboundPlugin); } /** @@ -178,7 +180,7 @@ public class LispSouthboundRpcTest { assertEquals(RPC_RESULT_FAILURE.isSuccessful(), lispSouthboundRPC.sendMapRegister(null).get().isSuccessful()); - Mockito.verifyZeroInteractions(lispSouthboundPlugin); + Mockito.verifyNoInteractions(lispSouthboundPlugin); } /** diff --git a/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/lisp/AuthenticationKeyDataListenerTest.java b/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/lisp/AuthenticationKeyDataListenerTest.java index f48adcfaa..18bd462ee 100644 --- a/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/lisp/AuthenticationKeyDataListenerTest.java +++ b/mappingservice/southbound/src/test/java/org/opendaylight/lispflowmapping/southbound/lisp/AuthenticationKeyDataListenerTest.java @@ -154,7 +154,7 @@ public class AuthenticationKeyDataListenerTest { Mockito.when(mod_nullModType.getModificationType()).thenReturn(null); authenticationKeyDataListener.onDataTreeChanged(Lists.newArrayList(change_nullModType)); - Mockito.verifyZeroInteractions(akdbMock); + Mockito.verifyNoInteractions(akdbMock); } /**