From 938005505883cf7a636a8840e20e3dc8a0ad9176 Mon Sep 17 00:00:00 2001 From: "adheli.tavares" Date: Thu, 27 Jul 2023 10:12:59 +0100 Subject: Java 17 Upgrade Issue-ID: POLICY-4669 Change-Id: I0157ae0ea7151658308c7e6d429098f16824c190 Signed-off-by: adheli.tavares --- .../tosca/authorative/concepts/ToscaEntity.java | 4 +- .../provider/AuthorativeToscaProvider.java | 10 +-- .../concepts/JpaToscaCapabilityAssignment.java | 16 ++-- .../concepts/JpaToscaCapabilityAssignments.java | 14 ++-- .../simple/concepts/JpaToscaCapabilityType.java | 12 +-- .../simple/concepts/JpaToscaCapabilityTypes.java | 14 ++-- .../simple/concepts/JpaToscaConstraintInRange.java | 11 ++- .../simple/concepts/JpaToscaConstraintLogical.java | 41 +++------ .../concepts/JpaToscaConstraintValidValues.java | 11 ++- .../tosca/simple/concepts/JpaToscaDataType.java | 14 ++-- .../tosca/simple/concepts/JpaToscaDataTypes.java | 17 ++-- .../tosca/simple/concepts/JpaToscaEntityType.java | 25 +++--- .../tosca/simple/concepts/JpaToscaEventFilter.java | 16 ++-- .../tosca/simple/concepts/JpaToscaModel.java | 28 +++---- .../simple/concepts/JpaToscaNodeTemplate.java | 35 ++++---- .../simple/concepts/JpaToscaNodeTemplates.java | 17 ++-- .../tosca/simple/concepts/JpaToscaNodeType.java | 27 +++--- .../tosca/simple/concepts/JpaToscaNodeTypes.java | 17 ++-- .../tosca/simple/concepts/JpaToscaParameter.java | 6 +- .../tosca/simple/concepts/JpaToscaPolicies.java | 15 ++-- .../tosca/simple/concepts/JpaToscaPolicy.java | 22 ++--- .../tosca/simple/concepts/JpaToscaPolicyType.java | 20 +++-- .../tosca/simple/concepts/JpaToscaPolicyTypes.java | 17 ++-- .../tosca/simple/concepts/JpaToscaProperty.java | 15 ++-- .../simple/concepts/JpaToscaRelationshipType.java | 12 +-- .../simple/concepts/JpaToscaRelationshipTypes.java | 17 ++-- .../tosca/simple/concepts/JpaToscaRequirement.java | 16 ++-- .../simple/concepts/JpaToscaRequirements.java | 17 ++-- .../simple/concepts/JpaToscaSchemaDefinition.java | 14 ++-- .../simple/concepts/JpaToscaServiceTemplate.java | 95 ++++++++++----------- .../simple/concepts/JpaToscaServiceTemplates.java | 10 +-- .../simple/concepts/JpaToscaTimeInterval.java | 14 ++-- .../simple/concepts/JpaToscaTopologyTemplate.java | 49 +++++------ .../tosca/simple/concepts/JpaToscaTrigger.java | 6 +- .../concepts/JpaToscaWithToscaProperties.java | 9 +- .../JpaToscaWithTypeAndStringProperties.java | 23 +++--- .../tosca/simple/provider/SimpleToscaProvider.java | 6 +- .../SimpleToscaServiceTemplateProvider.java | 4 +- .../tosca/utils/ToscaServiceTemplateUtils.java | 4 +- .../onap/policy/models/tosca/utils/ToscaUtils.java | 4 +- .../concepts/JpaToscaConstraintLogicalTest.java | 5 +- .../simple/concepts/JpaToscaConstraintTest.java | 6 +- .../simple/concepts/JpaToscaPropertyTest.java | 4 +- .../concepts/JpaToscaServiceTemplateTest.java | 96 +++++++++++++--------- 44 files changed, 428 insertions(+), 407 deletions(-) (limited to 'models-tosca/src') 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 24c74cbaa..d5c098a2e 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP Policy Model * ================================================================================ - * Copyright (C) 2019-2022 Nordix Foundation. + * Copyright (C) 2019-2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,11 +23,11 @@ package org.onap.policy.models.tosca.authorative.concepts; import com.google.gson.annotations.SerializedName; +import jakarta.ws.rs.core.Response; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import javax.ws.rs.core.Response; import lombok.Data; import lombok.NoArgsConstructor; import lombok.NonNull; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java index b3284d987..35971563f 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2022 Nordix Foundation. + * Copyright (C) 2019-2023 Nordix Foundation. * Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,12 +21,12 @@ package org.onap.policy.models.tosca.authorative.provider; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; import lombok.NonNull; import org.apache.commons.collections4.CollectionUtils; import org.onap.policy.models.base.PfConceptKey; @@ -678,9 +678,7 @@ public class AuthorativeToscaProvider { private List asConceptList(final List> listOfMaps) { List returnList = new ArrayList<>(); for (Map conceptMap : listOfMaps) { - for (T concept : conceptMap.values()) { - returnList.add(concept); - } + returnList.addAll(conceptMap.values()); } return returnList; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignment.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignment.java index 3e0ec281b..7fb741d27 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignment.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignment.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020-2021 Nordix Foundation. + * Copyright (C) 2020-2021, 2023 Nordix Foundation. * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,16 +21,17 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.Lob; +import jakarta.persistence.Table; +import java.io.Serial; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Lob; -import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -52,6 +53,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityAssignme @EqualsAndHashCode(callSuper = false) public class JpaToscaCapabilityAssignment extends JpaToscaWithTypeAndStringProperties { + @Serial private static final long serialVersionUID = 1675770231921107988L; private static final String AUTHORATIVE_UNBOUNDED_LITERAL = "UNBOUNDED"; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignments.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignments.java index 18e77bbf1..bc531017a 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignments.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityAssignments.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * Copyright (C) 2020, 2023 Nordix Foundation. * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,13 +21,14 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.Table; +import java.io.Serial; import java.util.List; import java.util.Map; import java.util.TreeMap; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -55,6 +56,7 @@ public class JpaToscaCapabilityAssignments implements PfAuthorative>> { public static final String DEFAULT_NAME = "ToscaCapabilityAssignmentsSimple"; public static final String DEFAULT_VERSION = "1.0.0"; + @Serial private static final long serialVersionUID = -7526648702327776101L; /** @@ -76,7 +78,7 @@ public class JpaToscaCapabilityAssignments } /** - * This Constructor creates an concept container with all of its fields defined. + * This Constructor creates a concept container with all of its fields defined. * * @param key the concept container key * @param conceptMap the concepts to be stored in the concept container diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityType.java index 4118c4db3..96d176f7a 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityType.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * Copyright (C) 2020, 2023 Nordix Foundation. * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,10 +21,11 @@ package org.onap.policy.models.tosca.simple.concepts; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.Table; +import java.io.Serial; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; @@ -44,6 +45,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityType; @EqualsAndHashCode(callSuper = true) @NoArgsConstructor public class JpaToscaCapabilityType extends JpaToscaWithToscaProperties { + @Serial private static final long serialVersionUID = -563659852901842616L; /** diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityTypes.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityTypes.java index e1feaed95..e23d45afc 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityTypes.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaCapabilityTypes.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * Copyright (C) 2020, 2023 Nordix Foundation. * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,13 +21,14 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.Table; +import java.io.Serial; import java.util.List; import java.util.Map; import java.util.TreeMap; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -50,6 +51,7 @@ import org.onap.policy.models.tosca.utils.ToscaUtils; public class JpaToscaCapabilityTypes extends PfConceptContainer { public static final String DEFAULT_NAME = "ToscaCapabilityTypesSimple"; public static final String DEFAULT_VERSION = "1.0.0"; + @Serial private static final long serialVersionUID = -4157979965271220098L; /** @@ -71,7 +73,7 @@ public class JpaToscaCapabilityTypes extends PfConceptContainer toscaConstraint.setEqual(compareTo); + case GT -> toscaConstraint.setGreaterThan(compareTo); + case GE -> toscaConstraint.setGreaterOrEqual(compareTo); + case LT -> toscaConstraint.setLessThan(compareTo); + case LE -> toscaConstraint.setLessOrEqual(compareTo); + default -> { + return null; + } } return toscaConstraint; @@ -128,10 +116,7 @@ public class JpaToscaConstraintLogical extends JpaToscaConstraint { } @Override - public int compareTo(JpaToscaConstraint otherConstraint) { - if (otherConstraint == null) { - return -1; - } + public int compareTo(@NonNull JpaToscaConstraint otherConstraint) { if (this == otherConstraint) { return 0; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintValidValues.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintValidValues.java index b5c2d10e5..1f4785fe4 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintValidValues.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintValidValues.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,9 +21,10 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.ElementCollection; +import java.io.Serial; import java.util.ArrayList; import java.util.List; -import javax.persistence.ElementCollection; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @@ -39,6 +40,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConstraint; @EqualsAndHashCode(callSuper = false) @ToString public class JpaToscaConstraintValidValues extends JpaToscaConstraint { + @Serial private static final long serialVersionUID = -5060193250508635456L; @ElementCollection @@ -84,10 +86,7 @@ public class JpaToscaConstraintValidValues extends JpaToscaConstraint { } @Override - public int compareTo(JpaToscaConstraint otherConstraint) { - if (otherConstraint == null) { - return -1; - } + public int compareTo(@NonNull JpaToscaConstraint otherConstraint) { if (this == otherConstraint) { return 0; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataType.java index c086c535a..107fb3abc 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataType.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,13 +23,14 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.Table; +import java.io.Serial; import java.util.ArrayList; import java.util.List; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; @@ -54,6 +55,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType; @EqualsAndHashCode(callSuper = true) @NoArgsConstructor public class JpaToscaDataType extends JpaToscaWithToscaProperties { + @Serial private static final long serialVersionUID = -3922690413436539164L; @ElementCollection diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypes.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypes.java index faa1ce186..2142f1641 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypes.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataTypes.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2020, 2023 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,15 +21,17 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.Table; +import java.io.Serial; import java.util.List; import java.util.Map; import java.util.TreeMap; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.NonNull; import lombok.ToString; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.models.base.PfConceptContainer; @@ -49,6 +51,7 @@ import org.onap.policy.models.tosca.utils.ToscaUtils; @ToString(callSuper = true) @EqualsAndHashCode(callSuper = true) public class JpaToscaDataTypes extends PfConceptContainer { + @Serial private static final long serialVersionUID = 2941102271022190348L; public static final String DEFAULT_NAME = "ToscaDataTypesSimple"; @@ -73,7 +76,7 @@ public class JpaToscaDataTypes extends PfConceptContainer extends PfConcept implements PfAuthorative { + @Serial private static final long serialVersionUID = -1330661834220739393L; private static final StandardCoder STANDARD_CODER = new StandardCoder(); @@ -68,10 +69,8 @@ public class JpaToscaEntityType extends PfConcept impleme // @formatter:off @Column - @AttributeOverrides({ - @AttributeOverride(name = "name", column = @Column(name = "derived_from_name")), - @AttributeOverride(name = "version", column = @Column(name = "derived_from_version")) - }) + @AttributeOverride(name = "name", column = @Column(name = "derived_from_name")) + @AttributeOverride(name = "version", column = @Column(name = "derived_from_version")) @VerifyKey private PfConceptKey derivedFrom; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEventFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEventFilter.java index e879a1305..f81790437 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEventFilter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEventFilter.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,13 +23,14 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.Column; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.Table; +import java.io.Serial; import java.util.List; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -54,6 +55,7 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey; @Data @EqualsAndHashCode(callSuper = false) public class JpaToscaEventFilter extends PfConcept { + @Serial private static final long serialVersionUID = 8769020537228210247L; @EmbeddedId diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModel.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModel.java index 5f72e2ba8..76434f51d 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModel.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModel.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020,2023 Nordix Foundation. + * Copyright (C) 2019-2020, 2023 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ @@ -22,16 +22,16 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinColumns; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; import java.util.List; -import javax.persistence.CascadeType; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.JoinColumn; -import javax.persistence.JoinColumns; -import javax.persistence.OneToOne; -import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -44,7 +44,7 @@ import org.onap.policy.models.base.PfModelService; /** * A container class for a TOSCA model with multiple service templates. This class is a container class that allows a - * model with many service templates to be constructed that contains a well formed overall TOSCA model. + * model with many service templates to be constructed that contains a well-formed overall TOSCA model. * *

Validation runs {@link JpaToscaModel} validation on the model and all its sub concepts. */ @@ -58,10 +58,8 @@ public class JpaToscaModel extends PfModel { private static final long serialVersionUID = 8800599637708309945L; @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumns({ - @JoinColumn(name = "serviceTemplatesName", referencedColumnName = "name"), - @JoinColumn(name = "serviceTemplatesVersion", referencedColumnName = "version") - }) + @JoinColumn(name = "serviceTemplatesName", referencedColumnName = "name") + @JoinColumn(name = "serviceTemplatesVersion", referencedColumnName = "version") @Valid private JpaToscaServiceTemplates serviceTemplates; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java index 0a5f0c688..0148fedf4 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplate.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020-2021,2023 Nordix Foundation. + * Copyright (C) 2020-2021, 2023 Nordix Foundation. * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,20 +21,20 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; +import jakarta.ws.rs.core.Response; +import java.io.Serial; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import javax.persistence.CascadeType; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.JoinColumn; -import javax.persistence.JoinColumns; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.ws.rs.core.Response; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -58,24 +58,21 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; @Data @EqualsAndHashCode(callSuper = false) public class JpaToscaNodeTemplate extends JpaToscaWithTypeAndStringProperties { + @Serial private static final long serialVersionUID = 1675770231921107988L; private static final StandardCoder STANDARD_CODER = new StandardCoder(); // formatter:off @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumns({ - @JoinColumn(name = "requirementsName", referencedColumnName = "name"), - @JoinColumn(name = "requirementsVersion", referencedColumnName = "version") - }) + @JoinColumn(name = "requirementsName", referencedColumnName = "name") + @JoinColumn(name = "requirementsVersion", referencedColumnName = "version") @Valid private JpaToscaRequirements requirements; @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumns({ - @JoinColumn(name = "capabilitiesName", referencedColumnName = "name"), - @JoinColumn(name = "capabilitiesVersion", referencedColumnName = "version") - }) + @JoinColumn(name = "capabilitiesName", referencedColumnName = "name") + @JoinColumn(name = "capabilitiesVersion", referencedColumnName = "version") @Valid private JpaToscaCapabilityAssignments capabilities; // @formatter:on diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplates.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplates.java index 6cc7a1f4e..0a14e435d 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplates.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTemplates.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * Copyright (C) 2020, 2023 Nordix Foundation. * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,15 +21,17 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.Table; +import java.io.Serial; import java.util.List; import java.util.Map; import java.util.TreeMap; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.NonNull; import lombok.ToString; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.models.base.PfConceptContainer; @@ -49,6 +51,7 @@ import org.onap.policy.models.tosca.utils.ToscaUtils; public class JpaToscaNodeTemplates extends PfConceptContainer { public static final String DEFAULT_NAME = "ToscaNodeTemplatesSimple"; public static final String DEFAULT_VERSION = "1.0.0"; + @Serial private static final long serialVersionUID = -4157979965271220098L; /** @@ -70,7 +73,7 @@ public class JpaToscaNodeTemplates extends PfConceptContainer { + @Serial private static final long serialVersionUID = -563659852901842616L; // formatter:off @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumns({ - @JoinColumn(name = "requirementsName", referencedColumnName = "name"), - @JoinColumn(name = "requirementsVersion", referencedColumnName = "version") - }) + @JoinColumn(name = "requirementsName", referencedColumnName = "name") + @JoinColumn(name = "requirementsVersion", referencedColumnName = "version") // @formatter:on @Valid private JpaToscaRequirements requirements; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTypes.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTypes.java index b1fe40b78..2a4b22efa 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTypes.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeTypes.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * Copyright (C) 2020, 2023 Nordix Foundation. * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,15 +21,17 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.Table; +import java.io.Serial; import java.util.List; import java.util.Map; import java.util.TreeMap; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.NonNull; import lombok.ToString; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.models.base.PfConceptContainer; @@ -49,6 +51,7 @@ import org.onap.policy.models.tosca.utils.ToscaUtils; public class JpaToscaNodeTypes extends PfConceptContainer { public static final String DEFAULT_NAME = "ToscaNodeTypesSimple"; public static final String DEFAULT_VERSION = "1.0.0"; + @Serial private static final long serialVersionUID = -4157979965271220098L; /** @@ -70,7 +73,7 @@ public class JpaToscaNodeTypes extends PfConceptContainer implements PfAuthorative>> { + @Serial private static final long serialVersionUID = -7526648702327776101L; public static final String DEFAULT_NAME = "ToscaPoliciesSimple"; @@ -104,7 +107,7 @@ public class JpaToscaPolicies extends PfConceptContainer { + @Serial private static final long serialVersionUID = 3265174757061982805L; private static final String METADATA_METADATA_SET_NAME_TAG = "metadataSetName"; private static final String METADATA_METADATA_SET_VERSION_TAG = "metadataSetVersion"; @@ -200,7 +202,7 @@ public class JpaToscaPolicy extends JpaToscaWithTypeAndStringProperties { + @Serial private static final long serialVersionUID = -563659852901842616L; @ElementCollection diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypes.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypes.java index c20cada8f..f053a5baa 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypes.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyTypes.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2020, 2023 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,15 +21,17 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.Table; +import java.io.Serial; import java.util.List; import java.util.Map; import java.util.TreeMap; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.NonNull; import lombok.ToString; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.models.base.PfConceptContainer; @@ -49,6 +51,7 @@ import org.onap.policy.models.tosca.utils.ToscaUtils; @ToString(callSuper = true) @EqualsAndHashCode(callSuper = true) public class JpaToscaPolicyTypes extends PfConceptContainer { + @Serial private static final long serialVersionUID = -4157979965271220098L; public static final String DEFAULT_NAME = "ToscaPolicyTypesSimple"; @@ -73,7 +76,7 @@ public class JpaToscaPolicyTypes extends PfConceptContainer { + @Serial private static final long serialVersionUID = 1675770231921107988L; @EmbeddedId @@ -243,10 +245,7 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative { + @Serial private static final long serialVersionUID = -563659852901842616L; /** diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRelationshipTypes.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRelationshipTypes.java index eed351df5..ab37c4e00 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRelationshipTypes.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRelationshipTypes.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * Copyright (C) 2020, 2023 Nordix Foundation. * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,15 +21,17 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.Table; +import java.io.Serial; import java.util.List; import java.util.Map; import java.util.TreeMap; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.NonNull; import lombok.ToString; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.models.base.PfConceptContainer; @@ -49,6 +51,7 @@ import org.onap.policy.models.tosca.utils.ToscaUtils; public class JpaToscaRelationshipTypes extends PfConceptContainer { public static final String DEFAULT_NAME = "ToscaRelationshipTypesSimple"; public static final String DEFAULT_VERSION = "1.0.0"; + @Serial private static final long serialVersionUID = -4157979965271220098L; /** @@ -70,7 +73,7 @@ public class JpaToscaRelationshipTypes extends PfConceptContainer { + @Serial private static final long serialVersionUID = 2785481541573683089L; private static final String AUTHORATIVE_UNBOUNDED_LITERAL = "UNBOUNDED"; private static final Integer JPA_UNBOUNDED_VALUE = -1; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRequirements.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRequirements.java index 283c161d0..52087b29f 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRequirements.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRequirements.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * Copyright (C) 2020, 2023 Nordix Foundation. * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,15 +21,17 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.Table; +import java.io.Serial; import java.util.List; import java.util.Map; import java.util.TreeMap; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.NonNull; import lombok.ToString; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.models.base.PfAuthorative; @@ -51,6 +53,7 @@ import org.onap.policy.models.tosca.utils.ToscaUtils; @EqualsAndHashCode(callSuper = true) public class JpaToscaRequirements extends PfConceptContainer implements PfAuthorative>> { + @Serial private static final long serialVersionUID = -7526648702327776101L; public static final String DEFAULT_NAME = "ToscaRequirementsSimple"; @@ -75,7 +78,7 @@ public class JpaToscaRequirements extends PfConceptContainer, Serializable, Comparable { + @Serial private static final long serialVersionUID = 3645882081163287058L; @Column @@ -180,10 +182,8 @@ public class JpaToscaSchemaDefinition extends Validated copy.setDescription(description); if (constraints != null) { - final List newConstraints = new ArrayList<>(); - for (final JpaToscaConstraint constraint : constraints) { - newConstraints.add(constraint); // Constraints are immutable - } + // Constraints are immutable + final List newConstraints = new ArrayList<>(constraints); copy.setConstraints(newConstraints); } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java index 109f1f0a8..8f878c86e 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021,2023 Nordix Foundation. + * Copyright (C) 2019-2021, 2023 Nordix Foundation. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,21 +22,21 @@ package org.onap.policy.models.tosca.simple.concepts; import com.google.gson.annotations.SerializedName; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; +import java.io.Serial; import java.util.Collection; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.JoinColumn; -import javax.persistence.JoinColumns; -import javax.persistence.OneToOne; -import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -64,10 +64,11 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; @Data @EqualsAndHashCode(callSuper = true) public class JpaToscaServiceTemplate extends JpaToscaEntityType - implements PfAuthorative { + implements PfAuthorative { + @Serial private static final long serialVersionUID = 8084846046148349401L; - public static final String DEFAULT_TOSCA_DEFINTIONS_VERISON = "tosca_simple_yaml_1_1_0"; + public static final String DEFAULT_TOSCA_DEFINITIONS_VERSION = "tosca_simple_yaml_1_1_0"; public static final String DEFAULT_NAME = "ToscaServiceTemplateSimple"; public static final String DEFAULT_VERSION = "1.0.0"; @@ -79,57 +80,45 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType Map flattenMap(List> list) { Map result = new LinkedHashMap<>(); @@ -353,7 +342,7 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType dataTypeKeyCollection, - final BeanValidationResult result) { + final BeanValidationResult result) { for (PfConceptKey dataTypeKey : dataTypeKeyCollection) { if (dataTypes == null || dataTypes.get(dataTypeKey) == null) { addResult(result, "data type", dataTypeKey.getId(), NOT_FOUND); @@ -470,13 +459,13 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType { + @Serial private static final long serialVersionUID = 8969698734673232603L; public static final String DEFAULT_LOCAL_NAME = "ToscaTopologyTemplateSimple"; @@ -81,27 +83,20 @@ public class JpaToscaTopologyTemplate extends PfConcept implements PfAuthorative @NotBlank private String description; - // @formatter:off @ElementCollection @Lob private Map<@NotNull String, @NotNull @Valid JpaToscaParameter> inputs; @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumns({ - @JoinColumn(name = "nodeTemplatesName", referencedColumnName = "name"), - @JoinColumn(name = "nodeTemplatessVersion", referencedColumnName = "version") - }) + @JoinColumn(name = "nodeTemplatesName", referencedColumnName = "name") + @JoinColumn(name = "nodeTemplatessVersion", referencedColumnName = "version") @SerializedName("data_types") @Valid private JpaToscaNodeTemplates nodeTemplates; @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumns({ - @JoinColumn(name = "policyName", referencedColumnName = "name"), - @JoinColumn(name = "policyVersion", referencedColumnName = "version") - - }) - // @formatter:on + @JoinColumn(name = "policyName", referencedColumnName = "name") + @JoinColumn(name = "policyVersion", referencedColumnName = "version") @Valid private JpaToscaPolicies policies; @@ -110,7 +105,7 @@ public class JpaToscaTopologyTemplate extends PfConcept implements PfAuthorative */ public JpaToscaTopologyTemplate() { this(new PfReferenceKey(JpaToscaServiceTemplate.DEFAULT_NAME, JpaToscaServiceTemplate.DEFAULT_VERSION, - DEFAULT_LOCAL_NAME)); + DEFAULT_LOCAL_NAME)); } /** @@ -133,7 +128,7 @@ public class JpaToscaTopologyTemplate extends PfConcept implements PfAuthorative this.description = copyConcept.description; this.inputs = PfUtils.mapMap(copyConcept.inputs, JpaToscaParameter::new); this.nodeTemplates = - (copyConcept.nodeTemplates != null ? new JpaToscaNodeTemplates(copyConcept.nodeTemplates) : null); + (copyConcept.nodeTemplates != null ? new JpaToscaNodeTemplates(copyConcept.nodeTemplates) : null); this.policies = (copyConcept.policies != null ? new JpaToscaPolicies(copyConcept.policies) : null); } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTrigger.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTrigger.java index 1e13b225c..2b017ee74 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTrigger.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTrigger.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2021 Nordix Foundation. + * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation. * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,10 +25,10 @@ package org.onap.policy.models.tosca.simple.concepts; import com.google.gson.annotations.SerializedName; +import jakarta.persistence.Column; +import jakarta.persistence.EmbeddedId; import java.time.Duration; import java.util.List; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaProperties.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaProperties.java index 510287581..34119437d 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaProperties.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaProperties.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +21,10 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Lob; +import jakarta.persistence.MappedSuperclass; +import java.io.Serial; import java.util.Collection; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -27,9 +32,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import javax.persistence.ElementCollection; -import javax.persistence.Lob; -import javax.persistence.MappedSuperclass; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -56,6 +58,7 @@ import org.onap.policy.models.tosca.utils.ToscaUtils; @EqualsAndHashCode(callSuper = true) public abstract class JpaToscaWithToscaProperties extends JpaToscaEntityType implements PfAuthorative { + @Serial private static final long serialVersionUID = -563659852901842616L; @ElementCollection diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithTypeAndStringProperties.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithTypeAndStringProperties.java index cb0ff4e5d..d2dd0e834 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithTypeAndStringProperties.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithTypeAndStringProperties.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2021,2023 Nordix Foundation. + * Modifications Copyright (C) 2021, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,16 +21,16 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.AttributeOverride; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Lob; +import jakarta.persistence.MappedSuperclass; +import jakarta.ws.rs.core.Response; +import java.io.Serial; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import javax.persistence.AttributeOverride; -import javax.persistence.AttributeOverrides; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Lob; -import javax.persistence.MappedSuperclass; -import javax.ws.rs.core.Response; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -54,13 +54,12 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaWithTypeAndObjectP public abstract class JpaToscaWithTypeAndStringProperties extends JpaToscaEntityType implements PfAuthorative { + @Serial private static final long serialVersionUID = 2785481541573683089L; @Column - @AttributeOverrides ({ - @AttributeOverride(name = "name", column = @Column(name = "type_name")), - @AttributeOverride(name = "version", column = @Column(name = "type_version")) - }) + @AttributeOverride(name = "name", column = @Column(name = "type_name")) + @AttributeOverride(name = "version", column = @Column(name = "type_version")) @VerifyKey @NotNull private PfConceptKey type; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java index e2f61c464..486dc9f19 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020,2022 Nordix Foundation. + * Copyright (C) 2019-2020, 2022-2023 Nordix Foundation. * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,12 +21,12 @@ package org.onap.policy.models.tosca.simple.provider; +import jakarta.ws.rs.core.Response; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Optional; -import javax.ws.rs.core.Response; import lombok.NonNull; import org.apache.commons.collections4.CollectionUtils; import org.onap.policy.common.parameters.BeanValidationResult; @@ -492,7 +492,7 @@ public class SimpleToscaProvider { deletedServiceTemplate.setPolicyTypes(new JpaToscaPolicyTypes()); deletedServiceTemplate.getPolicyTypes().getConceptMap().put(policyTypeKey, policyType4Deletion); - LOGGER.debug("<-deletePolicyType: key={}, serviceTempalate={}", policyTypeKey, deletedServiceTemplate); + LOGGER.debug("<-deletePolicyType: key={}, serviceTemplate={}", policyTypeKey, deletedServiceTemplate); return deletedServiceTemplate; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProvider.java index b0b78638d..40f09e3a0 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProvider.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaServiceTemplateProvider.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * Copyright (C) 2020, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ package org.onap.policy.models.tosca.simple.provider; -import javax.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.Response.Status; import lombok.NonNull; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelException; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java index 6f4b2993f..1f6056f35 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020,2022 Nordix Foundation. + * Copyright (C) 2020, 2022-2023 Nordix Foundation. * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,8 +21,8 @@ package org.onap.policy.models.tosca.utils; +import jakarta.ws.rs.core.Response; import java.util.Map.Entry; -import javax.ws.rs.core.Response; import lombok.AccessLevel; import lombok.NoArgsConstructor; import lombok.NonNull; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java index be0d41d9b..f4c22fc5f 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2022 Nordix Foundation. + * Copyright (C) 2019-2023 Nordix Foundation. * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,11 +21,11 @@ package org.onap.policy.models.tosca.utils; +import jakarta.ws.rs.core.Response; import java.util.Collection; import java.util.HashSet; import java.util.Set; import java.util.function.Function; -import javax.ws.rs.core.Response; import lombok.AccessLevel; import lombok.NoArgsConstructor; import lombok.NonNull; diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogicalTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogicalTest.java index 53b42caa7..2fdd29c5a 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogicalTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogicalTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2023 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,6 +21,7 @@ package org.onap.policy.models.tosca.simple.concepts; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; @@ -69,7 +70,7 @@ public class JpaToscaConstraintLogicalTest { JpaToscaConstraintLogical jc5 = new JpaToscaConstraintLogical(c5); assertNull(jc5.toAuthorative()); - assertEquals(-1, jc0.compareTo(null)); + assertThatThrownBy(() -> jc0.compareTo(null)).isInstanceOf(NullPointerException.class); assertEquals(0, jc0.compareTo(jc0)); assertNotEquals(0, jc0.compareTo(new JpaToscaConstraintValidValues(new ArrayList<>()))); assertEquals(-2, jc0.compareTo(jc1)); 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 6c39737f1..02e3fdae3 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-2021 Nordix Foundation. + * Copyright (C) 2019-2021, 2023 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -68,7 +68,7 @@ public class JpaToscaConstraintTest { validValues.add("hello"); validValues.add("goodbye"); JpaToscaConstraintValidValues cvv0 = new JpaToscaConstraintValidValues(validValues); - assertEquals(-1, cvv0.compareTo(null)); + assertThatThrownBy(() -> cvv0.compareTo(null)).isInstanceOf(NullPointerException.class); assertEquals(0, cvv0.compareTo(cvv0)); assertNotEquals(0, cvv0.compareTo(new JpaToscaConstraintLogical(JpaToscaConstraintOperation.EQ, CONSTRAINT))); JpaToscaConstraintValidValues cvv1 = new JpaToscaConstraintValidValues(validValues); @@ -81,7 +81,7 @@ public class JpaToscaConstraintTest { rangeValues.add("hello"); rangeValues.add("goodbye"); JpaToscaConstraintInRange cir0 = new JpaToscaConstraintInRange(rangeValues); - assertEquals(-1, cir0.compareTo(null)); + assertThatThrownBy(() -> cir0.compareTo(null)).isInstanceOf(NullPointerException.class); assertEquals(0, cir0.compareTo(cir0)); assertNotEquals(0, cir0.compareTo(new JpaToscaConstraintLogical(JpaToscaConstraintOperation.EQ, CONSTRAINT))); JpaToscaConstraintInRange cir1 = new JpaToscaConstraintInRange(rangeValues); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPropertyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPropertyTest.java index 685266a9f..ffa21244c 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPropertyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPropertyTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2021, 2023 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -113,7 +113,7 @@ public class JpaToscaPropertyTest { assertEquals(tp, tdtClone1); assertEquals(0, tp.compareTo(tdtClone1)); - assertEquals(-1, tp.compareTo(null)); + assertThatThrownBy(() -> tp.compareTo(null)).isInstanceOf(NullPointerException.class); assertEquals(0, tp.compareTo(tp)); assertNotEquals(0, tp.compareTo(tp.getKey())); } diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplateTest.java index 9a91a9558..6296788ee 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplateTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplateTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2021, 2023 Nordix Foundation. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -96,39 +96,7 @@ public class JpaToscaServiceTemplateTest { tst.setTopologyTemplate(ttt); assertEquals(ttt, tst.getTopologyTemplate()); - JpaToscaServiceTemplate tttClone0 = new JpaToscaServiceTemplate(tst); - assertEquals(tst, tttClone0); - assertEquals(0, tst.compareTo(tttClone0)); - - JpaToscaServiceTemplate tttClone1 = new JpaToscaServiceTemplate(tst); - assertEquals(tst, tttClone1); - assertEquals(0, tst.compareTo(tttClone1)); - - assertEquals(-1, tst.compareTo(null)); - assertEquals(0, tst.compareTo(tst)); - assertNotEquals(0, tst.compareTo(tst.getKey())); - - PfConceptKey otherDtKey = new PfConceptKey("otherDt", VERSION_001); - JpaToscaServiceTemplate otherDt = new JpaToscaServiceTemplate(otherDtKey); - - assertNotEquals(0, tst.compareTo(otherDt)); - otherDt.setKey(tstKey); - assertNotEquals(0, tst.compareTo(otherDt)); - otherDt.setToscaDefinitionsVersion("Tosca Version"); - assertNotEquals(0, tst.compareTo(otherDt)); - otherDt.setDataTypes(dataTypes); - assertNotEquals(0, tst.compareTo(otherDt)); - otherDt.setPolicyTypes(policyTypes); - assertNotEquals(0, tst.compareTo(otherDt)); - otherDt.setTopologyTemplate(ttt); - assertEquals(0, tst.compareTo(otherDt)); - - assertEquals(6, tst.getKeys().size()); - assertEquals(1, new JpaToscaServiceTemplate().getKeys().size()); - - new JpaToscaServiceTemplate().clean(); - tst.clean(); - assertEquals(tttClone0, tst); + assertCloneAndCopies(tstKey, tst, dataTypes, policyTypes, ttt); assertTrue(new JpaToscaServiceTemplate().validate("").isValid()); assertTrue(tst.validate("").isValid()); @@ -146,7 +114,7 @@ public class JpaToscaServiceTemplateTest { BeanValidationResult result = tst.validate(""); assertThat(result.getResult()).contains("tosca_definitions_version").contains(Validated.IS_NULL); - tst.setToscaDefinitionsVersion(JpaToscaServiceTemplate.DEFAULT_TOSCA_DEFINTIONS_VERISON); + tst.setToscaDefinitionsVersion(JpaToscaServiceTemplate.DEFAULT_TOSCA_DEFINITIONS_VERSION); tst.setDataTypes(null); result = tst.validate(""); assertTrue(result.isValid()); @@ -160,6 +128,19 @@ public class JpaToscaServiceTemplateTest { JpaToscaProperty prop0 = new JpaToscaProperty(new PfReferenceKey(pt0.getKey(), "prop0")); prop0.setType(dt0.getKey()); + assertDataTypesAndToscaTopology(tst, pt0, dt0, prop0); + + tst.setPolicyTypes(null); + result = tst.validate(""); + assertTrue(result.isValid()); + + assertNoPolicyType(tst, policyTypes, pt0, dt0); + + } + + private static void assertDataTypesAndToscaTopology(JpaToscaServiceTemplate tst, JpaToscaPolicyType pt0, + JpaToscaDataType dt0, JpaToscaProperty prop0) { + BeanValidationResult result; pt0.setProperties(new LinkedHashMap<>()); pt0.getProperties().put(prop0.getKey().getLocalName(), prop0); result = tst.validate(""); @@ -191,11 +172,49 @@ public class JpaToscaServiceTemplateTest { tst.getTopologyTemplate().setPolicies(new JpaToscaPolicies()); result = tst.validate(""); assertTrue(result.isValid()); + } - tst.setPolicyTypes(null); - result = tst.validate(""); - assertTrue(result.isValid()); + private static void assertCloneAndCopies(PfConceptKey tstKey, JpaToscaServiceTemplate tst, + JpaToscaDataTypes dataTypes, JpaToscaPolicyTypes policyTypes, + JpaToscaTopologyTemplate ttt) { + JpaToscaServiceTemplate tttClone0 = new JpaToscaServiceTemplate(tst); + assertEquals(tst, tttClone0); + assertEquals(0, tst.compareTo(tttClone0)); + + JpaToscaServiceTemplate tttClone1 = new JpaToscaServiceTemplate(tst); + assertEquals(tst, tttClone1); + assertEquals(0, tst.compareTo(tttClone1)); + + assertEquals(-1, tst.compareTo(null)); + assertEquals(0, tst.compareTo(tst)); + assertNotEquals(0, tst.compareTo(tst.getKey())); + + PfConceptKey otherDtKey = new PfConceptKey("otherDt", VERSION_001); + JpaToscaServiceTemplate otherDt = new JpaToscaServiceTemplate(otherDtKey); + + assertNotEquals(0, tst.compareTo(otherDt)); + otherDt.setKey(tstKey); + assertNotEquals(0, tst.compareTo(otherDt)); + otherDt.setToscaDefinitionsVersion("Tosca Version"); + assertNotEquals(0, tst.compareTo(otherDt)); + otherDt.setDataTypes(dataTypes); + assertNotEquals(0, tst.compareTo(otherDt)); + otherDt.setPolicyTypes(policyTypes); + assertNotEquals(0, tst.compareTo(otherDt)); + otherDt.setTopologyTemplate(ttt); + assertEquals(0, tst.compareTo(otherDt)); + + assertEquals(6, tst.getKeys().size()); + assertEquals(1, new JpaToscaServiceTemplate().getKeys().size()); + + new JpaToscaServiceTemplate().clean(); + tst.clean(); + assertEquals(tttClone0, tst); + } + private static void assertNoPolicyType(JpaToscaServiceTemplate tst, JpaToscaPolicyTypes policyTypes, + JpaToscaPolicyType pt0, JpaToscaDataType dt0) { + BeanValidationResult result; JpaToscaPolicy pol0 = new JpaToscaPolicy(new PfConceptKey("pol0:0.0.1")); tst.getTopologyTemplate().getPolicies().getConceptMap().put(pol0.getKey(), pol0); result = tst.validate(""); @@ -239,6 +258,5 @@ public class JpaToscaServiceTemplateTest { assertFalse(result.isValid()); assertThat(result.getResult()).contains( "no policy types are defined on the service template for the policies in the topology template"); - } } -- cgit 1.2.3-korg