From 5d153a24a94a2a0d04bca8f0dbf0e0fc714827a7 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Wed, 6 Oct 2021 18:45:12 +0100 Subject: 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 --- .../simple/concepts/JpaToscaConstraintTest.java | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'models-tosca/src/test/java/org/onap') 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) 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 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); } } -- cgit 1.2.3-korg