diff options
author | liamfallon <liam.fallon@est.tech> | 2021-10-06 18:45:12 +0100 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2021-10-06 18:45:16 +0100 |
commit | 5d153a24a94a2a0d04bca8f0dbf0e0fc714827a7 (patch) | |
tree | b1a79b02cd6ad4ce6f2c74ab319f30e9bb3f2f8b /models-tosca/src/test/java/org | |
parent | 72f56e3460484a922f0bd19b9ef3eda868b34f6c (diff) |
Support in_range TOSCA Constraint
The TOSCA in_range constraint is not supported, causing errors to be
thrown in TOSCA control loop constraint edits.
Issue-ID: POLICY-3695
Change-Id: I95dec4118ce8572c5b76d528878c6782856e0a53
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-tosca/src/test/java/org')
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintTest.java | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintTest.java index 6ff225425..6c39737f1 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -53,6 +53,9 @@ public class JpaToscaConstraintTest { assertThatThrownBy(() -> new JpaToscaConstraintLogical(JpaToscaConstraintOperation.EQ, null)) .hasMessageMatching("compareTo is marked .*on.*ull but is null"); + assertThatThrownBy(() -> new JpaToscaConstraintInRange((List<String>) null)) + .hasMessageMatching("rangeValues is marked .*on.*ull but is null"); + assertNotNull(new JpaToscaConstraintLogical(JpaToscaConstraintOperation.EQ, CONSTRAINT)); assertEquals(0, new JpaToscaConstraintLogical(JpaToscaConstraintOperation.EQ, "") @@ -73,5 +76,26 @@ public class JpaToscaConstraintTest { cvv1.fromAuthorative(new ToscaConstraint()); assertNotNull(cvv1.getValidValues()); + + List<String> rangeValues = new ArrayList<>(); + rangeValues.add("hello"); + rangeValues.add("goodbye"); + JpaToscaConstraintInRange cir0 = new JpaToscaConstraintInRange(rangeValues); + assertEquals(-1, cir0.compareTo(null)); + assertEquals(0, cir0.compareTo(cir0)); + assertNotEquals(0, cir0.compareTo(new JpaToscaConstraintLogical(JpaToscaConstraintOperation.EQ, CONSTRAINT))); + JpaToscaConstraintInRange cir1 = new JpaToscaConstraintInRange(rangeValues); + assertEquals(0, cir0.compareTo(cir1)); + + ToscaConstraint tc0 = new ToscaConstraint(); + tc0.setRangeValues(rangeValues); + JpaToscaConstraintInRange cir2 = new JpaToscaConstraintInRange(tc0); + assertEquals(0, cir0.compareTo(cir2)); + + cir1.fromAuthorative(new ToscaConstraint()); + assertNotNull(cir1.getRangeValues()); + + ToscaConstraint tc1 = cir2.toAuthorative(); + assertEquals(tc0, tc1); } } |