diff options
19 files changed, 817 insertions, 6 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/keys/PolicyTypeIdent.java b/models-base/src/main/java/org/onap/policy/models/base/keys/PolicyTypeIdent.java new file mode 100644 index 000000000..09e03816e --- /dev/null +++ b/models-base/src/main/java/org/onap/policy/models/base/keys/PolicyTypeIdent.java @@ -0,0 +1,42 @@ +/* + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.base.keys; + +import lombok.NoArgsConstructor; +import lombok.NonNull; +import org.onap.policy.models.base.PfConceptKey; + +/** + * Identifies a policy type. Both the name and version must be non-null. + */ +@NonNull +@NoArgsConstructor +public class PolicyTypeIdent extends PfConceptKey { + private static final long serialVersionUID = 1L; + + public PolicyTypeIdent(String name, String version) { + super(name, version); + } + + public PolicyTypeIdent(PolicyTypeIdent source) { + super(source); + } +} diff --git a/models-base/src/test/java/org/onap/policy/models/base/keys/TestModels.java b/models-base/src/test/java/org/onap/policy/models/base/keys/TestModels.java new file mode 100644 index 000000000..a1bf3be68 --- /dev/null +++ b/models-base/src/test/java/org/onap/policy/models/base/keys/TestModels.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.base.keys; + +import com.openpojo.reflection.filters.FilterPackageInfo; +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 org.junit.Test; +import org.onap.policy.common.utils.validation.ToStringTester; + +/** + * Class to perform unit testing of models. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public class TestModels { + + @Test + public void testModels() { + final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterTester()) + .with(new GetterTester()).build(); + validator.validate(TestModels.class.getPackage().getName(), new FilterPackageInfo()); + } +} diff --git a/models-base/src/test/java/org/onap/policy/models/base/keys/TestPolicyTypeIdent.java b/models-base/src/test/java/org/onap/policy/models/base/keys/TestPolicyTypeIdent.java new file mode 100644 index 000000000..1638a87da --- /dev/null +++ b/models-base/src/test/java/org/onap/policy/models/base/keys/TestPolicyTypeIdent.java @@ -0,0 +1,60 @@ +/* + * ============LICENSE_START======================================================= + * ONAP Policy Models + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.base.keys; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.policy.models.base.keys.PolicyTypeIdent; +import org.onap.policy.models.base.keys.TestModels; + +/** + * Test the other constructors, as {@link TestModels} tests the other methods. + */ +public class TestPolicyTypeIdent { + private static final String NAME = "my-name"; + private static final String VERSION = "1.2.3"; + + @Test + public void testAllArgsConstructor() { + assertThatThrownBy(() -> new PolicyTypeIdent(null, VERSION)).isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> new PolicyTypeIdent(NAME, null)).isInstanceOf(NullPointerException.class); + + PolicyTypeIdent orig = new PolicyTypeIdent(NAME, VERSION); + assertEquals(NAME, orig.getName()); + assertEquals(VERSION, orig.getVersion()); + } + + @Test + public void testCopyConstructor() { + assertThatThrownBy(() -> new PolicyTypeIdent(null)).isInstanceOf(NullPointerException.class); + + PolicyTypeIdent orig = new PolicyTypeIdent(); + + // verify with null values + assertEquals(orig.toString(), new PolicyTypeIdent(orig).toString()); + + // verify with all values + orig = new PolicyTypeIdent(NAME, VERSION); + assertEquals(orig.toString(), new PolicyTypeIdent(orig).toString()); + } +} diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpSubGroup.java b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpSubGroup.java index e535233bc..43356982e 100644 --- a/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpSubGroup.java +++ b/models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpSubGroup.java @@ -28,8 +28,8 @@ import lombok.Getter; import lombok.NonNull; import lombok.Setter; import lombok.ToString; -import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfUtils; +import org.onap.policy.models.base.keys.PolicyTypeIdent; /** * Class to represent a group of all PDP's of the same pdp type running for a particular @@ -43,7 +43,7 @@ import org.onap.policy.models.base.PfUtils; public class PdpSubGroup { private String pdpType; - private List<PfConceptKey> supportedPolicyTypes; + private List<PolicyTypeIdent> supportedPolicyTypes; private List<Policy> policies; private int currentInstanceCount; private int desiredInstanceCount; @@ -64,7 +64,7 @@ public class PdpSubGroup { */ public PdpSubGroup(@NonNull PdpSubGroup source) { this.pdpType = source.pdpType; - this.supportedPolicyTypes = PfUtils.mapList(source.supportedPolicyTypes, PfConceptKey::new); + this.supportedPolicyTypes = PfUtils.mapList(source.supportedPolicyTypes, PolicyTypeIdent::new); this.policies = PfUtils.mapList(source.policies, Policy::new); this.currentInstanceCount = source.currentInstanceCount; this.desiredInstanceCount = source.desiredInstanceCount; diff --git a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/TestPdpSubGroup.java b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/TestPdpSubGroup.java index d2e5f2fcc..9af2f4e9d 100644 --- a/models-pap/src/test/java/org/onap/policy/models/pap/concepts/TestPdpSubGroup.java +++ b/models-pap/src/test/java/org/onap/policy/models/pap/concepts/TestPdpSubGroup.java @@ -27,7 +27,7 @@ import java.util.Arrays; import java.util.Map; import java.util.TreeMap; import org.junit.Test; -import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.keys.PolicyTypeIdent; /** * Test the copy constructor, as {@link TestModels} tests the other methods. @@ -66,8 +66,8 @@ public class TestPdpSubGroup { props.put("key-B", "value-B"); orig.setProperties(props); - PfConceptKey supp1 = new PfConceptKey("supp-A", "1.2"); - PfConceptKey supp2 = new PfConceptKey("supp-B", "3.4"); + PolicyTypeIdent supp1 = new PolicyTypeIdent("supp-A", "1.2"); + PolicyTypeIdent supp2 = new PolicyTypeIdent("supp-B", "3.4"); orig.setSupportedPolicyTypes(Arrays.asList(supp1, supp2)); assertEquals(orig.toString(), new PdpSubGroup(orig).toString()); diff --git a/models-pdp/pom.xml b/models-pdp/pom.xml new file mode 100644 index 000000000..1a4685664 --- /dev/null +++ b/models-pdp/pom.xml @@ -0,0 +1,48 @@ +<!-- + ============LICENSE_START======================================================= + Copyright (C) 2019 Nordix Foundation. + Modifications Copyright (C) 2019 AT&T Intellectual Property. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + SPDX-License-Identifier: Apache-2.0 + ============LICENSE_END========================================================= +--> + +<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"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models</artifactId> + <version>2.0.0-SNAPSHOT</version> + </parent> + + <artifactId>models-pdp</artifactId> + + <name>${project.artifactId}</name> + <description>The models for internal PDP API's.</description> + + <dependencies> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-base</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.policy.models</groupId> + <artifactId>policy-models-tosca</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project> diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpHealthCheck.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpHealthCheck.java new file mode 100644 index 000000000..b82af0225 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpHealthCheck.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.models.pdp.enums.PdpMessageType; + +/** + * Class to represent the PDP_HEALTH_CHECK message that PAP will send to either PDPGroup/Subgroup or a PDP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@Setter +@ToString +public class PdpHealthCheck extends PdpMessage { + + private String name; + private String pdpGroup; + private String pdpSubgroup; + + /** + * Constructor for instantiating PdpHealthCheck class with message name. + * + */ + public PdpHealthCheck() { + super(PdpMessageType.PDP_HEALTH_CHECK); + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java new file mode 100644 index 000000000..6160027ed --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpMessage.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import java.util.UUID; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.models.pdp.enums.PdpMessageType; + +/** + * Class to represent the base class for various messages that will ve exchanged between PAP and PDP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@Setter +@ToString +public class PdpMessage { + + @Setter(AccessLevel.NONE) + private PdpMessageType messageName; + + private String requestId = UUID.randomUUID().toString(); + + /** + * Time-stamp, in milliseconds, when the message was created. Defaults to the current + * time. + */ + private long timestampMs = System.currentTimeMillis(); + + /** + * Constructor for instantiating PdpMessage class with message name. + * + * @param messageName the message name + */ + public PdpMessage(final PdpMessageType messageName) { + this.messageName = messageName; + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpResponseDetails.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpResponseDetails.java new file mode 100644 index 000000000..c28d01a3e --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpResponseDetails.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.models.pdp.enums.PdpResponseStatus; + +/** + * Class to represent PDP response details. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@Setter +@ToString +public class PdpResponseDetails { + + // The responseTo field should match the original request id in the request. + private String responseTo; + private PdpResponseStatus responseStatus; + private String responseMessage; +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java new file mode 100644 index 000000000..bca162e91 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStateChange.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.models.pdp.enums.PdpMessageType; +import org.onap.policy.models.pdp.enums.PdpState; + +/** + * Class to represent the PDP_STATE_CHANGE message that PAP will send to either PDPGroup/Subgroup or a PDP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@Setter +@ToString +public class PdpStateChange extends PdpMessage { + + private String name; + private PdpState state; + private String pdpGroup; + private String pdpSubgroup; + + /** + * Constructor for instantiating PdpStateChange class with message name. + * + */ + public PdpStateChange() { + super(PdpMessageType.PDP_STATE_CHANGE); + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatistics.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatistics.java new file mode 100644 index 000000000..6f9b9c9d6 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatistics.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Class to represent statistics of a running PDP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@Setter +@ToString +public class PdpStatistics { + + private long policyDownloadCount; + private long policyDownloadSuccessCount; + private long policyDownloadFailCount; + private long policyExecutedCount; + private long policyExecutedSuccessCount; + private long policyExecutedFailCount; +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java new file mode 100644 index 000000000..f7b911fc4 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpStatus.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import java.util.List; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.models.base.keys.PolicyTypeIdent; +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.simple.concepts.ToscaPolicy; + +/** + * Class to represent the PDP_STATUS message that all the PDP's will send to PAP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@Setter +@ToString +public class PdpStatus extends PdpMessage { + + private String name; + private String version; + private String pdpType; + private PdpState state; + private PdpHealthStatus healthy; + private String description; + private String pdpGroup; + private String pdpSubgroup; + private List<PolicyTypeIdent> supportedPolicyTypes; + private List<ToscaPolicy> policies; + private String instance; + private String deploymentInstanceInfo; + private String properties; + private PdpStatistics statistics; + private PdpResponseDetails response; + + /** + * Constructor for instantiating PdpStatus class with message name. + * + */ + public PdpStatus() { + super(PdpMessageType.PDP_STATUS); + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java new file mode 100644 index 000000000..a048cde48 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpUpdate.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import java.util.List; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import org.onap.policy.models.pdp.enums.PdpMessageType; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy; + +/** + * Class to represent the PDP_UPDATE message that PAP will send to a PDP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +@Getter +@Setter +@ToString +public class PdpUpdate extends PdpMessage { + + private String name; + private String pdpType; + private String description; + private String pdpGroup; + private String pdpSubgroup; + private List<ToscaPolicy> policies; + + /** + * Constructor for instantiating PdpUpdate class with message name. + * + */ + public PdpUpdate() { + super(PdpMessageType.PDP_UPDATE); + } +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpHealthStatus.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpHealthStatus.java new file mode 100644 index 000000000..7d31c3344 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpHealthStatus.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.enums; + +/** + * Class to hold the possible values for health status of PDP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public enum PdpHealthStatus { + + /** + * PDP is healthy and working fine. + */ + HEALTHY, + + /** + * PDP is not healthy. + */ + NOT_HEALTHY, + + /** + * PDP is currently under test state and performing tests. + */ + TEST_IN_PROGRESS, +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpMessageType.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpMessageType.java new file mode 100644 index 000000000..7ba4ad73e --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpMessageType.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.enums; + +/** + * Class to hold the possible values for the type of PDP messages. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public enum PdpMessageType { + + /** + * Used by PDPs to report status to PAP. + */ + PDP_STATUS, + + /** + * Used by PAP to update the policies running on PDPs, triggers a PDP_STATUS message with the result of the + * PDP_UPDATE operation. + */ + PDP_UPDATE, + + /** + * Used by PAP to change the state of PDPs, triggers a PDP_STATUS message with the result of the PDP_STATE_CHANGE + * operation. + */ + PDP_STATE_CHANGE, + + /** + * Used by PAP to order a health check on PDPs, triggers a PDP_STATUS message with the result of the + * PDP_HEALTH_CHECK operation. + */ + PDP_HEALTH_CHECK, +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpResponseStatus.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpResponseStatus.java new file mode 100644 index 000000000..e6b94f446 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpResponseStatus.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.enums; + +/** + * Class to hold the possible values for PDP response status. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public enum PdpResponseStatus { + + /** + * PDP operation was successful. + */ + SUCCESS, + + /** + * PDP operation failed. + */ + FAIL, +} diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpState.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpState.java new file mode 100644 index 000000000..a1b96ac17 --- /dev/null +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/enums/PdpState.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.enums; + +/** + * Class to hold the possible values for state of PDP. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public enum PdpState { + + /** + * Policy execution is always rejected irrespective of PDP type. + */ + PASSIVE, + + /** + * Policy execution proceeds, but changes to domain state or context are not carried out. The PDP returns an + * indication that it is running in SAFE mode together with the action it would have performed if it was operating + * in ACTIVE mode. + */ + SAFE, + + /** + * Policy execution proceeds and changes to domain and state are carried out in a test environment. The PDP returns + * an indication that it is running in TEST mode together with the action it has performed on the test environment. + */ + TEST, + + /** + * Policy execution is executed in the live environment by the PDP. + */ + ACTIVE, + + /** + * Policy execution is terminated and not available. + */ + TERMINATED +} diff --git a/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestModels.java b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestModels.java new file mode 100644 index 000000000..39aee6f48 --- /dev/null +++ b/models-pdp/src/test/java/org/onap/policy/models/pdp/concepts/TestModels.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.pdp.concepts; + +import com.openpojo.reflection.filters.FilterPackageInfo; +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 org.junit.Test; +import org.onap.policy.common.utils.validation.ToStringTester; + +/** + * Class to perform unit testing of models. + * + * @author Ram Krishna Verma (ram.krishna.verma@est.tech) + */ +public class TestModels { + + @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()); + } +} @@ -56,6 +56,7 @@ <module>models-dao</module> <module>models-tosca</module> <module>models-pap</module> + <module>models-pdp</module> <module>models-errors</module> <module>models-decisions</module> <module>models-provider</module> |