import static org.opendaylight.transportpce.servicehandler.utils.ConstraintsUtils.buildHardConstraint;
import static org.opendaylight.transportpce.servicehandler.utils.ConstraintsUtils.buildSoftConstraint;
-import java.util.Arrays;
-import java.util.List;
+import java.util.Set;
import org.hamcrest.collection.IsMapContaining;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev210528.NodeIdType;
initialHardConstraints, initialSoftConstraints);
assertNull("updated soft constraints should contain no customer code",
generatedSoftConstraints.getCustomerCode());
- List<String> softCustomerCode = Arrays.asList("soft-customer-code 3", "soft-customer-code 4");
+ 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);
generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints(
assertEquals(initialSoftConstraints.getCustomerCode(), generatedSoftConstraints.getCustomerCode());
// test addition of hard customer-code when no soft customer-code
- List<String> hardCustomerCode = Arrays.asList("hard-customer-code 1", "hard-customer-code 2");
+ Set<String> hardCustomerCode = Set.of("hard-customer-code 1", "hard-customer-code 2");
initialHardConstraints =
buildHardConstraint(hardCustomerCode, false, null, null, null, null, false, false, null, null);
initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null);
initialHardConstraints, initialSoftConstraints);
assertNull("updated soft constraints should contain no diversity constraint",
generatedSoftConstraints.getDiversity());
- List<String> softDiversityServiceid = Arrays.asList("soft-service 3");
+ Set<String> softDiversityServiceid = Set.of("soft-service 3");
initialSoftConstraints =
buildSoftConstraint(null, false, softDiversityServiceid, null, null, null, false, false, null, null);
generatedSoftConstraints = DowngradeConstraints.updateSoftConstraints(
assertEquals(initialSoftConstraints.getDiversity(), generatedSoftConstraints.getDiversity());
// test addition of hard diversity when no soft diversity
- List<String> hardDiversityServiceid = Arrays.asList("hard-service 1", "hard-service 2");
+ Set<String> hardDiversityServiceid = Set.of("hard-service 1", "hard-service 2");
initialHardConstraints =
buildHardConstraint(null, false, hardDiversityServiceid, null, null, null, false, false, null, null);
initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, false, false, null, null);
}
@Test
- public void testUpdateSoftConstraintsForHopCount() {
+ public void testUpdateSoftConstraintsForHopCountAndTEmetric() {
HardConstraints initialHardConstraints =
buildHardConstraint(null, false, null, null, null, null, false, false, null, null);
SoftConstraints initialSoftConstraints =
assertNull("updated soft constraints should contain no hop-count constraint",
generatedSoftConstraints.getHopCount());
- initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, true, false, null, null);
+ 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",
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());
// test addition of hard hop-count when no soft hop-count
- initialHardConstraints = buildHardConstraint(null, false, null, null, null, null, true, false, null, null);
+ 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);
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());
// test addition of hard hop-count when existing soft hop-count
- initialSoftConstraints = buildSoftConstraint(null, false, null, null, null, null, true, false, null, null);
+ 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());
}
@Test
assertNull("generated soft constraints should be empty", genSoftConstraints.getCoRouting());
assertNull("generated soft constraints should be empty", genSoftConstraints.getLatency());
- List<String> hardCustomerCode = Arrays.asList("customer-code 1", "customer-code 2");
+ 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);