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;
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);
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<String> softCustomerCode = Set.of("soft-customer-code 3", "soft-customer-code 4");
initialSoftConstraints =
buildSoftConstraint(softCustomerCode, false, null, null, null, null, false, false, 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 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(),
}
@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<String> softDiversityServiceid = Set.of("soft-service 3");
initialSoftConstraints =
buildSoftConstraint(null, false, softDiversityServiceid, null, null, null, false, false, 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 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 =
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(),
}
@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 =
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
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
}
@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 =
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
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
}
@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 =
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
.routing.ServiceIdentifierListKey("service 1"))
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
.routing.ServiceIdentifierListKey("service 3"))
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
}
@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<String> 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().values().size(),
+ "generated soft constraints should contain exclude constraint with one link-id");
assertEquals("link-id 1",
genSoftConstraints.getExclude().getLinkIdentifier().values().stream().findAny().get().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());
+ 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");
}
}