From: liamfallon Date: Fri, 20 Nov 2020 10:24:44 +0000 (+0000) Subject: Add extra authorative TOSCA concepts X-Git-Tag: 2.4.0~46^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=950cbb8872fb2227f4a0382a756a7e1dff53b09c;hp=1dd41890f83702d47c5a957493046433989ef36c;p=policy%2Fmodels.git Add extra authorative TOSCA concepts This review brings in extra TOSCA concepts for Node types, nodes, and capabilities. The TOSCA handling is also amended to make the handling of equality consistent. Now, if filtering or ordering is required using an order rather than natural ordering, a comparator must be supplied by the user. Issue-ID: POLICY-2900 Change-Id: Ie40e86870b97eb993b1338bdc0666ac116f72f67 Signed-off-by: liamfallon --- diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptComparator.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptComparator.java new file mode 100644 index 000000000..36bff5fbc --- /dev/null +++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptComparator.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.base; + +import java.util.Comparator; + +/** + * Compare two PfNameVersion objects. + */ +public class PfConceptComparator implements Comparator { + + @Override + public int compare(PfConcept left, PfConcept right) { + return left.getKey().compareTo(right.getKey()); + } +} diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptFilter.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptFilter.java index 8cebcdb40..df6141b9b 100644 --- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptFilter.java +++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptFilter.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -58,7 +58,7 @@ public class PfConceptFilter implements PfObjectFilter { // @formatter:off if (LATEST_VERSION.equals(version)) { - return this.latestVersionFilter(returnList); + return this.latestVersionFilter(returnList, new PfConceptComparator()); } else { return returnList; } diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfNameVersion.java b/models-base/src/main/java/org/onap/policy/models/base/PfNameVersion.java index 7bdced77b..f9fde53e5 100644 --- a/models-base/src/main/java/org/onap/policy/models/base/PfNameVersion.java +++ b/models-base/src/main/java/org/onap/policy/models/base/PfNameVersion.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ public interface PfNameVersion { public void setVersion(final String version); /** - * COmpare two name version implementation objects. + * Compare two name version implementation objects. * * @param left the left name/version implementation * @param right the right name/version implementation diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java b/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java index f4e457192..f7e29f1b4 100644 --- a/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java +++ b/models-base/src/main/java/org/onap/policy/models/base/PfObjectFilter.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,6 +23,7 @@ package org.onap.policy.models.base; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.function.Function; import java.util.function.Predicate; @@ -34,7 +35,7 @@ import java.util.regex.Pattern; * @author Liam Fallon (liam.fallon@est.tech) */ @FunctionalInterface -public interface PfObjectFilter> { +public interface PfObjectFilter { /** * Filter an incoming list, removing items that do not match the filter. * @@ -118,15 +119,16 @@ public interface PfObjectFilter> { * Sort an incoming list and remove all but the latest version of each concept. * * @param originalList the incoming list + * @param versionComparator the comparator to use to order versions of the incoming object * @return the filtered list */ - public default List latestVersionFilter(final List originalList) { + public default List latestVersionFilter(final List originalList, final Comparator versionComparator) { if (originalList.size() <= 1) { return originalList; } List filteredList = new ArrayList<>(originalList); - Collections.sort(filteredList); + Collections.sort(filteredList, versionComparator); int icur = 0; for (int j = 1; j < filteredList.size(); j++) { diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfConceptComparatorTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfConceptComparatorTest.java new file mode 100644 index 000000000..ea0762711 --- /dev/null +++ b/models-base/src/test/java/org/onap/policy/models/base/PfConceptComparatorTest.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.base; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.policy.models.base.testconcepts.DummyBadPfConcept; +import org.onap.policy.models.base.testconcepts.DummyPfConcept; + +public class PfConceptComparatorTest { + + @Test + public void testPfConceptComparator() { + assertEquals(0, new PfConceptComparator().compare(new DummyPfConcept(), new DummyPfConcept())); + } +} diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfConceptFilterTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfConceptFilterTest.java index 424293f78..6d02b2fdd 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/PfConceptFilterTest.java +++ b/models-base/src/test/java/org/onap/policy/models/base/PfConceptFilterTest.java @@ -21,6 +21,7 @@ package org.onap.policy.models.base; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.ArrayList; @@ -50,5 +51,14 @@ public class PfConceptFilterTest { final PfConceptFilter conceptFilterNull = new PfConceptFilter(null, null, null); conceptFilterNull.filter(null); }).hasMessageMatching("^originalList is marked .*on.*ull but is null$"); + + conceptFilter.setName("hello"); + assertEquals("hello", conceptFilter.getName()); + + conceptFilter.setVersion("1.2.3"); + assertEquals("1.2.3", conceptFilter.getVersion()); + + conceptFilter.setVersionPrefix("AAA"); + assertEquals("AAA", conceptFilter.getVersionPrefix()); } } diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java index 7bf270b5f..8b94a48c3 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java +++ b/models-base/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java @@ -145,6 +145,12 @@ public class PfKeyImplTest { MyKey someKey8 = new MyKey(); someKey8.setVersion(VERSION001); assertFalse(someKey8.isNullKey()); + + someKey8.setVersion("10"); + assertEquals(0, someKey8.getMinorVersion()); + + someKey8.setVersion("10.11"); + assertEquals(0, someKey8.getPatchVersion()); } @Test diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java index 2e742c336..5cebf1e91 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java +++ b/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java @@ -22,6 +22,7 @@ package org.onap.policy.models.base; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import javax.ws.rs.core.Response; import org.junit.Test; @@ -39,10 +40,12 @@ public class PfModelExceptionInfoTest { final PfModelException pfme = new PfModelException(Response.Status.ACCEPTED, "HELLO"); assertThat(pfme).hasMessage("HELLO"); assertEquals("Server returned: Accepted", getErrorMessage(pfme).substring(0, 25)); + assertNotNull(pfme.toString()); final PfModelRuntimeException pfmr = new PfModelRuntimeException(Response.Status.ACCEPTED, "HELLO"); assertThat(pfmr).hasMessage("HELLO"); assertEquals("Server returned: Accepted", getErrorMessage(pfmr).substring(0, 25)); + assertNotNull(pfmr.toString()); } private String getErrorMessage(final ErrorResponseInfo eri) { diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfNameVersionTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfNameVersionTest.java index 7152b12f1..2937b60ab 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/PfNameVersionTest.java +++ b/models-base/src/test/java/org/onap/policy/models/base/PfNameVersionTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,6 +57,9 @@ public class PfNameVersionTest { dnv0.setVersion("1.2.3"); assertEquals(-1, dnv0.compareNameVersion(dnv0, dnv1)); + dnv1.setVersion(null); + assertEquals(-1, dnv0.compareNameVersion(dnv0, dnv1)); + dnv1.setVersion("1.2.3"); assertEquals(0, dnv0.compareNameVersion(dnv0, dnv1)); } diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfObjectFilterTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfObjectFilterTest.java index d6985e949..59d7ad70e 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/PfObjectFilterTest.java +++ b/models-base/src/test/java/org/onap/policy/models/base/PfObjectFilterTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,12 +26,14 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Predicate; import org.junit.Test; import org.onap.policy.models.base.testconcepts.DummyPfObject; +import org.onap.policy.models.base.testconcepts.DummyPfObjectComparator; import org.onap.policy.models.base.testconcepts.DummyPfObjectFilter; /** @@ -96,7 +98,7 @@ public class PfObjectFilterTest { assertEquals(true, dof.filterString(HELLO, HELLO)); assertEquals(true, dof.filterString(HELLO, null)); - List latestVersionList = dof.latestVersionFilter(doList); + List latestVersionList = dof.latestVersionFilter(doList, new DummyPfObjectComparator()); assertEquals(3, latestVersionList.size()); assertEquals("aaaaa", latestVersionList.get(0).getName()); assertEquals(VERSION002, latestVersionList.get(0).getVersion()); @@ -107,7 +109,8 @@ public class PfObjectFilterTest { latestVersionList.remove(2); latestVersionList.remove(1); - List newestVersionList = dof.latestVersionFilter(latestVersionList); + List newestVersionList = dof.latestVersionFilter(latestVersionList, + new DummyPfObjectComparator()); assertEquals(latestVersionList, newestVersionList); MyFilter filter = new MyFilter(); diff --git a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfObject.java b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfObject.java index 53009ddc8..9759f4aef 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfObject.java +++ b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfObject.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,21 +33,8 @@ import org.onap.policy.models.base.PfNameVersion; */ @Data @RequiredArgsConstructor -public class DummyPfObject implements PfNameVersion, Comparable { +public class DummyPfObject implements PfNameVersion { private String name; private String version; private String description; - - @Override - public int compareTo(@NonNull final DummyPfObject otherObject) { - int result = ObjectUtils.compare(this.name, otherObject.name); - if (result != 0) { - return result; - } - result = ObjectUtils.compare(this.version, otherObject.version); - if (result != 0) { - return result; - } - return ObjectUtils.compare(this.description, otherObject.description); - } } diff --git a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfObjectComparator.java b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfObjectComparator.java new file mode 100644 index 000000000..f83bce6a6 --- /dev/null +++ b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfObjectComparator.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.base.testconcepts; + +import java.util.Comparator; +import org.onap.policy.models.base.PfNameVersion; + +/** + * Compare two PfNameVersion objects. + */ +public class DummyPfObjectComparator implements Comparator { + + @Override + public int compare(final DummyPfObject left, final DummyPfObject right) { + return left.compareNameVersion(left, right); + } +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaCapabilityAssignment.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaCapabilityAssignment.java new file mode 100644 index 000000000..207f07a8f --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaCapabilityAssignment.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.authorative.concepts; + +import java.util.List; +import java.util.Map; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class ToscaCapabilityAssignment extends ToscaEntity { + private Map properties; + private Map attributes; + private List occurrences; +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaCapabilityType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaCapabilityType.java new file mode 100644 index 000000000..dd8fb05f4 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaCapabilityType.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Model + * ================================================================================ + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.authorative.concepts; + +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class ToscaCapabilityType extends ToscaEntity { + private Map properties; +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConstraint.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConstraint.java index 582b73cc6..33235a45a 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConstraint.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaConstraint.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,6 @@ import lombok.Data; */ @Data public class ToscaConstraint { - @ApiModelProperty(name = "valid_values") @SerializedName("valid_values") private List validValues; @@ -57,5 +56,4 @@ public class ToscaConstraint { @ApiModelProperty(name = "less_or_equal") @SerializedName("less_or_equal") private String lessOrEqual; - } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaDataType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaDataType.java index b07163b6e..6ea8804ca 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaDataType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaDataType.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java index b242bff65..10d3b7a14 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java @@ -44,7 +44,6 @@ import org.onap.policy.models.base.PfNameVersion; @NoArgsConstructor public class ToscaEntity implements PfNameVersion { private String name; - private String version; @ApiModelProperty(name = "derived_from") @@ -52,7 +51,6 @@ public class ToscaEntity implements PfNameVersion { private String derivedFrom; private Map metadata; - private String description; /** diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeTemplate.java new file mode 100644 index 000000000..343eb8e2c --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeTemplate.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Model + * ================================================================================ + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.authorative.concepts; + +import java.util.List; +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class ToscaNodeTemplate extends ToscaEntity { + private String type; + private Map properties; + private List> requirements; + private Map capabilities; +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeType.java new file mode 100644 index 000000000..5a4c94126 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaNodeType.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Model + * ================================================================================ + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.authorative.concepts; + +import java.util.List; +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class ToscaNodeType extends ToscaEntity { + private Map properties; + private List> requirements; +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaParameter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaParameter.java new file mode 100644 index 000000000..290bdacfe --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaParameter.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Model + * ================================================================================ + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.authorative.concepts; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class ToscaParameter { + private String name; + private String type; + + @ApiModelProperty(name = "type_version") + @SerializedName("type_version") + + private String typeVersion; + private Object value; +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicy.java index 27d4eb2e7..c98a844e5 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicy.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicy.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ import lombok.ToString; @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @ToString(callSuper = true) -public class ToscaPolicy extends ToscaEntity implements Comparable { +public class ToscaPolicy extends ToscaEntity { private String type; @ApiModelProperty(name = "type_version") @@ -88,9 +88,4 @@ public class ToscaPolicy extends ToscaEntity implements Comparable public ToscaPolicyTypeIdentifier getTypeIdentifier() { return new ToscaPolicyTypeIdentifier(getType(), getTypeVersion()); } - - @Override - public int compareTo(final ToscaPolicy other) { - return compareNameVersion(this, other); - } } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyComparator.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyComparator.java new file mode 100644 index 000000000..8bbe70db2 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyComparator.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.authorative.concepts; + +import java.util.Comparator; + +/** + * Compare two ToscaPolicy objects. + */ +public class ToscaPolicyComparator implements Comparator { + + @Override + public int compare(final ToscaPolicy left, final ToscaPolicy right) { + return left.compareNameVersion(left, right); + } +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java index 33170db18..86c2e6f3e 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -67,7 +67,7 @@ public class ToscaPolicyFilter implements PfObjectFilter { // @formatter:off if (LATEST_VERSION.equals(version)) { - return this.latestVersionFilter(returnList); + return this.latestVersionFilter(returnList, new ToscaPolicyComparator()); } else { return returnList; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java index 43e7114be..29bff911f 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java @@ -22,6 +22,7 @@ package org.onap.policy.models.tosca.authorative.concepts; import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.NoArgsConstructor; import lombok.NonNull; @@ -35,9 +36,11 @@ import org.apache.commons.lang3.ObjectUtils; public class ToscaPolicyIdentifierOptVersion implements Comparable { @NonNull + @ApiModelProperty(name = "policy-id") @SerializedName("policy-id") private String name; + @ApiModelProperty(name = "policy-version") @SerializedName("policy-version") private String version; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyType.java index f948eda38..af8f5fa90 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyType.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ import lombok.NonNull; @Data @EqualsAndHashCode(callSuper = true) @NoArgsConstructor -public class ToscaPolicyType extends ToscaEntity implements Comparable { +public class ToscaPolicyType extends ToscaEntity { private Map properties; /** @@ -57,9 +57,4 @@ public class ToscaPolicyType extends ToscaEntity implements Comparable { + + @Override + public int compare(final ToscaPolicyType left, final ToscaPolicyType right) { + return left.compareNameVersion(left, right); + } +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java index da6c561ce..4e9810b98 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ public class ToscaPolicyTypeFilter implements PfObjectFilter { // @formatter:off if (LATEST_VERSION.equals(version)) { - return this.latestVersionFilter(returnList); + return this.latestVersionFilter(returnList, new ToscaPolicyTypeComparator()); } else { return returnList; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaProperty.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaProperty.java index 59fbc8b22..0bd0d44e8 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaProperty.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaProperty.java @@ -41,9 +41,10 @@ public class ToscaProperty { } private String name; - private String type; + @ApiModelProperty(name = "type_version") + @SerializedName("type_version") private String typeVersion; private String description; @@ -53,14 +54,16 @@ public class ToscaProperty { private Object defaultValue; private boolean required = false; - private Status status; - private List constraints; + @ApiModelProperty(name = "key_schema") + @SerializedName("key_schema") + private ToscaSchemaDefinition keySchema; + @ApiModelProperty(name = "entry_schema") @SerializedName("entry_schema") - private ToscaEntrySchema entrySchema; + private ToscaSchemaDefinition entrySchema; private Map metadata; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaRelationshipType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaRelationshipType.java new file mode 100644 index 000000000..9e43d8954 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaRelationshipType.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP Policy Model + * ================================================================================ + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.authorative.concepts; + +import java.util.Map; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@EqualsAndHashCode(callSuper = true) +@NoArgsConstructor +public class ToscaRelationshipType extends ToscaEntity { + private Map properties; +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaRequirement.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaRequirement.java new file mode 100644 index 000000000..34dbb4f82 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaRequirement.java @@ -0,0 +1,34 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.authorative.concepts; + +import java.util.List; +import java.util.Map; +import lombok.Data; + +@Data +public class ToscaRequirement extends ToscaEntity { + private String capability; + private String node; + private String relationship; + private List occurrences; + private Map properties; +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntrySchema.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaSchemaDefinition.java similarity index 83% rename from models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntrySchema.java rename to models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaSchemaDefinition.java index 352dfa7fa..758711c98 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntrySchema.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaSchemaDefinition.java @@ -23,23 +23,25 @@ package org.onap.policy.models.tosca.authorative.concepts; +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; import java.util.List; import lombok.Data; /** - * Class to represent TOSCA entry schema matching input/output from/to client. + * Class to represent TOSCA schema matching input/output from/to client. * * @author Chenfei Gao (cgao@research.att.com) */ @Data -public class ToscaEntrySchema { +public class ToscaSchemaDefinition { private String name; - private String type; + @ApiModelProperty(name = "type_version") + @SerializedName("type_version") private String typeVersion; private String description; - private List constraints; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplate.java index 17391964e..e83d173de 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplate.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaServiceTemplate.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,28 +37,39 @@ import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = true) public class ToscaServiceTemplate extends ToscaEntity { - @ApiModelProperty(name = "tosca_definitions_version") @SerializedName("tosca_definitions_version") private String toscaDefinitionsVersion; - @ApiModelProperty(name = "topology_template") - @SerializedName("topology_template") - private ToscaTopologyTemplate toscaTopologyTemplate; + @ApiModelProperty(name = "data_types") + @SerializedName("data_types") + private Map dataTypes; + + @ApiModelProperty(name = "capability_types") + @SerializedName("capability_types") + private Map capabilityTypes; + + @ApiModelProperty(name = "node_types") + @SerializedName("node_types") + private Map nodeTypes; + + @ApiModelProperty(name = "relationship_types") + @SerializedName("relationship_types") + private Map relationshipTypes; @ApiModelProperty(name = "policy_types") @SerializedName("policy_types") private Map policyTypes; - @ApiModelProperty(name = "data_types") - @SerializedName("data_types") - private Map dataTypes; - - public Map getPolicyTypesAsMap() { - return ToscaEntity.getEntityMapAsMap(policyTypes); - } + @ApiModelProperty(name = "topology_template") + @SerializedName("topology_template") + private ToscaTopologyTemplate toscaTopologyTemplate; public Map getDataTypesAsMap() { return ToscaEntity.getEntityMapAsMap(dataTypes); } -} \ No newline at end of file + + public Map getPolicyTypesAsMap() { + return ToscaEntity.getEntityMapAsMap(policyTypes); + } +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplate.java index 74ebf07e0..a243b1688 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplate.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTopologyTemplate.java @@ -3,6 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +23,8 @@ package org.onap.policy.models.tosca.authorative.concepts; +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; import java.util.List; import java.util.Map; import lombok.Data; @@ -33,9 +36,14 @@ import lombok.Data; */ @Data public class ToscaTopologyTemplate { - private String description; + private Map inputs; + + @ApiModelProperty(name = "node_templates") + @SerializedName("node_templates") + private Map nodeTemplates; + private List> policies; public Map getPoliciesAsMap() { diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/package-info.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/package-info.java index 1db09b863..f100c89c3 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/package-info.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/package-info.java @@ -27,4 +27,4 @@ * @author Chenfei Gao (cgao@research.att.com) * */ -package org.onap.policy.models.tosca.authorative.concepts; \ No newline at end of file +package org.onap.policy.models.tosca.authorative.concepts; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntrySchema.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntrySchema.java index b697d5100..ef6aa7e92 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntrySchema.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntrySchema.java @@ -42,7 +42,7 @@ import org.onap.policy.models.base.PfValidationMessage; import org.onap.policy.models.base.PfValidationResult; import org.onap.policy.models.base.PfValidationResult.ValidationResult; import org.onap.policy.models.tosca.authorative.concepts.ToscaConstraint; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntrySchema; +import org.onap.policy.models.tosca.authorative.concepts.ToscaSchemaDefinition; /** * Class to represent the EntrySchema of list/map property in TOSCA definition. @@ -54,7 +54,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaEntrySchema; @EqualsAndHashCode(callSuper = false) @NoArgsConstructor public class JpaToscaEntrySchema - implements PfAuthorative, Serializable, Comparable { + implements PfAuthorative, Serializable, Comparable { private static final long serialVersionUID = 3645882081163287058L; @@ -93,13 +93,13 @@ public class JpaToscaEntrySchema * * @param authorativeConcept the authorative concept to copy from */ - public JpaToscaEntrySchema(final ToscaEntrySchema authorativeConcept) { + public JpaToscaEntrySchema(final ToscaSchemaDefinition authorativeConcept) { this.fromAuthorative(authorativeConcept); } @Override - public ToscaEntrySchema toAuthorative() { - ToscaEntrySchema toscaEntrySchema = new ToscaEntrySchema(); + public ToscaSchemaDefinition toAuthorative() { + ToscaSchemaDefinition toscaEntrySchema = new ToscaSchemaDefinition(); toscaEntrySchema.setType(type.getName()); toscaEntrySchema.setTypeVersion(type.getVersion()); @@ -120,7 +120,7 @@ public class JpaToscaEntrySchema } @Override - public void fromAuthorative(final ToscaEntrySchema toscaEntrySchema) { + public void fromAuthorative(final ToscaSchemaDefinition toscaEntrySchema) { if (toscaEntrySchema.getTypeVersion() != null) { type = new PfConceptKey(toscaEntrySchema.getType(), toscaEntrySchema.getTypeVersion()); } else { diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java index faafa8c60..9fd559392 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTest.java @@ -56,11 +56,11 @@ public class ToscaPolicyTest { assertEquals("3.2.1", type.getVersion()); ToscaPolicy clonedPolicy0 = new ToscaPolicy(policy); - assertEquals(0, policy.compareTo(clonedPolicy0)); + assertEquals(0, new ToscaPolicyComparator().compare(policy, clonedPolicy0)); policy.setProperties(new LinkedHashMap()); policy.getProperties().put("PropertyKey", "PropertyValue"); ToscaPolicy clonedPolicy1 = new ToscaPolicy(policy); - assertEquals(0, policy.compareTo(clonedPolicy1)); + assertEquals(0, new ToscaPolicyComparator().compare(policy, clonedPolicy1)); } } diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeTest.java index fc9c69319..75c6b51e3 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeTest.java @@ -46,7 +46,7 @@ public class ToscaPolicyTypeTest { tpt.setDescription("Desc"); ToscaPolicyType clonedTpt0 = new ToscaPolicyType(tpt); - assertEquals(0, tpt.compareTo(clonedTpt0)); + assertEquals(0, new ToscaPolicyTypeComparator().compare(tpt, clonedTpt0)); tpt.setMetadata(new LinkedHashMap<>()); tpt.setProperties(new LinkedHashMap<>()); @@ -57,6 +57,6 @@ public class ToscaPolicyTypeTest { tpt.getProperties().put("Property0", tp); ToscaPolicyType clonedTpt1 = new ToscaPolicyType(tpt); - assertEquals(0, tpt.compareTo(clonedTpt1)); + assertEquals(0, new ToscaPolicyTypeComparator().compare(tpt, clonedTpt1)); } }