Migrate tests away from Optional.get() 09/105609/1
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 23 Apr 2023 09:21:55 +0000 (11:21 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 23 Apr 2023 09:22:34 +0000 (11:22 +0200)
Upgraded modernizer plugin is flagging these violations, migrate to
alternatives.

Change-Id: I4f99b5cd6910819b8b50deda35d1b97445ecde2d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
17 files changed:
bgp/extensions/route-target/src/test/java/org/opendaylight/protocol/bgp/route/targetcontrain/impl/route/policy/ClientAttributePrependHandlerTest.java
bgp/openconfig-rp-spi/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/AppendActionTest.java
bgp/openconfig-rp-spi/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/AsPathLengthTest.java
bgp/openconfig-rp-spi/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/AttributesEqualTests.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/ExportDefaultStatementTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/ImportDefaultStatementTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/MatchAfiSafiNotInTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/MatchAsPathSetTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/MatchBgpNeighborSetTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/MatchCommunityTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/MatchExtComTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/SetCommunityTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/SetExtCommunityTest.java
bgp/openconfig-rp-statement/src/test/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/VpnNonMemberHandlerTest.java
bgp/parser-spi/src/test/java/org/opendaylight/protocol/bgp/parser/spi/UtilsTest.java
bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/AbstractRIBSupportTest.java
pcep/pcc-mock/src/test/java/org/opendaylight/protocol/pcep/pcc/mock/PCCMockCommon.java

index 0f3330bb49f5cd579aafad7176874c7af534b792..4617f6b6e60c3ad61779cd212b0c119cab441f3a 100644 (file)
@@ -56,7 +56,7 @@ public class ClientAttributePrependHandlerTest extends AbstractStatementRegistry
     @Test
     public void testPreprendClientAttribute() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("client-attribute-append-test")).findFirst().get();
+                .filter(st -> st.getName().equals("client-attribute-append-test")).findFirst().orElseThrow();
         final Attributes att = new AttributesBuilder()
                 .setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder()
                         .setGlobal(IPV4).build()).build())
index 41b5ad4b4d3abda8c8985500ca7a47654e5dbdda..52b81bc3a0152defff64af84c2f8cf3927b104fc 100644 (file)
@@ -51,7 +51,7 @@ public class AppendActionTest extends AbstractStatementRegistryTest {
     @Test
     public void testMultipleAppend() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("multiple-append-test")).findFirst().get();
+                .filter(st -> st.getName().equals("multiple-append-test")).findFirst().orElseThrow();
         final RouteAttributeContainer attributeContainer
                 = routeAttributeContainerFalse(new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -74,7 +74,7 @@ public class AppendActionTest extends AbstractStatementRegistryTest {
     @Test
     public void testNextHopSelf() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("next-hop-self-append-test")).findFirst().get();
+                .filter(st -> st.getName().equals("next-hop-self-append-test")).findFirst().orElseThrow();
         final RouteAttributeContainer attributeContainer
                 = routeAttributeContainerFalse(new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
index e706c8a7d8b5a82be94d1a34c6545dbe7335a85b..69ad5b9f3f9e782bfd91e45198e870d4a1b38e25 100644 (file)
@@ -12,8 +12,6 @@ import static org.junit.Assert.assertNull;
 import static org.mockito.Mockito.doReturn;
 import static org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer.routeAttributeContainerFalse;
 
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
@@ -47,15 +45,15 @@ public class AsPathLengthTest extends AbstractStatementRegistryTest {
     @Test
     public void testASPathLengthEq() {
         final AsPathBuilder asPath = new AsPathBuilder();
-        asPath.setSegments(Collections.singletonList(new SegmentsBuilder()
-                .setAsSequence(Arrays.asList(
+        asPath.setSegments(List.of(new SegmentsBuilder()
+                .setAsSequence(List.of(
                         AsNumber.getDefaultInstance("1"),
                         AsNumber.getDefaultInstance("2"),
                         AsNumber.getDefaultInstance("3")))
                 .build()));
 
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("as-path-eq-length-test")).findFirst().get();
+                .filter(st -> st.getName().equals("as-path-eq-length-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
                 .setAsPath(asPath.build())
                 .build());
@@ -68,8 +66,8 @@ public class AsPathLengthTest extends AbstractStatementRegistryTest {
                 statement);
         assertNotNull(result.getAttributes());
 
-        asPath.setSegments(Collections.singletonList(new SegmentsBuilder()
-                .setAsSequence(Arrays.asList(
+        asPath.setSegments(List.of(new SegmentsBuilder()
+                .setAsSequence(List.of(
                         AsNumber.getDefaultInstance("1"),
                         AsNumber.getDefaultInstance("3")))
                 .build()));
@@ -87,15 +85,15 @@ public class AsPathLengthTest extends AbstractStatementRegistryTest {
     @Test
     public void testASPathLengthGe() {
         final AsPathBuilder asPath = new AsPathBuilder();
-        asPath.setSegments(Collections.singletonList(new SegmentsBuilder()
-                .setAsSequence(Arrays.asList(
+        asPath.setSegments(List.of(new SegmentsBuilder()
+                .setAsSequence(List.of(
                         AsNumber.getDefaultInstance("1"),
                         AsNumber.getDefaultInstance("2"),
                         AsNumber.getDefaultInstance("3")))
                 .build()));
 
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("as-path-ge-length-test")).findFirst().get();
+                .filter(st -> st.getName().equals("as-path-ge-length-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
                 .setAsPath(asPath.build())
                 .build());
@@ -108,9 +106,8 @@ public class AsPathLengthTest extends AbstractStatementRegistryTest {
                 statement);
         assertNull(result.getAttributes());
 
-        asPath.setSegments(Collections.singletonList(new SegmentsBuilder()
-                .setAsSequence(Collections.singletonList(
-                        AsNumber.getDefaultInstance("3")))
+        asPath.setSegments(List.of(new SegmentsBuilder()
+                .setAsSequence(List.of(AsNumber.getDefaultInstance("3")))
                 .build()));
 
         attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setAsPath(asPath.build()).build());
@@ -126,15 +123,15 @@ public class AsPathLengthTest extends AbstractStatementRegistryTest {
     @Test
     public void testASPathLengthLe() {
         final AsPathBuilder asPath = new AsPathBuilder();
-        asPath.setSegments(Collections.singletonList(new SegmentsBuilder()
-                .setAsSequence(Arrays.asList(
+        asPath.setSegments(List.of(new SegmentsBuilder()
+                .setAsSequence(List.of(
                         AsNumber.getDefaultInstance("1"),
                         AsNumber.getDefaultInstance("2"),
                         AsNumber.getDefaultInstance("3")))
                 .build()));
 
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("as-path-le-length-test")).findFirst().get();
+                .filter(st -> st.getName().equals("as-path-le-length-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
                 .setAsPath(asPath.build())
                 .build());
@@ -147,8 +144,8 @@ public class AsPathLengthTest extends AbstractStatementRegistryTest {
                 statement);
         assertNotNull(result.getAttributes());
 
-        asPath.setSegments(Collections.singletonList(new SegmentsBuilder()
-                .setAsSequence(Collections.singletonList(AsNumber.getDefaultInstance("3"))).build()));
+        asPath.setSegments(List.of(new SegmentsBuilder()
+                .setAsSequence(List.of(AsNumber.getDefaultInstance("3"))).build()));
 
         attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setAsPath(asPath.build()).build());
         result = statementRegistry.applyExportStatement(
index 2b2ca7d1e89228804b5beb94157fb13bddedd43d..df509f8f310346311c7ab8baa6bf6da0408b4899 100644 (file)
@@ -54,7 +54,7 @@ public class AttributesEqualTests extends AbstractStatementRegistryTest {
     @Test
     public void testMedEq() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("med-eq-test")).findFirst().get();
+                .filter(st -> st.getName().equals("med-eq-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
                 .setMultiExitDisc(new MultiExitDiscBuilder().setMed(Uint32.valueOf(200)).build())
                 .build());
@@ -83,7 +83,7 @@ public class AttributesEqualTests extends AbstractStatementRegistryTest {
     @Test
     public void testOriginEq() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("origin-eq-test")).findFirst().get();
+                .filter(st -> st.getName().equals("origin-eq-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
                 .setOrigin(new OriginBuilder().setValue(BgpOrigin.Egp).build())
                 .build());
@@ -112,7 +112,7 @@ public class AttributesEqualTests extends AbstractStatementRegistryTest {
     @Test
     public void testNextHopIn() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("nexthop-in-test")).findFirst().get();
+                .filter(st -> st.getName().equals("nexthop-in-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
                 .setCNextHop(new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder()
                         .setGlobal(new Ipv6AddressNoZone("2001:db8::1")).build()).build())
@@ -143,7 +143,7 @@ public class AttributesEqualTests extends AbstractStatementRegistryTest {
     @Test
     public void testLocalPref() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("local-pref-eq-test")).findFirst().get();
+                .filter(st -> st.getName().equals("local-pref-eq-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
                 .setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(350)).build())
                 .build());
@@ -172,7 +172,7 @@ public class AttributesEqualTests extends AbstractStatementRegistryTest {
     @Test
     public void testAfiSafiIn() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("afi-safi-in-test")).findFirst().get();
+                .filter(st -> st.getName().equals("afi-safi-in-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
                 .setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(350)).build())
                 .build());
index e487bb4f3d12e17e5e56d20e960bd95eaba0159a..7ddb8cc88706c2b7887ca06eedeb3065888b04bf 100644 (file)
@@ -126,7 +126,9 @@ public class ExportDefaultStatementTest extends AbstractStatementRegistryConsume
         doReturn(toPeerRole).when(exportParameters).getToPeerRole();
         doReturn(AS).when(exportParameters).getToPeerLocalAs();
         return defaultExportStatements.stream()
-                .filter(st -> st.getName().equals(statementName)).findFirst().get();
+                .filter(st -> st.getName().equals(statementName))
+                .findFirst()
+                .orElseThrow();
     }
 
     private void assertApplyExportStatement(
index e6dd8ba85d0b23e4a97353ded849c0b816d8692b..be3848200349ef67631f22a2b32b08c1724e266e 100644 (file)
@@ -42,8 +42,8 @@ public class ImportDefaultStatementTest extends AbstractStatementRegistryConsume
     public void testFromEbgp() {
         final Statement statement = getStatement("from-external");
 
-        final RouteAttributeContainer attributeContainer
-                = routeAttributeContainerFalse(ImportAttributeTestUtil.createInput());
+        final RouteAttributeContainer attributeContainer =
+            routeAttributeContainerFalse(ImportAttributeTestUtil.createInput());
 
         assertApplyImportStatement(statement, PeerRole.Ebgp, attributeContainer,
                 ImportAttributeTestUtil.createOutput());
@@ -54,8 +54,7 @@ public class ImportDefaultStatementTest extends AbstractStatementRegistryConsume
         final Statement statement = getStatement("from-non-external");
 
         final Attributes expected = ImportAttributeTestUtil.createInput();
-        final RouteAttributeContainer attributeContainer
-                = routeAttributeContainerFalse(expected);
+        final RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(expected);
 
         assertApplyImportStatement(statement, PeerRole.Ibgp, attributeContainer, expected);
         assertApplyImportStatement(statement, PeerRole.RrClient, attributeContainer, expected);
@@ -64,7 +63,9 @@ public class ImportDefaultStatementTest extends AbstractStatementRegistryConsume
 
     private Statement getStatement(final String statementName) {
         return defaultImportStatements.stream()
-                .filter(st -> st.getName().equals(statementName)).findFirst().get();
+            .filter(st -> st.getName().equals(statementName))
+            .findFirst()
+            .orElseThrow();
     }
 
     private void assertApplyImportStatement(
index eb1fa925a06df2b53e94294435232bc2f61c64be..47327cbef4967f61b4f153fd5dbd93a17c4dc712 100644 (file)
@@ -46,7 +46,7 @@ public class MatchAfiSafiNotInTest extends AbstractStatementRegistryConsumerTest
     @Test
     public void testExtComAny() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("match-afi-safi-not-in-test")).findFirst().get();
+                .filter(st -> st.getName().equals("match-afi-safi-not-in-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
index 5e4e0c27e8ba08652c3a6a626447b60fa2a00050..bf4a478c4874f0cd7cc5abf6a20b7dfdcad0e2c3 100644 (file)
@@ -40,11 +40,10 @@ public class MatchAsPathSetTest extends AbstractStatementRegistryConsumerTest {
         baseAttributes = new PolicyRIBBaseParametersImpl(LOCAL_AS, IPV4, CLUSTER);
     }
 
-
     @Test
     public void testMatchAsPathAny() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("reject-match-as-path-any-set")).findFirst().get();
+                .filter(st -> st.getName().equals("reject-match-as-path-any-set")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -65,7 +64,7 @@ public class MatchAsPathSetTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testMatchAsPathAll() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("reject-match-as-path-all-set")).findFirst().get();
+                .filter(st -> st.getName().equals("reject-match-as-path-all-set")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
                 .setAsPath(new AsPathBuilder().setSegments(List.of(
                         new SegmentsBuilder().setAsSequence(List.of(
@@ -93,7 +92,7 @@ public class MatchAsPathSetTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testMatchAsPathInverse() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("reject-match-as-path-inverse-set")).findFirst().get();
+                .filter(st -> st.getName().equals("reject-match-as-path-inverse-set")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder()
                         .setAsPath(new AsPathBuilder().setSegments(List.of(
index 8aaae91f55368ca98b482f8bdd2b8d554db295d7..95e68961d47594ee3df2f692e827a44bdf0957f8 100644 (file)
@@ -41,7 +41,7 @@ public class MatchBgpNeighborSetTest extends AbstractStatementRegistryConsumerTe
     @Test
     public void testMatchFromBgpNeighborAny() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("reject-from-neighbor-test")).findFirst().get();
+                .filter(st -> st.getName().equals("reject-from-neighbor-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
 
@@ -61,7 +61,7 @@ public class MatchBgpNeighborSetTest extends AbstractStatementRegistryConsumerTe
     @Test
     public void testMatchFromBgpNeighborInvert() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("reject-from-neighbor-invert-test")).findFirst().get();
+                .filter(st -> st.getName().equals("reject-from-neighbor-invert-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
 
@@ -80,7 +80,7 @@ public class MatchBgpNeighborSetTest extends AbstractStatementRegistryConsumerTe
     @Test
     public void testMatchToBgpNeighborAny() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("reject-to-neighbor-test")).findFirst().get();
+                .filter(st -> st.getName().equals("reject-to-neighbor-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
 
@@ -101,7 +101,7 @@ public class MatchBgpNeighborSetTest extends AbstractStatementRegistryConsumerTe
     @Test
     public void testMatchToBgpNeighborInvert() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("reject-to-neighbor-invert-test")).findFirst().get();
+                .filter(st -> st.getName().equals("reject-to-neighbor-invert-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
 
index eab342a49e648a8a7a1f58be1101cd75c2443129..95436d90cd378590b772fd92977e746f1289e11e 100644 (file)
@@ -42,7 +42,7 @@ public class MatchCommunityTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testComAny() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("community-any-test")).findFirst().get();
+                .filter(st -> st.getName().equals("community-any-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -63,7 +63,7 @@ public class MatchCommunityTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testComInvert() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("community-invert-test")).findFirst().get();
+                .filter(st -> st.getName().equals("community-invert-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -84,7 +84,7 @@ public class MatchCommunityTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testComAll() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("community-all-test")).findFirst().get();
+                .filter(st -> st.getName().equals("community-all-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
index 6890311ef6f9a35adce5f9cd608aa5181123d28d..e992b4cd89bb1324ee3a91945e1456f3f3dfd57d 100644 (file)
@@ -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.protocol.bgp.openconfig.routing.policy.statement;
 
 import static org.junit.Assert.assertNotNull;
@@ -13,8 +12,6 @@ import static org.junit.Assert.assertNull;
 import static org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer.routeAttributeContainerFalse;
 import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.EncapsulationTunnelType.Vxlan;
 
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
@@ -51,22 +48,25 @@ public class MatchExtComTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testExtComAny() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("ext-community-any-test")).findFirst().get();
-        RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
-                new AttributesBuilder().build());
+                .filter(st -> st.getName().equals("ext-community-any-test")).findFirst().orElseThrow();
+        RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
                 baseAttributes, IPV4UNICAST.VALUE, exportParameters, attributeContainer, statement);
         assertNotNull(result.getAttributes());
 
 
         attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
-                .setExtendedCommunities(Collections.singletonList(new ExtendedCommunitiesBuilder()
-                        .setExtendedCommunity(new As4RouteOriginExtendedCommunityCaseBuilder()
-                                .setAs4RouteOriginExtendedCommunity(new As4RouteOriginExtendedCommunityBuilder()
-                                        .setAs4SpecificCommon(new As4SpecificCommonBuilder()
-                                                .setAsNumber(AsNumber.getDefaultInstance("65000"))
-                                                .setLocalAdministrator(Uint16.valueOf(123))
-                                                .build()).build()).build()).build())).build());
+            .setExtendedCommunities(List.of(new ExtendedCommunitiesBuilder()
+                .setExtendedCommunity(new As4RouteOriginExtendedCommunityCaseBuilder()
+                    .setAs4RouteOriginExtendedCommunity(new As4RouteOriginExtendedCommunityBuilder()
+                        .setAs4SpecificCommon(new As4SpecificCommonBuilder()
+                            .setAsNumber(AsNumber.getDefaultInstance("65000"))
+                            .setLocalAdministrator(Uint16.valueOf(123))
+                            .build())
+                        .build())
+                    .build())
+                .build()))
+            .build());
 
         result = statementRegistry.applyExportStatement(
                 baseAttributes, IPV4UNICAST.VALUE, exportParameters, attributeContainer, statement);
@@ -76,7 +76,7 @@ public class MatchExtComTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testExtComAll() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("ext-community-all-test")).findFirst().get();
+                .filter(st -> st.getName().equals("ext-community-all-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -84,7 +84,7 @@ public class MatchExtComTest extends AbstractStatementRegistryConsumerTest {
         assertNotNull(result.getAttributes());
 
 
-        attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setExtendedCommunities(Arrays.asList(
+        attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().setExtendedCommunities(List.of(
                 new ExtendedCommunitiesBuilder().setExtendedCommunity(new As4RouteOriginExtendedCommunityCaseBuilder()
                         .setAs4RouteOriginExtendedCommunity(
                                 new As4RouteOriginExtendedCommunityBuilder()
@@ -104,7 +104,7 @@ public class MatchExtComTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testExtComInvert() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("ext-community-invert-test")).findFirst().get();
+                .filter(st -> st.getName().equals("ext-community-invert-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -112,7 +112,7 @@ public class MatchExtComTest extends AbstractStatementRegistryConsumerTest {
         assertNull(result.getAttributes());
 
         attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
-                .setExtendedCommunities(Collections.singletonList(new ExtendedCommunitiesBuilder()
+                .setExtendedCommunities(List.of(new ExtendedCommunitiesBuilder()
                         .setExtendedCommunity(new As4RouteOriginExtendedCommunityCaseBuilder()
                                 .setAs4RouteOriginExtendedCommunity(new As4RouteOriginExtendedCommunityBuilder()
                                         .setAs4SpecificCommon(new As4SpecificCommonBuilder()
index 54d8fbed4f8e64ec0ca005e2995e672187ceb849..dab6f19f50ed623a93a822ab59ecff89564e2709 100644 (file)
@@ -5,15 +5,12 @@
  * 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.protocol.bgp.openconfig.routing.policy.statement;
 
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.doReturn;
 import static org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer.routeAttributeContainerFalse;
 
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
@@ -31,13 +28,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.
 import org.opendaylight.yangtools.yang.common.Uint16;
 
 public class SetCommunityTest extends AbstractStatementRegistryConsumerTest {
-    private final Attributes multipleCom = new AttributesBuilder().setCommunities(Arrays.asList(
+    private final Attributes multipleCom = new AttributesBuilder().setCommunities(List.of(
             new CommunitiesBuilder().setAsNumber(AsNumber.getDefaultInstance("65")).setSemantics(Uint16.valueOf(10))
                 .build(),
             new CommunitiesBuilder().setAsNumber(AsNumber.getDefaultInstance("66")).setSemantics(Uint16.valueOf(11))
                 .build()
     )).build();
-    private final Attributes emptyCom = new AttributesBuilder().setCommunities(Collections.emptyList()).build();
+    private final Attributes emptyCom = new AttributesBuilder().setCommunities(List.of()).build();
     @Mock
     private BGPRouteEntryExportParameters exportParameters;
     private List<Statement> basicStatements;
@@ -55,7 +52,7 @@ public class SetCommunityTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testInlineAdd() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("set-community-inline-add-test")).findFirst().get();
+                .filter(st -> st.getName().equals("set-community-inline-add-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -67,7 +64,7 @@ public class SetCommunityTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testInlineReplace() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("set-community-inline-replace-test")).findFirst().get();
+                .filter(st -> st.getName().equals("set-community-inline-replace-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -79,7 +76,7 @@ public class SetCommunityTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testInlineRemove() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("set-community-inline-remove-test")).findFirst().get();
+                .filter(st -> st.getName().equals("set-community-inline-remove-test")).findFirst().orElseThrow();
 
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(multipleCom);
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -91,7 +88,7 @@ public class SetCommunityTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testReferenceAdd() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("set-community-reference-add-test")).findFirst().get();
+                .filter(st -> st.getName().equals("set-community-reference-add-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -103,7 +100,7 @@ public class SetCommunityTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testReferenceReplace() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("set-community-reference-replace-test")).findFirst().get();
+                .filter(st -> st.getName().equals("set-community-reference-replace-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -115,7 +112,7 @@ public class SetCommunityTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testReferenceRemove() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("set-community-reference-remove-test")).findFirst().get();
+                .filter(st -> st.getName().equals("set-community-reference-remove-test")).findFirst().orElseThrow();
 
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(multipleCom);
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
index 2ff4f5a2979ddcd3806a16fd61343b5f27dad0a5..05cf5d41ab9270142895dbc5b6f8e14866bd060c 100644 (file)
@@ -12,8 +12,6 @@ import static org.mockito.Mockito.doReturn;
 import static org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer.routeAttributeContainerFalse;
 import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.EncapsulationTunnelType.Vxlan;
 
-import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
@@ -37,7 +35,7 @@ import org.opendaylight.yangtools.yang.common.Uint16;
 import org.opendaylight.yangtools.yang.common.Uint32;
 
 public class SetExtCommunityTest extends AbstractStatementRegistryConsumerTest {
-    private final Attributes multipleExtCom = new AttributesBuilder().setExtendedCommunities(Arrays.asList(
+    private final Attributes multipleExtCom = new AttributesBuilder().setExtendedCommunities(List.of(
             new ExtendedCommunitiesBuilder().setExtendedCommunity(new EncapsulationCaseBuilder()
                     .setEncapsulationExtendedCommunity(new EncapsulationExtendedCommunityBuilder()
                             .setTunnelType(Vxlan).build()).build()).build(),
@@ -47,8 +45,7 @@ public class SetExtCommunityTest extends AbstractStatementRegistryConsumerTest {
                                     .setLocalAdministrator(Uint16.valueOf(123))
                                     .setAsNumber(new AsNumber(Uint32.valueOf(65000))).build())
                             .build()).build()).build())).build();
-    private final Attributes emptyExtCom = new AttributesBuilder()
-            .setExtendedCommunities(Collections.emptyList()).build();
+    private final Attributes emptyExtCom = new AttributesBuilder().setExtendedCommunities(List.of()).build();
     @Mock
     private BGPRouteEntryExportParameters exportParameters;
     private List<Statement> basicStatements;
@@ -66,7 +63,7 @@ public class SetExtCommunityTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testInlineAdd() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("set-ext-community-inline-add-test")).findFirst().get();
+                .filter(st -> st.getName().equals("set-ext-community-inline-add-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -78,7 +75,7 @@ public class SetExtCommunityTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testInlineReplace() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("set-ext-community-inline-replace-test")).findFirst().get();
+                .filter(st -> st.getName().equals("set-ext-community-inline-replace-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -90,7 +87,7 @@ public class SetExtCommunityTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testInlineRemove() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("set-ext-community-inline-remove-test")).findFirst().get();
+                .filter(st -> st.getName().equals("set-ext-community-inline-remove-test")).findFirst().orElseThrow();
 
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(multipleExtCom);
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -102,7 +99,7 @@ public class SetExtCommunityTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testReferenceAdd() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("set-ext-community-reference-add-test")).findFirst().get();
+                .filter(st -> st.getName().equals("set-ext-community-reference-add-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -114,7 +111,7 @@ public class SetExtCommunityTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testReferenceReplace() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("set-ext-community-reference-replace-test")).findFirst().get();
+            .filter(st -> st.getName().equals("set-ext-community-reference-replace-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder().build());
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
@@ -126,7 +123,7 @@ public class SetExtCommunityTest extends AbstractStatementRegistryConsumerTest {
     @Test
     public void testReferenceRemove() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("set-ext-community-reference-remove-test")).findFirst().get();
+            .filter(st -> st.getName().equals("set-ext-community-reference-remove-test")).findFirst().orElseThrow();
 
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(multipleExtCom);
         RouteAttributeContainer result = statementRegistry.applyExportStatement(
index b1fa49d8336fe835fad3448745dc6330b384f6b9..cc2b48b664dead966054dd7f650c4a8c5e5a88b7 100644 (file)
@@ -54,7 +54,7 @@ public class VpnNonMemberHandlerTest extends AbstractStatementRegistryConsumerTe
     @Test
     public void testExtComAny() {
         Statement statement = basicStatements.stream()
-                .filter(st -> st.getName().equals("vpn-non-member-test")).findFirst().get();
+                .filter(st -> st.getName().equals("vpn-non-member-test")).findFirst().orElseThrow();
         RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
                 new AttributesBuilder()
                         .setExtendedCommunities(List.of(new ExtendedCommunitiesBuilder()
index f67bfab2607ea078f282ad8f16878c2aad589a3f..35091b04e29fa06b2b09a34f80fead355f4ec6e4 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.protocol.bgp.parser.spi;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.mockito.Mockito.doReturn;
 
 import com.google.common.primitives.UnsignedBytes;
@@ -30,9 +29,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
 
 @RunWith(MockitoJUnitRunner.StrictStubs.class)
 public class UtilsTest {
-
-    @Mock private AddressFamilyRegistry afiReg;
-    @Mock private SubsequentAddressFamilyRegistry safiReg;
+    @Mock
+    private AddressFamilyRegistry afiReg;
+    @Mock
+    private SubsequentAddressFamilyRegistry safiReg;
 
     @Before
     public void setUp() {
@@ -98,8 +98,8 @@ public class UtilsTest {
     public void testMultiprotocolCapabilitiesUtil() throws BGPParsingException {
         final byte[] bytes = new byte[] {0, 1, 0, 1};
         final ByteBuf bytesBuf = Unpooled.copiedBuffer(bytes);
-        final BgpTableType parsedAfiSafi = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(bytesBuf, afiReg,
-            safiReg).get();
+        final BgpTableType parsedAfiSafi = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(bytesBuf, afiReg, safiReg)
+            .orElseThrow();
         assertEquals(Ipv4AddressFamily.VALUE, parsedAfiSafi.getAfi());
         assertEquals(UnicastSubsequentAddressFamily.VALUE, parsedAfiSafi.getSafi());
 
@@ -113,18 +113,14 @@ public class UtilsTest {
     public void testUnsupportedAfi() {
         final byte[] bytes = new byte[] {0, 2, 0, 1};
         final ByteBuf bytesBuf = Unpooled.copiedBuffer(bytes);
-        final Optional<BgpTableType> parsedAfiSafi = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(bytesBuf, afiReg,
-            safiReg);
-        assertFalse(parsedAfiSafi.isPresent());
+        assertEquals(Optional.empty(), MultiprotocolCapabilitiesUtil.parseMPAfiSafi(bytesBuf, afiReg, safiReg));
     }
 
     @Test
     public void testUnsupportedSafi() {
         final byte[] bytes = new byte[] {0, 1, 0, 3};
         final ByteBuf bytesBuf = Unpooled.copiedBuffer(bytes);
-        final Optional<BgpTableType> parsedAfiSafi = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(bytesBuf, afiReg,
-            safiReg);
-        assertFalse(parsedAfiSafi.isPresent());
+        assertEquals(Optional.empty(), MultiprotocolCapabilitiesUtil.parseMPAfiSafi(bytesBuf, afiReg, safiReg));
     }
 
     @Test(expected = ParameterLengthOverflowException.class)
index 0d5c7af87013001ea325c2a1f510b21c95a66cea..635dede9c1bdd1bc25125a4a49073a61ceb12668 100644 (file)
@@ -84,7 +84,7 @@ public abstract class AbstractRIBSupportTest<C extends Routes & DataObject & Cho
     private AbstractRIBSupport<C, S, R> abstractRIBSupport;
 
     protected final void setUpTestCustomizer(final AbstractRIBSupport<C, S, R> ribSupport) throws Exception {
-        this.abstractRIBSupport = ribSupport;
+        abstractRIBSupport = ribSupport;
     }
 
     @Before
@@ -95,7 +95,7 @@ public abstract class AbstractRIBSupportTest<C extends Routes & DataObject & Cho
             AbstractRIBSupportTest.this.insertedRoutes.add(adapter.currentSerializer()
                     .fromNormalizedNode((YangInstanceIdentifier) args[1], (NormalizedNode) args[2]));
             return args[1];
-        }).when(this.tx).put(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class),
+        }).when(tx).put(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class),
                 any(NormalizedNode.class));
 
         doAnswer(invocation -> {
@@ -103,15 +103,15 @@ public abstract class AbstractRIBSupportTest<C extends Routes & DataObject & Cho
             AbstractRIBSupportTest.this.deletedRoutes.add((InstanceIdentifier)
                 adapter.currentSerializer().fromYangInstanceIdentifier((YangInstanceIdentifier) args[1]));
             return args[1];
-        }).when(this.tx).delete(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class));
-        this.deletedRoutes = new ArrayList<>();
-        this.insertedRoutes = new ArrayList<>();
+        }).when(tx).delete(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class));
+        deletedRoutes = new ArrayList<>();
+        insertedRoutes = new ArrayList<>();
     }
 
     @Override
     protected final AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() {
         final AbstractDataBrokerTestCustomizer customizer = super.createDataBrokerTestCustomizer();
-        this.adapter = customizer.getAdapterContext();
+        adapter = customizer.getAdapterContext();
         return customizer;
     }
 
@@ -143,29 +143,29 @@ public abstract class AbstractRIBSupportTest<C extends Routes & DataObject & Cho
         final Tables tables = new TablesBuilder().withKey(getTablesKey())
             .setAttributes(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329
                 .rib.tables.AttributesBuilder().build()).build();
-        return (MapEntryNode) this.adapter.currentSerializer().toNormalizedNode(tablesIId(), tables).getValue();
+        return (MapEntryNode) adapter.currentSerializer().toNormalizedNode(tablesIId(), tables).getValue();
     }
 
     protected final ChoiceNode createRoutes(final Routes routes) {
         final Tables tables = new TablesBuilder().withKey(getTablesKey()).setRoutes(routes).build();
-        return (ChoiceNode) verifyNotNull(((MapEntryNode) this.adapter.currentSerializer()
+        return (ChoiceNode) verifyNotNull(((MapEntryNode) adapter.currentSerializer()
             .toNormalizedNode(tablesIId(), tables).getValue())
             .childByArg(new NodeIdentifier(BindingReflections.findQName(Routes.class))));
     }
 
     protected final Collection<MapEntryNode> createRoutes(final S routes) {
         Preconditions.checkArgument(routes.implementedInterface()
-                .equals(this.abstractRIBSupport.routesContainerClass()));
+                .equals(abstractRIBSupport.routesContainerClass()));
         final InstanceIdentifier<S> routesIId = routesIId();
-        final Map.Entry<YangInstanceIdentifier, NormalizedNode> normalizedNode = this.adapter.currentSerializer()
+        final Map.Entry<YangInstanceIdentifier, NormalizedNode> normalizedNode = adapter.currentSerializer()
                 .toNormalizedNode(routesIId, routes);
         final ContainerNode container = (ContainerNode) normalizedNode.getValue();
         final NodeIdentifier routeNid = new NodeIdentifier(getRouteListQname());
-        return ((MapNode) verifyNotNull(container.childByArg(routeNid))).body();
+        return ((MapNode) container.getChildByArg(routeNid)).body();
     }
 
     private TablesKey getTablesKey() {
-        return new TablesKey(this.abstractRIBSupport.getAfi(), this.abstractRIBSupport.getSafi());
+        return new TablesKey(abstractRIBSupport.getAfi(), abstractRIBSupport.getSafi());
     }
 
     private InstanceIdentifier<Tables> tablesIId() {
@@ -174,22 +174,22 @@ public abstract class AbstractRIBSupportTest<C extends Routes & DataObject & Cho
 
     private InstanceIdentifier<S> routesIId() {
         final InstanceIdentifier<Tables> tables = tablesIId();
-        return tables.child(this.abstractRIBSupport.routesCaseClass(), this.abstractRIBSupport.routesContainerClass());
+        return tables.child(abstractRIBSupport.routesCaseClass(), abstractRIBSupport.routesContainerClass());
     }
 
     protected final YangInstanceIdentifier getTablePath() {
         final InstanceIdentifier<Tables> tables = tablesIId();
-        return this.adapter.currentSerializer().toYangInstanceIdentifier(tables);
+        return adapter.currentSerializer().toYangInstanceIdentifier(tables);
     }
 
     protected final YangInstanceIdentifier getRoutePath() {
         final InstanceIdentifier<S> routesIId = routesIId();
-        return this.adapter.currentSerializer().toYangInstanceIdentifier(routesIId).node(getRouteListQname());
+        return adapter.currentSerializer().toYangInstanceIdentifier(routesIId).node(getRouteListQname());
     }
 
     private QName getRouteListQname() {
-        return BindingReflections.findQName(this.abstractRIBSupport.routesListClass())
-                .bindTo(BindingReflections.getQNameModule(this.abstractRIBSupport.routesCaseClass()));
+        return BindingReflections.findQName(abstractRIBSupport.routesListClass())
+                .bindTo(BindingReflections.getQNameModule(abstractRIBSupport.routesCaseClass()));
     }
 
     protected final NodeIdentifierWithPredicates createRouteNIWP(final S routes) {
index a393b8996c450d0d4969d22b925fe51e6d77f047..37c8a5a6bd06962b763333ff3fec355d7910c979 100644 (file)
@@ -158,8 +158,8 @@ public abstract class PCCMockCommon {
         final List<Message> messages;
         checkReceivedMessages(pceSessionListener, expectedTotalMessages);
         if (startAtNumberLsp.isPresent()) {
-            messages = pceSessionListener.messages().subList(startAtNumberLsp.get(),
-                    startAtNumberLsp.get() + expectedNumberOfLsp);
+            final int offset = startAtNumberLsp.orElseThrow();
+            messages = pceSessionListener.messages().subList(offset, offset + expectedNumberOfLsp);
         } else {
             messages = pceSessionListener.messages();
         }