--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Models
+ * ================================================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.pap.concepts;
+
+import com.google.gson.annotations.SerializedName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.NonNull;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
+
+/**
+ * Policy identifier with an optional version; only the "name" is required.
+ *
+ * <p>Note that there are deliberately no setters or getters on this class, it is use purely for GSON serialization and
+ * deserializaiton
+ */
+public class PapPolicyIdentifier {
+ @NonNull
+ @ApiModelProperty(name = "policy-id")
+ @SerializedName("policy-id")
+ private String name;
+
+ @ApiModelProperty(name = "policy-version")
+ @SerializedName("policy-version")
+ private String version;
+
+ public PapPolicyIdentifier(final String name, final String version) {
+ this.name = name;
+ this.version = version;
+ }
+
+ public PapPolicyIdentifier(@NonNull final ToscaConceptIdentifier identifier) {
+ this(identifier.getName(), identifier.getVersion());
+ }
+
+ public PapPolicyIdentifier(@NonNull final ToscaConceptIdentifierOptVersion identifier) {
+ this(identifier.getName(), identifier.getVersion());
+ }
+
+ public ToscaConceptIdentifierOptVersion getGenericIdentifier() {
+ return name == null ? new ToscaConceptIdentifierOptVersion()
+ : new ToscaConceptIdentifierOptVersion(name, version);
+ }
+}
-/*
+/*-
* ============LICENSE_START=======================================================
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.models.pap.concepts;
import java.util.List;
-import lombok.Getter;
-import lombok.Setter;
+import java.util.stream.Collectors;
import lombok.ToString;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifierOptVersion;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
/**
- * Request deploy or update a set of policies using the <i>simple</i> PDP Group deployment
- * REST API. Only the "name" and "version" fields of a Policy are used, and only the
- * "name" field is actually required.
+ * Request deploy or update a set of policies using the <i>simple</i> PDP Group deployment REST API. Only the "name" and
+ * "version" fields of a Policy are used, and only the "name" field is actually required.
*/
-@Getter
-@Setter
@ToString
public class PdpDeployPolicies {
- private List<ToscaPolicyIdentifierOptVersion> policies;
+ private List<PapPolicyIdentifier> policies;
+
+ /**
+ * Get the identifiers of the policies on the list.
+ *
+ * @return The list of identifiers
+ */
+ public List<ToscaConceptIdentifierOptVersion> getPolicies() {
+ return policies == null ? null
+ : policies.stream().map(PapPolicyIdentifier::getGenericIdentifier).collect(Collectors.toList());
+ }
+
+ /**
+ * Set the identifiers of the policies on the list.
+ *
+ * @param policies The list of identifiers
+ */
+ public void setPolicies(final List<ToscaConceptIdentifierOptVersion> policies) {
+ this.policies =
+ policies == null ? null : policies.stream().map(PapPolicyIdentifier::new).collect(Collectors.toList());
+ }
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@Data
@NoArgsConstructor
* @param policy policy identifier, from which the name and version are to be
* extracted
*/
- public PolicyStatus(ToscaPolicyTypeIdentifier policyType, ToscaPolicyIdentifier policy) {
+ public PolicyStatus(ToscaConceptIdentifier policyType, ToscaConceptIdentifier policy) {
this.policyTypeId = policyType.getName();
this.policyTypeVersion = policyType.getVersion();
this.policyId = policy.getName();
this.policyVersion = policy.getVersion();
}
- public ToscaPolicyTypeIdentifier getPolicyType() {
- return new ToscaPolicyTypeIdentifier(policyTypeId, policyTypeVersion);
+ public ToscaConceptIdentifier getPolicyType() {
+ return new ToscaConceptIdentifier(policyTypeId, policyTypeVersion);
}
- public ToscaPolicyIdentifier getPolicy() {
- return new ToscaPolicyIdentifier(policyId, policyVersion);
+ public ToscaConceptIdentifier getPolicy() {
+ return new ToscaConceptIdentifier(policyId, policyVersion);
}
}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.pap.concepts;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.IOException;
+import org.junit.Test;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.TextFileUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
+
+/**
+ * This only tests the methods that aren't already tested via TestModels.
+ */
+public class PapPolicyIdentifierTest {
+
+ @Test
+ public void testPapPolicyIdentifier() throws CoderException {
+ assertNotNull(new PapPolicyIdentifier("Name", "Version"));
+ assertNotNull(new PapPolicyIdentifier("Name", null));
+ assertNotNull(new PapPolicyIdentifier(null, null));
+
+ assertNotNull(new PapPolicyIdentifier(new ToscaConceptIdentifier("Name", "Version")));
+ assertNotNull(new PapPolicyIdentifier(new ToscaConceptIdentifierOptVersion("Name", "Version")));
+
+ assertThatThrownBy(() -> new PapPolicyIdentifier((ToscaConceptIdentifier) null))
+ .isInstanceOf(NullPointerException.class);
+
+ assertThatThrownBy(() -> new PapPolicyIdentifier((ToscaConceptIdentifierOptVersion) null))
+ .isInstanceOf(NullPointerException.class);
+
+ PapPolicyIdentifier ppi = new PapPolicyIdentifier("myname", "1.2.3");
+
+ assertEquals("myname", ppi.getGenericIdentifier().getName());
+ assertEquals("1.2.3", ppi.getGenericIdentifier().getVersion());
+
+ PapPolicyIdentifier ppi2 = new PapPolicyIdentifier(null, null);
+ assertNull(ppi2.getGenericIdentifier().getName());
+ assertNull(ppi2.getGenericIdentifier().getVersion());
+ }
+
+ @Test
+ public void testPapPolicyIdentifierSerialization() throws CoderException, IOException {
+ String idString = TextFileUtils.getTextFileAsString("src/test/resources/json/PapPolicyIdentifier.json");
+
+ StandardCoder coder = new StandardCoder();
+
+ PapPolicyIdentifier ppi = coder.decode(idString, PapPolicyIdentifier.class);
+
+ assertEquals("MyPolicy", ppi.getGenericIdentifier().getName());
+ assertEquals("1.2.6", ppi.getGenericIdentifier().getVersion());
+
+ String idStringBack = coder.encode(ppi);
+ assertEquals(idString.replaceAll("\\s+", ""), idStringBack.replaceAll("\\s+", ""));
+ }
+}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.pap.concepts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.TextFileUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifierOptVersion;
+
+/**
+ * This only tests the methods that aren't already tested via TestModels.
+ */
+public class PdpDeployPoliciesTest {
+ @Test
+ public void testPapPolicyIdentifier() throws CoderException, IOException {
+ assertNotNull(new PdpDeployPolicies());
+
+ List<ToscaConceptIdentifierOptVersion> tciListIn = new ArrayList<>();
+
+ ToscaConceptIdentifierOptVersion tci0 = new ToscaConceptIdentifierOptVersion("MyPolicy0", "1.2.0");
+ tciListIn.add(tci0);
+ ToscaConceptIdentifierOptVersion tci1 = new ToscaConceptIdentifierOptVersion("MyPolicy1", "1.2.1");
+ tciListIn.add(tci1);
+ ToscaConceptIdentifierOptVersion tci2 = new ToscaConceptIdentifierOptVersion("MyPolicy2", "1.2.2");
+ tciListIn.add(tci2);
+
+ PdpDeployPolicies policies = new PdpDeployPolicies();
+ policies.setPolicies(null);
+ assertNull(policies.getPolicies());
+
+ policies.setPolicies(tciListIn);
+
+ assertEquals(3, policies.getPolicies().size());
+
+ assertEquals("MyPolicy0", policies.getPolicies().get(0).getName());
+ assertEquals("1.2.0", policies.getPolicies().get(0).getVersion());
+ assertEquals("MyPolicy1", policies.getPolicies().get(1).getName());
+ assertEquals("1.2.1", policies.getPolicies().get(1).getVersion());
+ assertEquals("MyPolicy2", policies.getPolicies().get(2).getName());
+ assertEquals("1.2.2", policies.getPolicies().get(2).getVersion());
+
+ List<ToscaConceptIdentifierOptVersion> tciListOut = policies.getPolicies();
+ assertEquals(tciListIn, tciListOut);
+ }
+
+ @Test
+ public void testPapPolicyIdentifierSerialization() throws CoderException, IOException {
+ String idListString = TextFileUtils.getTextFileAsString("src/test/resources/json/PapPoliciesList.json");
+
+ StandardCoder coder = new StandardCoder();
+
+ PdpDeployPolicies policies = coder.decode(idListString, PdpDeployPolicies.class);
+
+ assertEquals(3, policies.getPolicies().size());
+
+ assertEquals("MyPolicy0", policies.getPolicies().get(0).getName());
+ assertEquals("1.2.0", policies.getPolicies().get(0).getVersion());
+ assertEquals("MyPolicy1", policies.getPolicies().get(1).getName());
+ assertEquals("1.2.1", policies.getPolicies().get(1).getVersion());
+ assertEquals("MyPolicy2", policies.getPolicies().get(2).getName());
+ assertEquals("1.2.2", policies.getPolicies().get(2).getVersion());
+
+ String idListStringBack = coder.encode(policies);
+ assertEquals(idListString.replaceAll("\\s+", ""), idListStringBack.replaceAll("\\s+", ""));
+ }
+}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.junit.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* This only tests the methods that aren't already tested via TestModels.
@Test
public void test() throws CoderException {
- ToscaPolicyTypeIdentifier type = new ToscaPolicyTypeIdentifier("my-type", "3.2.1");
- ToscaPolicyIdentifier policy = new ToscaPolicyIdentifier("my-name", "1.2.3");
+ ToscaConceptIdentifier type = new ToscaConceptIdentifier("my-type", "3.2.1");
+ ToscaConceptIdentifier policy = new ToscaConceptIdentifier("my-name", "1.2.3");
// test constructor with arguments
PolicyStatus status = new PolicyStatus(type, policy);
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.models.pap.concepts;
-import com.openpojo.reflection.filters.FilterPackageInfo;
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.impl.PojoClassFactory;
import com.openpojo.validation.Validator;
import com.openpojo.validation.ValidatorBuilder;
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
+import java.util.List;
import org.junit.Test;
import org.onap.policy.common.utils.test.ToStringTester;
@Test
public void testPapModels() {
- final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterTester())
- .with(new GetterTester()).build();
- validator.validate(TestModels.class.getPackage().getName(), new FilterPackageInfo());
+ List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses(TestModels.class.getPackage().getName());
+
+ // @formatter:off
+ final Validator validator =
+ ValidatorBuilder.create()
+ .with(new ToStringTester())
+ .with(new SetterTester())
+ .with(new GetterTester())
+ .build();
+ // @formatter:on
+
+ pojoClasses.remove(PojoClassFactory.getPojoClass(PdpDeployPolicies.class));
+
+ validator.validate(pojoClasses);
}
}
--- /dev/null
+{
+ "policies": [
+ {
+ "policy-id" : "MyPolicy0",
+ "policy-version": "1.2.0"
+ },
+ {
+ "policy-id" : "MyPolicy1",
+ "policy-version": "1.2.1"
+ },
+ {
+ "policy-id" : "MyPolicy2",
+ "policy-version": "1.2.2"
+ }
+ ]
+}
--- /dev/null
+{
+ "policy-id" : "MyPolicy",
+ "policy-version": "1.2.6"
+}
\ No newline at end of file
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.models.base.PfUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* A deployment (i.e., set of policies) for all PDPs of the same pdp type running within a
private String pdpType;
private Action action;
- private List<ToscaPolicyIdentifier> policies;
+ private List<ToscaConceptIdentifier> policies;
/**
* Constructs the object.
public DeploymentSubGroup(@NonNull final DeploymentSubGroup source) {
this.pdpType = source.pdpType;
this.action = source.action;
- this.policies = PfUtils.mapList(source.policies, ToscaPolicyIdentifier::new, new ArrayList<>(0));
+ this.policies = PfUtils.mapList(source.policies, ToscaConceptIdentifier::new, new ArrayList<>(0));
}
/**
result.validateNotNull("pdpType", pdpType);
result.validateNotNull("action", action);
- result.validateNotNullList("policies", policies, ToscaPolicyIdentifier::validatePapRest);
+ result.validateNotNullList("policies", policies, ToscaConceptIdentifier::validatePapRest);
return result;
}
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import org.apache.commons.lang3.ObjectUtils;
import org.onap.policy.models.base.PfObjectFilter;
import org.onap.policy.models.pdp.enums.PdpState;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Filter class for searches for {@link PdpGroup} instances. If any fields are null, they are ignored.
private String pdpType;
// Set regular expressions on fields to match policy type names and versions
- private List<ToscaPolicyTypeIdentifier> policyTypeList;
+ private List<ToscaConceptIdentifier> policyTypeList;
// If set, only PDP groups where policy types are matched exactly are returned
@Builder.Default
private boolean matchPolicyTypesExactly = false;
// Set regular expressions on fields to match policy names and versions
- private List<ToscaPolicyIdentifier> policyList;
+ private List<ToscaConceptIdentifier> policyList;
// If set, only PDP groups where policies are matched exactly are returned
@Builder.Default
* @param matchPolicyTypesExactly if true, only PDP groups where policy types are matched exactly are returned
* @return true if the filter should let this PDP group through
*/
- private boolean filterOnPolicyTypeList(final PdpGroup pdpGroup, final List<ToscaPolicyTypeIdentifier> typeFilter,
+ private boolean filterOnPolicyTypeList(final PdpGroup pdpGroup, final List<ToscaConceptIdentifier> typeFilter,
final boolean matchPolicyTypesExactly) {
if (typeFilter == null) {
return true;
* @return true if one element of the elements to find is supported by an element on
* the list we searched
*/
- private boolean findSupportedPolicyType(List<ToscaPolicyTypeIdentifier> supportedPolicyTypes,
- List<ToscaPolicyTypeIdentifier> typeFilter) {
- for (ToscaPolicyTypeIdentifier supportedPolicyType : supportedPolicyTypes) {
+ private boolean findSupportedPolicyType(List<ToscaConceptIdentifier> supportedPolicyTypes,
+ List<ToscaConceptIdentifier> typeFilter) {
+ for (ToscaConceptIdentifier supportedPolicyType : supportedPolicyTypes) {
String supName = supportedPolicyType.getName();
if (supName.endsWith(".*")) {
String substr = supName.substring(0, supName.length() - 1);
* @param matchPoliciesExactly if true, only PDP groups where ps are matched exactly are returned
* @return true if the filter should let this PDP group through
*/
- private boolean filterOnPolicyList(final PdpGroup pdpGroup, final List<ToscaPolicyIdentifier> policyFilter,
+ private boolean filterOnPolicyList(final PdpGroup pdpGroup, final List<ToscaConceptIdentifier> policyFilter,
final boolean matchPoliciesExactly) {
if (policyFilter == null) {
return true;
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import org.onap.policy.models.pdp.enums.PdpHealthStatus;
import org.onap.policy.models.pdp.enums.PdpMessageType;
import org.onap.policy.models.pdp.enums.PdpState;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Class to represent the PDP_STATUS message that all the PDP's will send to PAP.
*/
private String description;
- private List<ToscaPolicyIdentifier> policies;
+ private List<ToscaConceptIdentifier> policies;
private String deploymentInstanceInfo;
private String properties;
private PdpStatistics statistics;
this.state = source.state;
this.healthy = source.healthy;
this.description = source.description;
- this.policies = PfUtils.mapList(source.policies, ToscaPolicyIdentifier::new, new ArrayList<>(0));
+ this.policies = PfUtils.mapList(source.policies, ToscaConceptIdentifier::new, new ArrayList<>(0));
this.deploymentInstanceInfo = source.deploymentInstanceInfo;
this.properties = source.properties;
this.statistics = (source.statistics == null ? null : new PdpStatistics(source.statistics));
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.models.base.PfUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Class to represent a group of all PDP's of the same pdp type running for a particular
@Data
public class PdpSubGroup {
private String pdpType;
- private List<ToscaPolicyTypeIdentifier> supportedPolicyTypes;
- private List<ToscaPolicyIdentifier> policies;
+ private List<ToscaConceptIdentifier> supportedPolicyTypes;
+ private List<ToscaConceptIdentifier> policies;
private int currentInstanceCount;
private int desiredInstanceCount;
private Map<String, String> properties;
*/
public PdpSubGroup(@NonNull final PdpSubGroup source) {
this.pdpType = source.pdpType;
- this.supportedPolicyTypes = PfUtils.mapList(source.supportedPolicyTypes, ToscaPolicyTypeIdentifier::new,
+ this.supportedPolicyTypes = PfUtils.mapList(source.supportedPolicyTypes, ToscaConceptIdentifier::new,
new ArrayList<>(0));
- this.policies = PfUtils.mapList(source.policies, ToscaPolicyIdentifier::new, new ArrayList<>(0));
+ this.policies = PfUtils.mapList(source.policies, ToscaConceptIdentifier::new, new ArrayList<>(0));
this.currentInstanceCount = source.currentInstanceCount;
this.desiredInstanceCount = source.desiredInstanceCount;
this.properties = (source.properties == null ? null : new LinkedHashMap<>(source.properties));
result.validateNotNull("pdpType", pdpType);
// When doing PdpGroup Update operation, supported policy types and policies doesn't have to be validated.
if (!updateGroupFlow) {
- result.validateNotNullList("policies", policies, ToscaPolicyIdentifier::validatePapRest);
+ result.validateNotNullList("policies", policies, ToscaConceptIdentifier::validatePapRest);
result.validateNotNullList("supportedPolicyTypes", supportedPolicyTypes,
- ToscaPolicyTypeIdentifier::validatePapRest);
+ ToscaConceptIdentifier::validatePapRest);
if (supportedPolicyTypes != null && supportedPolicyTypes.isEmpty()) {
result.addResult(new ObjectValidationResult("supportedPolicyTypes", supportedPolicyTypes,
* ONAP Policy Model
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.models.base.validation.annotations.VerifyKey;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Class to represent a PDP subgroup in the database.
pdpSubgroup.setSupportedPolicyTypes(new ArrayList<>());
for (PfSearchableKey supportedPolicyTypeKey : supportedPolicyTypes) {
- ToscaPolicyTypeIdentifier supportedPolicyTypeIdent = new ToscaPolicyTypeIdentifier(
+ ToscaConceptIdentifier supportedPolicyTypeIdent = new ToscaConceptIdentifier(
supportedPolicyTypeKey.getName(), supportedPolicyTypeKey.getVersion());
pdpSubgroup.getSupportedPolicyTypes().add(supportedPolicyTypeIdent);
}
pdpSubgroup.setPolicies(new ArrayList<>());
for (PfConceptKey policyKey : policies) {
- ToscaPolicyIdentifier toscaPolicyIdentifier = new ToscaPolicyIdentifier();
+ ToscaConceptIdentifier toscaPolicyIdentifier = new ToscaConceptIdentifier();
toscaPolicyIdentifier.setName(policyKey.getName());
toscaPolicyIdentifier.setVersion(policyKey.getVersion());
pdpSubgroup.getPolicies().add(toscaPolicyIdentifier);
this.supportedPolicyTypes = new ArrayList<>();
if (pdpSubgroup.getSupportedPolicyTypes() != null) {
- for (ToscaPolicyTypeIdentifier supportedPolicyType : pdpSubgroup.getSupportedPolicyTypes()) {
+ for (ToscaConceptIdentifier supportedPolicyType : pdpSubgroup.getSupportedPolicyTypes()) {
this.supportedPolicyTypes
.add(new PfSearchableKey(supportedPolicyType.getName(), supportedPolicyType.getVersion()));
}
this.policies = new ArrayList<>();
if (pdpSubgroup.getPolicies() != null) {
- for (ToscaPolicyIdentifier toscaPolicyIdentifier : pdpSubgroup.getPolicies()) {
+ for (ToscaConceptIdentifier toscaPolicyIdentifier : pdpSubgroup.getPolicies()) {
this.policies
.add(new PfConceptKey(toscaPolicyIdentifier.getName(), toscaPolicyIdentifier.getVersion()));
}
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.models.pdp.concepts.DeploymentSubGroup.Action;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Test methods not tested by {@link ModelsTest}.
orig.setPdpType("my-type");
orig.setAction(Action.POST);
- final ToscaPolicyIdentifier pol1 = new ToscaPolicyIdentifier();
+ final ToscaConceptIdentifier pol1 = new ToscaConceptIdentifier();
pol1.setName("policy-A");
pol1.setVersion("1.0.0");
- final ToscaPolicyIdentifier pol2 = new ToscaPolicyIdentifier();
+ final ToscaConceptIdentifier pol2 = new ToscaConceptIdentifier();
pol2.setName("policy-B");
pol1.setVersion("2.0.0");
orig.setPolicies(Arrays.asList(pol1, pol2));
subgrp.setPdpType("pdp-type");
subgrp.setAction(Action.PATCH);
- subgrp.setPolicies(Arrays.asList(makeIdent("policy-X", "4.0.0", ToscaPolicyIdentifier.class)));
+ subgrp.setPolicies(Arrays.asList(makeIdent("policy-X", "4.0.0", ToscaConceptIdentifier.class)));
// valid
ValidationResult result = subgrp.validatePapRest();
// invalid policy item
sub2 = new DeploymentSubGroup(subgrp);
- sub2.getPolicies().set(0, makeIdent(null, VERSION_300, ToscaPolicyIdentifier.class));
+ sub2.getPolicies().set(0, makeIdent(null, VERSION_300, ToscaConceptIdentifier.class));
assertInvalid(sub2);
}
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.pdp.enums.PdpState;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Test of the {@link PdpGroupFilter} class.
@Test
public void testFilterPolicyType() {
- List<ToscaPolicyTypeIdentifier> identifierList = new ArrayList<>();
+ List<ToscaConceptIdentifier> identifierList = new ArrayList<>();
- identifierList.add(new ToscaPolicyTypeIdentifier(NON_EXISTANT, VERSION1));
+ identifierList.add(new ToscaConceptIdentifier(NON_EXISTANT, VERSION1));
PdpGroupFilter filter =
PdpGroupFilter.builder().policyTypeList(identifierList).build();
List<PdpGroup> filteredList = filter.filter(pdpGroupList);
identifierList.clear();
// don't match wild cards
- identifierList.add(new ToscaPolicyTypeIdentifier(NON_EXISTANT, VERSION1));
+ identifierList.add(new ToscaConceptIdentifier(NON_EXISTANT, VERSION1));
filter = PdpGroupFilter.builder().policyTypeList(identifierList).build();
final List<PdpGroup> wildCards =
pdpGroupList.stream().map(this::makeWildCardPolicyTypes).collect(Collectors.toList());
identifierList.clear();
// match wild cards
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE0, VERSION1));
filter = PdpGroupFilter.builder().policyTypeList(identifierList).build();
filteredList = filter.filter(wildCards);
assertEquals(4, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE0, VERSION1));
filter = PdpGroupFilter.builder().policyTypeList(identifierList).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(4, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE1, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE1, VERSION4));
filter = PdpGroupFilter.builder().policyTypeList(identifierList).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(4, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE2, VERSION7));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE2, VERSION7));
filter = PdpGroupFilter.builder().policyTypeList(identifierList).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(2, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE3, VERSION0));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE3, VERSION0));
filter = PdpGroupFilter.builder().policyTypeList(identifierList).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(2, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyTypeIdentifier(NON_EXISTANT, VERSION1));
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION9));
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1));
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE1, VERSION4));
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE2, VERSION7));
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE3, VERSION0));
+ identifierList.add(new ToscaConceptIdentifier(NON_EXISTANT, VERSION1));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE0, VERSION9));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE0, VERSION1));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE1, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE2, VERSION7));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE3, VERSION0));
filter = PdpGroupFilter.builder().policyTypeList(identifierList).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(5, filteredList.size());
assertEquals(0, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE0, VERSION1));
filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(2, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1));
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE1, VERSION4));
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE2, VERSION7));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE0, VERSION1));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE1, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE2, VERSION7));
filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(1, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE0, VERSION1));
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE1, VERSION4));
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE3, VERSION0));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE0, VERSION1));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE1, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE3, VERSION0));
filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(1, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE1, VERSION4));
- identifierList.add(new ToscaPolicyTypeIdentifier(POLICY_TYPE3, VERSION0));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE1, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY_TYPE3, VERSION0));
filter = PdpGroupFilter.builder().policyTypeList(identifierList).matchPolicyTypesExactly(true).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(1, filteredList.size());
PdpGroup newGroup = new PdpGroup(group);
for (PdpSubGroup subgroup : newGroup.getPdpSubgroups()) {
- for (ToscaPolicyTypeIdentifier subType : subgroup.getSupportedPolicyTypes()) {
+ for (ToscaConceptIdentifier subType : subgroup.getSupportedPolicyTypes()) {
if (POLICY_TYPE0.equals(subType.getName())) {
subType.setName("policy.type.*");
}
@Test
public void testFilterPolicy() {
- List<ToscaPolicyIdentifier> identifierList = new ArrayList<>();
+ List<ToscaConceptIdentifier> identifierList = new ArrayList<>();
- identifierList.add(new ToscaPolicyIdentifier(NON_EXISTANT, VERSION1));
+ identifierList.add(new ToscaConceptIdentifier(NON_EXISTANT, VERSION1));
PdpGroupFilter filter =
PdpGroupFilter.builder().policyList(identifierList).build();
List<PdpGroup> filteredList = filter.filter(pdpGroupList);
assertEquals(0, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION9));
+ identifierList.add(new ToscaConceptIdentifier(POLICY0, VERSION9));
filter = PdpGroupFilter.builder().policyList(identifierList).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(0, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY0, VERSION4));
filter = PdpGroupFilter.builder().policyList(identifierList).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(4, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyIdentifier(POLICY1, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY1, VERSION4));
filter = PdpGroupFilter.builder().policyList(identifierList).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(1, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyIdentifier(POLICY2, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY2, VERSION4));
filter = PdpGroupFilter.builder().policyList(identifierList).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(2, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyIdentifier(POLICY3, VERSION1));
+ identifierList.add(new ToscaConceptIdentifier(POLICY3, VERSION1));
filter = PdpGroupFilter.builder().policyList(identifierList).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(1, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyIdentifier(NON_EXISTANT, VERSION1));
- identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION9));
- identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION4));
- identifierList.add(new ToscaPolicyIdentifier(POLICY1, VERSION4));
- identifierList.add(new ToscaPolicyIdentifier(POLICY2, VERSION4));
- identifierList.add(new ToscaPolicyIdentifier(POLICY3, VERSION1));
+ identifierList.add(new ToscaConceptIdentifier(NON_EXISTANT, VERSION1));
+ identifierList.add(new ToscaConceptIdentifier(POLICY0, VERSION9));
+ identifierList.add(new ToscaConceptIdentifier(POLICY0, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY1, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY2, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY3, VERSION1));
filter = PdpGroupFilter.builder().policyList(identifierList).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(5, filteredList.size());
assertEquals(0, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY0, VERSION4));
filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(3, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyIdentifier(POLICY0, VERSION4));
- identifierList.add(new ToscaPolicyIdentifier(POLICY1, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY0, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY1, VERSION4));
filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(1, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyIdentifier(POLICY2, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY2, VERSION4));
filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(1, filteredList.size());
identifierList.clear();
- identifierList.add(new ToscaPolicyIdentifier(POLICY2, VERSION4));
- identifierList.add(new ToscaPolicyIdentifier(POLICY3, VERSION1));
+ identifierList.add(new ToscaConceptIdentifier(POLICY2, VERSION4));
+ identifierList.add(new ToscaConceptIdentifier(POLICY3, VERSION1));
filter = PdpGroupFilter.builder().policyList(identifierList).matchPoliciesExactly(true).build();
filteredList = filter.filter(pdpGroupList);
assertEquals(1, filteredList.size());
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.junit.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.models.pdp.enums.PdpState;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Test methods not tested by {@link ModelsTest}.
PdpSubGroup subgroup1 = new PdpSubGroup();
subgroup1.setDesiredInstanceCount(1);
subgroup1.setPdpType(PDP_TYPE1);
- subgroup1.setSupportedPolicyTypes(Arrays.asList(new ToscaPolicyTypeIdentifier("a-type-name", "3.2.1")));
+ subgroup1.setSupportedPolicyTypes(Arrays.asList(new ToscaConceptIdentifier("a-type-name", "3.2.1")));
subgroup1.setPolicies(Collections.emptyList());
group.setPdpSubgroups(Arrays.asList(subgroup1));
PdpSubGroup subgroup1 = new PdpSubGroup();
subgroup1.setDesiredInstanceCount(1);
subgroup1.setPdpType(PDP_TYPE1);
- subgroup1.setSupportedPolicyTypes(Arrays.asList(new ToscaPolicyTypeIdentifier("a-type-name", "3.2.1")));
+ subgroup1.setSupportedPolicyTypes(Arrays.asList(new ToscaConceptIdentifier("a-type-name", "3.2.1")));
subgroup1.setPolicies(Collections.emptyList());
PdpSubGroup subgroup2 = new PdpSubGroup(subgroup1);
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.Map;
import org.junit.Test;
import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
public class PdpGroupsTest {
PdpSubGroup subgrp = new PdpSubGroup();
subgrp.setDesiredInstanceCount(1);
subgrp.setPdpType("pdp-type");
- subgrp.setSupportedPolicyTypes(Arrays.asList(new ToscaPolicyTypeIdentifier("policy-type", "9.8.7")));
+ subgrp.setSupportedPolicyTypes(Arrays.asList(new ToscaConceptIdentifier("policy-type", "9.8.7")));
subgrp.setPolicies(Collections.emptyList());
group1.setPdpSubgroups(Arrays.asList(subgrp));
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.junit.Test;
import org.onap.policy.models.pdp.enums.PdpHealthStatus;
import org.onap.policy.models.pdp.enums.PdpState;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
public class PdpStatusTest {
orig.setPdpGroup("my-group");
orig.setPdpSubgroup("my-subgroup");
orig.setPdpType("my-type");
- orig.setPolicies(Arrays.asList(new ToscaPolicyIdentifier("policy-A", "1.0.0")));
+ orig.setPolicies(Arrays.asList(new ToscaConceptIdentifier("policy-A", "1.0.0")));
orig.setProperties("my-properties");
final PdpResponseDetails resp = new PdpResponseDetails();
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* Test methods not tested by {@link ModelsTest}.
orig.setPdpType("my-type");
- final ToscaPolicyIdentifier pol1 = new ToscaPolicyIdentifier();
+ final ToscaConceptIdentifier pol1 = new ToscaConceptIdentifier();
pol1.setName("policy-A");
pol1.setVersion("1.0.0");
- final ToscaPolicyIdentifier pol2 = new ToscaPolicyIdentifier();
+ final ToscaConceptIdentifier pol2 = new ToscaConceptIdentifier();
pol2.setName("policy-B");
pol1.setVersion("2.0.0");
orig.setPolicies(Arrays.asList(pol1, pol2));
props.put("key-B", "value-B");
orig.setProperties(props);
- final ToscaPolicyTypeIdentifier supp1 = new ToscaPolicyTypeIdentifier("supp-A", "1.2");
- final ToscaPolicyTypeIdentifier supp2 = new ToscaPolicyTypeIdentifier("supp-B", "3.4");
+ final ToscaConceptIdentifier supp1 = new ToscaConceptIdentifier("supp-A", "1.2");
+ final ToscaConceptIdentifier supp2 = new ToscaConceptIdentifier("supp-B", "3.4");
orig.setSupportedPolicyTypes(Arrays.asList(supp1, supp2));
assertEquals(orig.toString(), new PdpSubGroup(orig).toString());
subgrp.setDesiredInstanceCount(1);
subgrp.setPdpType("pdp-type");
subgrp.setSupportedPolicyTypes(
- Arrays.asList(makeIdent("type-X", VERSION_300, ToscaPolicyTypeIdentifier.class)));
- subgrp.setPolicies(Arrays.asList(makeIdent("policy-X", "4.0.0", ToscaPolicyIdentifier.class)));
+ Arrays.asList(makeIdent("type-X", VERSION_300, ToscaConceptIdentifier.class)));
+ subgrp.setPolicies(Arrays.asList(makeIdent("policy-X", "4.0.0", ToscaConceptIdentifier.class)));
ValidationResult result = subgrp.validatePapRest(false);
assertNotNull(result);
subgrp.setDesiredInstanceCount(1);
subgrp.setPdpType("pdp-type");
subgrp.setSupportedPolicyTypes(
- Arrays.asList(makeIdent("type-X", VERSION_300, ToscaPolicyTypeIdentifier.class)));
- subgrp.setPolicies(Arrays.asList(makeIdent("policy-X", "4.0.0", ToscaPolicyIdentifier.class)));
+ Arrays.asList(makeIdent("type-X", VERSION_300, ToscaConceptIdentifier.class)));
+ subgrp.setPolicies(Arrays.asList(makeIdent("policy-X", "4.0.0", ToscaConceptIdentifier.class)));
// valid
ValidationResult result = subgrp.validatePapRest(false);
// invalid policy type item
sub2 = new PdpSubGroup(subgrp);
- sub2.getSupportedPolicyTypes().set(0, makeIdent(null, VERSION_300, ToscaPolicyTypeIdentifier.class));
+ sub2.getSupportedPolicyTypes().set(0, makeIdent(null, VERSION_300, ToscaConceptIdentifier.class));
assertInvalid(sub2);
// null policies
// invalid policy item
sub2 = new PdpSubGroup(subgrp);
- sub2.getPolicies().set(0, makeIdent(null, VERSION_300, ToscaPolicyIdentifier.class));
+ sub2.getPolicies().set(0, makeIdent(null, VERSION_300, ToscaConceptIdentifier.class));
assertInvalid(sub2);
}
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.enums.PdpHealthStatus;
import org.onap.policy.models.pdp.enums.PdpState;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.simple.provider.SimpleToscaProvider;
/**
assertEquals(5, new PdpProvider().createPdpGroups(pfDao, pdpGroups0.getGroups()).size());
- List<ToscaPolicyTypeIdentifier> policyTypeList = new ArrayList<>();
- policyTypeList.add(new ToscaPolicyTypeIdentifier("policy.type.0", "1.2.3"));
+ List<ToscaConceptIdentifier> policyTypeList = new ArrayList<>();
+ policyTypeList.add(new ToscaConceptIdentifier("policy.type.0", "1.2.3"));
- List<ToscaPolicyIdentifier> policyList = new ArrayList<>();
- policyList.add(new ToscaPolicyIdentifier("Policy0", "4.5.6"));
+ List<ToscaConceptIdentifier> policyList = new ArrayList<>();
+ policyList.add(new ToscaConceptIdentifier("Policy0", "4.5.6"));
// @formatter:off
final PdpGroupFilter filter = PdpGroupFilter.builder()
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
import org.onap.policy.models.pdp.persistence.provider.PdpStatisticsProvider;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplateFilter;
import org.onap.policy.models.tosca.authorative.provider.AuthorativeToscaProvider;
throws PfModelException {
assertInitialized();
- ToscaPolicyTypeIdentifier policyTypeIdentifier = new ToscaPolicyTypeIdentifier(name, version);
+ ToscaConceptIdentifier policyTypeIdentifier = new ToscaConceptIdentifier(name, version);
assertPolicyTypeNotSupportedInPdpGroup(policyTypeIdentifier);
return new AuthorativeToscaProvider().deletePolicyType(pfDao, name, version);
throws PfModelException {
assertInitialized();
- ToscaPolicyIdentifier policyIdentifier = new ToscaPolicyIdentifier(name, version);
+ ToscaConceptIdentifier policyIdentifier = new ToscaConceptIdentifier(name, version);
assertPolicyNotDeployedInPdpGroup(policyIdentifier);
return new AuthorativeToscaProvider().deletePolicy(pfDao, name, version);
* @param policyTypeIdentifier the policy type identifier
* @throws PfModelException if the policy type is supported in a PDP group
*/
- private void assertPolicyTypeNotSupportedInPdpGroup(ToscaPolicyTypeIdentifier policyTypeIdentifier)
+ private void assertPolicyTypeNotSupportedInPdpGroup(ToscaConceptIdentifier policyTypeIdentifier)
throws PfModelException {
for (PdpGroup pdpGroup : getPdpGroups(null)) {
for (PdpSubGroup pdpSubGroup : pdpGroup.getPdpSubgroups()) {
* @param policyIdentifier the identifier of the policy
* @throws PfModelException thrown if the policy is deployed in a PDP group
*/
- private void assertPolicyNotDeployedInPdpGroup(final ToscaPolicyIdentifier policyIdentifier)
+ private void assertPolicyNotDeployedInPdpGroup(final ToscaConceptIdentifier policyIdentifier)
throws PfModelException {
for (PdpGroup pdpGroup : getPdpGroups(null)) {
for (PdpSubGroup pdpSubGroup : pdpGroup.getPdpSubgroups()) {
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderFactory;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
}).hasMessageMatching("^parameters is marked .*on.*ull but is null$");
PolicyModelsProvider databaseProvider =
- new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
+ new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
parameters.setDatabaseUrl("jdbc://www.acmecorp.nonexist");
public void testProviderMethodsNull() throws Exception {
PolicyModelsProvider databaseProvider =
- new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
+ new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
assertThatThrownBy(() -> {
databaseProvider.getFilteredPolicyTypes(null);
@Test
public void testProviderMethodsNotInit() throws Exception {
PolicyModelsProvider databaseProvider =
- new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
+ new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
databaseProvider.close();
@Test
public void testProviderMethods() throws PfModelException {
PolicyModelsProvider databaseProvider =
- new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
+ new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
assertThatThrownBy(() -> databaseProvider.getPolicyTypes(NAME, VERSION_100))
- .hasMessage("service template not found in database");
+ .hasMessage("service template not found in database");
assertTrue(databaseProvider.getPolicyTypeList(NAME, VERSION_100).isEmpty());
assertThatThrownBy(() -> databaseProvider.getFilteredPolicyTypes(ToscaPolicyTypeFilter.builder().build()))
- .hasMessage("service template not found in database");
+ .hasMessage("service template not found in database");
assertTrue(databaseProvider.getFilteredPolicyTypeList(ToscaPolicyTypeFilter.builder().build()).isEmpty());
}).hasMessage("no policy types specified on service template");
assertThatThrownBy(() -> databaseProvider.deletePolicyType(NAME, VERSION_100))
- .hasMessage("service template not found in database");
+ .hasMessage("service template not found in database");
assertThatThrownBy(() -> databaseProvider.getPolicies(NAME, VERSION_100))
- .hasMessage("service template not found in database");
+ .hasMessage("service template not found in database");
assertTrue(databaseProvider.getPolicyList(NAME, VERSION_100).isEmpty());
assertThatThrownBy(() -> databaseProvider.getFilteredPolicies(ToscaPolicyFilter.builder().build()))
- .hasMessage("service template not found in database");
+ .hasMessage("service template not found in database");
assertTrue(databaseProvider.getFilteredPolicyList(ToscaPolicyFilter.builder().build()).isEmpty());
}).hasMessage("topology template not specified on service template");
assertThatThrownBy(() -> databaseProvider.deletePolicy("Policy", "0.0.0").getToscaTopologyTemplate())
- .hasMessage("service template not found in database");
+ .hasMessage("service template not found in database");
assertEquals(0, databaseProvider.getPdpGroups(NAME).size());
assertEquals(0, databaseProvider.getFilteredPdpGroups(PdpGroupFilter.builder().build()).size());
pdpSubGroup.setPdpType("type");
pdpSubGroup.setDesiredInstanceCount(123);
pdpSubGroup.setSupportedPolicyTypes(new ArrayList<>());
- pdpSubGroup.getSupportedPolicyTypes().add(new ToscaPolicyTypeIdentifier("type", "7.8.9"));
+ pdpSubGroup.getSupportedPolicyTypes().add(new ToscaConceptIdentifier("type", "7.8.9"));
pdpGroup.getPdpSubgroups().add(pdpSubGroup);
Pdp pdp = new Pdp();
statisticsArrayList.add(pdpStatistics);
assertEquals(123,
- databaseProvider.createPdpGroups(groupList).get(0).getPdpSubgroups().get(0).getDesiredInstanceCount());
+ databaseProvider.createPdpGroups(groupList).get(0).getPdpSubgroups().get(0).getDesiredInstanceCount());
assertEquals(1, databaseProvider.getPdpGroups(GROUP).size());
pdpSubGroup.setDesiredInstanceCount(234);
databaseProvider.updatePdpSubGroup(GROUP, pdpSubGroup);
assertEquals(234,
- databaseProvider.getPdpGroups(GROUP).get(0).getPdpSubgroups().get(0).getDesiredInstanceCount());
+ databaseProvider.getPdpGroups(GROUP).get(0).getPdpSubgroups().get(0).getDesiredInstanceCount());
- assertEquals("Hello",
- databaseProvider.getPdpGroups(GROUP).get(0).getPdpSubgroups().get(0).getPdpInstances().get(0).getMessage());
+ assertEquals("Hello", databaseProvider.getPdpGroups(GROUP).get(0).getPdpSubgroups().get(0).getPdpInstances()
+ .get(0).getMessage());
pdp.setMessage("Howdy");
databaseProvider.updatePdp(GROUP, "type", pdp);
- assertEquals("Howdy",
- databaseProvider.getPdpGroups(GROUP).get(0).getPdpSubgroups().get(0).getPdpInstances().get(0).getMessage());
+ assertEquals("Howdy", databaseProvider.getPdpGroups(GROUP).get(0).getPdpSubgroups().get(0).getPdpInstances()
+ .get(0).getMessage());
assertThatThrownBy(() -> {
databaseProvider.deletePdpGroup(NAME);
assertEquals(NAME, databaseProvider.getPdpStatistics(null, null).get(0).getPdpInstanceId());
assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(null, GROUP, null, null, null, ORDER, 0).get(0)
- .getPdpInstanceId());
+ .getPdpInstanceId());
assertEquals(0,
- databaseProvider.getFilteredPdpStatistics(null, GROUP, null, new Date(), null, ORDER, 0).size());
+ databaseProvider.getFilteredPdpStatistics(null, GROUP, null, new Date(), null, ORDER, 0).size());
assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(null, GROUP, null, null, new Date(), ORDER, 0)
- .get(0).getPdpInstanceId());
+ .get(0).getPdpInstanceId());
assertEquals(0,
- databaseProvider.getFilteredPdpStatistics(null, GROUP, null, new Date(), new Date(), ORDER, 0).size());
+ databaseProvider.getFilteredPdpStatistics(null, GROUP, null, new Date(), new Date(), ORDER, 0).size());
assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, null, null, null, ORDER, 0).get(0)
- .getPdpInstanceId());
+ .getPdpInstanceId());
assertEquals(0,
- databaseProvider.getFilteredPdpStatistics(NAME, GROUP, null, new Date(), new Date(), ORDER, 0).size());
+ databaseProvider.getFilteredPdpStatistics(NAME, GROUP, null, new Date(), new Date(), ORDER, 0).size());
assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", null, null, ORDER, 0).get(0)
- .getPdpInstanceId());
- assertEquals(0,
- databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", new Date(), new Date(), ORDER, 0).size());
+ .getPdpInstanceId());
+ assertEquals(0, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", new Date(), new Date(), ORDER, 0)
+ .size());
assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", null, null, ORDER, 1).get(0)
- .getPdpInstanceId());
+ .getPdpInstanceId());
assertEquals(NAME, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", null, null, ORDER, 5).get(0)
- .getPdpInstanceId());
- assertEquals(0,
- databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", new Date(), new Date(), ORDER, 5).size());
+ .getPdpInstanceId());
+ assertEquals(0, databaseProvider.getFilteredPdpStatistics(NAME, GROUP, "type", new Date(), new Date(), ORDER, 5)
+ .size());
assertEquals(NAME, databaseProvider.deletePdpStatistics(NAME, null).get(0).getPdpInstanceId());
assertEquals(0, databaseProvider.getPdpStatistics(null, null).size());
@Test
public void testDeletePolicyDeployedInSubgroup() throws PfModelException {
- List<ToscaPolicyIdentifier> policies = new ArrayList<>();
+ List<ToscaConceptIdentifier> policies = new ArrayList<>();
- policies.add(new ToscaPolicyIdentifier("p0", "0.0.1"));
- policies.add(new ToscaPolicyIdentifier("p1", "0.0.1"));
+ policies.add(new ToscaConceptIdentifier("p0", "0.0.1"));
+ policies.add(new ToscaConceptIdentifier("p1", "0.0.1"));
- List<ToscaPolicyTypeIdentifier> supportedPolicyTypes = new ArrayList<>();
- supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier("pt2", "0.0.1"));
+ List<ToscaConceptIdentifier> supportedPolicyTypes = new ArrayList<>();
+ supportedPolicyTypes.add(new ToscaConceptIdentifier("pt2", "0.0.1"));
PdpSubGroup subGroup = new PdpSubGroup();
subGroup.setPdpType("pdpType");
pdpGroups.add(pdpGroup);
PolicyModelsProvider databaseProvider =
- new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
+ new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
databaseProvider.createPdpGroups(pdpGroups);
assertThatThrownBy(() -> databaseProvider.deletePolicy("p0", "0.0.1"))
- .hasMessageContaining("policy is in use, it is deployed in PDP group pdpGroup subgroup pdpType");
+ .hasMessageContaining("policy is in use, it is deployed in PDP group pdpGroup subgroup pdpType");
assertThatThrownBy(() -> databaseProvider.deletePolicy("p3", "0.0.1"))
- .hasMessageContaining("service template not found in database");
+ .hasMessageContaining("service template not found in database");
databaseProvider.close();
}
@Test
public void testDeletePolicyTypeSupportedInSubgroup() throws PfModelException {
- List<ToscaPolicyTypeIdentifier> supportedPolicyTypes = new ArrayList<>();
- supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier("pt1", "0.0.1"));
- supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier("pt2", "0.0.1"));
+ List<ToscaConceptIdentifier> supportedPolicyTypes = new ArrayList<>();
+ supportedPolicyTypes.add(new ToscaConceptIdentifier("pt1", "0.0.1"));
+ supportedPolicyTypes.add(new ToscaConceptIdentifier("pt2", "0.0.1"));
PdpSubGroup subGroup = new PdpSubGroup();
subGroup.setPdpType("pdpType");
pdpGroups.add(pdpGroup);
PolicyModelsProvider databaseProvider =
- new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
+ new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
databaseProvider.createPdpGroups(pdpGroups);
assertThatThrownBy(() -> databaseProvider.deletePolicyType("pt2", "0.0.1"))
- .hasMessageContaining("policy type is in use, it is referenced in PDP group pdpGroup subgroup pdpType");
+ .hasMessageContaining("policy type is in use, it is referenced in PDP group pdpGroup subgroup pdpType");
assertThatThrownBy(() -> databaseProvider.deletePolicyType("pt0", "0.0.1"))
- .hasMessageContaining("service template not found in database");
+ .hasMessageContaining("service template not found in database");
databaseProvider.close();
}
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.models.sim.pdp.PdpSimulatorConstants;
import org.onap.policy.models.sim.pdp.parameters.PdpStatusParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
/**
* This class supports the handling of pdp messages.
*
* @return policyTypeIdentifiers
*/
- public List<ToscaPolicyIdentifier> getToscaPolicyIdentifiers(final List<ToscaPolicy> policies) {
- final List<ToscaPolicyIdentifier> policyIdentifiers = new ArrayList<>(policies.size());
+ public List<ToscaConceptIdentifier> getToscaPolicyIdentifiers(final List<ToscaPolicy> policies) {
+ final List<ToscaConceptIdentifier> policyIdentifiers = new ArrayList<>(policies.size());
for (final ToscaPolicy policy : policies) {
if (null != policy.getName() && null != policy.getVersion()) {
- policyIdentifiers.add(new ToscaPolicyIdentifier(policy.getName(), policy.getVersion()));
+ policyIdentifiers.add(new ToscaConceptIdentifier(policy.getName(), policy.getVersion()));
}
}
return policyIdentifiers;
-/*
+/*-
* ============LICENSE_START=======================================================
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.onap.policy.common.parameters.ValidationResult;
/**
- * Identifies a policy. Both the name and version must be non-null.
+ * Identifies a concept. Both the name and version must be non-null.
*/
@Data
@NoArgsConstructor
-public class ToscaPolicyIdentifier implements Comparable<ToscaPolicyIdentifier> {
+public class ToscaConceptIdentifier implements Comparable<ToscaConceptIdentifier> {
@NonNull
private String name;
private String version;
- public ToscaPolicyIdentifier(@NonNull String name, @NonNull String version) {
+ public ToscaConceptIdentifier(@NonNull String name, @NonNull String version) {
this.name = name;
this.version = version;
}
- public ToscaPolicyIdentifier(ToscaPolicyIdentifier source) {
+ public ToscaConceptIdentifier(ToscaConceptIdentifier source) {
this.name = source.name;
this.version = source.version;
}
/**
- * Validates that appropriate fields are populated for an incoming call to the PAP
- * REST API.
+ * Validates that appropriate fields are populated for an incoming call to the PAP REST API.
*
* @return the validation result
*/
}
@Override
- public int compareTo(ToscaPolicyIdentifier other) {
+ public int compareTo(ToscaConceptIdentifier other) {
if (this == other) {
return 0;
}
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.models.tosca.authorative.concepts;
-import com.google.gson.annotations.SerializedName;
-import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import org.apache.commons.lang3.ObjectUtils;
/**
- * Policy identifier with an optional version; only the "name" is required.
+ * Concept identifier with an optional version; only the "name" is required.
*/
@Data
@NoArgsConstructor
-public class ToscaPolicyIdentifierOptVersion implements Comparable<ToscaPolicyIdentifierOptVersion> {
+public class ToscaConceptIdentifierOptVersion implements Comparable<ToscaConceptIdentifierOptVersion> {
@NonNull
- @ApiModelProperty(name = "policy-id")
- @SerializedName("policy-id")
private String name;
- @ApiModelProperty(name = "policy-version")
- @SerializedName("policy-version")
private String version;
-
- public ToscaPolicyIdentifierOptVersion(@NonNull String name, String version) {
+ public ToscaConceptIdentifierOptVersion(@NonNull String name, String version) {
this.name = name;
this.version = version;
}
- public ToscaPolicyIdentifierOptVersion(ToscaPolicyIdentifierOptVersion source) {
+ public ToscaConceptIdentifierOptVersion(ToscaConceptIdentifierOptVersion source) {
this.name = source.name;
this.version = source.version;
}
- public ToscaPolicyIdentifierOptVersion(ToscaPolicyIdentifier source) {
+ public ToscaConceptIdentifierOptVersion(ToscaConceptIdentifier source) {
this.name = source.getName();
this.version = source.getVersion();
}
@Override
- public int compareTo(ToscaPolicyIdentifierOptVersion other) {
+ public int compareTo(ToscaConceptIdentifierOptVersion other) {
if (this == other) {
return 0;
}
* ONAP Policy Model
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* @return this policy's identifier
*/
- public ToscaPolicyIdentifier getIdentifier() {
- return new ToscaPolicyIdentifier(getName(), getVersion());
+ public ToscaConceptIdentifier getIdentifier() {
+ return new ToscaConceptIdentifier(getName(), getVersion());
}
/**
*
* @return this policy's type identifier
*/
- public ToscaPolicyTypeIdentifier getTypeIdentifier() {
- return new ToscaPolicyTypeIdentifier(getType(), getTypeVersion());
+ public ToscaConceptIdentifier getTypeIdentifier() {
+ return new ToscaConceptIdentifier(getType(), getTypeVersion());
}
}
+++ /dev/null
-/*
- * ============LICENSE_START=======================================================
- * ONAP Policy Models
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.models.tosca.authorative.concepts;
-
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.NonNull;
-import org.apache.commons.lang3.ObjectUtils;
-import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.parameters.ValidationResult;
-
-/**
- * Identifies a policy type. Both the name and version must be non-null.
- */
-@Data
-@NoArgsConstructor
-public class ToscaPolicyTypeIdentifier implements Comparable<ToscaPolicyTypeIdentifier> {
-
- @NonNull
- private String name;
-
- @NonNull
- private String version;
-
-
- public ToscaPolicyTypeIdentifier(@NonNull String name, @NonNull String version) {
- this.name = name;
- this.version = version;
- }
-
- public ToscaPolicyTypeIdentifier(ToscaPolicyTypeIdentifier source) {
- this.name = source.name;
- this.version = source.version;
- }
-
- /**
- * Validates that appropriate fields are populated for an incoming call to the PAP
- * REST API.
- *
- * @return the validation result
- */
- public ValidationResult validatePapRest() {
- BeanValidationResult result = new BeanValidationResult("group", this);
-
- result.validateNotNull("name", name);
- result.validateNotNull("version", version);
-
- return result;
- }
-
- @Override
- public int compareTo(ToscaPolicyTypeIdentifier other) {
- if (this == other) {
- return 0;
- }
-
- if (other == null) {
- return 1;
- }
-
- int result = ObjectUtils.compare(getName(), other.getName());
- if (result != 0) {
- return result;
- }
-
- return ObjectUtils.compare(getVersion(), other.getVersion());
- }
-
- @Override
- public String toString() {
- return this.name + " " + this.version;
- }
-}
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 Nordix Foundation.
+ * Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
public void fromAuthorative(ToscaServiceTemplate toscaServiceTemplate) {
super.fromAuthorative(toscaServiceTemplate);
- if (PfKey.NULL_KEY_NAME.equals(getKey().getName())) {
+ if (toscaServiceTemplate.getDefinedName() == null) {
getKey().setName(DEFAULT_NAME);
}
- if (PfKey.NULL_KEY_VERSION.equals(getKey().getVersion())) {
+ if (toscaServiceTemplate.getDefinedVersion() == null) {
getKey().setVersion(DEFAULT_VERSION);
}
* @param dataTypeKeyCollection the data type key collection
* @param result where the results are added
*/
- private void validateReferencedDataTypesExists(
- final Collection<PfConceptKey> dataTypeKeyCollection, final BeanValidationResult result) {
+ private void validateReferencedDataTypesExists(final Collection<PfConceptKey> dataTypeKeyCollection,
+ final BeanValidationResult result) {
for (PfConceptKey dataTypeKey : dataTypeKeyCollection) {
if (dataTypes == null || dataTypes.get(dataTypeKey) == null) {
addResult(result, "data type", dataTypeKey.getId(), NOT_FOUND);
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* Test the other constructors, as {@link PojosTest} tests the other methods.
*/
-public class ToscaPolicyIdentifierOptVersionTest extends ToscaIdentifierTestBase<ToscaPolicyIdentifierOptVersion> {
+public class ToscaConceptIdentifierOptVersionTest extends ToscaIdentifierTestBase<ToscaConceptIdentifierOptVersion> {
- public ToscaPolicyIdentifierOptVersionTest() {
- super(ToscaPolicyIdentifierOptVersion.class, "policy-id", "policy-version");
+ public ToscaConceptIdentifierOptVersionTest() {
+ super(ToscaConceptIdentifierOptVersion.class, "name", "version");
}
@Test
public void testAllArgsConstructor_testIsNullVersion() {
- assertThatThrownBy(() -> new ToscaPolicyIdentifierOptVersion(null, VERSION))
+ assertThatThrownBy(() -> new ToscaConceptIdentifierOptVersion(null, VERSION))
.isInstanceOf(NullPointerException.class);
// with null version
- ToscaPolicyIdentifierOptVersion orig = new ToscaPolicyIdentifierOptVersion(NAME, null);
+ ToscaConceptIdentifierOptVersion orig = new ToscaConceptIdentifierOptVersion(NAME, null);
assertEquals(NAME, orig.getName());
assertEquals(null, orig.getVersion());
- orig = new ToscaPolicyIdentifierOptVersion(NAME, VERSION);
+ orig = new ToscaConceptIdentifierOptVersion(NAME, VERSION);
assertEquals(NAME, orig.getName());
assertEquals(VERSION, orig.getVersion());
}
@Test
public void testCopyConstructor() throws Exception {
- assertThatThrownBy(() -> new ToscaPolicyIdentifierOptVersion((ToscaPolicyIdentifierOptVersion) null))
+ assertThatThrownBy(() -> new ToscaConceptIdentifierOptVersion((ToscaConceptIdentifierOptVersion) null))
.isInstanceOf(NullPointerException.class);
- ToscaPolicyIdentifierOptVersion orig = new ToscaPolicyIdentifierOptVersion();
+ ToscaConceptIdentifierOptVersion orig = new ToscaConceptIdentifierOptVersion();
// verify with null values
- assertEquals(orig.toString(), new ToscaPolicyIdentifierOptVersion(orig).toString());
+ assertEquals(orig.toString(), new ToscaConceptIdentifierOptVersion(orig).toString());
// verify with all values
orig = makeIdent(NAME, VERSION);
- assertEquals(orig.toString(), new ToscaPolicyIdentifierOptVersion(orig).toString());
+ assertEquals(orig.toString(), new ToscaConceptIdentifierOptVersion(orig).toString());
}
@Test
public void testCopyToscaPolicyIdentifierConstructor() {
- assertThatThrownBy(() -> new ToscaPolicyIdentifierOptVersion((ToscaPolicyIdentifier) null))
+ assertThatThrownBy(() -> new ToscaConceptIdentifierOptVersion((ToscaConceptIdentifier) null))
.isInstanceOf(NullPointerException.class);
- ToscaPolicyIdentifier orig = new ToscaPolicyIdentifier();
+ ToscaConceptIdentifier orig = new ToscaConceptIdentifier();
// verify with null values
- ToscaPolicyIdentifierOptVersion newIdent = new ToscaPolicyIdentifierOptVersion(orig);
+ ToscaConceptIdentifierOptVersion newIdent = new ToscaConceptIdentifierOptVersion(orig);
assertEquals(null, newIdent.getName());
assertEquals(null, newIdent.getVersion());
// verify with all values
orig.setName(NAME);
orig.setVersion(VERSION);
- newIdent = new ToscaPolicyIdentifierOptVersion(orig);
+ newIdent = new ToscaConceptIdentifierOptVersion(orig);
assertEquals(NAME, newIdent.getName());
assertEquals(VERSION, newIdent.getVersion());
}
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* Test methods not tested by {@link PojosTest}.
*/
-public class ToscaPolicyTypeIdentifierTest extends ToscaIdentifierTestBase<ToscaPolicyTypeIdentifier> {
+public class ToscaPolicyConceptIdentifierTest extends ToscaIdentifierTestBase<ToscaConceptIdentifier> {
- public ToscaPolicyTypeIdentifierTest() {
- super(ToscaPolicyTypeIdentifier.class, "name", "version");
+ public ToscaPolicyConceptIdentifierTest() {
+ super(ToscaConceptIdentifier.class, "name", "version");
}
@Test
public void testAllArgsConstructor() {
- assertThatThrownBy(() -> new ToscaPolicyTypeIdentifier(null, VERSION)).isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> new ToscaPolicyTypeIdentifier(NAME, null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> new ToscaConceptIdentifier(null, VERSION)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> new ToscaConceptIdentifier(NAME, null)).isInstanceOf(NullPointerException.class);
- ToscaPolicyTypeIdentifier orig = new ToscaPolicyTypeIdentifier(NAME, VERSION);
+ ToscaConceptIdentifier orig = new ToscaConceptIdentifier(NAME, VERSION);
assertEquals(NAME, orig.getName());
assertEquals(VERSION, orig.getVersion());
}
@Test
public void testCopyConstructor() {
- assertThatThrownBy(() -> new ToscaPolicyTypeIdentifier(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> new ToscaConceptIdentifier(null)).isInstanceOf(NullPointerException.class);
- ToscaPolicyTypeIdentifier orig = new ToscaPolicyTypeIdentifier();
+ ToscaConceptIdentifier orig = new ToscaConceptIdentifier();
// verify with null values
- assertEquals(orig.toString(), new ToscaPolicyTypeIdentifier(orig).toString());
+ assertEquals(orig.toString(), new ToscaConceptIdentifier(orig).toString());
// verify with all values
- orig = new ToscaPolicyTypeIdentifier(NAME, VERSION);
- assertEquals(orig.toString(), new ToscaPolicyTypeIdentifier(orig).toString());
+ orig = new ToscaConceptIdentifier(NAME, VERSION);
+ assertEquals(orig.toString(), new ToscaConceptIdentifier(orig).toString());
}
@Test
public void testValidatePapRest() throws Exception {
- ToscaPolicyTypeIdentifier ident = new ToscaPolicyTypeIdentifier(NAME, VERSION);
+ ToscaConceptIdentifier ident = new ToscaConceptIdentifier(NAME, VERSION);
ValidationResult result = ident.validatePapRest();
assertNotNull(result);
assertTrue(result.isValid());
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
assertEquals("ToscaEntityKey(name=my_name, version=1.2.3)", policy.getKey().toString());
- ToscaPolicyIdentifier ident = policy.getIdentifier();
+ ToscaConceptIdentifier ident = policy.getIdentifier();
assertEquals("my_name", ident.getName());
assertEquals("1.2.3", ident.getVersion());
- ToscaPolicyTypeIdentifier type = policy.getTypeIdentifier();
+ ToscaConceptIdentifier type = policy.getTypeIdentifier();
assertEquals("my_type", type.getName());
assertEquals("3.2.1", type.getVersion());
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* Test methods not tested by {@link PojosTest}.
*/
-public class ToscaPolicyIdentifierTest extends ToscaIdentifierTestBase<ToscaPolicyIdentifier> {
+public class ToscaPolicyTypeConceptIdentifierTest extends ToscaIdentifierTestBase<ToscaConceptIdentifier> {
- public ToscaPolicyIdentifierTest() {
- super(ToscaPolicyIdentifier.class, "name", "version");
+ public ToscaPolicyTypeConceptIdentifierTest() {
+ super(ToscaConceptIdentifier.class, "name", "version");
}
@Test
public void testAllArgsConstructor() {
- assertThatThrownBy(() -> new ToscaPolicyIdentifier(null, VERSION)).isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> new ToscaPolicyIdentifier(NAME, null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> new ToscaConceptIdentifier(null, VERSION)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> new ToscaConceptIdentifier(NAME, null)).isInstanceOf(NullPointerException.class);
- ToscaPolicyIdentifier orig = new ToscaPolicyIdentifier(NAME, VERSION);
+ ToscaConceptIdentifier orig = new ToscaConceptIdentifier(NAME, VERSION);
assertEquals(NAME, orig.getName());
assertEquals(VERSION, orig.getVersion());
}
@Test
public void testCopyConstructor() {
- assertThatThrownBy(() -> new ToscaPolicyIdentifier(null)).isInstanceOf(NullPointerException.class);
+ assertThatThrownBy(() -> new ToscaConceptIdentifier(null)).isInstanceOf(NullPointerException.class);
- ToscaPolicyIdentifier orig = new ToscaPolicyIdentifier();
+ ToscaConceptIdentifier orig = new ToscaConceptIdentifier();
// verify with null values
- assertEquals(orig.toString(), new ToscaPolicyIdentifier(orig).toString());
+ assertEquals(orig.toString(), new ToscaConceptIdentifier(orig).toString());
// verify with all values
- orig = new ToscaPolicyIdentifier(NAME, VERSION);
- assertEquals(orig.toString(), new ToscaPolicyIdentifier(orig).toString());
+ orig = new ToscaConceptIdentifier(NAME, VERSION);
+ assertEquals(orig.toString(), new ToscaConceptIdentifier(orig).toString());
}
@Test
public void testValidatePapRest() throws Exception {
- ToscaPolicyIdentifier ident = new ToscaPolicyIdentifier(NAME, VERSION);
+ ToscaConceptIdentifier ident = new ToscaConceptIdentifier(NAME, VERSION);
ValidationResult result = ident.validatePapRest();
assertNotNull(result);
assertTrue(result.isValid());