diff options
Diffstat (limited to 'models-tosca')
45 files changed, 431 insertions, 410 deletions
diff --git a/models-tosca/pom.xml b/models-tosca/pom.xml index 07406fcd6..cc3711514 100644 --- a/models-tosca/pom.xml +++ b/models-tosca/pom.xml @@ -19,13 +19,13 @@ ============LICENSE_END========================================================= --> <project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.policy.models</groupId> <artifactId>policy-models</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.1-SNAPSHOT</version> </parent> <artifactId>policy-models-tosca</artifactId> 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 <T> List<T> asConceptList(final List<Map<String, T>> listOfMaps) { List<T> returnList = new ArrayList<>(); for (Map<String, T> 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<ToscaCapabilityAssignment> { + @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<List<Map<String, ToscaCapabilityAssignment>>> { 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<ToscaCapabilityType> { + @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<JpaToscaCapabilityType, ToscaCapabilityType> { 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<JpaToscaCapabili } /** - * 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/JpaToscaConstraintInRange.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintInRange.java index 14e9db522..ea4810f3c 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintInRange.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintInRange.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. + * 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. @@ -20,9 +20,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; @@ -36,6 +37,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConstraint; @EqualsAndHashCode(callSuper = false) @ToString public class JpaToscaConstraintInRange extends JpaToscaConstraint { + @Serial private static final long serialVersionUID = -5060193250508635456L; @ElementCollection @@ -81,10 +83,7 @@ public class JpaToscaConstraintInRange 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/JpaToscaConstraintLogical.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java index e8d16a705..5d4577d0b 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,7 +21,8 @@ package org.onap.policy.models.tosca.simple.concepts; -import javax.persistence.Column; +import jakarta.persistence.Column; +import java.io.Serial; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NonNull; @@ -35,6 +36,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConstraint; @EqualsAndHashCode(callSuper = false) @ToString public class JpaToscaConstraintLogical extends JpaToscaConstraint { + @Serial private static final long serialVersionUID = -2730203215911880756L; @Column @@ -78,28 +80,14 @@ public class JpaToscaConstraintLogical extends JpaToscaConstraint { } switch (operation) { - case EQ: - toscaConstraint.setEqual(compareTo); - break; - - case GT: - toscaConstraint.setGreaterThan(compareTo); - break; - - case GE: - toscaConstraint.setGreaterOrEqual(compareTo); - break; - - case LT: - toscaConstraint.setLessThan(compareTo); - break; - - case LE: - toscaConstraint.setLessOrEqual(compareTo); - break; - - default: - // Can't happen + case EQ -> 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<ToscaDataType> { + @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<JpaToscaDataType, ToscaDataType> { + @Serial private static final long serialVersionUID = 2941102271022190348L; public static final String DEFAULT_NAME = "ToscaDataTypesSimple"; @@ -73,7 +76,7 @@ public class JpaToscaDataTypes extends PfConceptContainer<JpaToscaDataType, Tosc } /** - * 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 @@ -102,7 +105,7 @@ public class JpaToscaDataTypes extends PfConceptContainer<JpaToscaDataType, Tosc } @Override - public BeanValidationResult validate(String fieldName) { + public BeanValidationResult validate(@NonNull String fieldName) { BeanValidationResult result = super.validate(fieldName); for (JpaToscaDataType dataType : this.getConceptMap().values()) { diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java index b9acde26c..e23ac42c2 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020,2022-2023 Nordix Foundation. + * Copyright (C) 2019-2020, 2022-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,18 +21,18 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.AttributeOverride; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Lob; +import jakarta.persistence.MappedSuperclass; +import jakarta.ws.rs.core.Response; +import java.io.Serial; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; -import javax.persistence.AttributeOverride; -import javax.persistence.AttributeOverrides; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.EmbeddedId; -import javax.persistence.Lob; -import javax.persistence.MappedSuperclass; -import javax.ws.rs.core.Response; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -57,6 +57,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity; @Data @EqualsAndHashCode(callSuper = false) public class JpaToscaEntityType<T extends ToscaEntity> extends PfConcept implements PfAuthorative<T> { + @Serial private static final long serialVersionUID = -1330661834220739393L; private static final StandardCoder STANDARD_CODER = new StandardCoder(); @@ -68,10 +69,8 @@ public class JpaToscaEntityType<T extends ToscaEntity> 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. * * <p>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<ToscaNodeTemplate> { + @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<JpaToscaNodeTemplate, ToscaNodeTemplate> { 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<JpaToscaNodeTempla } /** - * 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 @@ -99,7 +102,7 @@ public class JpaToscaNodeTemplates extends PfConceptContainer<JpaToscaNodeTempla } @Override - public BeanValidationResult validate(String fieldName) { + public BeanValidationResult validate(@NonNull String fieldName) { BeanValidationResult result = super.validate(fieldName); // Check that all ancestors of this node template exist diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeType.java index f295accab..a7342d2f8 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaNodeType.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020,2023 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,16 +21,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.OneToOne; +import jakarta.persistence.Table; +import java.io.Serial; 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.NoArgsConstructor; @@ -54,15 +54,14 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType; @EqualsAndHashCode(callSuper = true) @NoArgsConstructor public class JpaToscaNodeType extends JpaToscaWithToscaProperties<ToscaNodeType> { + @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<JpaToscaNodeType, ToscaNodeType> { 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<JpaToscaNodeType, Tosc } /** - * 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 @@ -99,7 +102,7 @@ public class JpaToscaNodeTypes extends PfConceptContainer<JpaToscaNodeType, Tosc } @Override - public BeanValidationResult validate(String fieldName) { + public BeanValidationResult validate(@NonNull String fieldName) { BeanValidationResult result = super.validate(fieldName); // Check that all ancestors of this policy type exist diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.java index 552d9c15c..dfa8240ee 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaParameter.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. * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ @@ -22,9 +22,9 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.Column; +import jakarta.persistence.EmbeddedId; 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/JpaToscaPolicies.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicies.java index 7c1022c84..caf999590 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicies.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicies.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.PfAuthorative; @@ -51,6 +53,7 @@ import org.onap.policy.models.tosca.utils.ToscaUtils; @EqualsAndHashCode(callSuper = true) public class JpaToscaPolicies extends PfConceptContainer<JpaToscaPolicy, ToscaPolicy> implements PfAuthorative<List<Map<String, ToscaPolicy>>> { + @Serial private static final long serialVersionUID = -7526648702327776101L; public static final String DEFAULT_NAME = "ToscaPoliciesSimple"; @@ -104,7 +107,7 @@ public class JpaToscaPolicies extends PfConceptContainer<JpaToscaPolicy, ToscaPo } @Override - public BeanValidationResult validate(String fieldName) { + public BeanValidationResult validate(@NonNull String fieldName) { BeanValidationResult result = super.validate(fieldName); for (JpaToscaPolicy policy : this.getConceptMap().values()) { diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java index 92e0faea6..eb573ca51 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019-2021 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"); @@ -24,16 +24,17 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.Table; +import jakarta.ws.rs.core.Response; +import java.io.Serial; import java.util.LinkedHashMap; import java.util.List; -import javax.persistence.CollectionTable; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.JoinColumn; -import javax.persistence.Table; -import javax.ws.rs.core.Response; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -61,6 +62,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; @Data @EqualsAndHashCode(callSuper = true) public class JpaToscaPolicy extends JpaToscaWithTypeAndStringProperties<ToscaPolicy> { + @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<ToscaPol } @Override - public BeanValidationResult validate(String fieldName) { + public BeanValidationResult validate(@NonNull String fieldName) { BeanValidationResult result = super.validate(fieldName); validateKeyVersionNotNull(result, "key", getKey()); diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java index dfdf7ed9b..14502c64c 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.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. * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,15 +24,16 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.CollectionTable; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.Lob; +import jakarta.persistence.Table; +import java.io.Serial; import java.util.List; -import javax.persistence.CollectionTable; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.JoinColumn; -import javax.persistence.Lob; -import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; @@ -60,6 +61,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; @EqualsAndHashCode(callSuper = true) @NoArgsConstructor public class JpaToscaPolicyType extends JpaToscaWithToscaProperties<ToscaPolicyType> { + @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<JpaToscaPolicyType, ToscaPolicyType> { + @Serial private static final long serialVersionUID = -4157979965271220098L; public static final String DEFAULT_NAME = "ToscaPolicyTypesSimple"; @@ -73,7 +76,7 @@ public class JpaToscaPolicyTypes extends PfConceptContainer<JpaToscaPolicyType, } /** - * 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 @@ -102,7 +105,7 @@ public class JpaToscaPolicyTypes extends PfConceptContainer<JpaToscaPolicyType, } @Override - public BeanValidationResult validate(String fieldName) { + public BeanValidationResult validate(@NonNull String fieldName) { BeanValidationResult result = super.validate(fieldName); // Check that all ancestors of this policy type exist diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaProperty.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaProperty.java index 73b9faba8..0ef8ffbaa 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaProperty.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaProperty.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019-2021 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"); @@ -24,13 +24,14 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.EmbeddedId; +import java.io.Serial; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.EmbeddedId; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -58,6 +59,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty.Status; @Data @EqualsAndHashCode(callSuper = false) public class JpaToscaProperty extends PfConcept implements PfAuthorative<ToscaProperty> { + @Serial private static final long serialVersionUID = 1675770231921107988L; @EmbeddedId @@ -243,10 +245,7 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative<ToscaPr } @Override - public int compareTo(final PfConcept otherConcept) { - if (otherConcept == null) { - return -1; - } + public int compareTo(@NonNull final PfConcept otherConcept) { if (this == otherConcept) { return 0; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRelationshipType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRelationshipType.java index 118211153..f542192b9 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRelationshipType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRelationshipType.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.ToscaRelationshipType; @EqualsAndHashCode(callSuper = true) @NoArgsConstructor public class JpaToscaRelationshipType extends JpaToscaWithToscaProperties<ToscaRelationshipType> { + @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<JpaToscaRelationshipType, ToscaRelationshipType> { 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<JpaToscaRelati } /** - * 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 @@ -100,7 +103,7 @@ public class JpaToscaRelationshipTypes extends PfConceptContainer<JpaToscaRelati } @Override - public BeanValidationResult validate(String fieldName) { + public BeanValidationResult validate(@NonNull String fieldName) { BeanValidationResult result = super.validate(fieldName); // Check that all ancestors of this policy type exist diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRequirement.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRequirement.java index f2cf14cb7..18d9d0067 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRequirement.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaRequirement.java @@ -3,7 +3,7 @@ * ONAP Requirement Model * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2021 Nordix Foundation. + * Modifications Copyright (C) 2019-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. @@ -23,14 +23,15 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.Column; +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.Column; -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.NonNull; @@ -55,6 +56,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaRequirement; @EqualsAndHashCode(callSuper = true) public class JpaToscaRequirement extends JpaToscaWithTypeAndStringProperties<ToscaRequirement> { + @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<JpaToscaRequirement, ToscaRequirement> implements PfAuthorative<List<Map<String, ToscaRequirement>>> { + @Serial private static final long serialVersionUID = -7526648702327776101L; public static final String DEFAULT_NAME = "ToscaRequirementsSimple"; @@ -75,7 +78,7 @@ public class JpaToscaRequirements extends PfConceptContainer<JpaToscaRequirement } /** - * 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 @@ -104,7 +107,7 @@ public class JpaToscaRequirements extends PfConceptContainer<JpaToscaRequirement } @Override - public BeanValidationResult validate(String fieldName) { + public BeanValidationResult validate(@NonNull String fieldName) { BeanValidationResult result = super.validate(fieldName); for (JpaToscaRequirement requirement : this.getConceptMap().values()) { diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaSchemaDefinition.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaSchemaDefinition.java index 75941b28f..b41716579 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaSchemaDefinition.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaSchemaDefinition.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,11 +23,12 @@ package org.onap.policy.models.tosca.simple.concepts; +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import java.io.Serial; import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import javax.persistence.Column; -import javax.persistence.ElementCollection; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; @@ -58,6 +59,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaSchemaDefinition; public class JpaToscaSchemaDefinition extends Validated implements PfAuthorative<ToscaSchemaDefinition>, Serializable, Comparable<JpaToscaSchemaDefinition> { + @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<JpaToscaConstraint> newConstraints = new ArrayList<>(); - for (final JpaToscaConstraint constraint : constraints) { - newConstraints.add(constraint); // Constraints are immutable - } + // Constraints are immutable + final List<JpaToscaConstraint> 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<ToscaServiceTemplate> - implements PfAuthorative<ToscaServiceTemplate> { + implements PfAuthorative<ToscaServiceTemplate> { + @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<ToscaServiceTemp private String toscaDefinitionsVersion; @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumns({ - @JoinColumn(name = "dataTypesName", referencedColumnName = "name"), - @JoinColumn(name = "dataTypesVersion", referencedColumnName = "version") - }) + @JoinColumn(name = "dataTypesName", referencedColumnName = "name") + @JoinColumn(name = "dataTypesVersion", referencedColumnName = "version") @SerializedName("data_types") @Valid private JpaToscaDataTypes dataTypes; @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumns({ - @JoinColumn(name = "capabilityTypesName", referencedColumnName = "name"), - @JoinColumn(name = "capabilityTypesVersion", referencedColumnName = "version") - }) + @JoinColumn(name = "capabilityTypesName", referencedColumnName = "name") + @JoinColumn(name = "capabilityTypesVersion", referencedColumnName = "version") @SerializedName("capability_types") @Valid private JpaToscaCapabilityTypes capabilityTypes; @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumns({ - @JoinColumn(name = "relationshipTypesName", referencedColumnName = "name"), - @JoinColumn(name = "relationshipTypesVersion", referencedColumnName = "version") - }) + @JoinColumn(name = "relationshipTypesName", referencedColumnName = "name") + @JoinColumn(name = "relationshipTypesVersion", referencedColumnName = "version") @SerializedName("relationship_types") @Valid private JpaToscaRelationshipTypes relationshipTypes; @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumns({ - @JoinColumn(name = "nodeTypesName", referencedColumnName = "name"), - @JoinColumn(name = "nodeTypesVersion", referencedColumnName = "version") - }) + @JoinColumn(name = "nodeTypesName", referencedColumnName = "name") + @JoinColumn(name = "nodeTypesVersion", referencedColumnName = "version") @SerializedName("node_types") @Valid private JpaToscaNodeTypes nodeTypes; @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumns({ - @JoinColumn(name = "policyTypesName", referencedColumnName = "name"), - @JoinColumn(name = "policyTypesVersion", referencedColumnName = "version") - }) + @JoinColumn(name = "policyTypesName", referencedColumnName = "name") + @JoinColumn(name = "policyTypesVersion", referencedColumnName = "version") @SerializedName("policy_types") @Valid private JpaToscaPolicyTypes policyTypes; @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumns({ - @JoinColumn(name = "topologyTemplateParentKeyName", referencedColumnName = "parentKeyName"), - @JoinColumn(name = "topologyTemplateParentKeyVersion", referencedColumnName = "parentKeyVersion"), - @JoinColumn(name = "topologyTemplateParentLocalName", referencedColumnName = "parentLocalName"), - @JoinColumn(name = "topologyTemplateLocalName", referencedColumnName = "localName") - }) + @JoinColumn(name = "topologyTemplateParentKeyName", referencedColumnName = "parentKeyName") + @JoinColumn(name = "topologyTemplateParentKeyVersion", referencedColumnName = "parentKeyVersion") + @JoinColumn(name = "topologyTemplateParentLocalName", referencedColumnName = "parentLocalName") + @JoinColumn(name = "topologyTemplateLocalName", referencedColumnName = "localName") @SerializedName("topology_template") @Valid private JpaToscaTopologyTemplate topologyTemplate; @@ -148,13 +137,13 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType<ToscaServiceTemp * @param key the key */ public JpaToscaServiceTemplate(@NonNull final PfConceptKey key) { - this(key, DEFAULT_TOSCA_DEFINTIONS_VERISON); + this(key, DEFAULT_TOSCA_DEFINITIONS_VERSION); } /** * The full constructor creates a {@link JpaToscaServiceTemplate} object with all mandatory parameters. * - * @param key the key + * @param key the key * @param toscaDefinitionsVersion the TOSCA version string */ public JpaToscaServiceTemplate(@NonNull final PfConceptKey key, @NonNull final String toscaDefinitionsVersion) { @@ -172,15 +161,15 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType<ToscaServiceTemp this.toscaDefinitionsVersion = copyConcept.toscaDefinitionsVersion; this.dataTypes = (copyConcept.dataTypes != null ? new JpaToscaDataTypes(copyConcept.dataTypes) : null); this.capabilityTypes = - (copyConcept.capabilityTypes != null ? new JpaToscaCapabilityTypes(copyConcept.capabilityTypes) : null); + (copyConcept.capabilityTypes != null ? new JpaToscaCapabilityTypes(copyConcept.capabilityTypes) : null); this.relationshipTypes = - (copyConcept.relationshipTypes != null ? new JpaToscaRelationshipTypes(copyConcept.relationshipTypes) - : null); + (copyConcept.relationshipTypes != null ? new JpaToscaRelationshipTypes(copyConcept.relationshipTypes) + : null); this.nodeTypes = (copyConcept.nodeTypes != null ? new JpaToscaNodeTypes(copyConcept.nodeTypes) : null); this.policyTypes = (copyConcept.policyTypes != null ? new JpaToscaPolicyTypes(copyConcept.policyTypes) : null); this.topologyTemplate = - (copyConcept.topologyTemplate != null ? new JpaToscaTopologyTemplate(copyConcept.topologyTemplate) - : null); + (copyConcept.topologyTemplate != null ? new JpaToscaTopologyTemplate(copyConcept.topologyTemplate) + : null); } /** @@ -231,8 +220,8 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType<ToscaServiceTemp /** * Takes a list of maps and flattens it into a single map. * - * @param list list to be be flattened - * @return a map containing all of the elements from the list of maps + * @param list list to be flattened + * @return a map containing all the elements from the list of maps */ private <V> Map<String, V> flattenMap(List<Map<String, V>> list) { Map<String, V> result = new LinkedHashMap<>(); @@ -353,7 +342,7 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType<ToscaServiceTemp public BeanValidationResult validate(String fieldName) { BeanValidationResult result = super.validate(fieldName); - // No point in validating cross references if the structure of the individual parts are not valid + // No point in validating cross-references if the structure of the individual parts are not valid if (!result.isValid()) { return result; } @@ -452,10 +441,10 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType<ToscaServiceTemp * Validate that the referenced data types exist for a collection of data type keys. * * @param dataTypeKeyCollection the data type key collection - * @param result where the results are added + * @param result where the results are added */ private void validateReferencedDataTypesExists(final Collection<PfConceptKey> 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<ToscaServiceTemp */ private void validatePolicyTypesInPolicies(BeanValidationResult result) { if (topologyTemplate == null || topologyTemplate.getPolicies() == null - || topologyTemplate.getPolicies().getConceptMap().isEmpty()) { + || topologyTemplate.getPolicies().getConceptMap().isEmpty()) { return; } if (policyTypes == null || policyTypes.getConceptMap().isEmpty()) { addResult(result, "policyTypes", policyTypes, - "no policy types are defined on the service template for the policies in the topology template"); + "no policy types are defined on the service template for the policies in the topology template"); return; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplates.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplates.java index 4f9fa43f8..318ca1d8e 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplates.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplates.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 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,13 @@ 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.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 org.onap.policy.models.base.PfConceptContainer; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeInterval.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeInterval.java index 819b7d812..e54f11900 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeInterval.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeInterval.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. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,14 +24,15 @@ package org.onap.policy.models.tosca.simple.concepts; import com.google.gson.annotations.SerializedName; +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.sql.Timestamp; import java.time.Instant; import java.util.List; -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; @@ -56,6 +57,7 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey; @Data @EqualsAndHashCode(callSuper = false) public class JpaToscaTimeInterval extends PfConcept { + @Serial private static final long serialVersionUID = 9151467029611969980L; @EmbeddedId diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.java index 629e14a84..30152df10 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.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-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,23 +22,24 @@ 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.ElementCollection; +import jakarta.persistence.EmbeddedId; +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.Lob; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; +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.Column; -import javax.persistence.ElementCollection; -import javax.persistence.EmbeddedId; -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.Lob; -import javax.persistence.OneToOne; -import javax.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -68,6 +69,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; @Data @EqualsAndHashCode(callSuper = false) public class JpaToscaTopologyTemplate extends PfConcept implements PfAuthorative<ToscaTopologyTemplate> { + @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<T extends ToscaWithToscaProperties> extends JpaToscaEntityType<T> implements PfAuthorative<T> { + @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<T extends ToscaWithTypeAndObjectProperties> extends JpaToscaEntityType<T> implements PfAuthorative<T> { + @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"); - } } |