X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=servicehandler%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fservicehandler%2FDowngradeConstraintsTest.java;h=b3bcaa70c0f5a32ba49e8b6c73c933386464c377;hb=HEAD;hp=abc8d502ae84d755aefdb71ea57fcdb022a57d8c;hpb=f49968974e1477d4fd9cfdd87d867c9ad347678e;p=transportpce.git diff --git a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraintsTest.java b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraintsTest.java index abc8d502a..b3bcaa70c 100644 --- a/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraintsTest.java +++ b/servicehandler/src/test/java/org/opendaylight/transportpce/servicehandler/DowngradeConstraintsTest.java @@ -7,27 +7,28 @@ */ package org.opendaylight.transportpce.servicehandler; +import static org.hamcrest.CoreMatchers.hasItems; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.collection.IsCollectionWithSize.hasSize; import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.opendaylight.transportpce.servicehandler.utils.ConstraintsUtils.buildHardConstraint; import static org.opendaylight.transportpce.servicehandler.utils.ConstraintsUtils.buildSoftConstraint; import java.util.Set; import org.hamcrest.collection.IsMapContaining; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev210528.NodeIdType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.DiversityConstraints.DiversityType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.common.constraints.LinkIdentifierKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.diversity.existing.service.constraints.ServiceIdentifierListKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.HardConstraints; -import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.HardConstraintsBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.routing.constraints.SoftConstraints; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.DiversityConstraints.DiversityType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.common.constraints.LinkIdentifierBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.diversity.existing.service.constraints.ServiceIdentifierListKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.routing.constraints.HardConstraints; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.routing.constraints.HardConstraintsBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.routing.constraints.SoftConstraints; /** * Class to test downgrading and updating Constraints . @@ -37,7 +38,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev21 public class DowngradeConstraintsTest { @Test - public void testUpdateSoftConstraintsForCustomerCode() { + void testUpdateSoftConstraintsForCustomerCode() { // test no addition when hard customer-code is null or empty HardConstraints initialHardConstraints = buildHardConstraint(null, false, null, null, null, null, false, false, null, null); @@ -45,8 +46,8 @@ public class DowngradeConstraintsTest { buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); SoftConstraints generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertNull("updated soft constraints should contain no customer code", - generatedSoftConstraints.getCustomerCode()); + assertNull(generatedSoftConstraints.getCustomerCode(), + "updated soft constraints should contain no customer code"); Set softCustomerCode = Set.of("soft-customer-code 3", "soft-customer-code 4"); initialSoftConstraints = buildSoftConstraint(softCustomerCode, false, null, null, null, null, false, false, null, null); @@ -61,14 +62,13 @@ public class DowngradeConstraintsTest { initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints should contain the customer code of hard constraint", - generatedSoftConstraints.getCustomerCode(), - initialHardConstraints.getCustomerCode()); + assertEquals(generatedSoftConstraints.getCustomerCode(),initialHardConstraints.getCustomerCode(), + "updated soft constraints should contain the customer code of hard constraint"); // test addition of hard customer-code when existing soft customer-code initialSoftConstraints = buildSoftConstraint(softCustomerCode, false, null, null, null, null, false, false, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( - initialHardConstraints, initialSoftConstraints); + initialHardConstraints, initialSoftConstraints); assertThat("updated soft constraints should contain 4 customer code", generatedSoftConstraints.getCustomerCode(), hasSize(4)); assertThat(generatedSoftConstraints.getCustomerCode(), @@ -77,15 +77,15 @@ public class DowngradeConstraintsTest { } @Test - public void testUpdateSoftConstraintsForDiversity() { + void testUpdateSoftConstraintsForDiversity() { HardConstraints initialHardConstraints = buildHardConstraint(null, false, null, null, null, null, false, false, null, null); SoftConstraints initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); SoftConstraints generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertNull("updated soft constraints should contain no diversity constraint", - generatedSoftConstraints.getDiversity()); + assertNull(generatedSoftConstraints.getDiversity(), + "updated soft constraints should contain no diversity constraint"); Set softDiversityServiceid = Set.of("soft-service 3"); initialSoftConstraints = buildSoftConstraint(null, false, softDiversityServiceid, null, null, null, false, false, null, null); @@ -100,9 +100,8 @@ public class DowngradeConstraintsTest { initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints should contain the diversity of hard constraint", - generatedSoftConstraints.getDiversity(), - initialHardConstraints.getDiversity()); + assertEquals(generatedSoftConstraints.getDiversity(), initialHardConstraints.getDiversity(), + "updated soft constraints should contain the diversity of hard constraint"); // test addition of hard diversity when existing soft diversity initialSoftConstraints = @@ -111,9 +110,8 @@ public class DowngradeConstraintsTest { initialHardConstraints, initialSoftConstraints); assertThat("updated soft constraints should contain diversity with 3 services", generatedSoftConstraints.getDiversity().getServiceIdentifierList().size(), is(3)); - assertEquals("updated soft constraints should have diversity type of serial", - DiversityType.Serial, - generatedSoftConstraints.getDiversity().getDiversityType()); + assertEquals(DiversityType.Serial, generatedSoftConstraints.getDiversity().getDiversityType(), + "updated soft constraints should have diversity type of serial"); assertThat(generatedSoftConstraints.getDiversity().getServiceIdentifierList(), IsMapContaining.hasKey(new ServiceIdentifierListKey("hard-service 1"))); assertThat(generatedSoftConstraints.getDiversity().getServiceIdentifierList(), @@ -123,21 +121,21 @@ public class DowngradeConstraintsTest { } @Test - public void testUpdateSoftConstraintsForExclude() { + void testUpdateSoftConstraintsForExclude() { HardConstraints initialHardConstraints = buildHardConstraint(null, false, null, null, null, null, false, false, null, null); SoftConstraints initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); SoftConstraints generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertNull("updated soft constraints should contain no exclude constraint", - generatedSoftConstraints.getExclude()); + assertNull(generatedSoftConstraints.getExclude(), + "updated soft constraints should contain no exclude constraint"); initialSoftConstraints = buildSoftConstraint(null, false, null, "link", null, null, false, false, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints should not be changed", - initialSoftConstraints.getExclude(), generatedSoftConstraints.getExclude()); + assertEquals(initialSoftConstraints.getExclude(), generatedSoftConstraints.getExclude(), + "updated soft constraints should not be changed"); // test addition of hard exclude with fiber list when no soft exclude initialHardConstraints = @@ -145,8 +143,8 @@ public class DowngradeConstraintsTest { initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints should contain the exclude constraint of hard constraint", - generatedSoftConstraints.getExclude(), initialHardConstraints.getExclude()); + assertEquals(generatedSoftConstraints.getExclude(), initialHardConstraints.getExclude(), + "updated soft constraints should contain the exclude constraint of hard constraint"); // test addition of hard exclude with fiber list when existing soft // exclude with fiber list @@ -164,8 +162,8 @@ public class DowngradeConstraintsTest { initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints should contain the exclude constraint of hard constraint", - generatedSoftConstraints.getExclude(), initialHardConstraints.getExclude()); + assertEquals(generatedSoftConstraints.getExclude(), initialHardConstraints.getExclude(), + "updated soft constraints should contain the exclude constraint of hard constraint"); // test addition of hard exclude with link list when existing soft // exclude with link list @@ -174,30 +172,30 @@ public class DowngradeConstraintsTest { initialHardConstraints, initialSoftConstraints); assertThat("updated soft constraints should contain exclude with 3 links", generatedSoftConstraints.getExclude().getLinkIdentifier().size(), is(3)); - assertThat(generatedSoftConstraints.getExclude().getLinkIdentifier(), - IsMapContaining.hasKey(new LinkIdentifierKey("link-id 1", "openroadm-topology"))); - assertThat(generatedSoftConstraints.getExclude().getLinkIdentifier(), - IsMapContaining.hasKey(new LinkIdentifierKey("link-id 2", "openroadm-topology"))); - assertThat(generatedSoftConstraints.getExclude().getLinkIdentifier(), - IsMapContaining.hasKey(new LinkIdentifierKey("link-id 3", "openroadm-topology"))); + assertThat(generatedSoftConstraints.getExclude().getLinkIdentifier(), hasItems(new LinkIdentifierBuilder() + .setLinkId("link-id 1").setLinkNetworkId("openroadm-topology").build())); + assertThat(generatedSoftConstraints.getExclude().getLinkIdentifier(), hasItems(new LinkIdentifierBuilder() + .setLinkId("link-id 2").setLinkNetworkId("openroadm-topology").build())); + assertThat(generatedSoftConstraints.getExclude().getLinkIdentifier(), hasItems(new LinkIdentifierBuilder() + .setLinkId("link-id 3").setLinkNetworkId("openroadm-topology").build())); } @Test - public void testUpdateSoftConstraintsForInclude() { + void testUpdateSoftConstraintsForInclude() { HardConstraints initialHardConstraints = buildHardConstraint(null, false, null, null, null, null, false, false, null, null); SoftConstraints initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); SoftConstraints generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertNull("updated soft constraints should contain no include constraint", - generatedSoftConstraints.getInclude()); + assertNull(generatedSoftConstraints.getInclude(), + "updated soft constraints should contain no include constraint"); initialSoftConstraints = buildSoftConstraint(null, false, null, null, "link", null, false, false, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints should not be changed", - initialSoftConstraints.getInclude(), generatedSoftConstraints.getInclude()); + assertEquals(initialSoftConstraints.getInclude(), generatedSoftConstraints.getInclude(), + "updated soft constraints should not be changed"); // test addition of hard include with fiber list when no soft include initialHardConstraints = @@ -205,8 +203,8 @@ public class DowngradeConstraintsTest { initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints should contain the include constraint of hard constraint", - generatedSoftConstraints.getInclude(), initialHardConstraints.getInclude()); + assertEquals(generatedSoftConstraints.getInclude(), initialHardConstraints.getInclude(), + "updated soft constraints should contain the include constraint of hard constraint"); // test addition of hard include with fiber list when existing soft // include with fiber list @@ -224,8 +222,8 @@ public class DowngradeConstraintsTest { initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints should contain the include constraint of hard constraint", - generatedSoftConstraints.getInclude(), initialHardConstraints.getInclude()); + assertEquals(generatedSoftConstraints.getInclude(), initialHardConstraints.getInclude(), + "updated soft constraints should contain the include constraint of hard constraint"); // test addition of hard include with link list when existing soft // include with link list @@ -234,33 +232,33 @@ public class DowngradeConstraintsTest { initialHardConstraints, initialSoftConstraints); assertThat("updated soft constraints should contain include with 3 links", generatedSoftConstraints.getInclude().getLinkIdentifier().size(), is(3)); - assertThat(generatedSoftConstraints.getInclude().getLinkIdentifier(), - IsMapContaining.hasKey(new LinkIdentifierKey("link-id 1", "openroadm-topology"))); - assertThat(generatedSoftConstraints.getInclude().getLinkIdentifier(), - IsMapContaining.hasKey(new LinkIdentifierKey("link-id 2", "openroadm-topology"))); - assertThat(generatedSoftConstraints.getInclude().getLinkIdentifier(), - IsMapContaining.hasKey(new LinkIdentifierKey("link-id 3", "openroadm-topology"))); + assertThat(generatedSoftConstraints.getInclude().getLinkIdentifier(), hasItems(new LinkIdentifierBuilder() + .setLinkId("link-id 1").setLinkNetworkId("openroadm-topology").build())); + assertThat(generatedSoftConstraints.getInclude().getLinkIdentifier(), hasItems(new LinkIdentifierBuilder() + .setLinkId("link-id 2").setLinkNetworkId("openroadm-topology").build())); + assertThat(generatedSoftConstraints.getInclude().getLinkIdentifier(), hasItems(new LinkIdentifierBuilder() + .setLinkId("link-id 3").setLinkNetworkId("openroadm-topology").build())); } @Test - public void testUpdateSoftConstraintsForLatency() { + void testUpdateSoftConstraintsForLatency() { HardConstraints initialHardConstraints = buildHardConstraint(null, false, null, null, null, null, false, false, null, null); SoftConstraints initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); SoftConstraints generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertNull("updated soft constraints should contain no latency constraint", - generatedSoftConstraints.getLatency()); + assertNull(generatedSoftConstraints.getLatency(), + "updated soft constraints should contain no latency constraint"); initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, Double.valueOf(12.2), false, false, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints should not be changed", - initialSoftConstraints.getLatency(), generatedSoftConstraints.getLatency()); - assertEquals("updated soft constraints value should be '12.2'", - (float) 12.2, generatedSoftConstraints.getLatency().getMaxLatency().floatValue(), 0.0f); + assertEquals(initialSoftConstraints.getLatency(), generatedSoftConstraints.getLatency(), + "updated soft constraints should not be changed"); + assertEquals((float) 12.2, generatedSoftConstraints.getLatency().getMaxLatency().floatValue(), 0.0f, + "updated soft constraints value should be '12.2'"); // test addition of hard latency when no soft latency initialHardConstraints = @@ -268,141 +266,141 @@ public class DowngradeConstraintsTest { initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints value should be '16.59'", - (float) 16.59, generatedSoftConstraints.getLatency().getMaxLatency().floatValue(), 0.0f); + assertEquals((float) 16.59, generatedSoftConstraints.getLatency().getMaxLatency().floatValue(), 0.0f, + "updated soft constraints value should be '16.59'"); // test addition of hard latency when existing different soft latency initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, Double.valueOf(12.2), false, false, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints value should be '12.2'", - (float) 12.2, generatedSoftConstraints.getLatency().getMaxLatency().floatValue(), 0.0f); + assertEquals((float) 12.2, generatedSoftConstraints.getLatency().getMaxLatency().floatValue(), 0.0f, + "updated soft constraints value should be '12.2'"); } @Test - public void testUpdateSoftConstraintsForDistance() { + void testUpdateSoftConstraintsForDistance() { HardConstraints initialHardConstraints = buildHardConstraint(null, false, null, null, null, null, false, false, null, null); SoftConstraints initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); SoftConstraints generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertNull("updated soft constraints should contain no distance constraint", - generatedSoftConstraints.getDistance()); + assertNull(generatedSoftConstraints.getDistance(), + "updated soft constraints should contain no distance constraint"); initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, "750.2", null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints should not be changed", - initialSoftConstraints.getDistance(), generatedSoftConstraints.getDistance()); - assertEquals("updated soft constraints value should be '750.2'", - (float) 750.2, generatedSoftConstraints.getDistance().getMaxDistance().floatValue(), 0.0f); + assertEquals(initialSoftConstraints.getDistance(), generatedSoftConstraints.getDistance(), + "updated soft constraints should not be changed"); + assertEquals((float) 750.2, generatedSoftConstraints.getDistance().getMaxDistance().floatValue(), 0.0f, + "updated soft constraints value should be '750.2'"); // test addition of hard distance when no soft distance initialHardConstraints = buildHardConstraint(null, false, null, null, null, null, false, false, "555.5", null); initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints value should be '555.5'", - (float) 555.5, generatedSoftConstraints.getDistance().getMaxDistance().floatValue(), 0.0f); + assertEquals((float) 555.5, generatedSoftConstraints.getDistance().getMaxDistance().floatValue(), 0.0f, + "updated soft constraints value should be '555.5'"); // test addition of hard distance when existing different soft distance initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, "750.2", null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints value should be '555.5'", - (float) 555.5, generatedSoftConstraints.getDistance().getMaxDistance().floatValue(), 0.0f); + assertEquals((float) 555.5, generatedSoftConstraints.getDistance().getMaxDistance().floatValue(), 0.0f, + "updated soft constraints value should be '555.5'"); } @Test - public void testUpdateSoftConstraintsForHopCountAndTEmetric() { + void testUpdateSoftConstraintsForHopCountAndTEmetric() { HardConstraints initialHardConstraints = buildHardConstraint(null, false, null, null, null, null, false, false, null, null); SoftConstraints initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); SoftConstraints generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertNull("updated soft constraints should contain no hop-count constraint", - generatedSoftConstraints.getHopCount()); + assertNull(generatedSoftConstraints.getHopCount(), + "updated soft constraints should contain no hop-count constraint"); initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, true, true, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints should not be changed", - initialSoftConstraints.getHopCount(), generatedSoftConstraints.getHopCount()); - assertEquals("updated soft constraints max-wdm-hop-count should be '3'", - 3, generatedSoftConstraints.getHopCount().getMaxWdmHopCount().intValue()); - assertEquals("updated soft constraints max-otn-hop-count should be '5'", - 5, generatedSoftConstraints.getHopCount().getMaxOtnHopCount().intValue()); - assertEquals("updated soft constraints max-wdm-TE-metric should be '8'", - 8, generatedSoftConstraints.getTEMetric().getMaxWdmTEMetric().intValue()); - assertEquals("updated soft constraints max-otn-TE-metric should be '11'", - 11, generatedSoftConstraints.getTEMetric().getMaxOtnTEMetric().intValue()); + assertEquals(initialSoftConstraints.getHopCount(), generatedSoftConstraints.getHopCount(), + "updated soft constraints should not be changed"); + assertEquals(3, generatedSoftConstraints.getHopCount().getMaxWdmHopCount().intValue(), + "updated soft constraints max-wdm-hop-count should be '3'"); + assertEquals(5, generatedSoftConstraints.getHopCount().getMaxOtnHopCount().intValue(), + "updated soft constraints max-otn-hop-count should be '5'"); + assertEquals(8, generatedSoftConstraints.getTEMetric().getMaxWdmTEMetric().intValue(), + "updated soft constraints max-wdm-TE-metric should be '8'"); + assertEquals(11, generatedSoftConstraints.getTEMetric().getMaxOtnTEMetric().intValue(), + "updated soft constraints max-otn-TE-metric should be '11'"); // test addition of hard hop-count when no soft hop-count initialHardConstraints = buildHardConstraint(null, false, null, null, null, null, true, true, null, null); initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints should contain hard constraint", - initialHardConstraints.getHopCount(), generatedSoftConstraints.getHopCount()); - assertEquals("updated soft constraints max-wdm-hop-count should be '3'", - 3, generatedSoftConstraints.getHopCount().getMaxWdmHopCount().intValue()); - assertEquals("updated soft constraints max-otn-hop-count should be '5'", - 5, generatedSoftConstraints.getHopCount().getMaxOtnHopCount().intValue()); - assertEquals("updated soft constraints max-wdm-TE-metric should be '8'", - 8, generatedSoftConstraints.getTEMetric().getMaxWdmTEMetric().intValue()); - assertEquals("updated soft constraints max-otn-TE-metric should be '11'", - 11, generatedSoftConstraints.getTEMetric().getMaxOtnTEMetric().intValue()); + assertEquals(initialHardConstraints.getHopCount(), generatedSoftConstraints.getHopCount(), + "updated soft constraints should contain hard constraint"); + assertEquals(3, generatedSoftConstraints.getHopCount().getMaxWdmHopCount().intValue(), + "updated soft constraints max-wdm-hop-count should be '3'"); + assertEquals(5, generatedSoftConstraints.getHopCount().getMaxOtnHopCount().intValue(), + "updated soft constraints max-otn-hop-count should be '5'"); + assertEquals(8, generatedSoftConstraints.getTEMetric().getMaxWdmTEMetric().intValue(), + "updated soft constraints max-wdm-TE-metric should be '8'"); + assertEquals(11, generatedSoftConstraints.getTEMetric().getMaxOtnTEMetric().intValue(), + "updated soft constraints max-otn-TE-metric should be '11'"); // test addition of hard hop-count when existing soft hop-count initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, true, true, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints max-wdm-hop-count should be '3'", - 3, generatedSoftConstraints.getHopCount().getMaxWdmHopCount().intValue()); - assertEquals("updated soft constraints max-otn-hop-count should be '5'", - 5, generatedSoftConstraints.getHopCount().getMaxOtnHopCount().intValue()); - assertEquals("updated soft constraints max-wdm-TE-metric should be '8'", - 8, generatedSoftConstraints.getTEMetric().getMaxWdmTEMetric().intValue()); - assertEquals("updated soft constraints max-otn-TE-metric should be '11'", - 11, generatedSoftConstraints.getTEMetric().getMaxOtnTEMetric().intValue()); + assertEquals(3, generatedSoftConstraints.getHopCount().getMaxWdmHopCount().intValue(), + "updated soft constraints max-wdm-hop-count should be '3'"); + assertEquals(5, generatedSoftConstraints.getHopCount().getMaxOtnHopCount().intValue(), + "updated soft constraints max-otn-hop-count should be '5'"); + assertEquals(8, generatedSoftConstraints.getTEMetric().getMaxWdmTEMetric().intValue(), + "updated soft constraints max-wdm-TE-metric should be '8'"); + assertEquals(11, generatedSoftConstraints.getTEMetric().getMaxOtnTEMetric().intValue(), + "updated soft constraints max-otn-TE-metric should be '11'"); } @Test - public void testUpdateSoftConstraintsForCoRouting() { + void testUpdateSoftConstraintsForCoRouting() { HardConstraints initialHardConstraints = buildHardConstraint(null, false, null, null, null, null, false, false, null, null); SoftConstraints initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); SoftConstraints generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertNull("updated soft constraints should contain no co-routing constraint", - generatedSoftConstraints.getCoRouting()); + assertNull(generatedSoftConstraints.getCoRouting(), + "updated soft constraints should contain no co-routing constraint"); initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, true, false, null, "coRouting1"); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints should not be changed", - initialSoftConstraints.getCoRouting(), generatedSoftConstraints.getCoRouting()); - assertEquals("updated soft constraints should contain 2 co-routed services", - 2, generatedSoftConstraints.getCoRouting().getServiceIdentifierList().size()); + assertEquals(initialSoftConstraints.getCoRouting(), generatedSoftConstraints.getCoRouting(), + "updated soft constraints should not be changed"); + assertEquals(2, generatedSoftConstraints.getCoRouting().getServiceIdentifierList().size(), + "updated soft constraints should contain 2 co-routed services"); assertTrue(generatedSoftConstraints.getCoRouting().getServiceIdentifierList() - .get(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.constraints.co + .get(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.co .routing.ServiceIdentifierListKey("service 1")) .getServiceApplicability().getEquipment().getRoadmSrg()); assertNull(generatedSoftConstraints.getCoRouting().getServiceIdentifierList() - .get(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.constraints.co + .get(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.co .routing.ServiceIdentifierListKey("service 1")) .getServiceApplicability().getLink()); assertNull(generatedSoftConstraints.getCoRouting().getServiceIdentifierList() - .get(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.constraints.co + .get(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.co .routing.ServiceIdentifierListKey("service 2")) .getServiceApplicability().getEquipment()); assertTrue(generatedSoftConstraints.getCoRouting().getServiceIdentifierList() - .get(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.constraints.co + .get(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.co .routing.ServiceIdentifierListKey("service 2")) .getServiceApplicability().getLink()); @@ -412,16 +410,16 @@ public class DowngradeConstraintsTest { initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints should contain hard constraint", - initialHardConstraints.getCoRouting(), generatedSoftConstraints.getCoRouting()); - assertEquals("updated soft constraints should contain 1 co-routed service", - 1, generatedSoftConstraints.getCoRouting().getServiceIdentifierList().size()); + assertEquals(initialHardConstraints.getCoRouting(), generatedSoftConstraints.getCoRouting(), + "updated soft constraints should contain hard constraint"); + assertEquals(1, generatedSoftConstraints.getCoRouting().getServiceIdentifierList().size(), + "updated soft constraints should contain 1 co-routed service"); assertTrue(generatedSoftConstraints.getCoRouting().getServiceIdentifierList() - .get(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.constraints.co + .get(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.co .routing.ServiceIdentifierListKey("service 3")) .getServiceApplicability().getSite()); assertNull(generatedSoftConstraints.getCoRouting().getServiceIdentifierList() - .get(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.constraints.co + .get(new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.co .routing.ServiceIdentifierListKey("service 3")) .getServiceApplicability().getLink()); @@ -430,77 +428,76 @@ public class DowngradeConstraintsTest { buildSoftConstraint(null, false, null, null, null, null, true, false, null, "coRouting1"); generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints( initialHardConstraints, initialSoftConstraints); - assertEquals("updated soft constraints should contain 3 co-routed service", - 3, generatedSoftConstraints.getCoRouting().getServiceIdentifierList().size()); + assertEquals(3, generatedSoftConstraints.getCoRouting().getServiceIdentifierList().size(), + "updated soft constraints should contain 3 co-routed service"); assertThat(generatedSoftConstraints.getCoRouting().getServiceIdentifierList(), IsMapContaining.hasKey( - new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.constraints.co + new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.co .routing.ServiceIdentifierListKey("service 1"))); assertThat(generatedSoftConstraints.getCoRouting().getServiceIdentifierList(), IsMapContaining.hasKey( - new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.constraints.co + new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.co .routing.ServiceIdentifierListKey("service 2"))); assertThat(generatedSoftConstraints.getCoRouting().getServiceIdentifierList(), IsMapContaining.hasKey( - new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev211210.constraints.co + new org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constraints.rev221209.constraints.co .routing.ServiceIdentifierListKey("service 3"))); } @Test - public void testDowngradeHardConstraints() { + void testDowngradeHardConstraints() { HardConstraints initialHardConstraints = null; HardConstraints genHardConstraints = DowngradeConstraints.downgradeHardConstraints(initialHardConstraints); - assertNotNull("generated hard-constraints should be empty, not null", genHardConstraints); + assertNotNull(genHardConstraints, "generated hard-constraints should be empty, not null"); initialHardConstraints = new HardConstraintsBuilder().build(); genHardConstraints = DowngradeConstraints.downgradeHardConstraints(initialHardConstraints); - assertNotNull("generated hard-constraints should be empty, not null", genHardConstraints); + assertNotNull(genHardConstraints, "generated hard-constraints should be empty, not null"); initialHardConstraints = buildHardConstraint(null, false, null, "link1", null, Double.valueOf(12.8), false, false, null, null); genHardConstraints = DowngradeConstraints.downgradeHardConstraints(initialHardConstraints); - assertEquals("Latency value should be 12.8", - (long) 12.8, genHardConstraints.getLatency().getMaxLatency().longValue()); - assertNull("generated hard constraints should only contain max-latency value", - genHardConstraints.getCoRouting()); - assertNull("generated hard constraints should only contain max-latency value", - genHardConstraints.getExclude()); - assertNull("generated hard constraints should only contain max-latency value", - genHardConstraints.getInclude()); + assertEquals((long) 12.8, genHardConstraints.getLatency().getMaxLatency().longValue(), + "Latency value should be 12.8"); + assertNull(genHardConstraints.getCoRouting(), + "generated hard constraints should only contain max-latency value"); + assertNull(genHardConstraints.getExclude(), "generated hard constraints should only contain max-latency value"); + assertNull(genHardConstraints.getInclude(), "generated hard constraints should only contain max-latency value"); } @Test - public void testConvertToSoftConstraints() { + void testConvertToSoftConstraints() { HardConstraints initialHardConstraints = null; SoftConstraints genSoftConstraints = DowngradeConstraints.convertToSoftConstraints(initialHardConstraints); - assertNotNull("generated soft constraints should never be null", genSoftConstraints); - assertNull("generated soft constraints should be empty", genSoftConstraints.getExclude()); - assertNull("generated soft constraints should be empty", genSoftConstraints.getCoRouting()); - assertNull("generated soft constraints should be empty", genSoftConstraints.getLatency()); + assertNotNull(genSoftConstraints, "generated soft constraints should never be null"); + assertNull(genSoftConstraints.getExclude(), "generated soft constraints should be empty"); + assertNull(genSoftConstraints.getCoRouting(), "generated soft constraints should be empty"); + assertNull(genSoftConstraints.getLatency(), "generated soft constraints should be empty"); Set hardCustomerCode = Set.of("customer-code 1", "customer-code 2"); initialHardConstraints = buildHardConstraint(hardCustomerCode, false, null, "link1", "node", null, false, false, null, null); genSoftConstraints = DowngradeConstraints.convertToSoftConstraints(initialHardConstraints); - assertEquals("generated soft constraints should contain customer-code items", 2, - genSoftConstraints.getCustomerCode().size()); + assertEquals(2, genSoftConstraints.getCustomerCode().size(), + "generated soft constraints should contain customer-code items"); assertTrue(genSoftConstraints.getCustomerCode().contains("customer-code 1")); assertTrue(genSoftConstraints.getCustomerCode().contains("customer-code 2")); - assertNotNull("generated soft constraints should contain exclude constraint", genSoftConstraints.getExclude()); - assertEquals("generated soft constraints should contain exclude constraint with one link-id", - 1, genSoftConstraints.getExclude().getLinkIdentifier().values().size()); + assertNotNull(genSoftConstraints.getExclude(), "generated soft constraints should contain exclude constraint"); + assertEquals(1, genSoftConstraints.getExclude().getLinkIdentifier().size(), + "generated soft constraints should contain exclude constraint with one link-id"); assertEquals("link-id 1", - genSoftConstraints.getExclude().getLinkIdentifier().values().stream().findAny().get().getLinkId()); + genSoftConstraints.getExclude().getLinkIdentifier().stream().findAny().orElseThrow().getLinkId()); assertEquals("openroadm-topology", - genSoftConstraints.getExclude().getLinkIdentifier().values().stream().findAny().get().getLinkNetworkId()); - assertNotNull("generated soft constraints should contain include constraint", genSoftConstraints.getInclude()); - assertEquals("generated soft constraints should contain include constraint with two node-id", - 2, genSoftConstraints.getInclude().getNodeId().size()); + genSoftConstraints.getExclude().getLinkIdentifier().stream().findAny().orElseThrow() + .getLinkNetworkId()); + assertNotNull(genSoftConstraints.getInclude(), "generated soft constraints should contain include constraint"); + assertEquals(2, genSoftConstraints.getInclude().getNodeId().size(), + "generated soft constraints should contain include constraint with two node-id"); assertTrue(genSoftConstraints.getInclude().getNodeId().contains(new NodeIdType("node-id-1"))); assertTrue(genSoftConstraints.getInclude().getNodeId().contains(new NodeIdType("node-id-3"))); - assertNull("generated soft constraints should not contain any latency constraint", - genSoftConstraints.getLatency()); - assertNull("generated soft constraints should not contain any max-distance constraint", - genSoftConstraints.getDistance()); - assertNull("generated soft constraints should not contain any co-routing constraint", - genSoftConstraints.getCoRouting()); + assertNull(genSoftConstraints.getLatency(), + "generated soft constraints should not contain any latency constraint"); + assertNull(genSoftConstraints.getDistance(), + "generated soft constraints should not contain any max-distance constraint"); + assertNull(genSoftConstraints.getCoRouting(), + "generated soft constraints should not contain any co-routing constraint"); } }