2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.models.tosca.simple.concepts;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotEquals;
25 import static org.junit.Assert.assertNull;
27 import java.util.ArrayList;
29 import org.junit.Test;
30 import org.onap.policy.models.tosca.authorative.concepts.ToscaConstraint;
33 * Test the {@link JpaToscaConstraintLogical} class.
35 * @author Liam Fallon (liam.fallon@est.tech)
37 public class JpaToscaConstraintLogicalTest {
40 public void testLogicalConstraint() {
41 ToscaConstraint c0 = new ToscaConstraint();
43 JpaToscaConstraintLogical jc0 = new JpaToscaConstraintLogical(c0);
44 assertEquals(c0, jc0.toAuthorative());
46 ToscaConstraint c1 = new ToscaConstraint();
47 c1.setGreaterOrEqual("Hello");
48 JpaToscaConstraintLogical jc1 = new JpaToscaConstraintLogical(c1);
49 assertEquals(c1, jc1.toAuthorative());
51 ToscaConstraint c2 = new ToscaConstraint();
52 c2.setGreaterThan("Hello");
53 JpaToscaConstraintLogical jc2 = new JpaToscaConstraintLogical(c2);
54 assertEquals(c2, jc2.toAuthorative());
56 ToscaConstraint c3 = new ToscaConstraint();
57 c3.setLessOrEqual("Hello");
58 JpaToscaConstraintLogical jc3 = new JpaToscaConstraintLogical(c3);
59 assertEquals(c3, jc3.toAuthorative());
61 ToscaConstraint c4 = new ToscaConstraint();
62 c4.setLessThan("Hello");
63 JpaToscaConstraintLogical jc4 = new JpaToscaConstraintLogical(c4);
64 assertEquals(c4, jc4.toAuthorative());
66 ToscaConstraint c5 = new ToscaConstraint();
67 JpaToscaConstraintLogical jc5 = new JpaToscaConstraintLogical(c5);
68 assertNull(jc5.toAuthorative());
70 assertEquals(-1, jc0.compareTo(null));
71 assertEquals(0, jc0.compareTo(jc0));
72 assertNotEquals(0, jc0.compareTo(new JpaToscaConstraintValidValues(new ArrayList<>())));
73 assertEquals(-2, jc0.compareTo(jc1));