diff options
author | Jim Hahn <jrh3@att.com> | 2019-05-08 14:33:57 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-05-08 16:24:35 -0400 |
commit | 10b21aae2bde224ab7f91f4b5ab1b89369c8fd1c (patch) | |
tree | 0417099e379e8be69f90221e8fd066fc40def62b | |
parent | 01841878936986bc80a974977ccdeaceaf7f9a78 (diff) |
Add payload to vFW policy yaml
Added new "streams" payload to vFW policy yaml files.
Removed references to pg-streams.
Also deleted directories that were moved to policy/models.
Also removed references to trafficgenerator.
Updated licenses.
Removed some trailing whitespace.
Change-Id: I6becaa573628eee677f0959fadf86f9a9f032f88
Issue-ID: POLICY-1752
Signed-off-by: Jim Hahn <jrh3@att.com>
406 files changed, 12 insertions, 45582 deletions
diff --git a/controlloop/common/actors/actor.appc/pom.xml b/controlloop/common/actors/actor.appc/pom.xml deleted file mode 100644 index a7f1f5ada..000000000 --- a/controlloop/common/actors/actor.appc/pom.xml +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - drools-pdp-apps - ================================================================================ - Copyright (C) 2017-2018 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========================================================= - --> - -<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.drools-applications.controlloop.common.actors</groupId> - <artifactId>actors</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>actor.appc</artifactId> - - <dependencies> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId> - <artifactId>actorServiceProvider</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>appc</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>trafficgenerator</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>events</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> - <artifactId>simulators</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.common</groupId> - <artifactId>policy-endpoints</artifactId> - <version>${version.policy.common}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-pdp</groupId> - <artifactId>policy-management</artifactId> - <version>${version.policy.drools-pdp}</version> - <scope>provided</scope> - </dependency> - </dependencies> -</project> diff --git a/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcActorServiceProvider.java b/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcActorServiceProvider.java deleted file mode 100644 index 264498637..000000000 --- a/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcActorServiceProvider.java +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * APPCActorServiceProvider - * ================================================================================ - * Copyright (C) 2017-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.controlloop.actor.appc; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -import java.util.Collections; -import java.util.List; - -import org.onap.policy.appc.CommonHeader; -import org.onap.policy.appc.Request; -import org.onap.policy.controlloop.ControlLoopOperation; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.vnf.trafficgenerator.PgRequest; -import org.onap.policy.vnf.trafficgenerator.PgStream; -import org.onap.policy.vnf.trafficgenerator.PgStreams; - - -public class AppcActorServiceProvider implements Actor { - // Strings for targets - private static final String TARGET_VM = "VM"; - private static final String TARGET_VNF = "VNF"; - - // Strings for recipes - private static final String RECIPE_RESTART = "Restart"; - private static final String RECIPE_REBUILD = "Rebuild"; - private static final String RECIPE_MIGRATE = "Migrate"; - private static final String RECIPE_MODIFY = "ModifyConfig"; - - private static final ImmutableList<String> recipes = - ImmutableList.of(RECIPE_RESTART, RECIPE_REBUILD, RECIPE_MIGRATE, RECIPE_MODIFY); - private static final ImmutableMap<String, List<String>> targets = new ImmutableMap.Builder<String, List<String>>() - .put(RECIPE_RESTART, ImmutableList.of(TARGET_VM)).put(RECIPE_REBUILD, ImmutableList.of(TARGET_VM)) - .put(RECIPE_MIGRATE, ImmutableList.of(TARGET_VM)).put(RECIPE_MODIFY, ImmutableList.of(TARGET_VNF)).build(); - private static final ImmutableMap<String, List<String>> payloads = new ImmutableMap.Builder<String, List<String>>() - .put(RECIPE_MODIFY, ImmutableList.of("generic-vnf.vnf-id")).build(); - - @Override - public String actor() { - return "APPC"; - } - - @Override - public List<String> recipes() { - return ImmutableList.copyOf(recipes); - } - - @Override - public List<String> recipeTargets(String recipe) { - return ImmutableList.copyOf(targets.getOrDefault(recipe, Collections.emptyList())); - } - - @Override - public List<String> recipePayloads(String recipe) { - return ImmutableList.copyOf(payloads.getOrDefault(recipe, Collections.emptyList())); - } - - /** - * Constructs an APPC request conforming to the legacy API. The legacy API will be deprecated in - * future releases as all legacy functionality is moved into the LCM API. - * - * @param onset the event that is reporting the alert for policy to perform an action - * @param operation the control loop operation specifying the actor, operation, target, etc. - * @param policy the policy the was specified from the yaml generated by CLAMP or through the - * Policy GUI/API - * @return an APPC request conforming to the legacy API - */ - public static Request constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy, - String targetVnf) { - /* - * Construct an APPC request - */ - Request request = new Request(); - request.setCommonHeader(new CommonHeader()); - request.getCommonHeader().setRequestId(onset.getRequestId()); - request.getCommonHeader().setSubRequestId(operation.getSubRequestId()); - request.setAction(policy.getRecipe().substring(0, 1).toUpperCase() + policy.getRecipe().substring(1)); - - /* - * For now Policy generates the PG Streams as a demo, in the future the payload can be - * provided by CLAMP - */ - request.getPayload().put("generic-vnf.vnf-id", targetVnf); - - PgRequest pgRequest = new PgRequest(); - pgRequest.pgStreams = new PgStreams(); - - PgStream pgStream; - for (int i = 0; i < 5; i++) { - pgStream = new PgStream(); - pgStream.streamId = "fw_udp" + (i + 1); - pgStream.isEnabled = "true"; - pgRequest.pgStreams.pgStream.add(pgStream); - } - request.getPayload().put("pg-streams", pgRequest.pgStreams); - - /* - * Return the request - */ - - return request; - } - - -} diff --git a/controlloop/common/actors/actor.appc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor b/controlloop/common/actors/actor.appc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor deleted file mode 100644 index f1002a301..000000000 --- a/controlloop/common/actors/actor.appc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor +++ /dev/null @@ -1 +0,0 @@ -org.onap.policy.controlloop.actor.appc.AppcActorServiceProvider
\ No newline at end of file diff --git a/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java b/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java deleted file mode 100644 index 9f8528fe0..000000000 --- a/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java +++ /dev/null @@ -1,178 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * AppcServiceProviderTest - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.actor.appc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.time.Instant; -import java.util.HashMap; -import java.util.UUID; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.appc.Request; -import org.onap.policy.appc.Response; -import org.onap.policy.appc.ResponseCode; -import org.onap.policy.appc.util.Serialization; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.ControlLoopOperation; -import org.onap.policy.controlloop.ControlLoopTargetType; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.controlloop.policy.Target; -import org.onap.policy.controlloop.policy.TargetType; -import org.onap.policy.drools.system.PolicyEngine; -import org.onap.policy.simulators.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AppcServiceProviderTest { - - private static final Logger logger = LoggerFactory.getLogger(AppcServiceProviderTest.class); - - private static final VirtualControlLoopEvent onsetEvent; - private static final ControlLoopOperation operation; - private static final Policy policy; - - static { - /* - * Construct an onset with an AAI subtag containing generic-vnf.vnf-id and a target type of - * VM. - */ - onsetEvent = new VirtualControlLoopEvent(); - onsetEvent.setClosedLoopControlName("closedLoopControlName-Test"); - onsetEvent.setRequestId(UUID.randomUUID()); - onsetEvent.setClosedLoopEventClient("tca.instance00001"); - onsetEvent.setTargetType(ControlLoopTargetType.VNF); - onsetEvent.setTarget("generic-vnf.vnf-name"); - onsetEvent.setFrom("DCAE"); - onsetEvent.setClosedLoopAlarmStart(Instant.now()); - onsetEvent.setAai(new HashMap<>()); - onsetEvent.getAai().put("generic-vnf.vnf-name", "fw0001vm001fw001"); - onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); - - /* Construct an operation with an APPC actor and ModifyConfig operation. */ - operation = new ControlLoopOperation(); - operation.setActor("APPC"); - operation.setOperation("ModifyConfig"); - operation.setTarget("VNF"); - operation.setEnd(Instant.now()); - operation.setSubRequestId("1"); - - /* Construct a policy specifying to modify configuration. */ - policy = new Policy(); - policy.setName("Modify Packet Generation Config"); - policy.setDescription("Upon getting the trigger event, modify packet gen config"); - policy.setActor("APPC"); - policy.setTarget(new Target(TargetType.VNF)); - policy.getTarget().setResourceID("Eace933104d443b496b8.nodes.heat.vpg"); - policy.setRecipe("ModifyConfig"); - policy.setPayload(null); - policy.setRetry(2); - policy.setTimeout(300); - - /* Set environment properties */ - PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666"); - PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI"); - PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI"); - - } - - /** - * Set up before test class. - */ - @BeforeClass - public static void setUpSimulator() { - try { - Util.buildAaiSim(); - } catch (Exception e) { - fail(e.getMessage()); - } - } - - /** - * Tear down after test class. - */ - @AfterClass - public static void tearDownSimulator() { - HttpServletServer.factory.destroy(); - } - - @Test - public void constructModifyConfigRequestTest() { - - Request appcRequest; - appcRequest = AppcActorServiceProvider.constructRequest(onsetEvent, operation, policy, "vnf01"); - - /* The service provider must return a non null APPC request */ - assertNotNull(appcRequest); - - /* A common header is required and cannot be null */ - assertNotNull(appcRequest.getCommonHeader()); - assertEquals(appcRequest.getCommonHeader().getRequestId(), onsetEvent.getRequestId()); - - /* An action is required and cannot be null */ - assertNotNull(appcRequest.getAction()); - assertEquals("ModifyConfig", appcRequest.getAction()); - - /* A payload is required and cannot be null */ - assertNotNull(appcRequest.getPayload()); - assertTrue(appcRequest.getPayload().containsKey("generic-vnf.vnf-id")); - assertNotNull(appcRequest.getPayload().get("generic-vnf.vnf-id")); - assertTrue(appcRequest.getPayload().containsKey("pg-streams")); - - logger.debug("APPC Request: \n" + appcRequest.toString()); - - /* Print out request as json to make sure serialization works */ - String jsonRequest = Serialization.gsonPretty.toJson(appcRequest); - logger.debug("JSON Output: \n" + jsonRequest); - - /* The JSON string must contain the following fields */ - assertTrue(jsonRequest.contains("CommonHeader")); - assertTrue(jsonRequest.contains("Action")); - assertTrue(jsonRequest.contains("ModifyConfig")); - assertTrue(jsonRequest.contains("Payload")); - assertTrue(jsonRequest.contains("generic-vnf.vnf-id")); - assertTrue(jsonRequest.contains("pg-streams")); - - Response appcResponse = new Response(appcRequest); - appcResponse.getStatus().setCode(ResponseCode.SUCCESS.getValue()); - appcResponse.getStatus().setDescription("AppC success"); - /* Print out request as json to make sure serialization works */ - String jsonResponse = Serialization.gsonPretty.toJson(appcResponse); - logger.debug("JSON Output: \n" + jsonResponse); - } - - @Test - public void testMethods() { - AppcActorServiceProvider sp = new AppcActorServiceProvider(); - - assertEquals("APPC", sp.actor()); - assertEquals(4, sp.recipes().size()); - assertEquals("VM", sp.recipeTargets("Restart").get(0)); - assertEquals(0, sp.recipePayloads("Restart").size()); - } -} diff --git a/controlloop/common/actors/actor.appclcm/pom.xml b/controlloop/common/actors/actor.appclcm/pom.xml deleted file mode 100644 index 28f9c1c60..000000000 --- a/controlloop/common/actors/actor.appclcm/pom.xml +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - drools-pdp-apps - ================================================================================ - Copyright (C) 2017-2018 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========================================================= - --> - -<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.drools-applications.controlloop.common.actors</groupId> - <artifactId>actors</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>actor.appclcm</artifactId> - - <dependencies> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId> - <artifactId>actorServiceProvider</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>appclcm</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>aai</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>events</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.common</groupId> - <artifactId>policy-endpoints</artifactId> - <version>${version.policy.common}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-pdp</groupId> - <artifactId>policy-management</artifactId> - <version>${version.policy.drools-pdp}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> - <artifactId>simulators</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> -</project> diff --git a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java deleted file mode 100644 index 5c82a9500..000000000 --- a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java +++ /dev/null @@ -1,359 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * AppcLcmActorServiceProvider - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * Modifications copyright (c) 2018 Nokia - * ================================================================================ - * 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.controlloop.actor.appclcm; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -import java.util.AbstractMap; -import java.util.AbstractMap.SimpleEntry; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.onap.policy.aai.AaiManager; -import org.onap.policy.aai.AaiNqInstanceFilters; -import org.onap.policy.aai.AaiNqInventoryResponseItem; -import org.onap.policy.aai.AaiNqNamedQuery; -import org.onap.policy.aai.AaiNqQueryParameters; -import org.onap.policy.aai.AaiNqRequest; -import org.onap.policy.aai.AaiNqResponse; -import org.onap.policy.aai.util.AaiException; -import org.onap.policy.appclcm.LcmCommonHeader; -import org.onap.policy.appclcm.LcmRequest; -import org.onap.policy.appclcm.LcmRequestWrapper; -import org.onap.policy.appclcm.LcmResponse; -import org.onap.policy.appclcm.LcmResponseCode; -import org.onap.policy.appclcm.LcmResponseWrapper; -import org.onap.policy.controlloop.ControlLoopOperation; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.controlloop.policy.PolicyResult; -import org.onap.policy.drools.system.PolicyEngine; -import org.onap.policy.rest.RestManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AppcLcmActorServiceProvider implements Actor { - - private static final Logger logger = LoggerFactory.getLogger(AppcLcmActorServiceProvider.class); - - /* To be used in future releases to restart a single vm */ - private static final String APPC_VM_ID = "vm-id"; - - // Strings for targets - private static final String TARGET_VM = "VM"; - private static final String TARGET_VNF = "VNF"; - - // Strings for recipes - private static final String RECIPE_RESTART = "Restart"; - private static final String RECIPE_REBUILD = "Rebuild"; - private static final String RECIPE_MIGRATE = "Migrate"; - private static final String RECIPE_MODIFY = "ConfigModify"; - - /* To be used in future releases when LCM ConfigModify is used */ - private static final String APPC_REQUEST_PARAMS = "request-parameters"; - private static final String APPC_CONFIG_PARAMS = "configuration-parameters"; - - private static final ImmutableList<String> recipes = - ImmutableList.of(RECIPE_RESTART, RECIPE_REBUILD, RECIPE_MIGRATE, RECIPE_MODIFY); - private static final ImmutableMap<String, List<String>> targets = new ImmutableMap.Builder<String, List<String>>() - .put(RECIPE_RESTART, ImmutableList.of(TARGET_VM)).put(RECIPE_REBUILD, ImmutableList.of(TARGET_VM)) - .put(RECIPE_MIGRATE, ImmutableList.of(TARGET_VM)).put(RECIPE_MODIFY, ImmutableList.of(TARGET_VNF)).build(); - private static final ImmutableMap<String, List<String>> payloads = - new ImmutableMap.Builder<String, List<String>>().put(RECIPE_RESTART, ImmutableList.of(APPC_VM_ID)) - .put(RECIPE_MODIFY, ImmutableList.of(APPC_REQUEST_PARAMS, APPC_CONFIG_PARAMS)).build(); - - @Override - public String actor() { - return "APPC"; - } - - @Override - public List<String> recipes() { - return ImmutableList.copyOf(recipes); - } - - @Override - public List<String> recipeTargets(String recipe) { - return ImmutableList.copyOf(targets.getOrDefault(recipe, Collections.emptyList())); - } - - @Override - public List<String> recipePayloads(String recipe) { - return ImmutableList.copyOf(payloads.getOrDefault(recipe, Collections.emptyList())); - } - - /** - * This method recursively traverses the A&AI named query response to find the generic-vnf - * object that contains a model-invariant-id that matches the resourceId of the policy. Once - * this match is found the generic-vnf object's vnf-id is returned. - * - * @param items the list of items related to the vnf returned by A&AI - * @param resourceId the id of the target from the sdc catalog - * - * @return the vnf-id of the target vnf to act upon or null if not found - */ - private static String parseAaiResponse(List<AaiNqInventoryResponseItem> items, String resourceId) { - String vnfId = null; - for (AaiNqInventoryResponseItem item : items) { - if ((item.getGenericVnf() != null) && (item.getGenericVnf().getModelInvariantId() != null) - && (resourceId.equals(item.getGenericVnf().getModelInvariantId()))) { - vnfId = item.getGenericVnf().getVnfId(); - break; - } else { - if ((item.getItems() != null) && (item.getItems().getInventoryResponseItems() != null)) { - vnfId = parseAaiResponse(item.getItems().getInventoryResponseItems(), resourceId); - } - } - } - return vnfId; - } - - /** - * Constructs an A&AI Named Query using a source vnf-id to determine the vnf-id of the target - * entity specified in the policy to act upon. - * - * @param resourceId the id of the target from the sdc catalog - * - * @param sourceVnfId the vnf id of the source entity reporting the alert - * - * @return the target entities vnf id to act upon - * @throws AaiException it an error occurs - */ - public static String vnfNamedQuery(String resourceId, String sourceVnfId) throws AaiException { - - // TODO: This request id should not be hard coded in future releases - UUID requestId = UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087"); - - AaiNqRequest aaiRequest = new AaiNqRequest(); - aaiRequest.setQueryParameters(new AaiNqQueryParameters()); - aaiRequest.getQueryParameters().setNamedQuery(new AaiNqNamedQuery()); - aaiRequest.getQueryParameters().getNamedQuery().setNamedQueryUuid(requestId); - - Map<String, Map<String, String>> filter = new HashMap<>(); - Map<String, String> filterItem = new HashMap<>(); - - filterItem.put("vnf-id", sourceVnfId); - filter.put("generic-vnf", filterItem); - - aaiRequest.setInstanceFilters(new AaiNqInstanceFilters()); - aaiRequest.getInstanceFilters().getInstanceFilter().add(filter); - - AaiNqResponse aaiResponse = new AaiManager(new RestManager()).postQuery(getPeManagerEnvProperty("aai.url"), - getPeManagerEnvProperty("aai.username"), getPeManagerEnvProperty("aai.password"), aaiRequest, - requestId); - - if (aaiResponse == null) { - throw new AaiException("The named query response was null"); - } - - String targetVnfId = parseAaiResponse(aaiResponse.getInventoryResponseItems(), resourceId); - if (targetVnfId == null) { - throw new AaiException("Target vnf-id could not be found"); - } - - return targetVnfId; - } - - /** - * Constructs an APPC request conforming to the lcm API. The actual request is constructed and - * then placed in a wrapper object used to send through DMAAP. - * - * @param onset the event that is reporting the alert for policy to perform an action - * @param operation the control loop operation specifying the actor, operation, target, etc. - * @param policy the policy the was specified from the yaml generated by CLAMP or through the - * Policy GUI/API - * @return an APPC request conforming to the lcm API using the DMAAP wrapper - */ - public static LcmRequestWrapper constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, - Policy policy, String targetVnf) { - - /* Construct an APPC request using LCM Model */ - - /* - * The actual LCM request is placed in a wrapper used to send through dmaap. The current - * version is 2.0 as of R1. - */ - AppcLcmRecipeFormatter lcmRecipeFormatter = new AppcLcmRecipeFormatter(policy.getRecipe()); - - LcmRequestWrapper dmaapRequest = new LcmRequestWrapper(); - dmaapRequest.setVersion("2.0"); - dmaapRequest.setCorrelationId(onset.getRequestId() + "-" + operation.getSubRequestId()); - dmaapRequest.setRpcName(lcmRecipeFormatter.getUrlRecipe()); - dmaapRequest.setType("request"); - - /* This is the actual request that is placed in the dmaap wrapper. */ - final LcmRequest appcRequest = new LcmRequest(); - - /* The common header is a required field for all APPC requests. */ - LcmCommonHeader requestCommonHeader = new LcmCommonHeader(); - requestCommonHeader.setOriginatorId(onset.getRequestId().toString()); - requestCommonHeader.setRequestId(onset.getRequestId()); - requestCommonHeader.setSubRequestId(operation.getSubRequestId()); - - appcRequest.setCommonHeader(requestCommonHeader); - - /* - * Action Identifiers are required for APPC LCM requests. For R1, the recipes supported by - * Policy only require a vnf-id. - */ - HashMap<String, String> requestActionIdentifiers = new HashMap<>(); - requestActionIdentifiers.put("vnf-id", targetVnf); - - appcRequest.setActionIdentifiers(requestActionIdentifiers); - - /* - * An action is required for all APPC requests, this will be the recipe specified in the - * policy. - */ - appcRequest.setAction(lcmRecipeFormatter.getBodyRecipe()); - - /* - * For R1, the payloads will not be required for the Restart, Rebuild, or Migrate recipes. - * APPC will populate the payload based on A&AI look up of the vnd-id provided in the action - * identifiers. - */ - if (recipeSupportsPayload(policy.getRecipe()) && payloadSupplied(policy.getPayload())) { - appcRequest.setPayload(parsePayload(policy.getPayload())); - } else { - appcRequest.setPayload(null); - } - - /* - * Once the LCM request is constructed, add it into the body of the dmaap wrapper. - */ - dmaapRequest.setBody(appcRequest); - - /* Return the request to be sent through dmaap. */ - return dmaapRequest; - } - - private static boolean payloadSupplied(Map<String, String> payload) { - return payload != null && !payload.isEmpty(); - } - - private static boolean recipeSupportsPayload(String recipe) { - return !RECIPE_RESTART.equalsIgnoreCase(recipe) && !RECIPE_REBUILD.equalsIgnoreCase(recipe) - && !RECIPE_MIGRATE.equalsIgnoreCase(recipe); - } - - private static String parsePayload(Map<String, String> payload) { - StringBuilder payloadString = new StringBuilder("{"); - payload - .forEach((key, value) -> payloadString.append("\"").append(key).append("\": ").append(value).append(",")); - return payloadString.substring(0, payloadString.length() - 1) + "}"; - } - - /** - * Parses the operation attempt using the subRequestId of APPC response. - * - * @param subRequestId the sub id used to send to APPC, Policy sets this using the operation - * attempt - * - * @return the current operation attempt - */ - public static Integer parseOperationAttempt(String subRequestId) { - Integer operationAttempt; - try { - operationAttempt = Integer.parseInt(subRequestId); - } catch (NumberFormatException e) { - logger.debug("A NumberFormatException was thrown due to error in parsing the operation attempt"); - return null; - } - return operationAttempt; - } - - /** - * Processes the APPC LCM response sent from APPC. Determines if the APPC operation was - * successful/unsuccessful and maps this to the corresponding Policy result. - * - * @param dmaapResponse the dmaap wrapper message that contains the actual APPC reponse inside - * the body field - * - * @return an key-value pair that contains the Policy result and APPC response message - */ - public static SimpleEntry<PolicyResult, String> processResponse(LcmResponseWrapper dmaapResponse) { - /* The actual APPC response is inside the wrapper's body field. */ - LcmResponse appcResponse = dmaapResponse.getBody(); - - /* The message returned in the APPC response. */ - String message; - - /* The Policy result determined from the APPC Response. */ - PolicyResult result; - - /* If there is no status, Policy cannot determine if the request was successful. */ - if (appcResponse.getStatus() == null) { - message = "Policy was unable to parse APP-C response status field (it was null)."; - return new AbstractMap.SimpleEntry<>(PolicyResult.FAILURE_EXCEPTION, message); - } - - /* If there is no code, Policy cannot determine if the request was successful. */ - String responseValue = LcmResponseCode.toResponseValue(appcResponse.getStatus().getCode()); - if (responseValue == null) { - message = "Policy was unable to parse APP-C response status code field."; - return new AbstractMap.SimpleEntry<>(PolicyResult.FAILURE_EXCEPTION, message); - } - - /* Save the APPC response's message for Policy notification message. */ - message = appcResponse.getStatus().getMessage(); - - /* Maps the APPC response result to a Policy result. */ - switch (responseValue) { - case LcmResponseCode.ACCEPTED: - /* Nothing to do if code is accept, continue processing */ - result = null; - break; - case LcmResponseCode.SUCCESS: - result = PolicyResult.SUCCESS; - break; - case LcmResponseCode.FAILURE: - result = PolicyResult.FAILURE; - break; - case LcmResponseCode.REJECT: - case LcmResponseCode.ERROR: - default: - result = PolicyResult.FAILURE_EXCEPTION; - } - return new AbstractMap.SimpleEntry<>(result, message); - } - - /** - * This method reads and validates environmental properties coming from the policy engine. Null - * properties cause an {@link IllegalArgumentException} runtime exception to be thrown - * - * @param enginePropertyName the name of the parameter to retrieve - * @return the property value - */ - private static String getPeManagerEnvProperty(String enginePropertyName) { - String enginePropertyValue = PolicyEngine.manager.getEnvironmentProperty(enginePropertyName); - if (enginePropertyValue == null) { - throw new IllegalArgumentException("The value of policy engine manager environment property \"" - + enginePropertyName + "\" may not be null"); - } - return enginePropertyValue; - } -} diff --git a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmRecipeFormatter.java b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmRecipeFormatter.java deleted file mode 100644 index 12fad9e84..000000000 --- a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmRecipeFormatter.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * - * ================================================================================ - * Copyright (C) 2018 Nokia Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2018 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.controlloop.actor.appclcm; - -import com.google.common.collect.Lists; -import java.util.stream.Collectors; -import org.apache.commons.lang.StringUtils; - -class AppcLcmRecipeFormatter { - - private final String dashCasedRecipe; - - AppcLcmRecipeFormatter(String dashCasedRecipe) { - this.dashCasedRecipe = dashCasedRecipe; - } - - String getUrlRecipe() { - return dashCasedRecipe.toLowerCase(); - } - - String getBodyRecipe() { - return Lists.newArrayList(dashCasedRecipe.split("-")) - .stream() - .map(String::toLowerCase) - .map(StringUtils::capitalize) - .collect(Collectors.joining("")); - } -} diff --git a/controlloop/common/actors/actor.appclcm/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor b/controlloop/common/actors/actor.appclcm/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor deleted file mode 100644 index 403ad9859..000000000 --- a/controlloop/common/actors/actor.appclcm/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor +++ /dev/null @@ -1 +0,0 @@ -org.onap.policy.controlloop.actor.appclcm.AppcLcmActorServiceProvider
\ No newline at end of file diff --git a/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java b/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java deleted file mode 100644 index 79bcf153f..000000000 --- a/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProviderTest.java +++ /dev/null @@ -1,442 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * AppcServiceProviderTest - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.actor.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - -import java.time.Instant; -import java.util.AbstractMap; -import java.util.HashMap; -import java.util.UUID; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.aai.util.AaiException; -import org.onap.policy.appclcm.LcmCommonHeader; -import org.onap.policy.appclcm.LcmRequest; -import org.onap.policy.appclcm.LcmRequestWrapper; -import org.onap.policy.appclcm.LcmResponse; -import org.onap.policy.appclcm.LcmResponseWrapper; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.ControlLoopOperation; -import org.onap.policy.controlloop.ControlLoopTargetType; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.controlloop.policy.PolicyResult; -import org.onap.policy.controlloop.policy.Target; -import org.onap.policy.controlloop.policy.TargetType; -import org.onap.policy.drools.system.PolicyEngine; -import org.onap.policy.simulators.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class AppcLcmActorServiceProviderTest { - - private static final Logger logger = LoggerFactory.getLogger(AppcLcmActorServiceProviderTest.class); - - private static final VirtualControlLoopEvent onsetEvent; - private static final ControlLoopOperation operation; - private static final Policy policy; - private static final LcmResponseWrapper dmaapResponse; - - private static final String RECIPE_RESTART = "Restart"; - private static final String RECIPE_REBUILD = "Rebuild"; - private static final String RECIPE_MIGRATE = "Migrate"; - - static { - /* - * Construct an onset with an AAI subtag containing generic-vnf.vnf-id and a target type of - * VM. - */ - onsetEvent = new VirtualControlLoopEvent(); - onsetEvent.setClosedLoopControlName("closedLoopControlName-Test"); - onsetEvent.setRequestId(UUID.randomUUID()); - onsetEvent.setClosedLoopEventClient("tca.instance00001"); - onsetEvent.setTargetType(ControlLoopTargetType.VM); - onsetEvent.setTarget("generic-vnf.vnf-name"); - onsetEvent.setFrom("DCAE"); - onsetEvent.setClosedLoopAlarmStart(Instant.now()); - onsetEvent.setAai(new HashMap<>()); - onsetEvent.getAai().put("generic-vnf.vnf-name", "fw0001vm001fw001"); - onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); - - /* Construct an operation with an APPC actor and restart operation. */ - operation = new ControlLoopOperation(); - operation.setActor("APPC"); - operation.setOperation("Restart"); - operation.setTarget("VM"); - operation.setEnd(Instant.now()); - operation.setSubRequestId("1"); - - /* Construct a policy specifying to restart vm. */ - policy = new Policy(); - policy.setName("Restart the VM"); - policy.setDescription("Upon getting the trigger event, restart the VM"); - policy.setActor("APPC"); - policy.setTarget(new Target(TargetType.VNF)); - policy.setRecipe("Restart"); - policy.setPayload(null); - policy.setRetry(2); - policy.setTimeout(300); - - /* A sample DMAAP request wrapper. */ - LcmRequestWrapper dmaapRequest = new LcmRequestWrapper(); - dmaapRequest.setCorrelationId(onsetEvent.getRequestId().toString() + "-" + "1"); - dmaapRequest.setRpcName(policy.getRecipe().toLowerCase()); - dmaapRequest.setType("request"); - - /* A sample DMAAP response wrapper */ - dmaapResponse = new LcmResponseWrapper(); - dmaapResponse.setCorrelationId(onsetEvent.getRequestId().toString() + "-" + "1"); - dmaapResponse.setRpcName(policy.getRecipe().toLowerCase()); - dmaapResponse.setType("response"); - - /* Set environment properties */ - PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666"); - PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI"); - PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI"); - - /* A sample APPC LCM request. */ - LcmRequest appcRequest = new LcmRequest(); - - /* The following code constructs a sample APPC LCM Request */ - appcRequest.setAction("restart"); - - HashMap<String, String> actionIdentifiers = new HashMap<>(); - actionIdentifiers.put("vnf-id", "trial-vnf-003"); - - appcRequest.setActionIdentifiers(actionIdentifiers); - - LcmCommonHeader commonHeader = new LcmCommonHeader(); - commonHeader.setRequestId(onsetEvent.getRequestId()); - commonHeader.setSubRequestId("1"); - commonHeader.setOriginatorId(onsetEvent.getRequestId().toString()); - - appcRequest.setCommonHeader(commonHeader); - - appcRequest.setPayload(null); - - dmaapRequest.setBody(appcRequest); - - /* The following code constructs a sample APPC LCM Response */ - LcmResponse appcResponse = new LcmResponse(appcRequest); - appcResponse.getStatus().setCode(400); - appcResponse.getStatus().setMessage("Restart Successful"); - - dmaapResponse.setBody(appcResponse); - } - - /** - * Set up before test class. - */ - @BeforeClass - public static void setUpSimulator() { - try { - Util.buildAaiSim(); - } catch (Exception e) { - fail(e.getMessage()); - } - } - - /** - * Tear down after test class. - */ - @AfterClass - public static void tearDownSimulator() { - HttpServletServer.factory.destroy(); - } - - /** - * A test to construct an APPC LCM restart request. - */ - @Test - public void constructRestartRequestTest() { - - LcmRequestWrapper dmaapRequest = - AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, policy, "vnf01"); - - /* The service provider must return a non null DMAAP request wrapper */ - assertNotNull(dmaapRequest); - - /* The DMAAP wrapper's type field must be request */ - assertEquals("request", dmaapRequest.getType()); - - /* The DMAAP wrapper's body field cannot be null */ - assertNotNull(dmaapRequest.getBody()); - - LcmRequest appcRequest = dmaapRequest.getBody(); - - /* A common header is required and cannot be null */ - assertNotNull(appcRequest.getCommonHeader()); - assertEquals(appcRequest.getCommonHeader().getRequestId(), onsetEvent.getRequestId()); - - /* An action is required and cannot be null */ - assertNotNull(appcRequest.getAction()); - assertEquals("Restart", appcRequest.getAction()); - - /* Action Identifiers are required and cannot be null */ - assertNotNull(appcRequest.getActionIdentifiers()); - assertNotNull(appcRequest.getActionIdentifiers().get("vnf-id")); - assertEquals("vnf01", appcRequest.getActionIdentifiers().get("vnf-id")); - - logger.debug("APPC Request: \n" + appcRequest.toString()); - } - - /** - * A test to process a successful APPC restart response. - */ - @Test - public void processRestartResponseSuccessTest() { - AbstractMap.SimpleEntry<PolicyResult, String> result = - AppcLcmActorServiceProvider.processResponse(dmaapResponse); - assertEquals(PolicyResult.SUCCESS, result.getKey()); - assertEquals("Restart Successful", result.getValue()); - } - - /** - * A test to map APPC response results to corresponding Policy results. - */ - @Test - public void appcToPolicyResultTest() { - - AbstractMap.SimpleEntry<PolicyResult, String> result; - - /* If APPC accepts, PolicyResult is null */ - dmaapResponse.getBody().getStatus().setCode(100); - dmaapResponse.getBody().getStatus().setMessage("ACCEPTED"); - result = AppcLcmActorServiceProvider.processResponse(dmaapResponse); - assertNull(result.getKey()); - - /* If APPC is successful, PolicyResult is success */ - dmaapResponse.getBody().getStatus().setCode(400); - dmaapResponse.getBody().getStatus().setMessage("SUCCESS"); - result = AppcLcmActorServiceProvider.processResponse(dmaapResponse); - assertEquals(PolicyResult.SUCCESS, result.getKey()); - - /* If APPC returns an error, PolicyResult is failure exception */ - dmaapResponse.getBody().getStatus().setCode(200); - dmaapResponse.getBody().getStatus().setMessage("ERROR"); - result = AppcLcmActorServiceProvider.processResponse(dmaapResponse); - assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey()); - - /* If APPC rejects, PolicyResult is failure exception */ - dmaapResponse.getBody().getStatus().setCode(300); - dmaapResponse.getBody().getStatus().setMessage("REJECT"); - result = AppcLcmActorServiceProvider.processResponse(dmaapResponse); - assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey()); - - /* Test multiple reject codes */ - dmaapResponse.getBody().getStatus().setCode(306); - dmaapResponse.getBody().getStatus().setMessage("REJECT"); - result = AppcLcmActorServiceProvider.processResponse(dmaapResponse); - assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey()); - - dmaapResponse.getBody().getStatus().setCode(313); - dmaapResponse.getBody().getStatus().setMessage("REJECT"); - result = AppcLcmActorServiceProvider.processResponse(dmaapResponse); - assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey()); - - /* If APPC returns failure, PolicyResult is failure */ - dmaapResponse.getBody().getStatus().setCode(401); - dmaapResponse.getBody().getStatus().setMessage("FAILURE"); - result = AppcLcmActorServiceProvider.processResponse(dmaapResponse); - assertEquals(PolicyResult.FAILURE, result.getKey()); - - /* Test multiple failure codes */ - dmaapResponse.getBody().getStatus().setCode(406); - dmaapResponse.getBody().getStatus().setMessage("FAILURE"); - result = AppcLcmActorServiceProvider.processResponse(dmaapResponse); - assertEquals(PolicyResult.FAILURE, result.getKey()); - - dmaapResponse.getBody().getStatus().setCode(450); - dmaapResponse.getBody().getStatus().setMessage("FAILURE"); - result = AppcLcmActorServiceProvider.processResponse(dmaapResponse); - assertEquals(PolicyResult.FAILURE, result.getKey()); - - /* If APPC returns partial success, PolicyResult is failure exception */ - dmaapResponse.getBody().getStatus().setCode(500); - dmaapResponse.getBody().getStatus().setMessage("PARTIAL SUCCESS"); - result = AppcLcmActorServiceProvider.processResponse(dmaapResponse); - assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey()); - - /* If APPC returns partial failure, PolicyResult is failure exception */ - dmaapResponse.getBody().getStatus().setCode(501); - dmaapResponse.getBody().getStatus().setMessage("PARTIAL FAILURE"); - result = AppcLcmActorServiceProvider.processResponse(dmaapResponse); - assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey()); - - /* Test multiple partial failure codes */ - dmaapResponse.getBody().getStatus().setCode(599); - dmaapResponse.getBody().getStatus().setMessage("PARTIAL FAILURE"); - result = AppcLcmActorServiceProvider.processResponse(dmaapResponse); - assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey()); - - dmaapResponse.getBody().getStatus().setCode(550); - dmaapResponse.getBody().getStatus().setMessage("PARTIAL FAILURE"); - result = AppcLcmActorServiceProvider.processResponse(dmaapResponse); - assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey()); - - /* If APPC code is unknown to Policy, PolicyResult is failure exception */ - dmaapResponse.getBody().getStatus().setCode(700); - dmaapResponse.getBody().getStatus().setMessage("UNKNOWN"); - result = AppcLcmActorServiceProvider.processResponse(dmaapResponse); - assertEquals(PolicyResult.FAILURE_EXCEPTION, result.getKey()); - } - - /** - * This test ensures that that if the the source entity is also the target entity, the source - * will be used for the APPC request. - */ - @Test - public void sourceIsTargetTest() { - String resourceId = "82194af1-3c2c-485a-8f44-420e22a9eaa4"; - String targetVnfId = null; - try { - targetVnfId = AppcLcmActorServiceProvider.vnfNamedQuery(resourceId, "vnf01"); - } catch (AaiException e) { - logger.warn(e.toString()); - fail("no vnf-id found"); - } - assertNotNull(targetVnfId); - assertEquals("vnf01", targetVnfId); - } - - /** - * THis test exercises getters not exercised in other tests. - */ - @Test - public void testMethods() { - AppcLcmActorServiceProvider sp = new AppcLcmActorServiceProvider(); - - assertEquals("APPC", sp.actor()); - assertEquals(4, sp.recipes().size()); - assertEquals("VM", sp.recipeTargets("Restart").get(0)); - assertEquals("vm-id", sp.recipePayloads("Restart").get(0)); - } - - @Test - public void payloadNotPassedWhenNotSupportedByRecipe() { - //given - Policy migratePolicy = constructPolicyWithRecipe(RECIPE_MIGRATE); - Policy rebuildPolicy = constructPolicyWithRecipe(RECIPE_REBUILD); - Policy restartPolicy = constructPolicyWithRecipe(RECIPE_RESTART); - - // when - LcmRequestWrapper migrateRequest = - AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, migratePolicy, "vnf01"); - LcmRequestWrapper rebuildRequest = - AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, rebuildPolicy, "vnf01"); - LcmRequestWrapper restartRequest = - AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, restartPolicy, "vnf01"); - - // then - assertNull(migrateRequest.getBody().getPayload()); - assertNull(rebuildRequest.getBody().getPayload()); - assertNull(restartRequest.getBody().getPayload()); - } - - @Test - public void payloadNotPassedWhenNotSuppliedOrEmpty() { - //given - Policy noPayloadPolicy = constructHealthCheckPolicyWithPayload(null); - Policy emptyPayloadPolicy = constructHealthCheckPolicyWithPayload(new HashMap<>()); - - // when - LcmRequestWrapper noPayloadRequest = - AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, noPayloadPolicy, "vnf01"); - LcmRequestWrapper emptyPayloadRequest = - AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, emptyPayloadPolicy, "vnf01"); - - - // then - assertNull(noPayloadRequest.getBody().getPayload()); - assertNull(emptyPayloadRequest.getBody().getPayload()); - } - - @Test - public void payloadParsedProperlyForSinglePayloadParameter() { - // given - HashMap<String, String> payload = new HashMap<>(); - payload.put("requestParameters", "{\"host-ip-address\":\"10.183.37.25\"}"); - Policy otherPolicy = constructHealthCheckPolicyWithPayload(payload); - - // when - LcmRequestWrapper dmaapRequest = - AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, otherPolicy, "vnf01"); - - // then - assertEquals(dmaapRequest.getBody().getPayload(), - "{\"requestParameters\": {\"host-ip-address\":\"10.183.37.25\"}}"); - } - - - @Test - public void payloadParsedProperlyForMultiplePayloadParameters() { - // given - HashMap<String, String> payload = new HashMap<>(); - payload.put("requestParameters", "{\"host-ip-address\":\"10.183.37.25\"}"); - payload.put("configurationParameters", "[{\"ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[9]\"," - + "\"oam-ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[16]\"," - + "\"enabled\":\"$.vf-module-topology.vf-module-parameters.param[23]\"}]"); - Policy otherPolicy = constructHealthCheckPolicyWithPayload(payload); - - // when - LcmRequestWrapper dmaapRequest = - AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, otherPolicy, "vnf01"); - - // then - assertEquals(dmaapRequest.getBody().getPayload(), - "{\"requestParameters\": " - + "{\"host-ip-address\":\"10.183.37.25\"}," - + "\"configurationParameters\": " - + "[{\"ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[9]\"," - + "\"oam-ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[16]\"," - + "\"enabled\":\"$.vf-module-topology.vf-module-parameters.param[23]\"}]" - + "}"); - } - - private Policy constructHealthCheckPolicyWithPayload(HashMap<String, String> payload) { - return constructHealthCheckPolicyWithPayloadAndRecipe(payload, "Health-Check"); - } - - private Policy constructPolicyWithRecipe(String recipe) { - return constructHealthCheckPolicyWithPayloadAndRecipe(null, recipe); - } - - private Policy constructHealthCheckPolicyWithPayloadAndRecipe(HashMap<String, String> payload, String recipe) { - Policy otherPolicy = new Policy(); - otherPolicy.setName("Perform health check"); - otherPolicy.setDescription("Upon getting the trigger event, perform health check"); - otherPolicy.setActor("APPC"); - otherPolicy.setTarget(new Target(TargetType.VNF)); - otherPolicy.setRecipe(recipe); - otherPolicy.setPayload(payload); - otherPolicy.setRetry(2); - otherPolicy.setTimeout(300); - return otherPolicy; - } -} diff --git a/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmRecipeFormatterTest.java b/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmRecipeFormatterTest.java deleted file mode 100644 index e63b04acd..000000000 --- a/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmRecipeFormatterTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * - * ================================================================================ - * Copyright (C) 2018 Nokia 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.controlloop.actor.appclcm; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - - - -public class AppcLcmRecipeFormatterTest { - - @Test - public void shouldCorrectlyFormatRestartRequestWhenRestartGiven() { - //given - AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("Restart"); - String expectedUrlRecipe = "restart"; - String expectedBodyRecipe = "Restart"; - - //when - String actualUrlRecipe = recipeFormatter.getUrlRecipe(); - String actualBodyRecipe = recipeFormatter.getBodyRecipe(); - - //then - assertEquals(expectedUrlRecipe, actualUrlRecipe); - assertEquals(expectedBodyRecipe, actualBodyRecipe); - } - - @Test - public void shouldReturnCapitalizedBodySingleWordRecipe() { - //given - AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("moDify"); - String expectedRecipe = "Modify"; - - //when - String actualRecipe = recipeFormatter.getBodyRecipe(); - - //then - assertEquals(expectedRecipe, actualRecipe); - } - - @Test - public void shouldReturnCapitalizeAndJoinedBodyMultiWordRecipe() { - //given - AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("coNfig-moDify"); - String expectedRecipe = "ConfigModify"; - - //when - String actualRecipe = recipeFormatter.getBodyRecipe(); - - //then - assertEquals(expectedRecipe, actualRecipe); - } - - @Test - public void shouldReturnLowercasedUrlSingleWordRecipe() { - //given - AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("ModIfy"); - String expectedRecipe = "modify"; - - //when - String actualRecipe = recipeFormatter.getUrlRecipe(); - - //then - assertEquals(expectedRecipe, actualRecipe); - } - - @Test - public void shouldReturnLowercasedDashJoinedUrlMultiWordRecipe() { - //given - AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("Config-MoDify"); - String expectedRecipe = "config-modify"; - - //when - String actualRecipe = recipeFormatter.getUrlRecipe(); - - //then - assertEquals(expectedRecipe, actualRecipe); - } -}
\ No newline at end of file diff --git a/controlloop/common/actors/actor.sdnc/pom.xml b/controlloop/common/actors/actor.sdnc/pom.xml deleted file mode 100644 index 8c26ce8c4..000000000 --- a/controlloop/common/actors/actor.sdnc/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - drools-pdp-apps - ================================================================================ - Copyright (C) 2018 Huawei 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========================================================= - --> - -<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.drools-applications.controlloop.common.actors</groupId> - <artifactId>actors</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>actor.sdnc</artifactId> - - <dependencies> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId> - <artifactId>actorServiceProvider</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>sdnc</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>events</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>aai</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.common</groupId> - <artifactId>policy-endpoints</artifactId> - <version>${version.policy.common}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-pdp</groupId> - <artifactId>policy-management</artifactId> - <version>${version.policy.drools-pdp}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> - <artifactId>simulators</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - </dependencies> -</project> diff --git a/controlloop/common/actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProvider.java b/controlloop/common/actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProvider.java deleted file mode 100644 index 9d7660c5d..000000000 --- a/controlloop/common/actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProvider.java +++ /dev/null @@ -1,199 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SdncActorServiceProvider - * ================================================================================ - * Copyright (C) 2018-2019 Huawei Technologies Co., Ltd. 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.controlloop.actor.sdnc; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -import java.util.Collections; -import java.util.List; -import java.util.UUID; - -import org.onap.policy.controlloop.ControlLoopOperation; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.sdnc.SdncHealNetworkInfo; -import org.onap.policy.sdnc.SdncHealRequest; -import org.onap.policy.sdnc.SdncHealRequestHeaderInfo; -import org.onap.policy.sdnc.SdncHealRequestInfo; -import org.onap.policy.sdnc.SdncHealServiceInfo; -import org.onap.policy.sdnc.SdncHealVfModuleParameter; -import org.onap.policy.sdnc.SdncHealVfModuleParametersInfo; -import org.onap.policy.sdnc.SdncHealVfModuleRequestInput; -import org.onap.policy.sdnc.SdncHealVnfInfo; - -import org.onap.policy.sdnc.SdncRequest; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class SdncActorServiceProvider implements Actor { - private static final Logger logger = LoggerFactory.getLogger(SdncActorServiceProvider.class); - - // Strings for Sdnc Actor - private static final String SDNC_ACTOR = "SDNC"; - - // Strings for targets - private static final String TARGET_VM = "VM"; - - // Strings for recipes - private static final String RECIPE_REROUTE = "Reroute"; - - // Strings for recipes - private static final String RECIPE_BW_ON_DEMAND = "BandwidthOnDemand"; - - private static final ImmutableList<String> recipes = ImmutableList.of(RECIPE_REROUTE); - private static final ImmutableMap<String, List<String>> targets = - new ImmutableMap.Builder<String, List<String>>().put(RECIPE_REROUTE, ImmutableList.of(TARGET_VM)).build(); - - @Override - public String actor() { - return SDNC_ACTOR; - } - - @Override - public List<String> recipes() { - return ImmutableList.copyOf(recipes); - } - - @Override - public List<String> recipeTargets(String recipe) { - return ImmutableList.copyOf(targets.getOrDefault(recipe, Collections.emptyList())); - } - - @Override - public List<String> recipePayloads(String recipe) { - return Collections.emptyList(); - } - - /** - * Construct a request. - * - * @param onset the onset event - * @param operation the control loop operation - * @param policy the policy - * @return the constructed request - */ - public SdncRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, - Policy policy) { - switch (policy.getRecipe()) { - case RECIPE_REROUTE: - return constructReOptimizeRequest(onset); - case RECIPE_BW_ON_DEMAND: - logger.info("Construct request for receipe {}" , RECIPE_BW_ON_DEMAND); - return constructBwOnDemandRequest(onset); - default: - logger.info("Unsupported recipe {} " + policy.getRecipe()); - return null; - } - } - - private SdncRequest constructBwOnDemandRequest(VirtualControlLoopEvent onset) { - // Construct an Sdnc request - String serviceInstance = onset.getAai().get("service-instance.service-instance-id"); - if (serviceInstance == null || serviceInstance.isEmpty()) { - // This indicates that AAI Enrichment needs to be done by event producer. - return null; - } - SdncHealVfModuleParameter bandwidth = new SdncHealVfModuleParameter(); - bandwidth.setName("bandwidth"); - bandwidth.setValue(onset.getAai().get("bandwidth")); - - SdncHealVfModuleParameter timeStamp = new SdncHealVfModuleParameter(); - timeStamp.setName("bandwidth-change-time"); - timeStamp.setValue(onset.getAai().get("bandwidth-change-time")); - - SdncHealVfModuleParametersInfo vfParametersInfo = new SdncHealVfModuleParametersInfo(); - vfParametersInfo.addParameters(bandwidth); - vfParametersInfo.addParameters(timeStamp); - - SdncHealVfModuleRequestInput vfRequestInfo = new SdncHealVfModuleRequestInput(); - vfRequestInfo.setVfModuleParametersInfo(vfParametersInfo); - - SdncHealServiceInfo serviceInfo = new SdncHealServiceInfo(); - serviceInfo.setServiceInstanceId(serviceInstance); - - SdncHealRequestInfo requestInfo = new SdncHealRequestInfo(); - requestInfo.setRequestAction("SdwanBandwidthChange"); - - SdncHealRequestHeaderInfo headerInfo = new SdncHealRequestHeaderInfo(); - headerInfo.setSvcAction("update"); - headerInfo.setSvcRequestId(UUID.randomUUID().toString()); - - SdncRequest request = new SdncRequest(); - request.setNsInstanceId(serviceInstance); - request.setRequestId(onset.getRequestId()); - request.setUrl("/GENERIC-RESOURCE-API:vnf-topology-operation"); - - SdncHealVnfInfo vnfInfo = new SdncHealVnfInfo(); - vnfInfo.setVnfId(onset.getAai().get("vnfId")); - - SdncHealRequest healRequest = new SdncHealRequest(); - healRequest.setVnfInfo(vnfInfo); - healRequest.setRequestHeaderInfo(headerInfo); - healRequest.setVfModuleRequestInput(vfRequestInfo); - healRequest.setRequestInfo(requestInfo); - healRequest.setServiceInfo(serviceInfo); - request.setHealRequest(healRequest); - return request; - } - - private SdncRequest constructReOptimizeRequest(VirtualControlLoopEvent onset) { - // Construct an Sdnc request - String serviceInstance = onset.getAai().get("service-instance.service-instance-id"); - if (serviceInstance == null || serviceInstance.isEmpty()) { - // This indicates that AAI Enrichment needs to be done by event producer. - return null; - } - SdncHealServiceInfo serviceInfo = new SdncHealServiceInfo(); - serviceInfo.setServiceInstanceId(serviceInstance); - - String networkId = onset.getAai().get("network-information.network-id"); - if (networkId == null || networkId.isEmpty()) { - // This indicates that AAI Enrichment needs to be done by event producer. - return null; - } - SdncHealNetworkInfo networkInfo = new SdncHealNetworkInfo(); - networkInfo.setNetworkId(networkId); - - SdncHealRequestInfo requestInfo = new SdncHealRequestInfo(); - requestInfo.setRequestAction("ReoptimizeSOTNInstance"); - - SdncHealRequestHeaderInfo headerInfo = new SdncHealRequestHeaderInfo(); - headerInfo.setSvcAction("reoptimize"); - headerInfo.setSvcRequestId(UUID.randomUUID().toString()); - - SdncRequest request = new SdncRequest(); - request.setNsInstanceId(serviceInstance); - request.setRequestId(onset.getRequestId()); - request.setUrl("/GENERIC-RESOURCE-API:network-topology-operation"); - - SdncHealRequest healRequest = new SdncHealRequest(); - healRequest.setRequestHeaderInfo(headerInfo); - healRequest.setNetworkInfo(networkInfo); - healRequest.setRequestInfo(requestInfo); - healRequest.setServiceInfo(serviceInfo); - request.setHealRequest(healRequest); - return request; - } -}
\ No newline at end of file diff --git a/controlloop/common/actors/actor.sdnc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor b/controlloop/common/actors/actor.sdnc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor deleted file mode 100644 index f4d1e975e..000000000 --- a/controlloop/common/actors/actor.sdnc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor +++ /dev/null @@ -1 +0,0 @@ -org.onap.policy.controlloop.actor.sdnc.SdncActorServiceProvider
\ No newline at end of file diff --git a/controlloop/common/actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProviderTest.java b/controlloop/common/actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProviderTest.java deleted file mode 100644 index f968f8609..000000000 --- a/controlloop/common/actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProviderTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * TestSdncActorServiceProvider - * ================================================================================ - * Copyright (C) 2018-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corp. 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.controlloop.actor.sdnc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - -import java.util.Objects; -import java.util.UUID; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.aai.AaiGetVnfResponse; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; -import org.onap.policy.controlloop.ControlLoopOperation; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.drools.system.PolicyEngine; -import org.onap.policy.sdnc.SdncRequest; -import org.onap.policy.simulators.Util; - -public class SdncActorServiceProviderTest { - - /** - * Set up for test class. - */ - @BeforeClass - public static void setUpSimulator() { - try { - Util.buildAaiSim(); - } catch (Exception e) { - fail(e.getMessage()); - } - } - - @AfterClass - public static void tearDownSimulator() { - HttpServletServer.factory.destroy(); - } - - @Test - public void testConstructRequest() { - VirtualControlLoopEvent onset = new VirtualControlLoopEvent(); - ControlLoopOperation operation = new ControlLoopOperation(); - - Policy policy = new Policy(); - policy.setRecipe("Reroute"); - - SdncActorServiceProvider provider = new SdncActorServiceProvider(); - assertNull(provider.constructRequest(onset, operation, policy)); - - onset.getAai().put("network-information.network-id", "network-5555"); - assertNull(provider.constructRequest(onset, operation, policy)); - - PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666"); - PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI"); - PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI"); - assertNull(provider.constructRequest(onset, operation, policy)); - - UUID requestId = UUID.randomUUID(); - onset.setRequestId(requestId); - assertNull(provider.constructRequest(onset, operation, policy)); - - PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI"); - assertNull(provider.constructRequest(onset, operation, policy)); - - onset.getAai().put("service-instance.service-instance-id", "service-instance-01"); - assertNotNull(provider.constructRequest(onset, operation, policy)); - - policy.setRecipe("Reroute"); - assertNotNull(provider.constructRequest(onset, operation, policy)); - - SdncRequest request = - provider.constructRequest(onset, operation, policy); - - assertEquals(requestId, Objects.requireNonNull(request).getRequestId()); - assertEquals("reoptimize", request.getHealRequest().getRequestHeaderInfo().getSvcAction()); - assertEquals("ReoptimizeSOTNInstance", request.getHealRequest().getRequestInfo().getRequestAction()); - assertEquals("network-5555", request.getHealRequest().getNetworkInfo().getNetworkId()); - assertEquals("service-instance-01", request.getHealRequest().getServiceInfo().getServiceInstanceId()); - } - - @Test - public void testMethods() { - SdncActorServiceProvider sp = new SdncActorServiceProvider(); - - assertEquals("SDNC", sp.actor()); - assertEquals(1, sp.recipes().size()); - assertEquals("Reroute", sp.recipes().get(0)); - assertEquals("VM", sp.recipeTargets("Reroute").get(0)); - assertEquals(0, sp.recipePayloads("Reroute").size()); - } -} diff --git a/controlloop/common/actors/actor.sdnr/pom.xml b/controlloop/common/actors/actor.sdnr/pom.xml deleted file mode 100644 index 671bab6c9..000000000 --- a/controlloop/common/actors/actor.sdnr/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - drools-pdp-apps - ================================================================================ - Copyright (C) 2018 Wipro Limited 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========================================================= - --> - -<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.drools-applications.controlloop.common.actors</groupId> - <artifactId>actors</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>actor.sdnr</artifactId> - - <dependencies> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId> - <artifactId>actorServiceProvider</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>sdnr</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>events</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> - <artifactId>simulators</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.common</groupId> - <artifactId>policy-endpoints</artifactId> - <version>${version.policy.common}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-pdp</groupId> - <artifactId>policy-management</artifactId> - <version>${version.policy.drools-pdp}</version> - <scope>provided</scope> - </dependency> - </dependencies> -</project> diff --git a/controlloop/common/actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProvider.java b/controlloop/common/actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProvider.java deleted file mode 100644 index d6ec1d219..000000000 --- a/controlloop/common/actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProvider.java +++ /dev/null @@ -1,290 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SdnrActorServiceProvider - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.controlloop.actor.sdnr; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -import java.util.Collections; -import java.util.List; - -import org.onap.policy.controlloop.ControlLoopOperation; -import org.onap.policy.controlloop.ControlLoopResponse; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.controlloop.policy.PolicyResult; -import org.onap.policy.sdnr.PciCommonHeader; -import org.onap.policy.sdnr.PciRequest; -import org.onap.policy.sdnr.PciRequestWrapper; -import org.onap.policy.sdnr.PciResponse; -import org.onap.policy.sdnr.PciResponseCode; -import org.onap.policy.sdnr.PciResponseWrapper; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SdnrActorServiceProvider implements Actor { - - public static class Pair<A, B> { - public final A result; - public final B message; - - public Pair(A result, B message) { - this.result = result; - this.message = message; - } - - public A getResult() { - return this.result; - } - - public B getMessage() { - return this.message; - } - } - - private static final Logger logger = LoggerFactory.getLogger(SdnrActorServiceProvider.class); - - // Strings for targets - private static final String TARGET_VNF = "VNF"; - - // Strings for recipes - private static final String RECIPE_MODIFY = "ModifyConfig"; - private static final String RECIPE_MODIFY_ANR = "ModifyConfigANR"; - - /* To be used in future releases when pci ModifyConfig is used */ - private static final String SDNR_REQUEST_PARAMS = "request-parameters"; - private static final String SDNR_CONFIG_PARAMS = "configuration-parameters"; - - private static final ImmutableList<String> recipes = ImmutableList.of(RECIPE_MODIFY); - private static final ImmutableMap<String, List<String>> targets = new ImmutableMap.Builder<String, List<String>>() - .put(RECIPE_MODIFY, ImmutableList.of(TARGET_VNF)).build(); - private static final ImmutableMap<String, List<String>> payloads = new ImmutableMap.Builder<String, List<String>>() - .put(RECIPE_MODIFY, ImmutableList.of(SDNR_REQUEST_PARAMS, SDNR_CONFIG_PARAMS)).build(); - - @Override - public String actor() { - return "SDNR"; - } - - @Override - public List<String> recipes() { - return ImmutableList.copyOf(recipes); - } - - @Override - public List<String> recipeTargets(String recipe) { - return ImmutableList.copyOf(targets.getOrDefault(recipe, Collections.emptyList())); - } - - @Override - public List<String> recipePayloads(String recipe) { - return ImmutableList.copyOf(payloads.getOrDefault(recipe, Collections.emptyList())); - } - - /** - * Constructs an SDNR request conforming to the pci API. The actual request is - * constructed and then placed in a wrapper object used to send through DMAAP. - * - * @param onset - * the event that is reporting the alert for policy to perform an - * action - * @param operation - * the control loop operation specifying the actor, operation, - * target, etc. - * @param policy - * the policy the was specified from the yaml generated by CLAMP or - * through the Policy GUI/API - * @return an SDNR request conforming to the pci API using the DMAAP wrapper - */ - - public static PciRequestWrapper constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, - Policy policy) { - - /* Construct an SDNR request using pci Model */ - - /* - * The actual pci request is placed in a wrapper used to send through dmaap. The - * current version is 2.0 as of R1. - */ - PciRequestWrapper dmaapRequest = new PciRequestWrapper(); - dmaapRequest.setVersion("1.0"); - dmaapRequest.setCorrelationId(onset.getRequestId() + "-" + operation.getSubRequestId()); - dmaapRequest.setRpcName(policy.getRecipe().toLowerCase()); - dmaapRequest.setType("request"); - - /* This is the actual request that is placed in the dmaap wrapper. */ - final PciRequest sdnrRequest = new PciRequest(); - - /* The common header is a required field for all SDNR requests. */ - PciCommonHeader requestCommonHeader = new PciCommonHeader(); - requestCommonHeader.setRequestId(onset.getRequestId()); - requestCommonHeader.setSubRequestId(operation.getSubRequestId()); - - sdnrRequest.setCommonHeader(requestCommonHeader); - sdnrRequest.setPayload(onset.getPayload()); - - /* - * An action is required for all SDNR requests, this will be the recipe - * specified in the policy. - */ - sdnrRequest.setAction(policy.getRecipe()); - - /* - * Once the pci request is constructed, add it into the body of the dmaap - * wrapper. - */ - dmaapRequest.setBody(sdnrRequest); - logger.info("SDNR Request to be sent is {}", dmaapRequest); - - /* Return the request to be sent through dmaap. */ - return dmaapRequest; - } - - /** - * Parses the operation attempt using the subRequestId of SDNR response. - * - * @param subRequestId - * the sub id used to send to SDNR, Policy sets this using the - * operation attempt - * - * @return the current operation attempt - */ - public static Integer parseOperationAttempt(String subRequestId) { - Integer operationAttempt; - try { - operationAttempt = Integer.parseInt(subRequestId); - } catch (NumberFormatException e) { - logger.debug("A NumberFormatException was thrown in parsing the operation attempt {}", subRequestId); - return null; - } - return operationAttempt; - } - - /** - * Processes the SDNR pci response sent from SDNR. Determines if the SDNR - * operation was successful/unsuccessful and maps this to the corresponding - * Policy result. - * - * @param dmaapResponse - * the dmaap wrapper message that contains the actual SDNR reponse - * inside the body field - * - * @return an key-value pair that contains the Policy result and SDNR response - * message - */ - public static SdnrActorServiceProvider.Pair<PolicyResult, String> processResponse( - PciResponseWrapper dmaapResponse) { - - logger.info("SDNR processResponse called : {}", dmaapResponse); - - /* The actual SDNR response is inside the wrapper's body field. */ - PciResponse sdnrResponse = dmaapResponse.getBody(); - - /* The message returned in the SDNR response. */ - String message; - - /* The Policy result determined from the SDNR Response. */ - PolicyResult result; - - /* - * If there is no status, Policy cannot determine if the request was successful. - */ - if (sdnrResponse.getStatus() == null) { - message = "Policy was unable to parse SDN-R response status field (it was null)."; - return new SdnrActorServiceProvider.Pair<>(PolicyResult.FAILURE_EXCEPTION, message); - } - - /* - * If there is no code, Policy cannot determine if the request was successful. - */ - String responseValue = PciResponseCode.toResponseValue(sdnrResponse.getStatus().getCode()); - if (responseValue == null) { - message = "Policy was unable to parse SDN-R response status code field."; - return new SdnrActorServiceProvider.Pair<>(PolicyResult.FAILURE_EXCEPTION, message); - } - logger.info("SDNR Response Code is {}", responseValue); - - /* Save the SDNR response's message for Policy notification message. */ - message = sdnrResponse.getStatus().getValue(); - logger.info("SDNR Response Message is {}", message); - - /* - * Response and Payload are just printed and no further action needed in - * casablanca release - */ - String rspPayload = sdnrResponse.getPayload(); - logger.info("SDNR Response Payload is {}", rspPayload); - - /* Maps the SDNR response result to a Policy result. */ - switch (responseValue) { - case PciResponseCode.ACCEPTED: - /* Nothing to do if code is accept, continue processing */ - result = null; - break; - case PciResponseCode.SUCCESS: - result = PolicyResult.SUCCESS; - break; - case PciResponseCode.FAILURE: - result = PolicyResult.FAILURE; - break; - case PciResponseCode.REJECT: - case PciResponseCode.ERROR: - default: - result = PolicyResult.FAILURE_EXCEPTION; - } - return new SdnrActorServiceProvider.Pair<>(result, message); - } - - /** - * Converts the SDNR response to ControlLoopResponse object. - * - * @param dmaapResponse - * the dmaap wrapper message that contains the actual SDNR reponse - * inside the body field - * - * @return a ControlLoopResponse object to send to DCAE_CL_RSP topic - */ - public static ControlLoopResponse getControlLoopResponse(PciResponseWrapper dmaapResponse, - VirtualControlLoopEvent event) { - - logger.info("SDNR getClosedLoopResponse called : {} {}", dmaapResponse, event); - - /* The actual SDNR response is inside the wrapper's body field. */ - PciResponse sdnrResponse = dmaapResponse.getBody(); - - /* The ControlLoop response determined from the SDNR Response and input event. */ - ControlLoopResponse clRsp = new ControlLoopResponse(); - clRsp.setPayload(sdnrResponse.getPayload()); - clRsp.setFrom("SDNR"); - clRsp.setTarget("DCAE"); - clRsp.setClosedLoopControlName(event.getClosedLoopControlName()); - clRsp.setPolicyName(event.getPolicyName()); - clRsp.setPolicyVersion(event.getPolicyVersion()); - clRsp.setRequestId(event.getRequestId()); - clRsp.setVersion(event.getVersion()); - logger.info("SDNR getClosedLoopResponse clRsp : {}", clRsp); - - return clRsp; - } - -} diff --git a/controlloop/common/actors/actor.sdnr/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor b/controlloop/common/actors/actor.sdnr/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor deleted file mode 100644 index c8d5e4c41..000000000 --- a/controlloop/common/actors/actor.sdnr/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor +++ /dev/null @@ -1 +0,0 @@ -org.onap.policy.controlloop.actor.sdnr.SdnrActorServiceProvider diff --git a/controlloop/common/actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProviderTest.java b/controlloop/common/actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProviderTest.java deleted file mode 100644 index ac302565c..000000000 --- a/controlloop/common/actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProviderTest.java +++ /dev/null @@ -1,169 +0,0 @@ -/*- - * SdnrActorServiceProviderTest - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.controlloop.actor.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.time.Instant; -import java.util.HashMap; -import java.util.UUID; - -import org.junit.Test; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.ControlLoopOperation; -import org.onap.policy.controlloop.ControlLoopResponse; -import org.onap.policy.controlloop.ControlLoopTargetType; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.controlloop.policy.Target; -import org.onap.policy.controlloop.policy.TargetType; -import org.onap.policy.sdnr.PciRequest; -import org.onap.policy.sdnr.PciResponse; -import org.onap.policy.sdnr.PciResponseWrapper; -import org.onap.policy.sdnr.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SdnrActorServiceProviderTest { - - private static final Logger logger = LoggerFactory.getLogger(SdnrActorServiceProviderTest.class); - - private static final VirtualControlLoopEvent onsetEvent; - private static final ControlLoopOperation operation; - private static final Policy policy; - - static { - /* - * Construct an onset. Using dummy AAI details since the code mandates AAI - * details. - */ - onsetEvent = new VirtualControlLoopEvent(); - onsetEvent.setClosedLoopControlName("closedLoopControlName-Test"); - onsetEvent.setRequestId(UUID.randomUUID()); - onsetEvent.setClosedLoopEventClient("tca.instance00001"); - onsetEvent.setTargetType(ControlLoopTargetType.VNF); - onsetEvent.setTarget("generic-vnf.vnf-name"); - onsetEvent.setFrom("DCAE"); - onsetEvent.setClosedLoopAlarmStart(Instant.now()); - onsetEvent.setAai(new HashMap<>()); - onsetEvent.getAai().put("generic-vnf.vnf-name", "notused"); - onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); - onsetEvent.setPayload("some payload"); - - /* Construct an operation with an SDNR actor and ModifyConfig operation. */ - operation = new ControlLoopOperation(); - operation.setActor("SDNR"); - operation.setOperation("ModifyConfig"); - operation.setTarget("VNF"); - operation.setEnd(Instant.now()); - operation.setSubRequestId("1"); - - /* Construct a policy specifying to modify configuration. */ - policy = new Policy(); - policy.setName("Modify PCI Config"); - policy.setDescription("Upon getting the trigger event, modify pci config"); - policy.setActor("SDNR"); - policy.setTarget(new Target(TargetType.VNF)); - policy.getTarget().setResourceID("Eace933104d443b496b8.nodes.heat.vpg"); - policy.setRecipe("ModifyConfig"); - policy.setPayload(null); - policy.setRetry(2); - policy.setTimeout(300); - - } - - @Test - public void getControlLoopResponseTest() { - PciRequest sdnrRequest; - sdnrRequest = SdnrActorServiceProvider.constructRequest(onsetEvent, operation, policy).getBody(); - PciResponse sdnrResponse = new PciResponse(sdnrRequest); - sdnrResponse.getStatus().setCode(200); - sdnrResponse.getStatus().setValue("SDNR success"); - sdnrResponse.setPayload("sdnr payload "); - /* Print out request as json to make sure serialization works */ - String jsonResponse = Serialization.gsonPretty.toJson(sdnrResponse); - logger.info(jsonResponse); - PciResponseWrapper pciResponseWrapper = new PciResponseWrapper(); - pciResponseWrapper.setBody(sdnrResponse); - - ControlLoopResponse clRsp = SdnrActorServiceProvider.getControlLoopResponse(pciResponseWrapper, onsetEvent); - assertEquals(clRsp.getClosedLoopControlName(), onsetEvent.getClosedLoopControlName()); - assertEquals(clRsp.getRequestId(), onsetEvent.getRequestId()); - assertEquals(clRsp.getPolicyName(), onsetEvent.getPolicyName()); - assertEquals(clRsp.getPolicyVersion(), onsetEvent.getPolicyVersion()); - assertEquals(clRsp.getVersion(), onsetEvent.getVersion()); - assertEquals(clRsp.getFrom(), "SDNR"); - assertEquals(clRsp.getTarget(), "DCAE"); - assertEquals(clRsp.getPayload(), sdnrResponse.getPayload()); - } - - @Test - public void constructModifyConfigRequestTest() { - - PciRequest sdnrRequest; - sdnrRequest = SdnrActorServiceProvider.constructRequest(onsetEvent, operation, policy).getBody(); - - /* The service provider must return a non null SDNR request */ - assertNotNull(sdnrRequest); - - /* A common header is required and cannot be null */ - assertNotNull(sdnrRequest.getCommonHeader()); - assertEquals(sdnrRequest.getCommonHeader().getRequestId(), onsetEvent.getRequestId()); - - /* An action is required and cannot be null */ - assertNotNull(sdnrRequest.getAction()); - assertEquals("ModifyConfig", sdnrRequest.getAction()); - - /* A payload is required and cannot be null */ - assertNotNull(sdnrRequest.getPayload()); - assertEquals("some payload", sdnrRequest.getPayload()); - - logger.debug("SDNR Request: \n" + sdnrRequest.toString()); - - /* Print out request as json to make sure serialization works */ - String jsonRequest = Serialization.gsonPretty.toJson(sdnrRequest); - logger.debug("JSON Output: \n" + jsonRequest); - - /* The JSON string must contain the following fields */ - assertTrue(jsonRequest.contains("CommonHeader")); - assertTrue(jsonRequest.contains("Action")); - assertTrue(jsonRequest.contains("ModifyConfig")); - assertTrue(jsonRequest.contains("payload")); - - PciResponse sdnrResponse = new PciResponse(sdnrRequest); - sdnrResponse.getStatus().setCode(200); - sdnrResponse.getStatus().setValue("SDNR success"); - /* Print out request as json to make sure serialization works */ - String jsonResponse = Serialization.gsonPretty.toJson(sdnrResponse); - logger.debug("JSON Output: \n" + jsonResponse); - } - - @Test - public void testMethods() { - SdnrActorServiceProvider sp = new SdnrActorServiceProvider(); - - assertEquals("SDNR", sp.actor()); - assertEquals(1, sp.recipes().size()); - assertEquals("VNF", sp.recipeTargets("ModifyConfig").get(0)); - assertEquals(2, sp.recipePayloads("ModifyConfig").size()); - } -} diff --git a/controlloop/common/actors/actor.so/pom.xml b/controlloop/common/actors/actor.so/pom.xml deleted file mode 100644 index 0092f41b8..000000000 --- a/controlloop/common/actors/actor.so/pom.xml +++ /dev/null @@ -1,93 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - drools-pdp-apps - ================================================================================ - Copyright (C) 2017-2018 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========================================================= - --> - -<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.drools-applications.controlloop.common.actors</groupId> - <artifactId>actors</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>actor.so</artifactId> - - <dependencies> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId> - <artifactId>actorServiceProvider</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>aai</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>events</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>so</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.drools</groupId> - <artifactId>drools-core</artifactId> - <version>6.5.0.Final</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.common</groupId> - <artifactId>policy-endpoints</artifactId> - <version>${version.policy.common}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-pdp</groupId> - <artifactId>policy-management</artifactId> - <version>${version.policy.drools-pdp}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> - <artifactId>simulators</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - </dependencies> -</project> diff --git a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java deleted file mode 100644 index dcda995ad..000000000 --- a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java +++ /dev/null @@ -1,457 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * SOActorServiceProvider - * ================================================================================ - * Copyright (C) 2017-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.controlloop.actor.so; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.gson.reflect.TypeToken; -import java.lang.reflect.Type; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import org.drools.core.WorkingMemory; -import org.onap.policy.aai.AaiNqExtraProperty; -import org.onap.policy.aai.AaiNqInventoryResponseItem; -import org.onap.policy.aai.AaiNqResponseWrapper; -import org.onap.policy.controlloop.ControlLoopOperation; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.so.SoCloudConfiguration; -import org.onap.policy.so.SoManager; -import org.onap.policy.so.SoModelInfo; -import org.onap.policy.so.SoOperationType; -import org.onap.policy.so.SoRelatedInstance; -import org.onap.policy.so.SoRelatedInstanceListElement; -import org.onap.policy.so.SoRequest; -import org.onap.policy.so.SoRequestDetails; -import org.onap.policy.so.SoRequestInfo; -import org.onap.policy.so.SoRequestParameters; -import org.onap.policy.so.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SoActorServiceProvider implements Actor { - private static final Logger logger = LoggerFactory.getLogger(SoActorServiceProvider.class); - - // Strings for SO Actor - private static final String SO_ACTOR = "SO"; - - // Strings for targets - private static final String TARGET_VFC = "VFC"; - - // Strings for recipes - private static final String RECIPE_VF_MODULE_CREATE = "VF Module Create"; - private static final String RECIPE_VF_MODULE_DELETE = "VF Module Delete"; - - private static final ImmutableList<String> recipes = ImmutableList.of(RECIPE_VF_MODULE_CREATE, - RECIPE_VF_MODULE_DELETE); - private static final ImmutableMap<String, List<String>> targets = new ImmutableMap.Builder<String, List<String>>() - .put(RECIPE_VF_MODULE_CREATE, ImmutableList.of(TARGET_VFC)) - .put(RECIPE_VF_MODULE_DELETE, ImmutableList.of(TARGET_VFC)).build(); - - // name of request parameters within policy payload - public static final String REQ_PARAM_NM = "requestParameters"; - - // name of configuration parameters within policy payload - public static final String CONFIG_PARAM_NM = "configurationParameters"; - - private static final String MODEL_NAME_PROPERTY_KEY = "model-ver.model-name"; - private static final String MODEL_VERSION_PROPERTY_KEY = "model-ver.model-version"; - private static final String MODEL_VERSION_ID_PROPERTY_KEY = "model-ver.model-version-id"; - - // used to decode configuration parameters via gson - private static final Type CONFIG_TYPE = new TypeToken<List<Map<String, String>>>() {}.getType(); - - // Static variables required to hold the IDs of the last service item, VNF item and VF Module. - // Note that in - // a multithreaded deployment this WILL break - private static String lastVNFItemVnfId; - private static String lastServiceItemServiceInstanceId; - private static String lastVfModuleItemVfModuleInstanceId; - - @Override - public String actor() { - return SO_ACTOR; - } - - @Override - public List<String> recipes() { - return ImmutableList.copyOf(recipes); - } - - @Override - public List<String> recipeTargets(String recipe) { - return ImmutableList.copyOf(targets.getOrDefault(recipe, Collections.emptyList())); - } - - @Override - public List<String> recipePayloads(String recipe) { - return Collections.emptyList(); - } - - /** - * Constructs a SO request conforming to the lcm API. The actual request is - * constructed and then placed in a wrapper object used to send through DMAAP. - * - * @param onset the event that is reporting the alert for policy to perform an action - * @param operation the control loop operation specifying the actor, operation, - * target, etc. - * @param policy the policy the was specified from the yaml generated by CLAMP or - * through the Policy GUI/API - * @param aaiResponseWrapper wrapper for AAI vserver named-query response - * @return a SO request conforming to the lcm API using the DMAAP wrapper - */ - public SoRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy, - AaiNqResponseWrapper aaiResponseWrapper) { - if (!SO_ACTOR.equals(policy.getActor()) || !recipes().contains(policy.getRecipe())) { - return null; - } - - // A&AI named query should have been performed by now. If not, return null - if (aaiResponseWrapper == null) { - return null; - } - - AaiNqInventoryResponseItem vnfItem; - AaiNqInventoryResponseItem vnfServiceItem; - AaiNqInventoryResponseItem tenantItem; - - // Extract the items we're interested in from the response - try { - vnfItem = aaiResponseWrapper.getAaiNqResponse().getInventoryResponseItems().get(0).getItems() - .getInventoryResponseItems().get(0); - } catch (Exception e) { - logger.error("VNF Item not found in AAI response {}", Serialization.gsonPretty.toJson(aaiResponseWrapper), - e); - return null; - } - - try { - vnfServiceItem = vnfItem.getItems().getInventoryResponseItems().get(0); - } catch (Exception e) { - logger.error("VNF Service Item not found in AAI response {}", - Serialization.gsonPretty.toJson(aaiResponseWrapper), e); - return null; - } - - try { - tenantItem = aaiResponseWrapper.getAaiNqResponse().getInventoryResponseItems().get(0).getItems() - .getInventoryResponseItems().get(1); - } catch (Exception e) { - logger.error("Tenant Item not found in AAI response {}", - Serialization.gsonPretty.toJson(aaiResponseWrapper), e); - return null; - } - - // Find the index for base vf module and non-base vf module - AaiNqInventoryResponseItem baseItem = findVfModule(aaiResponseWrapper, true); - AaiNqInventoryResponseItem vfModuleItem = findVfModule(aaiResponseWrapper, false); - - // Report the error if either base vf module or non-base vf module is not found - if (baseItem == null || vfModuleItem == null) { - logger.error("Either base or non-base vf module is not found from AAI response."); - return null; - } - - // Construct SO Request for a policy's recipe - if (RECIPE_VF_MODULE_CREATE.equals(policy.getRecipe())) { - return constructCreateRequest(aaiResponseWrapper, policy, tenantItem, vnfItem, vnfServiceItem, - vfModuleItem); - } else if (RECIPE_VF_MODULE_DELETE.equals(policy.getRecipe())) { - return constructDeleteRequest(tenantItem, vnfItem, vnfServiceItem, vfModuleItem); - } else { - return null; - } - } - - /** - * Construct SO request to create vf-module. - * - * @param aaiResponseWrapper the AAI response containing the VF modules - * @param policy the policy - * @param tenantItem tenant item from A&AI named-query response - * @param vnfItem vnf item from A&AI named-query response - * @param vnfServiceItem vnf service item from A&AI named-query response - * @param vfModuleItem vf module item from A&AI named-query response - * @return SO create vf-module request - */ - private SoRequest constructCreateRequest(AaiNqResponseWrapper aaiResponseWrapper, Policy policy, - AaiNqInventoryResponseItem tenantItem, AaiNqInventoryResponseItem vnfItem, - AaiNqInventoryResponseItem vnfServiceItem, - AaiNqInventoryResponseItem vfModuleItem) { - SoRequest request = new SoRequest(); - request.setOperationType(SoOperationType.SCALE_OUT); - // - // - // Do NOT send So the requestId, they do not support this field - // - request.setRequestDetails(new SoRequestDetails()); - request.getRequestDetails().setRequestParameters(new SoRequestParameters()); - request.getRequestDetails().getRequestParameters().setUserParams(null); - - // cloudConfiguration - request.getRequestDetails().setCloudConfiguration(constructCloudConfiguration(tenantItem)); - // modelInfo - request.getRequestDetails().setModelInfo(constructVfModuleModelInfo(vfModuleItem)); - request.getRequestDetails().getModelInfo().setModelVersionId(vfModuleItem.getVfModule().getModelVersionId()); - - // requestInfo - request.getRequestDetails().setRequestInfo(constructRequestInfo()); - String vfModuleName = aaiResponseWrapper.genVfModuleName(); - request.getRequestDetails().getRequestInfo().setInstanceName(vfModuleName); - - // relatedInstanceList - SoRelatedInstanceListElement relatedInstanceListElement1 = new SoRelatedInstanceListElement(); - SoRelatedInstanceListElement relatedInstanceListElement2 = new SoRelatedInstanceListElement(); - relatedInstanceListElement1.setRelatedInstance(new SoRelatedInstance()); - relatedInstanceListElement2.setRelatedInstance(new SoRelatedInstance()); - - // Service Item - relatedInstanceListElement1.getRelatedInstance() - .setInstanceId(vnfServiceItem.getServiceInstance().getServiceInstanceId()); - relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SoModelInfo()); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service"); - relatedInstanceListElement1.getRelatedInstance().getModelInfo() - .setModelInvariantId(vnfServiceItem.getServiceInstance().getModelInvariantId()); - for (AaiNqExtraProperty prop : vnfServiceItem.getExtraProperties().getExtraProperty()) { - if (prop.getPropertyName().equals(MODEL_NAME_PROPERTY_KEY)) { - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName(prop.getPropertyValue()); - } else if (prop.getPropertyName().equals(MODEL_VERSION_PROPERTY_KEY)) { - relatedInstanceListElement1.getRelatedInstance().getModelInfo() - .setModelVersion(prop.getPropertyValue()); - } else if (prop.getPropertyName().equals(MODEL_VERSION_ID_PROPERTY_KEY)) { - relatedInstanceListElement1.getRelatedInstance().getModelInfo() - .setModelVersionId(prop.getPropertyValue()); - } - } - - // VNF Item - relatedInstanceListElement2.getRelatedInstance().setInstanceId(vnfItem.getGenericVnf().getVnfId()); - relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SoModelInfo()); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo() - .setModelInvariantId(vnfItem.getGenericVnf().getModelInvariantId()); - for (AaiNqExtraProperty prop : vnfItem.getExtraProperties().getExtraProperty()) { - if (prop.getPropertyName().equals(MODEL_NAME_PROPERTY_KEY)) { - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName(prop.getPropertyValue()); - } else if (prop.getPropertyName().equals(MODEL_VERSION_PROPERTY_KEY)) { - relatedInstanceListElement2.getRelatedInstance().getModelInfo() - .setModelVersion(prop.getPropertyValue()); - } else if (prop.getPropertyName().equals(MODEL_VERSION_ID_PROPERTY_KEY)) { - relatedInstanceListElement2.getRelatedInstance().getModelInfo() - .setModelVersionId(prop.getPropertyValue()); - } - } - relatedInstanceListElement2.getRelatedInstance().getModelInfo() - .setModelCustomizationName(vnfItem.getGenericVnf().getVnfType() - .substring(vnfItem.getGenericVnf().getVnfType().lastIndexOf('/') + 1)); - relatedInstanceListElement2.getRelatedInstance().getModelInfo() - .setModelCustomizationId(vnfItem.getGenericVnf().getModelCustomizationId()); - - // Insert the Service Item and VNF Item - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); - - // Request Parameters - buildRequestParameters(policy, request.getRequestDetails()); - - // Configuration Parameters - buildConfigurationParameters(policy, request.getRequestDetails()); - // Save the instance IDs for the VNF and service to static fields - // vfModuleId is not required for the create vf-module - preserveInstanceIds(vnfItem.getGenericVnf().getVnfId(), vnfServiceItem.getServiceInstance() - .getServiceInstanceId(), null); - if (logger.isDebugEnabled()) { - logger.debug("Constructed SO request: {}", Serialization.gsonPretty.toJson(request)); - } - return request; - } - - /** - * Construct SO request to delete vf-module. - * - * @param tenantItem tenant item from A&AI named-query response - * @param vnfItem vnf item from A&AI named-query response - * @param vnfServiceItem vnf service item from A&AI named-query response - * @param vfModuleItem vf module item from A&AI named-query response - * @return SO delete vf-module request - */ - private SoRequest constructDeleteRequest(AaiNqInventoryResponseItem tenantItem, AaiNqInventoryResponseItem - vnfItem, AaiNqInventoryResponseItem vnfServiceItem, AaiNqInventoryResponseItem vfModuleItem) { - SoRequest request = new SoRequest(); - request.setOperationType(SoOperationType.DELETE_VF_MODULE); - request.setRequestDetails(new SoRequestDetails()); - request.getRequestDetails().setRelatedInstanceList(null); - request.getRequestDetails().setConfigurationParameters(null); - - // cloudConfiguration - request.getRequestDetails().setCloudConfiguration(constructCloudConfiguration(tenantItem)); - // modelInfo - request.getRequestDetails().setModelInfo(constructVfModuleModelInfo(vfModuleItem)); - // requestInfo - request.getRequestDetails().setRequestInfo(constructRequestInfo()); - // Save the instance IDs for the VNF, service and vfModule to static fields - preserveInstanceIds(vnfItem.getGenericVnf().getVnfId(), vnfServiceItem.getServiceInstance() - .getServiceInstanceId(), vfModuleItem.getVfModule().getVfModuleId()); - - if (logger.isDebugEnabled()) { - logger.debug("Constructed SO request: {}", Serialization.gsonPretty.toJson(request)); - } - return request; - } - - /** - * Construct requestInfo for the SO requestDetails. - * - * @return SO request information - */ - private SoRequestInfo constructRequestInfo() { - SoRequestInfo soRequestInfo = new SoRequestInfo(); - soRequestInfo.setSource("POLICY"); - soRequestInfo.setSuppressRollback(false); - soRequestInfo.setRequestorId("policy"); - return soRequestInfo; - } - - /** - * Construct modelInfo of the vfModule for the SO requestDetails. - * - * @param vfModuleItem vf module item from A&AI named-query response - * @return SO Model info for the vfModule - */ - private SoModelInfo constructVfModuleModelInfo(AaiNqInventoryResponseItem vfModuleItem) { - SoModelInfo soModelInfo = new SoModelInfo(); - soModelInfo.setModelType("vfModule"); - soModelInfo.setModelInvariantId(vfModuleItem.getVfModule().getModelInvariantId()); - soModelInfo.setModelCustomizationId(vfModuleItem.getVfModule().getModelCustomizationId()); - - for (AaiNqExtraProperty prop : vfModuleItem.getExtraProperties().getExtraProperty()) { - if (prop.getPropertyName().equals(MODEL_NAME_PROPERTY_KEY)) { - soModelInfo.setModelName(prop.getPropertyValue()); - } else if (prop.getPropertyName().equals(MODEL_VERSION_PROPERTY_KEY)) { - soModelInfo.setModelVersion(prop.getPropertyValue()); - } - } - return soModelInfo; - } - - /** - * Construct cloudConfiguration for the SO requestDetails. - * - * @param tenantItem tenant item from A&AI named-query response - * @return SO cloud configuration - */ - private SoCloudConfiguration constructCloudConfiguration(AaiNqInventoryResponseItem tenantItem) { - SoCloudConfiguration cloudConfiguration = new SoCloudConfiguration(); - cloudConfiguration.setTenantId(tenantItem.getTenant().getTenantId()); - cloudConfiguration.setLcpCloudRegionId(tenantItem.getItems().getInventoryResponseItems().get(0) - .getCloudRegion().getCloudRegionId()); - return cloudConfiguration; - } - - /** - * This method is needed to get the serviceInstanceId and vnfInstanceId which is used - * in the asyncSORestCall. - * - * @param requestId the request Id - * @param wm the working memory - * @param request the request - */ - public static void sendRequest(String requestId, WorkingMemory wm, Object request) { - SoManager soManager = new SoManager(); - soManager.asyncSoRestCall(requestId, wm, lastServiceItemServiceInstanceId, lastVNFItemVnfId, - lastVfModuleItemVfModuleInstanceId, (SoRequest) request); - } - - /** - * Find the base or non base VF module item in an AAI response. - * If there is more than one item, then the <i>last</i> item is returned - * - * @param aaiResponseWrapper the AAI response containing the VF modules - * @param baseFlag true if we are searching for the base, false if we are searching - * for the non base - * @return the base or non base VF module item or null if the module was not found - */ - private AaiNqInventoryResponseItem findVfModule(AaiNqResponseWrapper aaiResponseWrapper, boolean baseFlag) { - List<AaiNqInventoryResponseItem> lst = aaiResponseWrapper.getVfModuleItems(baseFlag); - return (lst.isEmpty() ? null : lst.get(lst.size() - 1)); - } - - /** - * Builds the request parameters from the policy payload. - * - * @param policy the policy - * @param request request into which to stick the request parameters - */ - private void buildRequestParameters(Policy policy, SoRequestDetails request) { - // assume null until proven otherwise - request.setRequestParameters(null); - - if (policy.getPayload() == null) { - return; - } - - String json = policy.getPayload().get(REQ_PARAM_NM); - if (json == null) { - return; - } - - request.setRequestParameters(Serialization.gsonPretty.fromJson(json, SoRequestParameters.class)); - } - - /** - * Builds the configuration parameters from the policy payload. - * - * @param policy the policy - * @param request request into which to stick the configuration parameters - */ - private void buildConfigurationParameters(Policy policy, SoRequestDetails request) { - // assume null until proven otherwise - request.setConfigurationParameters(null); - - if (policy.getPayload() == null) { - return; - } - - String json = policy.getPayload().get(CONFIG_PARAM_NM); - if (json == null) { - return; - } - - request.setConfigurationParameters(Serialization.gsonPretty.fromJson(json, CONFIG_TYPE)); - } - - /** - * This method is called to remember the last service instance ID, VNF Item VNF ID and vf module ID. - * Note these fields are static, beware for multithreaded deployments - * - * @param vnfInstanceId update the last VNF instance ID to this value - * @param serviceInstanceId update the last service instance ID to this value - * @param vfModuleId update the vfModule instance ID to this value - */ - private static void preserveInstanceIds(final String vnfInstanceId, final String serviceInstanceId, - final String vfModuleId) { - lastVNFItemVnfId = vnfInstanceId; - lastServiceItemServiceInstanceId = serviceInstanceId; - lastVfModuleItemVfModuleInstanceId = vfModuleId; - } -} diff --git a/controlloop/common/actors/actor.so/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor b/controlloop/common/actors/actor.so/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor deleted file mode 100644 index a955eb71c..000000000 --- a/controlloop/common/actors/actor.so/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor +++ /dev/null @@ -1 +0,0 @@ -org.onap.policy.controlloop.actor.so.SoActorServiceProvider
\ No newline at end of file diff --git a/controlloop/common/actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java b/controlloop/common/actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java deleted file mode 100644 index 272e45ae1..000000000 --- a/controlloop/common/actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorServiceProviderTest.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * TestSOActorServiceProvider - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018-2019 AT&T. 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.controlloop.actor.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.UUID; -import org.apache.commons.io.IOUtils; -import org.junit.Test; -import org.onap.policy.aai.AaiNqResponse; -import org.onap.policy.aai.AaiNqResponseWrapper; -import org.onap.policy.controlloop.ControlLoopOperation; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.so.SoOperationType; -import org.onap.policy.so.SoRequest; -import org.onap.policy.so.SoRequestParameters; -import org.onap.policy.so.util.Serialization; - -public class SoActorServiceProviderTest { - - private static final String VF_MODULE_CREATE = "VF Module Create"; - private static final String VF_MODULE_DELETE = "VF Module Delete"; - - @Test - public void testConstructRequest() throws Exception { - VirtualControlLoopEvent onset = new VirtualControlLoopEvent(); - final ControlLoopOperation operation = new ControlLoopOperation(); - final AaiNqResponseWrapper aaiNqResp = loadAaiResponse(onset, "aai/AaiNqResponse-Full.json"); - - final UUID requestId = UUID.randomUUID(); - onset.setRequestId(requestId); - - Policy policy = new Policy(); - policy.setActor("Dorothy"); - policy.setRecipe("GoToOz"); - - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp)); - - policy.setActor("SO"); - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp)); - - policy.setRecipe(VF_MODULE_CREATE); - - // empty policy payload - SoRequest request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp); - assertNotNull(request); - - assertEquals("my_module_3", request.getRequestDetails().getRequestInfo().getInstanceName()); - assertEquals("policy", request.getRequestDetails().getRequestInfo().getRequestorId()); - assertEquals("RegionOne", request.getRequestDetails().getCloudConfiguration().getLcpCloudRegionId()); - - // non-empty policy payload - policy.setPayload(makePayload()); - request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp); - assertNotNull(request); - assertEquals(true, request.getRequestDetails().getRequestParameters().isUsePreload()); - assertEquals("avalue", request.getRequestDetails().getRequestParameters().getUserParams().get(0).get("akey")); - assertEquals(1, request.getRequestDetails().getConfigurationParameters().size()); - assertEquals("cvalue", request.getRequestDetails().getConfigurationParameters().get(0).get("ckey")); - - // payload with config, but no request params - policy.setPayload(makePayload()); - policy.getPayload().remove(SoActorServiceProvider.REQ_PARAM_NM); - request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp); - assertNotNull(request); - assertNull(request.getRequestDetails().getRequestParameters()); - assertNotNull(request.getRequestDetails().getConfigurationParameters()); - - // payload with request, but no config params - policy.setPayload(makePayload()); - policy.getPayload().remove(SoActorServiceProvider.CONFIG_PARAM_NM); - request = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp); - assertNotNull(request); - assertNotNull(request.getRequestDetails().getRequestParameters()); - assertNull(request.getRequestDetails().getConfigurationParameters()); - - // null response - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, null)); - - // response has no base VF module - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, - loadAaiResponse(onset, "aai/AaiNqResponse-NoBase.json"))); - - // response has no non-base VF modules (other than the "dummy") - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, - loadAaiResponse(onset, "aai/AaiNqResponse-NoNonBase.json"))); - - policy.setRecipe(VF_MODULE_DELETE); - SoRequest deleteRequest = new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp); - assertNotNull(deleteRequest); - assertEquals(SoOperationType.DELETE_VF_MODULE, deleteRequest.getOperationType()); - - /* - * NOTE: The remaining tests must be done in order - */ - - policy.setRecipe(VF_MODULE_CREATE); - - // null tenant - aaiNqResp.getAaiNqResponse().getInventoryResponseItems().get(0).getItems().getInventoryResponseItems() - .remove(1); - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp)); - - // null service item - aaiNqResp.getAaiNqResponse().getInventoryResponseItems().get(0).getItems().getInventoryResponseItems().get(0) - .setItems(null); - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp)); - - // null response - aaiNqResp.setAaiNqResponse(null); - assertNull(new SoActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp)); - } - - @Test - public void testSendRequest() { - try { - SoActorServiceProvider.sendRequest(UUID.randomUUID().toString(), null, null); - } catch (Exception e) { - fail("Test should not throw an exception"); - } - } - - @Test - public void testMethods() { - SoActorServiceProvider sp = new SoActorServiceProvider(); - - assertEquals("SO", sp.actor()); - assertEquals(2, sp.recipes().size()); - assertEquals(VF_MODULE_CREATE, sp.recipes().get(0)); - assertEquals(VF_MODULE_DELETE, sp.recipes().get(1)); - assertEquals(0, sp.recipePayloads(VF_MODULE_CREATE).size()); - assertEquals(0, sp.recipeTargets("unknown recipe").size()); - assertEquals(1, sp.recipeTargets(VF_MODULE_CREATE).size()); - } - - /** - * Creates a policy payload containing request & configuration parameters. - * - * @return the payload - */ - private Map<String, String> makePayload() { - Map<String, String> payload = new TreeMap<>(); - - payload.put(SoActorServiceProvider.REQ_PARAM_NM, makeReqParams()); - payload.put(SoActorServiceProvider.CONFIG_PARAM_NM, makeConfigParams()); - - return payload; - } - - /** - * Creates request parameters. - * - * @return request parameters, encoded as JSON - */ - private String makeReqParams() { - SoRequestParameters params = new SoRequestParameters(); - - params.setUsePreload(true); - - Map<String, String> map = new TreeMap<>(); - map.put("akey", "avalue"); - - List<Map<String, String>> lst = new LinkedList<>(); - lst.add(map); - - params.setUserParams(lst); - - return Serialization.gsonPretty.toJson(params); - } - - /** - * Creates configuration parameters. - * - * @return configuration parameters, encoded as JSON - */ - private String makeConfigParams() { - Map<String, String> map = new TreeMap<>(); - map.put("ckey", "cvalue"); - - List<Map<String, String>> lst = new LinkedList<>(); - lst.add(map); - - return Serialization.gsonPretty.toJson(lst); - } - - /** - * Reads an AAI vserver named-query response from a file. - * - * @param onset the ONSET event - * @param fileName name of the file containing the JSON response - * @return output from the AAI vserver named-query - * @throws IOException if the file cannot be read - */ - private AaiNqResponseWrapper loadAaiResponse(VirtualControlLoopEvent onset, String fileName) throws IOException { - String resp = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8); - AaiNqResponse aaiNqResponse = Serialization.gsonPretty.fromJson(resp, AaiNqResponse.class); - - return new AaiNqResponseWrapper(onset.getRequestId(), aaiNqResponse); - } -} diff --git a/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-Full.json b/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-Full.json deleted file mode 100644 index af40be948..000000000 --- a/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-Full.json +++ /dev/null @@ -1,267 +0,0 @@ -{ - "inventory-response-item": [ - { - "vserver": { - "vserver-id": "6ed3642c-f7a1-4a7c-9290-3d51fe1531eb", - "vserver-name": "zdfw1lb01lb02", - "vserver-name2": "zdfw1lb01lb02", - "prov-status": "ACTIVE", - "vserver-selflink": "http://10.12.25.2:8774/v2.1/41d6d38489bd40b09ea8a6b6b852dcbd/servers/6ed3642c-f7a1-4a7c-9290-3d51fe1531eb", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1510606403522" - }, - "extra-properties": { - "extra-property": [] - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "model-name": "vLoadBalancer", - "generic-vnf": { - "vnf-id": "db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "vnf-name": "Vfmodule_vLB1113", - "vnf-type": "vLoadBalancer-1106/vLoadBalancer 0", - "service-id": "66f157fc-4148-4880-95f5-e120677e98d1", - "prov-status": "PREPROV", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1510604011851", - "model-invariant-id": "cee050ed-92a5-494f-ab04-234307a846dc", - "model-version-id": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2" - }, - { - "property-name": "model-ver.model-name", - "property-value": "vLoadBalancer" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "cee050ed-92a5-494f-ab04-234307a846dc" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1.0" - } - ] - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "model-name": "vLoadBalancer-1106", - "service-instance": { - "service-instance-id": "3b12f31f-8f2d-4f5c-b875-61ff1194b941", - "service-instance-name": "vLoadBalancer-1113", - "resource-version": "1510603936425", - "model-invariant-id": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a", - "model-version-id": "732d4692-4b97-46f9-a996-0b3339e88c50" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "732d4692-4b97-46f9-a996-0b3339e88c50" - }, - { - "property-name": "model-ver.model-name", - "property-value": "vLoadBalancer-1106" - }, - { - "property-name": "model.model-type", - "property-value": "service" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1.0" - } - ] - } - }, - { - "model-name": "Vloadbalancer..base_vlb..module-0", - "vf-module": { - "vf-module-id": "e6b3e3eb-34e1-4c00-b8c1-2a4fbe479b12", - "vf-module-name": "Vfmodule_vLB1113-1", - "heat-stack-id": "Vfmodule_vLB1113-1/3dd6d900-772f-4fcc-a0cb-e250ab2bb4db", - "orchestration-status": "active", - "is-base-vf-module": true, - "resource-version": "1510604612557", - "model-invariant-id": "6d760188-9a24-451a-b05b-e08b86cb94f2", - "model-version-id": "93facad9-55f2-4fe0-9574-814c2bc2d071" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "93facad9-55f2-4fe0-9574-814c2bc2d071" - }, - { - "property-name": "model-ver.model-name", - "property-value": "Vloadbalancer..base_vlb..module-0" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "6d760188-9a24-451a-b05b-e08b86cb94f2" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1" - } - ] - } - }, - { - "model-name": "Vloadbalancer..dnsscaling..module-1", - "vf-module": { - "vf-module-id": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "vf-module-name": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "is-base-vf-module": false, - "resource-version": "1510610079687", - "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c", - "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - { - "property-name": "model-ver.model-name", - "property-value": "Vloadbalancer..dnsscaling..module-1" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1" - } - ] - } - }, - { - "model-name": "Vloadbalancer..dnsscaling..module-1", - "vf-module": { - "vf-module-id": "my_module_db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "vf-module-name": "my_module_1", - "is-base-vf-module": false, - "resource-version": "1510610079687", - "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c", - "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - { - "property-name": "model-ver.model-name", - "property-value": "Vloadbalancer..dnsscaling..module-1" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1" - } - ] - } - }, - { - "model-name": "Vloadbalancer..dnsscaling..module-1", - "vf-module": { - "vf-module-id": "my_module_db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "vf-module-name": "my_module_2", - "is-base-vf-module": false, - "resource-version": "1510610079687", - "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c", - "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - { - "property-name": "model-ver.model-name", - "property-value": "Vloadbalancer..dnsscaling..module-1" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1" - } - ] - } - } - ] - } - }, - { - "tenant": { - "tenant-id": "41d6d38489bd40b09ea8a6b6b852dcbd", - "tenant-name": "Integration-SB-00", - "resource-version": "1509587770200" - }, - "extra-properties": { - "extra-property": [] - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "cloud-region": { - "cloud-owner": "CloudOwner", - "cloud-region-id": "RegionOne", - "cloud-region-version": "v1", - "resource-version": "1509587770092" - }, - "extra-properties": { - "extra-property": [] - } - } - ] - } - } - ] - } - } - ] -} diff --git a/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-NoBase.json b/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-NoBase.json deleted file mode 100644 index 7101f60f2..000000000 --- a/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-NoBase.json +++ /dev/null @@ -1,230 +0,0 @@ -{ - "inventory-response-item": [ - { - "vserver": { - "vserver-id": "6ed3642c-f7a1-4a7c-9290-3d51fe1531eb", - "vserver-name": "zdfw1lb01lb02", - "vserver-name2": "zdfw1lb01lb02", - "prov-status": "ACTIVE", - "vserver-selflink": "http://10.12.25.2:8774/v2.1/41d6d38489bd40b09ea8a6b6b852dcbd/servers/6ed3642c-f7a1-4a7c-9290-3d51fe1531eb", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1510606403522" - }, - "extra-properties": { - "extra-property": [] - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "model-name": "vLoadBalancer", - "generic-vnf": { - "vnf-id": "db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "vnf-name": "Vfmodule_vLB1113", - "vnf-type": "vLoadBalancer-1106/vLoadBalancer 0", - "service-id": "66f157fc-4148-4880-95f5-e120677e98d1", - "prov-status": "PREPROV", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1510604011851", - "model-invariant-id": "cee050ed-92a5-494f-ab04-234307a846dc", - "model-version-id": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2" - }, - { - "property-name": "model-ver.model-name", - "property-value": "vLoadBalancer" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "cee050ed-92a5-494f-ab04-234307a846dc" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1.0" - } - ] - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "model-name": "vLoadBalancer-1106", - "service-instance": { - "service-instance-id": "3b12f31f-8f2d-4f5c-b875-61ff1194b941", - "service-instance-name": "vLoadBalancer-1113", - "resource-version": "1510603936425", - "model-invariant-id": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a", - "model-version-id": "732d4692-4b97-46f9-a996-0b3339e88c50" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "732d4692-4b97-46f9-a996-0b3339e88c50" - }, - { - "property-name": "model-ver.model-name", - "property-value": "vLoadBalancer-1106" - }, - { - "property-name": "model.model-type", - "property-value": "service" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1.0" - } - ] - } - }, - { - "model-name": "Vloadbalancer..dnsscaling..module-1", - "vf-module": { - "vf-module-id": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "vf-module-name": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "is-base-vf-module": false, - "resource-version": "1510610079687", - "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c", - "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - { - "property-name": "model-ver.model-name", - "property-value": "Vloadbalancer..dnsscaling..module-1" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1" - } - ] - } - }, - { - "model-name": "Vloadbalancer..dnsscaling..module-1", - "vf-module": { - "vf-module-id": "my_module_db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "vf-module-name": "my_module_1", - "is-base-vf-module": false, - "resource-version": "1510610079687", - "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c", - "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - { - "property-name": "model-ver.model-name", - "property-value": "Vloadbalancer..dnsscaling..module-1" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1" - } - ] - } - }, - { - "model-name": "Vloadbalancer..dnsscaling..module-1", - "vf-module": { - "vf-module-id": "my_module_db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "vf-module-name": "my_module_2", - "is-base-vf-module": false, - "resource-version": "1510610079687", - "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c", - "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - { - "property-name": "model-ver.model-name", - "property-value": "Vloadbalancer..dnsscaling..module-1" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1" - } - ] - } - } - ] - } - }, - { - "tenant": { - "tenant-id": "41d6d38489bd40b09ea8a6b6b852dcbd", - "tenant-name": "Integration-SB-00", - "resource-version": "1509587770200" - }, - "extra-properties": { - "extra-property": [] - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "cloud-region": { - "cloud-owner": "CloudOwner", - "cloud-region-id": "RegionOne", - "cloud-region-version": "v1", - "resource-version": "1509587770092" - }, - "extra-properties": { - "extra-property": [] - } - } - ] - } - } - ] - } - } - ] -} diff --git a/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-NoNonBase.json b/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-NoNonBase.json deleted file mode 100644 index a58100bc5..000000000 --- a/controlloop/common/actors/actor.so/src/test/resources/org/onap/policy/controlloop/actor/so/aai/AaiNqResponse-NoNonBase.json +++ /dev/null @@ -1,197 +0,0 @@ -{ - "inventory-response-item": [ - { - "vserver": { - "vserver-id": "6ed3642c-f7a1-4a7c-9290-3d51fe1531eb", - "vserver-name": "zdfw1lb01lb02", - "vserver-name2": "zdfw1lb01lb02", - "prov-status": "ACTIVE", - "vserver-selflink": "http://10.12.25.2:8774/v2.1/41d6d38489bd40b09ea8a6b6b852dcbd/servers/6ed3642c-f7a1-4a7c-9290-3d51fe1531eb", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1510606403522" - }, - "extra-properties": { - "extra-property": [] - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "model-name": "vLoadBalancer", - "generic-vnf": { - "vnf-id": "db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "vnf-name": "Vfmodule_vLB1113", - "vnf-type": "vLoadBalancer-1106/vLoadBalancer 0", - "service-id": "66f157fc-4148-4880-95f5-e120677e98d1", - "prov-status": "PREPROV", - "in-maint": false, - "is-closed-loop-disabled": false, - "resource-version": "1510604011851", - "model-invariant-id": "cee050ed-92a5-494f-ab04-234307a846dc", - "model-version-id": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2" - }, - { - "property-name": "model-ver.model-name", - "property-value": "vLoadBalancer" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "cee050ed-92a5-494f-ab04-234307a846dc" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1.0" - } - ] - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "model-name": "vLoadBalancer-1106", - "service-instance": { - "service-instance-id": "3b12f31f-8f2d-4f5c-b875-61ff1194b941", - "service-instance-name": "vLoadBalancer-1113", - "resource-version": "1510603936425", - "model-invariant-id": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a", - "model-version-id": "732d4692-4b97-46f9-a996-0b3339e88c50" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "732d4692-4b97-46f9-a996-0b3339e88c50" - }, - { - "property-name": "model-ver.model-name", - "property-value": "vLoadBalancer-1106" - }, - { - "property-name": "model.model-type", - "property-value": "service" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1.0" - } - ] - } - }, - { - "model-name": "Vloadbalancer..base_vlb..module-0", - "vf-module": { - "vf-module-id": "e6b3e3eb-34e1-4c00-b8c1-2a4fbe479b12", - "vf-module-name": "Vfmodule_vLB1113-1", - "heat-stack-id": "Vfmodule_vLB1113-1/3dd6d900-772f-4fcc-a0cb-e250ab2bb4db", - "orchestration-status": "active", - "is-base-vf-module": true, - "resource-version": "1510604612557", - "model-invariant-id": "6d760188-9a24-451a-b05b-e08b86cb94f2", - "model-version-id": "93facad9-55f2-4fe0-9574-814c2bc2d071" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "93facad9-55f2-4fe0-9574-814c2bc2d071" - }, - { - "property-name": "model-ver.model-name", - "property-value": "Vloadbalancer..base_vlb..module-0" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "6d760188-9a24-451a-b05b-e08b86cb94f2" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1" - } - ] - } - }, - { - "model-name": "Vloadbalancer..dnsscaling..module-1", - "vf-module": { - "vf-module-id": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "vf-module-name": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144", - "is-base-vf-module": false, - "resource-version": "1510610079687", - "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c", - "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a" - }, - { - "property-name": "model-ver.model-name", - "property-value": "Vloadbalancer..dnsscaling..module-1" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1" - } - ] - } - } - ] - } - }, - { - "tenant": { - "tenant-id": "41d6d38489bd40b09ea8a6b6b852dcbd", - "tenant-name": "Integration-SB-00", - "resource-version": "1509587770200" - }, - "extra-properties": { - "extra-property": [] - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "cloud-region": { - "cloud-owner": "CloudOwner", - "cloud-region-id": "RegionOne", - "cloud-region-version": "v1", - "resource-version": "1509587770092" - }, - "extra-properties": { - "extra-property": [] - } - } - ] - } - } - ] - } - } - ] -} diff --git a/controlloop/common/actors/actor.test/pom.xml b/controlloop/common/actors/actor.test/pom.xml deleted file mode 100644 index 873c7a64c..000000000 --- a/controlloop/common/actors/actor.test/pom.xml +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - drools-pdp-apps - ================================================================================ - Copyright (C) 2017-2018 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========================================================= - --> - -<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.drools-applications.controlloop.common.actors</groupId> - <artifactId>actors</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>actor.test</artifactId> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - </plugin> - </plugins> - </build> - <dependencies> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId> - <artifactId>actorServiceProvider</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>aai</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId> - <artifactId>actor.appc</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId> - <artifactId>actor.so</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId> - <artifactId>actor.appclcm</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId> - <artifactId>actor.vfc</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> -</project> diff --git a/controlloop/common/actors/actor.vfc/pom.xml b/controlloop/common/actors/actor.vfc/pom.xml deleted file mode 100644 index 0b7b4c4fe..000000000 --- a/controlloop/common/actors/actor.vfc/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - drools-pdp-apps - ================================================================================ - Copyright (C) 2017-2018 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========================================================= - --> - -<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.drools-applications.controlloop.common.actors</groupId> - <artifactId>actors</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>actor.vfc</artifactId> - - <dependencies> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId> - <artifactId>actorServiceProvider</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>vfc</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>events</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>aai</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.common</groupId> - <artifactId>policy-endpoints</artifactId> - <version>${version.policy.common}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-pdp</groupId> - <artifactId>policy-management</artifactId> - <version>${version.policy.drools-pdp}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> - <artifactId>simulators</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - </dependencies> -</project> diff --git a/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java b/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java deleted file mode 100644 index 098f1b791..000000000 --- a/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java +++ /dev/null @@ -1,151 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017-2018 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018-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.controlloop.actor.vfc; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -import java.util.Collections; -import java.util.List; -import java.util.UUID; - -import org.onap.policy.aai.AaiGetVnfResponse; -import org.onap.policy.aai.AaiManager; -import org.onap.policy.controlloop.ControlLoopOperation; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.drools.system.PolicyEngine; -import org.onap.policy.rest.RestManager; -import org.onap.policy.vfc.VfcHealActionVmInfo; -import org.onap.policy.vfc.VfcHealAdditionalParams; -import org.onap.policy.vfc.VfcHealRequest; -import org.onap.policy.vfc.VfcRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class VfcActorServiceProvider implements Actor { - private static final Logger logger = LoggerFactory.getLogger(VfcActorServiceProvider.class); - - // Strings for VFC Actor - private static final String VFC_ACTOR = "VFC"; - - // Strings for targets - private static final String TARGET_VM = "VM"; - - // Strings for recipes - private static final String RECIPE_RESTART = "Restart"; - - private static final ImmutableList<String> recipes = ImmutableList.of(RECIPE_RESTART); - private static final ImmutableMap<String, List<String>> targets = - new ImmutableMap.Builder<String, List<String>>().put(RECIPE_RESTART, ImmutableList.of(TARGET_VM)).build(); - - @Override - public String actor() { - return VFC_ACTOR; - } - - @Override - public List<String> recipes() { - return ImmutableList.copyOf(recipes); - } - - @Override - public List<String> recipeTargets(String recipe) { - return ImmutableList.copyOf(targets.getOrDefault(recipe, Collections.emptyList())); - } - - @Override - public List<String> recipePayloads(String recipe) { - return Collections.emptyList(); - } - - /** - * Construct a request. - * - * @param onset the onset event - * @param operation the control loop operation - * @param policy the policy - * @param vnfResponse the VNF response - * @return the constructed request - */ - public static VfcRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, - Policy policy, AaiGetVnfResponse vnfResponse) { - - // Construct an VFC request - VfcRequest request = new VfcRequest(); - String serviceInstance = onset.getAai().get("service-instance.service-instance-id"); - if (serviceInstance == null || "".equals(serviceInstance)) { - AaiGetVnfResponse tempVnfResp = vnfResponse; - if (tempVnfResp == null) { // if the response is null, we haven't queried - // This does the AAI query since we haven't already - tempVnfResp = getAaiServiceInstance(onset); - if (tempVnfResp == null) { - return null; - } - } - serviceInstance = tempVnfResp.getServiceId(); - } - request.setNsInstanceId(serviceInstance); - request.setRequestId(onset.getRequestId()); - request.setHealRequest(new VfcHealRequest()); - request.getHealRequest().setVnfInstanceId(onset.getAai().get("generic-vnf.vnf-id")); - request.getHealRequest().setCause(operation.getMessage()); - request.getHealRequest().setAdditionalParams(new VfcHealAdditionalParams()); - - if (policy.getRecipe().toLowerCase().equalsIgnoreCase(RECIPE_RESTART)) { - request.getHealRequest().getAdditionalParams().setAction("restartvm"); - request.getHealRequest().getAdditionalParams().setActionInfo(new VfcHealActionVmInfo()); - request.getHealRequest().getAdditionalParams().getActionInfo() - .setVmid(onset.getAai().get("vserver.vserver-id")); - request.getHealRequest().getAdditionalParams().getActionInfo() - .setVmname(onset.getAai().get("vserver.vserver-name")); - } else { - return null; - } - return request; - } - - private static AaiGetVnfResponse getAaiServiceInstance(VirtualControlLoopEvent event) { - AaiGetVnfResponse response = null; - UUID requestId = event.getRequestId(); - String vnfName = event.getAai().get("generic-vnf.vnf-name"); - String vnfId = event.getAai().get("generic-vnf.vnf-id"); - String aaiUrl = PolicyEngine.manager.getEnvironmentProperty("aai.url"); - String aaiUsername = PolicyEngine.manager.getEnvironmentProperty("aai.username"); - String aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password"); - try { - if (vnfName != null) { - String url = aaiUrl + "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name="; - response = new AaiManager(new RestManager()).getQueryByVnfName(url, aaiUsername, aaiPassword, requestId, - vnfName); - } else if (vnfId != null) { - String url = aaiUrl + "/aai/v11/network/generic-vnfs/generic-vnf/"; - response = new AaiManager(new RestManager()).getQueryByVnfId(url, aaiUsername, aaiPassword, requestId, - vnfId); - } else { - logger.error("getAAIServiceInstance failed"); - } - } catch (Exception e) { - logger.error("getAAIServiceInstance exception: ", e); - } - return response; - } -} diff --git a/controlloop/common/actors/actor.vfc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor b/controlloop/common/actors/actor.vfc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor deleted file mode 100644 index e43c726cf..000000000 --- a/controlloop/common/actors/actor.vfc/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor +++ /dev/null @@ -1 +0,0 @@ -org.onap.policy.controlloop.actor.vfc.VfcActorServiceProvider diff --git a/controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java b/controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java deleted file mode 100644 index 9e6b5b827..000000000 --- a/controlloop/common/actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - Policy Drools Applications - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corp. 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.controlloop.actor.vfc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - -import java.util.Objects; -import java.util.UUID; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.aai.AaiGetVnfResponse; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; -import org.onap.policy.controlloop.ControlLoopOperation; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.drools.system.PolicyEngine; -import org.onap.policy.simulators.Util; -import org.onap.policy.vfc.VfcRequest; - -public class VfcActorServiceProviderTest { - - /** - * Set up for test class. - */ - @BeforeClass - public static void setUpSimulator() { - try { - Util.buildAaiSim(); - } catch (Exception e) { - fail(e.getMessage()); - } - } - - @AfterClass - public static void tearDownSimulator() { - HttpServletServer.factory.destroy(); - } - - @Test - public void testConstructRequest() { - VirtualControlLoopEvent onset = new VirtualControlLoopEvent(); - ControlLoopOperation operation = new ControlLoopOperation(); - - Policy policy = new Policy(); - policy.setRecipe("GoToOz"); - - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null)); - - onset.getAai().put("generic-vnf.vnf-id", "dorothy.gale.1939"); - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null)); - - PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666"); - PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI"); - PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI"); - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null)); - - UUID requestId = UUID.randomUUID(); - onset.setRequestId(requestId); - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null)); - - onset.getAai().put("generic-vnf.vnf-name", "Dorothy"); - PolicyEngine.manager.getEnvironment().remove("aai.password"); - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null)); - - PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI"); - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null)); - - onset.getAai().put("service-instance.service-instance-id", ""); - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, null)); - - assertNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse())); - - policy.setRecipe("Restart"); - assertNotNull(VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse())); - - VfcRequest request = - VfcActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse()); - - assertEquals(requestId, Objects.requireNonNull(request).getRequestId()); - assertEquals("dorothy.gale.1939", request.getHealRequest().getVnfInstanceId()); - assertEquals("restartvm", request.getHealRequest().getAdditionalParams().getAction()); - } - - @Test - public void testMethods() { - VfcActorServiceProvider sp = new VfcActorServiceProvider(); - - assertEquals("VFC", sp.actor()); - assertEquals(1, sp.recipes().size()); - assertEquals("Restart", sp.recipes().get(0)); - assertEquals("VM", sp.recipeTargets("Restart").get(0)); - assertEquals(0, sp.recipePayloads("Restart").size()); - } -} diff --git a/controlloop/common/actors/actorServiceProvider/pom.xml b/controlloop/common/actors/actorServiceProvider/pom.xml deleted file mode 100644 index b89b5806e..000000000 --- a/controlloop/common/actors/actorServiceProvider/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - drools-pdp-apps - ================================================================================ - Copyright (C) 2017-2018 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========================================================= - --> - -<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.drools-applications.controlloop.common.actors</groupId> - <artifactId>actors</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>actorServiceProvider</artifactId> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> -</project> diff --git a/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java b/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java deleted file mode 100644 index aeb536c57..000000000 --- a/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/ActorService.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ActorService - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.actorserviceprovider; - -import com.google.common.collect.ImmutableList; - -import java.util.Iterator; -import java.util.ServiceLoader; - -import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ActorService { - - private static final Logger logger = LoggerFactory.getLogger(ActorService.class); - private static ActorService service; - - // USed to load actors - private final ServiceLoader<Actor> loader; - - private ActorService() { - loader = ServiceLoader.load(Actor.class); - } - - /** - * Get the single instance. - * - * @return the instance - */ - public static synchronized ActorService getInstance() { - if (service == null) { - service = new ActorService(); - } - return service; - } - - /** - * Get the actors. - * - * @return the actors - */ - public ImmutableList<Actor> actors() { - Iterator<Actor> iter = loader.iterator(); - logger.debug("returning actors"); - while (iter.hasNext()) { - if (logger.isDebugEnabled()) { - logger.debug("Got {}", iter.next().actor()); - } - } - - return ImmutableList.copyOf(loader.iterator()); - } -} diff --git a/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/spi/Actor.java b/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/spi/Actor.java deleted file mode 100644 index 47e02a5cb..000000000 --- a/controlloop/common/actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/spi/Actor.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Actor - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.actorserviceprovider.spi; - -import java.util.List; - -public interface Actor { - - String actor(); - - List<String> recipes(); - - List<String> recipeTargets(String recipe); - - List<String> recipePayloads(String recipe); - -} diff --git a/controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java b/controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java deleted file mode 100644 index 4e50d855f..000000000 --- a/controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * TestActorServiceProvider - * ================================================================================ - * Copyright (C) 2018 Ericsson. 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.controlloop.actorserviceprovider; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; - -public class ActorServiceProviderTest { - - @Test - public void testActorServiceProvider() { - ActorService actorService = ActorService.getInstance(); - assertNotNull(actorService); - - assertEquals(1, actorService.actors().size()); - - actorService = ActorService.getInstance(); - assertNotNull(actorService); - - Actor dummyActor = ActorService.getInstance().actors().get(0); - assertNotNull(dummyActor); - - assertEquals("DummyActor", dummyActor.actor()); - - assertEquals(2, dummyActor.recipes().size()); - assertEquals("Dorothy", dummyActor.recipes().get(0)); - assertEquals("Wizard", dummyActor.recipes().get(1)); - - assertEquals(2, dummyActor.recipeTargets("Dorothy").size()); - assertEquals(2, dummyActor.recipePayloads("Dorothy").size()); - } -} diff --git a/controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/DummyActor.java b/controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/DummyActor.java deleted file mode 100644 index 2e8512411..000000000 --- a/controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/DummyActor.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * TestActorServiceProvider - * ================================================================================ - * Copyright (C) 2018 Ericsson. 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.controlloop.actorserviceprovider; - -import java.util.ArrayList; -import java.util.List; - -import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; - -public class DummyActor implements Actor { - @Override - public String actor() { - return this.getClass().getSimpleName(); - } - - @Override - public List<String> recipes() { - List<String> recipeList = new ArrayList<>(); - recipeList.add("Dorothy"); - recipeList.add("Wizard"); - - return recipeList; - } - - @Override - public List<String> recipeTargets(String recipe) { - List<String> recipeTargetList = new ArrayList<>(); - recipeTargetList.add("Wicked Witch"); - recipeTargetList.add("Wizard of Oz"); - - return recipeTargetList; - } - - @Override - public List<String> recipePayloads(String recipe) { - List<String> recipePayloadList = new ArrayList<>(); - recipePayloadList.add("Dorothy"); - recipePayloadList.add("Toto"); - - return recipePayloadList; - } -} diff --git a/controlloop/common/actors/actorServiceProvider/src/test/resources/META-INF/services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor b/controlloop/common/actors/actorServiceProvider/src/test/resources/META-INF/services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor deleted file mode 100644 index 2a4bb5749..000000000 --- a/controlloop/common/actors/actorServiceProvider/src/test/resources/META-INF/services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor +++ /dev/null @@ -1 +0,0 @@ -org.onap.policy.controlloop.actorserviceprovider.DummyActor
\ No newline at end of file diff --git a/controlloop/common/actors/pom.xml b/controlloop/common/actors/pom.xml deleted file mode 100644 index f5247b82c..000000000 --- a/controlloop/common/actors/pom.xml +++ /dev/null @@ -1,55 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - drools-pdp-apps - ================================================================================ - Copyright (C) 2017-2018 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========================================================= - --> - -<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> - <packaging>pom</packaging> - - <parent> - <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> - <artifactId>common</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <groupId>org.onap.policy.drools-applications.controlloop.common.actors</groupId> - <artifactId>actors</artifactId> - - <modules> - <module>actorServiceProvider</module> - <module>actor.appc</module> - <module>actor.vfc</module> - <module>actor.sdnc</module> - <module>actor.appclcm</module> - <module>actor.sdnr</module> - <module>actor.so</module> - <module>actor.test</module> - </modules> - <dependencies> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> - <artifactId>policy-yaml</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> -</project> diff --git a/controlloop/common/controller-usecases/pom.xml b/controlloop/common/controller-usecases/pom.xml index 918f350b7..f4bcb1c20 100644 --- a/controlloop/common/controller-usecases/pom.xml +++ b/controlloop/common/controller-usecases/pom.xml @@ -128,12 +128,6 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> - <artifactId>trafficgenerator</artifactId> - <version>${policy.models.version}</version> - <scope>provided</scope> - </dependency> - <dependency> <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> <artifactId>eventmanager</artifactId> <version>${project.version}</version> diff --git a/controlloop/common/eventmanager/pom.xml b/controlloop/common/eventmanager/pom.xml index ab62bf713..aa974d16f 100644 --- a/controlloop/common/eventmanager/pom.xml +++ b/controlloop/common/eventmanager/pom.xml @@ -132,12 +132,6 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> - <artifactId>trafficgenerator</artifactId> - <version>${policy.models.version}</version> - <scope>provided</scope> - </dependency> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> diff --git a/controlloop/common/feature-controlloop-management/pom.xml b/controlloop/common/feature-controlloop-management/pom.xml index 84fbe485e..3286f8fd0 100644 --- a/controlloop/common/feature-controlloop-management/pom.xml +++ b/controlloop/common/feature-controlloop-management/pom.xml @@ -154,11 +154,6 @@ <version>${policy.models.version}</version> </dependency> <dependency> - <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> - <artifactId>trafficgenerator</artifactId> - <version>${policy.models.version}</version> - </dependency> - <dependency> <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> <artifactId>eventmanager</artifactId> <version>${project.version}</version> diff --git a/controlloop/common/model-impl/aai/pom.xml b/controlloop/common/model-impl/aai/pom.xml deleted file mode 100644 index f563ab4f8..000000000 --- a/controlloop/common/model-impl/aai/pom.xml +++ /dev/null @@ -1,66 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - drools-pdp-apps - ================================================================================ - Copyright (C) 2017-2018 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========================================================= - --> - -<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.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>model-impl</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>aai</artifactId> - - <dependencies> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>rest</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <version>2.13.0</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.common</groupId> - <artifactId>policy-endpoints</artifactId> - <version>${version.policy.common}</version> - <scope>provided</scope> - </dependency> - </dependencies> -</project> diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetResponse.java deleted file mode 100644 index e702db699..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetResponse.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class AaiGetResponse implements Serializable { - private static final long serialVersionUID = 7311418432051756162L; - - @SerializedName("requestError") - private AaiNqRequestError requestError; - - public AaiNqRequestError getRequestError() { - return requestError; - } - - public void setRequestError(AaiNqRequestError requestError) { - this.requestError = requestError; - } - -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVnfResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVnfResponse.java deleted file mode 100644 index b6c38477a..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVnfResponse.java +++ /dev/null @@ -1,151 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class AaiGetVnfResponse extends AaiGetResponse implements Serializable { - - private static final long serialVersionUID = -6247505944905898871L; - - @SerializedName("vnf-id") - private String vnfId; - - @SerializedName("vnf-name") - private String vnfName; - - @SerializedName("vnf-type") - private String vnfType; - - @SerializedName("service-id") - private String serviceId; - - @SerializedName("orchestration-status") - private String orchestrationStatus; - - @SerializedName("in-maint") - private boolean inMaint; - - @SerializedName("is-closed-loop-disabled") - private boolean isClosedLoopDisabled; - - @SerializedName("model-invariant-id") - private String modelInvariantId; - - @SerializedName("prov-status") - private String provStatus; - - @SerializedName("resource-version") - private String resourceVersion; - - @SerializedName("relationship-list") - private RelationshipList relationshipList; - - public String getVnfId() { - return vnfId; - } - - public String getVnfName() { - return vnfName; - } - - public String getVnfType() { - return vnfType; - } - - public String getServiceId() { - return serviceId; - } - - public String getOrchestrationStatus() { - return orchestrationStatus; - } - - public boolean getInMaint() { - return inMaint; - } - - public boolean getIsClosedLoopDisabled() { - return isClosedLoopDisabled; - } - - public String getModelInvariantId() { - return modelInvariantId; - } - - public String getProvStatus() { - return provStatus; - } - - public String getResourceVersion() { - return resourceVersion; - } - - public RelationshipList getRelationshipList() { - return relationshipList; - } - - public void setVnfId(String vnfId) { - this.vnfId = vnfId; - } - - public void setVnfName(String vnfName) { - this.vnfName = vnfName; - } - - public void setVnfType(String vnfType) { - this.vnfType = vnfType; - } - - public void setServiceId(String serviceId) { - this.serviceId = serviceId; - } - - public void setOrchestrationStatus(String orchestrationStatus) { - this.orchestrationStatus = orchestrationStatus; - } - - public void setInMaint(boolean inMaint) { - this.inMaint = inMaint; - } - - public void setIsClosedLoopDisabled(boolean isClosedLoopDisabled) { - this.isClosedLoopDisabled = isClosedLoopDisabled; - } - - public void setModelInvariantId(String modelInvariantId) { - this.modelInvariantId = modelInvariantId; - } - - public void setProvStatus(String provStatus) { - this.provStatus = provStatus; - } - - public void setResourceVersion(String resourceVersion) { - this.resourceVersion = resourceVersion; - } - - public void setRelationshipList(RelationshipList relationshipList) { - this.relationshipList = relationshipList; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVserverResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVserverResponse.java deleted file mode 100644 index a2d4b856a..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiGetVserverResponse.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; - -public class AaiGetVserverResponse extends AaiGetResponse implements Serializable { - - private static final long serialVersionUID = -6247505944905898871L; - - @SerializedName("vserver") - private List<AaiNqVServer> vserver = new LinkedList<>(); - - public List<AaiNqVServer> getVserver() { - return vserver; - } - - public void setVserver(List<AaiNqVServer> vserver) { - this.vserver = vserver; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java deleted file mode 100644 index e609e932e..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiManager.java +++ /dev/null @@ -1,234 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd. - * ================================================================================ - * 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.aai; - -import com.google.gson.JsonSyntaxException; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.onap.policy.aai.util.Serialization; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; -import org.onap.policy.rest.RestManager; -import org.onap.policy.rest.RestManager.Pair; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class handles communication towards and responses from A&AI for this module. - */ -public final class AaiManager { - - /** The Constant logger. */ - private static final Logger logger = LoggerFactory.getLogger(AaiManager.class); - - /** The rest manager. */ - // The REST manager used for processing REST calls for this AAI manager - private final RestManager restManager; - - /** - * Constructor, create the AAI manager with the specified REST manager. - * - * @param restManager the rest manager to use for REST calls - */ - public AaiManager(final RestManager restManager) { - this.restManager = restManager; - } - - /** - * Post a query to A&AI. - * - * @param url the A&AI URL - * @param username the user name for authentication - * @param password the password for authentication - * @param request the request to issue towards A&AI - * @param requestId the UUID of the request - * @return the response from A&AI - */ - public AaiNqResponse postQuery(String url, String username, String password, AaiNqRequest request, UUID requestId) { - - final Map<String, String> headers = createHeaders(requestId); - - url = url + "/aai/search/named-query"; - - logger.debug("RestManager.post before"); - String requestJson = Serialization.gsonPretty.toJson(request); - NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, requestJson); - Pair<Integer, String> httpDetails = - restManager.post(url, username, password, headers, "application/json", requestJson); - logger.debug("RestManager.post after"); - - if (httpDetails == null) { - logger.info("AAI POST Null Response to {}", url); - return null; - } - - int httpResponseCode = httpDetails.first; - - logger.info(url); - logger.info("{}", httpResponseCode); - logger.info(httpDetails.second); - - if (httpDetails.second != null) { - return composeResponse(httpDetails, url, AaiNqResponse.class); - } - return null; - } - - /** - * Perform a GET request for a particular virtual server towards A&AI. - * - * @param urlGet the A&AI URL - * @param username the user name for authentication - * @param password the password for authentication - * @param requestId the UUID of the request - * @param key the key of the virtual server - * @return the response for the virtual server from A&AI - */ - public AaiGetVserverResponse getQueryByVserverName(String urlGet, String username, String password, UUID requestId, - String key) { - return getQuery(urlGet, username, password, requestId, key, AaiGetVserverResponse.class); - } - - /** - * Perform a GET request for a particular VNF by VNF ID towards A&AI. - * - * @param urlGet the A&AI URL - * @param username the user name for authentication - * @param password the password for authentication - * @param requestId the UUID of the request - * @param key the ID of the VNF - * @return the response for the virtual server from A&AI - */ - public AaiGetVnfResponse getQueryByVnfId(String urlGet, String username, String password, UUID requestId, - String key) { - return getQuery(urlGet, username, password, requestId, key, AaiGetVnfResponse.class); - } - - /** - * Perform a GET request for a particular VNF by VNF name towards A&AI. - * - * @param urlGet the A&AI URL - * @param username the user name for authentication - * @param password the password for authentication - * @param requestId the UUID of the request - * @param key the name of the VNF - * @return the response for the virtual server from A&AI - */ - public AaiGetVnfResponse getQueryByVnfName(String urlGet, String username, String password, UUID requestId, - String key) { - return getQuery(urlGet, username, password, requestId, key, AaiGetVnfResponse.class); - } - - /** - * Perform a GET query for a particular entity towards A&AI. - * - * @param <T> the generic type for the response - * @param urlGet the A&AI URL - * @param username the user name for authentication - * @param password the password for authentication - * @param requestId the UUID of the request - * @param key the name of the VNF - * @param classOfT the class of the response to return - * @return the response for the virtual server from A&AI - */ - private <T> T getQuery(final String url, final String username, final String password, final UUID requestId, - final String key, final Class<T> classOfResponse) { - - Map<String, String> headers = createHeaders(requestId); - - String urlGet = url + key; - - int attemptsLeft = 3; - - while (attemptsLeft-- > 0) { - NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|]", CommInfrastructure.REST, urlGet); - Pair<Integer, String> httpDetailsGet = restManager.get(urlGet, username, password, headers); - if (httpDetailsGet == null) { - logger.info("AAI GET Null Response to {}", urlGet); - return null; - } - - int httpResponseCode = httpDetailsGet.first; - - logger.info(urlGet); - logger.info("{}", httpResponseCode); - logger.info(httpDetailsGet.second); - - if (httpResponseCode == 200) { - T responseGet = composeResponse(httpDetailsGet, urlGet, classOfResponse); - if (responseGet != null) { - return responseGet; - } - } - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - - } - - return null; - } - - /** - * Create the headers for the HTTP request. - * - * @param requestId the request ID to insert in the headers - * @return the HTTP headers - */ - private Map<String, String> createHeaders(final UUID requestId) { - Map<String, String> headers = new HashMap<>(); - - headers.put("X-FromAppId", "POLICY"); - headers.put("X-TransactionId", requestId.toString()); - headers.put("Accept", "application/json"); - - return headers; - } - - /** - * This method uses Google's GSON to create a response object from a JSON string. - * - * @param <T> the generic type - * @param httpDetails the HTTP response - * @param url the URL from which the response came - * @param classOfResponse The response class - * @return an instance of the response class - * @throws JsonSyntaxException on GSON errors instantiating the response - */ - private <T> T composeResponse(final Pair<Integer, String> httpDetails, final String url, - final Class<T> classOfResponse) { - try { - T response = Serialization.gsonPretty.fromJson(httpDetails.second, classOfResponse); - NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, url, httpDetails.second); - return response; - } catch (JsonSyntaxException e) { - logger.error("postQuery threw: ", e); - return null; - } - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqCloudRegion.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqCloudRegion.java deleted file mode 100644 index b0715bc7a..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqCloudRegion.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class AaiNqCloudRegion implements Serializable { - - private static final long serialVersionUID = -897231529157222683L; - - @SerializedName("cloud-owner") - private String cloudOwner; - - @SerializedName("cloud-region-id") - private String cloudRegionId; - - @SerializedName("cloud-region-version") - private String cloudRegionVersion; - - @SerializedName("complex-name") - private String complexName; - - @SerializedName("resource-version") - private String resourceVersion; - - public String getCloudOwner() { - return cloudOwner; - } - - public String getCloudRegionId() { - return cloudRegionId; - } - - public String getCloudRegionVersion() { - return cloudRegionVersion; - } - - public String getComplexName() { - return complexName; - } - - public String getResourceVersion() { - return resourceVersion; - } - - public void setCloudOwner(String cloudOwner) { - this.cloudOwner = cloudOwner; - } - - public void setCloudRegionId(String cloudRegionId) { - this.cloudRegionId = cloudRegionId; - } - - public void setCloudRegionVersion(String cloudRegionVersion) { - this.cloudRegionVersion = cloudRegionVersion; - } - - public void setComplexName(String complexName) { - this.complexName = complexName; - } - - public void setResourceVersion(String resourceVersion) { - this.resourceVersion = resourceVersion; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperties.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperties.java deleted file mode 100644 index abe779f32..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperties.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; - -public class AaiNqExtraProperties implements Serializable { - private static final long serialVersionUID = 4109625574744702319L; - - @SerializedName("extra-property") - private List<AaiNqExtraProperty> extraProperty = new LinkedList<>(); - - public List<AaiNqExtraProperty> getExtraProperty() { - return extraProperty; - } - - public void setExtraProperty(List<AaiNqExtraProperty> extraProperty) { - this.extraProperty = extraProperty; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperty.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperty.java deleted file mode 100644 index d63fe1f08..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqExtraProperty.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class AaiNqExtraProperty implements Serializable { - - private static final long serialVersionUID = -3861240617222397736L; - - @SerializedName("property-name") - private String propertyName; - - @SerializedName("property-value") - private String propertyValue; - - public AaiNqExtraProperty() {} - - public AaiNqExtraProperty(String propertyName, String propertyValue) { - this.propertyName = propertyName; - this.propertyValue = propertyValue; - } - - public String getPropertyName() { - return propertyName; - } - - public String getPropertyValue() { - return propertyValue; - } - - public void setPropertyName(String propertyName) { - this.propertyName = propertyName; - } - - public void setPropertyValue(String propertyValue) { - this.propertyValue = propertyValue; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqGenericVnf.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqGenericVnf.java deleted file mode 100644 index 788d236e7..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqGenericVnf.java +++ /dev/null @@ -1,227 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; -import java.io.Serializable; - -public class AaiNqGenericVnf implements Serializable { - - private static final long serialVersionUID = 834322706248060560L; - - @SerializedName("vnf-id") - private String vnfId; - - @SerializedName("vnf-name") - private String vnfName; - - @SerializedName("vnf-name2") - private String vnfName2; - - @SerializedName("vnf-type") - private String vnfType; - - @SerializedName("service-id") - private String serviceId; - - @SerializedName("prov-status") - private String provStatus; - - @SerializedName("operational-state") - private String operationalState; - - @SerializedName("ipv4-oam-address") - private String ipv4OamAddress; - - @SerializedName("ipv4-loopback0-address") - private String ipv4Loopback0Address; - - @SerializedName("in-maint") - private Boolean inMaint; - - @SerializedName("is-closed-loop-disabled") - private Boolean isClosedLoopDisabled; - - @SerializedName("resource-version") - private String resourceVersion; - - @SerializedName("encrypted-access-flag") - private Boolean encrypedAccessFlag; - - @SerializedName("persona-model-id") - private String personaModelId; - - @SerializedName("persona-model-version") - private String personaModelVersion; - - @SerializedName("model-invariant-id") - private String modelInvariantId; - - @SerializedName("model-version-id") - private String modelVersionId; - - @SerializedName("model-customization-id") - private String modelCustomizationId = null; - - public String getVnfId() { - return vnfId; - } - - public String getVnfName() { - return vnfName; - } - - public String getVnfName2() { - return vnfName2; - } - - public String getVnfType() { - return vnfType; - } - - public String getServiceId() { - return serviceId; - } - - public String getProvStatus() { - return provStatus; - } - - public String getOperationalState() { - return operationalState; - } - - public String getIpv4OamAddress() { - return ipv4OamAddress; - } - - public String getIpv4Loopback0Address() { - return ipv4Loopback0Address; - } - - public Boolean getInMaint() { - return inMaint; - } - - public Boolean getIsClosedLoopDisabled() { - return isClosedLoopDisabled; - } - - public String getResourceVersion() { - return resourceVersion; - } - - public Boolean getEncrypedAccessFlag() { - return encrypedAccessFlag; - } - - public String getPersonaModelId() { - return personaModelId; - } - - public String getPersonaModelVersion() { - return personaModelVersion; - } - - public String getModelInvariantId() { - return modelInvariantId; - } - - public String getModelVersionId() { - return modelVersionId; - } - - public String getModelCustomizationId() { - return modelCustomizationId; - } - - public void setVnfId(String vnfId) { - this.vnfId = vnfId; - } - - public void setVnfName(String vnfName) { - this.vnfName = vnfName; - } - - public void setVnfName2(String vnfName2) { - this.vnfName2 = vnfName2; - } - - public void setVnfType(String vnfType) { - this.vnfType = vnfType; - } - - public void setServiceId(String serviceId) { - this.serviceId = serviceId; - } - - public void setProvStatus(String provStatus) { - this.provStatus = provStatus; - } - - public void setOperationalState(String operationalState) { - this.operationalState = operationalState; - } - - public void setIpv4OamAddress(String ipv4OamAddress) { - this.ipv4OamAddress = ipv4OamAddress; - } - - public void setIpv4Loopback0Address(String ipv4Loopback0Address) { - this.ipv4Loopback0Address = ipv4Loopback0Address; - } - - public void setInMaint(Boolean inMaint) { - this.inMaint = inMaint; - } - - public void setIsClosedLoopDisabled(Boolean isClosedLoopDisabled) { - this.isClosedLoopDisabled = isClosedLoopDisabled; - } - - public void setResourceVersion(String resourceVersion) { - this.resourceVersion = resourceVersion; - } - - public void setEncrypedAccessFlag(Boolean encrypedAccessFlag) { - this.encrypedAccessFlag = encrypedAccessFlag; - } - - public void setPersonaModelId(String personaModelId) { - this.personaModelId = personaModelId; - } - - public void setPersonaModelVersion(String personaModelVersion) { - this.personaModelVersion = personaModelVersion; - } - - public void setModelInvariantId(String modelInvariantId) { - this.modelInvariantId = modelInvariantId; - } - - public void setModelVersionId(String modelVersionId) { - this.modelVersionId = modelVersionId; - } - - public void setModelCustomizationId(String modelCustomizationId) { - this.modelCustomizationId = modelCustomizationId; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInstanceFilters.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInstanceFilters.java deleted file mode 100644 index 21cd87f82..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInstanceFilters.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -public class AaiNqInstanceFilters implements Serializable { - - private static final long serialVersionUID = 8993824591338121185L; - - @SerializedName("instance-filter") - private List<Map<String, Map<String, String>>> instanceFilter = new LinkedList<>(); - - public List<Map<String, Map<String, String>>> getInstanceFilter() { - return instanceFilter; - } - - public void setInstanceFilter(List<Map<String, Map<String, String>>> instanceFilter) { - this.instanceFilter = instanceFilter; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItem.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItem.java deleted file mode 100644 index 53ec65fff..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItem.java +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class AaiNqInventoryResponseItem implements Serializable { - - private static final long serialVersionUID = 7142072567154675183L; - - @SerializedName("model-name") - private String modelName; - - @SerializedName("vf-module") - private AaiNqVfModule vfModule; - - @SerializedName("service-instance") - private AaiNqServiceInstance serviceInstance; - - @SerializedName("vserver") - private AaiNqVServer vserver; - - @SerializedName("tenant") - private AaiNqTenant tenant; - - @SerializedName("cloud-region") - private AaiNqCloudRegion cloudRegion; - - @SerializedName("generic-vnf") - private AaiNqGenericVnf genericVnf; - - @SerializedName("extra-properties") - private AaiNqExtraProperties extraProperties; - - @SerializedName("inventory-response-items") - private AaiNqInventoryResponseItems items; - - public String getModelName() { - return modelName; - } - - public AaiNqVfModule getVfModule() { - return vfModule; - } - - public AaiNqServiceInstance getServiceInstance() { - return serviceInstance; - } - - public AaiNqVServer getVserver() { - return vserver; - } - - public AaiNqTenant getTenant() { - return tenant; - } - - public AaiNqCloudRegion getCloudRegion() { - return cloudRegion; - } - - public AaiNqGenericVnf getGenericVnf() { - return genericVnf; - } - - public AaiNqExtraProperties getExtraProperties() { - return extraProperties; - } - - public AaiNqInventoryResponseItems getItems() { - return items; - } - - public void setModelName(String modelName) { - this.modelName = modelName; - } - - public void setVfModule(AaiNqVfModule vfModule) { - this.vfModule = vfModule; - } - - public void setServiceInstance(AaiNqServiceInstance serviceInstance) { - this.serviceInstance = serviceInstance; - } - - public void setVserver(AaiNqVServer vserver) { - this.vserver = vserver; - } - - public void setTenant(AaiNqTenant tenant) { - this.tenant = tenant; - } - - public void setCloudRegion(AaiNqCloudRegion cloudRegion) { - this.cloudRegion = cloudRegion; - } - - public void setGenericVnf(AaiNqGenericVnf genericVnf) { - this.genericVnf = genericVnf; - } - - public void setExtraProperties(AaiNqExtraProperties extraProperties) { - this.extraProperties = extraProperties; - } - - public void setItems(AaiNqInventoryResponseItems items) { - this.items = items; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItems.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItems.java deleted file mode 100644 index 3ebbc1644..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqInventoryResponseItems.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; - -public class AaiNqInventoryResponseItems implements Serializable { - private static final long serialVersionUID = 7602807659381179004L; - - @SerializedName("inventory-response-item") - private List<AaiNqInventoryResponseItem> inventoryResponseItems = new LinkedList<>(); - - public List<AaiNqInventoryResponseItem> getInventoryResponseItems() { - return inventoryResponseItems; - } - - public void setInventoryResponseItems(List<AaiNqInventoryResponseItem> inventoryResponseItems) { - this.inventoryResponseItems = inventoryResponseItems; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqNamedQuery.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqNamedQuery.java deleted file mode 100644 index 1d18eb857..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqNamedQuery.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.UUID; - -public class AaiNqNamedQuery implements Serializable { - private static final long serialVersionUID = -3277980060302645333L; - - @SerializedName("named-query-uuid") - private UUID namedQueryUuid; - - public UUID getNamedQueryUuid() { - return namedQueryUuid; - } - - public void setNamedQueryUuid(UUID namedQueryUuid) { - this.namedQueryUuid = namedQueryUuid; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqQueryParameters.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqQueryParameters.java deleted file mode 100644 index 438e5b269..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqQueryParameters.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class AaiNqQueryParameters implements Serializable { - private static final long serialVersionUID = -4291227193197126982L; - - @SerializedName("named-query") - private AaiNqNamedQuery namedQuery; - - public AaiNqNamedQuery getNamedQuery() { - return namedQuery; - } - - public void setNamedQuery(AaiNqNamedQuery namedQuery) { - this.namedQuery = namedQuery; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequest.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequest.java deleted file mode 100644 index 9e60ed1a6..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequest.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class AaiNqRequest implements Serializable { - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("query-parameters") - private AaiNqQueryParameters queryParameters; - - @SerializedName("instance-filters") - private AaiNqInstanceFilters instanceFilters; - - public AaiNqQueryParameters getQueryParameters() { - return queryParameters; - } - - public AaiNqInstanceFilters getInstanceFilters() { - return instanceFilters; - } - - public void setQueryParameters(AaiNqQueryParameters queryParameters) { - this.queryParameters = queryParameters; - } - - public void setInstanceFilters(AaiNqInstanceFilters instanceFilters) { - this.instanceFilters = instanceFilters; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequestError.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequestError.java deleted file mode 100644 index 4a7ce504b..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqRequestError.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class AaiNqRequestError implements Serializable { - private static final long serialVersionUID = -7742674155387022932L; - - @SerializedName("serviceException") - private AaiNqServiceExcept serviceExcept; - - public AaiNqServiceExcept getServiceExcept() { - return serviceExcept; - } - - public void setServiceExcept(AaiNqServiceExcept serviceExcept) { - this.serviceExcept = serviceExcept; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponse.java deleted file mode 100644 index 36eb0c299..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponse.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; - -public class AaiNqResponse implements Serializable { - private static final long serialVersionUID = 8411407444051746101L; - - @SerializedName("inventory-response-item") - private List<AaiNqInventoryResponseItem> inventoryResponseItems = new LinkedList<>(); - - @SerializedName("requestError") - private AaiNqRequestError requestError; - - public List<AaiNqInventoryResponseItem> getInventoryResponseItems() { - return inventoryResponseItems; - } - - public AaiNqRequestError getRequestError() { - return requestError; - } - - public void setRequestError(AaiNqRequestError requestError) { - this.requestError = requestError; - } - - public void setInventoryResponseItems(List<AaiNqInventoryResponseItem> inventoryResponseItems) { - this.inventoryResponseItems = inventoryResponseItems; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponseWrapper.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponseWrapper.java deleted file mode 100644 index 038e3f88b..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqResponseWrapper.java +++ /dev/null @@ -1,152 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.UUID; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqResponseWrapper implements Serializable { - private static final long serialVersionUID = 8411407444051746101L; - - private static final Logger logger = LoggerFactory.getLogger(AaiNqResponseWrapper.class); - - private static final Pattern VF_MODULE_NAME_PAT = Pattern.compile("(.*_)(\\d+)"); - - private UUID requestId; - private AaiNqResponse aaiNqResponse; - - public AaiNqResponseWrapper() {} - - public AaiNqResponseWrapper(UUID requestId, AaiNqResponse aaiNqResponse) { - this.requestId = requestId; - this.aaiNqResponse = aaiNqResponse; - } - - public UUID getRequestId() { - return requestId; - } - - public void setRequestId(UUID requestId) { - this.requestId = requestId; - } - - public AaiNqResponse getAaiNqResponse() { - return aaiNqResponse; - } - - public void setAaiNqResponse(AaiNqResponse aaiNqResponse) { - this.aaiNqResponse = aaiNqResponse; - } - - /** - * Counts the number of VF modules, if any, in the response. - * - * @return the number of VF modules, or {@code 0} if there are none - */ - public int countVfModules() { - return getVfModuleItems(false).size(); - } - - /** - * Generates the name for the next VF module. - * - * @return the name of the next VF module, or {@code null} if the name could not be - * generated (i.e., because the response has no matching VF module names on - * which to model it) - */ - public String genVfModuleName() { - /* - * Loop through the VF modules, extracting the name prefix and the largest number - * suffix - */ - String prefix = null; - int maxSuffix = -1; - - for (AaiNqInventoryResponseItem item : getVfModuleItems(false)) { - String name = item.getVfModule().getVfModuleName(); - Matcher matcher = VF_MODULE_NAME_PAT.matcher(name); - if (matcher.matches()) { - int suffix = Integer.parseInt(matcher.group(2)); - if (suffix > maxSuffix) { - maxSuffix = suffix; - prefix = matcher.group(1); - } - } - } - - ++maxSuffix; - - return (prefix == null ? null : prefix + maxSuffix); - } - - /** - * Gets a list of VF modules. If the non-base VF modules are requested, then only - * those whose names match the name pattern, {@link #VF_MODULE_NAME_PAT}, are - * returned. - * - * @param wantBaseModule {@code true} if the the base VF module(s) is desired, - * {@code false} otherwise - * @return the list of VF module items - */ - public List<AaiNqInventoryResponseItem> getVfModuleItems(boolean wantBaseModule) { - // get the list of items - List<AaiNqInventoryResponseItem> itemList; - try { - itemList = aaiNqResponse.getInventoryResponseItems().get(0).getItems().getInventoryResponseItems().get(0) - .getItems().getInventoryResponseItems(); - - } catch (NullPointerException | IndexOutOfBoundsException e) { - logger.debug("no VF modules in AAI response", e); - return Collections.emptyList(); - } - - if (itemList == null) { - return Collections.emptyList(); - } - - /* - * Walk the items looking for VF modules, allocating the list only when an item is - * found. - */ - List<AaiNqInventoryResponseItem> vfModuleItems = new ArrayList<>(itemList.size()); - - for (AaiNqInventoryResponseItem inventoryResponseItem : itemList) { - AaiNqVfModule vfmod = inventoryResponseItem.getVfModule(); - if (vfmod == null) { - continue; - } - - if (vfmod.getIsBaseVfModule() == wantBaseModule - && (wantBaseModule || VF_MODULE_NAME_PAT.matcher(vfmod.getVfModuleName()).matches())) { - vfModuleItems.add(inventoryResponseItem); - } - } - - return vfModuleItems; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceExcept.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceExcept.java deleted file mode 100644 index 77ac46d3d..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceExcept.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class AaiNqServiceExcept implements Serializable { - private static final long serialVersionUID = 2858343404484338546L; - - @SerializedName("messageId") - private String messageId; - - @SerializedName("text") - private String text; - - @SerializedName("variables") - private String[] variables; - - public String getMessageId() { - return messageId; - } - - public String getText() { - return text; - } - - public String[] getVariables() { - return variables; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceInstance.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceInstance.java deleted file mode 100644 index a3aa65920..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqServiceInstance.java +++ /dev/null @@ -1,117 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class AaiNqServiceInstance implements Serializable { - private static final long serialVersionUID = -8000944396593889586L; - - @SerializedName("service-instance-id") - private String serviceInstanceId; - - @SerializedName("service-instance-name") - private String serviceInstanceName; - - @SerializedName("persona-model-id") - private String personaModelId; - - @SerializedName("persona-model-version") - private String personaModelVersion; - - @SerializedName("service-instance-location-id") - private String serviceInstanceLocationId; - - @SerializedName("resource-version") - private String resourceVersion; - - @SerializedName("model-invariant-id") - private String modelInvariantId; - - @SerializedName("model-version-id") - private String modelVersionId; - - public String getServiceInstanceId() { - return serviceInstanceId; - } - - public String getServiceInstanceName() { - return serviceInstanceName; - } - - public String getPersonaModelId() { - return personaModelId; - } - - public String getPersonaModelVersion() { - return personaModelVersion; - } - - public String getServiceInstanceLocationId() { - return serviceInstanceLocationId; - } - - public String getResourceVersion() { - return resourceVersion; - } - - public String getModelInvariantId() { - return modelInvariantId; - } - - public String getModelVersionId() { - return modelVersionId; - } - - public void setServiceInstanceId(String serviceInstanceId) { - this.serviceInstanceId = serviceInstanceId; - } - - public void setServiceInstanceName(String serviceInstanceName) { - this.serviceInstanceName = serviceInstanceName; - } - - public void setPersonaModelId(String personaModelId) { - this.personaModelId = personaModelId; - } - - public void setPersonaModelVersion(String personaModelVersion) { - this.personaModelVersion = personaModelVersion; - } - - public void setServiceInstanceLocationId(String serviceInstanceLocationId) { - this.serviceInstanceLocationId = serviceInstanceLocationId; - } - - public void setResourceVersion(String resourceVersion) { - this.resourceVersion = resourceVersion; - } - - public void setModelInvariantId(String modelInvariantId) { - this.modelInvariantId = modelInvariantId; - } - - public void setModelVersionId(String modelVersionId) { - this.modelVersionId = modelVersionId; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqTenant.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqTenant.java deleted file mode 100644 index c8c6d106f..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqTenant.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class AaiNqTenant implements Serializable { - private static final long serialVersionUID = 4702784101671984364L; - - @SerializedName("tenant-id") - private String tenantId; - - @SerializedName("tenant-name") - private String tenantName; - - @SerializedName("resource-version") - private String resourceVersion; - - public String getTenantId() { - return tenantId; - } - - public String getTenantName() { - return tenantName; - } - - public String getResourceVersion() { - return resourceVersion; - } - - public void setTenantId(String tenantId) { - this.tenantId = tenantId; - } - - public void setTenantName(String tenantName) { - this.tenantName = tenantName; - } - - public void setResourceVersion(String resourceVersion) { - this.resourceVersion = resourceVersion; - } - - -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVServer.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVServer.java deleted file mode 100644 index c624497f1..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVServer.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class AaiNqVServer implements Serializable { - private static final long serialVersionUID = -6718526692734215643L; - - @SerializedName("vserver-id") - private String vserverId; - - @SerializedName("vserver-name") - private String vserverName; - - @SerializedName("vserver-name2") - private String vserverName2; - - @SerializedName("prov-status") - private String provStatus; - - @SerializedName("vserver-selflink") - private String vserverSelflink; - - @SerializedName("in-maint") - private Boolean inMaint; - - @SerializedName("is-closed-loop-disabled") - private Boolean isClosedLoopDisabled; - - @SerializedName("resource-version") - private String resourceVersion; - - @SerializedName("relationship-list") - private RelationshipList relationshipList; - - public String getVserverId() { - return vserverId; - } - - public String getVserverName() { - return vserverName; - } - - public String getVserverName2() { - return vserverName2; - } - - public String getProvStatus() { - return provStatus; - } - - public String getVserverSelflink() { - return vserverSelflink; - } - - public Boolean getInMaint() { - return inMaint; - } - - public Boolean getIsClosedLoopDisabled() { - return isClosedLoopDisabled; - } - - public String getResourceVersion() { - return resourceVersion; - } - - public RelationshipList getRelationshipList() { - return relationshipList; - } - - public void setVserverId(String vserverId) { - this.vserverId = vserverId; - } - - public void setVserverName(String vserverName) { - this.vserverName = vserverName; - } - - public void setVserverName2(String vserverName2) { - this.vserverName2 = vserverName2; - } - - public void setProvStatus(String provStatus) { - this.provStatus = provStatus; - } - - public void setVserverSelflink(String vserverSelflink) { - this.vserverSelflink = vserverSelflink; - } - - public void setInMaint(Boolean inMaint) { - this.inMaint = inMaint; - } - - public void setIsClosedLoopDisabled(Boolean isClosedLoopDisabled) { - this.isClosedLoopDisabled = isClosedLoopDisabled; - } - - public void setResourceVersion(String resourceVersion) { - this.resourceVersion = resourceVersion; - } - - public void setRelationshipList(RelationshipList relationshipList) { - this.relationshipList = relationshipList; - } - -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVfModule.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVfModule.java deleted file mode 100644 index d8021af28..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVfModule.java +++ /dev/null @@ -1,182 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; -import java.io.Serializable; - -public class AaiNqVfModule implements Serializable { - private static final long serialVersionUID = 8019133081429638232L; - - @SerializedName("vf-module-id") - private String vfModuleId; - - @SerializedName("vf-module-name") - private String vfModuleName; - - @SerializedName("heat-stack-id") - private String heatStackId; - - @SerializedName("orchestration-status") - private String orchestrationStatus; - - @SerializedName("is-base-vf-module") - private Boolean isBaseVfModule; - - @SerializedName("resource-version") - private String resourceVersion; - - @SerializedName("persona-model-id") - private String personaModelId; - - @SerializedName("persona-model-version") - private String personaModelVersion; - - @SerializedName("widget-model-id") - private String widgetModelId; - - @SerializedName("widget-model-version") - private String widgetModelVersion; - - @SerializedName("contrail-service-instance-fqdn") - private String contrailServiceInstanceFqdn; - - @SerializedName("model-invariant-id") - private String modelInvariantId; - - @SerializedName("model-version-id") - private String modelVersionId; - - @SerializedName("model-customization-id") - private String modelCustomizationId = null; - - public String getVfModuleId() { - return vfModuleId; - } - - public String getVfModuleName() { - return vfModuleName; - } - - public String getHeatStackId() { - return heatStackId; - } - - public String getOrchestrationStatus() { - return orchestrationStatus; - } - - public Boolean getIsBaseVfModule() { - return isBaseVfModule; - } - - public String getResourceVersion() { - return resourceVersion; - } - - public String getPersonaModelId() { - return personaModelId; - } - - public String getPersonaModelVersion() { - return personaModelVersion; - } - - public String getWidgetModelId() { - return widgetModelId; - } - - public String getWidgetModelVersion() { - return widgetModelVersion; - } - - public String getContrailServiceInstanceFqdn() { - return contrailServiceInstanceFqdn; - } - - public String getModelInvariantId() { - return modelInvariantId; - } - - public String getModelVersionId() { - return modelVersionId; - } - - public String getModelCustomizationId() { - return modelCustomizationId; - } - - public void setVfModuleId(String vfModuleId) { - this.vfModuleId = vfModuleId; - } - - public void setVfModuleName(String vfModuleName) { - this.vfModuleName = vfModuleName; - } - - public void setHeatStackId(String heatStackId) { - this.heatStackId = heatStackId; - } - - public void setOrchestrationStatus(String orchestrationStatus) { - this.orchestrationStatus = orchestrationStatus; - } - - public void setIsBaseVfModule(Boolean isBaseVfModule) { - this.isBaseVfModule = isBaseVfModule; - } - - public void setResourceVersion(String resourceVersion) { - this.resourceVersion = resourceVersion; - } - - public void setPersonaModelId(String personaModelId) { - this.personaModelId = personaModelId; - } - - public void setPersonaModelVersion(String personaModelVersion) { - this.personaModelVersion = personaModelVersion; - } - - public void setWidgetModelId(String widgetModelId) { - this.widgetModelId = widgetModelId; - } - - public void setWidgetModelVersion(String widgetModelVersion) { - this.widgetModelVersion = widgetModelVersion; - } - - public void setContrailServiceInstanceFqdn(String contrailServiceInstanceFqdn) { - this.contrailServiceInstanceFqdn = contrailServiceInstanceFqdn; - } - - public void setModelInvariantId(String modelInvariantId) { - this.modelInvariantId = modelInvariantId; - } - - public void setModelVersionId(String modelVersionId) { - this.modelVersionId = modelVersionId; - } - - public void setModelCustomizationId(String modelCustomizationId) { - this.modelCustomizationId = modelCustomizationId; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Pnf.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Pnf.java deleted file mode 100644 index 2ef0bde46..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Pnf.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017 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.aai; - -import java.io.Serializable; - -public class Pnf implements Serializable { - private static final long serialVersionUID = -3535108358668248501L; - - private String pnfName; - private PnfType pnfType; - - public Pnf() { - - } - - public Pnf(Pnf pnf) { - this.pnfName = pnf.pnfName; - this.pnfType = pnf.pnfType; - } - - public String getPnfName() { - return pnfName; - } - - public void setPnfName(String pnfName) { - this.pnfName = pnfName; - } - - public PnfType getPnfType() { - return pnfType; - } - - public void setPnfType(PnfType pnfType) { - this.pnfType = pnfType; - } - - @Override - public String toString() { - return "PNF [PNFName=" + pnfName + ", PNFType=" + pnfType + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((pnfName == null) ? 0 : pnfName.hashCode()); - result = prime * result + ((pnfType == null) ? 0 : pnfType.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Pnf other = (Pnf) obj; - if (pnfName == null) { - if (other.pnfName != null) { - return false; - } - } else if (!pnfName.equals(other.pnfName)) { - return false; - } - return pnfType == other.pnfType; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PnfInstance.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PnfInstance.java deleted file mode 100644 index 9d9e26c2c..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PnfInstance.java +++ /dev/null @@ -1,137 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import java.io.Serializable; - -public class PnfInstance implements Serializable { - - private static final long serialVersionUID = -3694152433472165034L; - - private String pnfName; - private String pnfInstanceName; - private PnfType pnfType; - private String pnfSerial; - - public PnfInstance() { - - } - - /** - * Create an instance from a given instance. - * - * @param instance the instance - */ - public PnfInstance(PnfInstance instance) { - if (instance == null) { - return; - } - this.pnfName = instance.pnfName; - this.pnfInstanceName = instance.pnfInstanceName; - this.pnfType = instance.pnfType; - this.pnfSerial = instance.pnfSerial; - } - - public String getPnfName() { - return pnfName; - } - - public void setPnfName(String pnfName) { - this.pnfName = pnfName; - } - - public String getPnfInstanceName() { - return pnfInstanceName; - } - - public void setPnfInstanceName(String pnfInstanceName) { - this.pnfInstanceName = pnfInstanceName; - } - - public PnfType getPnfType() { - return pnfType; - } - - public void setPnfType(PnfType pnfType) { - this.pnfType = pnfType; - } - - public String getPnfSerial() { - return pnfSerial; - } - - public void setPnfSerial(String pnfSerial) { - this.pnfSerial = pnfSerial; - } - - @Override - public String toString() { - return "PNFInstance [PNFName=" + pnfName + ", PNFInstanceName=" + pnfInstanceName + ", PNFType=" + pnfType - + ", PNFSerial=" + pnfSerial + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((pnfInstanceName == null) ? 0 : pnfInstanceName.hashCode()); - result = prime * result + ((pnfName == null) ? 0 : pnfName.hashCode()); - result = prime * result + ((pnfSerial == null) ? 0 : pnfSerial.hashCode()); - result = prime * result + ((pnfType == null) ? 0 : pnfType.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - PnfInstance other = (PnfInstance) obj; - if (pnfInstanceName == null) { - if (other.pnfInstanceName != null) { - return false; - } - } else if (!pnfInstanceName.equals(other.pnfInstanceName)) { - return false; - } - if (pnfName == null) { - if (other.pnfName != null) { - return false; - } - } else if (!pnfName.equals(other.pnfName)) { - return false; - } - if (pnfSerial == null) { - if (other.pnfSerial != null) { - return false; - } - } else if (!pnfSerial.equals(other.pnfSerial)) { - return false; - } - return pnfType == other.pnfType; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PnfType.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PnfType.java deleted file mode 100644 index 29dd2690c..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PnfType.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -public enum PnfType { - ENODEB("eNodeB"), PSERVER("pserver"); - - private String type; - - private PnfType(String type) { - this.type = type; - } - - @Override - public String toString() { - return this.type; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java deleted file mode 100644 index ca126d12c..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class RelatedToProperty implements Serializable { - private static final long serialVersionUID = 5644372985092588638L; - - @SerializedName("property-key") - private String propertyKey; - @SerializedName("property-value") - private String propertyValue; - - public String getPropertyKey() { - return propertyKey; - } - - public String getPropertyValue() { - return propertyValue; - } - - public void setPropertyKey(String propertyKey) { - this.propertyKey = propertyKey; - } - - public void setPropertyValue(String propertyValue) { - this.propertyValue = propertyValue; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java deleted file mode 100644 index 496129825..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; - -public class Relationship implements Serializable { - private static final long serialVersionUID = -68508443869003055L; - - @SerializedName("related-to") - private String relatedTo; - - @SerializedName("related-link") - private String relatedLink; - - @SerializedName("relationship-data") - private List<RelationshipData> relationshipData = new LinkedList<>(); - - @SerializedName("related-to-property") - private List<RelatedToProperty> relatedToProperty = new LinkedList<>(); - - public String getRelatedTo() { - return relatedTo; - } - - public String getRelatedLink() { - return relatedLink; - } - - public List<RelationshipData> getRelationshipData() { - return relationshipData; - } - - public List<RelatedToProperty> getRelatedToProperty() { - return relatedToProperty; - } - - public void setRelatedTo(String relatedTo) { - this.relatedTo = relatedTo; - } - - public void setRelatedLink(String relatedLink) { - this.relatedLink = relatedLink; - } - - public void setRelationshipData(List<RelationshipData> relationshipData) { - this.relationshipData = relationshipData; - } - - public void setRelatedToProperty(List<RelatedToProperty> relatedToProperty) { - this.relatedToProperty = relatedToProperty; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java deleted file mode 100644 index 24170803d..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class RelationshipData implements Serializable { - private static final long serialVersionUID = 550450041634939768L; - - @SerializedName("relationship-key") - private String relationshipKey; - @SerializedName("relationship-value") - private String relationshipValue; - - public String getRelationshipKey() { - return relationshipKey; - } - - public String getRelationshipValue() { - return relationshipValue; - } - - public void setRelationshipKey(String relationshipKey) { - this.relationshipKey = relationshipKey; - } - - public void setRelationshipValue(String relationshipValue) { - this.relationshipValue = relationshipValue; - } -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java deleted file mode 100644 index 8db1c7a39..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; - -public class RelationshipList implements Serializable { - private static final long serialVersionUID = 6115655704973981990L; - - @SerializedName("relationship") - private List<Relationship> relationships = new LinkedList<>(); - - public List<Relationship> getRelationships() { - return relationships; - } - - public void setRelationships(List<Relationship> relationships) { - this.relationships = relationships; - } - - -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/util/AaiException.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/util/AaiException.java deleted file mode 100644 index 45ddac431..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/util/AaiException.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017 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.aai.util; - -public class AaiException extends Exception { - - private static final long serialVersionUID = 9220983727706207465L; - - public AaiException() { - super(); - } - - public AaiException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } - - public AaiException(String message, Throwable cause) { - super(message, cause); - } - - public AaiException(String message) { - super(message); - } - - public AaiException(Throwable cause) { - super(cause); - } - -} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/util/Serialization.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/util/Serialization.java deleted file mode 100644 index 5b504c09c..000000000 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/util/Serialization.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai.util; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -public final class Serialization { - - public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() - .create(); - - private Serialization() {} - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetResponseTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetResponseTest.java deleted file mode 100644 index 9afa70a59..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetResponseTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.io.File; -import java.nio.file.Files; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiGetResponseTest { - private static final Logger logger = LoggerFactory.getLogger(AaiGetResponseTest.class); - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/AaiGetResponseError.json").toPath())); - - AaiGetResponse resp = Serialization.gsonPretty.fromJson(json, AaiGetResponse.class); - - // don't need to verify this in depth, as it has its own tests that do that - assertNotNull(resp.getRequestError()); - assertNotNull(resp.getRequestError().getServiceExcept()); - assertEquals("SVC3001", resp.getRequestError().getServiceExcept().getMessageId()); - - logger.info(Serialization.gsonPretty.toJson(resp)); - - // verify that setXxx methods work - resp.setRequestError(null); - assertNull(resp.getRequestError()); - - AaiNqRequestError err = new AaiNqRequestError(); - resp.setRequestError(err); - assertEquals(err, resp.getRequestError()); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVnfResponseTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVnfResponseTest.java deleted file mode 100644 index 26f3ca2dc..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVnfResponseTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.File; -import java.nio.file.Files; -import java.util.List; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiGetVnfResponseTest { - private static final Logger logger = LoggerFactory.getLogger(AaiGetVnfResponseTest.class); - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/AaiGetVnfResponse.json").toPath())); - - AaiGetVnfResponse resp = Serialization.gsonPretty.fromJson(json, AaiGetVnfResponse.class); - - assertEquals("807a3f02-f878-436b-870c-f0e91e81570d", resp.getVnfId()); - assertEquals("vLoadBalancerMS-Vnf-0809-2", resp.getVnfName()); - assertEquals("vLoadBalancerMS/vLoadBalancerMS 0", resp.getVnfType()); - assertEquals("1533850960381", resp.getResourceVersion()); - assertEquals(false, resp.getInMaint()); - assertEquals(true, resp.getIsClosedLoopDisabled()); - assertEquals("53638a85-361a-437d-8830-4b0d5329225e", resp.getModelInvariantId()); - assertEquals("PROV", resp.getProvStatus()); - assertEquals("Active", resp.getOrchestrationStatus()); - assertEquals("50e1b0be-e0c9-48e2-9f42-15279a783ee8", resp.getServiceId()); - - // don't need to verify this in depth, as it has its own tests that do that - RelationshipList relationshipList = resp.getRelationshipList(); - assertNotNull(relationshipList); - - List<Relationship> lst = relationshipList.getRelationships(); - assertNotNull(lst); - - assertEquals(5, lst.size()); - assertEquals("service-instance", lst.get(0).getRelatedTo()); - assertEquals("line-of-business", lst.get(1).getRelatedTo()); - - logger.info(Serialization.gsonPretty.toJson(resp)); - - // verify that setXxx methods work - relationshipList = new RelationshipList(); - - resp.setInMaint(true); - resp.setIsClosedLoopDisabled(false); - resp.setModelInvariantId("modiv"); - resp.setOrchestrationStatus("orch"); - resp.setProvStatus("mystatus"); - resp.setRelationshipList(relationshipList); - resp.setResourceVersion("vers"); - resp.setServiceId("svc"); - resp.setVnfId("vnfid"); - resp.setVnfName("vnfname"); - resp.setVnfType("vnftype"); - - assertEquals("vnfid", resp.getVnfId()); - assertEquals("vnfname", resp.getVnfName()); - assertEquals("vnftype", resp.getVnfType()); - assertEquals("vers", resp.getResourceVersion()); - assertEquals(true, resp.getInMaint()); - assertEquals(false, resp.getIsClosedLoopDisabled()); - assertEquals("modiv", resp.getModelInvariantId()); - assertEquals("mystatus", resp.getProvStatus()); - assertEquals("orch", resp.getOrchestrationStatus()); - assertEquals("svc", resp.getServiceId()); - assertEquals(relationshipList, resp.getRelationshipList()); - - - // test error case - json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/AaiGetResponseError.json").toPath())); - resp = Serialization.gsonPretty.fromJson(json, AaiGetVnfResponse.class); - - // don't need to verify this in depth, as it has its own tests that do that - assertNotNull(resp.getRequestError()); - assertNotNull(resp.getRequestError().getServiceExcept()); - assertEquals("SVC3001", resp.getRequestError().getServiceExcept().getMessageId()); - } -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVserverResponseTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVserverResponseTest.java deleted file mode 100644 index c0160e421..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiGetVserverResponseTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.File; -import java.nio.file.Files; -import java.util.LinkedList; -import java.util.List; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiGetVserverResponseTest { - private static final Logger logger = LoggerFactory.getLogger(AaiGetVserverResponseTest.class); - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/AaiGetVserverResponse.json").toPath())); - - AaiGetVserverResponse resp = Serialization.gsonPretty.fromJson(json, AaiGetVserverResponse.class); - - // don't need to verify this in depth, as it has its own tests that do that - List<AaiNqVServer> lst = resp.getVserver(); - assertEquals(1, lst.size()); - - AaiNqVServer svr = lst.get(0); - assertNotNull(svr); - assertEquals("1c94da3f-16f1-4fc7-9ed1-e018dfa62774", svr.getVserverId()); - - logger.info(Serialization.gsonPretty.toJson(resp)); - - // verify that setXxx methods work - lst = new LinkedList<>(); - lst.add(new AaiNqVServer()); - lst.add(new AaiNqVServer()); - - resp.setVserver(lst); - - assertEquals(lst, resp.getVserver()); - - - // test error case - json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/AaiGetResponseError.json").toPath())); - resp = Serialization.gsonPretty.fromJson(json, AaiGetVserverResponse.class); - - // don't need to verify this in depth, as it has its own tests that do that - assertNotNull(resp.getRequestError()); - assertNotNull(resp.getRequestError().getServiceExcept()); - assertEquals("SVC3001", resp.getRequestError().getServiceExcept().getMessageId()); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java deleted file mode 100644 index 3717740d5..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiManagerTest.java +++ /dev/null @@ -1,169 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-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.aai; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.isNull; -import static org.mockito.ArgumentMatchers.startsWith; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.junit.Before; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.onap.policy.rest.RestManager; -import org.onap.policy.rest.RestManager.Pair; - -public class AaiManagerTest { - RestManager restManagerMock; - UUID aaiNqRequestUuid = UUID.randomUUID(); - Pair<Integer, String> httpResponseOk; - Pair<Integer, String> httpResponseErr0; - Pair<Integer, String> httpResponseErr1; - Pair<Integer, String> httpResponseWait; - - /** - * Set up test cases. - */ - @Before - public void beforeTestAaiManager() { - restManagerMock = mock(RestManager.class); - - Map<String, String> expectedHeaders = new HashMap<>(); - expectedHeaders.put("X-FromAppId", "POLICY"); - expectedHeaders.put("X-TransactionId", aaiNqRequestUuid.toString()); - expectedHeaders.put("Accept", "application/json"); - - AaiNqResponse aaiNqResponse = new AaiNqResponseTest().getAaiNqResponse(); - httpResponseOk = restManagerMock.new Pair<>(200, Serialization.gsonPretty.toJson(aaiNqResponse)); - httpResponseErr0 = restManagerMock.new Pair<>(200, null); - httpResponseErr1 = restManagerMock.new Pair<>(200, "{"); - httpResponseWait = restManagerMock.new Pair<>(503, null); - } - - @Test - public void testAaiManagerAaiNqRequest() { - - AaiManager aaiManager = new AaiManager(restManagerMock); - assertNotNull(aaiManager); - - UUID aaiNqUuid = UUID.randomUUID(); - - AaiNqQueryParameters aaiNqQueryParameters = new AaiNqQueryParameters(); - AaiNqNamedQuery aaiNqNamedQuery = new AaiNqNamedQuery(); - aaiNqNamedQuery.setNamedQueryUuid(aaiNqUuid); - aaiNqQueryParameters.setNamedQuery(aaiNqNamedQuery); - - AaiNqRequest aaiNqRequest = new AaiNqRequest(); - aaiNqRequest.setQueryParameters(aaiNqQueryParameters); - - when(restManagerMock.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Gale"), anyMap(), - anyString(), anyString())).thenReturn(httpResponseOk); - - AaiNqResponse aaiNqOkResponse = aaiManager.postQuery("http://somewhere.over.the.rainbow", "Dorothy", "Gale", - aaiNqRequest, aaiNqRequestUuid); - assertNotNull(aaiNqOkResponse); - - when(restManagerMock.post(isNull(), eq("Dorothy"), anyString(), anyMap(), anyString(), anyString())) - .thenReturn(null); - - AaiNqResponse aaiNqNullResponse = aaiManager.postQuery(null, "Dorothy", "Gale", null, aaiNqRequestUuid); - assertNull(aaiNqNullResponse); - - when(restManagerMock.post(startsWith("http://somewhere.over.the.rainbow"), eq("Witch"), eq("West"), anyMap(), - anyString(), anyString())).thenReturn(httpResponseErr0); - - AaiNqResponse aaiNqNotOkResponse0 = aaiManager.postQuery("http://somewhere.over.the.rainbow", "Witch", "West", - aaiNqRequest, aaiNqRequestUuid); - assertNull(aaiNqNotOkResponse0); - - when(restManagerMock.post(startsWith("http://somewhere.under.the.rainbow"), eq("Witch"), eq("West"), anyMap(), - anyString(), anyString())).thenReturn(httpResponseErr1); - - AaiNqResponse aaiNqNotOkResponse1 = aaiManager.postQuery("http://somewhere.under.the.rainbow", "Witch", "West", - aaiNqRequest, aaiNqRequestUuid); - assertNull(aaiNqNotOkResponse1); - } - - @Test - public void testAaiManagerQueryByVserverName() { - AaiManager aaiManager = new AaiManager(restManagerMock); - assertNotNull(aaiManager); - - UUID vserverNameRequestId = UUID.randomUUID(); - - when(restManagerMock.get(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Gale"), anyMap())) - .thenReturn(httpResponseOk); - - AaiGetVserverResponse vserverResponse = aaiManager.getQueryByVserverName("http://somewhere.over.the.rainbow", - "Dorothy", "Gale", vserverNameRequestId, "vserverName"); - assertNotNull(vserverResponse); - - AaiGetVserverResponse vserverNullResponse = - aaiManager.getQueryByVserverName(null, "Dorothy", "Gale", vserverNameRequestId, "vserverName"); - assertNull(vserverNullResponse); - - when(restManagerMock.get(startsWith("http://somewhere.under.the.rainbow"), eq("Witch"), eq("West"), anyMap())) - .thenReturn(httpResponseErr0); - - AaiGetVserverResponse vserverNotOkResponse0 = aaiManager.getQueryByVserverName( - "http://somewhere.under.the.rainbow", "Witch", "West", vserverNameRequestId, "vserverName"); - assertNull(vserverNotOkResponse0); - } - - @Test - public void testAaiManagerQueryByVnfId() { - AaiManager aaiManager = new AaiManager(restManagerMock); - assertNotNull(aaiManager); - - UUID vserverNameRequestId = UUID.randomUUID(); - - when(restManagerMock.get(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Gale"), anyMap())) - .thenReturn(httpResponseOk); - - AaiGetVnfResponse vnfResponse = aaiManager.getQueryByVnfId("http://somewhere.over.the.rainbow", "Dorothy", - "Gale", vserverNameRequestId, "vnfID"); - assertNotNull(vnfResponse); - } - - @Test - public void testAaiManagerQueryByVnfName() { - AaiManager aaiManager = new AaiManager(restManagerMock); - assertNotNull(aaiManager); - - UUID vserverNameRequestId = UUID.randomUUID(); - - when(restManagerMock.get(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Gale"), anyMap())) - .thenReturn(httpResponseOk); - - AaiGetVnfResponse vnfResponse = aaiManager.getQueryByVnfId("http://somewhere.over.the.rainbow", "Dorothy", - "Gale", vserverNameRequestId, "vnfName"); - assertNotNull(vnfResponse); - } -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqCloudRegionTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqCloudRegionTest.java deleted file mode 100644 index dea981a0a..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqCloudRegionTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -public class AaiNqCloudRegionTest { - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - AaiNqCloudRegion aaiNqCloudRegion = new AaiNqCloudRegion(); - aaiNqCloudRegion.setCloudOwner("Rackspace"); - aaiNqCloudRegion.setCloudRegionId("DFW"); - aaiNqCloudRegion.setCloudRegionVersion("v1"); - aaiNqCloudRegion.setComplexName("SharedNode"); - aaiNqCloudRegion.setResourceVersion("1504789196021"); - assertNotNull(aaiNqCloudRegion); - assertEquals("Rackspace", aaiNqCloudRegion.getCloudOwner()); - assertEquals("DFW", aaiNqCloudRegion.getCloudRegionId()); - assertEquals("v1", aaiNqCloudRegion.getCloudRegionVersion()); - assertEquals("SharedNode", aaiNqCloudRegion.getComplexName()); - assertEquals("1504789196021", aaiNqCloudRegion.getResourceVersion()); - } -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertiesTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertiesTest.java deleted file mode 100644 index adbd9379b..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertiesTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertNotNull; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -public class AaiNqExtraPropertiesTest { - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - AaiNqExtraProperties aaiNqExtraProperties = new AaiNqExtraProperties(); - aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty("model.model-name", "service-instance")); - aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); - aaiNqExtraProperties.getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); - aaiNqExtraProperties.getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); - assertNotNull(aaiNqExtraProperties); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertyTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertyTest.java deleted file mode 100644 index 25f125945..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqExtraPropertyTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -public class AaiNqExtraPropertyTest { - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - AaiNqExtraProperty aaiNqExtraProperty = new AaiNqExtraProperty(); - aaiNqExtraProperty.setPropertyName("model.model-name"); - aaiNqExtraProperty.setPropertyValue("service-instance"); - assertNotNull(aaiNqExtraProperty); - - assertEquals("model.model-name", aaiNqExtraProperty.getPropertyName()); - assertEquals("service-instance", aaiNqExtraProperty.getPropertyValue()); - } -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqGenericVnfTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqGenericVnfTest.java deleted file mode 100644 index 7a94dccf0..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqGenericVnfTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -public class AaiNqGenericVnfTest { - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - AaiNqGenericVnf aaiNqGenericVnf = new AaiNqGenericVnf(); - aaiNqGenericVnf.setEncrypedAccessFlag(true); - aaiNqGenericVnf.setInMaint(false); - aaiNqGenericVnf.setIpv4Loopback0Address("aa"); - aaiNqGenericVnf.setIpv4OamAddress("oamAddress"); - aaiNqGenericVnf.setIsClosedLoopDisabled(false); - aaiNqGenericVnf.setModelInvariantId("653d2caa-7e47-4614-95b3-26c8d82755b8"); - aaiNqGenericVnf.setModelVersionId("98f410f6-4c63-447b-97d2-42508437cec0"); - aaiNqGenericVnf.setModelCustomizationId("SomeCustomizationId"); - aaiNqGenericVnf.setOperationalState("active"); - aaiNqGenericVnf.setPersonaModelId("653d2caa-7e47-4614-95b3-26c8d82755b8"); - aaiNqGenericVnf.setPersonaModelVersion("98f410f6-4c63-447b-97d2-42508437cec0"); - aaiNqGenericVnf.setProvStatus("complete"); - aaiNqGenericVnf.setResourceVersion("1505056714553"); - aaiNqGenericVnf.setServiceId("e8cb8968-5411-478b-906a-f28747de72cd"); - aaiNqGenericVnf.setVnfId("ed8b2bce-6b27-4089-992c-4a2c66024bcd"); - aaiNqGenericVnf.setVnfName("vCPEInfraVNF14a"); - aaiNqGenericVnf.setVnfName2("malumabb12"); - aaiNqGenericVnf.setVnfType("vCPEInfraService10/vCPEInfraService10 0"); - assertNotNull(aaiNqGenericVnf); - - assertEquals(true, aaiNqGenericVnf.getEncrypedAccessFlag()); - assertEquals(false, aaiNqGenericVnf.getInMaint()); - assertEquals("aa", aaiNqGenericVnf.getIpv4Loopback0Address()); - assertEquals("oamAddress", aaiNqGenericVnf.getIpv4OamAddress()); - assertEquals(false, aaiNqGenericVnf.getIsClosedLoopDisabled()); - assertEquals("653d2caa-7e47-4614-95b3-26c8d82755b8", aaiNqGenericVnf.getModelInvariantId()); - assertEquals("98f410f6-4c63-447b-97d2-42508437cec0", aaiNqGenericVnf.getModelVersionId()); - assertEquals("SomeCustomizationId", aaiNqGenericVnf.getModelCustomizationId()); - assertEquals("active", aaiNqGenericVnf.getOperationalState()); - assertEquals("653d2caa-7e47-4614-95b3-26c8d82755b8", aaiNqGenericVnf.getPersonaModelId()); - assertEquals("98f410f6-4c63-447b-97d2-42508437cec0", aaiNqGenericVnf.getPersonaModelVersion()); - assertEquals("complete", aaiNqGenericVnf.getProvStatus()); - assertEquals("1505056714553", aaiNqGenericVnf.getResourceVersion()); - assertEquals("e8cb8968-5411-478b-906a-f28747de72cd", aaiNqGenericVnf.getServiceId()); - assertEquals("ed8b2bce-6b27-4089-992c-4a2c66024bcd", aaiNqGenericVnf.getVnfId()); - assertEquals("vCPEInfraVNF14a", aaiNqGenericVnf.getVnfName()); - assertEquals("malumabb12", aaiNqGenericVnf.getVnfName2()); - assertEquals("vCPEInfraService10/vCPEInfraService10 0", aaiNqGenericVnf.getVnfType()); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInstanceFiltersTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInstanceFiltersTest.java deleted file mode 100644 index 1508891b4..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInstanceFiltersTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017 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.aai; - -import static org.junit.Assert.assertNotNull; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -public class AaiNqInstanceFiltersTest { - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - AaiNqInstanceFilters aaiNqInstanceFilters = new AaiNqInstanceFilters(); - assertNotNull(aaiNqInstanceFilters); - - aaiNqInstanceFilters.setInstanceFilter(aaiNqInstanceFilters.getInstanceFilter());; - assertNotNull(aaiNqInstanceFilters); - assertNotNull(aaiNqInstanceFilters.getInstanceFilter()); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemTest.java deleted file mode 100644 index 8b5265a00..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemTest.java +++ /dev/null @@ -1,170 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertNotNull; - -import java.util.LinkedList; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqInventoryResponseItemTest { - private static final Logger logger = LoggerFactory.getLogger(AaiNqInventoryResponseItemTest.class); - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - AaiNqInventoryResponseItem aaiNqInventoryResponseItem = new AaiNqInventoryResponseItem(); - aaiNqInventoryResponseItem.setModelName("service-instance"); - AaiNqCloudRegion aaiNqCloudRegion = new AaiNqCloudRegion(); - aaiNqCloudRegion.setCloudOwner("OWNER"); - aaiNqCloudRegion.setCloudRegionId("REGIONID"); - aaiNqCloudRegion.setCloudRegionVersion("2.5"); - aaiNqCloudRegion.setComplexName("COMPLEXNAME"); - aaiNqCloudRegion.setResourceVersion("1485365988"); - aaiNqInventoryResponseItem.setCloudRegion(aaiNqCloudRegion); - AaiNqExtraProperties aaiNqExtraProperties = new AaiNqExtraProperties(); - aaiNqExtraProperties.setExtraProperty(new LinkedList<>()); - aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty("model.model-name", "generic-vnf")); - aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - aaiNqExtraProperties.getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); - aaiNqExtraProperties.getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); - aaiNqExtraProperties.getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); - aaiNqInventoryResponseItem.setExtraProperties(aaiNqExtraProperties); - AaiNqGenericVnf aaiNqGenericVnf = new AaiNqGenericVnf(); - aaiNqGenericVnf.setVnfId("dhv-test-gvnf"); - aaiNqGenericVnf.setVnfName("dhv-test-gvnf-name"); - aaiNqGenericVnf.setVnfName2("dhv-test-gvnf-name2"); - aaiNqGenericVnf.setVnfType("SW"); - aaiNqGenericVnf.setServiceId("d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4"); - aaiNqGenericVnf.setProvStatus("PREPROV"); - aaiNqGenericVnf.setOperationalState("dhv-test-operational-state"); - aaiNqGenericVnf.setIpv4OamAddress("dhv-test-gvnf-ipv4-oam-address"); - aaiNqGenericVnf.setIpv4Loopback0Address("dhv-test-gvnfipv4-loopback0-address"); - aaiNqGenericVnf.setInMaint(false); - aaiNqGenericVnf.setIsClosedLoopDisabled(false); - aaiNqGenericVnf.setResourceVersion("1485366450"); - aaiNqGenericVnf.setEncrypedAccessFlag(true); - aaiNqGenericVnf.setPersonaModelId("acc6edd8-a8d4-4b93-afaa-0994068be14c"); - aaiNqGenericVnf.setPersonaModelVersion("1.0"); - aaiNqInventoryResponseItem.setGenericVnf(aaiNqGenericVnf); - AaiNqInventoryResponseItem serviceItem = new AaiNqInventoryResponseItem(); - serviceItem.setModelName("service-instance"); - serviceItem.setServiceInstance(new AaiNqServiceInstance()); - serviceItem.getServiceInstance().setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); - serviceItem.getServiceInstance().setServiceInstanceName("dhv-test-service-instance-name1"); - serviceItem.getServiceInstance().setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); - serviceItem.getServiceInstance().setPersonaModelVersion("1.0"); - serviceItem.getServiceInstance().setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); - serviceItem.getServiceInstance().setResourceVersion("1485366092"); - serviceItem.setExtraProperties(new AaiNqExtraProperties()); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "service-instance")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); - - AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); - vfModuleItem.setModelName("vf-module"); - vfModuleItem.setVfModule(new AaiNqVfModule()); - vfModuleItem.getVfModule().setVfModuleId("example-vf-module-id-val-49261"); - vfModuleItem.getVfModule().setVfModuleName("example-vf-module-name-val-73074"); - vfModuleItem.getVfModule().setHeatStackId("example-heat-stack-id-val-86300"); - vfModuleItem.getVfModule().setOrchestrationStatus("example-orchestration-status-val-56523"); - vfModuleItem.getVfModule().setIsBaseVfModule(true); - vfModuleItem.getVfModule().setResourceVersion("1485366450"); - vfModuleItem.getVfModule().setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); - vfModuleItem.getVfModule().setPersonaModelVersion("1.0"); - vfModuleItem.getVfModule().setWidgetModelId("example-widget-model-id-val-92571"); - vfModuleItem.getVfModule().setWidgetModelVersion("example-widget-model-version-val-83317"); - vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); - vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "vf-module")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); - - AaiNqInventoryResponseItems aaiNqInventoryResponseItems = new AaiNqInventoryResponseItems(); - aaiNqInventoryResponseItems.getInventoryResponseItems().add(serviceItem); - aaiNqInventoryResponseItems.getInventoryResponseItems().add(vfModuleItem); - aaiNqInventoryResponseItem.setItems(aaiNqInventoryResponseItems); - aaiNqInventoryResponseItem.setModelName("model-name"); - AaiNqServiceInstance serviceInstance = new AaiNqServiceInstance(); - serviceInstance.setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); - serviceInstance.setServiceInstanceName("dhv-test-service-instance-name1"); - serviceInstance.setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); - serviceInstance.setPersonaModelVersion("1.0"); - serviceInstance.setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); - serviceInstance.setResourceVersion("1485366092"); - aaiNqInventoryResponseItem.setServiceInstance(serviceInstance); - AaiNqTenant aaiNqTenant = new AaiNqTenant(); - aaiNqTenant.setTenantId("dhv-test-tenant"); - aaiNqTenant.setTenantName("dhv-test-tenant-name"); - aaiNqTenant.setResourceVersion("1485366334"); - aaiNqInventoryResponseItem.setTenant(aaiNqTenant); - AaiNqVfModule aaiNqVfModule = new AaiNqVfModule(); - aaiNqVfModule.setVfModuleId("example-vf-module-id-val-49261"); - aaiNqVfModule.setVfModuleName("example-vf-module-name-val-73074"); - aaiNqVfModule.setHeatStackId("example-heat-stack-id-val-86300"); - aaiNqVfModule.setOrchestrationStatus("example-orchestration-status-val-56523"); - aaiNqVfModule.setIsBaseVfModule(true); - aaiNqVfModule.setResourceVersion("1485366450"); - aaiNqVfModule.setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); - aaiNqVfModule.setPersonaModelVersion("1.0"); - aaiNqVfModule.setWidgetModelId("example-widget-model-id-val-92571"); - aaiNqVfModule.setWidgetModelVersion("example-widget-model-version-val-83317"); - aaiNqVfModule.setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); - aaiNqInventoryResponseItem.setVfModule(aaiNqVfModule); - AaiNqVServer aaiNqVServer = new AaiNqVServer(); - aaiNqVServer.setVserverId("dhv-test-vserver"); - aaiNqVServer.setVserverName("dhv-test-vserver-name"); - aaiNqVServer.setVserverName2("dhv-test-vserver-name2"); - aaiNqVServer.setProvStatus("PREPROV"); - aaiNqVServer.setVserverSelflink("dhv-test-vserver-selflink"); - aaiNqVServer.setInMaint(false); - aaiNqVServer.setIsClosedLoopDisabled(false); - aaiNqVServer.setResourceVersion("1485366417"); - aaiNqInventoryResponseItem.setVserver(aaiNqVServer); - assertNotNull(aaiNqInventoryResponseItem); - - logger.info(Serialization.gsonPretty.toJson(aaiNqInventoryResponseItem)); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemsTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemsTest.java deleted file mode 100644 index 99c6e5e92..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqInventoryResponseItemsTest.java +++ /dev/null @@ -1,163 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.LinkedList; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqInventoryResponseItemsTest { - private static final Logger logger = LoggerFactory.getLogger(AaiNqInventoryResponseItemsTest.class); - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - AaiNqInventoryResponseItem serviceItem = new AaiNqInventoryResponseItem(); - serviceItem.setModelName("service-instance"); - assertEquals("service-instance", serviceItem.getModelName()); - - serviceItem.setServiceInstance(new AaiNqServiceInstance()); - serviceItem.getServiceInstance().setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); - serviceItem.getServiceInstance().setServiceInstanceName("dhv-test-service-instance-name1"); - serviceItem.getServiceInstance().setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); - serviceItem.getServiceInstance().setPersonaModelVersion("1.0"); - serviceItem.getServiceInstance().setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); - serviceItem.getServiceInstance().setResourceVersion("1485366092"); - serviceItem.setExtraProperties(new AaiNqExtraProperties()); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "service-instance")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); - - AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); - vfModuleItem.setModelName("vf-module"); - vfModuleItem.setVfModule(new AaiNqVfModule()); - vfModuleItem.getVfModule().setVfModuleId("example-vf-module-id-val-49261"); - vfModuleItem.getVfModule().setVfModuleName("example-vf-module-name-val-73074"); - vfModuleItem.getVfModule().setHeatStackId("example-heat-stack-id-val-86300"); - vfModuleItem.getVfModule().setOrchestrationStatus("example-orchestration-status-val-56523"); - vfModuleItem.getVfModule().setIsBaseVfModule(true); - vfModuleItem.getVfModule().setResourceVersion("1485366450"); - vfModuleItem.getVfModule().setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); - vfModuleItem.getVfModule().setPersonaModelVersion("1.0"); - vfModuleItem.getVfModule().setWidgetModelId("example-widget-model-id-val-92571"); - vfModuleItem.getVfModule().setWidgetModelVersion("example-widget-model-version-val-83317"); - vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); - vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "vf-module")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); - - AaiNqInventoryResponseItem genericVnfItem = new AaiNqInventoryResponseItem(); - genericVnfItem.setModelName("generic-vnf"); - genericVnfItem.setGenericVnf(new AaiNqGenericVnf()); - genericVnfItem.getGenericVnf().setVnfId("dhv-test-gvnf"); - genericVnfItem.getGenericVnf().setVnfName("dhv-test-gvnf-name"); - genericVnfItem.getGenericVnf().setVnfName2("dhv-test-gvnf-name2"); - genericVnfItem.getGenericVnf().setVnfType("SW"); - genericVnfItem.getGenericVnf().setServiceId("d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4"); - genericVnfItem.getGenericVnf().setProvStatus("PREPROV"); - genericVnfItem.getGenericVnf().setOperationalState("dhv-test-operational-state"); - genericVnfItem.getGenericVnf().setIpv4OamAddress("dhv-test-gvnf-ipv4-oam-address"); - genericVnfItem.getGenericVnf().setIpv4Loopback0Address("dhv-test-gvnfipv4-loopback0-address"); - genericVnfItem.getGenericVnf().setInMaint(false); - genericVnfItem.getGenericVnf().setIsClosedLoopDisabled(false); - genericVnfItem.getGenericVnf().setResourceVersion("1485366450"); - genericVnfItem.getGenericVnf().setEncrypedAccessFlag(true); - genericVnfItem.getGenericVnf().setPersonaModelId("acc6edd8-a8d4-4b93-afaa-0994068be14c"); - genericVnfItem.getGenericVnf().setPersonaModelVersion("1.0"); - genericVnfItem.setExtraProperties(new AaiNqExtraProperties()); - genericVnfItem.getExtraProperties().setExtraProperty(new LinkedList<>()); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "generic-vnf")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-type", "widget")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-version", "1.0")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); - genericVnfItem.setItems(new AaiNqInventoryResponseItems()); - genericVnfItem.getItems().setInventoryResponseItems(new LinkedList<>()); - genericVnfItem.getItems().getInventoryResponseItems().add(serviceItem); - genericVnfItem.getItems().getInventoryResponseItems().add(vfModuleItem); - - AaiNqInventoryResponseItem cloudItem = new AaiNqInventoryResponseItem(); - cloudItem.setCloudRegion(new AaiNqCloudRegion()); - cloudItem.getCloudRegion().setCloudOwner("OWNER"); - cloudItem.getCloudRegion().setCloudRegionId("REGIONID"); - cloudItem.getCloudRegion().setCloudRegionVersion("2.5"); - cloudItem.getCloudRegion().setComplexName("COMPLEXNAME"); - cloudItem.getCloudRegion().setResourceVersion("1485365988"); - - AaiNqInventoryResponseItem tenantItem = new AaiNqInventoryResponseItem(); - tenantItem.setTenant(new AaiNqTenant()); - tenantItem.getTenant().setTenantId("dhv-test-tenant"); - tenantItem.getTenant().setTenantName("dhv-test-tenant-name"); - tenantItem.getTenant().setResourceVersion("1485366334"); - tenantItem.setItems(new AaiNqInventoryResponseItems()); - tenantItem.getItems().setInventoryResponseItems(new LinkedList<>()); - tenantItem.getItems().getInventoryResponseItems().add(cloudItem); - AaiNqInventoryResponseItem vserverItem = new AaiNqInventoryResponseItem(); - vserverItem.setVserver(new AaiNqVServer()); - vserverItem.getVserver().setVserverId("dhv-test-vserver"); - vserverItem.getVserver().setVserverName("dhv-test-vserver-name"); - vserverItem.getVserver().setVserverName2("dhv-test-vserver-name2"); - vserverItem.getVserver().setProvStatus("PREPROV"); - vserverItem.getVserver().setVserverSelflink("dhv-test-vserver-selflink"); - vserverItem.getVserver().setInMaint(false); - vserverItem.getVserver().setIsClosedLoopDisabled(false); - vserverItem.getVserver().setResourceVersion("1485366417"); - vserverItem.setItems(new AaiNqInventoryResponseItems()); - vserverItem.getItems().setInventoryResponseItems(new LinkedList<>()); - vserverItem.getItems().getInventoryResponseItems().add(genericVnfItem); - vserverItem.getItems().getInventoryResponseItems().add(tenantItem); - - AaiNqInventoryResponseItems aaiNqInventoryResponseItems = new AaiNqInventoryResponseItems(); - aaiNqInventoryResponseItems.getInventoryResponseItems().add(vserverItem); - assertNotNull(aaiNqInventoryResponseItems); - logger.info(Serialization.gsonPretty.toJson(aaiNqInventoryResponseItems)); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqNamedQueryTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqNamedQueryTest.java deleted file mode 100644 index 2e65a843d..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqNamedQueryTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -public class AaiNqNamedQueryTest { - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - AaiNqNamedQuery aaiNqNamedQuery = new AaiNqNamedQuery(); - UUID uuid = UUID.randomUUID(); - aaiNqNamedQuery.setNamedQueryUuid(uuid); - assertNotNull(aaiNqNamedQuery); - assertEquals(aaiNqNamedQuery.getNamedQueryUuid(), uuid); - } -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqQueryParametersTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqQueryParametersTest.java deleted file mode 100644 index 1f0a8354a..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqQueryParametersTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -public class AaiNqQueryParametersTest { - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - AaiNqQueryParameters aaiNqQueryParameters = new AaiNqQueryParameters(); - AaiNqNamedQuery aaiNqNamedQuery = new AaiNqNamedQuery(); - aaiNqNamedQuery.setNamedQueryUuid(UUID.randomUUID()); - aaiNqQueryParameters.setNamedQuery(aaiNqNamedQuery); - assertNotNull(aaiNqNamedQuery); - assertEquals(aaiNqQueryParameters.getNamedQuery(), aaiNqNamedQuery); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestErrorTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestErrorTest.java deleted file mode 100644 index e943c0c01..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestErrorTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -public class AaiNqRequestErrorTest { - - @Test - public void test() { - AaiNqRequestError aainqRequestError = new AaiNqRequestError(); - AaiNqServiceExcept serviceExcept = new AaiNqServiceExcept(); - aainqRequestError.setServiceExcept(serviceExcept); - assertEquals(aainqRequestError.getServiceExcept(), serviceExcept); - - assertNull(serviceExcept.getMessageId()); - assertNull(serviceExcept.getText()); - assertNull(serviceExcept.getVariables()); - } -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestTest.java deleted file mode 100644 index 1ac5e457b..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqRequestTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqRequestTest { - private static final Logger logger = LoggerFactory.getLogger(AaiNqRequestTest.class); - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - AaiNqRequest aaiNqRequest = new AaiNqRequest(); - AaiNqInstanceFilters aaiNqInstanceFilters = new AaiNqInstanceFilters(); - - aaiNqRequest.setInstanceFilters(aaiNqInstanceFilters); - assertNotNull(aaiNqRequest.getInstanceFilters()); - AaiNqNamedQuery aaiNqNamedQuery = new AaiNqNamedQuery(); - UUID uuid = UUID.randomUUID(); - aaiNqNamedQuery.setNamedQueryUuid(uuid); - - AaiNqQueryParameters aaiNqQueryParameters = new AaiNqQueryParameters(); - aaiNqQueryParameters.setNamedQuery(aaiNqNamedQuery); - aaiNqRequest.setQueryParameters(aaiNqQueryParameters); - - assertNotNull(aaiNqRequest); - - assertEquals(aaiNqNamedQuery.getNamedQueryUuid(), uuid); - assertEquals(aaiNqQueryParameters.getNamedQuery(), aaiNqNamedQuery); - assertEquals(aaiNqRequest.getQueryParameters(), aaiNqQueryParameters); - - logger.info(Serialization.gsonPretty.toJson(aaiNqRequest)); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseTest.java deleted file mode 100644 index c715a22c2..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import java.util.LinkedList; - -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqResponseTest { - private static final Logger logger = LoggerFactory.getLogger(AaiNqResponseTest.class); - - @Test - public void test() { - getAaiNqResponse(); - } - - /** - * Get A&AI NQ response. - * - * @return the A&AI NG response - */ - public AaiNqResponse getAaiNqResponse() { - AaiNqInventoryResponseItem serviceItem = new AaiNqInventoryResponseItem(); - serviceItem.setModelName("service-instance"); - serviceItem.setServiceInstance(new AaiNqServiceInstance()); - serviceItem.getServiceInstance().setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); - serviceItem.getServiceInstance().setServiceInstanceName("dhv-test-service-instance-name1"); - serviceItem.getServiceInstance().setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); - serviceItem.getServiceInstance().setPersonaModelVersion("1.0"); - serviceItem.getServiceInstance().setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); - serviceItem.getServiceInstance().setResourceVersion("1485366092"); - serviceItem.setExtraProperties(new AaiNqExtraProperties()); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "service-instance")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); - - AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); - vfModuleItem.setModelName("vf-module"); - vfModuleItem.setVfModule(new AaiNqVfModule()); - vfModuleItem.getVfModule().setVfModuleId("example-vf-module-id-val-49261"); - vfModuleItem.getVfModule().setVfModuleName("example-vf-module-name-val-73074"); - vfModuleItem.getVfModule().setHeatStackId("example-heat-stack-id-val-86300"); - vfModuleItem.getVfModule().setOrchestrationStatus("example-orchestration-status-val-56523"); - vfModuleItem.getVfModule().setIsBaseVfModule(true); - vfModuleItem.getVfModule().setResourceVersion("1485366450"); - vfModuleItem.getVfModule().setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); - vfModuleItem.getVfModule().setPersonaModelVersion("1.0"); - vfModuleItem.getVfModule().setWidgetModelId("example-widget-model-id-val-92571"); - vfModuleItem.getVfModule().setWidgetModelVersion("example-widget-model-version-val-83317"); - vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); - vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "vf-module")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); - - AaiNqInventoryResponseItem genericVnfItem = new AaiNqInventoryResponseItem(); - genericVnfItem.setModelName("generic-vnf"); - genericVnfItem.setGenericVnf(new AaiNqGenericVnf()); - genericVnfItem.getGenericVnf().setVnfId("dhv-test-gvnf"); - genericVnfItem.getGenericVnf().setVnfName("dhv-test-gvnf-name"); - genericVnfItem.getGenericVnf().setVnfName2("dhv-test-gvnf-name2"); - genericVnfItem.getGenericVnf().setVnfType("SW"); - genericVnfItem.getGenericVnf().setServiceId("d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4"); - genericVnfItem.getGenericVnf().setProvStatus("PREPROV"); - genericVnfItem.getGenericVnf().setOperationalState("dhv-test-operational-state"); - genericVnfItem.getGenericVnf().setIpv4OamAddress("dhv-test-gvnf-ipv4-oam-address"); - genericVnfItem.getGenericVnf().setIpv4Loopback0Address("dhv-test-gvnfipv4-loopback0-address"); - genericVnfItem.getGenericVnf().setInMaint(false); - genericVnfItem.getGenericVnf().setIsClosedLoopDisabled(false); - genericVnfItem.getGenericVnf().setResourceVersion("1485366450"); - genericVnfItem.getGenericVnf().setEncrypedAccessFlag(true); - genericVnfItem.getGenericVnf().setPersonaModelId("acc6edd8-a8d4-4b93-afaa-0994068be14c"); - genericVnfItem.getGenericVnf().setPersonaModelVersion("1.0"); - genericVnfItem.setExtraProperties(new AaiNqExtraProperties()); - genericVnfItem.getExtraProperties().setExtraProperty(new LinkedList<>()); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "generic-vnf")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-type", "widget")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-version", "1.0")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); - genericVnfItem.setItems(new AaiNqInventoryResponseItems()); - genericVnfItem.getItems().setInventoryResponseItems(new LinkedList<>()); - genericVnfItem.getItems().getInventoryResponseItems().add(serviceItem); - genericVnfItem.getItems().getInventoryResponseItems().add(vfModuleItem); - - AaiNqInventoryResponseItem cloudItem = new AaiNqInventoryResponseItem(); - cloudItem.setCloudRegion(new AaiNqCloudRegion()); - cloudItem.getCloudRegion().setCloudOwner("OWNER"); - cloudItem.getCloudRegion().setCloudRegionId("REGIONID"); - cloudItem.getCloudRegion().setCloudRegionVersion("2.5"); - cloudItem.getCloudRegion().setComplexName("COMPLEXNAME"); - cloudItem.getCloudRegion().setResourceVersion("1485365988"); - - AaiNqInventoryResponseItem tenantItem = new AaiNqInventoryResponseItem(); - tenantItem.setTenant(new AaiNqTenant()); - tenantItem.getTenant().setTenantId("dhv-test-tenant"); - tenantItem.getTenant().setTenantName("dhv-test-tenant-name"); - tenantItem.getTenant().setResourceVersion("1485366334"); - tenantItem.setItems(new AaiNqInventoryResponseItems()); - tenantItem.getItems().setInventoryResponseItems(new LinkedList<>()); - tenantItem.getItems().getInventoryResponseItems().add(cloudItem); - - AaiNqInventoryResponseItem vserverItem = new AaiNqInventoryResponseItem(); - vserverItem.setVserver(new AaiNqVServer()); - vserverItem.getVserver().setVserverId("dhv-test-vserver"); - vserverItem.getVserver().setVserverName("dhv-test-vserver-name"); - vserverItem.getVserver().setVserverName2("dhv-test-vserver-name2"); - vserverItem.getVserver().setProvStatus("PREPROV"); - vserverItem.getVserver().setVserverSelflink("dhv-test-vserver-selflink"); - vserverItem.getVserver().setInMaint(false); - vserverItem.getVserver().setIsClosedLoopDisabled(false); - vserverItem.getVserver().setResourceVersion("1485366417"); - vserverItem.setItems(new AaiNqInventoryResponseItems()); - vserverItem.getItems().setInventoryResponseItems(new LinkedList<>()); - vserverItem.getItems().getInventoryResponseItems().add(genericVnfItem); - vserverItem.getItems().getInventoryResponseItems().add(tenantItem); - - AaiNqResponse aaiResponse = new AaiNqResponse(); - aaiResponse.getInventoryResponseItems().add(vserverItem); - logger.info(Serialization.gsonPretty.toJson(aaiResponse)); - - return aaiResponse; - } -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java deleted file mode 100644 index d1e8e964e..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqResponseWrapperTest.java +++ /dev/null @@ -1,261 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.LinkedList; -import java.util.List; -import java.util.UUID; -import org.apache.commons.io.IOUtils; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqResponseWrapperTest { - private static final Logger logger = LoggerFactory.getLogger(AaiNqResponseWrapperTest.class); - - @Test - public void test() { - AaiNqInventoryResponseItem serviceItem = new AaiNqInventoryResponseItem(); - serviceItem.setModelName("service-instance"); - serviceItem.setServiceInstance(new AaiNqServiceInstance()); - serviceItem.getServiceInstance().setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); - serviceItem.getServiceInstance().setServiceInstanceName("dhv-test-service-instance-name1"); - serviceItem.getServiceInstance().setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); - serviceItem.getServiceInstance().setPersonaModelVersion("1.0"); - serviceItem.getServiceInstance().setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); - serviceItem.getServiceInstance().setResourceVersion("1485366092"); - serviceItem.setExtraProperties(new AaiNqExtraProperties()); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "service-instance")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - serviceItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "82194af1-3c2c-485a-8f44-420e22a9eaa4")); - serviceItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "46b92144-923a-4d20-b85a-3cbd847668a9")); - - AaiNqInventoryResponseItem vfModuleItem = new AaiNqInventoryResponseItem(); - vfModuleItem.setModelName("vf-module"); - vfModuleItem.setVfModule(new AaiNqVfModule()); - vfModuleItem.getVfModule().setVfModuleId("example-vf-module-id-val-49261"); - vfModuleItem.getVfModule().setVfModuleName("example-vf-module-name-val-73074"); - vfModuleItem.getVfModule().setHeatStackId("example-heat-stack-id-val-86300"); - vfModuleItem.getVfModule().setOrchestrationStatus("example-orchestration-status-val-56523"); - vfModuleItem.getVfModule().setIsBaseVfModule(true); - vfModuleItem.getVfModule().setResourceVersion("1485366450"); - vfModuleItem.getVfModule().setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); - vfModuleItem.getVfModule().setPersonaModelVersion("1.0"); - vfModuleItem.getVfModule().setWidgetModelId("example-widget-model-id-val-92571"); - vfModuleItem.getVfModule().setWidgetModelVersion("example-widget-model-version-val-83317"); - vfModuleItem.getVfModule().setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); - vfModuleItem.setExtraProperties(new AaiNqExtraProperties()); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "vf-module")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-type", "widget")); - vfModuleItem.getExtraProperties().getExtraProperty().add(new AaiNqExtraProperty("model.model-version", "1.0")); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "ef86f9c5-2165-44f3-8fc3-96018b609ea5")); - vfModuleItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "c00563ae-812b-4e62-8330-7c4d0f47088a")); - - AaiNqInventoryResponseItem genericVnfItem = new AaiNqInventoryResponseItem(); - genericVnfItem.setModelName("generic-vnf"); - genericVnfItem.setGenericVnf(new AaiNqGenericVnf()); - genericVnfItem.getGenericVnf().setVnfId("dhv-test-gvnf"); - genericVnfItem.getGenericVnf().setVnfName("dhv-test-gvnf-name"); - genericVnfItem.getGenericVnf().setVnfName2("dhv-test-gvnf-name2"); - genericVnfItem.getGenericVnf().setVnfType("SW"); - genericVnfItem.getGenericVnf().setServiceId("d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4"); - genericVnfItem.getGenericVnf().setProvStatus("PREPROV"); - genericVnfItem.getGenericVnf().setOperationalState("dhv-test-operational-state"); - genericVnfItem.getGenericVnf().setIpv4OamAddress("dhv-test-gvnf-ipv4-oam-address"); - genericVnfItem.getGenericVnf().setIpv4Loopback0Address("dhv-test-gvnfipv4-loopback0-address"); - genericVnfItem.getGenericVnf().setInMaint(false); - genericVnfItem.getGenericVnf().setIsClosedLoopDisabled(false); - genericVnfItem.getGenericVnf().setResourceVersion("1485366450"); - genericVnfItem.getGenericVnf().setEncrypedAccessFlag(true); - genericVnfItem.getGenericVnf().setPersonaModelId("acc6edd8-a8d4-4b93-afaa-0994068be14c"); - genericVnfItem.getGenericVnf().setPersonaModelVersion("1.0"); - genericVnfItem.setExtraProperties(new AaiNqExtraProperties()); - genericVnfItem.getExtraProperties().setExtraProperty(new LinkedList<>()); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name", "generic-vnf")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-type", "widget")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-version", "1.0")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-id", "acc6edd8-a8d4-4b93-afaa-0994068be14c")); - genericVnfItem.getExtraProperties().getExtraProperty() - .add(new AaiNqExtraProperty("model.model-name-version-id", "93a6166f-b3d5-4f06-b4ba-aed48d009ad9")); - genericVnfItem.setItems(new AaiNqInventoryResponseItems()); - genericVnfItem.getItems().setInventoryResponseItems(new LinkedList<>()); - genericVnfItem.getItems().getInventoryResponseItems().add(serviceItem); - genericVnfItem.getItems().getInventoryResponseItems().add(vfModuleItem); - - AaiNqInventoryResponseItem cloudItem = new AaiNqInventoryResponseItem(); - cloudItem.setCloudRegion(new AaiNqCloudRegion()); - cloudItem.getCloudRegion().setCloudOwner("OWNER"); - cloudItem.getCloudRegion().setCloudRegionId("REGIONID"); - cloudItem.getCloudRegion().setCloudRegionVersion("2.5"); - cloudItem.getCloudRegion().setComplexName("COMPLEXNAME"); - cloudItem.getCloudRegion().setResourceVersion("1485365988"); - - AaiNqInventoryResponseItem tenantItem = new AaiNqInventoryResponseItem(); - tenantItem.setTenant(new AaiNqTenant()); - tenantItem.getTenant().setTenantId("dhv-test-tenant"); - tenantItem.getTenant().setTenantName("dhv-test-tenant-name"); - tenantItem.getTenant().setResourceVersion("1485366334"); - tenantItem.setItems(new AaiNqInventoryResponseItems()); - tenantItem.getItems().setInventoryResponseItems(new LinkedList<>()); - tenantItem.getItems().getInventoryResponseItems().add(cloudItem); - - AaiNqInventoryResponseItem vserverItem = new AaiNqInventoryResponseItem(); - vserverItem.setVserver(new AaiNqVServer()); - vserverItem.getVserver().setVserverId("dhv-test-vserver"); - vserverItem.getVserver().setVserverName("dhv-test-vserver-name"); - vserverItem.getVserver().setVserverName2("dhv-test-vserver-name2"); - vserverItem.getVserver().setProvStatus("PREPROV"); - vserverItem.getVserver().setVserverSelflink("dhv-test-vserver-selflink"); - vserverItem.getVserver().setInMaint(false); - vserverItem.getVserver().setIsClosedLoopDisabled(false); - vserverItem.getVserver().setResourceVersion("1485366417"); - vserverItem.setItems(new AaiNqInventoryResponseItems()); - vserverItem.getItems().setInventoryResponseItems(new LinkedList<>()); - vserverItem.getItems().getInventoryResponseItems().add(genericVnfItem); - vserverItem.getItems().getInventoryResponseItems().add(tenantItem); - - AaiNqResponse aaiResponse = new AaiNqResponse(); - aaiResponse.getInventoryResponseItems().add(vserverItem); - AaiNqResponseWrapper aaiNqResponseWarapper = new AaiNqResponseWrapper(); - aaiNqResponseWarapper.setAaiNqResponse(aaiResponse); - aaiNqResponseWarapper.setRequestId(UUID.randomUUID()); - assertNotNull(aaiNqResponseWarapper); - logger.info(Serialization.gsonPretty.toJson(aaiNqResponseWarapper)); - - AaiNqResponse aaiResponse2 = new AaiNqResponse(); - aaiResponse2.getInventoryResponseItems().add(vserverItem); - AaiNqResponseWrapper aaiNqResponseWarapper2 = new AaiNqResponseWrapper(UUID.randomUUID(), aaiResponse); - assertNotNull(aaiNqResponseWarapper2); - assertNotNull(aaiNqResponseWarapper2.getRequestId()); - assertNotNull(aaiNqResponseWarapper2.getAaiNqResponse()); - logger.info(Serialization.gsonPretty.toJson(aaiNqResponseWarapper2)); - } - - @Test - public void testCountVfModules() throws Exception { - AaiNqResponseWrapper resp; - - // null item - resp = new AaiNqResponseWrapper(); - assertEquals(0, resp.countVfModules()); - - // no names - resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoNames.json")); - assertEquals(0, resp.countVfModules()); - - // has VF modules - resp.setAaiNqResponse(load("AaiNqResponseWrapper-Vserver.json")); - assertEquals(3, resp.countVfModules()); - } - - @Test - public void testGenVfModuleName() throws Exception { - AaiNqResponseWrapper resp; - - // null item - resp = new AaiNqResponseWrapper(); - assertEquals(null, resp.genVfModuleName()); - - // no names - resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoNames.json")); - assertEquals(null, resp.genVfModuleName()); - - // has VF modules - resp.setAaiNqResponse(load("AaiNqResponseWrapper-Vserver.json")); - assertEquals("my-module-abc_124", resp.genVfModuleName()); - } - - @Test - public void testGetVfModules() throws Exception { - AaiNqResponseWrapper resp; - - // null item - resp = new AaiNqResponseWrapper(); - assertTrue(resp.getVfModuleItems(true).isEmpty()); - - // missing item - resp = new AaiNqResponseWrapper(); - resp.setAaiNqResponse(new AaiNqResponse()); - assertTrue(resp.getVfModuleItems(false).isEmpty()); - - // null item list - resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoItems.json")); - resp.getAaiNqResponse().getInventoryResponseItems().get(0).getItems().getInventoryResponseItems().get(0) - .getItems().setInventoryResponseItems(null); - assertTrue(resp.getVfModuleItems(false).isEmpty()); - - // no modules - resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoModules.json")); - assertTrue(resp.getVfModuleItems(false).isEmpty()); - - // no names - resp.setAaiNqResponse(load("AaiNqResponseWrapper-NoNames.json")); - List<AaiNqInventoryResponseItem> lst; - lst = resp.getVfModuleItems(false); - assertEquals(0, lst.size()); - - // base VF modules - resp.setAaiNqResponse(load("AaiNqResponseWrapper-Vserver.json")); - lst = resp.getVfModuleItems(true); - assertEquals(1, lst.size()); - assertEquals("Vfmodule_vLBMS-0809-1", lst.get(0).getVfModule().getVfModuleName()); - - // non base VF modules - resp.setAaiNqResponse(load("AaiNqResponseWrapper-Vserver.json")); - lst = resp.getVfModuleItems(false); - assertEquals(3, lst.size()); - int index; - index = 0; - assertEquals("my-module-abc_1", lst.get(index++).getVfModule().getVfModuleName()); - assertEquals("my-module-abc_123", lst.get(index++).getVfModule().getVfModuleName()); - assertEquals("my-module-abc_34", lst.get(index++).getVfModule().getVfModuleName()); - } - - /** - * Loads a response from a JSON file. - * - * @param fileName name of the file containing the JSON response - * @return the response - * @throws IOException if the file cannot be read - */ - private AaiNqResponse load(String fileName) throws IOException { - String json = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8); - return Serialization.gsonPretty.fromJson(json, AaiNqResponse.class); - } -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqServiceInstanceTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqServiceInstanceTest.java deleted file mode 100644 index add616dce..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqServiceInstanceTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqServiceInstanceTest { - private static final Logger logger = LoggerFactory.getLogger(AaiNqServiceInstanceTest.class); - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - AaiNqServiceInstance aaiNqServiceInstance = new AaiNqServiceInstance(); - aaiNqServiceInstance.setServiceInstanceId("dhv-test-vhnfportal-service-instance-id"); - aaiNqServiceInstance.setServiceInstanceName("dhv-test-service-instance-name1"); - aaiNqServiceInstance.setPersonaModelId("82194af1-3c2c-485a-8f44-420e22a9eaa4"); - aaiNqServiceInstance.setPersonaModelVersion("1.0"); - aaiNqServiceInstance.setServiceInstanceLocationId("dhv-test-service-instance-location-id1"); - aaiNqServiceInstance.setResourceVersion("1485366092"); - aaiNqServiceInstance.setModelInvariantId("SomeID"); - aaiNqServiceInstance.setModelVersionId("SomeVersion"); - assertNotNull(aaiNqServiceInstance); - assertEquals("dhv-test-vhnfportal-service-instance-id", aaiNqServiceInstance.getServiceInstanceId()); - assertEquals("dhv-test-service-instance-name1", aaiNqServiceInstance.getServiceInstanceName()); - assertEquals("82194af1-3c2c-485a-8f44-420e22a9eaa4", aaiNqServiceInstance.getPersonaModelId()); - assertEquals("1.0", aaiNqServiceInstance.getPersonaModelVersion()); - assertEquals("dhv-test-service-instance-location-id1", aaiNqServiceInstance.getServiceInstanceLocationId()); - assertEquals("1485366092", aaiNqServiceInstance.getResourceVersion()); - assertEquals("SomeID", aaiNqServiceInstance.getModelInvariantId()); - assertEquals("SomeVersion", aaiNqServiceInstance.getModelVersionId()); - logger.info(Serialization.gsonPretty.toJson(aaiNqServiceInstance)); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqTenantTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqTenantTest.java deleted file mode 100644 index c1755f9cb..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqTenantTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqTenantTest { - private static final Logger logger = LoggerFactory.getLogger(AaiNqTenantTest.class); - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - AaiNqTenant aaiNqTenant = new AaiNqTenant(); - aaiNqTenant.setTenantId("dhv-test-tenant"); - aaiNqTenant.setTenantName("dhv-test-tenant-name"); - aaiNqTenant.setResourceVersion("1485366334"); - assertNotNull(aaiNqTenant); - assertEquals("dhv-test-tenant", aaiNqTenant.getTenantId()); - assertEquals("dhv-test-tenant-name", aaiNqTenant.getTenantName()); - assertEquals("1485366334", aaiNqTenant.getResourceVersion()); - - logger.info(Serialization.gsonPretty.toJson(aaiNqTenant)); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java deleted file mode 100644 index bdda679d5..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVServerTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.File; -import java.nio.file.Files; -import java.util.List; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqVServerTest { - private static final Logger logger = LoggerFactory.getLogger(AaiNqVServerTest.class); - - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files - .readAllBytes(new File("src/test/resources/org/onap/policy/aai/AaiNqVServer.json").toPath())); - - AaiNqVServer resp = Serialization.gsonPretty.fromJson(json, AaiNqVServer.class); - - assertEquals(false, resp.getInMaint()); - assertEquals(true, resp.getIsClosedLoopDisabled()); - assertEquals("ACTIVE", resp.getProvStatus()); - assertEquals("1533850964910", resp.getResourceVersion()); - assertEquals("1c94da3f-16f1-4fc7-9ed1-e018dfa62774", resp.getVserverId()); - assertEquals("vlb-ms-0809-1", resp.getVserverName()); - assertEquals("vlb-ms-0809-7", resp.getVserverName2()); - assertEquals("http://localhost:8774/v2.1/4086f396c5e04caf9502c5fdeca575c4/servers/1c94da3f-16f1-4fc7-9ed1-e018dfa62774", - resp.getVserverSelflink()); - - // don't need to verify this in depth, as it has its own tests that do that - RelationshipList relationshipList = resp.getRelationshipList(); - assertNotNull(relationshipList); - - List<Relationship> lst = relationshipList.getRelationships(); - assertNotNull(lst); - - assertEquals(3, lst.size()); - assertEquals("generic-vnf", lst.get(0).getRelatedTo()); - assertEquals("image", lst.get(1).getRelatedTo()); - - logger.info(Serialization.gsonPretty.toJson(resp)); - - // verify that setXxx methods work - relationshipList = new RelationshipList(); - - resp.setInMaint(true); - resp.setIsClosedLoopDisabled(false); - resp.setProvStatus("inactive"); - resp.setRelationshipList(relationshipList); - resp.setResourceVersion("vers"); - resp.setVserverId("vid"); - resp.setVserverName("vname"); - resp.setVserverName2("vname2"); - resp.setVserverSelflink("link"); - - assertEquals(true, resp.getInMaint()); - assertEquals(false, resp.getIsClosedLoopDisabled()); - assertEquals("inactive", resp.getProvStatus()); - assertEquals("vers", resp.getResourceVersion()); - assertEquals("vid", resp.getVserverId()); - assertEquals("vname", resp.getVserverName()); - assertEquals("vname2", resp.getVserverName2()); - assertEquals("link", resp.getVserverSelflink()); - assertEquals(relationshipList, resp.getRelationshipList()); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVfModuleTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVfModuleTest.java deleted file mode 100644 index b82f2b377..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVfModuleTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AaiNqVfModuleTest { - private static final Logger logger = LoggerFactory.getLogger(AaiNqVfModuleTest.class); - - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - AaiNqVfModule aaiNqVfModule = new AaiNqVfModule(); - aaiNqVfModule.setVfModuleId("example-vf-module-id-val-49261"); - aaiNqVfModule.setVfModuleName("example-vf-module-name-val-73074"); - aaiNqVfModule.setHeatStackId("example-heat-stack-id-val-86300"); - aaiNqVfModule.setOrchestrationStatus("example-orchestration-status-val-56523"); - aaiNqVfModule.setIsBaseVfModule(true); - aaiNqVfModule.setResourceVersion("1485366450"); - aaiNqVfModule.setPersonaModelId("ef86f9c5-2165-44f3-8fc3-96018b609ea5"); - aaiNqVfModule.setPersonaModelVersion("1.0"); - aaiNqVfModule.setWidgetModelId("example-widget-model-id-val-92571"); - aaiNqVfModule.setWidgetModelVersion("example-widget-model-version-val-83317"); - aaiNqVfModule.setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796"); - aaiNqVfModule.setModelInvariantId("SomeId"); - aaiNqVfModule.setModelVersionId("SomeVersion"); - aaiNqVfModule.setModelCustomizationId("SomeCustomizationId"); - assertNotNull(aaiNqVfModule); - assertEquals("example-vf-module-id-val-49261", aaiNqVfModule.getVfModuleId()); - assertEquals("example-vf-module-name-val-73074", aaiNqVfModule.getVfModuleName()); - assertEquals("example-heat-stack-id-val-86300", aaiNqVfModule.getHeatStackId()); - assertEquals("example-orchestration-status-val-56523", aaiNqVfModule.getOrchestrationStatus()); - assertEquals(true, aaiNqVfModule.getIsBaseVfModule()); - assertEquals("1485366450", aaiNqVfModule.getResourceVersion()); - assertEquals("ef86f9c5-2165-44f3-8fc3-96018b609ea5", aaiNqVfModule.getPersonaModelId()); - assertEquals("1.0", aaiNqVfModule.getPersonaModelVersion()); - assertEquals("example-widget-model-id-val-92571", aaiNqVfModule.getWidgetModelId()); - assertEquals("example-widget-model-version-val-83317", aaiNqVfModule.getWidgetModelVersion()); - assertEquals("example-contrail-service-instance-fqdn-val-86796", - aaiNqVfModule.getContrailServiceInstanceFqdn()); - assertEquals("SomeId", aaiNqVfModule.getModelInvariantId()); - assertEquals("SomeVersion", aaiNqVfModule.getModelVersionId()); - assertEquals("SomeCustomizationId", aaiNqVfModule.getModelCustomizationId()); - logger.info(Serialization.gsonPretty.toJson(aaiNqVfModule)); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PnfInstanceTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PnfInstanceTest.java deleted file mode 100644 index 495d9f134..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PnfInstanceTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PnfInstanceTest { - private static final Logger logger = LoggerFactory.getLogger(PnfInstanceTest.class); - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - PnfInstance pnfInstance = new PnfInstance(); - pnfInstance.setPnfInstanceName("pnf-instance-name-test"); - pnfInstance.setPnfName("pnf-name-test"); - pnfInstance.setPnfType(PnfType.ENODEB); - pnfInstance.setPnfSerial("pnf-serial-test"); - assertNotNull(pnfInstance); - assertEquals("pnf-instance-name-test", pnfInstance.getPnfInstanceName()); - - PnfInstance pnfInstanceNull = new PnfInstance(null); - assertNotNull(pnfInstanceNull); - - PnfInstance pnfInstanceClone = new PnfInstance(pnfInstance); - assertNotNull(pnfInstanceClone); - - assertEquals("pnf-name-test", pnfInstanceClone.getPnfName()); - assertEquals(PnfType.ENODEB, pnfInstanceClone.getPnfType()); - assertEquals("pnf-serial-test", pnfInstanceClone.getPnfSerial()); - - assertEquals("PNFInstance [PNFName=pnf-name-test, PNFInstanceName=pnf-instance-name-test, PNFType=eNodeB, " - + "PNFSerial=pnf-serial-test]", pnfInstanceClone.toString()); - assertNotEquals(0, pnfInstanceClone.hashCode()); - assertNotEquals(0, new Pnf().hashCode()); - - PnfInstance pnfInstanceOther0 = new PnfInstance(); - pnfInstanceOther0.setPnfName("pnf-name-test"); - - PnfInstance pnfInstanceOther1 = new PnfInstance(pnfInstance); - pnfInstanceOther1.setPnfName("pnf-name-test-diff"); - - PnfInstance pnfInstanceOther2 = new PnfInstance(pnfInstance); - pnfInstanceOther2.setPnfInstanceName("pnf-instance-name-test-diff"); - - PnfInstance pnfInstanceOther3 = new PnfInstance(pnfInstance); - pnfInstanceOther3.setPnfName(null); - - PnfInstance pnfInstanceOther4 = new PnfInstance(pnfInstance); - pnfInstanceOther4.setPnfSerial(null); - - PnfInstance pnfInstanceOther5 = new PnfInstance(pnfInstance); - pnfInstanceOther5.setPnfSerial("pnf-serial-test-diff"); - - assertTrue(pnfInstance.equals(pnfInstance)); - assertFalse(pnfInstance.equals(null)); - assertFalse(pnfInstance.equals("hello")); - assertTrue(pnfInstance.equals(pnfInstanceClone)); - assertFalse(pnfInstance.equals(new Pnf())); - assertFalse(new Pnf().equals(pnfInstance)); - assertFalse(new Pnf().equals(pnfInstanceOther0)); - assertFalse(pnfInstanceOther0.equals(pnfInstance)); - assertFalse(pnfInstanceOther1.equals(pnfInstance)); - assertFalse(pnfInstanceOther2.equals(pnfInstance)); - assertFalse(pnfInstanceOther3.equals(pnfInstance)); - assertFalse(pnfInstanceOther4.equals(pnfInstance)); - assertFalse(pnfInstanceOther5.equals(pnfInstance)); - - logger.info(Serialization.gsonPretty.toJson(pnfInstance)); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTest.java deleted file mode 100644 index 0380c15b0..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PnfTest { - private static final Logger logger = LoggerFactory.getLogger(PnfTest.class); - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - Pnf pnf = new Pnf(); - pnf.setPnfName("pnf-name-test"); - pnf.setPnfType(PnfType.ENODEB); - assertNotNull(pnf); - - Pnf pnfClone = new Pnf(pnf); - assertNotNull(pnfClone); - - assertEquals("pnf-name-test", pnfClone.getPnfName()); - assertEquals(PnfType.ENODEB, pnfClone.getPnfType()); - - assertEquals("PNF [PNFName=pnf-name-test, PNFType=eNodeB]", pnfClone.toString()); - assertNotEquals(0, pnfClone.hashCode()); - assertNotEquals(0, new Pnf().hashCode()); - - Pnf pnfOther = new Pnf(); - pnfOther.setPnfName("pnf-name-test"); - - assertTrue(pnf.equals(pnf)); - assertFalse(pnf.equals(null)); - assertFalse(pnf.equals("hello")); - assertTrue(pnf.equals(pnfClone)); - assertFalse(pnf.equals(new Pnf())); - assertFalse(new Pnf().equals(pnf)); - assertFalse(new Pnf().equals(pnfOther)); - assertFalse(pnfOther.equals(pnf)); - - logger.info(Serialization.gsonPretty.toJson(pnf)); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTypeTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTypeTest.java deleted file mode 100644 index e62430ade..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/PnfTypeTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertNotNull; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class PnfTypeTest { - private static final Logger logger = LoggerFactory.getLogger(PnfTypeTest.class); - - - @BeforeClass - public static void setUpBeforeClass() throws Exception {} - - @AfterClass - public static void tearDownAfterClass() throws Exception {} - - @Test - public void test() { - PnfType pnfType = PnfType.ENODEB; - assertNotNull(pnfType); - assertNotNull(pnfType.toString()); - logger.info(Serialization.gsonPretty.toJson(pnfType)); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java deleted file mode 100644 index 832d59f89..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelatedToPropertyTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; - -import java.io.File; -import java.nio.file.Files; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RelatedToPropertyTest { - private static final Logger logger = LoggerFactory.getLogger(RelatedToPropertyTest.class); - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/RelatedToProperty.json").toPath())); - - RelatedToProperty relatedToProperty = Serialization.gsonPretty.fromJson(json, RelatedToProperty.class); - - assertEquals("generic-vnf.vnf-name", relatedToProperty.getPropertyKey()); - assertEquals("vLoadBalancerMS-Vnf-0809-1", relatedToProperty.getPropertyValue()); - - logger.info(Serialization.gsonPretty.toJson(relatedToProperty)); - - // verify that setXxx methods work - relatedToProperty.setPropertyKey("a key"); - relatedToProperty.setPropertyValue("a value"); - - assertEquals("a key", relatedToProperty.getPropertyKey()); - assertEquals("a value", relatedToProperty.getPropertyValue()); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java deleted file mode 100644 index 93b1d32c4..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipDataTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; - -import java.io.File; -import java.nio.file.Files; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RelationshipDataTest { - private static final Logger logger = LoggerFactory.getLogger(RelationshipDataTest.class); - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/RelationshipData.json").toPath())); - - RelationshipData relationshipData = Serialization.gsonPretty.fromJson(json, RelationshipData.class); - - assertEquals("generic-vnf.vnf-id", relationshipData.getRelationshipKey()); - assertEquals("807a3f02-f878-436b-870c-f0e91e81570d", relationshipData.getRelationshipValue()); - - logger.info(Serialization.gsonPretty.toJson(relationshipData)); - - // verify that setXxx methods work - relationshipData.setRelationshipKey("a key"); - relationshipData.setRelationshipValue("a value"); - - assertEquals("a key", relationshipData.getRelationshipKey()); - assertEquals("a value", relationshipData.getRelationshipValue()); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java deleted file mode 100644 index d67f2bb8b..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipListTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.File; -import java.nio.file.Files; -import java.util.LinkedList; -import java.util.List; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RelationshipListTest { - private static final Logger logger = LoggerFactory.getLogger(RelationshipListTest.class); - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files.readAllBytes( - new File("src/test/resources/org/onap/policy/aai/RelationshipList.json").toPath())); - - RelationshipList relationshipList = Serialization.gsonPretty.fromJson(json, RelationshipList.class); - - List<Relationship> lst = relationshipList.getRelationships(); - assertNotNull(lst); - assertEquals(3, lst.size()); - - // don't need to verify this in depth, as it has its own tests that do that - assertEquals("generic-vnf", lst.get(0).getRelatedTo()); - assertEquals("image", lst.get(1).getRelatedTo()); - assertEquals("flavor", lst.get(2).getRelatedTo()); - - logger.info(Serialization.gsonPretty.toJson(relationshipList)); - - // verify that setXxx methods work - lst = new LinkedList<>(); - lst.add(new Relationship()); - lst.add(new Relationship()); - - relationshipList.setRelationships(lst); - assertEquals(lst, relationshipList.getRelationships()); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java deleted file mode 100644 index f229a091a..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/RelationshipTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017-2018 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.aai; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.File; -import java.nio.file.Files; -import java.util.LinkedList; -import java.util.List; -import org.junit.Test; -import org.onap.policy.aai.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RelationshipTest { - private static final Logger logger = LoggerFactory.getLogger(RelationshipTest.class); - - @Test - public void test() throws Exception { - // deserialize json and verify fields are populated properly - String json = new String(Files - .readAllBytes(new File("src/test/resources/org/onap/policy/aai/Relationship.json").toPath())); - - Relationship relationship = Serialization.gsonPretty.fromJson(json, Relationship.class); - - assertEquals("/aai/v11/network/generic-vnfs/generic-vnf/807a3f02-f878-436b-870c-f0e91e81570d", - relationship.getRelatedLink()); - assertEquals("generic-vnf", relationship.getRelatedTo()); - - // don't need to verify this in depth, as it has its own tests that do that - List<RelatedToProperty> relatedToProperty = relationship.getRelatedToProperty(); - assertNotNull(relatedToProperty); - assertEquals(2, relatedToProperty.size()); - assertEquals("vLoadBalancerMS-Vnf-0809-1", relatedToProperty.get(0).getPropertyValue()); - assertEquals("vLoadBalancerMS-Vnf-0809-2", relatedToProperty.get(1).getPropertyValue()); - - // don't need to verify this in depth, as it has its own tests that do that - List<RelationshipData> relationshipData = relationship.getRelationshipData(); - assertNotNull(relationshipData); - assertEquals(2, relationshipData.size()); - assertEquals("807a3f02-f878-436b-870c-f0e91e81570d", relationshipData.get(0).getRelationshipValue()); - assertEquals("907a3f02-f878-436b-870c-f0e91e81570e", relationshipData.get(1).getRelationshipValue()); - - logger.info(Serialization.gsonPretty.toJson(relationship)); - - // verify that setXxx methods work - relatedToProperty = new LinkedList<>(); - relatedToProperty.add(new RelatedToProperty()); - relatedToProperty.add(new RelatedToProperty()); - relatedToProperty.add(new RelatedToProperty()); - - relationshipData = new LinkedList<>(); - relationshipData.add(new RelationshipData()); - relationshipData.add(new RelationshipData()); - relationshipData.add(new RelationshipData()); - - relationship.setRelatedLink("related-link"); - relationship.setRelatedTo("related-to"); - relationship.setRelatedToProperty(relatedToProperty); - relationship.setRelationshipData(relationshipData); - - assertEquals("related-link", relationship.getRelatedLink()); - assertEquals("related-to", relationship.getRelatedTo()); - assertEquals(relatedToProperty, relationship.getRelatedToProperty()); - assertEquals(relationshipData, relationship.getRelationshipData()); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/util/AaiExceptionTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/util/AaiExceptionTest.java deleted file mode 100644 index 69004e7f3..000000000 --- a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/util/AaiExceptionTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * aai - * ================================================================================ - * Copyright (C) 2017 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.aai.util; - -import static org.junit.Assert.assertNotNull; - -import java.io.IOException; - -import org.junit.Test; - -public class AaiExceptionTest { - - @Test - public void test() { - assertNotNull(new AaiException()); - assertNotNull(new AaiException("message")); - assertNotNull(new AaiException("message", new IOException())); - assertNotNull(new AaiException("message", new IOException(), true, false)); - assertNotNull(new AaiException(new IOException())); - } - -} diff --git a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetResponseError.json b/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetResponseError.json deleted file mode 100644 index 6751fef5c..000000000 --- a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetResponseError.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "requestError": { - "serviceException": { - "messageId": "SVC3001", - "text": "Resource not found for %1 using id %2 (msg=%3) (ec=%4)", - "variables": [ - "GET", - "network/generic-vnfs/generic-vnf/3f02-f878-436b-870c-f0e91e81570d", - "Node Not Found:No Node of type generic-vnf found at: network/generic-vnfs/generic-vnf/3f02-f878-436b-870c-f0e91e81570d", - "ERR.5.4.6114" - ] - } - } -} diff --git a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetVnfResponse.json b/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetVnfResponse.json deleted file mode 100644 index faa0e0e1b..000000000 --- a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetVnfResponse.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "in-maint": false, - "ipv4-oam-address": "10.0.150.1", - "is-closed-loop-disabled": true, - "model-customization-id": "6c1a5439-3b77-4d8a-bb2b-9fe7006ad671", - "model-invariant-id": "53638a85-361a-437d-8830-4b0d5329225e", - "model-version-id": "a82cd55f-1452-4c36-941a-c9f970a3e67c", - "nf-function": "", - "nf-naming-code": "", - "nf-role": "vLB", - "nf-type": "", - "orchestration-status": "Active", - "prov-status": "PROV", - "relationship-list": { - "relationship": [ - { - "related-link": "/aai/v11/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vLB/service-instances/service-instance/b66d24cc-feca-4fdc-8090-2e9539a8bbac", - "related-to": "service-instance", - "related-to-property": [ - { - "property-key": "service-instance.service-instance-name", - "property-value": "vLoadBalancerMS-Service-0809-1" - } - ], - "relationship-data": [ - { - "relationship-key": "customer.global-customer-id", - "relationship-value": "Demonstration" - }, - { - "relationship-key": "service-subscription.service-type", - "relationship-value": "vLB" - }, - { - "relationship-key": "service-instance.service-instance-id", - "relationship-value": "b66d24cc-feca-4fdc-8090-2e9539a8bbac" - } - ] - }, - { - "related-link": "/aai/v11/business/lines-of-business/line-of-business/Test-Business", - "related-to": "line-of-business", - "relationship-data": [ - { - "relationship-key": "line-of-business.line-of-business-name", - "relationship-value": "Test-Business" - } - ] - }, - { - "related-link": "/aai/v11/business/platforms/platform/Test-Platform", - "related-to": "platform", - "relationship-data": [ - { - "relationship-key": "platform.platform-name", - "relationship-value": "Test-Platform" - } - ] - }, - { - "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/4086f396c5e04caf9502c5fdeca575c4/vservers/vserver/191729bd-cb1d-485d-aa06-b20c888272a8", - "related-to": "vserver", - "related-to-property": [ - { - "property-key": "vserver.vserver-name", - "property-value": "vdns-ms01-0809-1" - } - ], - "relationship-data": [ - { - "relationship-key": "cloud-region.cloud-owner", - "relationship-value": "CloudOwner" - }, - { - "relationship-key": "cloud-region.cloud-region-id", - "relationship-value": "RegionOne" - }, - { - "relationship-key": "tenant.tenant-id", - "relationship-value": "4086f396c5e04caf9502c5fdeca575c4" - }, - { - "relationship-key": "vserver.vserver-id", - "relationship-value": "191729bd-cb1d-485d-aa06-b20c888272a8" - } - ] - }, - { - "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/4086f396c5e04caf9502c5fdeca575c4/vservers/vserver/1c94da3f-16f1-4fc7-9ed1-e018dfa62774", - "related-to": "vserver", - "related-to-property": [ - { - "property-key": "vserver.vserver-name", - "property-value": "vlb-ms-0809-1" - } - ], - "relationship-data": [ - { - "relationship-key": "cloud-region.cloud-owner", - "relationship-value": "CloudOwner" - }, - { - "relationship-key": "cloud-region.cloud-region-id", - "relationship-value": "RegionOne" - }, - { - "relationship-key": "tenant.tenant-id", - "relationship-value": "4086f396c5e04caf9502c5fdeca575c4" - }, - { - "relationship-key": "vserver.vserver-id", - "relationship-value": "1c94da3f-16f1-4fc7-9ed1-e018dfa62774" - } - ] - } - ] - }, - "resource-version": "1533850960381", - "service-id": "50e1b0be-e0c9-48e2-9f42-15279a783ee8", - "vnf-id": "807a3f02-f878-436b-870c-f0e91e81570d", - "vnf-name": "vLoadBalancerMS-Vnf-0809-2", - "vnf-type": "vLoadBalancerMS/vLoadBalancerMS 0" -} diff --git a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetVserverResponse.json b/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetVserverResponse.json deleted file mode 100644 index 19885942e..000000000 --- a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiGetVserverResponse.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "vserver": [ - { - "in-maint": false, - "is-closed-loop-disabled": true, - "prov-status": "ACTIVE", - "relationship-list": { - "relationship": [ - { - "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/807a3f02-f878-436b-870c-f0e91e81570d", - "related-to": "generic-vnf", - "related-to-property": [ - { - "property-key": "generic-vnf.vnf-name", - "property-value": "vLoadBalancerMS-Vnf-0809-2" - } - ], - "relationship-data": [ - { - "relationship-key": "generic-vnf.vnf-id", - "relationship-value": "807a3f02-f878-436b-870c-f0e91e81570d" - } - ] - }, - { - "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/6e219e86-cd94-4989-9119-def29aa10b12", - "related-to": "image", - "related-to-property": [ - { - "property-key": "image.image-name", - "property-value": "unknown" - } - ], - "relationship-data": [ - { - "relationship-key": "cloud-region.cloud-owner", - "relationship-value": "CloudOwner" - }, - { - "relationship-key": "cloud-region.cloud-region-id", - "relationship-value": "RegionOne" - }, - { - "relationship-key": "image.image-id", - "relationship-value": "6e219e86-cd94-4989-9119-def29aa10b12" - } - ] - }, - { - "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/764efb04-5a46-4806-a766-2bdd24559f39", - "related-to": "flavor", - "related-to-property": [ - { - "property-key": "flavor.flavor-name", - "property-value": "m1.medium" - } - ], - "relationship-data": [ - { - "relationship-key": "cloud-region.cloud-owner", - "relationship-value": "CloudOwner" - }, - { - "relationship-key": "cloud-region.cloud-region-id", - "relationship-value": "RegionOne" - }, - { - "relationship-key": "flavor.flavor-id", - "relationship-value": "764efb04-5a46-4806-a766-2bdd24559f39" - } - ] - } - ] - }, - "resource-version": "1533850964910", - "vserver-id": "1c94da3f-16f1-4fc7-9ed1-e018dfa62774", - "vserver-name": "vlb-ms-0809-1", - "vserver-name2": "vlb-ms-0809-7", - "vserver-selflink": "http://localhost:8774/v2.1/4086f396c5e04caf9502c5fdeca575c4/servers/1c94da3f-16f1-4fc7-9ed1-e018dfa62774" - } - ] -} diff --git a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoItems.json b/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoItems.json deleted file mode 100644 index 996692402..000000000 --- a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoItems.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "inventory-response-item": [ - { - "extra-properties": {}, - "inventory-response-items": { - "inventory-response-item": [ - { - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "a82cd55f-1452-4c36-941a-c9f970a3e67c" - }, - { - "property-name": "model-ver.model-name", - "property-value": "vLoadBalancerMS" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "53638a85-361a-437d-8830-4b0d5329225e" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1.0" - } - ] - }, - "generic-vnf": { - "in-maint": false, - "ipv4-oam-address": "10.0.150.1", - "is-closed-loop-disabled": false, - "model-customization-id": "6c1a5439-3b77-4d8a-bb2b-9fe7006ad671", - "model-invariant-id": "53638a85-361a-437d-8830-4b0d5329225e", - "model-version-id": "a82cd55f-1452-4c36-941a-c9f970a3e67c", - "nf-function": "", - "nf-naming-code": "", - "nf-role": "vLB", - "nf-type": "", - "orchestration-status": "Active", - "prov-status": "PROV", - "resource-version": "1533850960381", - "service-id": "50e1b0be-e0c9-48e2-9f42-15279a783ee8", - "vnf-id": "807a3f02-f878-436b-870c-f0e91e81570d", - "vnf-name": "vLoadBalancerMS-Vnf-0809-2", - "vnf-type": "vLoadBalancerMS/vLoadBalancerMS 0" - }, - "inventory-response-items": { - "inventory-response-item": [ - ] - }, - "model-name": "vLoadBalancerMS" - }, - { - "extra-properties": {}, - "inventory-response-items": { - "inventory-response-item": [ - { - "cloud-region": { - "cloud-owner": "CloudOwner", - "cloud-region-id": "RegionOne", - "cloud-region-version": "v2.5", - "cloud-type": "openstack", - "cloud-zone": "zone-1", - "owner-defined-type": "owner type", - "resource-version": "1533652058185", - "sriov-automation": false - }, - "extra-properties": {} - } - ] - }, - "tenant": { - "resource-version": "1533652058206", - "tenant-id": "4086f396c5e04caf9502c5fdeca575c4", - "tenant-name": "PFPP" - } - } - ] - }, - "vserver": { - "in-maint": false, - "is-closed-loop-disabled": false, - "prov-status": "ACTIVE", - "resource-version": "1533850964910", - "vserver-id": "1c94da3f-16f1-4fc7-9ed1-e018dfa62774", - "vserver-name": "vlb-ms-0809-1", - "vserver-name2": "vlb-ms-0809-1", - "vserver-selflink": "http://10.12.25.2:8774/v2.1/4086f396c5e04caf9502c5fdeca575c4/servers/1c94da3f-16f1-4fc7-9ed1-e018dfa62774" - } - } - ] -} diff --git a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoModules.json b/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoModules.json deleted file mode 100644 index 2dd6090c7..000000000 --- a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoModules.json +++ /dev/null @@ -1,133 +0,0 @@ -{ - "inventory-response-item": [ - { - "extra-properties": {}, - "inventory-response-items": { - "inventory-response-item": [ - { - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "a82cd55f-1452-4c36-941a-c9f970a3e67c" - }, - { - "property-name": "model-ver.model-name", - "property-value": "vLoadBalancerMS" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "53638a85-361a-437d-8830-4b0d5329225e" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1.0" - } - ] - }, - "generic-vnf": { - "in-maint": false, - "ipv4-oam-address": "10.0.150.1", - "is-closed-loop-disabled": false, - "model-customization-id": "6c1a5439-3b77-4d8a-bb2b-9fe7006ad671", - "model-invariant-id": "53638a85-361a-437d-8830-4b0d5329225e", - "model-version-id": "a82cd55f-1452-4c36-941a-c9f970a3e67c", - "nf-function": "", - "nf-naming-code": "", - "nf-role": "vLB", - "nf-type": "", - "orchestration-status": "Active", - "prov-status": "PROV", - "resource-version": "1533850960381", - "service-id": "50e1b0be-e0c9-48e2-9f42-15279a783ee8", - "vnf-id": "807a3f02-f878-436b-870c-f0e91e81570d", - "vnf-name": "vLoadBalancerMS-Vnf-0809-2", - "vnf-type": "vLoadBalancerMS/vLoadBalancerMS 0" - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "4feb459d-d8ef-4cde-a714-235c79787962" - }, - { - "property-name": "model-ver.model-name", - "property-value": "vLoadBalancerMS" - }, - { - "property-name": "model.model-type", - "property-value": "service" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "b5477216-9b7d-4e75-8777-5b632d406759" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1.0" - } - ] - }, - "model-name": "vLoadBalancerMS", - "service-instance": { - "environment-context": "General_Revenue-Bearing", - "model-invariant-id": "b5477216-9b7d-4e75-8777-5b632d406759", - "model-version-id": "4feb459d-d8ef-4cde-a714-235c79787962", - "orchestration-status": "Active", - "resource-version": "1533848425145", - "service-instance-id": "b66d24cc-feca-4fdc-8090-2e9539a8bbac", - "service-instance-name": "vLoadBalancerMS-Service-0809-1", - "workload-context": "Production" - } - } - ] - }, - "model-name": "vLoadBalancerMS" - }, - { - "extra-properties": {}, - "inventory-response-items": { - "inventory-response-item": [ - { - "cloud-region": { - "cloud-owner": "CloudOwner", - "cloud-region-id": "RegionOne", - "cloud-region-version": "v2.5", - "cloud-type": "openstack", - "cloud-zone": "zone-1", - "owner-defined-type": "owner type", - "resource-version": "1533652058185", - "sriov-automation": false - }, - "extra-properties": {} - } - ] - }, - "tenant": { - "resource-version": "1533652058206", - "tenant-id": "4086f396c5e04caf9502c5fdeca575c4", - "tenant-name": "PFPP" - } - } - ] - }, - "vserver": { - "in-maint": false, - "is-closed-loop-disabled": false, - "prov-status": "ACTIVE", - "resource-version": "1533850964910", - "vserver-id": "1c94da3f-16f1-4fc7-9ed1-e018dfa62774", - "vserver-name": "vlb-ms-0809-1", - "vserver-name2": "vlb-ms-0809-1", - "vserver-selflink": "http://10.12.25.2:8774/v2.1/4086f396c5e04caf9502c5fdeca575c4/servers/1c94da3f-16f1-4fc7-9ed1-e018dfa62774" - } - } - ] -} diff --git a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoNames.json b/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoNames.json deleted file mode 100644 index 9c1a9bc5d..000000000 --- a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-NoNames.json +++ /dev/null @@ -1,133 +0,0 @@ -{ - "inventory-response-item": [ - { - "extra-properties": {}, - "inventory-response-items": { - "inventory-response-item": [ - { - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "a82cd55f-1452-4c36-941a-c9f970a3e67c" - }, - { - "property-name": "model-ver.model-name", - "property-value": "vLoadBalancerMS" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "53638a85-361a-437d-8830-4b0d5329225e" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1.0" - } - ] - }, - "generic-vnf": { - "in-maint": false, - "ipv4-oam-address": "10.0.150.1", - "is-closed-loop-disabled": false, - "model-customization-id": "6c1a5439-3b77-4d8a-bb2b-9fe7006ad671", - "model-invariant-id": "53638a85-361a-437d-8830-4b0d5329225e", - "model-version-id": "a82cd55f-1452-4c36-941a-c9f970a3e67c", - "nf-function": "", - "nf-naming-code": "", - "nf-role": "vLB", - "nf-type": "", - "orchestration-status": "Active", - "prov-status": "PROV", - "resource-version": "1533850960381", - "service-id": "50e1b0be-e0c9-48e2-9f42-15279a783ee8", - "vnf-id": "807a3f02-f878-436b-870c-f0e91e81570d", - "vnf-name": "vLoadBalancerMS-Vnf-0809-2", - "vnf-type": "vLoadBalancerMS/vLoadBalancerMS 0" - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "model-name": "vLoadBalancerMS", - "service-instance": { - "environment-context": "General_Revenue-Bearing", - "model-invariant-id": "b5477216-9b7d-4e75-8777-5b632d406759", - "model-version-id": "4feb459d-d8ef-4cde-a714-235c79787962", - "orchestration-status": "Active", - "resource-version": "1533848425145", - "service-instance-id": "b66d24cc-feca-4fdc-8090-2e9539a8bbac", - "service-instance-name": "vLoadBalancerMS-Service-0809-1", - "workload-context": "Production" - } - }, - { - "vf-module": { - "is-base-vf-module": false, - "model-invariant-id": "6d01b7f1-769a-4080-b8ea-57fd03ef1572", - "model-version-id": "3302088a-457e-496c-9282-2eb3d5b8dd24", - "resource-version": "1534270663202", - "vf-module-id": "dummy_807a3f02-f878-436b-870c-f0e91e81570d", - "vf-module-name": "dummy_807a3f02-f878-436b-870c-f0e91e81570d" - } - }, - { - "vf-module": { - "heat-stack-id": "Vfmodule_vLBMS-0809-1/83ab2394-2b22-40f9-8ba2-383698dd2958", - "is-base-vf-module": true, - "model-customization-id": "5198f732-8f22-48f9-98f8-d6b8b50118be", - "model-invariant-id": "1f566a81-58ba-4762-81f9-d2259509429a", - "model-version-id": "94827d25-4ac3-4850-abfc-7b6e3c531db4", - "module-index": 0, - "orchestration-status": "active", - "resource-version": "1533850416834", - "vf-module-id": "b861467d-d3a7-4b21-81b3-94d928a7e8b7", - "vf-module-name": "Vfmodule_vLBMS-0809-1" - } - } - ] - }, - "model-name": "vLoadBalancerMS" - }, - { - "extra-properties": {}, - "inventory-response-items": { - "inventory-response-item": [ - { - "cloud-region": { - "cloud-owner": "CloudOwner", - "cloud-region-id": "RegionOne", - "cloud-region-version": "v2.5", - "cloud-type": "openstack", - "cloud-zone": "zone-1", - "owner-defined-type": "owner type", - "resource-version": "1533652058185", - "sriov-automation": false - }, - "extra-properties": {} - } - ] - }, - "tenant": { - "resource-version": "1533652058206", - "tenant-id": "4086f396c5e04caf9502c5fdeca575c4", - "tenant-name": "PFPP" - } - } - ] - }, - "vserver": { - "in-maint": false, - "is-closed-loop-disabled": false, - "prov-status": "ACTIVE", - "resource-version": "1533850964910", - "vserver-id": "1c94da3f-16f1-4fc7-9ed1-e018dfa62774", - "vserver-name": "vlb-ms-0809-1", - "vserver-name2": "vlb-ms-0809-1", - "vserver-selflink": "http://10.12.25.2:8774/v2.1/4086f396c5e04caf9502c5fdeca575c4/servers/1c94da3f-16f1-4fc7-9ed1-e018dfa62774" - } - } - ] -} diff --git a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-Vserver.json b/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-Vserver.json deleted file mode 100644 index fb341dc65..000000000 --- a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqResponseWrapper-Vserver.json +++ /dev/null @@ -1,157 +0,0 @@ -{ - "inventory-response-item": [ - { - "extra-properties": {}, - "inventory-response-items": { - "inventory-response-item": [ - { - "extra-properties": { - "extra-property": [ - { - "property-name": "model-ver.model-version-id", - "property-value": "a82cd55f-1452-4c36-941a-c9f970a3e67c" - }, - { - "property-name": "model-ver.model-name", - "property-value": "vLoadBalancerMS" - }, - { - "property-name": "model.model-type", - "property-value": "resource" - }, - { - "property-name": "model.model-invariant-id", - "property-value": "53638a85-361a-437d-8830-4b0d5329225e" - }, - { - "property-name": "model-ver.model-version", - "property-value": "1.0" - } - ] - }, - "generic-vnf": { - "in-maint": false, - "ipv4-oam-address": "10.0.150.1", - "is-closed-loop-disabled": false, - "model-customization-id": "6c1a5439-3b77-4d8a-bb2b-9fe7006ad671", - "model-invariant-id": "53638a85-361a-437d-8830-4b0d5329225e", - "model-version-id": "a82cd55f-1452-4c36-941a-c9f970a3e67c", - "nf-function": "", - "nf-naming-code": "", - "nf-role": "vLB", - "nf-type": "", - "orchestration-status": "Active", - "prov-status": "PROV", - "resource-version": "1533850960381", - "service-id": "50e1b0be-e0c9-48e2-9f42-15279a783ee8", - "vnf-id": "807a3f02-f878-436b-870c-f0e91e81570d", - "vnf-name": "vLoadBalancerMS-Vnf-0809-2", - "vnf-type": "vLoadBalancerMS/vLoadBalancerMS 0" - }, - "inventory-response-items": { - "inventory-response-item": [ - { - "model-name": "vLoadBalancerMS", - "service-instance": { - "environment-context": "General_Revenue-Bearing", - "model-invariant-id": "b5477216-9b7d-4e75-8777-5b632d406759", - "model-version-id": "4feb459d-d8ef-4cde-a714-235c79787962", - "orchestration-status": "Active", - "resource-version": "1533848425145", - "service-instance-id": "b66d24cc-feca-4fdc-8090-2e9539a8bbac", - "service-instance-name": "vLoadBalancerMS-Service-0809-1", - "workload-context": "Production" - } - }, - { - "vf-module": { - "is-base-vf-module": false, - "model-invariant-id": "6d01b7f1-769a-4080-b8ea-57fd03ef1572", - "model-version-id": "3302088a-457e-496c-9282-2eb3d5b8dd24", - "resource-version": "1534270663202", - "vf-module-id": "dummy_807a3f02-f878-436b-870c-f0e91e81570d", - "vf-module-name": "dummy_807a3f02-f878-436b-870c-f0e91e81570d" - } - }, - { - "vf-module": { - "is-base-vf-module": false, - "vf-module-name": "my-module-abc_1" - } - }, - { - "vf-module": { - "heat-stack-id": "Vfmodule_vLBMS-0809-1/83ab2394-2b22-40f9-8ba2-383698dd2958", - "is-base-vf-module": true, - "model-customization-id": "5198f732-8f22-48f9-98f8-d6b8b50118be", - "model-invariant-id": "1f566a81-58ba-4762-81f9-d2259509429a", - "model-version-id": "94827d25-4ac3-4850-abfc-7b6e3c531db4", - "module-index": 0, - "orchestration-status": "active", - "resource-version": "1533850416834", - "vf-module-id": "b861467d-d3a7-4b21-81b3-94d928a7e8b7", - "vf-module-name": "Vfmodule_vLBMS-0809-1" - } - }, - { - "vf-module": { - "is-base-vf-module": false, - "vf-module-name": "my-module-abc_123" - } - }, - { - "vf-module": { - "is-base-vf-module": false, - "vf-module-name": "no-underscore-number-9999" - } - }, - { - "vf-module": { - "is-base-vf-module": false, - "vf-module-name": "my-module-abc_34" - } - } - ] - }, - "model-name": "vLoadBalancerMS" - }, - { - "extra-properties": {}, - "inventory-response-items": { - "inventory-response-item": [ - { - "cloud-region": { - "cloud-owner": "CloudOwner", - "cloud-region-id": "RegionOne", - "cloud-region-version": "v2.5", - "cloud-type": "openstack", - "cloud-zone": "zone-1", - "owner-defined-type": "owner type", - "resource-version": "1533652058185", - "sriov-automation": false - }, - "extra-properties": {} - } - ] - }, - "tenant": { - "resource-version": "1533652058206", - "tenant-id": "4086f396c5e04caf9502c5fdeca575c4", - "tenant-name": "PFPP" - } - } - ] - }, - "vserver": { - "in-maint": false, - "is-closed-loop-disabled": false, - "prov-status": "ACTIVE", - "resource-version": "1533850964910", - "vserver-id": "1c94da3f-16f1-4fc7-9ed1-e018dfa62774", - "vserver-name": "vlb-ms-0809-1", - "vserver-name2": "vlb-ms-0809-1", - "vserver-selflink": "http://10.12.25.2:8774/v2.1/4086f396c5e04caf9502c5fdeca575c4/servers/1c94da3f-16f1-4fc7-9ed1-e018dfa62774" - } - } - ] -} diff --git a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqVServer.json b/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqVServer.json deleted file mode 100644 index 0a59d8a87..000000000 --- a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/AaiNqVServer.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "in-maint": false, - "is-closed-loop-disabled": true, - "prov-status": "ACTIVE", - "relationship-list": { - "relationship": [ - { - "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/807a3f02-f878-436b-870c-f0e91e81570d", - "related-to": "generic-vnf", - "related-to-property": [ - { - "property-key": "generic-vnf.vnf-name", - "property-value": "vLoadBalancerMS-Vnf-0809-2" - } - ], - "relationship-data": [ - { - "relationship-key": "generic-vnf.vnf-id", - "relationship-value": "807a3f02-f878-436b-870c-f0e91e81570d" - } - ] - }, - { - "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/6e219e86-cd94-4989-9119-def29aa10b12", - "related-to": "image", - "related-to-property": [ - { - "property-key": "image.image-name", - "property-value": "unknown" - } - ], - "relationship-data": [ - { - "relationship-key": "cloud-region.cloud-owner", - "relationship-value": "CloudOwner" - }, - { - "relationship-key": "cloud-region.cloud-region-id", - "relationship-value": "RegionOne" - }, - { - "relationship-key": "image.image-id", - "relationship-value": "6e219e86-cd94-4989-9119-def29aa10b12" - } - ] - }, - { - "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/764efb04-5a46-4806-a766-2bdd24559f39", - "related-to": "flavor", - "related-to-property": [ - { - "property-key": "flavor.flavor-name", - "property-value": "m1.medium" - } - ], - "relationship-data": [ - { - "relationship-key": "cloud-region.cloud-owner", - "relationship-value": "CloudOwner" - }, - { - "relationship-key": "cloud-region.cloud-region-id", - "relationship-value": "RegionOne" - }, - { - "relationship-key": "flavor.flavor-id", - "relationship-value": "764efb04-5a46-4806-a766-2bdd24559f39" - } - ] - } - ] - }, - "resource-version": "1533850964910", - "vserver-id": "1c94da3f-16f1-4fc7-9ed1-e018dfa62774", - "vserver-name": "vlb-ms-0809-1", - "vserver-name2": "vlb-ms-0809-7", - "vserver-selflink": "http://localhost:8774/v2.1/4086f396c5e04caf9502c5fdeca575c4/servers/1c94da3f-16f1-4fc7-9ed1-e018dfa62774" -} diff --git a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/RelatedToProperty.json b/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/RelatedToProperty.json deleted file mode 100644 index 2211b3725..000000000 --- a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/RelatedToProperty.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "property-key": "generic-vnf.vnf-name", - "property-value": "vLoadBalancerMS-Vnf-0809-1" -} diff --git a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/Relationship.json b/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/Relationship.json deleted file mode 100644 index 39d9ce1b6..000000000 --- a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/Relationship.json +++ /dev/null @@ -1,25 +0,0 @@ - -{ - "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/807a3f02-f878-436b-870c-f0e91e81570d", - "related-to": "generic-vnf", - "related-to-property": [ - { - "property-key": "generic-vnf.vnf-name", - "property-value": "vLoadBalancerMS-Vnf-0809-1" - }, - { - "property-key": "generic-vnf.vnf-name", - "property-value": "vLoadBalancerMS-Vnf-0809-2" - } - ], - "relationship-data": [ - { - "relationship-key": "generic-vnf.vnf-id", - "relationship-value": "807a3f02-f878-436b-870c-f0e91e81570d" - }, - { - "relationship-key": "generic-vnf.vnf-id", - "relationship-value": "907a3f02-f878-436b-870c-f0e91e81570e" - } - ] -} diff --git a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/RelationshipData.json b/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/RelationshipData.json deleted file mode 100644 index 4bbb39e8f..000000000 --- a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/RelationshipData.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "relationship-key": "generic-vnf.vnf-id", - "relationship-value": "807a3f02-f878-436b-870c-f0e91e81570d" -} diff --git a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/RelationshipList.json b/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/RelationshipList.json deleted file mode 100644 index ae180f056..000000000 --- a/controlloop/common/model-impl/aai/src/test/resources/org/onap/policy/aai/RelationshipList.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "relationship": [ - { - "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/807a3f02-f878-436b-870c-f0e91e81570d", - "related-to": "generic-vnf", - "related-to-property": [ - { - "property-key": "generic-vnf.vnf-name", - "property-value": "vLoadBalancerMS-Vnf-0809-2" - } - ], - "relationship-data": [ - { - "relationship-key": "generic-vnf.vnf-id", - "relationship-value": "807a3f02-f878-436b-870c-f0e91e81570d" - } - ] - }, - { - "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/6e219e86-cd94-4989-9119-def29aa10b12", - "related-to": "image", - "related-to-property": [ - { - "property-key": "image.image-name", - "property-value": "unknown" - } - ], - "relationship-data": [ - { - "relationship-key": "cloud-region.cloud-owner", - "relationship-value": "CloudOwner" - }, - { - "relationship-key": "cloud-region.cloud-region-id", - "relationship-value": "RegionOne" - }, - { - "relationship-key": "image.image-id", - "relationship-value": "6e219e86-cd94-4989-9119-def29aa10b12" - } - ] - }, - { - "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/764efb04-5a46-4806-a766-2bdd24559f39", - "related-to": "flavor", - "related-to-property": [ - { - "property-key": "flavor.flavor-name", - "property-value": "m1.medium" - } - ], - "relationship-data": [ - { - "relationship-key": "cloud-region.cloud-owner", - "relationship-value": "CloudOwner" - }, - { - "relationship-key": "cloud-region.cloud-region-id", - "relationship-value": "RegionOne" - }, - { - "relationship-key": "flavor.flavor-id", - "relationship-value": "764efb04-5a46-4806-a766-2bdd24559f39" - } - ] - } - ] -} diff --git a/controlloop/common/model-impl/appc/pom.xml b/controlloop/common/model-impl/appc/pom.xml deleted file mode 100644 index 628e27ed4..000000000 --- a/controlloop/common/model-impl/appc/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - Drools PDP Application Models - ================================================================================ - Copyright (C) 2017-2018 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========================================================= - --> - -<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.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>model-impl</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>appc</artifactId> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <scope>provided</scope> - </dependency> - </dependencies> - -</project> diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java deleted file mode 100644 index e58c45b5b..000000000 --- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java +++ /dev/null @@ -1,216 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-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.appc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.time.Instant; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; -import java.util.UUID; - -public class CommonHeader implements Serializable { - private static final long serialVersionUID = -3581658269910980336L; - - @SerializedName("TimeStamp") - private Instant timeStamp = Instant.now(); - - @SerializedName("APIver") - private String apiVer = "1.01"; - - @SerializedName("OriginatorID") - private String originatorId; - - @SerializedName("RequestID") - private UUID requestId; - - @SerializedName("SubRequestID") - private String subRequestId; - - @SerializedName("RequestTrack") - private Collection<String> requestTrack = new ArrayList<>(); - - @SerializedName("Flags") - private Collection<Map<String, String>> flags = new ArrayList<>(); - - public CommonHeader() {} - - /** - * Construct an instance from an existing instance. - * - * @param commonHeader the existing instance - */ - public CommonHeader(CommonHeader commonHeader) { - this.originatorId = commonHeader.originatorId; - this.requestId = commonHeader.requestId; - this.subRequestId = commonHeader.subRequestId; - if (commonHeader.requestTrack != null) { - this.requestTrack.addAll(commonHeader.requestTrack); - } - if (commonHeader.flags != null) { - this.flags.addAll(commonHeader.flags); - } - } - - public Instant getTimeStamp() { - return timeStamp; - } - - public void setTimeStamp(Instant timeStamp) { - this.timeStamp = timeStamp; - } - - public String getApiVer() { - return apiVer; - } - - public void setApiVer(String apiVer) { - this.apiVer = apiVer; - } - - public String getOriginatorId() { - return originatorId; - } - - public void setOriginatorId(String originatorId) { - this.originatorId = originatorId; - } - - public UUID getRequestId() { - return requestId; - } - - public void setRequestId(UUID requestId) { - this.requestId = requestId; - } - - public String getSubRequestId() { - return subRequestId; - } - - public void setSubRequestId(String subRequestId) { - this.subRequestId = subRequestId; - } - - public Collection<String> getRequestTrack() { - return requestTrack; - } - - public void setRequestTrack(Collection<String> requestTrack) { - this.requestTrack = requestTrack; - } - - public Collection<Map<String, String>> getFlags() { - return flags; - } - - public void setFlags(Collection<Map<String, String>> flags) { - this.flags = flags; - } - - @Override - public String toString() { - return "CommonHeader [TimeStamp=" + timeStamp + ", APIver=" + apiVer + ", OriginatorId=" + originatorId - + ", RequestId=" + requestId + ", SubrequestId=" + subRequestId + ", RequestTrack=" + requestTrack - + ", Flags=" + flags + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode()); - result = prime * result + ((flags == null) ? 0 : flags.hashCode()); - result = prime * result + ((originatorId == null) ? 0 : originatorId.hashCode()); - result = prime * result + ((requestId == null) ? 0 : requestId.hashCode()); - result = prime * result + ((requestTrack == null) ? 0 : requestTrack.hashCode()); - result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode()); - result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - CommonHeader other = (CommonHeader) obj; - if (apiVer == null) { - if (other.apiVer != null) { - return false; - } - } else if (!apiVer.equals(other.apiVer)) { - return false; - } - if (flags == null) { - if (other.flags != null) { - return false; - } - } else if (!flags.equals(other.flags)) { - return false; - } - if (originatorId == null) { - if (other.originatorId != null) { - return false; - } - } else if (!originatorId.equals(other.originatorId)) { - return false; - } - if (requestId == null) { - if (other.requestId != null) { - return false; - } - } else if (!requestId.equals(other.requestId)) { - return false; - } - if (requestTrack == null) { - if (other.requestTrack != null) { - return false; - } - } else if (!requestTrack.equals(other.requestTrack)) { - return false; - } - if (subRequestId == null) { - if (other.subRequestId != null) { - return false; - } - } else if (!subRequestId.equals(other.subRequestId)) { - return false; - } - if (timeStamp == null) { - if (other.timeStamp != null) { - return false; - } - } else if (!timeStamp.equals(other.timeStamp)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java deleted file mode 100644 index cbf5b44d6..000000000 --- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java +++ /dev/null @@ -1,165 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-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.appc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -public class Request implements Serializable { - private static final long serialVersionUID = -3912323643990646431L; - - @SerializedName("CommonHeader") - private CommonHeader commonHeader; - - @SerializedName("Action") - private String action; - - @SerializedName("TargetID") - private String targetId; - - @SerializedName("ObjectID") - private String objectId; - - @SerializedName("Payload") - private HashMap<String, Object> payload = new HashMap<>(); - - public Request() { - // Initiate an empty Request instance - } - - public CommonHeader getCommonHeader() { - return commonHeader; - } - - public Map<String, Object> getPayload() { - return payload; - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public String getTargetId() { - return targetId; - } - - public void setTargetId(String targetId) { - this.targetId = targetId; - } - - public String getObjectId() { - return objectId; - } - - public void setObjectId(String objectId) { - this.objectId = objectId; - } - - public void setCommonHeader(CommonHeader commonHeader) { - this.commonHeader = commonHeader; - } - - public void setPayload(Map<String, Object> payload) { - this.payload = new HashMap<>(payload); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((action == null) ? 0 : action.hashCode()); - result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode()); - result = prime * result + ((objectId == null) ? 0 : objectId.hashCode()); - result = prime * result + ((payload == null) ? 0 : payload.hashCode()); - result = prime * result + ((targetId == null) ? 0 : targetId.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - - Request other = (Request) obj; - if (action == null) { - if (other.action != null) { - return false; - } - } else if (!action.equals(other.action)) { - return false; - } - - if (commonHeader == null) { - if (other.commonHeader != null) { - return false; - } - } else if (!commonHeader.equals(other.commonHeader)) { - return false; - } - - if (objectId == null) { - if (other.objectId != null) { - return false; - } - } else if (!objectId.equals(other.objectId)) { - return false; - } - - if (payload == null) { - if (other.payload != null) { - return false; - } - } else if (!payload.equals(other.payload)) { - return false; - } - - if (targetId == null) { - if (other.targetId != null) { - return false; - } - } else if (!targetId.equals(other.targetId)) { - return false; - } - - return true; - } - - @Override - public String toString() { - return "Request [CommonHeader=" + commonHeader + ", Action=" + action + ", TargetId=" + targetId + ", ObjectId=" - + objectId + ", Payload=" + payload + "]"; - } - -} diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java deleted file mode 100644 index af503b104..000000000 --- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java +++ /dev/null @@ -1,136 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -public class Response implements Serializable { - private static final long serialVersionUID = 434953706339865151L; - - @SerializedName("CommonHeader") - private CommonHeader commonHeader; - - @SerializedName("Status") - private ResponseStatus status = new ResponseStatus(); - - @SerializedName("Payload") - private HashMap<String, Object> payload = new HashMap<>(); - - public Response() { - - } - - /** - * Construct an instance from an existing instance. - * - * @param request the existing instance - */ - public Response(Request request) { - if (request.getCommonHeader() != null) { - this.commonHeader = new CommonHeader(request.getCommonHeader()); - } - if (request.getPayload() != null) { - this.payload.putAll(request.getPayload()); - } - } - - public CommonHeader getCommonHeader() { - return commonHeader; - } - - public void setCommonHeader(CommonHeader commonHeader) { - this.commonHeader = commonHeader; - } - - public ResponseStatus getStatus() { - return status; - } - - public void setStatus(ResponseStatus status) { - this.status = status; - } - - public Map<String, Object> getPayload() { - return payload; - } - - public void setPayload(Map<String, Object> payload) { - this.payload = new HashMap<>(payload); - } - - @Override - public String toString() { - return "Response [CommonHeader=" + commonHeader + ", Status=" + status + ", Payload=" + payload + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode()); - result = prime * result + ((payload == null) ? 0 : payload.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Response other = (Response) obj; - if (commonHeader == null) { - if (other.commonHeader != null) { - return false; - } - } else if (!commonHeader.equals(other.commonHeader)) { - return false; - } - if (payload == null) { - if (other.payload != null) { - return false; - } - } else if (!payload.equals(other.payload)) { - return false; - } - if (status == null) { - if (other.status != null) { - return false; - } - } else if (!status.equals(other.status)) { - return false; - } - return true; - } - - - -} diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java deleted file mode 100644 index b62f917ba..000000000 --- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appc; - -import com.google.gson.annotations.SerializedName; - -public enum ResponseCode { - ACCEPT(100), ERROR(200), REJECT(300), SUCCESS(400), FAILURE(500); - - @SerializedName("Code") - private Integer code; - - private ResponseCode(int code) { - this.code = code; - } - - public int getValue() { - return this.code; - } - - @Override - public String toString() { - return Integer.toString(this.code); - } - - /** - * Convert an integer code to a ResponseCode. - * - * @param code the integer code - * @return the ResponseCode - */ - public static ResponseCode toResponseCode(int code) { - if (code == ACCEPT.code) { - return ACCEPT; - } - if (code == ERROR.code) { - return ERROR; - } - if (code == REJECT.code) { - return REJECT; - } - if (code == SUCCESS.code) { - return SUCCESS; - } - if (code == FAILURE.code) { - return FAILURE; - } - return null; - } -} diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java deleted file mode 100644 index f54117862..000000000 --- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class ResponseStatus implements Serializable { - private static final long serialVersionUID = 2421770469587860452L; - - @SerializedName("Code") - private int code; - - @SerializedName("Value") - private String value; - - @SerializedName("Description") - private String description; - - @Override - public String toString() { - return "ResponseStatus [Code=" + code + ", Value=" + value + ", Description=" + description + "]"; - } - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + code; - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((value == null) ? 0 : value.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ResponseStatus other = (ResponseStatus) obj; - if (code != other.code) { - return false; - } - if (description == null) { - if (other.description != null) { - return false; - } - } else if (!description.equals(other.description)) { - return false; - } - if (value == null) { - if (other.value != null) { - return false; - } - } else if (!value.equals(other.value)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java deleted file mode 100644 index a12f9d139..000000000 --- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appc; - -import com.google.gson.annotations.SerializedName; - -public enum ResponseValue { - ACCEPT("ACCEPT"), ERROR("ERROR"), REJECT("REJECT"), SUCCESS("SUCCESS"), FAILURE("FAILURE"); - - @SerializedName("Value") - private String value; - - private ResponseValue(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - /** - * Convert a String value to a ResponseValue. - * - * @param value the String value - * @return the ResponseValue - */ - public static ResponseValue toResponseValue(String value) { - if (value == null) { - return null; - } - - if (value.equals(ACCEPT.toString())) { - return ACCEPT; - } - if (value.equals(ERROR.toString())) { - return ERROR; - } - if (value.equals(REJECT.toString())) { - return REJECT; - } - if (value.equals(SUCCESS.toString())) { - return SUCCESS; - } - if (value.equals(FAILURE.toString())) { - return FAILURE; - } - - return null; - } - -} diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java deleted file mode 100644 index d8a397dca..000000000 --- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appc.util; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -import java.lang.reflect.Type; -import java.time.Instant; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class Serialization { - public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx"); - - public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() - .registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter()) - .registerTypeAdapter(Instant.class, new GsonInstantAdapter()) - // .registerTypeAdapter(CommonHeader1607.class, new gsonCommonHeaderInstance()) - // .registerTypeAdapter(ResponseStatus1607.class, new gsonResponseStatus()) - .create(); - - private Serialization() {} - - public static class GsonUtcAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> { - private static final Logger logger = LoggerFactory.getLogger(GsonUtcAdapter.class); - - @Override - public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context) { - try { - return ZonedDateTime.parse(element.getAsString(), format); - } catch (Exception e) { - logger.error("deserialize threw: ", e); - } - return null; - } - - @Override - public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) { - return new JsonPrimitive(datetime.format(format)); - } - } - - public static class GsonInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> { - - @Override - public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { - return Instant.ofEpochMilli(json.getAsLong()); - } - - @Override - public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) { - return new JsonPrimitive(src.toEpochMilli()); - } - - } - -} diff --git a/controlloop/common/model-impl/appc/src/main/resources/definitions.yaml b/controlloop/common/model-impl/appc/src/main/resources/definitions.yaml deleted file mode 100644 index 680a9929c..000000000 --- a/controlloop/common/model-impl/appc/src/main/resources/definitions.yaml +++ /dev/null @@ -1,118 +0,0 @@ -### -# ============LICENSE_START======================================================= -# appc -# ================================================================================ -# Copyright (C) 2017 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========================================================= -### - -Request: - type: object - properties: - CommonHeader: - type: object - properties: - TimeStamp: - type: string - APIver: - type: string - value: '1.01' - OriginatorID: - type: string - RequestID: - type: string - pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - SubRequestID: - type: string - Flags: - type: object - required: - - TimeStamp - - APIver - - OriginatorID - - RequestID - Action: - type: string - enum: - - Audit - - ActionStatus - - BlockAudits - - Configure - - HealthCheck - - Install - - LiveUpgrade - - Migrate - - ModifyConfig - - Query - - Rebuild - - Reconfigure - - Restart - - Rollback - - Scale - - Start - - Stop - - Sync - - Terminate - - Test - - Upgrade - TargetID: - type: string - ObjectID: - type: string - Payload: - type: object - required: - - CommonHeader - - Action - - TargetID -Response: - type: object - properties: - CommonHeader: - type: object - properties: - TimeStamp: - type: string - APIver: - type: string - OriginatorID: - type: string - RequestID: - type: string - SubRequestID: - type: string - Flags: - type: object - required: - - TimeStamp - - APIver - - OriginatorID - - RequestID - Status: - type: object - properties: - Code: - type: integer - Value: - type: string - required: - - Code - - Value - Payload: - type: object - required: - - CommonHeader - - Status - diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java deleted file mode 100644 index 93a05f424..000000000 --- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java +++ /dev/null @@ -1,178 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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========================================================= - */ - -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017 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.appc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.junit.Test; - -public class CommonHeaderTest { - - @Test - public void testCommonHeader() { - CommonHeader commonHeader = new CommonHeader(); - assertNotNull(commonHeader); - assertNotNull(new CommonHeader(commonHeader)); - assertNotEquals(0, commonHeader.hashCode()); - - commonHeader.setApiVer("Kansas"); - assertEquals("Kansas", commonHeader.getApiVer()); - - List<Map<String, String>> flagSet = new ArrayList<>(); - commonHeader.setFlags(flagSet); - assertEquals(flagSet, commonHeader.getFlags()); - - commonHeader.setOriginatorId("Dorothy"); - assertEquals("Dorothy", commonHeader.getOriginatorId()); - - UUID requestId = UUID.randomUUID(); - commonHeader.setRequestId(requestId); - assertEquals(requestId, commonHeader.getRequestId()); - - List<String> requestTrackSet = new ArrayList<>(); - commonHeader.setRequestTrack(requestTrackSet); - assertEquals(requestTrackSet, commonHeader.getRequestTrack()); - - commonHeader.setSubRequestId("Can I go home?"); - assertEquals("Can I go home?", commonHeader.getSubRequestId()); - - Instant timestamp = Instant.now(); - commonHeader.setTimeStamp(timestamp); - assertEquals(timestamp, commonHeader.getTimeStamp()); - - assertNotEquals(0, commonHeader.hashCode()); - - assertEquals("CommonHeader [TimeStamp=", commonHeader.toString().substring(0, 24)); - - CommonHeader copiedCommonHeader = new CommonHeader(); - copiedCommonHeader.setApiVer(commonHeader.getApiVer()); - copiedCommonHeader.setFlags(commonHeader.getFlags()); - copiedCommonHeader.setOriginatorId(commonHeader.getOriginatorId()); - copiedCommonHeader.setRequestId(commonHeader.getRequestId()); - copiedCommonHeader.setRequestTrack(commonHeader.getRequestTrack()); - copiedCommonHeader.setSubRequestId(commonHeader.getSubRequestId()); - copiedCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(commonHeader)); - assertTrue(commonHeader.equals(copiedCommonHeader)); - assertFalse(commonHeader.equals(null)); - assertFalse(commonHeader.equals("Hello")); - - CommonHeader clonedCommonHeader = new CommonHeader(commonHeader); - clonedCommonHeader.setApiVer(commonHeader.getApiVer()); - clonedCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(clonedCommonHeader)); - - commonHeader.setApiVer(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setApiVer(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); - commonHeader.setApiVer("Kansas"); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setApiVer("Kansas"); - assertTrue(commonHeader.equals(copiedCommonHeader)); - - commonHeader.setFlags(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setFlags(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); - commonHeader.setFlags(flagSet); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setFlags(flagSet); - assertTrue(commonHeader.equals(copiedCommonHeader)); - - commonHeader.setOriginatorId(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setOriginatorId(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); - commonHeader.setOriginatorId("Dorothy"); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setOriginatorId("Dorothy"); - assertTrue(commonHeader.equals(copiedCommonHeader)); - - commonHeader.setRequestId(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setRequestId(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); - commonHeader.setRequestId(requestId); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setRequestId(requestId); - assertTrue(commonHeader.equals(copiedCommonHeader)); - - commonHeader.setRequestTrack(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setRequestTrack(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); - commonHeader.setRequestTrack(requestTrackSet); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setRequestTrack(requestTrackSet); - assertTrue(commonHeader.equals(copiedCommonHeader)); - - commonHeader.setSubRequestId(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setSubRequestId(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); - commonHeader.setSubRequestId("Can I go home?"); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setSubRequestId("Can I go home?"); - assertTrue(commonHeader.equals(copiedCommonHeader)); - - commonHeader.setTimeStamp(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setTimeStamp(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); - commonHeader.setTimeStamp(timestamp); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setTimeStamp(timestamp); - assertTrue(commonHeader.equals(copiedCommonHeader)); - } -} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/EnumsTest.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/EnumsTest.java deleted file mode 100644 index afb9a312e..000000000 --- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/EnumsTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -public class EnumsTest { - - @Test - public void testResponseCode() { - assertEquals(5, ResponseCode.values().length); - - assertNull(ResponseCode.toResponseCode(0)); - - assertEquals(ResponseCode.ACCEPT, ResponseCode.toResponseCode(100)); - assertEquals(ResponseCode.ERROR, ResponseCode.toResponseCode(200)); - assertEquals(ResponseCode.REJECT, ResponseCode.toResponseCode(300)); - assertEquals(ResponseCode.SUCCESS, ResponseCode.toResponseCode(400)); - assertEquals(ResponseCode.FAILURE, ResponseCode.toResponseCode(500)); - - assertEquals(100, ResponseCode.ACCEPT.getValue()); - assertEquals(200, ResponseCode.ERROR.getValue()); - assertEquals(300, ResponseCode.REJECT.getValue()); - assertEquals(400, ResponseCode.SUCCESS.getValue()); - assertEquals(500, ResponseCode.FAILURE.getValue()); - - assertEquals("100", ResponseCode.ACCEPT.toString()); - assertEquals("200", ResponseCode.ERROR.toString()); - assertEquals("300", ResponseCode.REJECT.toString()); - assertEquals("400", ResponseCode.SUCCESS.toString()); - assertEquals("500", ResponseCode.FAILURE.toString()); - } - - @Test - public void testResponseValue() { - assertEquals(5, ResponseValue.values().length); - - assertNull(ResponseValue.toResponseValue("Dorothy")); - assertNull(ResponseValue.toResponseValue(null)); - - assertEquals(ResponseValue.ACCEPT, ResponseValue.toResponseValue("ACCEPT")); - assertEquals(ResponseValue.ERROR, ResponseValue.toResponseValue("ERROR")); - assertEquals(ResponseValue.REJECT, ResponseValue.toResponseValue("REJECT")); - assertEquals(ResponseValue.SUCCESS, ResponseValue.toResponseValue("SUCCESS")); - assertEquals(ResponseValue.FAILURE, ResponseValue.toResponseValue("FAILURE")); - - assertEquals("ACCEPT", ResponseValue.ACCEPT.toString()); - assertEquals("ERROR", ResponseValue.ERROR.toString()); - assertEquals("REJECT", ResponseValue.REJECT.toString()); - assertEquals("SUCCESS", ResponseValue.SUCCESS.toString()); - assertEquals("FAILURE", ResponseValue.FAILURE.toString()); - } -} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java deleted file mode 100644 index e0c850b60..000000000 --- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - -public class RequestTest { - - @Test - public void testRequest() { - Request request = new Request(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - CommonHeader commonHeader = new CommonHeader(); - - request.setCommonHeader(commonHeader); - assertEquals(commonHeader, request.getCommonHeader()); - - request.setAction("Go to Oz"); - assertEquals("Go to Oz", request.getAction()); - - request.setObjectId("Wizard"); - assertEquals("Wizard", request.getObjectId()); - - request.setTargetId("Oz"); - assertEquals("Oz", request.getTargetId()); - - Map<String, Object> payload = new HashMap<>(); - payload.put("North", "Good Witch"); - payload.put("West", "Bad Witch"); - - request.setPayload(payload); - assertEquals(payload, request.getPayload()); - - assertNotEquals(0, request.hashCode()); - - assertEquals("Request [CommonHeader=CommonHeader [TimeStamp=", request.toString().substring(0, 46)); - - Request copiedRequest = new Request(); - copiedRequest.setCommonHeader(request.getCommonHeader()); - copiedRequest.setAction(request.getAction()); - copiedRequest.setObjectId(request.getObjectId()); - copiedRequest.setPayload(request.getPayload()); - copiedRequest.setTargetId(request.getTargetId()); - - assertTrue(request.equals(request)); - assertTrue(request.equals(copiedRequest)); - assertFalse(request.equals(null)); - assertFalse(request.equals("Hello")); - - request.setCommonHeader(null); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setCommonHeader(null); - assertTrue(request.equals(copiedRequest)); - request.setCommonHeader(commonHeader); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setCommonHeader(commonHeader); - assertTrue(request.equals(copiedRequest)); - - request.setAction(null); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setAction(null); - assertTrue(request.equals(copiedRequest)); - request.setAction("Go to Oz"); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setAction("Go to Oz"); - assertTrue(request.equals(copiedRequest)); - - request.setObjectId(null); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setObjectId(null); - assertTrue(request.equals(copiedRequest)); - request.setObjectId("Wizard"); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setObjectId("Wizard"); - assertTrue(request.equals(copiedRequest)); - - request.setTargetId(null); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setTargetId(null); - assertTrue(request.equals(copiedRequest)); - request.setTargetId("Oz"); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setTargetId("Oz"); - assertTrue(request.equals(copiedRequest)); - - request.setPayload(new HashMap<String, Object>()); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setPayload(new HashMap<String, Object>()); - assertTrue(request.equals(copiedRequest)); - request.setPayload(payload); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setPayload(payload); - assertTrue(request.equals(copiedRequest)); - } -} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java deleted file mode 100644 index ab8811d37..000000000 --- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class ResponseStatusTest { - - @Test - public void testResonseStatus() { - ResponseStatus status = new ResponseStatus(); - assertNotNull(status); - assertNotEquals(0, status.hashCode()); - - status.setCode(1234); - assertEquals(1234, status.getCode()); - - status.setDescription("The wonderful land of Oz"); - assertEquals("The wonderful land of Oz", status.getDescription()); - - status.setValue("There's no place like home"); - assertEquals("There's no place like home", status.getValue()); - assertNotEquals(0, status.hashCode()); - - assertEquals("ResponseStatus [Code=1234, Value=There's no pla", status.toString().substring(0, 47)); - - ResponseStatus copiedStatus = new ResponseStatus(); - copiedStatus.setCode(status.getCode()); - copiedStatus.setDescription(status.getDescription()); - copiedStatus.setValue(status.getValue()); - - assertTrue(status.equals(status)); - assertTrue(status.equals(copiedStatus)); - assertFalse(status.equals(null)); - assertFalse(status.equals("Hello")); - - status.setCode(-1); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setCode(-1); - assertTrue(status.equals(copiedStatus)); - status.setCode(1234); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setCode(1234); - assertTrue(status.equals(copiedStatus)); - - status.setDescription(null); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setDescription(null); - assertTrue(status.equals(copiedStatus)); - status.setDescription("The wonderful land of Oz"); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setDescription("The wonderful land of Oz"); - assertTrue(status.equals(copiedStatus)); - - status.setValue(null); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setValue(null); - assertTrue(status.equals(copiedStatus)); - status.setValue("There's no place like home"); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setValue("There's no place like home"); - assertTrue(status.equals(copiedStatus)); - } -} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java deleted file mode 100644 index ce0ba90a5..000000000 --- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - -public class ResponseTest { - - @Test - public void testResonse() { - Response response = new Response(); - assertNotNull(response); - assertNotNull(new Response(new Request())); - assertNotEquals(0, response.hashCode()); - - CommonHeader commonHeader = new CommonHeader(); - - Request request = new Request(); - request.setCommonHeader(commonHeader); - assertNotNull(new Response(request)); - - response.setCommonHeader(commonHeader); - assertEquals(commonHeader, response.getCommonHeader()); - - ResponseStatus status = new ResponseStatus(); - response.setStatus(status); - assertEquals(status, response.getStatus()); - - Map<String, Object> payload = new HashMap<>(); - payload.put("North", "Good Witch"); - payload.put("West", "Bad Witch"); - - response.setPayload(payload); - assertEquals(payload, response.getPayload()); - - assertNotEquals(0, response.hashCode()); - - assertEquals("Response [CommonHeader=CommonHeader [TimeStamp=", response.toString().substring(0, 47)); - - Response copiedResponse = new Response(); - copiedResponse.setCommonHeader(response.getCommonHeader()); - copiedResponse.setStatus(response.getStatus()); - copiedResponse.setPayload(response.getPayload()); - - assertTrue(response.equals(response)); - assertTrue(response.equals(copiedResponse)); - assertFalse(response.equals(null)); - assertFalse(response.equals("Hello")); - - response.setCommonHeader(null); - assertFalse(response.equals(copiedResponse)); - copiedResponse.setCommonHeader(null); - assertTrue(response.equals(copiedResponse)); - response.setCommonHeader(commonHeader); - assertFalse(response.equals(copiedResponse)); - copiedResponse.setCommonHeader(commonHeader); - assertTrue(response.equals(copiedResponse)); - - response.setStatus(null); - assertFalse(response.equals(copiedResponse)); - copiedResponse.setStatus(null); - assertTrue(response.equals(copiedResponse)); - response.setStatus(status); - assertFalse(response.equals(copiedResponse)); - copiedResponse.setStatus(status); - assertTrue(response.equals(copiedResponse)); - - response.setPayload(new HashMap<String, Object>()); - assertFalse(response.equals(copiedResponse)); - copiedResponse.setPayload(new HashMap<String, Object>()); - assertTrue(response.equals(copiedResponse)); - response.setPayload(payload); - assertFalse(response.equals(copiedResponse)); - copiedResponse.setPayload(payload); - assertTrue(response.equals(copiedResponse)); - } -} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/SerializationTest.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/SerializationTest.java deleted file mode 100644 index 6a3a3a099..000000000 --- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/SerializationTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appc.util; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import java.time.Instant; -import java.time.ZoneId; -import java.time.ZonedDateTime; - -import org.junit.Test; - -public class SerializationTest { - - @Test - public void test() { - String nameString = "Dorothy"; - String jsonName = Serialization.gsonPretty.toJson(nameString, String.class); - assertEquals("\"Dorothy\"", jsonName); - String jsonInOutName = Serialization.gsonPretty.fromJson(jsonName, String.class); - assertEquals("Dorothy", jsonInOutName); - - Instant instant = Instant.ofEpochMilli(1516127215000L); - String instantString = Serialization.gsonPretty.toJson(instant, Instant.class); - assertEquals("1516127215000", instantString); - Instant outInstant = Serialization.gsonPretty.fromJson(instantString, Instant.class); - assertEquals(instant, outInstant); - - ZonedDateTime zdt = ZonedDateTime.ofInstant(instant, ZoneId.of("UTC")); - String zdtString = Serialization.gsonPretty.toJson(zdt, ZonedDateTime.class); - assertEquals("\"2018-01-16 18:26:55.000000+00:00\"", zdtString); - ZonedDateTime outZdt = Serialization.gsonPretty.fromJson(zdtString, ZonedDateTime.class); - assertEquals(zdt.getDayOfWeek(), outZdt.getDayOfWeek()); - - assertNull(Serialization.gsonPretty.fromJson("oz time is weird", ZonedDateTime.class)); - } -} diff --git a/controlloop/common/model-impl/appclcm/pom.xml b/controlloop/common/model-impl/appclcm/pom.xml deleted file mode 100644 index 9341e7bb6..000000000 --- a/controlloop/common/model-impl/appclcm/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - Drools PDP Application Models - ================================================================================ - Copyright (C) 2017-2018 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========================================================= - --> - -<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.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>model-impl</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>appclcm</artifactId> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <scope>provided</scope> - </dependency> - </dependencies> - -</project> diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmCommonHeader.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmCommonHeader.java deleted file mode 100644 index dbf8dd0cd..000000000 --- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmCommonHeader.java +++ /dev/null @@ -1,256 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * Copyright (C) 2017-2018 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.appclcm; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.time.Instant; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -public class LcmCommonHeader implements Serializable { - - private static final long serialVersionUID = 6581963539127062114L; - - @SerializedName(value = "timestamp") - private Instant timeStamp = Instant.now(); - - @SerializedName(value = "api-ver") - private String apiVer = "2.00"; - - @SerializedName(value = "originator-id") - private String originatorId; - - @SerializedName(value = "request-id") - private UUID requestId; - - @SerializedName(value = "sub-request-id") - private String subRequestId; - - @SerializedName(value = "flags") - private Map<String, String> flags = new HashMap<>(); - - public LcmCommonHeader() { - - } - - /** - * Used to copy a common header. - * - * @param commonHeader a header that is defined by the lcm api guide that contains information - * about the request (requestId, flags, etc.) - */ - public LcmCommonHeader(LcmCommonHeader commonHeader) { - this.originatorId = commonHeader.originatorId; - this.requestId = commonHeader.requestId; - this.subRequestId = commonHeader.subRequestId; - if (commonHeader.flags != null) { - this.flags.putAll(commonHeader.flags); - } - } - - /** - * Get the timestamp. - * - * @return the timeStamp - */ - public Instant getTimeStamp() { - return timeStamp; - } - - /** - * Set the timestamp. - * - * @param timeStamp the timeStamp to set - */ - public void setTimeStamp(Instant timeStamp) { - this.timeStamp = timeStamp; - } - - /** - * Get the API version. - * - * @return the apiVer - */ - public String getApiVer() { - return apiVer; - } - - /** - * Set the API version. - * - * @param apiVer the apiVer to set - */ - public void setApiVer(String apiVer) { - this.apiVer = apiVer; - } - - /** - * Get the originator Id. - * - * @return the originatorId - */ - public String getOriginatorId() { - return originatorId; - } - - /** - * Set the originator Id. - * - * @param originatorId the originatorId to set - */ - public void setOriginatorId(String originatorId) { - this.originatorId = originatorId; - } - - /** - * Get the request Id. - * - * @return the requestId - */ - public UUID getRequestId() { - return requestId; - } - - /** - * Set the request Id. - * - * @param requestId the requestId to set - */ - public void setRequestId(UUID requestId) { - this.requestId = requestId; - } - - /** - * Get the sub request Id. - * - * @return the subRequestId - */ - public String getSubRequestId() { - return subRequestId; - } - - /** - * Set the sub request Id. - * - * @param subRequestId the subRequestId to set - */ - public void setSubRequestId(String subRequestId) { - this.subRequestId = subRequestId; - } - - /** - * Get the flags. - * - * @return the flags - */ - public Map<String, String> getFlags() { - return flags; - } - - /** - * Set the flags. - * - * @param flags the flags to set - */ - public void setFlags(Map<String, String> flags) { - this.flags = flags; - } - - @Override - public String toString() { - return "CommonHeader [timeStamp=" + timeStamp + ", apiVer=" + apiVer + ", originatorId=" + originatorId - + ", requestId=" + requestId + ", subRequestId=" + subRequestId + ", flags=" + flags + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode()); - result = prime * result + ((flags == null) ? 0 : flags.hashCode()); - result = prime * result + ((originatorId == null) ? 0 : originatorId.hashCode()); - result = prime * result + ((requestId == null) ? 0 : requestId.hashCode()); - result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode()); - result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - LcmCommonHeader other = (LcmCommonHeader) obj; - if (apiVer == null) { - if (other.apiVer != null) { - return false; - } - } else if (!apiVer.equals(other.apiVer)) { - return false; - } - if (flags == null) { - if (other.flags != null) { - return false; - } - } else if (!flags.equals(other.flags)) { - return false; - } - if (originatorId == null) { - if (other.originatorId != null) { - return false; - } - } else if (!originatorId.equals(other.originatorId)) { - return false; - } - if (requestId == null) { - if (other.requestId != null) { - return false; - } - } else if (!requestId.equals(other.requestId)) { - return false; - } - if (subRequestId == null) { - if (other.subRequestId != null) { - return false; - } - } else if (!subRequestId.equals(other.subRequestId)) { - return false; - } - if (timeStamp == null) { - if (other.timeStamp != null) { - return false; - } - } else if (!timeStamp.equals(other.timeStamp)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequest.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequest.java deleted file mode 100644 index afac0dece..000000000 --- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequest.java +++ /dev/null @@ -1,175 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * Copyright (C) 2017-2018 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.appclcm; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.Map; - -public class LcmRequest implements Serializable { - - private static final long serialVersionUID = 219375564922846624L; - - @SerializedName(value = "common-header") - private LcmCommonHeader commonHeader; - - @SerializedName(value = "action") - private String action; - - @SerializedName(value = "action-identifiers") - private Map<String, String> actionIdentifiers; - - @SerializedName(value = "payload") - private String payload; - - public LcmRequest() { - // Create a default LCM request - } - - public LcmCommonHeader getCommonHeader() { - return commonHeader; - } - - /** - * Get the action. - * - * @return the action - */ - public String getAction() { - return action; - } - - /** - * Set the action. - * - * @param action the action to set - */ - public void setAction(String action) { - this.action = action; - } - - /** - * Get the action identifiers. - * - * @return the actionIdentifiers - */ - public Map<String, String> getActionIdentifiers() { - return actionIdentifiers; - } - - /** - * Set the action identifiers. - * - * @param actionIdentifiers the actionIdentifiers to set - */ - public void setActionIdentifiers(Map<String, String> actionIdentifiers) { - this.actionIdentifiers = actionIdentifiers; - } - - /** - * Get the payload. - * - * @return the payload - */ - public String getPayload() { - return payload; - } - - /** - * Set the payload. - * - * @param payload the payload to set - */ - public void setPayload(String payload) { - this.payload = payload; - } - - /** - * Get the common header. - * - * @param commonHeader the commonHeader to set - */ - public void setCommonHeader(LcmCommonHeader commonHeader) { - this.commonHeader = commonHeader; - } - - @Override - public String toString() { - return "Request [commonHeader=" + commonHeader + ", action=" + action + ", actionIdentifiers=" - + actionIdentifiers + ", payload=" + payload + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode()); - result = prime * result + ((action == null) ? 0 : action.hashCode()); - result = prime * result + ((actionIdentifiers == null) ? 0 : actionIdentifiers.hashCode()); - result = prime * result + ((payload == null) ? 0 : payload.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - LcmRequest other = (LcmRequest) obj; - if (commonHeader == null) { - if (other.commonHeader != null) { - return false; - } - } else if (!commonHeader.equals(other.commonHeader)) { - return false; - } - if (action == null) { - if (other.action != null) { - return false; - } - } else if (!action.equals(other.action)) { - return false; - } - if (actionIdentifiers == null) { - if (other.actionIdentifiers != null) { - return false; - } - } else if (!actionIdentifiers.equals(other.actionIdentifiers)) { - return false; - } - if (payload == null) { - if (other.payload != null) { - return false; - } - } else if (!payload.equals(other.payload)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequestWrapper.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequestWrapper.java deleted file mode 100644 index b77303ad0..000000000 --- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmRequestWrapper.java +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * Copyright (C) 2017-2018 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.appclcm; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class LcmRequestWrapper extends LcmWrapper implements Serializable { - - private static final long serialVersionUID = 424866914715980798L; - - @SerializedName(value = "body") - private LcmRequest body; - - public LcmRequestWrapper() { - super(); - } - - public LcmRequestWrapper(LcmRequest request) { - body = request; - } - - /** - * Get the body. - * - * @return the body - */ - public LcmRequest getBody() { - return body; - } - - /** - * Set the body. - * - * @param body the body to set - */ - public void setBody(LcmRequest body) { - this.body = body; - } - - @Override - public String toString() { - return "RequestWrapper [body=" + body + ", toString()=" + super.toString() + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((body == null) ? 0 : body.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - LcmRequestWrapper other = (LcmRequestWrapper) obj; - if (body == null) { - if (other.body != null) { - return false; - } - } else if (!body.equals(other.body)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponse.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponse.java deleted file mode 100644 index 2a65c9a14..000000000 --- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponse.java +++ /dev/null @@ -1,161 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * Copyright (C) 2017-2018 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.appclcm; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class LcmResponse implements Serializable { - - private static final long serialVersionUID = 6332508597287669750L; - - @SerializedName(value = "common-header") - private LcmCommonHeader commonHeader; - - @SerializedName(value = "status") - private LcmResponseStatus status = new LcmResponseStatus(); - - @SerializedName(value = "payload") - private String payload; - - public LcmResponse() { - // EMPTY - } - - /** - * Constructs a response using the common header of the request since they will be the same. - * - * @param request an appc lcm request object specified by the lcm api guide - */ - public LcmResponse(LcmRequest request) { - this.commonHeader = new LcmCommonHeader(request.getCommonHeader()); - String requestPayload = request.getPayload(); - if (requestPayload != null) { - this.payload = requestPayload; - } - } - - /** - * Get the common header. - * - * @return the commonHeader - */ - public LcmCommonHeader getCommonHeader() { - return commonHeader; - } - - /** - * Set the common header. - * - * @param commonHeader the commonHeader to set - */ - public void setCommonHeader(LcmCommonHeader commonHeader) { - this.commonHeader = commonHeader; - } - - /** - * Get the status. - * - * @return the status - */ - public LcmResponseStatus getStatus() { - return status; - } - - /** - * Set the status. - * - * @param status the status to set - */ - public void setStatus(LcmResponseStatus status) { - this.status = status; - } - - /** - * Get the payload. - * - * @return the payload - */ - public String getPayload() { - return payload; - } - - /** - * Set the payload. - * - * @param payload the payload to set - */ - public void setPayload(String payload) { - this.payload = payload; - } - - @Override - public String toString() { - return "Response [commonHeader=" + commonHeader + ", status=" + status + ", payload=" + payload + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode()); - result = prime * result + ((payload == null) ? 0 : payload.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - LcmResponse other = (LcmResponse) obj; - if (commonHeader == null) { - if (other.commonHeader != null) { - return false; - } - } else if (!commonHeader.equals(other.commonHeader)) { - return false; - } - if (payload == null) { - if (other.payload != null) { - return false; - } - } else if (!payload.equals(other.payload)) { - return false; - } - if (status == null) { - if (other.status != null) { - return false; - } - } else if (!status.equals(other.status)) { - return false; - } - return true; - } -} diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseCode.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseCode.java deleted file mode 100644 index d3c3464ed..000000000 --- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseCode.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. 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.appclcm; - -import java.io.Serializable; -import org.onap.policy.appclcm.util.StatusCodeEnum; - -public class LcmResponseCode implements Serializable { - - /* These fields define the key to the response code value. */ - public static final String ACCEPTED = "ACCEPTED"; - public static final String ERROR = "ERROR"; - public static final String REJECT = "REJECT"; - public static final String SUCCESS = "SUCCESS"; - public static final String FAILURE = "FAILURE"; - public static final String PARTIAL_SUCCESS = "PARTIAL SUCCESS"; - public static final String PARTIAL_FAILURE = "PARTIAL FAILURE"; - private static final long serialVersionUID = 8189456447227022582L; - - private final Integer code; - - protected LcmResponseCode(final int code) { - this.code = code; - } - - public int getCode() { - return this.code; - } - - @Override - public String toString() { - return Integer.toString(this.code); - } - - /** - * Translates the code to a string value that represents the meaning of the code. - * - * @param code the numeric value that is returned by APPC based on success, failure, etc. of the action requested - * @return the string value equivalent of the APPC response code - */ - public static String toResponseValue(int code) { - StatusCodeEnum statusCodeEnum = StatusCodeEnum.fromStatusCode(code); - return (statusCodeEnum != null) ? statusCodeEnum.toString() : null; - } -} diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseStatus.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseStatus.java deleted file mode 100644 index 4c044a0a8..000000000 --- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseStatus.java +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * Copyright (C) 2017-2018 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.appclcm; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class LcmResponseStatus implements Serializable { - - private static final long serialVersionUID = 974891505135467199L; - - @SerializedName(value = "code") - private int code; - - @SerializedName(value = "message") - private String message; - - public LcmResponseStatus() { - // Create a default LCMResponseStatus instance - } - - /** - * Get the code. - * - * @return the code - */ - public int getCode() { - return code; - } - - /** - * Set the code. - * - * @param code the code to set - */ - public void setCode(int code) { - this.code = code; - } - - /** - * Get the message. - * - * @return the message - */ - public String getMessage() { - return message; - } - - /** - * Set the message. - * - * @param message the message to set - */ - public void setMessage(String message) { - this.message = message; - } - - @Override - public String toString() { - return "ResponseStatus [code=" + code + ", message=" + message + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + code; - result = prime * result + ((message == null) ? 0 : message.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - LcmResponseStatus other = (LcmResponseStatus) obj; - if (code != other.code) { - return false; - } - if (message == null) { - if (other.message != null) { - return false; - } - } else if (!message.equals(other.message)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseWrapper.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseWrapper.java deleted file mode 100644 index 43cc32511..000000000 --- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmResponseWrapper.java +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * Copyright (C) 2017-2018 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.appclcm; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class LcmResponseWrapper extends LcmWrapper implements Serializable { - - private static final long serialVersionUID = 463937813781086802L; - - @SerializedName(value = "body") - private LcmResponse body; - - public LcmResponseWrapper() { - super(); - } - - /** - * Get the body. - * - * @return the body - */ - public LcmResponse getBody() { - return body; - } - - /** - * Set the body. - * - * @param body the body to set - */ - public void setBody(LcmResponse body) { - this.body = body; - } - - @Override - public String toString() { - return "ResponseWrapper [body=" + body + ", toString()=" + super.toString() + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((body == null) ? 0 : body.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - LcmResponseWrapper other = (LcmResponseWrapper) obj; - if (body == null) { - if (other.body != null) { - return false; - } - } else if (!body.equals(other.body)) { - return false; - } - return true; - } -} diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmWrapper.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmWrapper.java deleted file mode 100644 index 322abb015..000000000 --- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/LcmWrapper.java +++ /dev/null @@ -1,208 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * Copyright (C) 2017-2018 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.appclcm; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class LcmWrapper implements Serializable { - - private static final long serialVersionUID = 753005805432396532L; - - @SerializedName(value = "version") - private String version; - - @SerializedName(value = "cambria-partition") - private String cambriaPartition; - - @SerializedName(value = "rpc-name") - private String rpcName; - - @SerializedName(value = "correlation-id") - private String correlationId; - - @SerializedName(value = "type") - private String type; - - public LcmWrapper() { - // Create a default LCMWrapper instance - } - - /** - * Get the version. - * - * @return the version - */ - public String getVersion() { - return version; - } - - /** - * Set the version. - * - * @param version the version to set - */ - public void setVersion(String version) { - this.version = version; - } - - /** - * Get the cambria partition. - * - * @return the cambriaPartition - */ - public String getCambriaPartition() { - return cambriaPartition; - } - - /** - * Set the cambria partition. - * - * @param cambriaPartition the cambriaPartition to set - */ - public void setCambriaPartition(String cambriaPartition) { - this.cambriaPartition = cambriaPartition; - } - - /** - * Get the RPN name. - * - * @return the rpcName - */ - public String getRpcName() { - return rpcName; - } - - /** - * Set the RPC name. - * - * @param rpcName the rpcName to set - */ - public void setRpcName(String rpcName) { - this.rpcName = rpcName; - } - - /** - * Get the correlation Id. - * - * @return the correlationId - */ - public String getCorrelationId() { - return correlationId; - } - - /** - * Set the correclation Id. - * - * @param correlationId the correlationId to set - */ - public void setCorrelationId(String correlationId) { - this.correlationId = correlationId; - } - - /** - * Get the type. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Set the type. - * - * @param type the type to set - */ - public void setType(String type) { - this.type = type; - } - - @Override - public String toString() { - return "Wrapper [version=" + version + ", cambriaPartition=" + cambriaPartition + ", rpcName=" + rpcName - + ", correlationId=" + correlationId + ", type=" + type + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((cambriaPartition == null) ? 0 : cambriaPartition.hashCode()); - result = prime * result + ((correlationId == null) ? 0 : correlationId.hashCode()); - result = prime * result + ((rpcName == null) ? 0 : rpcName.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + ((version == null) ? 0 : version.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - LcmWrapper other = (LcmWrapper) obj; - if (cambriaPartition == null) { - if (other.cambriaPartition != null) { - return false; - } - } else if (!cambriaPartition.equals(other.cambriaPartition)) { - return false; - } - if (correlationId == null) { - if (other.correlationId != null) { - return false; - } - } else if (!correlationId.equals(other.correlationId)) { - return false; - } - if (rpcName == null) { - if (other.rpcName != null) { - return false; - } - } else if (!rpcName.equals(other.rpcName)) { - return false; - } - if (type == null) { - if (other.type != null) { - return false; - } - } else if (!type.equals(other.type)) { - return false; - } - if (version == null) { - if (other.version != null) { - return false; - } - } else if (!version.equals(other.version)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java deleted file mode 100644 index ee2d28094..000000000 --- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/Serialization.java +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appclcm.util; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -import java.lang.reflect.Type; -import java.time.Instant; - -import org.onap.policy.appclcm.LcmRequest; -import org.onap.policy.appclcm.LcmResponse; - -public final class Serialization { - public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() - .registerTypeAdapter(Instant.class, new InstantAdapter()).create(); - - public static final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() - .registerTypeAdapter(LcmRequest.class, new RequestAdapter()) - .registerTypeAdapter(LcmResponse.class, new ResponseAdapter()).create(); - - public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() - .registerTypeAdapter(Instant.class, new InstantJunitAdapter()).create(); - - private Serialization() {} - - public static class RequestAdapter implements JsonSerializer<LcmRequest>, JsonDeserializer<LcmRequest> { - - @Override - public JsonElement serialize(LcmRequest src, Type typeOfSrc, JsonSerializationContext context) { - JsonElement requestJson = gsonPretty.toJsonTree(src, LcmRequest.class); - JsonObject input = new JsonObject(); - input.add("input", requestJson); - - return input; - } - - @Override - public LcmRequest deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { - return gsonPretty.fromJson(json.getAsJsonObject().get("input"), LcmRequest.class); - } - } - - public static class ResponseAdapter implements JsonSerializer<LcmResponse>, JsonDeserializer<LcmResponse> { - - @Override - public JsonElement serialize(LcmResponse src, Type typeOfSrc, JsonSerializationContext context) { - JsonElement responseJson = gsonPretty.toJsonTree(src, LcmResponse.class); - JsonObject output = new JsonObject(); - output.add("output", responseJson); - return output; - } - - @Override - public LcmResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { - return gsonPretty.fromJson(json.getAsJsonObject().get("output"), LcmResponse.class); - } - } - - public static class InstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> { - - @Override - public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { - return Instant.parse(json.getAsString()); - } - - @Override - public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) { - return new JsonPrimitive(src.toString()); - } - - } - - public static class InstantJunitAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> { - - @Override - public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { - return Instant.ofEpochMilli(json.getAsLong()); - } - - @Override - public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) { - return new JsonPrimitive(src.toEpochMilli()); - } - - } - -} diff --git a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/StatusCodeEnum.java b/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/StatusCodeEnum.java deleted file mode 100644 index d954789e8..000000000 --- a/controlloop/common/model-impl/appclcm/src/main/java/org/onap/policy/appclcm/util/StatusCodeEnum.java +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Samsung Electronics Co., Ltd. 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.appclcm.util; - -import java.util.HashMap; -import java.util.Map; - -public enum StatusCodeEnum { - ACCEPTED("ACCEPTED"), ERROR("ERROR"), REJECT("REJECT"), SUCCESS("SUCCESS"), FAILURE("FAILURE"), - PARTIAL_SUCCESS("PARTIAL SUCCESS"), PARTIAL_FAILURE("PARTIAL FAILURE"); - - private String name; - - StatusCodeEnum(final String name) { - this.name = name; - } - - public String toString() { - return this.name; - } - - /** - * Determine status enum from the code. - * - * @param statusCode integer code indicating the status - * @return enum representation of status code - */ - public static StatusCodeEnum fromStatusCode(final int statusCode) { - if (statusCode == 100) { - return ACCEPTED; - } - - if (statusCode == 200) { - return ERROR; - } - - if (isRejectStatusCode(statusCode)) { - return REJECT; - } - - if (statusCode == 400) { - return SUCCESS; - } - - if (isFailureStatusCode(statusCode)) { - return FAILURE; - } - - if (statusCode == 500) { - return PARTIAL_SUCCESS; - } - - if (isPartialFailureStatusCode(statusCode)) { - return PARTIAL_FAILURE; - } - - return null; - } - - private static boolean isRejectStatusCode(final int statusCode) { - return statusCode >= 300 && statusCode <= 313; - } - - private static boolean isFailureStatusCode(final int statusCode) { - return statusCode == 450 || (statusCode >= 401 && statusCode <= 406); - } - - private static boolean isPartialFailureStatusCode(final int statusCode) { - return statusCode >= 501 && statusCode <= 599; - } -}
\ No newline at end of file diff --git a/controlloop/common/model-impl/appclcm/src/main/resources/definitions.yaml b/controlloop/common/model-impl/appclcm/src/main/resources/definitions.yaml deleted file mode 100644 index 680a9929c..000000000 --- a/controlloop/common/model-impl/appclcm/src/main/resources/definitions.yaml +++ /dev/null @@ -1,118 +0,0 @@ -### -# ============LICENSE_START======================================================= -# appc -# ================================================================================ -# Copyright (C) 2017 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========================================================= -### - -Request: - type: object - properties: - CommonHeader: - type: object - properties: - TimeStamp: - type: string - APIver: - type: string - value: '1.01' - OriginatorID: - type: string - RequestID: - type: string - pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - SubRequestID: - type: string - Flags: - type: object - required: - - TimeStamp - - APIver - - OriginatorID - - RequestID - Action: - type: string - enum: - - Audit - - ActionStatus - - BlockAudits - - Configure - - HealthCheck - - Install - - LiveUpgrade - - Migrate - - ModifyConfig - - Query - - Rebuild - - Reconfigure - - Restart - - Rollback - - Scale - - Start - - Stop - - Sync - - Terminate - - Test - - Upgrade - TargetID: - type: string - ObjectID: - type: string - Payload: - type: object - required: - - CommonHeader - - Action - - TargetID -Response: - type: object - properties: - CommonHeader: - type: object - properties: - TimeStamp: - type: string - APIver: - type: string - OriginatorID: - type: string - RequestID: - type: string - SubRequestID: - type: string - Flags: - type: object - required: - - TimeStamp - - APIver - - OriginatorID - - RequestID - Status: - type: object - properties: - Code: - type: integer - Value: - type: string - required: - - Code - - Value - Payload: - type: object - required: - - CommonHeader - - Status - diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java deleted file mode 100644 index cee87077a..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/AppcLcmTest.java +++ /dev/null @@ -1,232 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * Copyright (C) 2017-2018 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.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.HashMap; -import java.util.UUID; - -import org.junit.Test; -import org.onap.policy.appclcm.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AppcLcmTest { - - private static final Logger logger = LoggerFactory.getLogger(AppcLcmTest.class); - - private static LcmRequestWrapper dmaapRequest; - private static LcmResponseWrapper dmaapResponse; - - static { - /* - * Construct an APPCLCM Request to be Serialized - */ - dmaapRequest = new LcmRequestWrapper(); - dmaapRequest.setCorrelationId("664be3d2-6c12-4f4b-a3e7-c349acced200" + "-" + "1"); - dmaapRequest.setRpcName("restart"); - dmaapRequest.setType("request"); - - dmaapResponse = new LcmResponseWrapper(); - dmaapResponse.setCorrelationId("664be3d2-6c12-4f4b-a3e7-c349acced200" + "-" + "1"); - dmaapResponse.setRpcName("restart"); - dmaapResponse.setType("response"); - - LcmRequest appcRequest = new LcmRequest(); - - appcRequest.setAction("restart"); - - HashMap<String, String> actionIdentifiers = new HashMap<>(); - actionIdentifiers.put("vnf-id", "trial-vnf-003"); - actionIdentifiers.put("vserver-id", "08f6c1f9-99e7-49f3-a662-c62b9f200d79"); - - appcRequest.setActionIdentifiers(actionIdentifiers); - - LcmCommonHeader commonHeader = new LcmCommonHeader(); - commonHeader.setRequestId(UUID.fromString("664be3d2-6c12-4f4b-a3e7-c349acced200")); - commonHeader.setSubRequestId("1"); - commonHeader.setOriginatorId("664be3d2-6c12-4f4b-a3e7-c349acced200"); - - appcRequest.setCommonHeader(commonHeader); - - appcRequest.setPayload(null); - - dmaapRequest.setBody(appcRequest); - - /* - * Construct an APPCLCM Response to be Serialized - */ - LcmResponse appcResponse = new LcmResponse(appcRequest); - appcResponse.getStatus().setCode(400); - appcResponse.getStatus().setMessage("Restart Successful"); - appcResponse.setPayload(null); - - dmaapResponse.setBody(appcResponse); - } - - @Test - public void testRequestSerialization() { - - /* - * Use the gson serializer to obtain json - */ - String jsonRequest = Serialization.gson.toJson(dmaapRequest, LcmRequestWrapper.class); - assertNotNull(jsonRequest); - - /* - * The serializer should have added an extra sub-tag called "input" that wraps the request - */ - assertTrue(jsonRequest.contains("input")); - - /* - * The common-header, request-id, and sub-request-id should exist - */ - assertTrue(jsonRequest.contains("common-header")); - assertTrue(jsonRequest.contains("request-id")); - assertTrue(jsonRequest.contains("sub-request-id")); - - /* - * action-identifiers should exist and contain a vnf-id - */ - assertTrue(jsonRequest.contains("action-identifiers")); - assertTrue(jsonRequest.contains("vnf-id")); - - /* - * The action sub-tag should exist - */ - assertTrue(jsonRequest.contains("action")); - - logger.debug("Request as JSON: " + jsonRequest + "\n\n"); - } - - @Test - public void testRequestDeserialization() { - - /* - * Convert the LCM request object into json so we have a string of json to use for testing - */ - String jsonRequest = Serialization.gson.toJson(dmaapRequest, LcmRequestWrapper.class); - - /* - * Use the serializer to convert the json string into a java object - */ - LcmRequestWrapper dmaapRequest = Serialization.gson.fromJson(jsonRequest, LcmRequestWrapper.class); - assertNotNull(dmaapRequest); - - /* - * The type of the DMAAP wrapper should be request - */ - assertEquals("request", dmaapRequest.getType()); - - /* - * The DMAAP wrapper must have a body as that is the true APPC request - */ - assertNotNull(dmaapRequest.getBody()); - LcmRequest appcRequest = dmaapRequest.getBody(); - assertNotNull(appcRequest); - - /* - * The common header should not be null - */ - assertNotNull(appcRequest.getCommonHeader()); - - /* - * The action should not be null and should be set to restart - */ - assertNotNull(appcRequest.getAction()); - assertEquals("restart", appcRequest.getAction()); - - /* - * The action-identifiers should not be null and should contain a vnf-id - */ - assertNotNull(appcRequest.getActionIdentifiers()); - assertNotNull(appcRequest.getActionIdentifiers().get("vnf-id")); - - logger.debug("Request as a Java Object: \n" + appcRequest.toString() + "\n\n"); - } - - @Test - public void testResponseSerialization() { - - /* - * Use the serializer to convert the object into json - */ - String jsonResponse = Serialization.gson.toJson(dmaapResponse, LcmResponseWrapper.class); - assertNotNull(jsonResponse); - - /* - * The serializer should have added an extra sub-tag called "input" that wraps the request - */ - assertTrue(jsonResponse.contains("output")); - - /* - * The response should contain a common-header, request-id, sub-request-id, and status - */ - assertTrue(jsonResponse.contains("common-header")); - assertTrue(jsonResponse.contains("request-id")); - assertTrue(jsonResponse.contains("sub-request-id")); - assertTrue(jsonResponse.contains("status")); - - logger.debug("Response as JSON: " + jsonResponse + "\n\n"); - } - - @Test - public void testResponseDeserialization() { - /* - * Convert the LCM response object into json so we have a string of json to use for testing - */ - String jsonResponse = Serialization.gson.toJson(dmaapResponse, LcmResponseWrapper.class); - - /* - * Use the serializer to convert the json string into a java object - */ - LcmResponseWrapper dmaapResponse = Serialization.gson.fromJson(jsonResponse, LcmResponseWrapper.class); - assertNotNull(dmaapResponse); - - /* - * The type of the DMAAP wrapper should be response - */ - assertEquals("response", dmaapResponse.getType()); - - /* - * The DMAAP wrapper must have a body as that is the true APPC response - */ - assertNotNull(dmaapResponse.getBody()); - LcmResponse appcResponse = dmaapResponse.getBody(); - assertNotNull(appcResponse); - - /* - * The common header should not be null - */ - assertNotNull(appcResponse.getCommonHeader()); - - /* - * The status should not be null and the status code should be 400 - */ - assertNotNull(appcResponse.getStatus()); - assertEquals(400, appcResponse.getStatus().getCode()); - - logger.debug("Response as a Java Object: \n" + appcResponse.toString() + "\n\n"); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java deleted file mode 100644 index d48771a5c..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.time.Instant; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.junit.Test; - -public class LcmCommonHeaderTest { - - @Test - public void testLcmCommonHeader() { - LcmCommonHeader commonHeader = new LcmCommonHeader(); - assertNotNull(commonHeader); - assertNotNull(new LcmCommonHeader(commonHeader)); - assertNotEquals(0, commonHeader.hashCode()); - - commonHeader.setApiVer("Kansas"); - assertEquals("Kansas", commonHeader.getApiVer()); - - Map<String, String> flagMap = new HashMap<>(); - commonHeader.setFlags(flagMap); - assertEquals(flagMap, commonHeader.getFlags()); - - commonHeader.setOriginatorId("Dorothy"); - assertEquals("Dorothy", commonHeader.getOriginatorId()); - - UUID requestId = UUID.randomUUID(); - commonHeader.setRequestId(requestId); - assertEquals(requestId, commonHeader.getRequestId()); - - commonHeader.setSubRequestId("Can I go home?"); - assertEquals("Can I go home?", commonHeader.getSubRequestId()); - - Instant timestamp = Instant.now(); - commonHeader.setTimeStamp(timestamp); - assertEquals(timestamp, commonHeader.getTimeStamp()); - - assertNotEquals(0, commonHeader.hashCode()); - - assertEquals("CommonHeader [timeStamp=", commonHeader.toString().substring(0, 24)); - - LcmCommonHeader copiedLcmCommonHeader = new LcmCommonHeader(); - copiedLcmCommonHeader.setApiVer(commonHeader.getApiVer()); - copiedLcmCommonHeader.setFlags(commonHeader.getFlags()); - copiedLcmCommonHeader.setOriginatorId(commonHeader.getOriginatorId()); - copiedLcmCommonHeader.setRequestId(commonHeader.getRequestId()); - copiedLcmCommonHeader.setSubRequestId(commonHeader.getSubRequestId()); - copiedLcmCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(commonHeader)); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - assertFalse(commonHeader.equals(null)); - assertFalse(commonHeader.equals("Hello")); - - LcmCommonHeader clonedLcmCommonHeader = new LcmCommonHeader(commonHeader); - clonedLcmCommonHeader.setApiVer(commonHeader.getApiVer()); - clonedLcmCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(clonedLcmCommonHeader)); - - commonHeader.setApiVer(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setApiVer(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setApiVer("Kansas"); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setApiVer("Kansas"); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - - commonHeader.setFlags(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setFlags(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setFlags(flagMap); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setFlags(flagMap); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - - commonHeader.setOriginatorId(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setOriginatorId(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setOriginatorId("Dorothy"); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setOriginatorId("Dorothy"); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - - commonHeader.setRequestId(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setRequestId(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setRequestId(requestId); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setRequestId(requestId); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - - commonHeader.setSubRequestId(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setSubRequestId(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setSubRequestId("Can I go home?"); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setSubRequestId("Can I go home?"); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - - commonHeader.setTimeStamp(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setTimeStamp(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setTimeStamp(timestamp); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setTimeStamp(timestamp); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java deleted file mode 100644 index 5cc817d5e..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - -public class LcmRequestTest { - - @Test - public void testLcmRequest() { - LcmRequest request = new LcmRequest(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - LcmCommonHeader commonHeader = new LcmCommonHeader(); - - request.setCommonHeader(commonHeader); - assertEquals(commonHeader, request.getCommonHeader()); - - request.setAction("Go to Oz"); - assertEquals("Go to Oz", request.getAction()); - - Map<String, String> actionIdentifiers = new HashMap<>(); - actionIdentifiers.put("North", "Good Witch"); - actionIdentifiers.put("West", "Bad Witch"); - - request.setActionIdentifiers(actionIdentifiers); - assertEquals(actionIdentifiers, request.getActionIdentifiers()); - - request.setPayload("The Emerald City"); - assertEquals("The Emerald City", request.getPayload()); - - assertNotEquals(0, request.hashCode()); - - assertEquals("Request [commonHeader=CommonHeader [timeStamp=", request.toString().substring(0, 46)); - - LcmRequest copiedLcmRequest = new LcmRequest(); - copiedLcmRequest.setCommonHeader(request.getCommonHeader()); - copiedLcmRequest.setAction(request.getAction()); - copiedLcmRequest.setActionIdentifiers(request.getActionIdentifiers()); - copiedLcmRequest.setPayload(request.getPayload()); - - assertTrue(request.equals(request)); - assertTrue(request.equals(copiedLcmRequest)); - assertFalse(request.equals(null)); - assertFalse(request.equals("Hello")); - - request.setCommonHeader(null); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setCommonHeader(null); - assertTrue(request.equals(copiedLcmRequest)); - request.setCommonHeader(commonHeader); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setCommonHeader(commonHeader); - assertTrue(request.equals(copiedLcmRequest)); - - request.setAction(null); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setAction(null); - assertTrue(request.equals(copiedLcmRequest)); - request.setAction("Go to Oz"); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setAction("Go to Oz"); - assertTrue(request.equals(copiedLcmRequest)); - - request.setActionIdentifiers(null); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setActionIdentifiers(null); - assertTrue(request.equals(copiedLcmRequest)); - request.setActionIdentifiers(actionIdentifiers); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setActionIdentifiers(actionIdentifiers); - assertTrue(request.equals(copiedLcmRequest)); - - request.setPayload(null); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setPayload(null); - assertTrue(request.equals(copiedLcmRequest)); - request.setPayload("The Emerald City"); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setPayload("The Emerald City"); - assertTrue(request.equals(copiedLcmRequest)); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestWrapperTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestWrapperTest.java deleted file mode 100644 index 42bb91876..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestWrapperTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class LcmRequestWrapperTest { - - @Test - public void testLcmRequestWrapperWrapper() { - assertNotNull(new LcmRequestWrapper(new LcmRequest())); - LcmRequestWrapper requestWrapper = new LcmRequestWrapper(); - assertNotNull(requestWrapper); - assertNotEquals(0, requestWrapper.hashCode()); - - LcmRequest request = new LcmRequest(); - - requestWrapper.setBody(request); - assertEquals(request, requestWrapper.getBody()); - - assertNotEquals(0, requestWrapper.hashCode()); - - assertEquals("RequestWrapper [body=Request [commonHeader=nul", requestWrapper.toString().substring(0, 46)); - - LcmRequestWrapper copiedLcmRequestWrapper = new LcmRequestWrapper(); - copiedLcmRequestWrapper.setBody(requestWrapper.getBody()); - - assertTrue(requestWrapper.equals(requestWrapper)); - assertTrue(requestWrapper.equals(copiedLcmRequestWrapper)); - assertFalse(requestWrapper.equals(null)); - assertFalse(requestWrapper.equals("Hello")); - - requestWrapper.setBody(null); - assertFalse(requestWrapper.equals(copiedLcmRequestWrapper)); - copiedLcmRequestWrapper.setBody(null); - assertTrue(requestWrapper.equals(copiedLcmRequestWrapper)); - requestWrapper.setBody(request); - assertFalse(requestWrapper.equals(copiedLcmRequestWrapper)); - copiedLcmRequestWrapper.setBody(request); - assertTrue(requestWrapper.equals(copiedLcmRequestWrapper)); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResonseCodeTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResonseCodeTest.java deleted file mode 100644 index b83fc8d79..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResonseCodeTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -public class LcmResonseCodeTest { - - @Test - public void testLcmResponseCode() { - assertNull(LcmResponseCode.toResponseValue(0)); - - assertEquals(LcmResponseCode.ACCEPTED, LcmResponseCode.toResponseValue(100)); - assertEquals(LcmResponseCode.ERROR, LcmResponseCode.toResponseValue(200)); - assertEquals(LcmResponseCode.REJECT, LcmResponseCode.toResponseValue(300)); - assertEquals(LcmResponseCode.SUCCESS, LcmResponseCode.toResponseValue(400)); - assertEquals(LcmResponseCode.FAILURE, LcmResponseCode.toResponseValue(450)); - assertEquals(LcmResponseCode.FAILURE, LcmResponseCode.toResponseValue(401)); - assertEquals(LcmResponseCode.FAILURE, LcmResponseCode.toResponseValue(406)); - assertEquals(LcmResponseCode.PARTIAL_SUCCESS, LcmResponseCode.toResponseValue(500)); - assertEquals(LcmResponseCode.PARTIAL_FAILURE, LcmResponseCode.toResponseValue(501)); - assertEquals(LcmResponseCode.PARTIAL_FAILURE, LcmResponseCode.toResponseValue(599)); - - assertEquals("100", new LcmResponseCode(100).toString()); - assertEquals("200", new LcmResponseCode(200).toString()); - assertEquals("300", new LcmResponseCode(300).toString()); - assertEquals("400", new LcmResponseCode(400).toString()); - assertEquals("450", new LcmResponseCode(450).toString()); - assertEquals("500", new LcmResponseCode(500).toString()); - assertEquals("510", new LcmResponseCode(510).toString()); - - assertEquals(300, new LcmResponseCode(300).getCode()); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java deleted file mode 100644 index c1a78e10a..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 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.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class LcmResponseStatusTest { - - @Test - public void testResonseStatus() { - LcmResponseStatus status = new LcmResponseStatus(); - assertNotNull(status); - assertNotEquals(0, status.hashCode()); - - status.setCode(1234); - assertEquals(1234, status.getCode()); - - status.setMessage("The wonderful land of Oz"); - assertEquals("The wonderful land of Oz", status.getMessage()); - - assertEquals("ResponseStatus [code=1234, message=The wonderfu", status.toString().substring(0, 47)); - - LcmResponseStatus copiedStatus = new LcmResponseStatus(); - copiedStatus.setCode(status.getCode()); - copiedStatus.setMessage(status.getMessage()); - - assertTrue(status.equals(status)); - assertTrue(status.equals(copiedStatus)); - assertFalse(status.equals(null)); - assertFalse(status.equals("Hello")); - - status.setCode(-1); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setCode(-1); - assertTrue(status.equals(copiedStatus)); - status.setCode(1234); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setCode(1234); - assertTrue(status.equals(copiedStatus)); - - status.setMessage(null); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setMessage(null); - assertTrue(status.equals(copiedStatus)); - status.setMessage("The wonderful land of Oz"); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setMessage("The wonderful land of Oz"); - assertTrue(status.equals(copiedStatus)); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java deleted file mode 100644 index 7583ee0c4..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appclcm - * ================================================================================ - * Copyright (C) 2017-2018 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.appclcm; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class LcmResponseTest { - - private static final String PAYLOAD = "payload"; - - @Test - public void testHashCode() { - LcmResponse response = new LcmResponse(); - assertTrue(response.hashCode() != 0); - response.setCommonHeader(new LcmCommonHeader()); - assertTrue(response.hashCode() != 0); - response.setPayload(PAYLOAD); - assertTrue(response.hashCode() != 0); - response.setStatus(null); - assertTrue(response.hashCode() != 0); - } - - @Test - public void testLcmResponse() { - LcmResponse response = new LcmResponse(); - assertNull(response.getCommonHeader()); - assertNull(response.getPayload()); - assertNotNull(response.getStatus()); - } - - @Test - public void testToString() { - LcmResponse response = new LcmResponse(); - assertFalse(response.toString().isEmpty()); - } - - @Test - public void testEqualsObject() { - LcmResponse response = new LcmResponse(); - assertTrue(response.equals(response)); - assertFalse(response.equals(null)); - assertFalse(response.equals(new Object())); - - LcmResponse response2 = new LcmResponse(); - assertTrue(response.equals(response2)); - - response.setCommonHeader(new LcmCommonHeader()); - assertFalse(response.equals(response2)); - response2.setCommonHeader(response.getCommonHeader()); - assertTrue(response.equals(response2)); - - response.setPayload(PAYLOAD); - assertFalse(response.equals(response2)); - response2.setPayload(response.getPayload()); - assertTrue(response.equals(response2)); - - response.setCommonHeader(null); - assertFalse(response.equals(response2)); - response2.setCommonHeader(null); - assertTrue(response.equals(response2)); - - response.setPayload(null); - assertFalse(response.equals(response2)); - response2.setPayload(response.getPayload()); - assertTrue(response.equals(response2)); - - response.setStatus(null); - assertFalse(response.equals(response2)); - response2.setStatus(response.getStatus()); - assertTrue(response.equals(response2)); - - LcmResponseStatus status = new LcmResponseStatus(); - status.setCode(5); - response.setStatus(status); - response2.setStatus(new LcmResponseStatus()); - assertFalse(response.equals(response2)); - } - - @Test - public void testResponseRequest() { - LcmRequest request = new LcmRequest(); - request.setCommonHeader(new LcmCommonHeader()); - request.setPayload(PAYLOAD); - - LcmResponse response = new LcmResponse(request); - - assertTrue(response.getPayload().equals(PAYLOAD)); - } - -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java deleted file mode 100644 index 2fc04794e..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017 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.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class LcmResponseWrapperTest { - - @Test - public void testLcmResponseWrapperWrapper() { - LcmResponseWrapper responseWrapper = new LcmResponseWrapper(); - assertNotNull(responseWrapper); - assertNotEquals(0, responseWrapper.hashCode()); - - LcmResponse response = new LcmResponse(); - - responseWrapper.setBody(response); - assertEquals(response, responseWrapper.getBody()); - - assertNotEquals(0, responseWrapper.hashCode()); - - assertEquals("ResponseWrapper [body=Response [commonHeader=n", responseWrapper.toString().substring(0, 46)); - - LcmResponseWrapper copiedLcmResponseWrapper = new LcmResponseWrapper(); - copiedLcmResponseWrapper.setBody(responseWrapper.getBody()); - - assertTrue(responseWrapper.equals(responseWrapper)); - assertTrue(responseWrapper.equals(copiedLcmResponseWrapper)); - assertFalse(responseWrapper.equals(null)); - assertFalse(responseWrapper.equals("Hello")); - - responseWrapper.setBody(null); - assertFalse(responseWrapper.equals(copiedLcmResponseWrapper)); - copiedLcmResponseWrapper.setBody(null); - assertTrue(responseWrapper.equals(copiedLcmResponseWrapper)); - responseWrapper.setBody(response); - assertFalse(responseWrapper.equals(copiedLcmResponseWrapper)); - copiedLcmResponseWrapper.setBody(response); - assertTrue(responseWrapper.equals(copiedLcmResponseWrapper)); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java deleted file mode 100644 index a12b7f775..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017 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.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class LcmWrapperTest { - - @Test - public void testLcmWrapper() { - LcmWrapper wrapper = new LcmWrapper(); - assertNotNull(wrapper); - assertNotEquals(0, wrapper.hashCode()); - - wrapper.setVersion("19.3.9"); - assertEquals("19.3.9", wrapper.getVersion()); - - wrapper.setCambriaPartition("The Emerald City"); - assertEquals("The Emerald City", wrapper.getCambriaPartition()); - - wrapper.setRpcName("Tornado"); - assertEquals("Tornado", wrapper.getRpcName()); - - wrapper.setCorrelationId("YellowBrickRoad"); - assertEquals("YellowBrickRoad", wrapper.getCorrelationId()); - - wrapper.setType("Munchkin"); - assertEquals("Munchkin", wrapper.getType()); - - assertNotEquals(0, wrapper.hashCode()); - - assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46)); - - LcmWrapper copiedLcmWrapper = new LcmWrapper(); - copiedLcmWrapper.setVersion(wrapper.getVersion()); - copiedLcmWrapper.setCambriaPartition(wrapper.getCambriaPartition()); - copiedLcmWrapper.setRpcName(wrapper.getRpcName()); - copiedLcmWrapper.setCorrelationId(wrapper.getCorrelationId()); - copiedLcmWrapper.setType(wrapper.getType()); - - assertTrue(wrapper.equals(wrapper)); - assertTrue(wrapper.equals(copiedLcmWrapper)); - assertFalse(wrapper.equals(null)); - assertFalse(wrapper.equals("Hello")); - - wrapper.setVersion(null); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setVersion(null); - assertTrue(wrapper.equals(copiedLcmWrapper)); - wrapper.setVersion("19.3.9"); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setVersion("19.3.9"); - assertTrue(wrapper.equals(copiedLcmWrapper)); - - wrapper.setCambriaPartition(null); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setCambriaPartition(null); - assertTrue(wrapper.equals(copiedLcmWrapper)); - wrapper.setCambriaPartition("The Emerald City"); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setCambriaPartition("The Emerald City"); - assertTrue(wrapper.equals(copiedLcmWrapper)); - - wrapper.setRpcName(null); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setRpcName(null); - assertTrue(wrapper.equals(copiedLcmWrapper)); - wrapper.setRpcName("Tornado"); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setRpcName("Tornado"); - assertTrue(wrapper.equals(copiedLcmWrapper)); - - wrapper.setCorrelationId(null); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setCorrelationId(null); - assertTrue(wrapper.equals(copiedLcmWrapper)); - wrapper.setCorrelationId("YellowBrickRoad"); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setCorrelationId("YellowBrickRoad"); - assertTrue(wrapper.equals(copiedLcmWrapper)); - - wrapper.setType(null); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setType(null); - assertTrue(wrapper.equals(copiedLcmWrapper)); - wrapper.setType("Munchkin"); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setType("Munchkin"); - assertTrue(wrapper.equals(copiedLcmWrapper)); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java deleted file mode 100644 index 62f98644f..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017 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.appclcm.util; - -import static org.junit.Assert.assertEquals; - -import java.time.Instant; -import java.time.ZoneId; -import java.time.ZonedDateTime; - -import org.junit.Test; - -public class SerializationTest { - - @Test - public void test() { - String nameString = "Dorothy"; - String jsonName = Serialization.gsonPretty.toJson(nameString, String.class); - assertEquals("\"Dorothy\"", jsonName); - String jsonInOutName = Serialization.gsonPretty.fromJson(jsonName, String.class); - assertEquals("Dorothy", jsonInOutName); - - Instant instant0 = Instant.ofEpochMilli(1516127215000L); - String instantString0 = Serialization.gsonPretty.toJson(instant0, Instant.class); - assertEquals("\"2018-01-16T18:26:55Z\"", instantString0); - Instant outInstant0 = Serialization.gsonPretty.fromJson(instantString0, Instant.class); - assertEquals(instant0, outInstant0); - - Instant instant1 = Instant.ofEpochMilli(1516127215000L); - String instantString1 = Serialization.gsonJunit.toJson(instant1, Instant.class); - assertEquals("1516127215000", instantString1); - Instant outInstant1 = Serialization.gsonJunit.fromJson(instantString1, Instant.class); - assertEquals(instant1, outInstant1); - - ZonedDateTime zdt = ZonedDateTime.ofInstant(instant0, ZoneId.of("UTC")); - String zdtString = Serialization.gsonPretty.toJson(zdt, ZonedDateTime.class); - assertEquals("{\n \"dateTime\": {\n \"date\":", zdtString.substring(0, 29)); - } -} diff --git a/controlloop/common/model-impl/events/README.md b/controlloop/common/model-impl/events/README.md deleted file mode 100644 index 6ebd725d2..000000000 --- a/controlloop/common/model-impl/events/README.md +++ /dev/null @@ -1,11 +0,0 @@ -Copyright 2018 AT&T Intellectual Property. All rights reserved. -This file is licensed under the CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE -Full license text at https://creativecommons.org/licenses/by/4.0/legalcode - -Policy Control Loop - -This is the implementation of the Policy's Control Loop messages. This includes the Events consumed and Notifications produced by the ONAP Policy Platform. - - - - diff --git a/controlloop/common/model-impl/events/pom.xml b/controlloop/common/model-impl/events/pom.xml deleted file mode 100644 index cfe8c4ad7..000000000 --- a/controlloop/common/model-impl/events/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - events in model-impl - ================================================================================ - Copyright (C) 2017-2018 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========================================================= - --> - -<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.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>model-impl</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>events</artifactId> - - <dependencies> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> -</project> diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java deleted file mode 100644 index 944bef754..000000000 --- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java +++ /dev/null @@ -1,192 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop; - -import com.google.gson.annotations.SerializedName; -import java.io.Serializable; -import java.util.UUID; - -public abstract class ControlLoopEvent implements Serializable { - - private static final long serialVersionUID = 2391252138583119195L; - - @SerializedName("closedLoopControlName") - private String closedLoopControlName; - - @SerializedName("version") - private String version = "1.0.2"; - - @SerializedName("requestID") - private UUID requestId; - - @SerializedName("closedLoopEventClient") - private String closedLoopEventClient; - - @SerializedName("target_type") - private ControlLoopTargetType targetType; - - @SerializedName("target") - private String target; - - @SerializedName("from") - private String from; - - @SerializedName("policyScope") - private String policyScope; - - @SerializedName("policyName") - private String policyName; - - @SerializedName("policyVersion") - private String policyVersion; - - @SerializedName("closedLoopEventStatus") - private ControlLoopEventStatus closedLoopEventStatus; - - @SerializedName("payload") - private String payload; - - public ControlLoopEvent() { - - } - - /** - * Construct an instace from an existing instance. - * - * @param event the existing instance - */ - public ControlLoopEvent(ControlLoopEvent event) { - if (event == null) { - return; - } - this.closedLoopControlName = event.closedLoopControlName; - this.requestId = event.requestId; - this.closedLoopEventClient = event.closedLoopEventClient; - this.targetType = event.targetType; - this.target = event.target; - this.from = event.from; - this.policyScope = event.policyScope; - this.policyName = event.policyName; - this.policyVersion = event.policyVersion; - this.closedLoopEventStatus = event.closedLoopEventStatus; - this.payload = event.payload; - } - - public boolean isEventStatusValid() { - return this.closedLoopEventStatus != null; - } - - public String getClosedLoopControlName() { - return closedLoopControlName; - } - - public void setClosedLoopControlName(String closedLoopControlName) { - this.closedLoopControlName = closedLoopControlName; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public UUID getRequestId() { - return requestId; - } - - public void setRequestId(UUID requestId) { - this.requestId = requestId; - } - - public String getClosedLoopEventClient() { - return closedLoopEventClient; - } - - public void setClosedLoopEventClient(String closedLoopEventClient) { - this.closedLoopEventClient = closedLoopEventClient; - } - - public ControlLoopTargetType getTargetType() { - return targetType; - } - - public void setTargetType(ControlLoopTargetType targetType) { - this.targetType = targetType; - } - - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - public String getFrom() { - return from; - } - - public void setFrom(String from) { - this.from = from; - } - - public String getPolicyScope() { - return policyScope; - } - - public void setPolicyScope(String policyScope) { - this.policyScope = policyScope; - } - - public String getPolicyName() { - return policyName; - } - - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - - public String getPolicyVersion() { - return policyVersion; - } - - public void setPolicyVersion(String policyVersion) { - this.policyVersion = policyVersion; - } - - public ControlLoopEventStatus getClosedLoopEventStatus() { - return closedLoopEventStatus; - } - - public void setClosedLoopEventStatus(ControlLoopEventStatus closedLoopEventStatus) { - this.closedLoopEventStatus = closedLoopEventStatus; - } - - public String getPayload() { - return payload; - } - - public void setPayload(String payload) { - this.payload = payload; - } -} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java deleted file mode 100644 index f439e70ab..000000000 --- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop; - -public enum ControlLoopEventStatus { - ONSET("ONSET"), ABATED("ABATED"); - - private String status; - - private ControlLoopEventStatus(String status) { - this.status = status; - } - - @Override - public String toString() { - return this.status; - } - - /** - * Convert a String status to a ControlLoopEventStatus. - * - * @param status the String status - * @return the ControlLoopEventStatus - */ - public static ControlLoopEventStatus toStatus(String status) { - if (ONSET.status.equalsIgnoreCase(status)) { - return ONSET; - } - if (ABATED.status.equalsIgnoreCase(status)) { - return ABATED; - } - // - // In case DCAE uses the old abatement - // - if ("abatement".equalsIgnoreCase(status)) { - return ABATED; - } - return null; - } - -} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java deleted file mode 100644 index 8c670fe9e..000000000 --- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java +++ /dev/null @@ -1,190 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop; - -import java.io.Serializable; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.LinkedList; -import java.util.List; -import java.util.UUID; - -public abstract class ControlLoopNotification implements Serializable { - - private static final long serialVersionUID = 7538596984567127915L; - - private String closedLoopControlName; - private String version = "1.0.2"; - private UUID requestId; - private String closedLoopEventClient; - private ControlLoopTargetType targetType; - private String target; - private String from; - private String policyScope; - private String policyName; - private String policyVersion; - private ControlLoopNotificationType notification; - private String message; - private ZonedDateTime notificationTime = ZonedDateTime.now(ZoneOffset.UTC); - private Integer opsClTimer; - private List<ControlLoopOperation> history = new LinkedList<>(); - - public ControlLoopNotification() { - - } - - /** - * Construct an instance. - * - * @param event the event - */ - public ControlLoopNotification(ControlLoopEvent event) { - if (event == null) { - return; - } - - this.setClosedLoopControlName(event.getClosedLoopControlName()); - this.setRequestId(event.getRequestId()); - this.setClosedLoopEventClient(event.getClosedLoopEventClient()); - this.setTargetType(event.getTargetType()); - this.setTarget(event.getTarget()); - } - - public String getClosedLoopControlName() { - return closedLoopControlName; - } - - public void setClosedLoopControlName(String closedLoopControlName) { - this.closedLoopControlName = closedLoopControlName; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public UUID getRequestId() { - return requestId; - } - - public void setRequestId(UUID requestId) { - this.requestId = requestId; - } - - public String getClosedLoopEventClient() { - return closedLoopEventClient; - } - - public void setClosedLoopEventClient(String closedLoopEventClient) { - this.closedLoopEventClient = closedLoopEventClient; - } - - public ControlLoopTargetType getTargetType() { - return targetType; - } - - public void setTargetType(ControlLoopTargetType targetType) { - this.targetType = targetType; - } - - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - public String getFrom() { - return from; - } - - public void setFrom(String from) { - this.from = from; - } - - public String getPolicyScope() { - return policyScope; - } - - public void setPolicyScope(String policyScope) { - this.policyScope = policyScope; - } - - public String getPolicyName() { - return policyName; - } - - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - - public String getPolicyVersion() { - return policyVersion; - } - - public void setPolicyVersion(String policyVersion) { - this.policyVersion = policyVersion; - } - - public ControlLoopNotificationType getNotification() { - return notification; - } - - public void setNotification(ControlLoopNotificationType notification) { - this.notification = notification; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public ZonedDateTime getNotificationTime() { - return notificationTime; - } - - public void setNotificationTime(ZonedDateTime notificationTime) { - this.notificationTime = notificationTime; - } - - public Integer getOpsClTimer() { - return opsClTimer; - } - - public void setOpsClTimer(Integer opsClTimer) { - this.opsClTimer = opsClTimer; - } - - public List<ControlLoopOperation> getHistory() { - return history; - } - - public void setHistory(List<ControlLoopOperation> history) { - this.history = history; - } -} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java deleted file mode 100644 index 9f5a41d39..000000000 --- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop; - -public enum ControlLoopNotificationType { - ACTIVE("ACTIVE"), REJECTED("REJECTED"), OPERATION("OPERATION"), OPERATION_SUCCESS( - "OPERATION: SUCCESS"), OPERATION_FAILURE("OPERATION: FAILURE"), FINAL_FAILURE( - "FINAL: FAILURE"), FINAL_SUCCESS("FINAL: SUCCESS"), FINAL_OPENLOOP("FINAL: OPENLOOP"); - - private String type; - - private ControlLoopNotificationType(String type) { - this.type = type; - } - - @Override - public String toString() { - return this.type; - } - - /** - * Convert a String type to a ControlLoopNotificationType. - * - * @param type the String type - * @return the ControlLoopNotificationType - */ - public static ControlLoopNotificationType toType(String type) { - if (ACTIVE.toString().equals(type)) { - return ACTIVE; - } - if (REJECTED.toString().equals(type)) { - return REJECTED; - } - if (OPERATION.toString().equals(type)) { - return OPERATION; - } - if (OPERATION_SUCCESS.toString().equals(type)) { - return OPERATION_SUCCESS; - } - if (OPERATION_FAILURE.toString().equals(type)) { - return OPERATION_FAILURE; - } - if (FINAL_FAILURE.toString().equals(type)) { - return FINAL_FAILURE; - } - if (FINAL_SUCCESS.toString().equals(type)) { - return FINAL_SUCCESS; - } - if (FINAL_OPENLOOP.toString().equals(type)) { - return FINAL_OPENLOOP; - } - return null; - } - -} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java deleted file mode 100644 index 3ef731687..000000000 --- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java +++ /dev/null @@ -1,229 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop; - -import java.io.Serializable; -import java.time.Instant; - -public class ControlLoopOperation implements Serializable { - - private static final long serialVersionUID = 8662706581293017099L; - - private String actor; - private String operation; - private String target; - private Instant start = Instant.now(); - private Instant end; - private String subRequestId; - private String outcome; - private String message; - - public ControlLoopOperation() { - - } - - /** - * Construct an instance from an existing instance. - * - * @param op the existing instance - */ - public ControlLoopOperation(ControlLoopOperation op) { - if (op == null) { - return; - } - - this.actor = op.actor; - this.operation = op.operation; - this.target = op.target; - this.start = op.start; - this.end = op.end; - this.subRequestId = op.subRequestId; - this.outcome = op.outcome; - this.message = op.message; - } - - public String toMessage() { - return "actor=" + actor + ",operation=" + operation + ",target=" + target + ",subRequestId=" + subRequestId; - } - - public String toHistory() { - return "actor=" + actor + ",operation=" + operation + ",target=" + target + ",start=" + start + ",end=" + end - + ",subRequestId=" + subRequestId + ",outcome=" + outcome + ",message=" + message; - } - - public String getActor() { - return actor; - } - - public void setActor(String actor) { - this.actor = actor; - } - - public String getOperation() { - return operation; - } - - public void setOperation(String operation) { - this.operation = operation; - } - - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - public Instant getStart() { - return start; - } - - public void setStart(Instant start) { - this.start = start; - } - - public Instant getEnd() { - return end; - } - - public void setEnd(Instant end) { - this.end = end; - } - - public String getSubRequestId() { - return subRequestId; - } - - public void setSubRequestId(String subRequestId) { - this.subRequestId = subRequestId; - } - - public String getOutcome() { - return outcome; - } - - public void setOutcome(String outcome) { - this.outcome = outcome; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public String toString() { - return "ControlLoopOperation [actor=" + actor + ", operation=" + operation + ", target=" + target + ", start=" - + start + ", end=" + end + ", subRequestId=" + subRequestId + ", outcome=" + outcome + ", message=" - + message + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((actor == null) ? 0 : actor.hashCode()); - result = prime * result + ((end == null) ? 0 : end.hashCode()); - result = prime * result + ((message == null) ? 0 : message.hashCode()); - result = prime * result + ((operation == null) ? 0 : operation.hashCode()); - result = prime * result + ((outcome == null) ? 0 : outcome.hashCode()); - result = prime * result + ((start == null) ? 0 : start.hashCode()); - result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode()); - result = prime * result + ((target == null) ? 0 : target.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ControlLoopOperation other = (ControlLoopOperation) obj; - if (actor == null) { - if (other.actor != null) { - return false; - } - } else if (!actor.equals(other.actor)) { - return false; - } - if (end == null) { - if (other.end != null) { - return false; - } - } else if (!end.equals(other.end)) { - return false; - } - if (message == null) { - if (other.message != null) { - return false; - } - } else if (!message.equals(other.message)) { - return false; - } - if (operation == null) { - if (other.operation != null) { - return false; - } - } else if (!operation.equals(other.operation)) { - return false; - } - if (outcome == null) { - if (other.outcome != null) { - return false; - } - } else if (!outcome.equals(other.outcome)) { - return false; - } - if (start == null) { - if (other.start != null) { - return false; - } - } else if (!start.equals(other.start)) { - return false; - } - if (subRequestId == null) { - if (other.subRequestId != null) { - return false; - } - } else if (!subRequestId.equals(other.subRequestId)) { - return false; - } - if (target == null) { - if (other.target != null) { - return false; - } - } else if (!target.equals(other.target)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java deleted file mode 100644 index 0bdc5cace..000000000 --- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop; - -import java.util.UUID; - -public class ControlLoopOperationWrapper { - - private UUID requestId; - private ControlLoopOperation operation; - - public ControlLoopOperationWrapper() { - - } - - public ControlLoopOperationWrapper(UUID requestId, ControlLoopOperation operation) { - this.requestId = requestId; - this.operation = operation; - } - - public UUID getRequestId() { - return requestId; - } - - public void setRequestId(UUID requestId) { - this.requestId = requestId; - } - - public ControlLoopOperation getOperation() { - return operation; - } - - public void setOperation(ControlLoopOperation operation) { - this.operation = operation; - } -} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopResponse.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopResponse.java deleted file mode 100644 index 483aaacfa..000000000 --- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopResponse.java +++ /dev/null @@ -1,142 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2019 Wipro Limited 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.controlloop; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.UUID; - -public class ControlLoopResponse implements Serializable { - - private static final long serialVersionUID = 2391252138583119195L; - - @SerializedName("closedLoopControlName") - private String closedLoopControlName; - - @SerializedName("version") - private String version = "1.0.0"; - - @SerializedName("requestID") - private UUID requestId; - - @SerializedName("target") - private String target; - - @SerializedName("from") - private String from; - - @SerializedName("policyName") - private String policyName; - - @SerializedName("policyVersion") - private String policyVersion; - - @SerializedName("payload") - private String payload; - - public ControlLoopResponse() { - - } - - /** - * Construct an instace from an existing instance. - * - * @param response - * the existing instance - */ - public ControlLoopResponse(ControlLoopResponse response) { - if (response == null) { - return; - } - this.closedLoopControlName = response.closedLoopControlName; - this.requestId = response.requestId; - this.target = response.target; - this.from = response.from; - this.policyName = response.policyName; - this.policyVersion = response.policyVersion; - this.payload = response.payload; - } - - public String getClosedLoopControlName() { - return closedLoopControlName; - } - - public void setClosedLoopControlName(String closedLoopControlName) { - this.closedLoopControlName = closedLoopControlName; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public UUID getRequestId() { - return requestId; - } - - public void setRequestId(UUID requestId) { - this.requestId = requestId; - } - - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - public String getFrom() { - return from; - } - - public void setFrom(String from) { - this.from = from; - } - - public String getPolicyName() { - return policyName; - } - - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - - public String getPolicyVersion() { - return policyVersion; - } - - public void setPolicyVersion(String policyVersion) { - this.policyVersion = policyVersion; - } - - public String getPayload() { - return payload; - } - - public void setPayload(String payload) { - this.payload = payload; - } -} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java deleted file mode 100644 index 4782654fc..000000000 --- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop; - -public enum ControlLoopTargetType { - VM("VM"), VF("VF"), VFC("VFC"), VNF("VNF"); - - private String type; - - private ControlLoopTargetType(String type) { - this.type = type; - } - - @Override - public String toString() { - return this.type; - } - - /** - * Convert a String type to a ControlLoopTargetType. - * - * @param type the String type - * @return the ControlLoopTargetType - */ - public static ControlLoopTargetType toType(String type) { - if (VM.toString().equals(type)) { - return VM; - } - if (VF.toString().equals(type)) { - return VF; - } - if (VFC.toString().equals(type)) { - return VFC; - } - if (VNF.toString().equals(type)) { - return VNF; - } - - return null; - } -} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java deleted file mode 100644 index 9cb85ae7f..000000000 --- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop; - -public class PhysicalControlLoopEvent extends ControlLoopEvent { - private static final long serialVersionUID = -7282930271094849487L; - - public PhysicalControlLoopEvent() {} - - /** - * Construct an instance from an existing instance. - * - * @param event the existing instance - */ - public PhysicalControlLoopEvent(PhysicalControlLoopEvent event) { - super(event); - } -} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java deleted file mode 100644 index 0b5db3a1f..000000000 --- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop; - -public class PhysicalControlLoopNotification extends ControlLoopNotification { - private static final long serialVersionUID = 8105197217140032892L; - - public PhysicalControlLoopNotification() {} - - /** - * Construct an instance from an existing instance. - * - * @param event the existing instance - */ - public PhysicalControlLoopNotification(PhysicalControlLoopEvent event) { - super(event); - } - -} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java deleted file mode 100644 index b5ae50ac8..000000000 --- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop; - -import com.google.gson.annotations.SerializedName; - -import java.time.Instant; -import java.util.HashMap; -import java.util.Map; - -public class VirtualControlLoopEvent extends ControlLoopEvent { - - private static final long serialVersionUID = -5752405682246066226L; - - @SerializedName("closedLoopAlarmStart") - private Instant closedLoopAlarmStart; - - @SerializedName("closedLoopAlarmEnd") - private Instant closedLoopAlarmEnd; - - @SerializedName("AAI") - private Map<String, String> aai = new HashMap<>(); - - public VirtualControlLoopEvent() {} - - - /** - * Construct an instance from an existing instance. - * - * @param event the existing instance - */ - public VirtualControlLoopEvent(VirtualControlLoopEvent event) { - super(event); - if (event == null) { - return; - } - if (event.aai != null) { - this.aai = new HashMap<>(event.aai); - } - this.closedLoopAlarmStart = event.closedLoopAlarmStart; - this.closedLoopAlarmEnd = event.closedLoopAlarmEnd; - } - - public Instant getClosedLoopAlarmStart() { - return closedLoopAlarmStart; - } - - public void setClosedLoopAlarmStart(Instant closedLoopAlarmStart) { - this.closedLoopAlarmStart = closedLoopAlarmStart; - } - - public Instant getClosedLoopAlarmEnd() { - return closedLoopAlarmEnd; - } - - public void setClosedLoopAlarmEnd(Instant closedLoopAlarmEnd) { - this.closedLoopAlarmEnd = closedLoopAlarmEnd; - } - - public Map<String, String> getAai() { - return aai; - } - - public void setAai(Map<String, String> aai) { - this.aai = aai; - } -} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java deleted file mode 100644 index 71a901505..000000000 --- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop; - -import com.google.gson.annotations.SerializedName; - -import java.time.Instant; -import java.util.HashMap; -import java.util.Map; - -public class VirtualControlLoopNotification extends ControlLoopNotification { - - private static final long serialVersionUID = 5354756047932144017L; - - @SerializedName("AAI") - private Map<String, String> aai = new HashMap<>(); - - @SerializedName("closedLoopAlarmStart") - private Instant closedLoopAlarmStart; - - @SerializedName("closedLoopAlarmEnd") - private Instant closedLoopAlarmEnd; - - public VirtualControlLoopNotification() {} - - /** - * Construct an instance. - * - * @param event the event - */ - public VirtualControlLoopNotification(VirtualControlLoopEvent event) { - super(event); - if (event == null) { - return; - } - if (event.getAai() != null) { - this.setAai(new HashMap<>(event.getAai())); - } - this.closedLoopAlarmStart = event.getClosedLoopAlarmStart(); - this.closedLoopAlarmEnd = event.getClosedLoopAlarmEnd(); - } - - public Map<String, String> getAai() { - return aai; - } - - public void setAai(Map<String, String> aai) { - this.aai = aai; - } - - public Instant getClosedLoopAlarmStart() { - return closedLoopAlarmStart; - } - - public void setClosedLoopAlarmStart(Instant closedLoopAlarmStart) { - this.closedLoopAlarmStart = closedLoopAlarmStart; - } - - public Instant getClosedLoopAlarmEnd() { - return closedLoopAlarmEnd; - } - - public void setClosedLoopAlarmEnd(Instant closedLoopAlarmEnd) { - this.closedLoopAlarmEnd = closedLoopAlarmEnd; - } -} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/params/ControlLoopParams.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/params/ControlLoopParams.java deleted file mode 100644 index ab93f5e9b..000000000 --- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/params/ControlLoopParams.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * AppcLcmActorServiceProvider - * ================================================================================ - * Copyright (C) 2018 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.controlloop.params; - -import java.io.Serializable; - -public class ControlLoopParams implements Serializable { - - private static final long serialVersionUID = 970755684770982776L; - - private String closedLoopControlName; - private String controlLoopYaml; - private String policyName; - private String policyScope; - private String policyVersion; - - public ControlLoopParams() { - super(); - } - - /** - * Construct an instance from an existing instance. - * - * @param params the existing instance - */ - public ControlLoopParams(ControlLoopParams params) { - this.closedLoopControlName = params.closedLoopControlName; - this.controlLoopYaml = params.controlLoopYaml; - this.policyName = params.policyName; - this.policyScope = params.policyScope; - this.policyVersion = params.policyVersion; - } - - public String getClosedLoopControlName() { - return closedLoopControlName; - } - - public void setClosedLoopControlName(String closedLoopControlName) { - this.closedLoopControlName = closedLoopControlName; - } - - public String getControlLoopYaml() { - return controlLoopYaml; - } - - public void setControlLoopYaml(String controlLoopYaml) { - this.controlLoopYaml = controlLoopYaml; - } - - public String getPolicyName() { - return policyName; - } - - public void setPolicyName(String policyName) { - this.policyName = policyName; - } - - public String getPolicyScope() { - return policyScope; - } - - public void setPolicyScope(String policyScope) { - this.policyScope = policyScope; - } - - public String getPolicyVersion() { - return policyVersion; - } - - public void setPolicyVersion(String policyVersion) { - this.policyVersion = policyVersion; - } - -} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java deleted file mode 100644 index 4bbab7a50..000000000 --- a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.util; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -import java.lang.reflect.Type; -import java.time.Instant; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; - -import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.ControlLoopTargetType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class Serialization { - public static final Gson gson = - new GsonBuilder().disableHtmlEscaping().registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter()) - .registerTypeAdapter(Instant.class, new GsonInstantAdapter()) - .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter()) - .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter()).create(); - - - public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() - .registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter()) - .registerTypeAdapter(Instant.class, new GsonInstantAdapter()) - .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter()) - .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter()).create(); - - public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() - .registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter()) - .registerTypeAdapter(Instant.class, new GsonInstantAdapter()) - .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter()).create(); - - private Serialization() {} - - public static class NotificationTypeAdapter - implements JsonSerializer<ControlLoopNotificationType>, JsonDeserializer<ControlLoopNotificationType> { - @Override - public JsonElement serialize(ControlLoopNotificationType src, Type typeOfSrc, - JsonSerializationContext context) { - return new JsonPrimitive(src.toString()); - } - - @Override - public ControlLoopNotificationType deserialize(JsonElement json, Type typeOfT, - JsonDeserializationContext context) { - return ControlLoopNotificationType.toType(json.getAsString()); - } - } - - public static class TargetTypeAdapter - implements JsonSerializer<ControlLoopTargetType>, JsonDeserializer<ControlLoopTargetType> { - @Override - public JsonElement serialize(ControlLoopTargetType src, Type typeOfSrc, JsonSerializationContext context) { - return new JsonPrimitive(src.toString()); - } - - @Override - public ControlLoopTargetType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { - return ControlLoopTargetType.toType(json.getAsString()); - } - } - - public static class GsonUtcAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> { - private static final Logger logger = LoggerFactory.getLogger(GsonUtcAdapter.class); - public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx"); - - @Override - public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context) { - try { - return ZonedDateTime.parse(element.getAsString(), format); - } catch (Exception e) { - logger.error(e.getMessage(), e); - } - return null; - } - - @Override - public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) { - return new JsonPrimitive(datetime.format(format)); - } - } - - public static class GsonInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> { - - @Override - public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { - return Instant.ofEpochMilli(json.getAsLong()); - } - - @Override - public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) { - return new JsonPrimitive(src.toEpochMilli()); - } - - } - -} diff --git a/controlloop/common/model-impl/events/src/main/resources/definitions.yaml b/controlloop/common/model-impl/events/src/main/resources/definitions.yaml deleted file mode 100644 index e7f147300..000000000 --- a/controlloop/common/model-impl/events/src/main/resources/definitions.yaml +++ /dev/null @@ -1,127 +0,0 @@ -# Copyright 2018 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. -AAI: - type: object - properties: - AICVServerSelfLink: - type: string - VNF_NAME: - type: string - AICVMID: - type: string - AICTenantID: - type: string - LOC_ID: - type: string - in_maint: - type: boolean - AICIdentity: - type: string - Prov_status: - type: string - OAM_IPV4: - type: string - is_closed_loop_disabled: - type: boolean - VM_NAME: - type: string - OAM_IPV6: - type: string - required: - - AICVServerSelfLink - - AICIdentity - - is_closed_loop_disabled -ControlLoop: - type: object - description: Common fields for control loop events and notifications - properties: - closedLoopControlName: - type: string - description: A UNIQUE string identifying the Closed Loop ID this event is for. There are no semantics behind this string. - serviceInstance: - $ref: '../../../../sdc/src/main/resources/definitions.yaml#/serviceInstance' - resourceInstance: - $ref: '../../../../sdc/src/main/resources/definitions.yaml#/resourceInstance' - requestID: - type: string - description: This is required via ONAP Platform Logging Requirements. - pattern: /[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}/ - triggerID: - type: string - description: ID that maps back to Highland Park. Concatenation between eventID and firstEPOCH. - triggerSourceName: - type: string - description: pulled from eventSourceName of trigger H.P. alarm. The contents of this field should also be contained in the AAI Json sub-tag (see below). - closedLoopAlarmStart: - type: string - description: firstEpoch. UTC Timestamp when this event was detected by DCAE. Conform to ONAP Logging requirements. - closedLoopAlarmEnd: - type: string - description: lastEpoch. UTC Timestamp when this event was detected as cleared by DCAE. Conform to ONAP Logging requirements. - closedLoopEventClient: - type: string - description: Open DCAE sub-system that detected the event and published this event message. - target: - type: string - description: The target entity that is being administered. This could be VM_NAME, VNF_NAME, etc. This should map to a field name in the AAI sub-tag shown below. - AAI: - $ref: '#/AAI' - from: - type: string - policyScope: - type: string - policyName: - type: string - policyVersion: - type: string - required: - - closedLoopControlName - - requestID - - triggerID - - triggerSourceName - - closedLoopAlarmStart - - closedLoopEventClient - - target - - AAI - - from - - policyScope - - policyName - - policyVersion -Event: - allOf: - - $ref: '#/ControlLoop' - - properties: - closedLoopEventStatus: - type: string - description: The status for the event within Open DCAE. A value of “ONSET” indicates the event has been encountered. “ABATED” indicates the event has been abated. - valid_values: - - ONSET - - ABATEMENT - - required: - - closedLoopEventStatus -Notification: - - $ref: '#/ControlLoop' - - properties: - notification: - type: string - notificationTime: - type: string - message: - type: string - OPS_CL_timer: - type: int - - required: - - notification - - notificationTime - - OPS_CL_timer diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopEventStatusTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopEventStatusTest.java deleted file mode 100644 index b4944fc42..000000000 --- a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopEventStatusTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2018 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.controlloop; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - -import org.junit.Test; - -public class ControlLoopEventStatusTest { - - @Test - public void test() { - ControlLoopEventStatus status = ControlLoopEventStatus.ABATED; - assertEquals(ControlLoopEventStatus.ABATED, ControlLoopEventStatus.toStatus(status.toString())); - assertNotEquals(ControlLoopEventStatus.ONSET, ControlLoopEventStatus.toStatus(status.toString())); - - status = ControlLoopEventStatus.ONSET; - assertEquals(ControlLoopEventStatus.ONSET, ControlLoopEventStatus.toStatus(status.toString())); - assertNotEquals(ControlLoopEventStatus.ABATED, ControlLoopEventStatus.toStatus(status.toString())); - assertEquals(ControlLoopEventStatus.ABATED, ControlLoopEventStatus.toStatus("abatement")); - } -} diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopEventTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopEventTest.java deleted file mode 100644 index 9da12aaab..000000000 --- a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopEventTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2018 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.controlloop; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.UUID; -import org.junit.Test; - -public class ControlLoopEventTest { - - private class TestControlLoopEvent extends ControlLoopEvent { - private static final long serialVersionUID = 1L; - - public TestControlLoopEvent() { - super(); - } - - public TestControlLoopEvent(ControlLoopEvent event) { - super(event); - } - } - - @Test - public void test() { - ControlLoopEvent event = new TestControlLoopEvent(); - - assertEquals("1.0.2", event.getVersion()); - - event = new TestControlLoopEvent(null); - assertEquals("1.0.2", event.getVersion()); - - event.setClosedLoopControlName("name"); - assertEquals("name", event.getClosedLoopControlName()); - - event.setClosedLoopEventClient("client"); - assertEquals("client", event.getClosedLoopEventClient()); - - event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); - assertEquals(ControlLoopEventStatus.ONSET, event.getClosedLoopEventStatus()); - - event.setFrom("from"); - assertEquals("from", event.getFrom()); - - event.setPayload("payload"); - assertEquals("payload", event.getPayload()); - - event.setPolicyName("policyname"); - assertEquals("policyname", event.getPolicyName()); - - event.setPolicyScope("scope"); - assertEquals("scope", event.getPolicyScope()); - - event.setPolicyVersion("1"); - assertEquals("1", event.getPolicyVersion()); - - UUID id = UUID.randomUUID(); - event.setRequestId(id); - assertEquals(id, event.getRequestId()); - - event.setTarget("target"); - assertEquals("target", event.getTarget()); - - event.setTargetType(ControlLoopTargetType.VF); - assertEquals(ControlLoopTargetType.VF, event.getTargetType()); - - event.setVersion("foo"); - assertEquals("foo", event.getVersion()); - - ControlLoopEvent event2 = new TestControlLoopEvent(event); - assertTrue(event2.isEventStatusValid()); - - event2.setClosedLoopEventStatus(null); - assertFalse(event2.isEventStatusValid()); - } -} diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopNotificationTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopNotificationTest.java deleted file mode 100644 index de03cc265..000000000 --- a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopNotificationTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2018 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.controlloop; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.util.Collections; -import java.util.UUID; -import org.junit.Test; -import org.onap.policy.controlloop.util.Serialization; - -public class ControlLoopNotificationTest { - - private class TestControlLoopNotification extends ControlLoopNotification { - private static final long serialVersionUID = 1L; - - public TestControlLoopNotification() { - super(); - } - - public TestControlLoopNotification(ControlLoopEvent event) { - super(event); - } - } - - @Test - public void test() { - ControlLoopNotification notification = new TestControlLoopNotification(); - - assertEquals("1.0.2", notification.getVersion()); - - notification.setClosedLoopControlName("name"); - assertEquals("name", notification.getClosedLoopControlName()); - - notification.setClosedLoopEventClient("client"); - assertEquals("client", notification.getClosedLoopEventClient()); - - notification.setFrom("from"); - assertEquals("from", notification.getFrom()); - - notification.setHistory(Collections.emptyList()); - assertTrue(notification.getHistory().size() == 0); - - notification.setMessage("message"); - assertEquals("message", notification.getMessage()); - - notification.setNotification(ControlLoopNotificationType.ACTIVE); - assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification()); - - ZonedDateTime time = ZonedDateTime.now(ZoneOffset.UTC); - notification.setNotificationTime(time); - assertEquals(time, notification.getNotificationTime()); - - notification.setOpsClTimer(Integer.valueOf(1000)); - assertEquals(Integer.valueOf(1000), notification.getOpsClTimer()); - - notification.setPolicyName("name"); - assertEquals("name", notification.getPolicyName()); - - notification.setPolicyScope("scope"); - assertEquals("scope", notification.getPolicyScope()); - - notification.setPolicyVersion("1"); - assertEquals("1", notification.getPolicyVersion()); - - UUID id = UUID.randomUUID(); - notification.setRequestId(id); - assertEquals(id, notification.getRequestId()); - - notification.setTarget("target"); - assertEquals("target", notification.getTarget()); - - notification.setTargetType(ControlLoopTargetType.VFC); - assertEquals(ControlLoopTargetType.VFC, notification.getTargetType()); - - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName("controlloop"); - - TestControlLoopNotification notification2 = new TestControlLoopNotification(event); - assertEquals("controlloop", notification2.getClosedLoopControlName()); - - notification2.setVersion("1"); - assertEquals("1", notification2.getVersion()); - - String json = Serialization.gsonPretty.toJson(notification); - - TestControlLoopNotification notification3 = Serialization.gson.fromJson(json, - TestControlLoopNotification.class); - - // - // There is no equals for the class - chose not to create one - // - assertEquals(notification.getRequestId(), notification3.getRequestId()); - - } -} diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopNotificationTypeTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopNotificationTypeTest.java deleted file mode 100644 index 63103ac8f..000000000 --- a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopNotificationTypeTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2018 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.controlloop; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -public class ControlLoopNotificationTypeTest { - - @Test - public void test() { - - assertEquals(ControlLoopNotificationType.ACTIVE, ControlLoopNotificationType.toType("ACTIVE")); - assertEquals(ControlLoopNotificationType.REJECTED, ControlLoopNotificationType.toType("REJECTED")); - assertEquals(ControlLoopNotificationType.OPERATION, ControlLoopNotificationType.toType("OPERATION")); - assertEquals(ControlLoopNotificationType.OPERATION_SUCCESS, - ControlLoopNotificationType.toType("OPERATION: SUCCESS")); - assertEquals(ControlLoopNotificationType.OPERATION_FAILURE, - ControlLoopNotificationType.toType("OPERATION: FAILURE")); - assertEquals(ControlLoopNotificationType.FINAL_FAILURE, - ControlLoopNotificationType.toType("FINAL: FAILURE")); - assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, - ControlLoopNotificationType.toType("FINAL: SUCCESS")); - assertEquals(ControlLoopNotificationType.FINAL_OPENLOOP, - ControlLoopNotificationType.toType("FINAL: OPENLOOP")); - - assertNull(ControlLoopNotificationType.toType("foo")); - } -} diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationTest.java deleted file mode 100644 index 6c6a83e85..000000000 --- a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2018 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.controlloop; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.time.Instant; -import org.junit.Test; - -public class ControlLoopOperationTest { - - @Test - public void test() { - ControlLoopOperation operation = new ControlLoopOperation(); - - assertEquals(operation, operation); - assertNotEquals(operation, new String()); - assertNotEquals(operation, null); - - assertTrue(operation.hashCode() != 0); - assertTrue(operation.toString().startsWith("ControlLoopOperation")); - - assertNotNull(operation); - - operation.setActor("actor"); - assertEquals("actor", operation.getActor()); - - operation.setOperation("operation"); - assertEquals("operation", operation.getOperation()); - - Instant now = Instant.now(); - operation.setStart(now); - assertEquals(now, operation.getStart()); - operation.setEnd(now); - assertEquals(now, operation.getEnd()); - - operation.setMessage("message"); - assertEquals("message", operation.getMessage()); - - operation.setOutcome("outcome"); - assertEquals("outcome", operation.getOutcome()); - - operation.setSubRequestId("1"); - assertEquals("1", operation.getSubRequestId()); - - operation.setTarget("target"); - assertEquals("target", operation.getTarget()); - - assertTrue(operation.hashCode() != 0); - - ControlLoopOperation operation2 = new ControlLoopOperation(operation); - assertEquals(now, operation2.getEnd()); - - assertEquals(operation, operation2); - - operation2.setActor("foo"); - assertNotEquals(operation, operation2); - - operation = new ControlLoopOperation(null); - assertNotNull(operation.getStart()); - - assertNotEquals(operation, operation2); - - assertTrue(operation.toMessage().startsWith("actor=")); - assertTrue(operation.toHistory().startsWith("actor=")); - - } -} diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationWrapperTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationWrapperTest.java deleted file mode 100644 index 8d25c8eac..000000000 --- a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopOperationWrapperTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2018 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.controlloop; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; -import org.junit.Test; - -public class ControlLoopOperationWrapperTest { - - @Test - public void test() { - ControlLoopOperationWrapper wrapper = new ControlLoopOperationWrapper(); - - assertNotNull(wrapper); - - ControlLoopOperation operation = new ControlLoopOperation(); - wrapper.setOperation(operation); - UUID id = UUID.randomUUID(); - wrapper.setRequestId(id); - - ControlLoopOperationWrapper wrapper2 = new ControlLoopOperationWrapper(wrapper.getRequestId(), - wrapper.getOperation()); - - assertEquals(operation, wrapper2.getOperation()); - assertEquals(id, wrapper2.getRequestId()); - - - } -} diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopResponseTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopResponseTest.java deleted file mode 100644 index 3bab0aef4..000000000 --- a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopResponseTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2019 Wipro Limited 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.controlloop; - -import static org.junit.Assert.assertEquals; - -import java.util.UUID; -import org.junit.Test; - -public class ControlLoopResponseTest { - - @Test - public void test() { - ControlLoopResponse rsp = new ControlLoopResponse(); - - assertEquals("1.0.0", rsp.getVersion()); - - rsp = new ControlLoopResponse(null); - assertEquals("1.0.0", rsp.getVersion()); - - rsp.setClosedLoopControlName("name"); - assertEquals("name", rsp.getClosedLoopControlName()); - - rsp.setFrom("from"); - assertEquals("from", rsp.getFrom()); - - rsp.setPayload("payload"); - assertEquals("payload", rsp.getPayload()); - - rsp.setPolicyName("policyname"); - assertEquals("policyname", rsp.getPolicyName()); - - rsp.setPolicyVersion("1"); - assertEquals("1", rsp.getPolicyVersion()); - - UUID id = UUID.randomUUID(); - rsp.setRequestId(id); - assertEquals(id, rsp.getRequestId()); - - rsp.setTarget("target"); - assertEquals("target", rsp.getTarget()); - - rsp.setVersion("foo"); - assertEquals("foo", rsp.getVersion()); - - } -} diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java deleted file mode 100644 index 1afd1f674..000000000 --- a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/ControlLoopTargetTypeTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2018 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.controlloop; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -public class ControlLoopTargetTypeTest { - - @Test - public void test() { - assertEquals(ControlLoopTargetType.VM, ControlLoopTargetType.toType("VM")); - assertEquals(ControlLoopTargetType.VF, ControlLoopTargetType.toType("VF")); - assertEquals(ControlLoopTargetType.VFC, ControlLoopTargetType.toType("VFC")); - assertEquals(ControlLoopTargetType.VNF, ControlLoopTargetType.toType("VNF")); - - assertNull(ControlLoopTargetType.toType("foo")); - } -} diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/PhysicalControlLoopEventTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/PhysicalControlLoopEventTest.java deleted file mode 100644 index b0f08e15b..000000000 --- a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/PhysicalControlLoopEventTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2018 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.controlloop; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class PhysicalControlLoopEventTest { - - @Test - public void test() { - PhysicalControlLoopEvent event = new PhysicalControlLoopEvent(); - assertNotNull(event); - - PhysicalControlLoopEvent event2 = new PhysicalControlLoopEvent(event); - assertNotNull(event2); - } -} diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/PhysicalControlLoopNotificationTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/PhysicalControlLoopNotificationTest.java deleted file mode 100644 index e10707bc1..000000000 --- a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/PhysicalControlLoopNotificationTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2018 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.controlloop; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class PhysicalControlLoopNotificationTest { - - @Test - public void test() { - PhysicalControlLoopNotification notification = new PhysicalControlLoopNotification(); - assertNotNull(notification); - - PhysicalControlLoopNotification notification2 = new PhysicalControlLoopNotification( - new PhysicalControlLoopEvent()); - assertNotNull(notification2); - } -} diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/VirtualControlLoopEventTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/VirtualControlLoopEventTest.java deleted file mode 100644 index 49837d191..000000000 --- a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/VirtualControlLoopEventTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2018 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.controlloop; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.time.Instant; -import org.junit.Test; - -public class VirtualControlLoopEventTest { - - @Test - public void test() { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - - assertNotNull(event); - assertNotNull(event.getAai()); - - Instant now = Instant.now(); - event.setClosedLoopAlarmStart(now); - event.setClosedLoopAlarmEnd(now); - - VirtualControlLoopEvent event2 = new VirtualControlLoopEvent(event); - assertEquals(now, event2.getClosedLoopAlarmStart()); - - event = new VirtualControlLoopEvent(null); - assertNull(event.getClosedLoopAlarmStart()); - } -} diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/VirtualControlLoopNotificationTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/VirtualControlLoopNotificationTest.java deleted file mode 100644 index 9adfebea2..000000000 --- a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/VirtualControlLoopNotificationTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2018 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.controlloop; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.time.Instant; -import java.util.Collections; -import org.junit.Test; - -public class VirtualControlLoopNotificationTest { - - @Test - public void test() { - VirtualControlLoopNotification notification = new VirtualControlLoopNotification(); - assertNotNull(notification); - - notification.setAai(Collections.emptyMap()); - assertTrue(notification.getAai().isEmpty()); - - Instant now = Instant.now(); - notification.setClosedLoopAlarmStart(now); - - notification.setClosedLoopAlarmEnd(now); - - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - - Instant later = Instant.now(); - event.setAai(Collections.emptyMap()); - event.setClosedLoopAlarmStart(later); - event.setClosedLoopAlarmEnd(later); - - notification = new VirtualControlLoopNotification(event); - assertEquals(later, notification.getClosedLoopAlarmStart()); - assertEquals(later, notification.getClosedLoopAlarmEnd()); - - } -} diff --git a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/params/ControlLoopParamsTest.java b/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/params/ControlLoopParamsTest.java deleted file mode 100644 index 065345a1a..000000000 --- a/controlloop/common/model-impl/events/src/test/java/org/onap/policy/controlloop/params/ControlLoopParamsTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * controlloop - * ================================================================================ - * Copyright (C) 2018 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.controlloop.params; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class ControlLoopParamsTest { - - @Test - public void test() { - ControlLoopParams params = new ControlLoopParams(); - assertNotNull(params); - - params.setClosedLoopControlName("name"); - params.setControlLoopYaml("yaml"); - params.setPolicyName("name"); - params.setPolicyScope("scope"); - params.setPolicyVersion("1"); - - ControlLoopParams params2 = new ControlLoopParams(params); - - assertTrue(params2.getClosedLoopControlName().equals("name")); - assertTrue(params2.getControlLoopYaml().equals("yaml")); - assertTrue(params2.getPolicyName().equals("name")); - assertTrue(params2.getPolicyScope().equals("scope")); - assertTrue(params2.getPolicyVersion().equals("1")); - - } -} diff --git a/controlloop/common/model-impl/pom.xml b/controlloop/common/model-impl/pom.xml deleted file mode 100644 index 4c3a5e625..000000000 --- a/controlloop/common/model-impl/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - Drools PDP Application Common Models - ================================================================================ - Copyright (C) 2017 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========================================================= - --> - -<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> - <packaging>pom</packaging> - - <parent> - <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> - <artifactId>common</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>model-impl</artifactId> - - <modules> - <module>aai</module> - <module>appc</module> - <module>appclcm</module> - <module>sdnr</module> - <module>events</module> - <module>so</module> - <module>rest</module> - <module>sdc</module> - <module>trafficgenerator</module> - <module>vfc</module> - <module>sdnc</module> - </modules> - - -</project> diff --git a/controlloop/common/model-impl/rest/pom.xml b/controlloop/common/model-impl/rest/pom.xml deleted file mode 100644 index 43f84fe76..000000000 --- a/controlloop/common/model-impl/rest/pom.xml +++ /dev/null @@ -1,90 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - Drools PDP Application Models - ================================================================================ - Copyright (C) 2017-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========================================================= - --> - -<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.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>model-impl</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>rest</artifactId> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpclient</artifactId> - <scope>provided</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <artifactId>maven-checkstyle-plugin</artifactId> - <executions> - <execution> - <id>onap-java-style</id> - <goals> - <goal>check</goal> - </goals> - <phase>process-sources</phase> - <configuration> - <!-- Use Google Java Style Guide: - https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml - with minor changes --> - <configLocation>onap-checkstyle/onap-java-style.xml</configLocation> - <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory --> - <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory> - <includeResources>true</includeResources> - <includeTestSourceDirectory>true</includeTestSourceDirectory> - <includeTestResources>true</includeTestResources> - <excludes> - </excludes> - <consoleOutput>true</consoleOutput> - <failsOnViolation>true</failsOnViolation> - <violationSeverity>warning</violationSeverity> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.onap.oparent</groupId> - <artifactId>checkstyle</artifactId> - <version>${oparent.version}</version> - <scope>compile</scope> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> -</project> diff --git a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/HttpDeleteWithBody.java b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/HttpDeleteWithBody.java deleted file mode 100644 index 3e52d4f10..000000000 --- a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/HttpDeleteWithBody.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * rest - * ================================================================================ - * Copyright (C) 2018 Amdocs. All rights reserved. - * Modifications Copyright (C) 2018 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.rest; - -import java.net.URI; -import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; - -/** - * Allows for HTTP DELETE requests to contain a body, which the HttpDelete - * class does not support. - */ -public class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase { - public static final String METHOD_NAME = "DELETE"; - - public HttpDeleteWithBody(final String uri) { - super(); - setURI(URI.create(uri)); - } - - public HttpDeleteWithBody(final URI uri) { - super(); - setURI(uri); - } - - public HttpDeleteWithBody() { - super(); - } - - public String getMethod() { - return METHOD_NAME; - } - -} diff --git a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java deleted file mode 100644 index 84a220b9a..000000000 --- a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RestManager.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * rest - * ================================================================================ - * Copyright (C) 2017-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.rest; - -import java.nio.charset.Charset; -import java.util.Map; -import java.util.Map.Entry; -import javax.xml.bind.DatatypeConverter; - -import org.apache.http.HttpHeaders; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpRequestBase; -import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RestManager { - - private static final Logger logger = LoggerFactory.getLogger(RestManager.class); - - public class Pair<A, B> { - public final A first; - public final B second; - - public Pair(A first, B second) { - this.first = first; - this.second = second; - } - } - - /** - * Perform REST Post. - * - * @param url the url - * @param username the user name - * @param password the password - * @param headers any headers - * @param contentType what the content type is - * @param body body to send - * @return the response status code and the body - */ - public Pair<Integer, String> post(String url, String username, String password, - Map<String, String> headers, String contentType, String body) { - HttpPost post = new HttpPost(url); - addHeaders(post, username, password, headers); - post.addHeader("Content-Type", contentType); - try { - StringEntity input = new StringEntity(body); - input.setContentType(contentType); - post.setEntity(input); - } catch (Exception e) { - logger.error("post threw: ", e); - return null; - } - return sendRequest(post); - } - - /** - * Do a REST get. - * - * @param url URL - * @param username user name - * @param password password - * @param headers any headers to add - * @return a Pair for the response status and the body - */ - public Pair<Integer, String> get(String url, String username, String password, - Map<String, String> headers) { - HttpGet get = new HttpGet(url); - addHeaders(get, username, password, headers); - return sendRequest(get); - } - - /** - * Perform REST Delete. - * - * @param url the url - * @param username the user name - * @param password the password - * @param headers any headers - * @param contentType what the content type is - * @param body body (optional) to send - * @return the response status code and the body - */ - public Pair<Integer, String> delete(String url, String username, String password, Map<String, String> headers, - String contentType, String body) { - HttpDeleteWithBody delete = new HttpDeleteWithBody(url); - addHeaders(delete, username, password, headers); - delete.addHeader("Content-Type", contentType); - if (body != null && !body.isEmpty()) { - try { - StringEntity input = new StringEntity(body); - input.setContentType(contentType); - delete.setEntity(input); - } catch (Exception e) { - logger.error("delete threw: ", e); - return null; - } - } - return sendRequest(delete); - } - - /** - * Send REST request. - * - * @param request http request to send - * @return the response status code and the body - */ - private Pair<Integer, String> sendRequest(HttpRequestBase request) { - if (logger.isDebugEnabled()) { - logger.debug("***** sendRequest to url {}:", request.getURI()); - } - - try (CloseableHttpClient client = - HttpClientBuilder - .create() - .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) - .build()) { - HttpResponse response = client.execute(request); - if (response != null) { - String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8"); - logger.debug("HTTP Response Status Code: {}", - response.getStatusLine().getStatusCode()); - logger.debug("HTTP Response Body:"); - logger.debug(returnBody); - - return new Pair<>(response.getStatusLine().getStatusCode(), - returnBody); - } else { - logger.error("Response from {} is null", request.getURI()); - return null; - } - } catch (Exception e) { - logger.error("Request failed to {}", request.getURI(), e); - return null; - } - } - - /** - * Add header to the request. - * - * @param request http request to send - * @param username the user name - * @param password the password - * @param headers any headers - */ - private void addHeaders(HttpRequestBase request, String username, String password, Map<String, - String> headers) { - String authHeader = makeAuthHeader(username, password); - if (headers != null) { - for (Entry<String, String> entry : headers.entrySet()) { - request.addHeader(entry.getKey(), headers.get(entry.getKey())); - } - } - if (authHeader != null) { - request.setHeader(HttpHeaders.AUTHORIZATION, authHeader); - } - } - - private String makeAuthHeader(String username, String password) { - if (username == null || username.isEmpty()) { - return null; - } - - String auth = username + ":" + (password == null ? "" : password); - return "Basic " + DatatypeConverter.printBase64Binary(auth.getBytes(Charset.forName("ISO-8859-1"))); - } -} diff --git a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/GetTest.java b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/GetTest.java deleted file mode 100755 index 37e38ec70..000000000 --- a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/GetTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * rest - * ================================================================================ - * Copyright (C) 2017-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.rest; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.policy.rest.RestManager.Pair; - -public class GetTest { - - @Test(expected = NullPointerException.class) - public void testUrlNull() { - RestManager mgr = new RestManager(); - mgr.get(null, "user", null, null); - } - - @Test - public void testUsernameNull() { - RestManager mgr = new RestManager(); - - Pair<Integer, String> result = mgr.get("http://www.example.org", null, null, null); - assertEquals((Integer)200, result.first); - assertTrue(result.second != null); - assertTrue(result.second.length() > 0); - } - - @Test - public void testUsernameEmpty() { - RestManager mgr = new RestManager(); - - Pair<Integer, String> result = mgr.get("http://www.example.org", "", null, null); - assertEquals((Integer)200, result.first); - assertTrue(result.second != null); - assertTrue(result.second.length() > 0); - } - - @Test - public void testUrlExampleOrg() { - RestManager mgr = new RestManager(); - - Pair<Integer, String> result = mgr.get("http://www.example.org", "user", null, null); - assertEquals((Integer)200, result.first); - assertTrue(result.second != null); - assertTrue(result.second.length() > 0); - } -} diff --git a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/HttpDeleteWithBodyTest.java b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/HttpDeleteWithBodyTest.java deleted file mode 100644 index 0cb5f3aef..000000000 --- a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/HttpDeleteWithBodyTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * rest - * ================================================================================ - * Copyright (C) 2018 Amdocs. 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.rest; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class HttpDeleteWithBodyTest { - - @Test - public void getMethod() { - String url = "http://www.example.org"; - HttpDeleteWithBody deleteWithBody = new HttpDeleteWithBody(url); - assertEquals("DELETE", deleteWithBody.getMethod()); - assertEquals(url, deleteWithBody.getURI().toString()); - } -}
\ No newline at end of file diff --git a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/PairTest.java b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/PairTest.java deleted file mode 100755 index 6269e9de4..000000000 --- a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/PairTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * rest - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.rest; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.onap.policy.rest.RestManager.Pair; - -public class PairTest { - - @Test - public void testPair() { - RestManager mgr = new RestManager(); - - Pair<Integer, Integer> pii = mgr.new Pair<>(1, 2); - assertEquals((Integer) 1, (Integer) pii.first); - assertEquals((Integer) 2, (Integer) pii.second); - - Pair<Integer, String> pis = mgr.new Pair<>(1, "test"); - assertEquals((Integer) 1, (Integer) pis.first); - assertEquals("test", pis.second); - } -} diff --git a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/PostTest.java b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/PostTest.java deleted file mode 100755 index 834c29873..000000000 --- a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/PostTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * rest - * ================================================================================ - * Copyright (C) 2017-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.rest; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.onap.policy.rest.RestManager.Pair; - -public class PostTest { - - @Test - public void testUsernameNull() { - RestManager mgr = new RestManager(); - Pair<Integer, String> result = mgr.post("http://www.example.org", null, null, null, null, null); - assertEquals(null, result); - } - - @Test - public void testUsernameEmpty() { - RestManager mgr = new RestManager(); - Pair<Integer, String> result = mgr.post("http://www.example.org", "", null, null, null, null); - assertEquals(null, result); - } - - @Test - public void testBodyNull() { - RestManager mgr = new RestManager(); - Pair<Integer, String> result = mgr.post("http://www.example.org", "user", null, null, null, null); - assertEquals(null, result); - } -} diff --git a/controlloop/common/model-impl/sdc/checkstyle-suppressions.xml b/controlloop/common/model-impl/sdc/checkstyle-suppressions.xml deleted file mode 100644 index fd73d24e3..000000000 --- a/controlloop/common/model-impl/sdc/checkstyle-suppressions.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - Copyright (C) 2018 AT&T Technologies. 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========================================================= ---> - -<!DOCTYPE suppressions PUBLIC - "-//Puppy Crawl//DTD Suppressions 1.0//EN" - "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd"> - -<suppressions> - <suppress checks="AbbreviationAsWordInName" - files="ResourceInstance.java|ServiceInstance.java|Service.java" - lines="1-9999"/> -</suppressions> diff --git a/controlloop/common/model-impl/sdc/pom.xml b/controlloop/common/model-impl/sdc/pom.xml deleted file mode 100644 index 9c3bc0ab8..000000000 --- a/controlloop/common/model-impl/sdc/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - drools-pdp-apps - ================================================================================ - Copyright (C) 2017-2018 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========================================================= - --> - -<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.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>model-impl</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>sdc</artifactId> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <artifactId>maven-checkstyle-plugin</artifactId> - <executions> - <execution> - <id>onap-java-style</id> - <goals> - <goal>check</goal> - </goals> - <phase>process-sources</phase> - <configuration> - <!-- Use Google Java Style Guide: - https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml - with minor changes --> - <configLocation>onap-checkstyle/onap-java-style.xml</configLocation> - <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory --> - <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory> - <includeResources>true</includeResources> - <includeTestSourceDirectory>true</includeTestSourceDirectory> - <includeTestResources>true</includeTestResources> - <excludes> - </excludes> - <suppressionsLocation>${project.basedir}/checkstyle-suppressions.xml</suppressionsLocation> - <consoleOutput>true</consoleOutput> - <failsOnViolation>true</failsOnViolation> - <violationSeverity>warning</violationSeverity> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.onap.oparent</groupId> - <artifactId>checkstyle</artifactId> - <version>${oparent.version}</version> - <scope>compile</scope> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> -</project> diff --git a/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/Resource.java b/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/Resource.java deleted file mode 100644 index a747f8fd6..000000000 --- a/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/Resource.java +++ /dev/null @@ -1,188 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc - * ================================================================================ - * Copyright (C) 2017-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.sdc; - -import java.io.Serializable; -import java.util.UUID; - -public class Resource implements Serializable { - - private static final long serialVersionUID = -913729158733348027L; - - private UUID resourceUuid; - private UUID resourceInvariantUuid; - private String resourceName; - private String resourceVersion; - private ResourceType resourceType; - - public Resource() { - //Empty Constructor - } - - /** - * Constructor. - * - * @param resource copy object - */ - public Resource(Resource resource) { - this.resourceUuid = resource.resourceUuid; - this.resourceInvariantUuid = resource.resourceInvariantUuid; - this.resourceName = resource.resourceName; - this.resourceVersion = resource.resourceVersion; - this.resourceType = resource.resourceType; - } - - public Resource(UUID uuid) { - this.resourceUuid = uuid; - } - - public Resource(String name, ResourceType type) { - this.resourceName = name; - this.resourceType = type; - } - - /** - * Constructor. - * - * @param uuid uuid - * @param invariantUuid invariant uuid - * @param name name - * @param version version - * @param type type - */ - public Resource(UUID uuid, UUID invariantUuid, String name, String version, ResourceType type) { - this.resourceUuid = uuid; - this.resourceInvariantUuid = invariantUuid; - this.resourceName = name; - this.resourceVersion = version; - this.resourceType = type; - } - - public UUID getResourceUuid() { - return resourceUuid; - } - - public void setResourceUuid(UUID resourceUuid) { - this.resourceUuid = resourceUuid; - } - - public UUID getResourceInvariantUuid() { - return resourceInvariantUuid; - } - - public void setResourceInvariantUuid(UUID resourceInvariantUuid) { - this.resourceInvariantUuid = resourceInvariantUuid; - } - - public String getResourceName() { - return resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - public String getResourceVersion() { - return resourceVersion; - } - - public void setResourceVersion(String resourceVersion) { - this.resourceVersion = resourceVersion; - } - - public ResourceType getResourceType() { - return resourceType; - } - - public void setResourceType(ResourceType resourceType) { - this.resourceType = resourceType; - } - - @Override - public String toString() { - return "Resource [resourceUuid=" + resourceUuid + ", resourceInvariantUuid=" + resourceInvariantUuid - + ", resourceName=" + resourceName + ", resourceVersion=" + resourceVersion + ", resourceType=" - + resourceType + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((resourceInvariantUuid == null) ? 0 : resourceInvariantUuid.hashCode()); - result = prime * result + ((resourceName == null) ? 0 : resourceName.hashCode()); - result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode()); - result = prime * result + ((resourceUuid == null) ? 0 : resourceUuid.hashCode()); - result = prime * result + ((resourceVersion == null) ? 0 : resourceVersion.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Resource other = (Resource) obj; - if (resourceInvariantUuid == null) { - if (other.resourceInvariantUuid != null) { - return false; - } - } else if (!resourceInvariantUuid.equals(other.resourceInvariantUuid)) { - return false; - } - if (resourceName == null) { - if (other.resourceName != null) { - return false; - } - } else if (!resourceName.equals(other.resourceName)) { - return false; - } - if (resourceType == null) { - if (other.resourceType != null) { - return false; - } - } else if (!resourceType.equals(other.resourceType)) { - return false; - } - if (resourceUuid == null) { - if (other.resourceUuid != null) { - return false; - } - } else if (!resourceUuid.equals(other.resourceUuid)) { - return false; - } - if (resourceVersion == null) { - if (other.resourceVersion != null) { - return false; - } - } else if (!resourceVersion.equals(other.resourceVersion)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ResourceInstance.java b/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ResourceInstance.java deleted file mode 100644 index dcf663e64..000000000 --- a/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ResourceInstance.java +++ /dev/null @@ -1,178 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc - * ================================================================================ - * Copyright (C) 2017-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.sdc; - -import java.io.Serializable; -import java.util.UUID; - -public class ResourceInstance implements Serializable { - private static final long serialVersionUID = -5506162340393802424L; - - private String resourceInstanceName; - private String resourceName; - private UUID resourceInvariantUuid; - private String resourceVersion; - private ResourceType resourceType; - private UUID resourceUuid; - - public ResourceInstance() { - //Empty Constructor - } - - /** - * Constructor. - * - * @param instance copy object - */ - public ResourceInstance(ResourceInstance instance) { - if (instance == null) { - return; - } - this.resourceInstanceName = instance.resourceInstanceName; - this.resourceName = instance.resourceName; - this.resourceInvariantUuid = instance.resourceInvariantUuid; - this.resourceVersion = instance.resourceVersion; - this.resourceType = instance.resourceType; - this.resourceUuid = instance.resourceUuid; - } - - public String getResourceInstanceName() { - return resourceInstanceName; - } - - public void setResourceInstanceName(String resourceInstanceName) { - this.resourceInstanceName = resourceInstanceName; - } - - public String getResourceName() { - return resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - public UUID getResourceInvariantUUID() { - return resourceInvariantUuid; - } - - public void setResourceInvariantUUID(UUID resourceInvariantUuid) { - this.resourceInvariantUuid = resourceInvariantUuid; - } - - public String getResourceVersion() { - return resourceVersion; - } - - public void setResourceVersion(String resourceVersion) { - this.resourceVersion = resourceVersion; - } - - public ResourceType getResourceType() { - return resourceType; - } - - public void setResourceType(ResourceType resourceType) { - this.resourceType = resourceType; - } - - public UUID getResourceUuid() { - return resourceUuid; - } - - public void setResourceUuid(UUID resourceUuid) { - this.resourceUuid = resourceUuid; - } - - @Override - public String toString() { - return "ResourceInstance [resourceInstanceName=" + resourceInstanceName + ", resourceName=" + resourceName - + ", resourceInvariantUuid=" + resourceInvariantUuid + ", resourceVersion=" + resourceVersion - + ", resourceType=" + resourceType + ", resourceUuid=" + resourceUuid + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((resourceInstanceName == null) ? 0 : resourceInstanceName.hashCode()); - result = prime * result + ((resourceInvariantUuid == null) ? 0 : resourceInvariantUuid.hashCode()); - result = prime * result + ((resourceName == null) ? 0 : resourceName.hashCode()); - result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode()); - result = prime * result + ((resourceUuid == null) ? 0 : resourceUuid.hashCode()); - result = prime * result + ((resourceVersion == null) ? 0 : resourceVersion.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ResourceInstance other = (ResourceInstance) obj; - if (resourceInstanceName == null) { - if (other.resourceInstanceName != null) { - return false; - } - } else if (!resourceInstanceName.equals(other.resourceInstanceName)) { - return false; - } - if (resourceInvariantUuid == null) { - if (other.resourceInvariantUuid != null) { - return false; - } - } else if (!resourceInvariantUuid.equals(other.resourceInvariantUuid)) { - return false; - } - if (resourceName == null) { - if (other.resourceName != null) { - return false; - } - } else if (!resourceName.equals(other.resourceName)) { - return false; - } - if (resourceType != other.resourceType) { - return false; - } - if (resourceUuid == null) { - if (other.resourceUuid != null) { - return false; - } - } else if (!resourceUuid.equals(other.resourceUuid)) { - return false; - } - if (resourceVersion == null) { - if (other.resourceVersion != null) { - return false; - } - } else if (!resourceVersion.equals(other.resourceVersion)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ResourceType.java b/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ResourceType.java deleted file mode 100644 index 6202d64e0..000000000 --- a/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ResourceType.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc - * ================================================================================ - * Copyright (C) 2017-2018 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.sdc; - -public enum ResourceType { - VF("VF"), - VFC("VFC"), - VL("VL"), - CP("CP") - ; - - private String type; - - private ResourceType(String type) { - this.type = type; - } - - @Override - public String toString() { - return this.type; - } - -} diff --git a/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/Service.java b/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/Service.java deleted file mode 100644 index b3ebcc238..000000000 --- a/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/Service.java +++ /dev/null @@ -1,166 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc - * ================================================================================ - * Copyright (C) 2017-2018 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.sdc; - -import java.io.Serializable; -import java.util.UUID; - -public class Service implements Serializable { - - private static final long serialVersionUID = -1249276698549996806L; - - private UUID serviceUUID; - private UUID serviceInvariantUUID; - private String serviceName; - private String serviceVersion; - - public Service() { - //Empty Constructor - } - - public Service(UUID uuid) { - this.serviceUUID = uuid; - } - - public Service(String name) { - this.serviceName = name; - } - - /** - * Constructor. - * - * @param uuid service id - * @param invariantUUID service invariant id - * @param name name - * @param version version - */ - public Service(UUID uuid, UUID invariantUUID, String name, String version) { - this.serviceUUID = uuid; - this.serviceInvariantUUID = invariantUUID; - this.serviceName = name; - this.serviceVersion = version; - } - - /** - * Constructor. - * - * @param service copy object - */ - public Service(Service service) { - this.serviceUUID = service.serviceUUID; - this.serviceInvariantUUID = service.serviceInvariantUUID; - this.serviceName = service.serviceName; - this.serviceVersion = service.serviceVersion; - } - - public UUID getServiceUUID() { - return serviceUUID; - } - - public void setServiceUUID(UUID serviceUUID) { - this.serviceUUID = serviceUUID; - } - - public UUID getServiceInvariantUUID() { - return serviceInvariantUUID; - } - - public void setServiceInvariantUUID(UUID serviceInvariantUUID) { - this.serviceInvariantUUID = serviceInvariantUUID; - } - - public String getServiceName() { - return serviceName; - } - - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } - - public String getServiceVersion() { - return serviceVersion; - } - - public void setServiceVersion(String serviceVersion) { - this.serviceVersion = serviceVersion; - } - - @Override - public String toString() { - return "Service [serviceUUID=" + serviceUUID + ", serviceInvariantUUID=" + serviceInvariantUUID - + ", serviceName=" + serviceName + ", serviceVersion=" + serviceVersion + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((serviceInvariantUUID == null) ? 0 : serviceInvariantUUID.hashCode()); - result = prime * result + ((serviceName == null) ? 0 : serviceName.hashCode()); - result = prime * result + ((serviceUUID == null) ? 0 : serviceUUID.hashCode()); - result = prime * result + ((serviceVersion == null) ? 0 : serviceVersion.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Service other = (Service) obj; - if (serviceInvariantUUID == null) { - if (other.serviceInvariantUUID != null) { - return false; - } - } else if (!serviceInvariantUUID.equals(other.serviceInvariantUUID)) { - return false; - } - if (serviceName == null) { - if (other.serviceName != null) { - return false; - } - } else if (!serviceName.equals(other.serviceName)) { - return false; - } - if (serviceUUID == null) { - if (other.serviceUUID != null) { - return false; - } - } else if (!serviceUUID.equals(other.serviceUUID)) { - return false; - } - if (serviceVersion == null) { - if (other.serviceVersion != null) { - return false; - } - } else if (!serviceVersion.equals(other.serviceVersion)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ServiceInstance.java b/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ServiceInstance.java deleted file mode 100644 index a477267a3..000000000 --- a/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ServiceInstance.java +++ /dev/null @@ -1,201 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc - * ================================================================================ - * Copyright (C) 2017-2018 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.sdc; - -import java.io.Serializable; -import java.util.UUID; - -public class ServiceInstance implements Serializable { - private static final long serialVersionUID = 6285260780966679625L; - - private UUID personaModelUUID; - private UUID serviceUUID; - private UUID serviceInstanceUUID; - private UUID widgetModelUUID; - private String widgetModelVersion; - private String serviceName; - private String serviceInstanceName; - - public ServiceInstance() { - //Empty Constructor - } - - /** - * Constructor. - * - * @param instance copy object - */ - public ServiceInstance(ServiceInstance instance) { - if (instance == null) { - return; - } - this.personaModelUUID = instance.personaModelUUID; - this.serviceUUID = instance.serviceUUID; - this.serviceInstanceUUID = instance.serviceInstanceUUID; - this.widgetModelUUID = instance.widgetModelUUID; - this.widgetModelVersion = instance.widgetModelVersion; - this.serviceName = instance.serviceName; - this.serviceInstanceName = instance.serviceInstanceName; - } - - public UUID getPersonaModelUUID() { - return personaModelUUID; - } - - public void setPersonaModelUUID(UUID personaModelUUID) { - this.personaModelUUID = personaModelUUID; - } - - public UUID getServiceUUID() { - return serviceUUID; - } - - public void setServiceUUID(UUID serviceUUID) { - this.serviceUUID = serviceUUID; - } - - public UUID getServiceInstanceUUID() { - return serviceInstanceUUID; - } - - public void setServiceInstanceUUID(UUID serviceInstanceUUID) { - this.serviceInstanceUUID = serviceInstanceUUID; - } - - public UUID getWidgetModelUUID() { - return widgetModelUUID; - } - - public void setWidgetModelUUID(UUID widgetModelUUID) { - this.widgetModelUUID = widgetModelUUID; - } - - public String getWidgetModelVersion() { - return widgetModelVersion; - } - - public void setWidgetModelVersion(String widgetModelVersion) { - this.widgetModelVersion = widgetModelVersion; - } - - public String getServiceName() { - return serviceName; - } - - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } - - public String getServiceInstanceName() { - return serviceInstanceName; - } - - public void setServiceInstanceName(String serviceInstanceName) { - this.serviceInstanceName = serviceInstanceName; - } - - @Override - public String toString() { - return "ServiceInstance [personaModelUUID=" + personaModelUUID + ", serviceUUID=" + serviceUUID - + ", serviceInstanceUUID=" + serviceInstanceUUID + ", widgetModelUUID=" + widgetModelUUID - + ", widgetModelVersion=" + widgetModelVersion + ", serviceName=" + serviceName - + ", serviceInstanceName=" + serviceInstanceName + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((personaModelUUID == null) ? 0 : personaModelUUID.hashCode()); - result = prime * result + ((serviceInstanceName == null) ? 0 : serviceInstanceName.hashCode()); - result = prime * result + ((serviceInstanceUUID == null) ? 0 : serviceInstanceUUID.hashCode()); - result = prime * result + ((serviceName == null) ? 0 : serviceName.hashCode()); - result = prime * result + ((serviceUUID == null) ? 0 : serviceUUID.hashCode()); - result = prime * result + ((widgetModelUUID == null) ? 0 : widgetModelUUID.hashCode()); - result = prime * result + ((widgetModelVersion == null) ? 0 : widgetModelVersion.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ServiceInstance other = (ServiceInstance) obj; - if (personaModelUUID == null) { - if (other.personaModelUUID != null) { - return false; - } - } else if (!personaModelUUID.equals(other.personaModelUUID)) { - return false; - } - if (serviceInstanceName == null) { - if (other.serviceInstanceName != null) { - return false; - } - } else if (!serviceInstanceName.equals(other.serviceInstanceName)) { - return false; - } - if (serviceInstanceUUID == null) { - if (other.serviceInstanceUUID != null) { - return false; - } - } else if (!serviceInstanceUUID.equals(other.serviceInstanceUUID)) { - return false; - } - if (serviceName == null) { - if (other.serviceName != null) { - return false; - } - } else if (!serviceName.equals(other.serviceName)) { - return false; - } - if (serviceUUID == null) { - if (other.serviceUUID != null) { - return false; - } - } else if (!serviceUUID.equals(other.serviceUUID)) { - return false; - } - if (widgetModelUUID == null) { - if (other.widgetModelUUID != null) { - return false; - } - } else if (!widgetModelUUID.equals(other.widgetModelUUID)) { - return false; - } - if (widgetModelVersion == null) { - if (other.widgetModelVersion != null) { - return false; - } - } else if (!widgetModelVersion.equals(other.widgetModelVersion)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/sdc/src/main/resources/definitions.yaml b/controlloop/common/model-impl/sdc/src/main/resources/definitions.yaml deleted file mode 100644 index 55eff8a87..000000000 --- a/controlloop/common/model-impl/sdc/src/main/resources/definitions.yaml +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright 2018 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. -Service: - type: Object - properties: - serviceUUID: - type: string - pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - serviceInvariantUUID: - type: string - pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - serviceName: - type: string - serviceVersion: - type: string -Resource: - type: Object - properties: - resourceUUID: - type: string - pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - resourceInvariantUUID: - type: string - pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - resourceName: - type: string - resourceVersion: - type: string - resourceType: - type: string - valid_values: - - VF - - VFC - - CP - - VL -ServiceInstance: - type: Object - properties: - personaModelUUID: - type: string - pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - serviceUUID: - type: string - pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - serviceInstanceUUID: - type: string - pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - widgetModelUUID: - type: string - pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - widgetModelVersion: - type: string - serviceName: - type: string - serviceInstanceName: - type: string -ResourceInstance: - type: object - properties: - resourceInstanceName: - type: string - resourceName: - type: string - resourceInvariantUUID: - type: string - pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - resourceVersion: - type: string - resourceType: - type: string - valid_values: - - VF - - VFC - - CP - - VL - resourceUUID: - type: string - pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" diff --git a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceInstanceTest.java b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceInstanceTest.java deleted file mode 100644 index 572a1186a..000000000 --- a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceInstanceTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc - * ================================================================================ - * - * ================================================================================ - * 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.sdc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.UUID; - -import org.junit.Test; - -public class ResourceInstanceTest { - - @Test - public void testConstructors() { - ResourceInstance ri = new ResourceInstance(); - assertEquals(null, ri.getResourceInstanceName()); - assertEquals(null, ri.getResourceUuid()); - assertEquals(null, ri.getResourceInvariantUUID()); - assertEquals(null, ri.getResourceName()); - assertEquals(null, ri.getResourceType()); - assertEquals(null, ri.getResourceVersion()); - - ResourceInstance ri2 = new ResourceInstance((ResourceInstance) null); - assertEquals(null, ri2.getResourceInstanceName()); - assertEquals(null, ri2.getResourceUuid()); - assertEquals(null, ri2.getResourceInvariantUUID()); - assertEquals(null, ri2.getResourceName()); - assertEquals(null, ri2.getResourceType()); - assertEquals(null, ri2.getResourceVersion()); - - ri2 = new ResourceInstance(ri); - assertEquals(ri2.getResourceInstanceName(), ri.getResourceInstanceName()); - assertEquals(ri2.getResourceUuid(), ri.getResourceUuid()); - assertEquals(ri2.getResourceInvariantUUID(), ri.getResourceInvariantUUID()); - assertEquals(ri2.getResourceName(), ri.getResourceName()); - assertEquals(ri2.getResourceType(), ri.getResourceType()); - assertEquals(ri2.getResourceVersion(), ri.getResourceVersion()); - } - - @Test - public void testInstanceName() { - ResourceInstance ri = new ResourceInstance(); - String name = "nameTestInstance"; - ri.setResourceInstanceName(name);; - assertEquals(name, ri.getResourceInstanceName()); - } - - @Test - public void testUuid() { - ResourceInstance ri = new ResourceInstance(); - UUID uuid = UUID.randomUUID(); - ri.setResourceUuid(uuid); - assertEquals(uuid, ri.getResourceUuid()); - } - - @Test - public void testInvariantUuid() { - ResourceInstance ri = new ResourceInstance(); - UUID uuid = UUID.randomUUID(); - ri.setResourceInvariantUUID(uuid); - assertEquals(uuid, ri.getResourceInvariantUUID()); - } - - @Test - public void testName() { - ResourceInstance ri = new ResourceInstance(); - String name = "nameTest"; - ri.setResourceName(name); - assertEquals(name, ri.getResourceName()); - } - - @Test - public void testVersion() { - ResourceInstance ri = new ResourceInstance(); - String version = "versionTest"; - ri.setResourceVersion(version); - assertEquals(version, ri.getResourceVersion()); - } - - @Test - public void testType() { - ResourceInstance ri = new ResourceInstance(); - ri.setResourceType(ResourceType.CP); - assertEquals(ResourceType.CP, ri.getResourceType()); - } - - @Test - public void testEquals() { - ResourceInstance ri1 = new ResourceInstance(); - ResourceInstance ri2 = new ResourceInstance(ri1); - assertTrue(ri1.equals(ri2)); - assertTrue(ri2.equals(ri1)); - - ri1.setResourceInstanceName("instance"); - ri1.setResourceName("resource"); - ri1.setResourceInvariantUUID(UUID.randomUUID()); - ri1.setResourceInvariantUUID(UUID.randomUUID()); - ri1.setResourceVersion("0.0.0"); - ri1.setResourceType(ResourceType.VL); - ri2 = new ResourceInstance(ri1); - assertTrue(ri1.equals(ri2)); - assertTrue(ri2.equals(ri1)); - } - - @Test - public void testToString() { - ResourceInstance ri1 = new ResourceInstance(); - ResourceInstance ri2 = new ResourceInstance(ri1); - assertEquals(ri1.toString(), ri2.toString()); - - ri1.setResourceInstanceName("instance"); - ri1.setResourceName("resource"); - ri1.setResourceInvariantUUID(UUID.randomUUID()); - ri1.setResourceInvariantUUID(UUID.randomUUID()); - ri1.setResourceVersion("0.0.0"); - ri1.setResourceType(ResourceType.VL); - ri2 = new ResourceInstance(ri1); - assertEquals(ri1.toString(), ri2.toString()); - } - - @Test - public void testHashCode() { - ResourceInstance ri1 = new ResourceInstance(); - ResourceInstance ri2 = new ResourceInstance(ri1); - assertEquals(ri1.hashCode(), ri2.hashCode()); - - ri1.setResourceInstanceName("instance"); - ri1.setResourceName("resource"); - ri1.setResourceInvariantUUID(UUID.randomUUID()); - ri1.setResourceInvariantUUID(UUID.randomUUID()); - ri1.setResourceVersion("0.0.0"); - ri1.setResourceType(ResourceType.VL); - ri2 = new ResourceInstance(ri1); - assertEquals(ri1.hashCode(), ri2.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceTest.java b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceTest.java deleted file mode 100644 index 0ee68a11e..000000000 --- a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceTest.java +++ /dev/null @@ -1,152 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc - * ================================================================================ - * - * ================================================================================ - * 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.sdc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.UUID; - -import org.junit.Test; - -public class ResourceTest { - - @Test - public void testConstructors() { - Resource res = new Resource(); - assertEquals(null, res.getResourceUuid()); - assertEquals(null, res.getResourceInvariantUuid()); - assertEquals(null, res.getResourceName()); - assertEquals(null, res.getResourceType()); - assertEquals(null, res.getResourceVersion()); - - UUID uuid = UUID.randomUUID(); - res = new Resource(uuid); - assertEquals(uuid, res.getResourceUuid()); - assertEquals(null, res.getResourceInvariantUuid()); - assertEquals(null, res.getResourceName()); - assertEquals(null, res.getResourceType()); - assertEquals(null, res.getResourceVersion()); - - String name = "constTest"; - res = new Resource(name, ResourceType.CP); - assertEquals(null, res.getResourceUuid()); - assertEquals(name, res.getResourceName()); - assertEquals(ResourceType.CP, res.getResourceType()); - assertEquals(null, res.getResourceInvariantUuid()); - assertEquals(null, res.getResourceVersion()); - - uuid = UUID.randomUUID(); - UUID uuidInvariant = UUID.randomUUID(); - name = "constTestUUID"; - String version = "0.0.1"; - res = new Resource(uuid, uuidInvariant, name, version, ResourceType.VF); - assertEquals(uuid, res.getResourceUuid()); - assertEquals(uuidInvariant, res.getResourceInvariantUuid()); - assertEquals(name, res.getResourceName()); - assertEquals(ResourceType.VF, res.getResourceType()); - assertEquals(version, res.getResourceVersion()); - - Resource r2 = new Resource(res); - assertEquals(uuid, r2.getResourceUuid()); - assertEquals(uuidInvariant, r2.getResourceInvariantUuid()); - assertEquals(name, r2.getResourceName()); - assertEquals(ResourceType.VF, r2.getResourceType()); - assertEquals(version, r2.getResourceVersion()); - } - - @Test - public void testUuid() { - Resource res = new Resource(); - UUID uuid = UUID.randomUUID(); - res.setResourceUuid(uuid); - assertEquals(uuid, res.getResourceUuid()); - } - - @Test - public void testInvariantUuid() { - Resource res = new Resource(); - UUID uuid = UUID.randomUUID(); - res.setResourceInvariantUuid(uuid); - assertEquals(uuid, res.getResourceInvariantUuid()); - } - - @Test - public void testName() { - Resource res = new Resource(); - String name = "nameTest"; - res.setResourceName(name); - assertEquals(name, res.getResourceName()); - } - - @Test - public void testVersion() { - Resource res = new Resource(); - String version = "versionTest"; - res.setResourceVersion(version); - assertEquals(version, res.getResourceVersion()); - } - - @Test - public void testType() { - Resource res = new Resource(); - res.setResourceType(ResourceType.CP); - assertEquals(ResourceType.CP, res.getResourceType()); - } - - @Test - public void testEquals() { - Resource r1 = new Resource(); - Resource r2 = new Resource(r1); - assertTrue(r1.equals(r2)); - assertTrue(r2.equals(r1)); - - r1 = new Resource(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1", - ResourceType.VFC); - r2 = new Resource(r1); - assertTrue(r1.equals(r2)); - assertTrue(r2.equals(r1)); - } - - @Test - public void testToString() { - Resource r1 = new Resource(); - Resource r2 = new Resource(r1); - assertEquals(r1.toString(), r2.toString()); - - r1 = new Resource(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1", - ResourceType.VFC); - r2 = new Resource(r1); - assertEquals(r1.toString(), r2.toString()); - } - - @Test - public void testHashCode() { - Resource r1 = new Resource(); - Resource r2 = new Resource(r1); - assertEquals(r1.hashCode(), r2.hashCode()); - - r1 = new Resource(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1", - ResourceType.VFC); - r2 = new Resource(r1); - assertEquals(r1.hashCode(), r2.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceInstanceTest.java b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceInstanceTest.java deleted file mode 100644 index 14f2d3d37..000000000 --- a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceInstanceTest.java +++ /dev/null @@ -1,170 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc - * ================================================================================ - * - * ================================================================================ - * 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.sdc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.UUID; - -import org.junit.Test; - -public class ServiceInstanceTest { - - @Test - public void testConstructors() { - ServiceInstance si = new ServiceInstance(); - assertEquals(null, si.getServiceInstanceName()); - assertEquals(null, si.getServiceUUID()); - assertEquals(null, si.getServiceInstanceUUID()); - assertEquals(null, si.getServiceName()); - assertEquals(null, si.getPersonaModelUUID()); - assertEquals(null, si.getWidgetModelUUID()); - assertEquals(null, si.getWidgetModelVersion()); - - ServiceInstance si2 = new ServiceInstance((ServiceInstance) null); - assertEquals(null, si2.getServiceInstanceName()); - assertEquals(null, si2.getServiceUUID()); - assertEquals(null, si2.getServiceInstanceUUID()); - assertEquals(null, si2.getServiceName()); - assertEquals(null, si2.getPersonaModelUUID()); - assertEquals(null, si2.getWidgetModelUUID()); - assertEquals(null, si2.getWidgetModelVersion()); - - si2 = new ServiceInstance(si); - assertEquals(si2.getServiceInstanceName(), si.getServiceInstanceName()); - assertEquals(si2.getServiceUUID(), si.getServiceUUID()); - assertEquals(si2.getServiceInstanceUUID(), si.getServiceInstanceUUID()); - assertEquals(si2.getServiceName(), si.getServiceName()); - assertEquals(si2.getPersonaModelUUID(), si.getPersonaModelUUID()); - assertEquals(si2.getWidgetModelUUID(), si.getWidgetModelUUID()); - assertEquals(si2.getWidgetModelVersion(), si.getWidgetModelVersion()); - } - - @Test - public void testInstanceName() { - ServiceInstance si = new ServiceInstance(); - String name = "nameTestInstance"; - si.setServiceInstanceName(name);; - assertEquals(name, si.getServiceInstanceName()); - } - - @Test - public void testUuid() { - ServiceInstance si = new ServiceInstance(); - UUID uuid = UUID.randomUUID(); - si.setServiceUUID(uuid); - assertEquals(uuid, si.getServiceUUID()); - } - - @Test - public void testInstanceUuid() { - ServiceInstance si = new ServiceInstance(); - UUID uuid = UUID.randomUUID(); - si.setServiceInstanceUUID(uuid); - assertEquals(uuid, si.getServiceInstanceUUID()); - } - - @Test - public void testName() { - ServiceInstance si = new ServiceInstance(); - String name = "nameTest"; - si.setServiceName(name); - assertEquals(name, si.getServiceName()); - } - - @Test - public void testPersonaModelUuid() { - ServiceInstance si = new ServiceInstance(); - UUID uuid = UUID.randomUUID(); - si.setPersonaModelUUID(uuid); - assertEquals(uuid, si.getPersonaModelUUID()); - } - - @Test - public void testWidgetModelUuid() { - ServiceInstance si = new ServiceInstance(); - UUID uuid = UUID.randomUUID(); - si.setWidgetModelUUID(uuid); - assertEquals(uuid, si.getWidgetModelUUID()); - } - - @Test - public void testWidgetModelVersion() { - ServiceInstance si = new ServiceInstance(); - String version = "2.2.2"; - si.setWidgetModelVersion(version);; - assertEquals(version, si.getWidgetModelVersion()); - } - - @Test - public void testEquals() { - ServiceInstance si1 = new ServiceInstance(); - ServiceInstance si2 = new ServiceInstance(si1); - assertTrue(si1.equals(si2)); - assertTrue(si2.equals(si1)); - - si1.setServiceInstanceName("instance"); - si1.setServiceName("service"); - si1.setServiceInstanceUUID(UUID.randomUUID()); - si1.setServiceUUID(UUID.randomUUID()); - si1.setPersonaModelUUID(UUID.randomUUID()); - si1.setWidgetModelUUID(UUID.randomUUID()); - si1.setWidgetModelVersion("3.3.3"); - si2 = new ServiceInstance(si1); - assertTrue(si1.equals(si2)); - assertTrue(si2.equals(si1)); - } - - @Test - public void testToString() { - ServiceInstance si1 = new ServiceInstance(); - ServiceInstance si2 = new ServiceInstance(si1); - assertEquals(si1.toString(), si2.toString()); - - si1.setServiceInstanceName("instance"); - si1.setServiceName("service"); - si1.setServiceInstanceUUID(UUID.randomUUID()); - si1.setServiceUUID(UUID.randomUUID()); - si1.setPersonaModelUUID(UUID.randomUUID()); - si1.setWidgetModelUUID(UUID.randomUUID()); - si1.setWidgetModelVersion("3.3.3"); - si2 = new ServiceInstance(si1); - assertEquals(si1.toString(), si2.toString()); - } - - @Test - public void testHashCode() { - ServiceInstance si1 = new ServiceInstance(); - ServiceInstance si2 = new ServiceInstance(si1); - assertEquals(si1.hashCode(), si2.hashCode()); - - si1.setServiceInstanceName("instance"); - si1.setServiceName("service"); - si1.setServiceInstanceUUID(UUID.randomUUID()); - si1.setServiceUUID(UUID.randomUUID()); - si1.setPersonaModelUUID(UUID.randomUUID()); - si1.setWidgetModelUUID(UUID.randomUUID()); - si1.setWidgetModelVersion("3.3.3"); - si2 = new ServiceInstance(si1); - assertEquals(si1.hashCode(), si2.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceTest.java b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceTest.java deleted file mode 100644 index a7d223d18..000000000 --- a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc - * ================================================================================ - * - * ================================================================================ - * 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.sdc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.UUID; - -import org.junit.Test; - -public class ServiceTest { - - @Test - public void testConstructors() { - Service svc = new Service(); - assertEquals(null, svc.getServiceUUID()); - assertEquals(null, svc.getServiceInvariantUUID()); - assertEquals(null, svc.getServiceName()); - assertEquals(null, svc.getServiceVersion()); - - UUID uuid = UUID.randomUUID(); - svc = new Service(uuid); - assertEquals(uuid, svc.getServiceUUID()); - assertEquals(null, svc.getServiceInvariantUUID()); - assertEquals(null, svc.getServiceName()); - assertEquals(null, svc.getServiceVersion()); - - String name = "constTest"; - svc = new Service(name); - assertEquals(null, svc.getServiceUUID()); - assertEquals(name, svc.getServiceName()); - assertEquals(null, svc.getServiceInvariantUUID()); - assertEquals(null, svc.getServiceVersion()); - - uuid = UUID.randomUUID(); - UUID uuidInvariant = UUID.randomUUID(); - name = "constTestUUID"; - String version = "0.0.1"; - svc = new Service(uuid, uuidInvariant, name, version); - assertEquals(uuid, svc.getServiceUUID()); - assertEquals(uuidInvariant, svc.getServiceInvariantUUID()); - assertEquals(name, svc.getServiceName()); - assertEquals(version, svc.getServiceVersion()); - - Service s2 = new Service(svc); - assertEquals(uuid, s2.getServiceUUID()); - assertEquals(uuidInvariant, s2.getServiceInvariantUUID()); - assertEquals(name, s2.getServiceName()); - assertEquals(version, s2.getServiceVersion()); - } - - @Test - public void testUuid() { - Service svc = new Service(); - UUID uuid = UUID.randomUUID(); - svc.setServiceUUID(uuid); - assertEquals(uuid, svc.getServiceUUID()); - } - - @Test - public void testInvariantUuid() { - Service svc = new Service(); - UUID uuid = UUID.randomUUID(); - svc.setServiceInvariantUUID(uuid); - assertEquals(uuid, svc.getServiceInvariantUUID()); - } - - @Test - public void testName() { - Service svc = new Service(); - String name = "nameTest"; - svc.setServiceName(name); - assertEquals(name, svc.getServiceName()); - } - - @Test - public void testVersion() { - Service svc = new Service(); - String version = "versionTest"; - svc.setServiceVersion(version); - assertEquals(version, svc.getServiceVersion()); - } - - @Test - public void testEquals() { - Service s1 = new Service(); - Service s2 = new Service(s1); - assertTrue(s1.equals(s2)); - assertTrue(s2.equals(s1)); - - s1 = new Service(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1"); - s2 = new Service(s1); - assertTrue(s1.equals(s2)); - assertTrue(s2.equals(s1)); - } - - @Test - public void testToString() { - Service s1 = new Service(); - Service s2 = new Service(s1); - assertEquals(s1.toString(), s2.toString()); - - s1 = new Service(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1"); - s2 = new Service(s1); - assertEquals(s1.toString(), s2.toString()); - } - - @Test - public void testHashCode() { - Service s1 = new Service(); - Service s2 = new Service(s1); - assertEquals(s1.hashCode(), s2.hashCode()); - - s1 = new Service(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1"); - s2 = new Service(s1); - assertEquals(s1.hashCode(), s2.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdc/src/test/resources/service_trinity.yaml b/controlloop/common/model-impl/sdc/src/test/resources/service_trinity.yaml deleted file mode 100644 index d28749b1a..000000000 --- a/controlloop/common/model-impl/sdc/src/test/resources/service_trinity.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2018 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. -Service: - serviceName: trinity -
\ No newline at end of file diff --git a/controlloop/common/model-impl/sdc/src/test/resources/service_vSCP.yaml b/controlloop/common/model-impl/sdc/src/test/resources/service_vSCP.yaml deleted file mode 100644 index 5463c5ec8..000000000 --- a/controlloop/common/model-impl/sdc/src/test/resources/service_vSCP.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2018 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. -Service: - serviceName: vSCP
\ No newline at end of file diff --git a/controlloop/common/model-impl/sdc/src/test/resources/service_vUSP.yaml b/controlloop/common/model-impl/sdc/src/test/resources/service_vUSP.yaml deleted file mode 100644 index 3ed3e78f5..000000000 --- a/controlloop/common/model-impl/sdc/src/test/resources/service_vUSP.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2018 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. -Service: - serviceName: vUSP diff --git a/controlloop/common/model-impl/sdnc/pom.xml b/controlloop/common/model-impl/sdnc/pom.xml deleted file mode 100644 index d761c67ac..000000000 --- a/controlloop/common/model-impl/sdnc/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - Copyright (C) 2018 Huawei. All rights reserved. - Modifications Copyright (C) 2018 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========================================================= - --> - -<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.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>model-impl</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>sdnc</artifactId> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <version>2.13.0</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>rest</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.drools</groupId> - <artifactId>drools-core</artifactId> - <version>6.5.0.Final</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.common</groupId> - <artifactId>policy-endpoints</artifactId> - <version>${version.policy.common}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-pdp</groupId> - <artifactId>policy-management</artifactId> - <version>${version.policy.drools-pdp}</version> - <scope>provided</scope> - </dependency> - </dependencies> -</project> diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealNetworkInfo.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealNetworkInfo.java deleted file mode 100644 index 4039d9441..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealNetworkInfo.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Huawei. 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.sdnc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SdncHealNetworkInfo implements Serializable { - - private static final long serialVersionUID = 3208673205100673119L; - - @SerializedName("network-id") - private String networkId; - - public SdncHealNetworkInfo() { - // Default constructor for SdncHealActionVmInfo - } - - public String getNetworkId() { - return networkId; - } - - public void setNetworkId(String networkId) { - this.networkId = networkId; - } -} diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealRequest.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealRequest.java deleted file mode 100644 index 983084878..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealRequest.java +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018-2019 Huawei Technologies Co., Ltd. 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.sdnc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SdncHealRequest implements Serializable { - - private static final long serialVersionUID = -7341931593089709247L; - - @SerializedName("sdnc-request-header") - private SdncHealRequestHeaderInfo requestHeaderInfo; - - @SerializedName("request-information") - private SdncHealRequestInfo requestInfo; - - @SerializedName("service-information") - private SdncHealServiceInfo serviceInfo; - - @SerializedName("network-information") - private SdncHealNetworkInfo networkInfo; - - @SerializedName("vnf-information") - private SdncHealVnfInfo vnfInfo; - - @SerializedName("vf-module-request-input") - private SdncHealVfModuleRequestInput vfModuleRequestInput; - - public SdncHealRequest() { - // Default constructor for SdncHealRequest - } - - public SdncHealRequestHeaderInfo getRequestHeaderInfo() { - return requestHeaderInfo; - } - - public void setRequestHeaderInfo(SdncHealRequestHeaderInfo requestHeaderInfo) { - this.requestHeaderInfo = requestHeaderInfo; - } - - public SdncHealRequestInfo getRequestInfo() { - return requestInfo; - } - - public void setRequestInfo(SdncHealRequestInfo requestInfo) { - this.requestInfo = requestInfo; - } - - public SdncHealServiceInfo getServiceInfo() { - return serviceInfo; - } - - public void setServiceInfo(SdncHealServiceInfo serviceInfo) { - this.serviceInfo = serviceInfo; - } - - public SdncHealNetworkInfo getNetworkInfo() { - return networkInfo; - } - - public void setNetworkInfo(SdncHealNetworkInfo networkInfo) { - this.networkInfo = networkInfo; - } - - public SdncHealVnfInfo getVnfInfo() { - return vnfInfo; - } - - public void setVnfInfo(SdncHealVnfInfo vnfInfo) { - this.vnfInfo = vnfInfo; - } - - public SdncHealVfModuleRequestInput getVfModuleRequestInput() { - return vfModuleRequestInput; - } - - public void setVfModuleRequestInput(SdncHealVfModuleRequestInput input) { - this.vfModuleRequestInput = input; - } -} diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealRequestHeaderInfo.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealRequestHeaderInfo.java deleted file mode 100644 index 97426b40e..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealRequestHeaderInfo.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Huawei. 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.sdnc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SdncHealRequestHeaderInfo implements Serializable { - - private static final long serialVersionUID = 3208673205100673119L; - - @SerializedName("svc-request-id") - private String svcRequestId; - - @SerializedName("svc-action") - private String svcAction; - - public SdncHealRequestHeaderInfo() { - // Default constructor for SdncHealActionVmInfo - } - - public String getSvcRequestId() { - return svcRequestId; - } - - public void setSvcRequestId(String svcRequestId) { - this.svcRequestId = svcRequestId; - } - - public String getSvcAction() { - return svcAction; - } - - public void setSvcAction(String svcAction) { - this.svcAction = svcAction; - } -} diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealRequestInfo.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealRequestInfo.java deleted file mode 100644 index 91de4b2d2..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealRequestInfo.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Huawei. 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.sdnc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SdncHealRequestInfo implements Serializable { - - private static final long serialVersionUID = 3208673205100673119L; - - @SerializedName("request-action") - private String requestAction; - - public SdncHealRequestInfo() { - // Default constructor for SdncHealActionVmInfo - } - - public String getRequestAction() { - return requestAction; - } - - public void setRequestAction(String requestAction) { - this.requestAction = requestAction; - } -} diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealServiceInfo.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealServiceInfo.java deleted file mode 100644 index d86d32fea..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealServiceInfo.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Huawei. 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.sdnc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SdncHealServiceInfo implements Serializable { - - private static final long serialVersionUID = 3208673205100673119L; - - @SerializedName("service-instance-id") - private String serviceInstanceId; - - public SdncHealServiceInfo() { - // Default constructor for SdncHealActionVmInfo - } - - public String getServiceInstanceId() { - return serviceInstanceId; - } - - public void setServiceInstanceId(String serviceInstanceId) { - this.serviceInstanceId = serviceInstanceId; - } -} diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleParameter.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleParameter.java deleted file mode 100644 index 0ad772301..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleParameter.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Huawei Technologies Co., Ltd. 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.sdnc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SdncHealVfModuleParameter implements Serializable { - - private static final long serialVersionUID = 3208673205100673119L; - - @SerializedName("name") - private String name; - - @SerializedName("value") - private String value; - - public SdncHealVfModuleParameter() { - // Default constructor for SdncHealVfModuleParameter - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -} diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleParametersInfo.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleParametersInfo.java deleted file mode 100644 index 0463c6a5a..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleParametersInfo.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Huawei Technologies Co., Ltd. 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.sdnc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; - -public class SdncHealVfModuleParametersInfo implements Serializable { - - private static final long serialVersionUID = 3208673205100673119L; - - @SerializedName("param") - private List<SdncHealVfModuleParameter> parameters; - - public SdncHealVfModuleParametersInfo() { - // Default constructor for SdncHealVfModuleParametersInfo - parameters = new LinkedList<>(); - } - - public List<SdncHealVfModuleParameter> getParameters() { - return parameters; - } - - public void setParameters(List<SdncHealVfModuleParameter> parameters) { - this.parameters = parameters; - } - - public void addParameters(SdncHealVfModuleParameter parameter) { - parameters.add(parameter); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleRequestInput.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleRequestInput.java deleted file mode 100644 index 98cfc7ee7..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleRequestInput.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Huawei Technologies Co., Ltd. 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.sdnc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SdncHealVfModuleRequestInput implements Serializable { - - private static final long serialVersionUID = 3208673205100673119L; - - @SerializedName("vf-module-input-parameters") - private SdncHealVfModuleParametersInfo vfModuleParametersInfo; - - public SdncHealVfModuleRequestInput() { - // Default constructor for SdncHealVfModuleRequestInput - } - - public SdncHealVfModuleParametersInfo getVfModuleParametersInfo() { - return vfModuleParametersInfo; - } - - public void setVfModuleParametersInfo(SdncHealVfModuleParametersInfo info) { - this.vfModuleParametersInfo = info; - } -} diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVnfInfo.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVnfInfo.java deleted file mode 100644 index 16a6203ec..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVnfInfo.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Huawei Technologies Co., Ltd. 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.sdnc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SdncHealVnfInfo implements Serializable { - - private static final long serialVersionUID = 3208673205100673119L; - - @SerializedName("vnf-id") - private String vnfId; - - public SdncHealVnfInfo() { - // Default constructor for SdncHealVnfInfo - } - - public String getVnfId() { - return vnfId; - } - - public void setVnfId(String vnfId) { - this.vnfId = vnfId; - } -} diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java deleted file mode 100644 index c5ce6b295..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2018-2019 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd. - * ================================================================================ - * 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.sdnc; - - -import com.google.gson.JsonSyntaxException; - -import java.util.HashMap; -import java.util.Map; - -import org.drools.core.WorkingMemory; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; -import org.onap.policy.drools.system.PolicyEngine; -import org.onap.policy.rest.RestManager; -import org.onap.policy.rest.RestManager.Pair; -import org.onap.policy.sdnc.util.Serialization; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class SdncManager implements Runnable { - - private String sdncUrlBase; - private String username; - private String password; - private SdncRequest sdncRequest; - private WorkingMemory workingMem; - private static final Logger logger = LoggerFactory.getLogger(SdncManager.class); - - // The REST manager used for processing REST calls for this Sdnc manager - private RestManager restManager; - - /** - * Constructor. - * - * @param wm Drools working memory - * @param request request - */ - public SdncManager(WorkingMemory wm, SdncRequest request) { - if (wm == null || request == null) { - throw new IllegalArgumentException( - "the parameters \"wm\" and \"request\" on the SdncManager constructor may not be null" - ); - } - workingMem = wm; - sdncRequest = request; - - restManager = new RestManager(); - - setSdncParams(getPeManagerEnvProperty("sdnc.url"), getPeManagerEnvProperty("sdnc.username"), - getPeManagerEnvProperty("sdnc.password")); - } - - /** - * Set the parameters. - * - * @param baseUrl base URL - * @param name username - * @param pwd password - */ - public void setSdncParams(String baseUrl, String name, String pwd) { - sdncUrlBase = baseUrl; - username = name; - password = pwd; - } - - @Override - public void run() { - Map<String, String> headers = new HashMap<>(); - Pair<Integer, String> httpDetails; - - SdncResponse responseError = new SdncResponse(); - SdncResponseOutput responseOutput = new SdncResponseOutput(); - responseOutput.setResponseCode("404"); - responseError.setResponseOutput(responseOutput); - - headers.put("Accept", "application/json"); - String sdncUrl = sdncUrlBase + sdncRequest.getUrl(); - - try { - String sdncRequestJson = Serialization.gsonPretty.toJson(sdncRequest); - NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, sdncUrl, sdncRequestJson); - logger.info("[OUT|{}|{}|]{}{}", CommInfrastructure.REST, sdncUrl, NetLoggerUtil.SYSTEM_LS, sdncRequestJson); - - httpDetails = restManager.post(sdncUrl, username, password, headers, "application/json", - sdncRequestJson); - } catch (Exception e) { - logger.info(e.getMessage(), e); - workingMem.insert(responseError); - return; - } - - if (httpDetails == null) { - workingMem.insert(responseError); - return; - } - - try { - SdncResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, SdncResponse.class); - NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, sdncUrl, httpDetails.second); - logger.info("[IN|{}|{}|]{}{}", "Sdnc", sdncUrl, NetLoggerUtil.SYSTEM_LS, httpDetails.second); - String body = Serialization.gsonPretty.toJson(response); - logger.info("Response to Sdnc Heal post:"); - logger.info(body); - response.setRequestId(sdncRequest.getRequestId().toString()); - - if (!response.getResponseOutput().getResponseCode().equals("200")) { - logger.info( - "Sdnc Heal Restcall failed with http error code {} {}", httpDetails.first, httpDetails.second - ); - } - - workingMem.insert(response); - } catch (JsonSyntaxException e) { - logger.info("Failed to deserialize into SdncResponse {}", e.getLocalizedMessage(), e); - } catch (Exception e) { - logger.info("Unknown error deserializing into SdncResponse {}", e.getLocalizedMessage(), e); - } - } - - /** - * Protected setter for rest manager to allow mocked rest manager to be used for testing. - * @param restManager the test REST manager - */ - protected void setRestManager(final RestManager restManager) { - this.restManager = restManager; - } - - /** - * This method reads and validates environmental properties coming from the policy engine. Null properties cause - * an {@link IllegalArgumentException} runtime exception to be thrown - * @param enginePropertyName name of the parameter to retrieve - * @return the property value - */ - - private String getPeManagerEnvProperty(String enginePropertyName) { - String enginePropertyValue = PolicyEngine.manager.getEnvironmentProperty(enginePropertyName); - if (enginePropertyValue == null) { - throw new IllegalArgumentException( - "The value of policy engine manager environment property \"" - + enginePropertyName + "\" may not be null" - ); - } - return enginePropertyValue; - } -} diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncRequest.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncRequest.java deleted file mode 100644 index 7590c0da4..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncRequest.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018-2019 Huawei Technologies Co., Ltd. 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.sdnc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.UUID; - -public class SdncRequest implements Serializable { - - private static final long serialVersionUID = 3736300970326332512L; - // These fields are not serialized and not part of JSON - private transient String nsInstanceId; - private transient UUID requestId; - private transient String url; - - @SerializedName("input") - private SdncHealRequest healRequest; - - public SdncRequest() { - // Default constructor for SdncRequest - } - - public String getNsInstanceId() { - return nsInstanceId; - } - - public void setNsInstanceId(String nsInstanceId) { - this.nsInstanceId = nsInstanceId; - } - - public UUID getRequestId() { - return requestId; - } - - public void setRequestId(UUID requestId) { - this.requestId = requestId; - } - - public SdncHealRequest getHealRequest() { - return healRequest; - } - - public void setHealRequest(SdncHealRequest healRequest) { - this.healRequest = healRequest; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } -} diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncResponse.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncResponse.java deleted file mode 100644 index c0f244413..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncResponse.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Huawei. 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.sdnc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SdncResponse implements Serializable { - - private static final long serialVersionUID = 9151443891238218455L; - - @SerializedName("output") - private SdncResponseOutput responseOutput; - - private transient String requestId; - - public SdncResponse() { - // Default constructor for SdncResponse - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public SdncResponseOutput getResponseOutput() { - return responseOutput; - } - - public void setResponseOutput(SdncResponseOutput responseOutput) { - this.responseOutput = responseOutput; - } - -} diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncResponseNetworkInfo.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncResponseNetworkInfo.java deleted file mode 100644 index 75582ff45..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncResponseNetworkInfo.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Huawei. 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.sdnc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SdncResponseNetworkInfo implements Serializable { - - private static final long serialVersionUID = 6827782899144150158L; - - @SerializedName("instance-id") - private String instanceId; - - @SerializedName("object-path") - private String objectPath; - - public SdncResponseNetworkInfo() { - // Default constructor for SdncResponseNetworkInfo - } - - public String getInstanceId() { - return instanceId; - } - - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } - - public String getObjectPath() { - return objectPath; - } - - public void setObjectPath(String objectPath) { - this.objectPath = objectPath; - } -} diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncResponseOutput.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncResponseOutput.java deleted file mode 100644 index 48acc5e9a..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncResponseOutput.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Huawei. 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.sdnc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.List; - -public class SdncResponseOutput implements Serializable { - - private static final long serialVersionUID = 6827782899144150158L; - - @SerializedName("svc-request-id") - private String svcRequestId; - - @SerializedName("response-code") - private String responseCode; - - @SerializedName("ack-final-indicator") - private String ackFinalIndicator; - - public SdncResponseOutput() { - // Default constructor for SdncResponseDescriptor - } - - public String getSvcRequestId() { - return svcRequestId; - } - - public void setSvcRequestId(String svcRequestId) { - this.svcRequestId = svcRequestId; - } - - public String getResponseCode() { - return responseCode; - } - - public void setResponseCode(String responseCode) { - this.responseCode = responseCode; - } - - public String getAckFinalIndicator() { - return ackFinalIndicator; - } - - public void setAckFinalIndicator(String ackFinalIndicator) { - this.ackFinalIndicator = ackFinalIndicator; - } - -} diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncResponseServiceInfo.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncResponseServiceInfo.java deleted file mode 100644 index 745ba2475..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncResponseServiceInfo.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Huawei. 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.sdnc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SdncResponseServiceInfo implements Serializable { - - private static final long serialVersionUID = 6827782899144150158L; - - @SerializedName("instance-id") - private String instanceId; - - public SdncResponseServiceInfo() { - // Default constructor for SdncResponseServiceInfo - } - - public String getInstanceId() { - return instanceId; - } - - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } - -} diff --git a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/util/Serialization.java b/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/util/Serialization.java deleted file mode 100644 index 260407af2..000000000 --- a/controlloop/common/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/util/Serialization.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Huawei Corp. 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.sdnc.util; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -public final class Serialization { - private Serialization() { - } - - public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping() - .setPrettyPrinting() - .create(); - -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/DemoTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/DemoTest.java deleted file mode 100644 index 843f24dd1..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/DemoTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Huawei. 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.sdnc; - -import java.util.LinkedList; - -import org.junit.Test; -import org.onap.policy.sdnc.util.Serialization; - -public class DemoTest { - - @Test - public void test() { - SdncRequest request = new SdncRequest(); - - request.setNsInstanceId("100"); - request.setHealRequest(new SdncHealRequest()); - - request.getHealRequest().setRequestHeaderInfo(new SdncHealRequestHeaderInfo()); - request.getHealRequest().getRequestHeaderInfo().setSvcRequestId("service-req-01"); - request.getHealRequest().getRequestHeaderInfo().setSvcAction("servive-action"); - - request.getHealRequest().setRequestInfo(new SdncHealRequestInfo()); - request.getHealRequest().getRequestInfo().setRequestAction("request-action"); - - request.getHealRequest().setServiceInfo(new SdncHealServiceInfo()); - request.getHealRequest().getServiceInfo().setServiceInstanceId("service-instance-01"); - - request.getHealRequest().setNetworkInfo(new SdncHealNetworkInfo()); - request.getHealRequest().getNetworkInfo().setNetworkId("network-5555"); - - - String body = Serialization.gsonPretty.toJson(request); - System.out.println(body); - - SdncResponse response = new SdncResponse(); - - body = Serialization.gsonPretty.toJson(response); - System.out.println(body); - - response.setRequestId("request-01"); - response.setResponseOutput(new SdncResponseOutput()); - response.getResponseOutput().setSvcRequestId("service-req-01"); - response.getResponseOutput().setResponseCode("200"); - response.getResponseOutput().setAckFinalIndicator("final-indicator-00"); - - body = Serialization.gsonPretty.toJson(response); - System.out.println(body); - - response = Serialization.gsonPretty.fromJson(body, SdncResponse.class); - body = Serialization.gsonPretty.toJson(response); - System.out.println(body); - - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealAdditionalParamsTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealAdditionalParamsTest.java deleted file mode 100644 index 0403dd0a5..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealAdditionalParamsTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Huawei. 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.sdnc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class SdncHealAdditionalParamsTest { - - @Test - public void testSdncHealAdditionalParameters() { - SdncHealRequestHeaderInfo additionalParams = new SdncHealRequestHeaderInfo(); - assertNotNull(additionalParams); - assertNotEquals(0, additionalParams.hashCode()); - - String action = "Go Home"; - additionalParams.setSvcAction(action); - assertEquals(action, additionalParams.getSvcAction()); - - String requestId = "My Request"; - additionalParams.setSvcRequestId(requestId); - assertEquals(requestId, additionalParams.getSvcRequestId()); - - assertNotEquals(0, additionalParams.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealRequestTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealRequestTest.java deleted file mode 100644 index 705d3573f..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealRequestTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Huawei. 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.sdnc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class SdncHealRequestTest { - - @Test - public void testSdncHealRequest() { - SdncHealRequest request = new SdncHealRequest(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - SdncHealRequestInfo requestInfo = new SdncHealRequestInfo(); - request.setRequestInfo(requestInfo); - assertEquals(requestInfo, request.getRequestInfo()); - - assertNotEquals(0, request.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealServiceInfoTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealServiceInfoTest.java deleted file mode 100644 index 17791a1d9..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealServiceInfoTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnc - * ================================================================================ - * Copyright (C) 2018 Huawei. 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.sdnc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class SdncHealServiceInfoTest { - - @Test - public void testSdncHealServiceInfo() { - SdncHealServiceInfo serviceInfo = new SdncHealServiceInfo(); - assertNotNull(serviceInfo); - assertNotEquals(0, serviceInfo.hashCode()); - - String svrid = "ECity"; - serviceInfo.setServiceInstanceId(svrid); - assertEquals(svrid, serviceInfo.getServiceInstanceId()); - - assertNotEquals(0, serviceInfo.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncManagerTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncManagerTest.java deleted file mode 100644 index 2431fc715..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncManagerTest.java +++ /dev/null @@ -1,283 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnc - * ================================================================================ - * Copyright (C) 2018 Huawei. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.endsWith; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.startsWith; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import org.drools.core.WorkingMemory; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.drools.system.PolicyEngine; -import org.onap.policy.rest.RestManager; -import org.onap.policy.rest.RestManager.Pair; -import org.onap.policy.sdnc.util.Serialization; - -public class SdncManagerTest { - private static WorkingMemory mockedWorkingMemory; - - private RestManager mockedRestManager; - - private Pair<Integer, String> httpResponsePutOk; - private Pair<Integer, String> httpResponseGetOk; - private Pair<Integer, String> httpResponseBadResponse; - private Pair<Integer, String> httpResponseErr; - - private SdncRequest request; - private SdncResponse response; - - @BeforeClass - public static void beforeTestSdncManager() { - mockedWorkingMemory = mock(WorkingMemory.class); - } - - /** - * Set up the mocked REST manager. - */ - @Before - public void setupMockedRest() { - mockedRestManager = mock(RestManager.class); - - httpResponsePutOk = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(response)); - httpResponseGetOk = mockedRestManager.new Pair<>(200, Serialization.gsonPretty.toJson(response)); - httpResponseBadResponse = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(null)); - httpResponseErr = mockedRestManager.new Pair<>(200, null); - } - - /** - * Create the request and response before. - */ - @Before - public void createRequestAndResponse() { - SdncHealServiceInfo serviceInfo = new SdncHealServiceInfo(); - serviceInfo.setServiceInstanceId("E-City"); - - SdncHealRequestHeaderInfo additionalParams = new SdncHealRequestHeaderInfo(); - additionalParams.setSvcAction("Go Home"); - additionalParams.setSvcRequestId("My Request"); - - SdncHealRequest healRequest = new SdncHealRequest(); - healRequest.setRequestHeaderInfo(additionalParams); - healRequest.setServiceInfo(serviceInfo); - - UUID requestId = UUID.randomUUID(); - request = new SdncRequest(); - request.setRequestId(requestId); - request.setHealRequest(healRequest); - request.setNsInstanceId("Dorothy"); - - SdncResponseOutput responseDescriptor = new SdncResponseOutput(); - responseDescriptor.setSvcRequestId("1234"); - responseDescriptor.setResponseCode("200"); - responseDescriptor.setAckFinalIndicator("final-indicator-00"); - - response = new SdncResponse(); - response.setRequestId(request.getRequestId().toString()); - response.setResponseOutput(responseDescriptor); - } - - /** - * After Test clean up. - */ - @After - public void afterTestSdncManager() throws InterruptedException { - PolicyEngine.manager.getEnvironment().remove("sdnc.password"); - PolicyEngine.manager.getEnvironment().remove("sdnc.username"); - PolicyEngine.manager.getEnvironment().remove("sdnc.url"); - } - - @Test - public void testSdncInitiation() throws InterruptedException { - try { - new SdncManager(null, null); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals( - "the parameters \"wm\" and \"request\" on the SdncManager constructor may not be null", - e.getMessage() - ); - } - - try { - new SdncManager(mockedWorkingMemory, null); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals( - "the parameters \"wm\" and \"request\" on the SdncManager constructor may not be null", - e.getMessage() - ); - } - - try { - new SdncManager(mockedWorkingMemory, request); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals( - "The value of policy engine manager environment property \"sdnc.url\" may not be null", - e.getMessage() - ); - } - - PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); - try { - new SdncManager(mockedWorkingMemory, request); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals( - "The value of policy engine manager environment property \"sdnc.username\" may not be null", - e.getMessage() - ); - } - - PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); - try { - new SdncManager(mockedWorkingMemory, request); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals( - "The value of policy engine manager environment property \"sdnc.password\" may not be null", - e.getMessage() - ); - } - - PolicyEngine.manager.getEnvironment().put("sdnc.password", "Toto"); - new SdncManager(mockedWorkingMemory, request); - } - - @Test - public void testSdncExecutionException() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("sdnc.password", "Exception"); - - SdncManager manager = new SdncManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Exception"), anyMap(), anyString(), anyString())) - .thenThrow(new RuntimeException("OzException")); - - - managerThread.join(100); - } - - @Test - public void testSdncExecutionNull() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("sdnc.password", "Null"); - - SdncManager manager = new SdncManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Null"), anyMap(), anyString(), anyString())) - .thenReturn(null); - - managerThread.join(100); - } - - - @Test - public void testSdncExecutionError0() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("sdnc.password", "Error0"); - - SdncManager manager = new SdncManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Error0"), anyMap(), anyString(), anyString())) - .thenReturn(httpResponseErr); - - managerThread.join(100); - } - - @Test - public void testSdncExecutionBadResponse() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("sdnc.password", "BadResponse"); - - SdncManager manager = new SdncManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("OK"), anyMap(), anyString(), anyString())) - .thenReturn(httpResponseBadResponse); - - managerThread.join(100); - } - - @Test - public void testSdncExecutionOk() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("sdnc.password", "OK"); - - SdncManager manager = new SdncManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("OK"), anyMap(), anyString(), anyString())) - .thenReturn(httpResponsePutOk); - - when(mockedRestManager.get(endsWith("1234"), eq("Dorothy"), eq("OK"), anyMap())) - .thenReturn(httpResponseGetOk); - - - managerThread.join(100); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncRequestTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncRequestTest.java deleted file mode 100644 index 0c8a44898..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncRequestTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnc - * ================================================================================ - * Copyright (C) 2018 Huawei. 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.sdnc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; - -import org.junit.Test; - -public class SdncRequestTest { - - @Test - public void testSdncRequest() { - SdncRequest request = new SdncRequest(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - String nsInstanceId = "Dorothy"; - request.setNsInstanceId(nsInstanceId); - assertEquals(nsInstanceId, request.getNsInstanceId()); - - UUID requestId = UUID.randomUUID(); - request.setRequestId(requestId); - assertEquals(requestId, request.getRequestId()); - - SdncHealRequest healRequest = new SdncHealRequest(); - request.setHealRequest(healRequest); - assertEquals(healRequest, request.getHealRequest()); - - assertNotEquals(0, request.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncResponseDescriptorTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncResponseDescriptorTest.java deleted file mode 100644 index 5fdf2b3e2..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncResponseDescriptorTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnc - * ================================================================================ - * Copyright (C) 2018 Huawei. 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.sdnc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -public class SdncResponseDescriptorTest { - - @Test - public void testSdncResponseDescriptor() { - SdncResponseOutput output = new SdncResponseOutput(); - assertNotNull(output); - assertNotEquals(0, output.hashCode()); - - String responseCode = "200"; - output.setResponseCode(responseCode); - assertEquals(responseCode, output.getResponseCode()); - - String svcRequest = "svc-request-01"; - output.setSvcRequestId(svcRequest); - assertEquals(svcRequest, output.getSvcRequestId()); - - String indicator = "final-indicator-00"; - output.setAckFinalIndicator(indicator); - assertEquals(indicator, output.getAckFinalIndicator()); - - assertNotEquals(0, output.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncResponseTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncResponseTest.java deleted file mode 100644 index aa879f04e..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncResponseTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnc - * ================================================================================ - * Copyright (C) 2018 Huawei. 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.sdnc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - - -import org.junit.Test; - -public class SdncResponseTest { - - @Test - public void testSdncResponse() { - SdncResponse response = new SdncResponse(); - assertNotNull(response); - assertNotEquals(0, response.hashCode()); - - String requestId = "Get Home"; - response.setRequestId(requestId); - assertEquals(requestId, response.getRequestId()); - - SdncResponseOutput responseDescriptor = new SdncResponseOutput(); - response.setResponseOutput(responseDescriptor); - assertEquals(responseDescriptor, response.getResponseOutput()); - - assertNotEquals(0, response.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/util/SerializationTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/util/SerializationTest.java deleted file mode 100644 index 9b3ab7856..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/util/SerializationTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Huawei. 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.sdnc.util; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class SerializationTest { - - @Test - public void test() { - assertNotNull(Serialization.gsonPretty); - } -} diff --git a/controlloop/common/model-impl/sdnr/pom.xml b/controlloop/common/model-impl/sdnr/pom.xml deleted file mode 100644 index 6515e5186..000000000 --- a/controlloop/common/model-impl/sdnr/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - Drools PDP Application Models - ================================================================================ - Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. - Modifications Copyright (C) 2018 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========================================================= - --> - -<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.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>model-impl</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>sdnr</artifactId> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <scope>provided</scope> - </dependency> - </dependencies> -</project> diff --git a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciCommonHeader.java b/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciCommonHeader.java deleted file mode 100644 index d9e59ad3b..000000000 --- a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciCommonHeader.java +++ /dev/null @@ -1,264 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.time.Instant; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -public class PciCommonHeader implements Serializable { - - private static final long serialVersionUID = 5435363539127062114L; - - @SerializedName(value = "TimeStamp") - private Instant timeStamp = Instant.now(); - - @SerializedName(value = "APIVer") - private String apiVer = "1.0"; - - @SerializedName(value = "RequestID") - private UUID requestId; - - @SerializedName(value = "SubRequestID") - private String subRequestId; - - @SerializedName(value = "RequestTrack") - private Map<String, String> requestTrack = new HashMap<>(); - - @SerializedName(value = "Flags") - private Map<String, String> flags = new HashMap<>(); - - public PciCommonHeader() { - - } - - /** - * Used to copy a pci common header. - * - * @param commonHeader a header that is defined by the Pci api guide that contains information - * about the request (requestId, flags, etc.) - */ - public PciCommonHeader(PciCommonHeader commonHeader) { - this.timeStamp = commonHeader.timeStamp; - this.requestId = commonHeader.requestId; - this.subRequestId = commonHeader.subRequestId; - if (commonHeader.requestTrack != null) { - this.requestTrack.putAll(commonHeader.requestTrack); - } - if (commonHeader.flags != null) { - this.flags.putAll(commonHeader.flags); - } - } - - /** - * Get the timestamp. - * - * @return the timeStamp - */ - public Instant getTimeStamp() { - return timeStamp; - } - - /** - * Set the timestamp. - * - * @param timeStamp - * the timeStamp to set - */ - public void setTimeStamp(Instant timeStamp) { - this.timeStamp = timeStamp; - } - - /** - * Get the API version. - * - * @return the apiVer - */ - public String getApiVer() { - return apiVer; - } - - /** - * Set the API version. - * - * @param apiVer - * the apiVer to set - */ - public void setApiVer(String apiVer) { - this.apiVer = apiVer; - } - - /** - * Get the request Id. - * - * @return the requestId - */ - public UUID getRequestId() { - return requestId; - } - - /** - * Set the request Id. - * - * @param requestId - * the requestId to set - */ - public void setRequestId(UUID requestId) { - this.requestId = requestId; - } - - /** - * Get the sub request Id. - * - * @return the subRequestId - */ - public String getSubRequestId() { - return subRequestId; - } - - /** - * Set the sub request Id. - * - * @param subRequestId - * the subRequestId to set - */ - public void setSubRequestId(String subRequestId) { - this.subRequestId = subRequestId; - } - /** - * Set the request track. - * - * @param requestTrack - * the requestTrack to set - */ - public void setRequestTrack(Map<String, String> requestTrack) { - this.requestTrack = requestTrack; - } - /** - * Get the request track. - * - * @return the requestTrack - */ - public Map<String, String> getRequestTrack() { - return requestTrack; - } - - /** - * Get the flags. - * - * @return the flags - */ - public Map<String, String> getFlags() { - return flags; - } - - /** - * Set the flags. - * - * @param flags - * the flags to set - */ - public void setFlags(Map<String, String> flags) { - this.flags = flags; - } - - @Override - public String toString() { - return "CommonHeader [timeStamp=" + timeStamp + ", apiVer=" + apiVer - + ", requestId=" + requestId + ", subRequestId=" + subRequestId + ", requestTrack=" + requestTrack - + ", flags=" + flags + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode()); - result = prime * result + ((flags == null) ? 0 : flags.hashCode()); - result = prime * result + ((requestTrack == null) ? 0 : requestTrack.hashCode()); - result = prime * result + ((requestId == null) ? 0 : requestId.hashCode()); - result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode()); - result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - PciCommonHeader other = (PciCommonHeader) obj; - if (apiVer == null) { - if (other.apiVer != null) { - return false; - } - } else if (!apiVer.equals(other.apiVer)) { - return false; - } - if (flags == null) { - if (other.flags != null) { - return false; - } - } else if (!flags.equals(other.flags)) { - return false; - } - if (requestTrack == null) { - if (other.requestTrack != null) { - return false; - } - } else if (!requestTrack.equals(other.requestTrack)) { - return false; - } - if (requestId == null) { - if (other.requestId != null) { - return false; - } - } else if (!requestId.equals(other.requestId)) { - return false; - } - if (subRequestId == null) { - if (other.subRequestId != null) { - return false; - } - } else if (!subRequestId.equals(other.subRequestId)) { - return false; - } - if (timeStamp == null) { - if (other.timeStamp != null) { - return false; - } - } else if (!timeStamp.equals(other.timeStamp)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequest.java b/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequest.java deleted file mode 100644 index 5155f0b5c..000000000 --- a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequest.java +++ /dev/null @@ -1,143 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class PciRequest implements Serializable { - - private static final long serialVersionUID = 323235565922846624L; - - @SerializedName(value = "CommonHeader") - private PciCommonHeader commonHeader; - - @SerializedName(value = "Action") - private String action; - - @SerializedName(value = "Payload") - private String payload; - - public PciRequest() { - // Create a default PCI request - } - - public PciCommonHeader getCommonHeader() { - return commonHeader; - } - - public void setCommonHeader(PciCommonHeader commonHeader) { - this.commonHeader = commonHeader; - } - - /** - * Get the action. - * - * @return the action - */ - public String getAction() { - return action; - } - - /** - * Set the action. - * - * @param action - * the action to set - */ - public void setAction(String action) { - this.action = action; - } - - /** - * Get the payload. - * - * @return the payload - */ - - public String getPayload() { - return payload; - } - - /** - * Set the payload. - * - * @param action - * the action to set - */ - - public void setPayload(String payload) { - this.payload = payload; - } - - @Override - public String toString() { - return "PciRequest[commonHeader=" + commonHeader + ", action=" + action + ", payload=" + payload + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode()); - result = prime * result + ((action == null) ? 0 : action.hashCode()); - result = prime * result + ((payload == null) ? 0 : payload.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - PciRequest other = (PciRequest) obj; - if (commonHeader == null) { - if (other.commonHeader != null) { - return false; - } - } else if (!commonHeader.equals(other.commonHeader)) { - return false; - } - if (action == null) { - if (other.action != null) { - return false; - } - } else if (!action.equals(other.action)) { - return false; - } - if (payload == null) { - if (other.payload != null) { - return false; - } - } else if (!payload.equals(other.payload)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequestWrapper.java b/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequestWrapper.java deleted file mode 100644 index 5a84009c0..000000000 --- a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciRequestWrapper.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class PciRequestWrapper extends PciWrapper implements Serializable { - - private static final long serialVersionUID = 879766924715980798L; - - @SerializedName(value = "body") - private PciRequest body; - - public PciRequestWrapper() { - super(); - } - - public PciRequestWrapper(PciRequest request) { - body = request; - } - - /** - * Get the body. - * - * @return the body - */ - public PciRequest getBody() { - return body; - } - - /** - * Set the body. - * - * @param body - * the body to set - */ - public void setBody(PciRequest body) { - this.body = body; - } - - @Override - public String toString() { - return "RequestWrapper [body=" + body + ", toString()=" + super.toString() + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((body == null) ? 0 : body.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - PciRequestWrapper other = (PciRequestWrapper) obj; - if (body == null) { - if (other.body != null) { - return false; - } - } else if (!body.equals(other.body)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponse.java b/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponse.java deleted file mode 100644 index 21750e1bd..000000000 --- a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponse.java +++ /dev/null @@ -1,159 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class PciResponse implements Serializable { - - private static final long serialVersionUID = 8375708697287669750L; - - @SerializedName(value = "CommonHeader") - private PciCommonHeader commonHeader; - - @SerializedName(value = "Status") - private Status status = new Status(); - - @SerializedName(value = "Payload") - private String payload; - - public PciResponse() { - // EMPTY - } - - /** - * Constructs a response using the common header of the request since they will - * be the same. - * - * @param request - * an sdnr Pci request object specified by the Pci api guide - */ - public PciResponse(PciRequest request) { - this.commonHeader = new PciCommonHeader(request.getCommonHeader()); - - } - - /** - * Get the common header. - * - * @return the commonHeader - */ - public PciCommonHeader getCommonHeader() { - return commonHeader; - } - - /** - * Set the common header. - * - * @param commonHeader - * the commonHeader to set - */ - public void setCommonHeader(PciCommonHeader commonHeader) { - this.commonHeader = commonHeader; - } - - /** - * Get the status. - * - * @return the status - */ - public Status getStatus() { - return status; - } - - /** - * Set the status. - * - * @param status - * the status to set - */ - public void setStatus(Status status) { - this.status = status; - } - - /** - * Get the payload. - * - * @return the payload - */ - - public String getPayload() { - return payload; - } - - public void setPayload(String payload) { - this.payload = payload; - } - - @Override - public String toString() { - return "PciResponse[CommonHeader=" + commonHeader + ", Status=" + status + ", Payload=" - + payload + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode()); - result = prime * result + ((payload == null) ? 0 : payload.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - PciResponse other = (PciResponse) obj; - if (commonHeader == null) { - if (other.commonHeader != null) { - return false; - } - } else if (!commonHeader.equals(other.commonHeader)) { - return false; - } - if (payload == null) { - if (other.payload != null) { - return false; - } - } else if (!payload.equals(other.payload)) { - return false; - } - if (status == null) { - if (other.status != null) { - return false; - } - } else if (!status.equals(other.status)) { - return false; - } - return true; - } -} diff --git a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseCode.java b/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseCode.java deleted file mode 100644 index 430adcb92..000000000 --- a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseCode.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd. 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.sdnr; - -import java.io.Serializable; -import org.onap.policy.sdnr.util.StatusCodeEnum; - -public class PciResponseCode implements Serializable { - - /* These fields define the key to the response code value. */ - public static final String ACCEPTED = "ACCEPTED"; - public static final String ERROR = "ERROR"; - public static final String REJECT = "REJECT"; - public static final String SUCCESS = "SUCCESS"; - public static final String FAILURE = "FAILURE"; - public static final String PARTIAL_SUCCESS = "PARTIAL SUCCESS"; - public static final String PARTIAL_FAILURE = "PARTIAL FAILURE"; - private static final long serialVersionUID = -5371924429933449763L; - - private final Integer code; - - protected PciResponseCode(final int code) { - this.code = code; - } - - public int getCode() { - return this.code; - } - - @Override - public String toString() { - return Integer.toString(this.code); - } - - /** - * Translates the code to a string value that represents the meaning of the code. - * - * @param code the numeric value that is returned by SDNR based on success, failure, etc. of the action requested - * @return the string value equivalent of the SDNR response code - */ - public static String toResponseValue(int code) { - StatusCodeEnum statusCodeEnum = StatusCodeEnum.fromStatusCode(code); - return (statusCodeEnum != null) ? statusCodeEnum.toString() : null; - } -} diff --git a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseWrapper.java b/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseWrapper.java deleted file mode 100644 index 696d08623..000000000 --- a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciResponseWrapper.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class PciResponseWrapper extends PciWrapper implements Serializable { - - private static final long serialVersionUID = 109837814781086802L; - - @SerializedName(value = "body") - private PciResponse body; - - public PciResponseWrapper() { - super(); - } - - /** - * Get the body. - * - * @return the body - */ - public PciResponse getBody() { - return body; - } - - /** - * Set the body. - * - * @param body - * the body to set - */ - public void setBody(PciResponse body) { - this.body = body; - } - - @Override - public String toString() { - return "ResponseWrapper [body=" + body + ", toString()=" + super.toString() + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((body == null) ? 0 : body.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - PciResponseWrapper other = (PciResponseWrapper) obj; - if (body == null) { - if (other.body != null) { - return false; - } - } else if (!body.equals(other.body)) { - return false; - } - return true; - } -} diff --git a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciWrapper.java b/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciWrapper.java deleted file mode 100644 index 456c57877..000000000 --- a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/PciWrapper.java +++ /dev/null @@ -1,213 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class PciWrapper implements Serializable { - - private static final long serialVersionUID = 375215806432396532L; - - @SerializedName(value = "version") - private String version; - - @SerializedName(value = "cambria-partition") - private String cambriaPartition; - - @SerializedName(value = "rpc-name") - private String rpcName; - - @SerializedName(value = "correlation-id") - private String correlationId; - - @SerializedName(value = "type") - private String type; - - public PciWrapper() { - // Create a default PciWrapper instance - } - - /** - * Get the version. - * - * @return the version - */ - public String getVersion() { - return version; - } - - /** - * Set the version. - * - * @param version - * the version to set - */ - public void setVersion(String version) { - this.version = version; - } - - /** - * Get the cambria partition. - * - * @return the cambriaPartition - */ - public String getCambriaPartition() { - return cambriaPartition; - } - - /** - * Set the cambria partition. - * - * @param cambriaPartition - * the cambriaPartition to set - */ - public void setCambriaPartition(String cambriaPartition) { - this.cambriaPartition = cambriaPartition; - } - - /** - * Get the RPN name. - * - * @return the rpcName - */ - public String getRpcName() { - return rpcName; - } - - /** - * Set the RPC name. - * - * @param rpcName - * the rpcName to set - */ - public void setRpcName(String rpcName) { - this.rpcName = rpcName; - } - - /** - * Get the correlation Id. - * - * @return the correlationId - */ - public String getCorrelationId() { - return correlationId; - } - - /** - * Set the correclation Id. - * - * @param correlationId - * the correlationId to set - */ - public void setCorrelationId(String correlationId) { - this.correlationId = correlationId; - } - - /** - * Get the type. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Set the type. - * - * @param type - * the type to set - */ - public void setType(String type) { - this.type = type; - } - - @Override - public String toString() { - return "Wrapper [version=" + version + ", cambriaPartition=" + cambriaPartition + ", rpcName=" + rpcName - + ", correlationId=" + correlationId + ", type=" + type + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((cambriaPartition == null) ? 0 : cambriaPartition.hashCode()); - result = prime * result + ((correlationId == null) ? 0 : correlationId.hashCode()); - result = prime * result + ((rpcName == null) ? 0 : rpcName.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + ((version == null) ? 0 : version.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - PciWrapper other = (PciWrapper) obj; - if (cambriaPartition == null) { - if (other.cambriaPartition != null) { - return false; - } - } else if (!cambriaPartition.equals(other.cambriaPartition)) { - return false; - } - if (correlationId == null) { - if (other.correlationId != null) { - return false; - } - } else if (!correlationId.equals(other.correlationId)) { - return false; - } - if (rpcName == null) { - if (other.rpcName != null) { - return false; - } - } else if (!rpcName.equals(other.rpcName)) { - return false; - } - if (type == null) { - if (other.type != null) { - return false; - } - } else if (!type.equals(other.type)) { - return false; - } - if (version == null) { - if (other.version != null) { - return false; - } - } else if (!version.equals(other.version)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/Status.java b/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/Status.java deleted file mode 100644 index dc0295ae1..000000000 --- a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/Status.java +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class Status implements Serializable { - - private static final long serialVersionUID = 877641506135467199L; - - @SerializedName(value = "Code") - private int code; - - @SerializedName(value = "Value") - private String value; - - public Status() { - // Create a default PciResponseStatus instance - } - - /** - * Constructor for the class Status. - * - */ - public Status(int code, String value) { - super(); - this.code = code; - this.value = value; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - @Override - public String toString() { - return "Status [code = " + code + ", value = " + value + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + code; - result = prime * result + ((value == null) ? 0 : value.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Status other = (Status) obj; - if (code != other.code) { - return false; - } - if (value == null) { - if (other.value != null) { - return false; - } - } else if (!value.equals(other.value)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/util/Serialization.java b/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/util/Serialization.java deleted file mode 100644 index 3a116d741..000000000 --- a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/util/Serialization.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2018 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.sdnr.util; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -import java.lang.reflect.Type; -import java.time.Instant; - -import org.onap.policy.sdnr.PciRequest; -import org.onap.policy.sdnr.PciResponse; - - -public final class Serialization { - public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() - .registerTypeAdapter(Instant.class, new InstantAdapter()).create(); - - public static final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() - .registerTypeAdapter(PciRequest.class, new RequestAdapter()) - .registerTypeAdapter(PciResponse.class, new ResponseAdapter()).create(); - - public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting() - .registerTypeAdapter(Instant.class, new InstantJunitAdapter()).create(); - - private Serialization() {} - - public static class RequestAdapter implements JsonSerializer<PciRequest>, JsonDeserializer<PciRequest> { - - @Override - public JsonElement serialize(PciRequest src, Type typeOfSrc, JsonSerializationContext context) { - JsonElement requestJson = gsonPretty.toJsonTree(src, PciRequest.class); - JsonObject input = new JsonObject(); - input.add("input", requestJson); - - return input; - } - - @Override - public PciRequest deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { - return gsonPretty.fromJson(json.getAsJsonObject().get("input"), PciRequest.class); - } - } - - public static class ResponseAdapter implements JsonSerializer<PciResponse>, JsonDeserializer<PciResponse> { - - @Override - public JsonElement serialize(PciResponse src, Type typeOfSrc, JsonSerializationContext context) { - JsonElement responseJson = gsonPretty.toJsonTree(src, PciResponse.class); - JsonObject output = new JsonObject(); - output.add("output", responseJson); - return output; - } - - @Override - public PciResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { - return gsonPretty.fromJson(json.getAsJsonObject().get("output"), PciResponse.class); - } - } - - public static class InstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> { - - @Override - public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { - return Instant.parse(json.getAsString()); - } - - @Override - public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) { - return new JsonPrimitive(src.toString()); - } - - } - - public static class InstantJunitAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> { - - @Override - public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { - return Instant.ofEpochMilli(json.getAsLong()); - } - - @Override - public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) { - return new JsonPrimitive(src.toEpochMilli()); - } - - } - -} diff --git a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/util/StatusCodeEnum.java b/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/util/StatusCodeEnum.java deleted file mode 100644 index 8830545da..000000000 --- a/controlloop/common/model-impl/sdnr/src/main/java/org/onap/policy/sdnr/util/StatusCodeEnum.java +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Samsung Electronics Co., Ltd. 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.sdnr.util; - -import java.util.HashMap; -import java.util.Map; - -public enum StatusCodeEnum { - ACCEPTED("ACCEPTED"), ERROR("ERROR"), REJECT("REJECT"), SUCCESS("SUCCESS"), FAILURE("FAILURE"), - PARTIAL_SUCCESS("PARTIAL SUCCESS"), PARTIAL_FAILURE("PARTIAL FAILURE"); - - private String name; - - StatusCodeEnum(final String name) { - this.name = name; - } - - public String toString() { - return this.name; - } - - /** - * Determine status enum from the code. - * - * @param statusCode integer code indicating the status - * @return enum representation of status code - */ - public static StatusCodeEnum fromStatusCode(final int statusCode) { - if (statusCode == 100) { - return ACCEPTED; - } - - if (statusCode == 200) { - return SUCCESS; - } - - if (isRejectStatusCode(statusCode)) { - return REJECT; - } - - if (statusCode == 400) { - return ERROR; - } - - if (isFailureStatusCode(statusCode)) { - return FAILURE; - } - - if (statusCode == 500) { - return PARTIAL_SUCCESS; - } - - if (isPartialFailureStatusCode(statusCode)) { - return PARTIAL_FAILURE; - } - - return null; - } - - private static boolean isRejectStatusCode(final int statusCode) { - return statusCode >= 300 && statusCode <= 313; - } - - private static boolean isFailureStatusCode(final int statusCode) { - return statusCode == 450 || (statusCode >= 401 && statusCode <= 406); - } - - private static boolean isPartialFailureStatusCode(final int statusCode) { - return statusCode >= 501 && statusCode <= 599; - } - -} diff --git a/controlloop/common/model-impl/sdnr/src/main/resources/definitions.yaml b/controlloop/common/model-impl/sdnr/src/main/resources/definitions.yaml deleted file mode 100644 index 19c91e50d..000000000 --- a/controlloop/common/model-impl/sdnr/src/main/resources/definitions.yaml +++ /dev/null @@ -1,119 +0,0 @@ -### -# ============LICENSE_START======================================================= -# sdnr -# ================================================================================ -# Copyright (C) 2018 Wipro Limited 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========================================================= -### - -Request: - type: object - properties: - CommonHeader: - type: object - properties: - TimeStamp: - type: string - APIver: - type: string - value: '1.01' - OriginatorID: - type: string - RequestID: - type: string - pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - SubRequestID: - type: string - Flags: - type: object - required: - - TimeStamp - - APIver - - OriginatorID - - RequestID - Action: - type: string - enum: - - Audit - - ActionStatus - - BlockAudits - - Configure - - HealthCheck - - Install - - LiveUpgrade - - Migrate - - ModifyConfig - - ModifyConfigANR - - Query - - Rebuild - - Reconfigure - - Restart - - Rollback - - Scale - - Start - - Stop - - Sync - - Terminate - - Test - - Upgrade - TargetID: - type: string - ObjectID: - type: string - Payload: - type: object - required: - - CommonHeader - - Action - - TargetID -Response: - type: object - properties: - CommonHeader: - type: object - properties: - TimeStamp: - type: string - APIver: - type: string - OriginatorID: - type: string - RequestID: - type: string - SubRequestID: - type: string - Flags: - type: object - required: - - TimeStamp - - APIver - - OriginatorID - - RequestID - Status: - type: object - properties: - Code: - type: integer - Value: - type: string - required: - - Code - - Value - Payload: - type: object - required: - - CommonHeader - - Status - diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java deleted file mode 100644 index 4b3201440..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.time.Instant; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.junit.Test; - -public class PciCommonHeaderTest { - - @Test - public void testPciCommonHeader() { - PciCommonHeader commonHeader = new PciCommonHeader(); - assertNotNull(commonHeader); - assertNotNull(new PciCommonHeader(commonHeader)); - assertNotEquals(0, commonHeader.hashCode()); - - commonHeader.setApiVer("Kansas"); - assertEquals("Kansas", commonHeader.getApiVer()); - - Map<String, String> flagMap = new HashMap<>(); - commonHeader.setFlags(flagMap); - assertEquals(flagMap, commonHeader.getFlags()); - - Map<String, String> requestMap = new HashMap<>(); - commonHeader.setRequestTrack(requestMap); - assertEquals(requestMap, commonHeader.getRequestTrack()); - - UUID requestId = UUID.randomUUID(); - commonHeader.setRequestId(requestId); - assertEquals(requestId, commonHeader.getRequestId()); - - commonHeader.setSubRequestId("Can I go home?"); - assertEquals("Can I go home?", commonHeader.getSubRequestId()); - - Instant timestamp = Instant.now(); - commonHeader.setTimeStamp(timestamp); - assertEquals(timestamp, commonHeader.getTimeStamp()); - - assertNotEquals(0, commonHeader.hashCode()); - - assertEquals("CommonHeader [timeStamp=", commonHeader.toString().substring(0, 24)); - - PciCommonHeader copiedPciCommonHeader = new PciCommonHeader(); - copiedPciCommonHeader.setApiVer(commonHeader.getApiVer()); - copiedPciCommonHeader.setFlags(commonHeader.getFlags()); - copiedPciCommonHeader.setRequestId(commonHeader.getRequestId()); - copiedPciCommonHeader.setSubRequestId(commonHeader.getSubRequestId()); - copiedPciCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(commonHeader)); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - assertFalse(commonHeader.equals(null)); - assertFalse(commonHeader.equals("Hello")); - - PciCommonHeader clonedPciCommonHeader = new PciCommonHeader(commonHeader); - clonedPciCommonHeader.setApiVer(commonHeader.getApiVer()); - clonedPciCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(clonedPciCommonHeader)); - - commonHeader.setApiVer(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setApiVer(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setApiVer("Kansas"); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setApiVer("Kansas"); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - - commonHeader.setFlags(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setFlags(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setFlags(flagMap); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setFlags(flagMap); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - - commonHeader.setRequestTrack(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setRequestTrack(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setRequestTrack(requestMap); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setRequestTrack(requestMap); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - - - commonHeader.setRequestId(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setRequestId(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setRequestId(requestId); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setRequestId(requestId); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - - commonHeader.setSubRequestId(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setSubRequestId(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setSubRequestId("Can I go home?"); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setSubRequestId("Can I go home?"); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - - commonHeader.setTimeStamp(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setTimeStamp(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setTimeStamp(timestamp); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setTimeStamp(timestamp); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java deleted file mode 100644 index 64d976710..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class PciRequestTest { - - @Test - public void testPciRequest() { - PciRequest request = new PciRequest(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - PciCommonHeader commonHeader = new PciCommonHeader(); - String requestPayload = ""; - - request.setCommonHeader(commonHeader); - assertEquals(commonHeader, request.getCommonHeader()); - - request.setPayload(requestPayload); - assertEquals(requestPayload, request.getPayload()); - - request.setAction("Modify"); - assertEquals("Modify", request.getAction()); - - assertNotEquals(0, request.hashCode()); - - assertEquals("PciRequest[commonHeader=CommonHeader [timeStamp=", request.toString().substring(0, 48)); - - PciRequest copiedPciRequest = new PciRequest(); - copiedPciRequest.setCommonHeader(request.getCommonHeader()); - copiedPciRequest.setAction(request.getAction()); - copiedPciRequest.setPayload(request.getPayload()); - - assertTrue(request.equals(request)); - assertTrue(request.equals(copiedPciRequest)); - assertFalse(request.equals(null)); - assertFalse(request.equals("Hello")); - - request.setCommonHeader(null); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setCommonHeader(null); - assertTrue(request.equals(copiedPciRequest)); - request.setCommonHeader(commonHeader); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setCommonHeader(commonHeader); - assertTrue(request.equals(copiedPciRequest)); - - request.setAction(null); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setAction(null); - assertTrue(request.equals(copiedPciRequest)); - request.setAction("Modify"); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setAction("Modify"); - assertTrue(request.equals(copiedPciRequest)); - - request.setPayload(null); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setPayload(null); - assertTrue(request.equals(copiedPciRequest)); - request.setPayload(requestPayload); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setPayload(requestPayload); - assertTrue(request.equals(copiedPciRequest)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java deleted file mode 100644 index 79f3c0d6f..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class PciRequestWrapperTest { - - @Test - public void testPciRequestWrapperWrapper() { - assertNotNull(new PciRequestWrapper(new PciRequest())); - PciRequestWrapper requestWrapper = new PciRequestWrapper(); - assertNotNull(requestWrapper); - assertNotEquals(0, requestWrapper.hashCode()); - - PciRequest request = new PciRequest(); - - requestWrapper.setBody(request); - assertEquals(request, requestWrapper.getBody()); - - assertNotEquals(0, requestWrapper.hashCode()); - - assertEquals("RequestWrapper [body=PciRequest[commonHeader=nul", requestWrapper.toString().substring(0, 48)); - - PciRequestWrapper copiedPciRequestWrapper = new PciRequestWrapper(); - copiedPciRequestWrapper.setBody(requestWrapper.getBody()); - - assertTrue(requestWrapper.equals(requestWrapper)); - assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); - assertFalse(requestWrapper.equals(null)); - assertFalse(requestWrapper.equals("Hello")); - - requestWrapper.setBody(null); - assertFalse(requestWrapper.equals(copiedPciRequestWrapper)); - copiedPciRequestWrapper.setBody(null); - assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); - requestWrapper.setBody(request); - assertFalse(requestWrapper.equals(copiedPciRequestWrapper)); - copiedPciRequestWrapper.setBody(request); - assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseCodeTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseCodeTest.java deleted file mode 100644 index 355713133..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseCodeTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -public class PciResponseCodeTest { - - @Test - public void testPciResponseCode() { - assertNull(PciResponseCode.toResponseValue(0)); - - assertEquals(PciResponseCode.ACCEPTED, PciResponseCode.toResponseValue(100)); - assertEquals(PciResponseCode.SUCCESS, PciResponseCode.toResponseValue(200)); - assertEquals(PciResponseCode.REJECT, PciResponseCode.toResponseValue(300)); - assertEquals(PciResponseCode.ERROR, PciResponseCode.toResponseValue(400)); - assertEquals(PciResponseCode.FAILURE, PciResponseCode.toResponseValue(450)); - assertEquals(PciResponseCode.FAILURE, PciResponseCode.toResponseValue(401)); - assertEquals(PciResponseCode.FAILURE, PciResponseCode.toResponseValue(406)); - assertEquals(PciResponseCode.PARTIAL_SUCCESS, PciResponseCode.toResponseValue(500)); - assertEquals(PciResponseCode.PARTIAL_FAILURE, PciResponseCode.toResponseValue(501)); - assertEquals(PciResponseCode.PARTIAL_FAILURE, PciResponseCode.toResponseValue(599)); - - assertEquals("100", new PciResponseCode(100).toString()); - assertEquals("200", new PciResponseCode(200).toString()); - assertEquals("300", new PciResponseCode(300).toString()); - assertEquals("400", new PciResponseCode(400).toString()); - assertEquals("450", new PciResponseCode(450).toString()); - assertEquals("500", new PciResponseCode(500).toString()); - assertEquals("510", new PciResponseCode(510).toString()); - - assertEquals(300, new PciResponseCode(300).getCode()); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseTest.java deleted file mode 100644 index 52137ef7d..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class PciResponseTest { - - Status status = new Status(0, ""); - - String responsePayload = ""; - String requestPayload = ""; - - - @Test - public void testHashCode() { - PciResponse response = new PciResponse(); - assertTrue(response.hashCode() != 0); - response.setCommonHeader(new PciCommonHeader()); - assertTrue(response.hashCode() != 0); - response.setPayload(responsePayload); - assertTrue(response.hashCode() != 0); - response.setStatus(null); - assertTrue(response.hashCode() != 0); - } - - @Test - public void testPciResponse() { - PciResponse response = new PciResponse(); - assertNull(response.getCommonHeader()); - assertNull(response.getPayload()); - assertNotNull(response.getStatus()); - } - - @Test - public void testToString() { - PciResponse response = new PciResponse(); - assertFalse(response.toString().isEmpty()); - } - - @Test - public void testEqualsObject() { - PciResponse response = new PciResponse(); - assertTrue(response.equals(response)); - assertFalse(response.equals(null)); - assertFalse(response.equals(new Object())); - - PciResponse response2 = new PciResponse(); - assertTrue(response.equals(response2)); - - response.setCommonHeader(new PciCommonHeader()); - assertFalse(response.equals(response2)); - response2.setCommonHeader(response.getCommonHeader()); - assertTrue(response.equals(response2)); - - response.setPayload(responsePayload); - assertFalse(response.equals(response2)); - response2.setPayload(response.getPayload()); - assertTrue(response.equals(response2)); - - response.setCommonHeader(null); - assertFalse(response.equals(response2)); - response2.setCommonHeader(null); - assertTrue(response.equals(response2)); - - response.setPayload(null); - assertFalse(response.equals(response2)); - response2.setPayload(response.getPayload()); - assertTrue(response.equals(response2)); - - response.setStatus(null); - assertFalse(response.equals(response2)); - response2.setStatus(response.getStatus()); - assertTrue(response.equals(response2)); - - Status status = new Status(); - status.setCode(5); - response.setStatus(status); - response2.setStatus(new Status()); - assertFalse(response.equals(response2)); - } - - @Test - public void testResponseRequest() { - PciRequest request = new PciRequest(); - request.setCommonHeader(new PciCommonHeader()); - request.setPayload(requestPayload); - - PciResponse response = new PciResponse(request); - - assertTrue(response.getCommonHeader().equals(request.getCommonHeader())); - } - -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseWrapperTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseWrapperTest.java deleted file mode 100644 index 16f6f59e9..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseWrapperTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class PciResponseWrapperTest { - - @Test - public void testPciResponseWrapperWrapper() { - - PciResponseWrapper responseWrapper = new PciResponseWrapper(); - assertNotNull(responseWrapper); - assertNotEquals(0, responseWrapper.hashCode()); - - PciResponse response = new PciResponse(); - - responseWrapper.setBody(response); - assertEquals(response, responseWrapper.getBody()); - - assertNotEquals(0, responseWrapper.hashCode()); - - assertNotEquals("ResponseWrapper [body=Response [commonHeader=n", responseWrapper.toString().substring(0, 46)); - - PciResponseWrapper copiedPciResponseWrapper = new PciResponseWrapper(); - copiedPciResponseWrapper.setBody(responseWrapper.getBody()); - - assertTrue(responseWrapper.equals(responseWrapper)); - //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); - assertFalse(responseWrapper.equals(null)); - assertFalse(responseWrapper.equals("Hello")); - - responseWrapper.setBody(null); - assertFalse(responseWrapper.equals(copiedPciResponseWrapper)); - copiedPciResponseWrapper.setBody(null); - //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); - responseWrapper.setBody(response); - //assertFalse(responseWrapper.equals(copiedPciResponseWrapper)); - copiedPciResponseWrapper.setBody(response); - //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java deleted file mode 100644 index b38eed3e3..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class PciStatusTest { - - @Test - public void testResponseStatus() { - Status status = new Status(); - assertNotNull(status); - assertNotEquals(0, status.hashCode()); - - status.setCode(1234); - assertEquals(1234, status.getCode()); - - status.setValue("The wonderful land of Oz"); - assertEquals("The wonderful land of Oz", status.getValue()); - - assertEquals("Status [code = 1234, value = The wonderfu", status.toString().substring(0, 41)); - - Status copiedStatus = new Status(); - copiedStatus.setCode(status.getCode()); - copiedStatus.setValue(status.getValue()); - - assertTrue(status.equals(status)); - assertTrue(status.equals(copiedStatus)); - assertFalse(status.equals(null)); - assertFalse(status.equals("Hello")); - - status.setCode(-1); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setCode(-1); - assertTrue(status.equals(copiedStatus)); - status.setCode(1234); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setCode(1234); - assertTrue(status.equals(copiedStatus)); - - status.setValue(null); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setValue(null); - assertTrue(status.equals(copiedStatus)); - status.setValue("The wonderful land of Oz"); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setValue("The wonderful land of Oz"); - assertTrue(status.equals(copiedStatus)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java deleted file mode 100644 index a9501dddc..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class PciWrapperTest { - - @Test - public void testPciWrapper() { - PciWrapper wrapper = new PciWrapper(); - assertNotNull(wrapper); - assertNotEquals(0, wrapper.hashCode()); - - wrapper.setVersion("19.3.9"); - assertEquals("19.3.9", wrapper.getVersion()); - - wrapper.setCambriaPartition("The Emerald City"); - assertEquals("The Emerald City", wrapper.getCambriaPartition()); - - wrapper.setRpcName("Tornado"); - assertEquals("Tornado", wrapper.getRpcName()); - - wrapper.setCorrelationId("YellowBrickRoad"); - assertEquals("YellowBrickRoad", wrapper.getCorrelationId()); - - wrapper.setType("Munchkin"); - assertEquals("Munchkin", wrapper.getType()); - - assertNotEquals(0, wrapper.hashCode()); - - assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46)); - - PciWrapper copiedPciWrapper = new PciWrapper(); - copiedPciWrapper.setVersion(wrapper.getVersion()); - copiedPciWrapper.setCambriaPartition(wrapper.getCambriaPartition()); - copiedPciWrapper.setRpcName(wrapper.getRpcName()); - copiedPciWrapper.setCorrelationId(wrapper.getCorrelationId()); - copiedPciWrapper.setType(wrapper.getType()); - - assertTrue(wrapper.equals(wrapper)); - assertTrue(wrapper.equals(copiedPciWrapper)); - assertFalse(wrapper.equals(null)); - assertFalse(wrapper.equals("Hello")); - - wrapper.setVersion(null); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setVersion(null); - assertTrue(wrapper.equals(copiedPciWrapper)); - wrapper.setVersion("19.3.9"); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setVersion("19.3.9"); - assertTrue(wrapper.equals(copiedPciWrapper)); - - wrapper.setCambriaPartition(null); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setCambriaPartition(null); - assertTrue(wrapper.equals(copiedPciWrapper)); - wrapper.setCambriaPartition("The Emerald City"); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setCambriaPartition("The Emerald City"); - assertTrue(wrapper.equals(copiedPciWrapper)); - - wrapper.setRpcName(null); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setRpcName(null); - assertTrue(wrapper.equals(copiedPciWrapper)); - wrapper.setRpcName("Tornado"); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setRpcName("Tornado"); - assertTrue(wrapper.equals(copiedPciWrapper)); - - wrapper.setCorrelationId(null); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setCorrelationId(null); - assertTrue(wrapper.equals(copiedPciWrapper)); - wrapper.setCorrelationId("YellowBrickRoad"); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setCorrelationId("YellowBrickRoad"); - assertTrue(wrapper.equals(copiedPciWrapper)); - - wrapper.setType(null); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setType(null); - assertTrue(wrapper.equals(copiedPciWrapper)); - wrapper.setType("Munchkin"); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setType("Munchkin"); - assertTrue(wrapper.equals(copiedPciWrapper)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/SdnrTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/SdnrTest.java deleted file mode 100644 index f975e5575..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/SdnrTest.java +++ /dev/null @@ -1,215 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.UUID; - -import org.junit.Test; -import org.onap.policy.sdnr.util.Serialization; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SdnrTest { - - private static final Logger logger = LoggerFactory.getLogger(SdnrTest.class); - - private static PciRequestWrapper dmaapRequest; - private static PciResponseWrapper dmaapResponse; - - static { - /* - * Construct an SDNR Request to be Serialized - */ - dmaapRequest = new PciRequestWrapper(); - dmaapRequest.setCorrelationId("664be3d2-6c12-4f4b-a3e7-c349acced200" + "-" + "1"); - dmaapRequest.setRpcName("restart"); - dmaapRequest.setType("request"); - - dmaapResponse = new PciResponseWrapper(); - dmaapResponse.setCorrelationId("664be3d2-6c12-4f4b-a3e7-c349acced200" + "-" + "1"); - dmaapResponse.setRpcName("restart"); - dmaapResponse.setType("response"); - - PciRequest sdnrRequest = new PciRequest(); - - sdnrRequest.setAction("ModifyConfig"); - - PciCommonHeader commonHeader = new PciCommonHeader(); - commonHeader.setRequestId(UUID.fromString("664be3d2-6c12-4f4b-a3e7-c349acced200")); - commonHeader.setSubRequestId("1"); - - sdnrRequest.setCommonHeader(commonHeader); - - sdnrRequest.setPayload(null); - - dmaapRequest.setBody(sdnrRequest); - - /* - * Construct an SDNR Response to be Serialized - */ - PciResponse sdnrResponse = new PciResponse(sdnrRequest); - sdnrResponse.getStatus().setCode(400); - sdnrResponse.getStatus().setValue("Restart Successful"); - sdnrResponse.setPayload(null); - - dmaapResponse.setBody(sdnrResponse); - } - - @Test - public void testRequestSerialization() { - - /* - * Use the gson serializer to obtain json - */ - String jsonRequest = Serialization.gson.toJson(dmaapRequest, PciRequestWrapper.class); - assertNotNull(jsonRequest); - - /* - * The serializer should have added an extra sub-tag called "input" that wraps the request - */ - assertTrue(jsonRequest.contains("input")); - - /* - * The common-header, request-id, and sub-request-id should exist - */ - assertTrue(jsonRequest.contains("CommonHeader")); - assertTrue(jsonRequest.contains("RequestID")); - assertTrue(jsonRequest.contains("SubRequestID")); - - /* - * The action sub-tag should exist - */ - assertTrue(jsonRequest.contains("Action")); - - logger.debug("Request as JSON: " + jsonRequest + "\n\n"); - } - - @Test - public void testRequestDeserialization() { - - /* - * Convert the PCI request object into json so we have a string of json to use for testing - */ - String jsonRequest = Serialization.gson.toJson(dmaapRequest, PciRequestWrapper.class); - - /* - * Use the serializer to convert the json string into a java object - */ - PciRequestWrapper pciRequestWrapper = Serialization.gson.fromJson(jsonRequest, PciRequestWrapper.class); - assertNotNull(pciRequestWrapper); - assertEquals(dmaapRequest, pciRequestWrapper); - - /* - * The type of the DMAAP wrapper should be request - */ - assertEquals("request", dmaapRequest.getType()); - - /* - * The DMAAP wrapper must have a body as that is the true SDNR request - */ - assertNotNull(dmaapRequest.getBody()); - PciRequest sdnrRequest = dmaapRequest.getBody(); - assertNotNull(sdnrRequest); - - /* - * The common header should not be null - */ - assertNotNull(sdnrRequest.getCommonHeader()); - - /* - * The action should not be null and should be set to restart - */ - assertNotNull(sdnrRequest.getAction()); - assertEquals("ModifyConfig", sdnrRequest.getAction()); - - logger.debug("Request as a Java Object: \n" + sdnrRequest.toString() + "\n\n"); - } - - @Test - public void testResponseSerialization() { - - /* - * Use the serializer to convert the object into json - */ - String jsonResponse = Serialization.gson.toJson(dmaapResponse, PciResponseWrapper.class); - assertNotNull(jsonResponse); - - /* - * The serializer should have added an extra sub-tag called "input" that wraps the request - */ - assertTrue(jsonResponse.contains("output")); - - /* - * The response should contain a common-header, request-id, sub-request-id, and status - */ - assertTrue(jsonResponse.contains("CommonHeader")); - assertTrue(jsonResponse.contains("RequestID")); - assertTrue(jsonResponse.contains("SubRequestID")); - assertTrue(jsonResponse.contains("Status")); - - logger.debug("Response as JSON: " + jsonResponse + "\n\n"); - } - - @Test - public void testResponseDeserialization() { - /* - * Convert the PCI response object into json so we have a string of json to use for testing - */ - String jsonResponse = Serialization.gson.toJson(dmaapResponse, PciResponseWrapper.class); - - /* - * Use the serializer to convert the json string into a java object - */ - PciResponseWrapper pciResponseWrapper = Serialization.gson.fromJson(jsonResponse, PciResponseWrapper.class); - assertNotNull(pciResponseWrapper); - assertEquals(dmaapResponse, pciResponseWrapper); - - /* - * The type of the DMAAP wrapper should be response - */ - assertEquals("response", dmaapResponse.getType()); - - /* - * The DMAAP wrapper must have a body as that is the true SDNR response - */ - assertNotNull(dmaapResponse.getBody()); - PciResponse sdnrResponse = dmaapResponse.getBody(); - assertNotNull(sdnrResponse); - - /* - * The common header should not be null - */ - assertNotNull(sdnrResponse.getCommonHeader()); - - /* - * The status should not be null and the status code should be 400 - */ - assertNotNull(sdnrResponse.getStatus()); - assertEquals(400, sdnrResponse.getStatus().getCode()); - - logger.debug("Response as a Java Object: \n" + sdnrResponse.toString() + "\n\n"); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/SerializationTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/SerializationTest.java deleted file mode 100644 index e9793b286..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/SerializationTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited 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.sdnr.util; - -import static org.junit.Assert.assertEquals; - -import java.time.Instant; -import java.time.ZoneId; -import java.time.ZonedDateTime; - -import org.junit.Test; - -public class SerializationTest { - - @Test - public void test() { - String nameString = "Dorothy"; - String jsonName = Serialization.gsonPretty.toJson(nameString, String.class); - assertEquals("\"Dorothy\"", jsonName); - String jsonInOutName = Serialization.gsonPretty.fromJson(jsonName, String.class); - assertEquals("Dorothy", jsonInOutName); - - Instant instant0 = Instant.ofEpochMilli(1516127215000L); - String instantString0 = Serialization.gsonPretty.toJson(instant0, Instant.class); - assertEquals("\"2018-01-16T18:26:55Z\"", instantString0); - Instant outInstant0 = Serialization.gsonPretty.fromJson(instantString0, Instant.class); - assertEquals(instant0, outInstant0); - - Instant instant1 = Instant.ofEpochMilli(1516127215000L); - String instantString1 = Serialization.gsonJunit.toJson(instant1, Instant.class); - assertEquals("1516127215000", instantString1); - Instant outInstant1 = Serialization.gsonJunit.fromJson(instantString1, Instant.class); - assertEquals(instant1, outInstant1); - - ZonedDateTime zdt = ZonedDateTime.ofInstant(instant0, ZoneId.of("UTC")); - String zdtString = Serialization.gsonPretty.toJson(zdt, ZonedDateTime.class); - assertEquals("{\n \"dateTime\": {\n \"date\":", zdtString.substring(0, 29)); - } -} diff --git a/controlloop/common/model-impl/so/pom.xml b/controlloop/common/model-impl/so/pom.xml deleted file mode 100644 index 7ddaf2e79..000000000 --- a/controlloop/common/model-impl/so/pom.xml +++ /dev/null @@ -1,113 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - Drools PDP Application Models - ================================================================================ - Copyright (C) 2017-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========================================================= - --> - -<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.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>model-impl</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>so</artifactId> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.drools</groupId> - <artifactId>drools-core</artifactId> - <version>6.5.0.Final</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>rest</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onap.policy.common</groupId> - <artifactId>policy-endpoints</artifactId> - <version>${version.policy.common}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-pdp</groupId> - <artifactId>policy-management</artifactId> - <version>${version.policy.drools-pdp}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.glassfish.jersey.containers</groupId> - <artifactId>jersey-container-grizzly2-http</artifactId> - <version>2.25.1</version> - <scope>test</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <artifactId>maven-checkstyle-plugin</artifactId> - <executions> - <execution> - <id>onap-java-style</id> - <goals> - <goal>check</goal> - </goals> - <phase>process-sources</phase> - <configuration> - <!-- Use Google Java Style Guide: - https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml - with minor changes --> - <configLocation>onap-checkstyle/onap-java-style.xml</configLocation> - <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory --> - <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory> - <includeResources>true</includeResources> - <includeTestSourceDirectory>true</includeTestSourceDirectory> - <includeTestResources>true</includeTestResources> - <excludes> - </excludes> - <consoleOutput>true</consoleOutput> - <failsOnViolation>true</failsOnViolation> - <violationSeverity>warning</violationSeverity> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.onap.oparent</groupId> - <artifactId>checkstyle</artifactId> - <version>${oparent.version}</version> - <scope>compile</scope> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> -</project> diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoAsyncRequestStatus.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoAsyncRequestStatus.java deleted file mode 100644 index a596b1b07..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoAsyncRequestStatus.java +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.time.LocalDateTime; - -public class SoAsyncRequestStatus implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("correlator") - private String correlator; - - @SerializedName("requestId") - private String requestId; - - @SerializedName("instanceReferences") - private SoInstanceReferences instanceReferences; - - @SerializedName("startTime") - private LocalDateTime startTime; - - @SerializedName("finishTime") - private LocalDateTime finishTime; - - @SerializedName("requestScope") - private String requestScope; - - @SerializedName("requestType") - private String requestType; - - @SerializedName("requestStatus") - private SoRequestStatus requestStatus; - - public SoAsyncRequestStatus() { - // required by author - } - - public String getCorrelator() { - return correlator; - } - - - public LocalDateTime getFinishTime() { - return finishTime; - } - - public SoInstanceReferences getInstanceReferences() { - return instanceReferences; - } - - public String getRequestId() { - return requestId; - } - - public String getRequestScope() { - return requestScope; - } - - public SoRequestStatus getRequestStatus() { - return requestStatus; - } - - public String getRequestType() { - return requestType; - } - - public LocalDateTime getStartTime() { - return startTime; - } - - public void setCorrelator(String correlator) { - this.correlator = correlator; - } - - public void setFinishTime(LocalDateTime finishTime) { - this.finishTime = finishTime; - } - - public void setInstanceReferences(SoInstanceReferences instanceReferences) { - this.instanceReferences = instanceReferences; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public void setRequestScope(String requestScope) { - this.requestScope = requestScope; - } - - public void setRequestStatus(SoRequestStatus requestStatus) { - this.requestStatus = requestStatus; - } - - public void setRequestType(String requestType) { - this.requestType = requestType; - } - - public void setStartTime(LocalDateTime startTime) { - this.startTime = startTime; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoCloudConfiguration.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoCloudConfiguration.java deleted file mode 100644 index 48a2489ab..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoCloudConfiguration.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SoCloudConfiguration implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("lcpCloudRegionId") - private String lcpCloudRegionId; - - @SerializedName("tenantId") - private String tenantId; - - public SoCloudConfiguration() { - //required by author - } - - public String getLcpCloudRegionId() { - return lcpCloudRegionId; - } - - public String getTenantId() { - return tenantId; - } - - public void setLcpCloudRegionId(String lcpCloudRegionId) { - this.lcpCloudRegionId = lcpCloudRegionId; - } - - public void setTenantId(String tenantId) { - this.tenantId = tenantId; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoInstanceReferences.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoInstanceReferences.java deleted file mode 100644 index f4065e613..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoInstanceReferences.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SoInstanceReferences implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("requestId") - private String requestId; - - @SerializedName("instanceId") - private String instanceId; - - public SoInstanceReferences() { - //requried by author - } - - public String getInstanceId() { - return instanceId; - } - - public String getRequestId() { - return requestId; - } - - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoManager.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoManager.java deleted file mode 100644 index 836ebc85b..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoManager.java +++ /dev/null @@ -1,374 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd. - * ================================================================================ - * 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.so; - -import com.google.gson.GsonBuilder; -import com.google.gson.JsonSyntaxException; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import org.drools.core.WorkingMemory; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; -import org.onap.policy.drools.system.PolicyEngine; -import org.onap.policy.rest.RestManager; -import org.onap.policy.rest.RestManager.Pair; -import org.onap.policy.so.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * This class handles the interface towards SO (Service Orchestrator) for the ONAP Policy - * Framework. The SO API is defined at this link: - * http://onap.readthedocs.io/en/latest/submodules/so.git/docs/SO_R1_Interface.html#get-orchestration-request - * - */ -public final class SoManager { - private static final Logger logger = LoggerFactory.getLogger(SoManager.class); - - private static ExecutorService executors = Executors.newCachedThreadPool(); - - private static final int SO_RESPONSE_ERROR = 999; - private static final String MEDIA_TYPE = "application/json"; - private static final String LINE_SEPARATOR = System.lineSeparator(); - - // REST get timeout value in milliseconds - private static final int GET_REQUESTS_BEFORE_TIMEOUT = 20; - private static final long GET_REQUEST_WAIT_INTERVAL = 20000; - - // The REST manager used for processing REST calls for this VFC manager - private RestManager restManager; - - private long restGetTimeout = GET_REQUEST_WAIT_INTERVAL; - - /** - * Default constructor. - */ - public SoManager() { - restManager = new RestManager(); - } - - /** - * Create a service instance in SO. - * - * @param url the SO URL - * @param urlBase the base URL - * @param username user name on SO - * @param password password on SO - * @param request the request to issue to SO - * @return the SO Response object - */ - public SoResponse createModuleInstance(final String url, final String urlBase, final String username, - final String password, final SoRequest request) { - // Issue the HTTP POST request to SO to create the service instance - String requestJson = Serialization.gsonPretty.toJson(request); - NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|{}|{}|{}|{}|]{}{}", "SO", url, username, password, - createSimpleHeaders(), MEDIA_TYPE, LINE_SEPARATOR, requestJson); - Pair<Integer, String> httpResponse = - restManager.post(url, username, password, createSimpleHeaders(), MEDIA_TYPE, requestJson); - - // Process the response from SO - SoResponse response = waitForSoOperationCompletion(urlBase, username, password, url, httpResponse); - if (SO_RESPONSE_ERROR != response.getHttpResponseCode()) { - return response; - } else { - return null; - } - } - - /** - * Works just like SOManager#asyncSORestCall(String, WorkingMemory, String, String, String, SORequest) - * except the vfModuleInstanceId is always null. - * - */ - public Future<SoResponse> asyncSoRestCall(final String requestId, final WorkingMemory wm, - final String serviceInstanceId, final String vnfInstanceId, - final SoRequest request) { - return asyncSoRestCall(requestId, wm, serviceInstanceId, vnfInstanceId, null, request); - } - - /** - * This method makes an asynchronous Rest call to MSO and inserts the response into - * Drools working memory. - * - * @param requestId the request id - * @param wm the Drools working memory - * @param serviceInstanceId service instance id to construct the request url - * @param vnfInstanceId vnf instance id to construct the request url - * @param vfModuleInstanceId vfModule instance id to construct the request url (required in case of delete vf - * module) - * @param request the SO request - * @return a concurrent Future for the thread that handles the request - */ - public Future<SoResponse> asyncSoRestCall(final String requestId, - final WorkingMemory wm, - final String serviceInstanceId, - final String vnfInstanceId, - final String vfModuleInstanceId, final SoRequest request) { - return executors.submit(new AsyncSoRestCallThread(requestId, wm, serviceInstanceId, vnfInstanceId, - vfModuleInstanceId, request)); - } - - /** - * This class handles an asynchronous request to SO as a thread. - */ - private class AsyncSoRestCallThread implements Callable<SoResponse> { - final String requestId; - final WorkingMemory wm; - final String serviceInstanceId; - final String vnfInstanceId; - final String vfModuleInstanceId; - final SoRequest request; - - /** - * Constructor, sets the context of the request. - * - * @param requestID The request ID - * @param wm reference to the Drools working memory - * @param serviceInstanceId the service instance in SO to use - * @param vnfInstanceId the VNF instance that is the subject of the request - * @param vfModuleInstanceId the vf module instance id (not null in case of delete vf module request) - * @param request the request itself - */ - private AsyncSoRestCallThread(final String requestId, - final WorkingMemory wm, final String serviceInstanceId, - final String vnfInstanceId, final String vfModuleInstanceId, - final SoRequest request) { - this.requestId = requestId; - this.wm = wm; - this.serviceInstanceId = serviceInstanceId; - this.vnfInstanceId = vnfInstanceId; - this.vfModuleInstanceId = vfModuleInstanceId; - this.request = request; - } - - /** - * Process the asynchronous SO request. - */ - @Override - public SoResponse call() { - String urlBase = PolicyEngine.manager.getEnvironmentProperty("so.url"); - String username = PolicyEngine.manager.getEnvironmentProperty("so.username"); - String password = PolicyEngine.manager.getEnvironmentProperty("so.password"); - - // Create a JSON representation of the request - String soJson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create().toJson(request); - String url = null; - Pair<Integer, String> httpResponse = null; - - if (request.getOperationType() != null && request.getOperationType() - .equals(SoOperationType.SCALE_OUT)) { - url = urlBase + "/serviceInstantiation/v7/serviceInstances/" + serviceInstanceId + "/vnfs/" - + vnfInstanceId + "/vfModules/scaleOut"; - NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, soJson); - httpResponse = restManager.post(url, username, password, createSimpleHeaders(), MEDIA_TYPE, soJson); - } else if (request.getOperationType() != null && request.getOperationType() - .equals(SoOperationType.DELETE_VF_MODULE)) { - url = urlBase + "/serviceInstances/v7/" + serviceInstanceId + "/vnfs/" + vnfInstanceId - + "/vfModules/" + vfModuleInstanceId; - NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, soJson); - httpResponse = restManager.delete(url, username, password, createSimpleHeaders(), MEDIA_TYPE, soJson); - } else { - return null; - } - - // Process the response from SO - SoResponse response = waitForSoOperationCompletion(urlBase, username, password, url, httpResponse); - - // Return the response to Drools in its working memory - SoResponseWrapper soWrapper = new SoResponseWrapper(response, requestId); - wm.insert(soWrapper); - - return response; - } - } - - /** - * Wait for the SO operation we have ordered to complete. - * - * @param urlBaseSo The base URL for SO - * @param username user name on SO - * @param password password on SO - * @param initialRequestUrl The URL of the initial HTTP request - * @param initialHttpResponse The initial HTTP message returned from SO - * @return The parsed final response of SO to the request - */ - private SoResponse waitForSoOperationCompletion(final String urlBaseSo, final String username, - final String password, final String initialRequestUrl, - final Pair<Integer, String> initialHttpResponse) { - // Process the initial response from SO, the response to a post - SoResponse response = processSoResponse(initialRequestUrl, initialHttpResponse); - if (SO_RESPONSE_ERROR == response.getHttpResponseCode()) { - return response; - } - - // The SO URL to use to get the status of orchestration requests - String urlGet = urlBaseSo + "/orchestrationRequests/v5/" + response.getRequestReferences().getRequestId(); - - // The HTTP status code of the latest response - Pair<Integer, String> latestHttpResponse = initialHttpResponse; - - // Wait for the response from SO - for (int attemptsLeft = GET_REQUESTS_BEFORE_TIMEOUT; attemptsLeft >= 0; attemptsLeft--) { - // The SO request may have completed even on the first request so we check the - // response - // here before - // issuing any other requests - if (isRequestStateFinished(latestHttpResponse, response)) { - return response; - } - - // Wait for the defined interval before issuing a get - try { - Thread.sleep(restGetTimeout); - } catch (InterruptedException e) { - logger.error("Interrupted exception: ", e); - Thread.currentThread().interrupt(); - response.setHttpResponseCode(SO_RESPONSE_ERROR); - return response; - } - - // Issue a GET to find the current status of our request - NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|{}|{}|{}|{}|]{}", "SO", urlGet, username, password, - createSimpleHeaders(), MEDIA_TYPE, LINE_SEPARATOR); - Pair<Integer, String> httpResponse = restManager.get(urlGet, username, password, createSimpleHeaders()); - - // Get our response - response = processSoResponse(urlGet, httpResponse); - if (SO_RESPONSE_ERROR == response.getHttpResponseCode()) { - return response; - } - - // Our latest HTTP response code - latestHttpResponse = httpResponse; - } - - // We have timed out on the SO request - response.setHttpResponseCode(SO_RESPONSE_ERROR); - return response; - } - - /** - * Parse the response message from SO into a SOResponse object. - * - * @param requestURL The URL of the HTTP request - * @param httpResponse The HTTP message returned from SO - * @return The parsed response - */ - private SoResponse processSoResponse(final String requestUrl, final Pair<Integer, String> httpResponse) { - SoResponse response = new SoResponse(); - - // A null httpDetails indicates a HTTP problem, a valid response from SO must be - // either 200 - // or 202 - if (!httpResultIsNullFree(httpResponse) || (httpResponse.first != 200 && httpResponse.first != 202)) { - logger.error("Invalid HTTP response received from SO"); - response.setHttpResponseCode(SO_RESPONSE_ERROR); - return response; - } - - // Parse the JSON of the response into our POJO - try { - response = Serialization.gsonPretty.fromJson(httpResponse.second, SoResponse.class); - } catch (JsonSyntaxException e) { - logger.error("Failed to deserialize HTTP response into SOResponse: ", e); - response.setHttpResponseCode(SO_RESPONSE_ERROR); - return response; - } - - // Set the HTTP response code of the response if needed - if (response.getHttpResponseCode() == 0) { - response.setHttpResponseCode(httpResponse.first); - } - - NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, requestUrl, httpResponse.second); - - if (logger.isDebugEnabled()) { - logger.debug("***** Response to SO Request to URL {}:", requestUrl); - logger.debug(httpResponse.second); - } - - return response; - } - - /** - * Method to allow tuning of REST get timeout. - * - * @param restGetTimeout the timeout value - */ - protected void setRestGetTimeout(final long restGetTimeout) { - this.restGetTimeout = restGetTimeout; - } - - /** - * Check that the request state of a response is defined. - * - * @param response The response to check - * @return true if the request for the response is defined - */ - private boolean isRequestStateDefined(final SoResponse response) { - return response != null && response.getRequest() != null && response.getRequest().getRequestStatus() != null - && response.getRequest().getRequestStatus().getRequestState() != null; - } - - /** - * Check that the request state of a response is finished. - * - * @param latestHttpDetails the HTTP details of the response - * @param response The response to check - * @return true if the request for the response is finished - */ - private boolean isRequestStateFinished(final Pair<Integer, String> latestHttpDetails, final SoResponse response) { - if (latestHttpDetails != null && 200 == latestHttpDetails.first && isRequestStateDefined(response)) { - String requestState = response.getRequest().getRequestStatus().getRequestState(); - return "COMPLETE".equalsIgnoreCase(requestState) || "FAILED".equalsIgnoreCase(requestState); - } else { - return false; - } - } - - /** - * Check that a HTTP operation result has no nulls. - * - * @param httpOperationResult the result to check - * @return true if no nulls are found - */ - private boolean httpResultIsNullFree(Pair<Integer, String> httpOperationResult) { - return httpOperationResult != null && httpOperationResult.first != null && httpOperationResult.second != null; - } - - /** - * Create simple HTTP headers for unauthenticated requests to SO. - * - * @return the HTTP headers - */ - private Map<String, String> createSimpleHeaders() { - Map<String, String> headers = new HashMap<>(); - headers.put("Accept", MEDIA_TYPE); - return headers; - } -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoModelInfo.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoModelInfo.java deleted file mode 100644 index 8ab13201c..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoModelInfo.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SoModelInfo implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("modelType") - private String modelType; - - @SerializedName("modelInvariantId") - private String modelInvariantId; - - @SerializedName("modelVersionId") - private String modelVersionId; - - @SerializedName("modelName") - private String modelName; - - @SerializedName("modelVersion") - private String modelVersion; - - @SerializedName("modelCustomizationName") - private String modelCustomizationName; - - @SerializedName("modelCustomizationId") - private String modelCustomizationId; - - public SoModelInfo() { - //required by author - } - - public String getModelCustomizationId() { - return modelCustomizationId; - } - - public String getModelCustomizationName() { - return modelCustomizationName; - } - - public String getModelInvariantId() { - return modelInvariantId; - } - - public String getModelName() { - return modelName; - } - - public String getModelType() { - return modelType; - } - - public String getModelVersion() { - return modelVersion; - } - - public String getModelVersionId() { - return modelVersionId; - } - - public void setModelCustomizationId(String modelCustomizationId) { - this.modelCustomizationId = modelCustomizationId; - } - - public void setModelCustomizationName(String modelCustomizationName) { - this.modelCustomizationName = modelCustomizationName; - } - - public void setModelInvariantId(String modelInvariantId) { - this.modelInvariantId = modelInvariantId; - } - - public void setModelName(String modelName) { - this.modelName = modelName; - } - - public void setModelType(String modelType) { - this.modelType = modelType; - } - - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - - public void setModelVersionId(String modelVersionId) { - this.modelVersionId = modelVersionId; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoOperationType.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoOperationType.java deleted file mode 100644 index 191ee05d2..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoOperationType.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2018 Amdocs. All rights reserved. - * Modifications Copyright (C) 2018 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.so; - -/** - * Enumeration of SO Operations type that can be performed by a policy. - */ -public enum SoOperationType { - SCALE_OUT("Create Vf Module"), - DELETE_VF_MODULE("Delete Vf Module"); - - private String operationType; - - SoOperationType(String operationType) { - this.operationType = operationType; - } - - @Override - public String toString() { - return this.operationType; - } -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoPolicyExceptionHolder.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoPolicyExceptionHolder.java deleted file mode 100644 index 0553eac76..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoPolicyExceptionHolder.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SoPolicyExceptionHolder implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("messageId") - private String messageId; - - @SerializedName("text") - private String text; - - public SoPolicyExceptionHolder() { - //required by author - } - - public String getMessageId() { - return messageId; - } - - public String getText() { - return text; - } - - public void setMessageId(String messageId) { - this.messageId = messageId; - } - - public void setText(String text) { - this.text = text; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRelatedInstance.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRelatedInstance.java deleted file mode 100644 index f4e329643..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRelatedInstance.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SoRelatedInstance implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("instanceId") - private String instanceId; - - @SerializedName("instanceName") - private String instanceName; - - @SerializedName("modelInfo") - private SoModelInfo modelInfo; - - public SoRelatedInstance() { - //required by author - } - - public String getInstanceId() { - return instanceId; - } - - - public String getInstanceName() { - return instanceName; - } - - public SoModelInfo getModelInfo() { - return modelInfo; - } - - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } - - public void setInstanceName(String instanceName) { - this.instanceName = instanceName; - } - - - public void setModelInfo(SoModelInfo modelInfo) { - this.modelInfo = modelInfo; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRelatedInstanceListElement.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRelatedInstanceListElement.java deleted file mode 100644 index d4bf98680..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRelatedInstanceListElement.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SoRelatedInstanceListElement implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("relatedInstance") - private SoRelatedInstance relatedInstance; - - public SoRelatedInstanceListElement() { - //required by author - } - - public SoRelatedInstance getRelatedInstance() { - return relatedInstance; - } - - public void setRelatedInstance(SoRelatedInstance relatedInstance) { - this.relatedInstance = relatedInstance; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequest.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequest.java deleted file mode 100644 index 255c5b79e..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequest.java +++ /dev/null @@ -1,123 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.time.LocalDateTime; -import java.util.UUID; - -public class SoRequest implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("requestId") - private UUID requestId; - - @SerializedName("startTime") - private String startTime; - - @SerializedName("finishTime") - private LocalDateTime finishTime; - - @SerializedName("requestScope") - private String requestScope; - - @SerializedName("requestType") - private String requestType; - - @SerializedName("requestDetails") - private SoRequestDetails requestDetails; - - @SerializedName("requestStatus") - private SoRequestStatus requestStatus; - - private transient SoOperationType operationType; - - public SoRequest() { - // required by author - } - - public LocalDateTime getFinishTime() { - return finishTime; - } - - public SoRequestDetails getRequestDetails() { - return requestDetails; - } - - public UUID getRequestId() { - return requestId; - } - - public String getRequestScope() { - return requestScope; - } - - public SoRequestStatus getRequestStatus() { - return requestStatus; - } - - public String getRequestType() { - return requestType; - } - - public String getStartTime() { - return startTime; - } - - public void setFinishTime(LocalDateTime finishTime) { - this.finishTime = finishTime; - } - - public void setRequestDetails(SoRequestDetails requestDetails) { - this.requestDetails = requestDetails; - } - - public void setRequestId(UUID requestId) { - this.requestId = requestId; - } - - public void setRequestScope(String requestScope) { - this.requestScope = requestScope; - } - - public void setRequestStatus(SoRequestStatus requestStatus) { - this.requestStatus = requestStatus; - } - - public void setRequestType(String requestType) { - this.requestType = requestType; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public SoOperationType getOperationType() { - return operationType; - } - - public void setOperationType(SoOperationType operationType) { - this.operationType = operationType; - } -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestDetails.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestDetails.java deleted file mode 100644 index 0ea1a272d..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestDetails.java +++ /dev/null @@ -1,215 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -public class SoRequestDetails implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("modelInfo") - private SoModelInfo modelInfo; - - @SerializedName("cloudConfiguration") - private SoCloudConfiguration cloudConfiguration; - - @SerializedName("requestInfo") - private SoRequestInfo requestInfo; - - @SerializedName("subscriberInfo") - private SoSubscriberInfo subscriberInfo; - - @SerializedName("relatedInstanceList") - private List<SoRelatedInstanceListElement> relatedInstanceList = new LinkedList<>(); - - @SerializedName("requestParameters") - private SoRequestParameters requestParameters; - - @SerializedName("configurationParameters") - private List<Map<String, String>> configurationParameters = new LinkedList<>(); - - public SoRequestDetails() { - - } - - /** - * Constructor. - * - * @param soRequestDetails copy object - */ - public SoRequestDetails(SoRequestDetails soRequestDetails) { - this.modelInfo = soRequestDetails.modelInfo; - this.cloudConfiguration = soRequestDetails.cloudConfiguration; - this.requestInfo = soRequestDetails.requestInfo; - this.relatedInstanceList = soRequestDetails.relatedInstanceList; - this.requestParameters = soRequestDetails.requestParameters; - this.subscriberInfo = soRequestDetails.subscriberInfo; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - SoRequestDetails other = (SoRequestDetails) obj; - if (cloudConfiguration == null) { - if (other.cloudConfiguration != null) { - return false; - } - } else if (!cloudConfiguration.equals(other.cloudConfiguration)) { - return false; - } - if (configurationParameters == null) { - if (other.configurationParameters != null) { - return false; - } - } else if (!configurationParameters.equals(other.configurationParameters)) { - return false; - } - if (modelInfo == null) { - if (other.modelInfo != null) { - return false; - } - } else if (!modelInfo.equals(other.modelInfo)) { - return false; - } - if (relatedInstanceList == null) { - if (other.relatedInstanceList != null) { - return false; - } - } else if (!relatedInstanceList.equals(other.relatedInstanceList)) { - return false; - } - if (requestInfo == null) { - if (other.requestInfo != null) { - return false; - } - } else if (!requestInfo.equals(other.requestInfo)) { - return false; - } - if (requestParameters == null) { - if (other.requestParameters != null) { - return false; - } - } else if (!requestParameters.equals(other.requestParameters)) { - return false; - } - if (subscriberInfo == null) { - if (other.subscriberInfo != null) { - return false; - } - } else if (!subscriberInfo.equals(other.subscriberInfo)) { - return false; - } - return true; - } - - public SoCloudConfiguration getCloudConfiguration() { - return cloudConfiguration; - } - - public SoModelInfo getModelInfo() { - return modelInfo; - } - - public List<SoRelatedInstanceListElement> getRelatedInstanceList() { - return relatedInstanceList; - } - - public SoRequestInfo getRequestInfo() { - return requestInfo; - } - - public SoRequestParameters getRequestParameters() { - return requestParameters; - } - - public List<Map<String, String>> getConfigurationParameters() { - return configurationParameters; - } - - public SoSubscriberInfo getSubscriberInfo() { - return subscriberInfo; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((cloudConfiguration == null) ? 0 : cloudConfiguration.hashCode()); - result = prime * result + ((configurationParameters == null) ? 0 : configurationParameters.hashCode()); - result = prime * result + ((modelInfo == null) ? 0 : modelInfo.hashCode()); - result = prime * result + ((relatedInstanceList == null) ? 0 : relatedInstanceList.hashCode()); - result = prime * result + ((requestInfo == null) ? 0 : requestInfo.hashCode()); - result = prime * result + ((requestParameters == null) ? 0 : requestParameters.hashCode()); - result = prime * result + ((subscriberInfo == null) ? 0 : subscriberInfo.hashCode()); - return result; - } - - public void setCloudConfiguration(SoCloudConfiguration cloudConfiguration) { - this.cloudConfiguration = cloudConfiguration; - } - - public void setModelInfo(SoModelInfo modelInfo) { - this.modelInfo = modelInfo; - } - - public void setRequestInfo(SoRequestInfo requestInfo) { - this.requestInfo = requestInfo; - } - - public void setRequestParameters(SoRequestParameters requestParameters) { - this.requestParameters = requestParameters; - } - - public void setConfigurationParameters(List<Map<String, String>> configurationParameters) { - this.configurationParameters = configurationParameters; - } - - public void setSubscriberInfo(SoSubscriberInfo subscriberInfo) { - this.subscriberInfo = subscriberInfo; - } - - public void setRelatedInstanceList(List<SoRelatedInstanceListElement> relatedInstanceList) { - this.relatedInstanceList = relatedInstanceList; - } - - @Override - public String toString() { - return "SORequestDetails [modelInfo=" + modelInfo + ", cloudConfiguration=" + cloudConfiguration - + ", requestInfo=" + requestInfo + ", subscriberInfo=" + subscriberInfo - + ", relatedInstanceList=" + relatedInstanceList + ", requestParameters=" + requestParameters - + ", configurationParameters=" + configurationParameters + "]"; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestError.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestError.java deleted file mode 100644 index 1214a6c8c..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestError.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SoRequestError implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("policyException") - private SoPolicyExceptionHolder policyException; - - @SerializedName("serviceException") - private SoServiceExceptionHolder serviceException; - - public SoRequestError() { - // required by author - } - - public SoPolicyExceptionHolder getPolicyException() { - return policyException; - } - - public SoServiceExceptionHolder getServiceException() { - return serviceException; - } - - public void setPolicyException(SoPolicyExceptionHolder policyException) { - this.policyException = policyException; - } - - public void setServiceException(SoServiceExceptionHolder serviceException) { - this.serviceException = serviceException; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestInfo.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestInfo.java deleted file mode 100644 index ae0b57bc2..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestInfo.java +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SoRequestInfo implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("instanceName") - private String instanceName; - - @SerializedName("source") - private String source; - - @SerializedName("productFamilyId") - private String productFamilyId; - - @SerializedName("suppressRollback") - private boolean suppressRollback; - - @SerializedName("billingAccountNumber") - private String billingAccountNumber; - - @SerializedName("callbackUrl") - private String callbackUrl; - - @SerializedName("correlator") - private String correlator; - - @SerializedName("orderNumber") - private String orderNumber; - - @SerializedName("orderVersion") - private Integer orderVersion; - - @SerializedName("requestorId") - private String requestorId; - - public SoRequestInfo() { - // required by author - } - - public String getBillingAccountNumber() { - return billingAccountNumber; - } - - public String getCallbackUrl() { - return callbackUrl; - } - - public String getCorrelator() { - return correlator; - } - - public String getInstanceName() { - return instanceName; - } - - public String getOrderNumber() { - return orderNumber; - } - - public Integer getOrderVersion() { - return orderVersion; - } - - public String getProductFamilyId() { - return productFamilyId; - } - - public String getRequestorId() { - return requestorId; - } - - public String getSource() { - return source; - } - - public boolean isSuppressRollback() { - return suppressRollback; - } - - public void setBillingAccountNumber(String billingAccountNumber) { - this.billingAccountNumber = billingAccountNumber; - } - - public void setCallbackUrl(String callbackUrl) { - this.callbackUrl = callbackUrl; - } - - public void setCorrelator(String correlator) { - this.correlator = correlator; - } - - public void setInstanceName(String instanceName) { - this.instanceName = instanceName; - } - - public void setOrderNumber(String orderNumber) { - this.orderNumber = orderNumber; - } - - public void setOrderVersion(Integer orderVersion) { - this.orderVersion = orderVersion; - } - - public void setProductFamilyId(String productFamilyId) { - this.productFamilyId = productFamilyId; - } - - public void setRequestorId(String requestorId) { - this.requestorId = requestorId; - } - - public void setSource(String source) { - this.source = source; - } - - public void setSuppressRollback(boolean suppressRollback) { - this.suppressRollback = suppressRollback; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestParameters.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestParameters.java deleted file mode 100644 index bc545455b..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestParameters.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -public class SoRequestParameters implements Serializable { - - private static final long serialVersionUID = -3283942659786236033L; - - @SerializedName("subscriptionServiceType") - private String subscriptionServiceType; - - @SerializedName("usePreload") - private boolean usePreload; - - @SerializedName("userParams") - private List<Map<String, String>> userParams = new LinkedList<>(); - - public SoRequestParameters() { - // required by author - } - - public String getSubscriptionServiceType() { - return subscriptionServiceType; - } - - public boolean isUsePreload() { - return usePreload; - } - - public List<Map<String, String>> getUserParams() { - return userParams; - } - - public void setSubscriptionServiceType(String subscriptionServiceType) { - this.subscriptionServiceType = subscriptionServiceType; - } - - public void setUsePreload(boolean usePreload) { - this.usePreload = usePreload; - } - - public void setUserParams(List<Map<String, String>> userParams) { - this.userParams = userParams; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestReferences.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestReferences.java deleted file mode 100644 index 8006142ed..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestReferences.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SoRequestReferences implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("instanceId") - private String instanceId; - - @SerializedName("requestId") - private String requestId; - - public String getInstanceId() { - return instanceId; - } - - public String getRequestId() { - return requestId; - } - - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestStatus.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestStatus.java deleted file mode 100644 index 2d2e5bf24..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoRequestStatus.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SoRequestStatus implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("percentProgress") - private int percentProgress; - - @SerializedName("requestState") - private String requestState; - - @SerializedName("timestamp") - private String timestamp; - - @SerializedName("wasRolledBack") - private boolean wasRolledBack; - - public SoRequestStatus() { - //required by author - } - - public int getPercentProgress() { - return percentProgress; - } - - public String getRequestState() { - return requestState; - } - - public String getTimestamp() { - return timestamp; - } - - public boolean isWasRolledBack() { - return wasRolledBack; - } - - public void setPercentProgress(int percentProgress) { - this.percentProgress = percentProgress; - } - - public void setRequestState(String requestState) { - this.requestState = requestState; - } - - public void setTimestamp(String timestamp) { - this.timestamp = timestamp; - } - - public void setWasRolledBack(boolean wasRolledBack) { - this.wasRolledBack = wasRolledBack; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoResponse.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoResponse.java deleted file mode 100644 index 08b01c9f8..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoResponse.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SoResponse implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("requestReferences") - private SoRequestReferences requestReferences; - - @SerializedName("requestError") - private SoRequestError requestError; - - @SerializedName("request") - private SoRequest request; - - private int httpResponseCode; - - public SoResponse() { - // required by author - } - - public int getHttpResponseCode() { - return httpResponseCode; - } - - public SoRequest getRequest() { - return request; - } - - public SoRequestError getRequestError() { - return requestError; - } - - public SoRequestReferences getRequestReferences() { - return requestReferences; - } - - public void setHttpResponseCode(int httpResponseCode) { - this.httpResponseCode = httpResponseCode; - } - - public void setRequest(SoRequest request) { - this.request = request; - } - - public void setRequestError(SoRequestError requestError) { - this.requestError = requestError; - } - - public void setRequestReferences(SoRequestReferences requestReferences) { - this.requestReferences = requestReferences; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoResponseWrapper.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoResponseWrapper.java deleted file mode 100644 index 3262d03eb..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoResponseWrapper.java +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SoResponseWrapper implements Serializable { - - private static final long serialVersionUID = 7673023687132889069L; - - @SerializedName("SoResponse") - private SoResponse soResponse; - - private transient String requestId; - - public SoResponseWrapper(SoResponse response, String reqId) { - this.soResponse = response; - this.requestId = reqId; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - SoResponseWrapper other = (SoResponseWrapper) obj; - if (soResponse == null) { - if (other.soResponse != null) { - return false; - } - } - else if (!soResponse.equals(other.soResponse)) { - return false; - } - if (requestId == null) { - if (other.requestId != null) { - return false; - } - } - else if (!requestId.equals(other.requestId)) { - return false; - } - return true; - } - - public String getRequestId() { - return requestId; - } - - public SoResponse getSoResponse() { - return soResponse; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((soResponse == null) ? 0 : soResponse.hashCode()); - result = prime * result + ((requestId == null) ? 0 : requestId.hashCode()); - return result; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public void setSoResponse(SoResponse response) { - soResponse = response; - } - - @Override - public String toString() { - return "SOResponseWrapper [SOResponse=" + soResponse + ", RequestId=" + requestId + "]"; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoServiceExceptionHolder.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoServiceExceptionHolder.java deleted file mode 100644 index 5dd87e539..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoServiceExceptionHolder.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; - -public class SoServiceExceptionHolder implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("messageId") - private String messageId; - - @SerializedName("text") - private String text; - - @SerializedName("variables") - private List<String> variables = new LinkedList<>(); - - public SoServiceExceptionHolder() { - // required by author - } - - public String getMessageId() { - return messageId; - } - - public String getText() { - return text; - } - - public List<String> getVariables() { - return variables; - } - - public void setMessageId(String messageId) { - this.messageId = messageId; - } - - public void setText(String text) { - this.text = text; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoSubscriberInfo.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoSubscriberInfo.java deleted file mode 100644 index 208cff23d..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SoSubscriberInfo.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017-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.so; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class SoSubscriberInfo implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("globalSubscriberId") - private String globalSubscriberId; - - @SerializedName("subscriberCommonSiteId") - private String subscriberCommonSiteId; - - @SerializedName("subscriberName") - private String subscriberName; - - public SoSubscriberInfo() { - //required by author - } - - public String getGlobalSubscriberId() { - return globalSubscriberId; - } - - public String getSubscriberCommonSiteId() { - return subscriberCommonSiteId; - } - - public String getSubscriberName() { - return subscriberName; - } - - public void setGlobalSubscriberId(String globalSubscriberId) { - this.globalSubscriberId = globalSubscriberId; - } - - public void setSubscriberCommonSiteId(String subscriberCommonSiteId) { - this.subscriberCommonSiteId = subscriberCommonSiteId; - } - - public void setSubscriberName(String subscriberName) { - this.subscriberName = subscriberName; - } - -} diff --git a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/util/Serialization.java b/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/util/Serialization.java deleted file mode 100644 index 9bcd5e5c9..000000000 --- a/controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/util/Serialization.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * mso - * ================================================================================ - * Copyright (C) 2017 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.so.util; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -public final class Serialization { - - public static final Gson gsonPretty = - new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create(); - - private Serialization() { - // utility class with explicit private constructor - // change if class is more than utility - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/DemoTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/DemoTest.java deleted file mode 100644 index 2db347846..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/DemoTest.java +++ /dev/null @@ -1,186 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * mso - * ================================================================================ - * Copyright (C) 2017, 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.so; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; -import org.onap.policy.so.SoCloudConfiguration; -import org.onap.policy.so.SoModelInfo; -import org.onap.policy.so.SoRelatedInstance; -import org.onap.policy.so.SoRelatedInstanceListElement; -import org.onap.policy.so.SoRequest; -import org.onap.policy.so.SoRequestDetails; -import org.onap.policy.so.SoRequestInfo; -import org.onap.policy.so.SoRequestParameters; -import org.onap.policy.so.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DemoTest { - private static final Logger logger = LoggerFactory.getLogger(DemoTest.class); - - @Test - public void test() { - - SoRequest request = new SoRequest(); - request.setRequestDetails(new SoRequestDetails()); - request.getRequestDetails().setModelInfo(new SoModelInfo()); - request.getRequestDetails().setCloudConfiguration(new SoCloudConfiguration()); - request.getRequestDetails().setRequestInfo(new SoRequestInfo()); - request.getRequestDetails().setRequestParameters(new SoRequestParameters()); - - request.getRequestDetails().getModelInfo().setModelType("vfModule"); - request.getRequestDetails().getModelInfo().setModelInvariantId("ff5256d2-5a33-55df-13ab-12abad84e7ff"); - request.getRequestDetails().getModelInfo().setModelVersionId("fe6478e5-ea33-3346-ac12-ab121484a3fe"); - request.getRequestDetails().getModelInfo().setModelName("vSAMP12..base..module-0"); - request.getRequestDetails().getModelInfo().setModelVersion("1"); - - request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId("mdt1"); - request.getRequestDetails().getCloudConfiguration().setTenantId("88a6ca3ee0394ade9403f075db23167e"); - - request.getRequestDetails().getRequestInfo().setInstanceName("SOTEST103a-vSAMP12_base_module-0"); - request.getRequestDetails().getRequestInfo().setSource("VID"); - request.getRequestDetails().getRequestInfo().setSuppressRollback(true); - - SoRelatedInstanceListElement relatedInstanceListElement1 = - new SoRelatedInstanceListElement(); - SoRelatedInstanceListElement relatedInstanceListElement2 = - new SoRelatedInstanceListElement(); - SoRelatedInstanceListElement relatedInstanceListElement3 = - new SoRelatedInstanceListElement(); - relatedInstanceListElement1.setRelatedInstance(new SoRelatedInstance()); - relatedInstanceListElement2.setRelatedInstance(new SoRelatedInstance()); - relatedInstanceListElement3.setRelatedInstance(new SoRelatedInstance()); - - relatedInstanceListElement1.getRelatedInstance().setInstanceId( - "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c"); - relatedInstanceListElement1.getRelatedInstance().setInstanceName( - "SOTESTVOL103a-vSAMP12_base_module-0_vol"); - relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SoModelInfo()); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("volumeGroup"); - - relatedInstanceListElement2.getRelatedInstance().setInstanceId("serviceInstanceId"); - relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SoModelInfo()); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("service"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelInvariantId( - "ff3514e3-5a33-55df-13ab-12abad84e7ff"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId( - "fe6985cd-ea33-3346-ac12-ab121484a3fe"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName( - "parent service model name"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion("1.0"); - - relatedInstanceListElement3.getRelatedInstance().setInstanceId("vnfInstanceId"); - relatedInstanceListElement3.getRelatedInstance().setModelInfo(new SoModelInfo()); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelType("vnf"); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelInvariantId( - "ff5256d1-5a33-55df-13ab-12abad84e7ff"); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelVersionId( - "fe6478e4-ea33-3346-ac12-ab121484a3fe"); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelName("vSAMP12"); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelVersion("1.0"); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelCustomizationName("vSAMP12 1"); - - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement3); - - Map<String, String> userParam1 = new HashMap<>(); - userParam1.put("name1", "value1"); - - Map<String, String> userParam2 = new HashMap<>(); - userParam2.put("name2", "value2"); - - request.getRequestDetails().getRequestParameters().getUserParams().add(userParam1); - request.getRequestDetails().getRequestParameters().getUserParams().add(userParam2); - - logger.debug(Serialization.gsonPretty.toJson(request)); - - } - - @Test - public void testHack() { - - logger.debug("** HACK **"); - - SoRequest request = new SoRequest(); - - request.setRequestDetails(new SoRequestDetails()); - request.getRequestDetails().setModelInfo(new SoModelInfo()); - request.getRequestDetails().setCloudConfiguration(new SoCloudConfiguration()); - request.getRequestDetails().setRequestInfo(new SoRequestInfo()); - request.getRequestDetails().setRequestParameters(new SoRequestParameters()); - request.getRequestDetails().getRequestParameters().setUserParams(null); - - request.getRequestDetails().getModelInfo().setModelType("vfModule"); - request.getRequestDetails().getModelInfo().setModelInvariantId("a9c4a35a-de48-451a-9e4e-343f2ac52928"); - request.getRequestDetails().getModelInfo().setModelVersionId("e0d98ad1-238d-4555-b439-023d3f9079f6"); - request.getRequestDetails().getModelInfo().setModelName("0d9e0d9d352749f4B3cb..dnsscaling..module-0"); - request.getRequestDetails().getModelInfo().setModelVersion("2.0"); - - request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId("DFW"); - request.getRequestDetails().getCloudConfiguration().setTenantId("1015548"); - - request.getRequestDetails().getRequestInfo().setInstanceName( - "Vfmodule_Ete_Name1eScaling63928f-ccdc-4b34-bdef-9bf64109026e"); - request.getRequestDetails().getRequestInfo().setSource("POLICY"); - request.getRequestDetails().getRequestInfo().setSuppressRollback(false); - - SoRelatedInstanceListElement relatedInstanceListElement1 = - new SoRelatedInstanceListElement(); - SoRelatedInstanceListElement relatedInstanceListElement2 = - new SoRelatedInstanceListElement(); - relatedInstanceListElement1.setRelatedInstance(new SoRelatedInstance()); - relatedInstanceListElement2.setRelatedInstance(new SoRelatedInstance()); - - String serviceInstanceId = "98af39ce-6408-466b-921f-c2c7a8f59ed6"; - relatedInstanceListElement1.getRelatedInstance().setInstanceId(serviceInstanceId); - relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SoModelInfo()); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service"); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelInvariantId( - "24329a0c-1d57-4210-b1af-a65df64e9d59"); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersionId( - "ac642881-8e7e-4217-bd64-16ad41c42e30"); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName("5116d67e-0b4f-46bf-a46f"); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersion("2.0"); - - String vnfInstanceId = "8eb411b8-a936-412f-b01f-9a9a435c0e93"; - relatedInstanceListElement2.getRelatedInstance().setInstanceId(vnfInstanceId); - relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SoModelInfo()); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelInvariantId( - "09fd971e-db5f-475d-997c-cf6704b6b8fe"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId( - "152ed917-6dcc-46ee-bf8a-a775c5aa5a74"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName("9e4c31d2-4b25-4d9e-9fb4"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion("2.0"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelCustomizationName( - "0d9e0d9d-3527-49f4-b3cb 2"); - - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); - - logger.debug(Serialization.gsonPretty.toJson(request)); - } - -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/DummyWorkingMemory.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/DummyWorkingMemory.java deleted file mode 100644 index b8fd036c5..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/DummyWorkingMemory.java +++ /dev/null @@ -1,315 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2018 Ericsson. 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.so; - -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; - -import org.drools.core.WorkingMemory; -import org.drools.core.WorkingMemoryEntryPoint; -import org.drools.core.common.InternalFactHandle; -import org.drools.core.impl.InternalKnowledgeBase; -import org.drools.core.spi.AsyncExceptionHandler; -import org.drools.core.spi.GlobalResolver; -import org.kie.api.event.kiebase.KieBaseEventListener; -import org.kie.api.event.rule.AgendaEventListener; -import org.kie.api.event.rule.RuleRuntimeEventListener; -import org.kie.api.runtime.Environment; -import org.kie.api.runtime.ObjectFilter; -import org.kie.api.runtime.process.ProcessInstance; -import org.kie.api.runtime.process.WorkItemManager; -import org.kie.api.runtime.rule.Agenda; -import org.kie.api.runtime.rule.AgendaFilter; -import org.kie.api.runtime.rule.FactHandle; -import org.kie.api.runtime.rule.FactHandle.State; -import org.kie.api.runtime.rule.QueryResults; -import org.kie.api.time.SessionClock; - -public class DummyWorkingMemory implements WorkingMemory { - - @Override - public void addEventListener(RuleRuntimeEventListener listener) { - } - - @Override - public void addEventListener(AgendaEventListener listener) { - } - - @Override - public void addEventListener(KieBaseEventListener listener) { - } - - @Override - public void removeEventListener(RuleRuntimeEventListener listener) { - } - - @Override - public void removeEventListener(AgendaEventListener listener) { - } - - @Override - public void removeEventListener(KieBaseEventListener listener) { - } - - @Override - public Collection<RuleRuntimeEventListener> getRuleRuntimeEventListeners() { - return null; - } - - @Override - public Collection<AgendaEventListener> getAgendaEventListeners() { - return null; - } - - @Override - public Collection<KieBaseEventListener> getKieBaseEventListeners() { - return null; - } - - @Override - public FactHandle insert(Object object, boolean dynamic) { - return null; - } - - @Override - public FactHandle insert(Object object) { - return null; - } - - @Override - public void dispose() { - } - - @Override - public String getEntryPointId() { - return null; - } - - @Override - public void retract(FactHandle handle) { - } - - @Override - public void delete(FactHandle handle) { - } - - @Override - public void delete(FactHandle handle, State fhState) { - - - } - - @Override - public void update(FactHandle handle, Object object) { - } - - @Override - public void update(FactHandle handle, Object object, String... modifiedProperties) { - } - - @Override - public Collection<? extends Object> getObjects() { - return null; - } - - @Override - public Collection<? extends Object> getObjects(ObjectFilter filter) { - return null; - } - - @Override - public <T extends FactHandle> Collection<T> getFactHandles() { - return null; - } - - @Override - public <T extends FactHandle> Collection<T> getFactHandles(ObjectFilter filter) { - return null; - } - - @Override - public long getFactCount() { - return 0; - } - - @Override - public Agenda getAgenda() { - return null; - } - - @Override - public void setGlobal(String identifier, Object value) { - } - - @Override - public Object getGlobal(String identifier) { - return null; - } - - @Override - public Environment getEnvironment() { - return null; - } - - @Override - public void setGlobalResolver(GlobalResolver globalResolver) { - } - - @Override - public GlobalResolver getGlobalResolver() { - return null; - } - - @Override - public InternalKnowledgeBase getKnowledgeBase() { - return null; - } - - @Override - public int fireAllRules() { - return 0; - } - - @Override - public int fireAllRules(AgendaFilter agendaFilter) { - return 0; - } - - @Override - public int fireAllRules(int fireLimit) { - return 0; - } - - @Override - public int fireAllRules(AgendaFilter agendaFilter, int fireLimit) { - return 0; - } - - @Override - public Object getObject(FactHandle handle) { - return null; - } - - @Override - public FactHandle getFactHandle(Object object) { - return null; - } - - @Override - public FactHandle getFactHandleByIdentity(Object object) { - return null; - } - - @Override - public Iterator<?> iterateObjects() { - return null; - } - - @Override - public Iterator<?> iterateObjects(ObjectFilter filter) { - return null; - } - - @Override - public Iterator<InternalFactHandle> iterateFactHandles() { - return null; - } - - @Override - public Iterator<InternalFactHandle> iterateFactHandles(ObjectFilter filter) { - return null; - } - - @Override - public void setFocus(String focus) { - } - - @Override - public QueryResults getQueryResults(String query, Object... arguments) { - return null; - } - - @Override - public void setAsyncExceptionHandler(AsyncExceptionHandler handler) { - } - - @Override - public void clearAgenda() { - } - - @Override - public void clearAgendaGroup(String group) { - } - - @Override - public void clearActivationGroup(String group) { - } - - @Override - public void clearRuleFlowGroup(String group) { - } - - @Override - public ProcessInstance startProcess(String processId) { - return null; - } - - @Override - public ProcessInstance startProcess(String processId, Map<String, Object> parameters) { - return null; - } - - @Override - public Collection<ProcessInstance> getProcessInstances() { - return null; - } - - @Override - public ProcessInstance getProcessInstance(long id) { - return null; - } - - @Override - public ProcessInstance getProcessInstance(long id, boolean readOnly) { - return null; - } - - @Override - public WorkItemManager getWorkItemManager() { - return null; - } - - @Override - public void halt() { - } - - @Override - public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String id) { - return null; - } - - @Override - public SessionClock getSessionClock() { - return null; - } - -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoAsyncRequestStatusTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoAsyncRequestStatusTest.java deleted file mode 100755 index 64467b299..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoAsyncRequestStatusTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.time.LocalDateTime; - -import org.junit.Test; - -public class SoAsyncRequestStatusTest { - - @Test - public void testConstructor() { - SoAsyncRequestStatus obj = new SoAsyncRequestStatus(); - - assertTrue(obj.getCorrelator() == null); - assertTrue(obj.getFinishTime() == null); - assertTrue(obj.getInstanceReferences() == null); - assertTrue(obj.getRequestId() == null); - assertTrue(obj.getRequestScope() == null); - assertTrue(obj.getRequestStatus() == null); - assertTrue(obj.getStartTime() == null); - } - - @Test - public void testSetGet() { - SoAsyncRequestStatus obj = new SoAsyncRequestStatus(); - - obj.setCorrelator("correlator"); - assertEquals("correlator", obj.getCorrelator()); - - LocalDateTime finishTime = LocalDateTime.now(); - obj.setFinishTime(finishTime); - assertEquals(finishTime, obj.getFinishTime()); - - SoInstanceReferences instanceReferences = new SoInstanceReferences(); - obj.setInstanceReferences(instanceReferences); - assertEquals(instanceReferences, obj.getInstanceReferences()); - - obj.setRequestId("requestId"); - assertEquals("requestId", obj.getRequestId()); - - obj.setRequestScope("requestScope"); - assertEquals("requestScope", obj.getRequestScope()); - - SoRequestStatus requestStatus = new SoRequestStatus(); - obj.setRequestStatus(requestStatus); - assertEquals(requestStatus, obj.getRequestStatus()); - - obj.setRequestType("requestType"); - assertEquals("requestType", obj.getRequestType()); - - LocalDateTime startTime = LocalDateTime.now(); - obj.setStartTime(startTime); - assertEquals(startTime, obj.getStartTime()); - - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoCloudConfigurationTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoCloudConfigurationTest.java deleted file mode 100755 index 0b6521be1..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoCloudConfigurationTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class SoCloudConfigurationTest { - - @Test - public void testConstructor() { - SoCloudConfiguration obj = new SoCloudConfiguration(); - - assertTrue(obj.getLcpCloudRegionId() == null); - assertTrue(obj.getTenantId() == null); - } - - @Test - public void testSetGet() { - SoCloudConfiguration obj = new SoCloudConfiguration(); - - obj.setLcpCloudRegionId("lcpCloudRegionId"); - assertEquals("lcpCloudRegionId", obj.getLcpCloudRegionId()); - - obj.setTenantId("tenantId"); - assertEquals("tenantId", obj.getTenantId()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoDummyServerTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoDummyServerTest.java deleted file mode 100644 index 5c302474a..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoDummyServerTest.java +++ /dev/null @@ -1,239 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018-2019 AT&T. 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.so; - -import com.google.gson.Gson; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.Response; - -@Path("/SO") -public class SoDummyServerTest { - - private static int postMessagesReceived = 0; - private static int putMessagesReceived = 0; - private static int statMessagesReceived = 0; - private static int getMessagesReceived = 0; - private static int deleteMessagesReceived = 0; - - private static Map<String, SoResponse> ongoingRequestMap = new ConcurrentHashMap<>(); - - /** - * Stats method. - * - * @return response - */ - @GET - @Path("/Stats") - public Response serviceGetStats() { - statMessagesReceived++; - return Response.status(200).entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived - + ",\"POST\": " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived - + ",\"DELETE\": " + deleteMessagesReceived + "}").build(); - - } - - /** - * Get stat type. - * - * @param statType the stat type - * @return http response - */ - @GET - @Path("/OneStat/{statType}") - public Response serviceGetStat(@PathParam("statType") final String statType) { - statMessagesReceived++; - return Response.status(200).entity("{\"TYPE\": " + statType + "}").build(); - } - - /** - * Post to service instantiation. - * - * @param jsonString string to send - * @return http response - */ - @POST - @Path("/serviceInstantiation/v7") - public Response servicePostRequest(final String jsonString) { - postMessagesReceived++; - return buildResponse(jsonString); - } - - /** - * Post. - * - * @param serviceInstanceId service instance id - * @param vnfInstanceId vnf instance id - * @param jsonString json body - * @return http response - */ - @POST - @Path("/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut") - public Response servicePostRequestVfModules(@PathParam("serviceInstanceId") final String serviceInstanceId, - @PathParam("vnfInstanceId") final String vnfInstanceId, final String jsonString) { - postMessagesReceived++; - return buildResponse(jsonString); - } - - /** - * Get instance ID. - * - * @param nsInstanceId node instance id - * @return http response - */ - @GET - @Path("/orchestrationRequests/v5/{nsInstanceId}") - public Response soRequestStatus(@PathParam("nsInstanceId") final String nsInstanceId) { - - SoResponse response = ongoingRequestMap.get(nsInstanceId); - - int iterationsLeft = Integer.valueOf(response.getRequest().getRequestScope()); - if (--iterationsLeft > 0) { - response.getRequest().setRequestScope(new Integer(iterationsLeft).toString()); - String responseString = new Gson().toJson(response, SoResponse.class); - return Response.status(response.getHttpResponseCode()).entity(responseString).build(); - } - - ongoingRequestMap.remove(nsInstanceId); - - if ("ReturnBadAfterWait".equals(response.getRequest().getRequestType())) { - return Response.status(400).build(); - } - - response.getRequest().getRequestStatus().setRequestState("COMPLETE"); - response.getRequest().setRequestScope("0"); - response.setHttpResponseCode(200); - String responseString = new Gson().toJson(response, SoResponse.class); - return Response.status(response.getHttpResponseCode()).entity(responseString).build(); - } - - /** - * Delete. - * - * @param serviceInstanceId service instance id - * @param vnfInstanceId vnf instance id - * @param vfModuleInstanceId vf module instance id - * @param jsonString json body - * @return http response - */ - @DELETE - @Path("/serviceInstances/v7/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleInstanceId}") - public Response serviceDeleteRequestVfModules( - @PathParam("serviceInstanceId") final String serviceInstanceId, - @PathParam("vnfInstanceId") final String vnfInstanceId, - @PathParam("vfModuleInstanceId") final String vfModuleInstanceId, - final String jsonString) { - deleteMessagesReceived++; - return buildResponse(jsonString); - } - - private Response buildResponse(String jsonString) { - if (jsonString == null) { - return Response.status(400).build(); - } - - SoRequest request = null; - try { - request = new Gson().fromJson(jsonString, SoRequest.class); - } catch (Exception e) { - return Response.status(400).build(); - } - - if (request == null) { - return Response.status(400).build(); - } - - if (request.getRequestType() == null) { - return Response.status(400).build(); - } - - if ("ReturnBadJson".equals(request.getRequestType())) { - return Response.status(200) - .entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived - + ",\"POST\":" + " , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived - + ",\"DELETE\": " + deleteMessagesReceived + "}").build(); - } - - SoResponse response = new SoResponse(); - response.setRequest(request); - response.setRequestReferences(new SoRequestReferences()); - response.getRequestReferences().setRequestId(request.getRequestId().toString()); - - if ("ReturnCompleted".equals(request.getRequestType())) { - response.getRequest().getRequestStatus().setRequestState("COMPLETE"); - response.setHttpResponseCode(200); - String responseString = new Gson().toJson(response, SoResponse.class); - return Response.status(response.getHttpResponseCode()) - .entity(responseString) - .build(); - } - - if ("ReturnFailed".equals(request.getRequestType())) { - response.getRequest().getRequestStatus().setRequestState("FAILED"); - response.setHttpResponseCode(200); - String responseString = new Gson().toJson(response, SoResponse.class); - return Response.status(response.getHttpResponseCode()) - .entity(responseString) - .build(); - } - - if ("ReturnOnging202".equals(request.getRequestType())) { - ongoingRequestMap.put(request.getRequestId().toString(), response); - - response.getRequest().getRequestStatus().setRequestState("ONGOING"); - response.setHttpResponseCode(202); - String responseString = new Gson().toJson(response, SoResponse.class); - return Response.status(response.getHttpResponseCode()) - .entity(responseString) - .build(); - } - - if ("ReturnOnging200".equals(request.getRequestType())) { - ongoingRequestMap.put(request.getRequestId().toString(), response); - - response.getRequest().getRequestStatus().setRequestState("ONGOING"); - response.setHttpResponseCode(200); - String responseString = new Gson().toJson(response, SoResponse.class); - return Response.status(response.getHttpResponseCode()) - .entity(responseString) - .build(); - } - - if ("ReturnBadAfterWait".equals(request.getRequestType())) { - ongoingRequestMap.put(request.getRequestId().toString(), response); - - response.getRequest().getRequestStatus().setRequestState("ONGOING"); - response.setHttpResponseCode(200); - String responseString = new Gson().toJson(response, SoResponse.class); - return Response.status(response.getHttpResponseCode()) - .entity(responseString) - .build(); - } - return null; - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoInstanceReferencesTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoInstanceReferencesTest.java deleted file mode 100755 index 13d7dd83b..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoInstanceReferencesTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class SoInstanceReferencesTest { - - @Test - public void testConstructor() { - SoInstanceReferences obj = new SoInstanceReferences(); - - assertTrue(obj.getInstanceId() == null); - assertTrue(obj.getRequestId() == null); - } - - @Test - public void testSetGet() { - SoInstanceReferences obj = new SoInstanceReferences(); - - obj.setInstanceId("instanceId"); - assertEquals("instanceId", obj.getInstanceId()); - - obj.setRequestId("requestId"); - assertEquals("requestId", obj.getRequestId()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoManagerTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoManagerTest.java deleted file mode 100644 index e2482569d..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoManagerTest.java +++ /dev/null @@ -1,405 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * TestSOManager - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018-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.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.net.URI; -import java.util.UUID; -import java.util.concurrent.Future; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; -import org.drools.core.WorkingMemory; -import org.glassfish.grizzly.http.server.HttpServer; -import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; -import org.glassfish.jersey.server.ResourceConfig; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.drools.system.PolicyEngine; - -public class SoManagerTest { - private static final String BASE_URI = "http://localhost:46553/TestSOManager"; - private static final String BASE_SO_URI = BASE_URI + "/SO"; - private static HttpServer server; - - /** - * Set up test class. - */ - @BeforeClass - public static void setUp() throws IOException { - final ResourceConfig rc = new ResourceConfig(SoDummyServerTest.class); - //Grizzly by default doesn't allow payload for HTTP methods (ex: DELETE), for which HTTP spec doesn't - // explicitly state that. - //allow it before starting the server - server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc, false); - server.getServerConfiguration().setAllowPayloadForUndefinedHttpMethods(true); - server.start(); - } - - @AfterClass - public static void tearDown() throws Exception { - server.shutdown(); - } - - @Test - public void testGrizzlyServer() throws ClientProtocolException, IOException { - CloseableHttpClient httpclient = HttpClients.createDefault(); - HttpGet httpGet = new HttpGet("http://localhost:46553/TestSOManager/SO/Stats"); - CloseableHttpResponse response = httpclient.execute(httpGet); - - String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8"); - assertTrue(returnBody.matches("^\\{\"GET\": [0-9]*,\"STAT\": [0-9]*,\"POST\": [0-9]*,\"PUT\": [0-9]*," - + "\"DELETE\": [0-9]*\\}$")); - } - - @Test - public void testServiceInstantiation() throws IOException { - SoManager manager = new SoManager(); - assertNotNull(manager); - manager.setRestGetTimeout(100); - - SoResponse response = manager.createModuleInstance("http:/localhost:99999999", BASE_SO_URI, "sean", - "citizen", null); - assertNull(response); - - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", null); - assertNull(response); - - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", new SoRequest()); - assertNull(response); - - SoRequest request = new SoRequest(); - request.setRequestId(UUID.randomUUID()); - request.setRequestScope("Test"); - request.setRequestType("ReturnBadJson"); - request.setStartTime("2018-03-23 16:31"); - request.setRequestStatus(new SoRequestStatus()); - request.getRequestStatus().setRequestState("ONGOING"); - - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNull(response); - - request.setRequestType("ReturnCompleted"); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNotNull(response); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - - request.setRequestType("ReturnFailed"); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNotNull(response); - assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState()); - - // Use scope to set the number of iterations we'll wait for - - request.setRequestType("ReturnOnging200"); - request.setRequestScope(new Integer(10).toString()); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNotNull(response); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(20).toString()); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNotNull(response); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - - // Test timeout after 20 attempts for a response - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(21).toString()); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNull(response); - - // Test bad response after 3 attempts for a response - request.setRequestType("ReturnBadAfterWait"); - request.setRequestScope(new Integer(3).toString()); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNull(response); - } - - @Test - public void testVfModuleCreation() throws IOException { - SoManager manager = new SoManager(); - assertNotNull(manager); - manager.setRestGetTimeout(100); - - PolicyEngine.manager.setEnvironmentProperty("so.username", "sean"); - PolicyEngine.manager.setEnvironmentProperty("so.password", "citizen"); - - WorkingMemory wm = new DummyWorkingMemory(); - - SoRequest soRequest = new SoRequest(); - soRequest.setOperationType(SoOperationType.SCALE_OUT); - PolicyEngine.manager.setEnvironmentProperty("so.url", "http:/localhost:99999999"); - Future<SoResponse> asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, - UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); - try { - SoResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - PolicyEngine.manager.setEnvironmentProperty("so.url", BASE_SO_URI); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), soRequest); - try { - SoResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - SoRequest request = new SoRequest(); - request.setRequestId(UUID.randomUUID()); - request.setRequestScope("Test"); - request.setRequestType("ReturnBadJson"); - request.setStartTime("2018-03-23 16:31"); - request.setRequestStatus(new SoRequestStatus()); - request.getRequestStatus().setRequestState("ONGOING"); - request.setOperationType(SoOperationType.SCALE_OUT); - - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SoResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnCompleted"); - - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SoResponse response = asyncRestCallFuture.get(); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnFailed"); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SoResponse response = asyncRestCallFuture.get(); - assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Use scope to set the number of iterations we'll wait for - - request.setRequestType("ReturnOnging200"); - request.setRequestScope(new Integer(10).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SoResponse response = asyncRestCallFuture.get(); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(20).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SoResponse response = asyncRestCallFuture.get(); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Test timeout after 20 attempts for a response - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(21).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SoResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Test bad response after 3 attempts for a response - request.setRequestType("ReturnBadAfterWait"); - request.setRequestScope(new Integer(3).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SoResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - } - - @Test - public void testVfModuleDeletion() { - SoManager manager = new SoManager(); - assertNotNull(manager); - manager.setRestGetTimeout(100); - - PolicyEngine.manager.setEnvironmentProperty("so.username", "sean"); - PolicyEngine.manager.setEnvironmentProperty("so.password", "citizen"); - - WorkingMemory wm = new DummyWorkingMemory(); - - SoRequest soRequest = new SoRequest(); - soRequest.setOperationType(SoOperationType.DELETE_VF_MODULE); - PolicyEngine.manager.setEnvironmentProperty("so.url", "http:/localhost:99999999"); - Future<SoResponse> asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, - UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); - try { - SoResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - PolicyEngine.manager.setEnvironmentProperty("so.url", BASE_SO_URI); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); - try { - SoResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - SoRequest request = new SoRequest(); - request.setRequestId(UUID.randomUUID()); - request.setRequestScope("Test"); - request.setRequestType("ReturnBadJson"); - request.setStartTime("2018-03-23 16:31"); - request.setRequestStatus(new SoRequestStatus()); - request.getRequestStatus().setRequestState("ONGOING"); - request.setOperationType(SoOperationType.DELETE_VF_MODULE); - - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SoResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnCompleted"); - - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SoResponse response = asyncRestCallFuture.get(); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnFailed"); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SoResponse response = asyncRestCallFuture.get(); - assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Use scope to set the number of iterations we'll wait for - - request.setRequestType("ReturnOnging200"); - request.setRequestScope(new Integer(10).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SoResponse response = asyncRestCallFuture.get(); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(20).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SoResponse response = asyncRestCallFuture.get(); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Test timeout after 20 attempts for a response - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(21).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SoResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Test bad response after 3 attempts for a response - request.setRequestType("ReturnBadAfterWait"); - request.setRequestScope(new Integer(3).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SoResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoModelInfoTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoModelInfoTest.java deleted file mode 100755 index 3cc415cdd..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoModelInfoTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class SoModelInfoTest { - - @Test - public void testConstructor() { - SoModelInfo obj = new SoModelInfo(); - - assertTrue(obj.getModelCustomizationId() == null); - assertTrue(obj.getModelCustomizationName() == null); - assertTrue(obj.getModelInvariantId() == null); - assertTrue(obj.getModelName() == null); - assertTrue(obj.getModelType() == null); - assertTrue(obj.getModelVersion() == null); - assertTrue(obj.getModelVersionId() == null); - } - - @Test - public void testSetGet() { - SoModelInfo obj = new SoModelInfo(); - - obj.setModelCustomizationId("modelCustomizationId"); - assertEquals("modelCustomizationId", obj.getModelCustomizationId()); - - obj.setModelCustomizationName("modelCustomizationName"); - assertEquals("modelCustomizationName", obj.getModelCustomizationName()); - - obj.setModelInvariantId("modelInvariantId"); - assertEquals("modelInvariantId", obj.getModelInvariantId()); - - obj.setModelName("modelName"); - assertEquals("modelName", obj.getModelName()); - - obj.setModelType("modelType"); - assertEquals("modelType", obj.getModelType()); - - obj.setModelVersion("modelVersion"); - assertEquals("modelVersion", obj.getModelVersion()); - - obj.setModelVersionId("modelVersionId"); - assertEquals("modelVersionId", obj.getModelVersionId()); - - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoPolicyExceptionHolderTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoPolicyExceptionHolderTest.java deleted file mode 100755 index 00dfb8dc6..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoPolicyExceptionHolderTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017, 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.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class SoPolicyExceptionHolderTest { - - @Test - public void testConstructor() { - SoPolicyExceptionHolder obj = new SoPolicyExceptionHolder(); - - assertTrue(obj.getMessageId() == null); - assertTrue(obj.getText() == null); - } - - @Test - public void testSetGet() { - SoPolicyExceptionHolder obj = new SoPolicyExceptionHolder(); - - obj.setMessageId("messageId"); - assertEquals("messageId", obj.getMessageId()); - - obj.setText("text"); - assertEquals("text", obj.getText()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceListElementTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceListElementTest.java deleted file mode 100755 index c73a0ea05..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceListElementTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class SoRelatedInstanceListElementTest { - - @Test - public void testConstructor() { - SoRelatedInstanceListElement obj = new SoRelatedInstanceListElement(); - - assertTrue(obj.getRelatedInstance() == null); - } - - @Test - public void testSetGet() { - SoRelatedInstanceListElement obj = new SoRelatedInstanceListElement(); - - SoRelatedInstance relatedInstance = new SoRelatedInstance(); - obj.setRelatedInstance(relatedInstance); - assertEquals(relatedInstance, obj.getRelatedInstance()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceTest.java deleted file mode 100755 index 70f585efe..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017, 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.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class SoRelatedInstanceTest { - - @Test - public void testConstructor() { - SoRelatedInstance obj = new SoRelatedInstance(); - - assertTrue(obj.getInstanceId() == null); - assertTrue(obj.getInstanceName() == null); - assertTrue(obj.getModelInfo() == null); - } - - @Test - public void testSetGet() { - SoRelatedInstance obj = new SoRelatedInstance(); - - obj.setInstanceId("instanceId"); - assertEquals("instanceId", obj.getInstanceId()); - - obj.setInstanceName("instanceName"); - assertEquals("instanceName", obj.getInstanceName()); - - SoModelInfo modelInfo = new SoModelInfo(); - obj.setModelInfo(modelInfo); - assertEquals(modelInfo, obj.getModelInfo()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java deleted file mode 100755 index 7233482f6..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java +++ /dev/null @@ -1,176 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -public class SoRequestDetailsTest { - - @Test - public void testConstructor() { - SoRequestDetails obj = new SoRequestDetails(); - - assertTrue(obj.getCloudConfiguration() == null); - assertTrue(obj.getModelInfo() == null); - assertTrue(obj.getRequestInfo() == null); - assertTrue(obj.getRequestParameters() == null); - assertTrue(obj.getSubscriberInfo() == null); - - assertTrue(obj.getRelatedInstanceList() != null); - assertEquals(0, obj.getRelatedInstanceList().size()); - } - - @Test - public void testSetGet() { - SoRequestDetails obj = new SoRequestDetails(); - - SoCloudConfiguration cloudConfiguration = new SoCloudConfiguration(); - obj.setCloudConfiguration(cloudConfiguration); - assertEquals(cloudConfiguration, obj.getCloudConfiguration()); - - SoModelInfo modelInfo = new SoModelInfo(); - obj.setModelInfo(modelInfo); - assertEquals(modelInfo, obj.getModelInfo()); - - SoRequestInfo requestInfo = new SoRequestInfo(); - obj.setRequestInfo(requestInfo); - assertEquals(requestInfo, obj.getRequestInfo()); - - SoRequestParameters requestParameters = new SoRequestParameters(); - obj.setRequestParameters(requestParameters); - assertEquals(requestParameters, obj.getRequestParameters()); - - SoSubscriberInfo subscriberInfo = new SoSubscriberInfo(); - obj.setSubscriberInfo(subscriberInfo); - assertEquals(subscriberInfo, obj.getSubscriberInfo()); - } - - @Test - public void testSoMRequestDetailsMethods() { - SoRequestDetails details = new SoRequestDetails(); - assertNotNull(details); - assertNotEquals(0, details.hashCode()); - - SoCloudConfiguration cloudConfiguration = new SoCloudConfiguration(); - details.setCloudConfiguration(cloudConfiguration); - assertEquals(cloudConfiguration, details.getCloudConfiguration()); - assertNotEquals(0, details.hashCode()); - - SoModelInfo modelInfo = new SoModelInfo(); - details.setModelInfo(modelInfo); - assertEquals(modelInfo, details.getModelInfo()); - assertNotEquals(0, details.hashCode()); - - List<SoRelatedInstanceListElement> relatedInstanceList = new ArrayList<>(); - details.setRelatedInstanceList(relatedInstanceList); - assertEquals(relatedInstanceList, details.getRelatedInstanceList()); - assertNotEquals(0, details.hashCode()); - - SoRequestInfo requestInfo = new SoRequestInfo(); - details.setRequestInfo(requestInfo); - assertEquals(requestInfo, details.getRequestInfo()); - assertNotEquals(0, details.hashCode()); - - SoRequestParameters requestParameters = new SoRequestParameters(); - details.setRequestParameters(requestParameters); - assertEquals(requestParameters, details.getRequestParameters()); - assertNotEquals(0, details.hashCode()); - - SoSubscriberInfo subscriberInfo = new SoSubscriberInfo(); - details.setSubscriberInfo(subscriberInfo); - assertEquals(subscriberInfo, details.getSubscriberInfo()); - assertNotEquals(0, details.hashCode()); - - assertEquals("SORequestDetails [modelInfo=org.onap.policy.so", details.toString().substring(0, 46)); - - SoRequestDetails copiedDetails = new SoRequestDetails(details); - - assertTrue(details.equals(details)); - assertTrue(details.equals(copiedDetails)); - assertFalse(details.equals(null)); - assertFalse(details.equals("Hello")); - - details.setCloudConfiguration(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setCloudConfiguration(null); - assertTrue(details.equals(copiedDetails)); - details.setCloudConfiguration(cloudConfiguration); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setCloudConfiguration(cloudConfiguration); - assertTrue(details.equals(copiedDetails)); - - details.setModelInfo(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setModelInfo(null); - assertTrue(details.equals(copiedDetails)); - details.setModelInfo(modelInfo); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setModelInfo(modelInfo); - assertTrue(details.equals(copiedDetails)); - - details.setRequestInfo(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRequestInfo(null); - assertTrue(details.equals(copiedDetails)); - details.setRequestInfo(requestInfo); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRequestInfo(requestInfo); - assertTrue(details.equals(copiedDetails)); - - details.setRequestParameters(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRequestParameters(null); - assertTrue(details.equals(copiedDetails)); - details.setRequestParameters(requestParameters); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRequestParameters(requestParameters); - assertTrue(details.equals(copiedDetails)); - - details.setSubscriberInfo(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setSubscriberInfo(null); - assertTrue(details.equals(copiedDetails)); - details.setSubscriberInfo(subscriberInfo); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setSubscriberInfo(subscriberInfo); - assertTrue(details.equals(copiedDetails)); - - details.setRelatedInstanceList(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRelatedInstanceList(null); - assertTrue(details.equals(copiedDetails)); - details.setRelatedInstanceList(relatedInstanceList); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRelatedInstanceList(relatedInstanceList); - assertTrue(details.equals(copiedDetails)); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestErrorTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestErrorTest.java deleted file mode 100755 index b870dbd99..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestErrorTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class SoRequestErrorTest { - - @Test - public void testConstructor() { - SoRequestError obj = new SoRequestError(); - - assertTrue(obj.getPolicyException() == null); - assertTrue(obj.getServiceException() == null); - } - - @Test - public void testSetGet() { - SoRequestError obj = new SoRequestError(); - - SoPolicyExceptionHolder policyException = new SoPolicyExceptionHolder(); - obj.setPolicyException(policyException); - assertEquals(policyException, obj.getPolicyException()); - - SoServiceExceptionHolder serviceException = new SoServiceExceptionHolder(); - obj.setServiceException(serviceException); - assertEquals(serviceException, obj.getServiceException()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestInfoTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestInfoTest.java deleted file mode 100755 index 0e518018b..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestInfoTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class SoRequestInfoTest { - - @Test - public void testConstructor() { - SoRequestInfo obj = new SoRequestInfo(); - - assertTrue(obj.getBillingAccountNumber() == null); - assertTrue(obj.getCallbackUrl() == null); - assertTrue(obj.getCorrelator() == null); - assertTrue(obj.getInstanceName() == null); - assertTrue(obj.getOrderNumber() == null); - assertTrue(obj.getOrderVersion() == null); - assertTrue(obj.getProductFamilyId() == null); - assertTrue(obj.getRequestorId() == null); - assertTrue(obj.getSource() == null); - assertTrue(obj.isSuppressRollback() == false); - } - - @Test - public void testSetGet() { - SoRequestInfo obj = new SoRequestInfo(); - - obj.setBillingAccountNumber("billingAccountNumber"); - assertEquals("billingAccountNumber", obj.getBillingAccountNumber()); - - obj.setCallbackUrl("callbackUrl"); - assertEquals("callbackUrl", obj.getCallbackUrl()); - - obj.setCorrelator("correlator"); - assertEquals("correlator", obj.getCorrelator()); - - obj.setInstanceName("instanceName"); - assertEquals("instanceName", obj.getInstanceName()); - - obj.setOrderNumber("orderNumber"); - assertEquals("orderNumber", obj.getOrderNumber()); - - int orderVersion = 2008; - obj.setOrderVersion(orderVersion); - assertEquals((Integer) orderVersion, obj.getOrderVersion()); - - obj.setProductFamilyId("productFamilyId"); - assertEquals("productFamilyId", obj.getProductFamilyId()); - - obj.setRequestorId("requestorId"); - assertEquals("requestorId", obj.getRequestorId()); - - obj.setSource("source"); - assertEquals("source", obj.getSource()); - - obj.setSuppressRollback(true); - assertEquals(true, obj.isSuppressRollback()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestParametersTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestParametersTest.java deleted file mode 100755 index 7d671f5e1..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestParametersTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class SoRequestParametersTest { - - @Test - public void testConstructor() { - SoRequestParameters obj = new SoRequestParameters(); - - assertTrue(obj.getSubscriptionServiceType() == null); - assertTrue(obj.getUserParams() != null); - assertEquals(0, obj.getUserParams().size()); - } - - @Test - public void testSetGet() { - SoRequestParameters obj = new SoRequestParameters(); - - obj.setSubscriptionServiceType("subscriptionServiceType"); - assertEquals("subscriptionServiceType", obj.getSubscriptionServiceType()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestReferencesTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestReferencesTest.java deleted file mode 100755 index 549147e4b..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestReferencesTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class SoRequestReferencesTest { - - @Test - public void testConstructor() { - SoRequestReferences obj = new SoRequestReferences(); - - assertTrue(obj.getInstanceId() == null); - assertTrue(obj.getRequestId() == null); - } - - @Test - public void testSetGet() { - SoRequestReferences obj = new SoRequestReferences(); - - obj.setInstanceId("instanceId"); - assertEquals("instanceId", obj.getInstanceId()); - - obj.setRequestId("requestId"); - assertEquals("requestId", obj.getRequestId()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestStatusTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestStatusTest.java deleted file mode 100755 index 39a3241a3..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestStatusTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class SoRequestStatusTest { - - @Test - public void testConstructor() { - SoRequestStatus obj = new SoRequestStatus(); - - assertEquals(0, obj.getPercentProgress()); - assertTrue(obj.getRequestState() == null); - assertTrue(obj.getTimestamp() == null); - assertFalse(obj.isWasRolledBack()); - } - - @Test - public void testSetGet() { - SoRequestStatus obj = new SoRequestStatus(); - - obj.setPercentProgress(2008); - assertEquals(2008, obj.getPercentProgress()); - - obj.setRequestState("requestState"); - assertEquals("requestState", obj.getRequestState()); - - obj.setTimestamp("timestamp"); - assertEquals("timestamp", obj.getTimestamp()); - - obj.setWasRolledBack(true); - assertTrue(obj.isWasRolledBack()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestTest.java deleted file mode 100755 index 971b1d190..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.time.LocalDateTime; -import java.util.UUID; - -import org.junit.Test; - -public class SoRequestTest { - - @Test - public void testConstructor() { - SoRequest obj = new SoRequest(); - - assertTrue(obj.getFinishTime() == null); - assertTrue(obj.getRequestDetails() == null); - assertTrue(obj.getRequestId() == null); - assertTrue(obj.getRequestScope() == null); - assertTrue(obj.getRequestStatus() == null); - assertTrue(obj.getRequestType() == null); - assertTrue(obj.getStartTime() == null); - } - - @Test - public void testSetGet() { - SoRequest obj = new SoRequest(); - - LocalDateTime finishTime = LocalDateTime.now(); - obj.setFinishTime(finishTime); - assertEquals(finishTime, obj.getFinishTime()); - - UUID uuid = UUID.randomUUID(); - obj.setRequestId(uuid); - assertEquals(uuid, obj.getRequestId()); - - obj.setRequestScope("requestScope"); - assertEquals("requestScope", obj.getRequestScope()); - - SoRequestStatus requestStatus = new SoRequestStatus(); - obj.setRequestStatus(requestStatus); - assertEquals(requestStatus, obj.getRequestStatus()); - - obj.setRequestType("requestType"); - assertEquals("requestType", obj.getRequestType()); - - obj.setOperationType(SoOperationType.DELETE_VF_MODULE); - assertEquals(SoOperationType.DELETE_VF_MODULE, obj.getOperationType()); - - LocalDateTime startTime = LocalDateTime.now(); - obj.setStartTime(startTime.toString()); - assertEquals(startTime.toString(), obj.getStartTime()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseTest.java deleted file mode 100755 index c932ac969..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class SoResponseTest { - - @Test - public void testConstructor() { - SoResponse obj = new SoResponse(); - - assertEquals(0, obj.getHttpResponseCode()); - assertTrue(obj.getRequest() == null); - assertTrue(obj.getRequestError() == null); - assertTrue(obj.getRequestReferences() == null); - } - - @Test - public void testSetGet() { - SoResponse obj = new SoResponse(); - - obj.setHttpResponseCode(2008); - assertEquals(2008, obj.getHttpResponseCode()); - - SoRequest request = new SoRequest(); - obj.setRequest(request); - assertEquals(request, obj.getRequest()); - - SoRequestError requestError = new SoRequestError(); - obj.setRequestError(requestError); - assertEquals(requestError, obj.getRequestError()); - - SoRequestReferences requestReferences = new SoRequestReferences(); - obj.setRequestReferences(requestReferences); - assertEquals(requestReferences, obj.getRequestReferences()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseWrapperTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseWrapperTest.java deleted file mode 100755 index 26bd75d2a..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseWrapperTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2018-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.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; - -import org.junit.Test; - -public class SoResponseWrapperTest { - - @Test - public void testConstructor() { - SoResponse response = new SoResponse(); - SoResponseWrapper obj = new SoResponseWrapper(response, "reqID"); - - assertEquals(response, obj.getSoResponse()); - assertEquals("reqID", obj.getRequestId()); - } - - @Test - public void testSetGet() { - SoResponse response = new SoResponse(); - SoResponseWrapper obj = new SoResponseWrapper(response, "reqID"); - - SoResponse response2 = new SoResponse(); - response2.setHttpResponseCode(2008); - obj.setSoResponse(response2); - assertEquals(response2, obj.getSoResponse()); - - obj.setRequestId("id2"); - assertEquals("id2", obj.getRequestId()); - } - - @Test - public void testSoResponseWrapperMethods() { - String requestId = UUID.randomUUID().toString(); - SoResponse response = new SoResponse(); - - SoResponseWrapper responseWrapper = new SoResponseWrapper(response, requestId); - assertNotNull(responseWrapper); - assertNotEquals(0, responseWrapper.hashCode()); - - assertEquals(response, responseWrapper.getSoResponse()); - - assertNotEquals(0, responseWrapper.hashCode()); - - assertEquals("SOResponseWrapper [SOResponse=org.onap.policy.", responseWrapper.toString().substring(0, 46)); - - SoResponseWrapper identicalResponseWrapper = new SoResponseWrapper(response, requestId); - - assertEquals(responseWrapper, responseWrapper); - assertEquals(responseWrapper, identicalResponseWrapper); - assertNotEquals(null, responseWrapper); - assertNotEquals("Hello", responseWrapper); - assertFalse(responseWrapper.equals(null)); - assertFalse(responseWrapper.equals("AString")); - - assertEquals(new SoResponseWrapper(null, null), new SoResponseWrapper(null, null)); - assertNotEquals(new SoResponseWrapper(null, null), identicalResponseWrapper); - - assertNotEquals(0, new SoResponseWrapper(null, null).hashCode()); - - identicalResponseWrapper.setSoResponse(new SoResponse()); - assertNotEquals(responseWrapper, identicalResponseWrapper); - identicalResponseWrapper.setSoResponse(response); - assertEquals(responseWrapper, identicalResponseWrapper); - - identicalResponseWrapper.setRequestId(UUID.randomUUID().toString()); - assertNotEquals(responseWrapper, identicalResponseWrapper); - identicalResponseWrapper.setRequestId(requestId); - assertEquals(responseWrapper, identicalResponseWrapper); - - responseWrapper.setRequestId(null); - assertNotEquals(responseWrapper, identicalResponseWrapper); - identicalResponseWrapper.setRequestId(null); - assertEquals(responseWrapper, identicalResponseWrapper); - responseWrapper.setRequestId(requestId); - assertNotEquals(responseWrapper, identicalResponseWrapper); - identicalResponseWrapper.setRequestId(requestId); - assertEquals(responseWrapper, identicalResponseWrapper); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoServiceExceptionHolderTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoServiceExceptionHolderTest.java deleted file mode 100755 index 8c9d3a730..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoServiceExceptionHolderTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class SoServiceExceptionHolderTest { - - @Test - public void testConstructor() { - SoServiceExceptionHolder obj = new SoServiceExceptionHolder(); - - assertTrue(obj.getMessageId() == null); - assertTrue(obj.getText() == null); - assertTrue(obj.getVariables() != null); - assertEquals(0, obj.getVariables().size()); - } - - @Test - public void testSetGet() { - SoServiceExceptionHolder obj = new SoServiceExceptionHolder(); - - obj.setMessageId("messageId"); - assertEquals("messageId", obj.getMessageId()); - - obj.setText("text"); - assertEquals("text", obj.getText()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoSubscriberInfoTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoSubscriberInfoTest.java deleted file mode 100755 index e68e74e3f..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoSubscriberInfoTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class SoSubscriberInfoTest { - - @Test - public void testConstructor() { - SoSubscriberInfo obj = new SoSubscriberInfo(); - - assertTrue(obj.getGlobalSubscriberId() == null); - assertTrue(obj.getSubscriberCommonSiteId() == null); - assertTrue(obj.getSubscriberName() == null); - } - - @Test - public void testSetGet() { - SoSubscriberInfo obj = new SoSubscriberInfo(); - - obj.setGlobalSubscriberId("globalSubscriberId"); - assertEquals("globalSubscriberId", obj.getGlobalSubscriberId()); - - obj.setSubscriberCommonSiteId("subscriberCommonSiteId"); - assertEquals("subscriberCommonSiteId", obj.getSubscriberCommonSiteId()); - - obj.setSubscriberName("subscriberName"); - assertEquals("subscriberName", obj.getSubscriberName()); - } -} diff --git a/controlloop/common/model-impl/trafficgenerator/pom.xml b/controlloop/common/model-impl/trafficgenerator/pom.xml deleted file mode 100644 index 922da378f..000000000 --- a/controlloop/common/model-impl/trafficgenerator/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - Drools PDP Application Models - ================================================================================ - Copyright (C) 2017-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========================================================= - --> - -<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.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>model-impl</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>trafficgenerator</artifactId> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <scope>provided</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <artifactId>maven-checkstyle-plugin</artifactId> - <executions> - <execution> - <id>onap-java-style</id> - <goals> - <goal>check</goal> - </goals> - <phase>process-sources</phase> - <configuration> - <!-- Use Google Java Style Guide: - https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml - with minor changes --> - <configLocation>onap-checkstyle/onap-java-style.xml</configLocation> - <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory --> - <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory> - <includeResources>true</includeResources> - <includeTestSourceDirectory>true</includeTestSourceDirectory> - <includeTestResources>true</includeTestResources> - <excludes> - </excludes> - <consoleOutput>true</consoleOutput> - <failsOnViolation>true</failsOnViolation> - <violationSeverity>warning</violationSeverity> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.onap.oparent</groupId> - <artifactId>checkstyle</artifactId> - <version>${oparent.version}</version> - <scope>compile</scope> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> -</project> diff --git a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PgRequest.java b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PgRequest.java deleted file mode 100644 index 026d7d9cc..000000000 --- a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PgRequest.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * trafficgenerator - * ================================================================================ - * Copyright (C) 2017-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.vnf.trafficgenerator; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class PgRequest implements Serializable { - - private static final long serialVersionUID = -3283942659786236032L; - - @SerializedName("pg-streams") - public PgStreams pgStreams; - - public PgRequest() { - //required by author - } -} diff --git a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PgStream.java b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PgStream.java deleted file mode 100644 index 499d20f96..000000000 --- a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PgStream.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * trafficgenerator - * ================================================================================ - * Copyright (C) 2017-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.vnf.trafficgenerator; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class PgStream implements Serializable { - - private static final long serialVersionUID = 5567635677419358210L; - - @SerializedName("id") - public String streamId; - @SerializedName("is-enabled") - public String isEnabled; - - public PgStream() { - //required by author - } -} diff --git a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PgStreams.java b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PgStreams.java deleted file mode 100644 index 566a9eed0..000000000 --- a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PgStreams.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * trafficgenerator - * ================================================================================ - * Copyright (C) 2017-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.vnf.trafficgenerator; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; - -public class PgStreams implements Serializable { - - private static final long serialVersionUID = 5567635677419358210L; - - @SerializedName("pg-stream") - public List<PgStream> pgStream = new LinkedList<>(); - - public PgStreams() { - // required by author - } -} diff --git a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java deleted file mode 100644 index 3443bfcdf..000000000 --- a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * trafficgenerator - * ================================================================================ - * Copyright (C) 2017 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.vnf.trafficgenerator.util; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -public final class Serialization { - - public static final Gson gsonPretty = - new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create(); - - private Serialization() {} -} diff --git a/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/DemoTest.java b/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/DemoTest.java deleted file mode 100644 index 963bf0b99..000000000 --- a/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/DemoTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * trafficgenerator - * ================================================================================ - * Copyright (C) 2017-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.vnf.trafficgenerator; - -import org.junit.Test; - -import org.onap.policy.vnf.trafficgenerator.PgRequest; -import org.onap.policy.vnf.trafficgenerator.PgStream; -import org.onap.policy.vnf.trafficgenerator.PgStreams; -import org.onap.policy.vnf.trafficgenerator.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DemoTest { - private static final Logger logger = LoggerFactory.getLogger(DemoTest.class); - - @Test - public void test() { - PgRequest request = new PgRequest(); - request.pgStreams = new PgStreams(); - - PgStream pgStream; - for (int i = 0; i < 5; i++) { - pgStream = new PgStream(); - pgStream.streamId = "fw_udp" + (i + 1); - pgStream.isEnabled = "true"; - request.pgStreams.pgStream.add(pgStream); - } - - String body = Serialization.gsonPretty.toJson(request); - logger.debug(body); - - // fail("Not yet implemented"); - } - -} diff --git a/controlloop/common/model-impl/vfc/pom.xml b/controlloop/common/model-impl/vfc/pom.xml deleted file mode 100644 index 1df42831b..000000000 --- a/controlloop/common/model-impl/vfc/pom.xml +++ /dev/null @@ -1,112 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - Copyright (C) 2017 Intel Corp. All rights reserved. - Modifications Copyright (C) 2018 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========================================================= - --> - -<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.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>model-impl</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>vfc</artifactId> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <version>2.13.0</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-applications.controlloop.common.model-impl</groupId> - <artifactId>rest</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.drools</groupId> - <artifactId>drools-core</artifactId> - <version>6.5.0.Final</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.common</groupId> - <artifactId>policy-endpoints</artifactId> - <version>${version.policy.common}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.drools-pdp</groupId> - <artifactId>policy-management</artifactId> - <version>${version.policy.drools-pdp}</version> - <scope>provided</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <artifactId>maven-checkstyle-plugin</artifactId> - <executions> - <execution> - <id>onap-java-style</id> - <goals> - <goal>check</goal> - </goals> - <phase>process-sources</phase> - <configuration> - <!-- Use Google Java Style Guide: - https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml - with minor changes --> - <configLocation>onap-checkstyle/onap-java-style.xml</configLocation> - <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory --> - <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory> - <includeResources>true</includeResources> - <includeTestSourceDirectory>true</includeTestSourceDirectory> - <includeTestResources>true</includeTestResources> - <excludes> - </excludes> - <consoleOutput>true</consoleOutput> - <failsOnViolation>true</failsOnViolation> - <violationSeverity>warning</violationSeverity> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.onap.oparent</groupId> - <artifactId>checkstyle</artifactId> - <version>${oparent.version}</version> - <scope>compile</scope> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> -</project> diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealActionVmInfo.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealActionVmInfo.java deleted file mode 100644 index c154f7226..000000000 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealActionVmInfo.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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.vfc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class VfcHealActionVmInfo implements Serializable { - - private static final long serialVersionUID = 3208673205100673119L; - - @SerializedName("vmid") - private String vmid; - - @SerializedName("vmname") - private String vmname; - - public VfcHealActionVmInfo() { - // Default constructor - } - - public String getVmid() { - return vmid; - } - - public void setVmid(String vmid) { - this.vmid = vmid; - } - - public String getVmname() { - return vmname; - } - - public void setVmname(String vmname) { - this.vmname = vmname; - } -} diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealAdditionalParams.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealAdditionalParams.java deleted file mode 100644 index 2c5de3a22..000000000 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealAdditionalParams.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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.vfc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class VfcHealAdditionalParams implements Serializable { - - private static final long serialVersionUID = 2656694137285096191L; - - @SerializedName("action") - private String action; - - @SerializedName("actionvminfo") - private VfcHealActionVmInfo actionInfo; - - public VfcHealAdditionalParams() { - // Default constructor - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public VfcHealActionVmInfo getActionInfo() { - return actionInfo; - } - - public void setActionInfo(VfcHealActionVmInfo actionInfo) { - this.actionInfo = actionInfo; - } -} diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealRequest.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealRequest.java deleted file mode 100644 index 55ca4ac5c..000000000 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcHealRequest.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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.vfc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class VfcHealRequest implements Serializable { - - private static final long serialVersionUID = -7341931593089709247L; - - @SerializedName("vnfInstanceId") - private String vnfInstanceId; - - @SerializedName("cause") - private String cause; - - @SerializedName("additionalParams") - private VfcHealAdditionalParams additionalParams; - - public VfcHealRequest() { - // Default constructor - } - - public String getVnfInstanceId() { - return vnfInstanceId; - } - - public void setVnfInstanceId(String vnfInstanceId) { - this.vnfInstanceId = vnfInstanceId; - } - - public String getCause() { - return cause; - } - - public void setCause(String cause) { - this.cause = cause; - } - - public VfcHealAdditionalParams getAdditionalParams() { - return additionalParams; - } - - public void setAdditionalParams(VfcHealAdditionalParams additionalParams) { - this.additionalParams = additionalParams; - } -} diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcManager.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcManager.java deleted file mode 100644 index 7cea2f181..000000000 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcManager.java +++ /dev/null @@ -1,190 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017-2018 Intel Corp, AT&T. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corporation. All rights reserved. - * Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd. - * ================================================================================ - * 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.vfc; - -import com.google.gson.JsonSyntaxException; - -import java.util.HashMap; -import java.util.Map; - -import org.drools.core.WorkingMemory; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil; -import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; -import org.onap.policy.drools.system.PolicyEngine; -import org.onap.policy.rest.RestManager; -import org.onap.policy.rest.RestManager.Pair; -import org.onap.policy.vfc.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class VfcManager implements Runnable { - - private String vfcUrlBase; - private String username; - private String password; - private VfcRequest vfcRequest; - private WorkingMemory workingMem; - private static final Logger logger = LoggerFactory.getLogger(VfcManager.class); - - // The REST manager used for processing REST calls for this VFC manager - private RestManager restManager; - - /** - * Constructor. - * - * @param wm Drools working memory - * @param request request - */ - public VfcManager(WorkingMemory wm, VfcRequest request) { - if (wm == null || request == null) { - throw new IllegalArgumentException( - "the parameters \"wm\" and \"request\" on the VfcManager constructor may not be null"); - } - workingMem = wm; - vfcRequest = request; - - restManager = new RestManager(); - - // use getPEManagerEnvProperty() for required properties; others are optional - setVfcParams(getPeManagerEnvProperty("vfc.url"), PolicyEngine.manager.getEnvironmentProperty("vfc.username"), - PolicyEngine.manager.getEnvironmentProperty("vfc.password")); - } - - /** - * Set the parameters. - * - * @param baseUrl base URL - * @param name username - * @param pwd password - */ - public void setVfcParams(String baseUrl, String name, String pwd) { - vfcUrlBase = baseUrl + "/api/nslcm/v1"; - username = name; - password = pwd; - } - - @Override - public void run() { - Map<String, String> headers = new HashMap<>(); - Pair<Integer, String> httpDetails; - - VfcResponse responseError = new VfcResponse(); - responseError.setResponseDescriptor(new VfcResponseDescriptor()); - responseError.getResponseDescriptor().setStatus("error"); - - headers.put("Accept", "application/json"); - String vfcUrl = vfcUrlBase + "/ns/" + vfcRequest.getNsInstanceId() + "/heal"; - try { - String vfcRequestJson = Serialization.gsonPretty.toJson(vfcRequest); - NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, vfcUrl, vfcRequestJson); - - httpDetails = restManager.post(vfcUrl, username, password, headers, "application/json", vfcRequestJson); - } catch (Exception e) { - logger.error(e.getMessage(), e); - workingMem.insert(responseError); - return; - } - - if (httpDetails == null) { - workingMem.insert(responseError); - return; - } - - if (httpDetails.first != 202) { - logger.warn("VFC Heal Restcall failed"); - return; - } - - try { - VfcResponse response = Serialization.gsonPretty.fromJson(httpDetails.second, VfcResponse.class); - NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, vfcUrl, httpDetails.second); - String body = Serialization.gsonPretty.toJson(response); - logger.debug("Response to VFC Heal post:"); - logger.debug(body); - - String jobId = response.getJobId(); - int attemptsLeft = 20; - - String urlGet = vfcUrlBase + "/jobs/" + jobId; - VfcResponse responseGet = null; - - while (attemptsLeft-- > 0) { - NetLoggerUtil.getNetworkLogger().info("[OUT|{}|{}|]", "VFC", urlGet); - Pair<Integer, String> httpDetailsGet = restManager.get(urlGet, username, password, headers); - responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.second, VfcResponse.class); - NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, vfcUrl, httpDetailsGet.second); - responseGet.setRequestId(vfcRequest.getRequestId().toString()); - body = Serialization.gsonPretty.toJson(responseGet); - logger.debug("Response to VFC Heal get:"); - logger.debug(body); - - String responseStatus = responseGet.getResponseDescriptor().getStatus(); - if (httpDetailsGet.first == 200 - && ("finished".equalsIgnoreCase(responseStatus) || "error".equalsIgnoreCase(responseStatus))) { - logger.debug("VFC Heal Status {}", responseGet.getResponseDescriptor().getStatus()); - workingMem.insert(responseGet); - break; - } - Thread.sleep(20000); - } - if ((attemptsLeft <= 0) && (responseGet != null) && (responseGet.getResponseDescriptor() != null) - && (responseGet.getResponseDescriptor().getStatus() != null) - && (!responseGet.getResponseDescriptor().getStatus().isEmpty())) { - logger.debug("VFC timeout. Status: ({})", responseGet.getResponseDescriptor().getStatus()); - workingMem.insert(responseGet); - } - } catch (JsonSyntaxException e) { - logger.error("Failed to deserialize into VfcResponse {}", e.getLocalizedMessage(), e); - } catch (InterruptedException e) { - logger.error("Interrupted exception: {}", e.getLocalizedMessage(), e); - Thread.currentThread().interrupt(); - } catch (Exception e) { - logger.error("Unknown error deserializing into VfcResponse {}", e.getLocalizedMessage(), e); - } - } - - /** - * Protected setter for rest manager to allow mocked rest manager to be used for testing. - * - * @param restManager the test REST manager - */ - protected void setRestManager(final RestManager restManager) { - this.restManager = restManager; - } - - /** - * This method reads and validates environmental properties coming from the policy engine. Null - * properties cause an {@link IllegalArgumentException} runtime exception to be thrown - * - * @param string the name of the parameter to retrieve - * @return the property value - */ - - private String getPeManagerEnvProperty(String enginePropertyName) { - String enginePropertyValue = PolicyEngine.manager.getEnvironmentProperty(enginePropertyName); - if (enginePropertyValue == null) { - throw new IllegalArgumentException("The value of policy engine manager environment property \"" - + enginePropertyName + "\" may not be null"); - } - return enginePropertyValue; - } -} diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcRequest.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcRequest.java deleted file mode 100644 index c4473e7f1..000000000 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcRequest.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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.vfc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.UUID; - -public class VfcRequest implements Serializable { - - private static final long serialVersionUID = 3736300970326332512L; - // These fields are not serialized and not part of JSON - private transient String nsInstanceId; - private transient UUID requestId; - - @SerializedName("healVnfData") - private VfcHealRequest healRequest; - - public VfcRequest() { - // Default constructor - } - - public String getNsInstanceId() { - return nsInstanceId; - } - - public void setNsInstanceId(String nsInstanceId) { - this.nsInstanceId = nsInstanceId; - } - - public UUID getRequestId() { - return requestId; - } - - public void setRequestId(UUID requestId) { - this.requestId = requestId; - } - - public VfcHealRequest getHealRequest() { - return healRequest; - } - - public void setHealRequest(VfcHealRequest healRequest) { - this.healRequest = healRequest; - } -} diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcResponse.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcResponse.java deleted file mode 100644 index 2183be71b..000000000 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcResponse.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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.vfc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -public class VfcResponse implements Serializable { - - private static final long serialVersionUID = 9151443891238218455L; - - @SerializedName("jobId") - private String jobId; - - @SerializedName("responseDescriptor") - private VfcResponseDescriptor responseDescriptor; - - private transient String requestId; - - public VfcResponse() { - // Default constructor - } - - public String getJobId() { - return jobId; - } - - public void setJobId(String jobId) { - this.jobId = jobId; - } - - public VfcResponseDescriptor getResponseDescriptor() { - return responseDescriptor; - } - - public void setResponseDescriptor(VfcResponseDescriptor responseDescriptor) { - this.responseDescriptor = responseDescriptor; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } -} diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcResponseDescriptor.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcResponseDescriptor.java deleted file mode 100644 index 147b937dc..000000000 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VfcResponseDescriptor.java +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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.vfc; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; -import java.util.List; - -public class VfcResponseDescriptor implements Serializable { - - private static final long serialVersionUID = 6827782899144150158L; - - @SerializedName("progress") - private String progress; - - @SerializedName("status") - private String status; - - @SerializedName("statusDescription") - private String statusDescription; - - @SerializedName("errorCode") - private String errorCode; - - @SerializedName("responseId") - private String responseId; - - @SerializedName("responseHistoryList") - private List<VfcResponseDescriptor> responseHistoryList; - - public VfcResponseDescriptor() { - // Default constructor - } - - public String getStatus() { - return status; - } - - public String getProgress() { - return progress; - } - - public void setProgress(String progress) { - this.progress = progress; - } - - public String getStatusDescription() { - return statusDescription; - } - - public void setStatusDescription(String statusDescription) { - this.statusDescription = statusDescription; - } - - public String getErrorCode() { - return errorCode; - } - - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - public String getResponseId() { - return responseId; - } - - public void setResponseId(String responseId) { - this.responseId = responseId; - } - - public List<VfcResponseDescriptor> getResponseHistoryList() { - return responseHistoryList; - } - - public void setResponseHistoryList(List<VfcResponseDescriptor> responseHistoryList) { - this.responseHistoryList = responseHistoryList; - } - - public void setStatus(String status) { - this.status = status; - } -} diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/util/Serialization.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/util/Serialization.java deleted file mode 100644 index 19aca3aae..000000000 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/util/Serialization.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017-2018 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 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.vfc.util; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -public final class Serialization { - public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping() - .setPrettyPrinting() - .create(); - - private Serialization() { - } - -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/DemoTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/DemoTest.java deleted file mode 100644 index d334d232f..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/DemoTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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.vfc; - -import java.util.LinkedList; - -import org.junit.Test; -import org.onap.policy.vfc.util.Serialization; - -public class DemoTest { - - @Test - public void test() { - VfcRequest request = new VfcRequest(); - - request.setNsInstanceId("100"); - request.setHealRequest(new VfcHealRequest()); - request.getHealRequest().setVnfInstanceId("1"); - request.getHealRequest().setCause("vm is down"); - - request.getHealRequest().setAdditionalParams(new VfcHealAdditionalParams()); - request.getHealRequest().getAdditionalParams().setAction("restartvm"); - - request.getHealRequest().getAdditionalParams().setActionInfo(new VfcHealActionVmInfo()); - request.getHealRequest().getAdditionalParams().getActionInfo().setVmid("33"); - request.getHealRequest().getAdditionalParams().getActionInfo().setVmname("xgw-smp11"); - - String body = Serialization.gsonPretty.toJson(request); - System.out.println(body); - - VfcResponse response = new VfcResponse(); - response.setJobId("1"); - - body = Serialization.gsonPretty.toJson(response); - System.out.println(body); - - response.setResponseDescriptor(new VfcResponseDescriptor()); - response.getResponseDescriptor().setProgress("40"); - response.getResponseDescriptor().setStatus("processing"); - response.getResponseDescriptor().setStatusDescription("OMC VMs are decommissioned in VIM"); - response.getResponseDescriptor().setErrorCode(null); - response.getResponseDescriptor().setResponseId("42"); - body = Serialization.gsonPretty.toJson(response); - System.out.println(body); - - VfcResponseDescriptor responseDescriptor = new VfcResponseDescriptor(); - responseDescriptor.setProgress("20"); - responseDescriptor.setStatus("processing"); - responseDescriptor.setStatusDescription("OMC VMs are decommissioned in VIM"); - responseDescriptor.setErrorCode(null); - responseDescriptor.setResponseId("11"); - - response.getResponseDescriptor().setResponseHistoryList(new LinkedList<>()); - response.getResponseDescriptor().getResponseHistoryList().add(responseDescriptor); - - body = Serialization.gsonPretty.toJson(response); - System.out.println(body); - - response = Serialization.gsonPretty.fromJson(body, VfcResponse.class); - body = Serialization.gsonPretty.toJson(response); - System.out.println(body); - - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealActionVmInfoTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealActionVmInfoTest.java deleted file mode 100644 index 8b5b118d2..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealActionVmInfoTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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.vfc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class VfcHealActionVmInfoTest { - - @Test - public void testVfcHealActionVmInfo() { - VfcHealActionVmInfo actionInfo = new VfcHealActionVmInfo(); - assertNotNull(actionInfo); - assertNotEquals(0, actionInfo.hashCode()); - - String vmid = "ECity"; - actionInfo.setVmid(vmid); - assertEquals(vmid, actionInfo.getVmid()); - - String vmName = "Emerald City"; - actionInfo.setVmname(vmName); - assertEquals(vmName, actionInfo.getVmname()); - - assertNotEquals(0, actionInfo.hashCode()); - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealAdditionalParamsTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealAdditionalParamsTest.java deleted file mode 100644 index e7cb79fef..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealAdditionalParamsTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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.vfc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class VfcHealAdditionalParamsTest { - - @Test - public void testVfcHealAdditionalParameters() { - VfcHealAdditionalParams additionalParams = new VfcHealAdditionalParams(); - assertNotNull(additionalParams); - assertNotEquals(0, additionalParams.hashCode()); - - String action = "Go Home"; - additionalParams.setAction(action); - assertEquals(action, additionalParams.getAction()); - - VfcHealActionVmInfo actionInfo = new VfcHealActionVmInfo(); - additionalParams.setActionInfo(actionInfo ); - assertEquals(actionInfo, additionalParams.getActionInfo()); - - assertNotEquals(0, additionalParams.hashCode()); - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealRequestTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealRequestTest.java deleted file mode 100644 index b67b9ac07..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealRequestTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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.vfc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class VfcHealRequestTest { - - @Test - public void testVfcHealRequest() { - VfcHealRequest request = new VfcHealRequest(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - String vnfInstanceId = "Go To Oz"; - request.setVnfInstanceId(vnfInstanceId); - assertEquals(vnfInstanceId, request.getVnfInstanceId()); - - String cause = "West Witch"; - request.setCause(cause); - assertEquals(cause, request.getCause()); - - VfcHealAdditionalParams additionalParams = new VfcHealAdditionalParams(); - request.setAdditionalParams(additionalParams); - assertEquals(additionalParams, request.getAdditionalParams()); - - assertNotEquals(0, request.hashCode()); - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java deleted file mode 100644 index f9e6e8260..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java +++ /dev/null @@ -1,293 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson, AT&T. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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.vfc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.endsWith; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.startsWith; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import org.drools.core.WorkingMemory; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.drools.system.PolicyEngine; -import org.onap.policy.rest.RestManager; -import org.onap.policy.rest.RestManager.Pair; -import org.onap.policy.vfc.util.Serialization; - -public class VfcManagerTest { - private static WorkingMemory mockedWorkingMemory; - - private RestManager mockedRestManager; - - private Pair<Integer, String> httpResponsePutOk; - private Pair<Integer, String> httpResponseGetOk; - private Pair<Integer, String> httpResponseBadResponse; - private Pair<Integer, String> httpResponseErr; - - private VfcRequest request; - private VfcResponse response; - - @BeforeClass - public static void beforeTestVfcManager() { - mockedWorkingMemory = mock(WorkingMemory.class); - } - - /** - * Set up the mocked REST manager. - */ - @Before - public void setupMockedRest() { - mockedRestManager = mock(RestManager.class); - - httpResponsePutOk = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(response)); - httpResponseGetOk = mockedRestManager.new Pair<>(200, Serialization.gsonPretty.toJson(response)); - httpResponseBadResponse = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(null)); - httpResponseErr = mockedRestManager.new Pair<>(200, null); - } - - /** - * Create the request and response before. - */ - @Before - public void createRequestAndResponse() { - VfcHealActionVmInfo actionInfo = new VfcHealActionVmInfo(); - actionInfo.setVmid("TheWizard"); - actionInfo.setVmname("The Wizard of Oz"); - - VfcHealAdditionalParams additionalParams = new VfcHealAdditionalParams(); - additionalParams.setAction("Go Home"); - additionalParams.setActionInfo(actionInfo); - - VfcHealRequest healRequest = new VfcHealRequest(); - healRequest.setAdditionalParams(additionalParams); - healRequest.setCause("WestWitch"); - healRequest.setVnfInstanceId("EmeraldCity"); - - final UUID requestId = UUID.randomUUID(); - request = new VfcRequest(); - request.setHealRequest(healRequest); - request.setNsInstanceId("Dorothy"); - request.setRequestId(requestId); - - List<VfcResponseDescriptor> responseHistoryList = new ArrayList<>();; - - VfcResponseDescriptor responseDescriptor = new VfcResponseDescriptor(); - responseDescriptor.setErrorCode("1234"); - responseDescriptor.setProgress("Follow The Yellow Brick Road"); - responseDescriptor.setResponseHistoryList(responseHistoryList); - responseDescriptor.setResponseId(UUID.randomUUID().toString()); - responseDescriptor.setStatus("finished"); - responseDescriptor.setStatusDescription("There's no place like home"); - - response = new VfcResponse(); - response.setJobId("1234"); - response.setRequestId(request.getRequestId().toString()); - response.setResponseDescriptor(responseDescriptor); - } - - /** - * Remove the environnment. - */ - @After - public void tearDown() { - PolicyEngine.manager.getEnvironment().remove("vfc.password"); - PolicyEngine.manager.getEnvironment().remove("vfc.username"); - PolicyEngine.manager.getEnvironment().remove("vfc.url"); - } - - @Test - public void testVfcInitiation() { - try { - new VfcManager(null, null); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals("the parameters \"wm\" and \"request\" on the VfcManager constructor may not be null", - e.getMessage()); - } - - try { - new VfcManager(mockedWorkingMemory, null); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals("the parameters \"wm\" and \"request\" on the VfcManager constructor may not be null", - e.getMessage()); - } - - try { - new VfcManager(mockedWorkingMemory, request); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals("The value of policy engine manager environment property \"vfc.url\" may not be null", - e.getMessage()); - } - - // add url; username & password are not required - PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); - new VfcManager(mockedWorkingMemory, request); - - // url & username, but no password - PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); - - // url, username, and password - PolicyEngine.manager.getEnvironment().put("vfc.password", "Toto"); - new VfcManager(mockedWorkingMemory, request); - } - - @Test - public void testVfcExecutionException() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("vfc.password", "Exception"); - - VfcManager manager = new VfcManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post( - startsWith("http://somewhere.over.the.rainbow"), - eq("Dorothy"), - eq("Exception"), - anyMap(), - anyString(), - anyString())) - .thenThrow(new RuntimeException("OzException")); - - managerThread.join(); - - PolicyEngine.manager.getEnvironment().remove("vfc.password"); - PolicyEngine.manager.getEnvironment().remove("vfc.username"); - PolicyEngine.manager.getEnvironment().remove("vfc.url"); - } - - @Test - public void testVfcExecutionNull() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("vfc.password", "Null"); - - VfcManager manager = new VfcManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), - eq("Dorothy"), eq("Null"), anyMap(), anyString(), anyString())) - .thenReturn(null); - - managerThread.join(); - - PolicyEngine.manager.getEnvironment().remove("vfc.password"); - PolicyEngine.manager.getEnvironment().remove("vfc.username"); - PolicyEngine.manager.getEnvironment().remove("vfc.url"); - } - - @Test - public void testVfcExecutionError0() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("vfc.password", "Error0"); - - VfcManager manager = new VfcManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), - eq("Dorothy"), eq("Error0"), anyMap(), anyString(), anyString())) - .thenReturn(httpResponseErr); - - managerThread.join(); - - PolicyEngine.manager.getEnvironment().remove("vfc.password"); - PolicyEngine.manager.getEnvironment().remove("vfc.username"); - PolicyEngine.manager.getEnvironment().remove("vfc.url"); - } - - @Test - public void testVfcExecutionBadResponse() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("vfc.password", "BadResponse"); - - VfcManager manager = new VfcManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), - eq("Dorothy"), eq("OK"), anyMap(), anyString(), anyString())) - .thenReturn(httpResponseBadResponse); - - managerThread.join(); - - PolicyEngine.manager.getEnvironment().remove("vfc.password"); - PolicyEngine.manager.getEnvironment().remove("vfc.username"); - PolicyEngine.manager.getEnvironment().remove("vfc.url"); - } - - @Test - public void testVfcExecutionOk() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("vfc.password", "OK"); - - VfcManager manager = new VfcManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), - eq("Dorothy"), eq("OK"), anyMap(), anyString(), anyString())) - .thenReturn(httpResponsePutOk); - - when(mockedRestManager.get(endsWith("1234"), eq("Dorothy"), eq("OK"), anyMap())) - .thenReturn(httpResponseGetOk); - - managerThread.join(); - - PolicyEngine.manager.getEnvironment().remove("vfc.password"); - PolicyEngine.manager.getEnvironment().remove("vfc.username"); - PolicyEngine.manager.getEnvironment().remove("vfc.url"); - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcRequestTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcRequestTest.java deleted file mode 100644 index 7dede1b7b..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcRequestTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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.vfc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; - -import org.junit.Test; - -public class VfcRequestTest { - - @Test - public void testVfcRequest() { - VfcRequest request = new VfcRequest(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - String nsInstanceId = "Dorothy"; - request.setNsInstanceId(nsInstanceId); - assertEquals(nsInstanceId, request.getNsInstanceId()); - - UUID requestId = UUID.randomUUID(); - request.setRequestId(requestId); - assertEquals(requestId, request.getRequestId()); - - VfcHealRequest healRequest = new VfcHealRequest(); - request.setHealRequest(healRequest); - assertEquals(healRequest, request.getHealRequest()); - - assertNotEquals(0, request.hashCode()); - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseDescriptorTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseDescriptorTest.java deleted file mode 100644 index b4dc81b44..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseDescriptorTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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.vfc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -public class VfcResponseDescriptorTest { - - @Test - public void testVfcResponseDescriptor() { - VfcResponseDescriptor descriptor = new VfcResponseDescriptor(); - assertNotNull(descriptor); - assertNotEquals(0, descriptor.hashCode()); - - String errorCode = "WitchIsDead"; - descriptor.setErrorCode(errorCode); - assertEquals(errorCode, descriptor.getErrorCode()); - - String progress = "Visited Wizard"; - descriptor.setProgress(progress); - assertEquals(progress, descriptor.getProgress()); - - List<VfcResponseDescriptor> responseHistoryList = new ArrayList<>(); - descriptor.setResponseHistoryList(responseHistoryList); - assertEquals(responseHistoryList, descriptor.getResponseHistoryList()); - - String responseId = "WishHard"; - descriptor.setResponseId(responseId); - assertEquals(responseId, descriptor.getResponseId()); - - String status = "Back in Kansas"; - descriptor.setStatus(status); - assertEquals(status, descriptor.getStatus()); - - String statusDescription = "Back on the prairie"; - descriptor.setStatusDescription(statusDescription); - assertEquals(statusDescription, descriptor.getStatusDescription()); - - assertNotEquals(0, descriptor.hashCode()); - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseTest.java deleted file mode 100644 index 15ba6f520..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018-2019 AT&T Corporation. 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.vfc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class VfcResponseTest { - - @Test - public void testVfcResponse() { - VfcResponse response = new VfcResponse(); - assertNotNull(response); - assertNotEquals(0, response.hashCode()); - - String jobId = "GetToOz"; - response.setJobId(jobId); - assertEquals(jobId, response.getJobId()); - - String requestId = "Get Home"; - response.setRequestId(requestId); - assertEquals(requestId, response.getRequestId()); - - VfcResponseDescriptor responseDescriptor = new VfcResponseDescriptor(); - response.setResponseDescriptor(responseDescriptor); - assertEquals(responseDescriptor, response.getResponseDescriptor()); - - assertNotEquals(0, response.hashCode()); - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/util/SerializationTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/util/SerializationTest.java deleted file mode 100644 index beceb045a..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/util/SerializationTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. 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.vfc.util; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class SerializationTest { - - @Test - public void test() { - assertNotNull(Serialization.gsonPretty); - } -} diff --git a/controlloop/common/policy-yaml/README-guard-v2.0.0.md b/controlloop/common/policy-yaml/README-guard-v2.0.0.md deleted file mode 100644 index 55bfcc0f7..000000000 --- a/controlloop/common/policy-yaml/README-guard-v2.0.0.md +++ /dev/null @@ -1,187 +0,0 @@ -Copyright 2018 AT&T Intellectual Property. All rights reserved. -This file is licensed under the CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE -Full license text at https://creativecommons.org/licenses/by/4.0/legalcode - -ONAP Control Loop Guard - -A control loop guard is a YAML specification for creating policy guard for ControlLoop. - -ONAP Control Loop Guard Features: - -* The Control Loop Guard can specify the frequency limiter and the blacklist of target entities but not both in the same Guard. -* Two parts are incorporated. One is the common guard header including guard version while the other part is a set of guard policies. -* The Control Loop Guard should contain at least one guard policies. -* Each guard policy is bound to a specific Actor and Recipe. -* Each guard policy should have at least one limit constraints which define how the guard policy should be enforced. -* Supported Actors are APPC and SO. - -This SDK helps build the YAML specification for ONAP Control Loop Guard. - -# Create Builder Object - -To begin with, the ControlLoopGuardBuilder.Factory class has static methods that one should use to begin building a Control Loop Guard. It will return a [ControlLoopGuardBuilder object](src/main/java/org/onap/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java) that can then be used to continue to build and define the Control Loop Guard. - -```java - ControlLoopGuardBuilder builder = ControlLoopGuardBuilder.Factory.buildControlLoopGuard(new Guard()); -``` - -# Add Guard Policy - -After a guard builder has been created, the next step would be to add a guard policy to the newly created Control Loop Guard via the builder. To add a guard policy, use the addGuardPolicy() method. - -```java - GuardPolicy policy = new GuardPolicy( - "unique_guard_vUSP_1", - "APPC 5 Restart", - "We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am)", - "APPC", - "Restart"); - builder = builder.addGuardPolicy(policy); -``` - -# Add Limit Constraint to a Guard Policy - -The limit constraint defines the details of how to enforce the guard policy. Each limit constraint can contain two types of constraints - frequency limiter and black list. At least one type of constraints should be specified, otherwise the limit constraint will be counted as invalid. To add a limit constraint to an existing guard policy, use the addLimitConstraint() method. - -```java - Map<String, String> time_in_range = new HashMap<String, String>(); - time_in_range.put("arg2", "PT5H"); - time_in_range.put("arg3", "PT24H"); - List<String> blacklist = new LinkedList<String>(); - blacklist.add("vm_name_1"); - blacklist.add("vm_name_2"); - Constraint cons = new Constraint(5, "PT15M", time_in_range, blacklist); - builder = builder.addLimitConstraint(policy.id, cons); -``` - - -# Build the YAML Specification - -When finished defining the Guard Policies, build the specification and analyze the [Results.java](src/main/java/org/onap/policy/controlloop/policy/builder/Results.java) - -```java - Results results = builder.buildSpecification(); - if (results.isValid()) { - System.out.println(results.getSpecification()); - } else { - System.err.println("Builder failed"); - for (Message message : results.getMessages()) { - System.err.println(message.getMessage()); - } - } -``` - - -# Use the YAML Specification to Generate the XACML Guard Policies - -Now that you have a valid YAML specification, call the method in [PolicyGuardYamlToXacml.java](guard/src/main/java/org/onap/policy/guard/PolicyGuardYamlToXacml.java) to generate the XACML Guard Policies. - - -# YAML Specification - -The YAML specification has 2 sections to it: [guard](#guard-object) and [guards](#guards-array). The [guard section](#guard-object) section is simply a header defining the version of this guard. The [guards section](#guards-array) is simply an array of [GuardPolicy objects](#guardpolicy-object). - -## guard Object - -| Field Name | Type | Required | Description | -| ------------- |:-------------:| -----------| ------------:| -| version | string | required | Value for this release if 2.0.0 | - - -## guards array - -The guards section is an array of [GuardPolicy objects](#guardpolicy-object). - -### GuardPolicy Object - -| Field Name | Type | Required | Description | -| ------------- |:-------------:| -----------| ------------:| -| id | string | required | Unique ID for the policy. | -| name | string | required | Policy name | -| description | string | optional | Policy description | -| actor | string | required | Name of the actor for this operation: Example: APPC | -| recipe | string | required | Name of recipe to be performed. Example "Restart" | -| limit_constraints | array of [constraint](#constraint-object) object | required | Constraints used to enforce the guard policy | - -The guard policy is bound to a specific recipe performed by the actor. When the Control Loop tries to perform the recipe operation by the actor, this guard policy should be evaluated against all the specified constraints. If any of the constraints will be violated, the operation should be abandoned. - -#### constraint Object - -| Field Name | Type | Required | Description | -| ------------- |:-------------:| -----------| ------------:| -| num | integer | required if blacklist is not specified | The limited number of the same operations | -| duration | string | required if blacklist is not specified | Time window for counting the same operations | -| time_in_range | map<string, string> | optional | Valid time spans for enforcing the guard policy | -| blacklist | array of string | required if num and duration are not specified | A list of the entity names that should not be touched by the Control Loop | - -The first three attributes define the frequency limiter which means that only a limited number of the same operations can be allowed within each valid time window. The last attribute defines a blacklist of the target entities on which the Control Loop should not perform the operation. - -The "duration" parameter should have one of the following values: [5min, 10min, 30min, 1h, 12h, 1d, 5d, 1w, 1mon]. - - -## Examples of YAML Control Loop Guards - -[vService-Frequency-Limiter-Guard](src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml) -[vService-Blacklist-Guard](src/test/resources/v2.0.0-guard/policy_guard_blacklist.yaml) -[ONAP-vDNS-Guard](src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml) - - -### vService Frequency Limiter Guard -``` -guard: - version: 2.0.0 - -guards: - - id: unique_guard_vService_frequency_limiter - name: APPC 5 Restart - description: - We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am) - actor: APPC - recipe: Restart - limit_constraints: - - num: 5 - duration: PT15M - time_in_range: - arg2: PT5H - arg3: PT24H -``` - - -### vService Blacklist Guard -``` -guard: - version: 2.0.0 - -guards: - - id: unique_guard_vService_blacklist - name: APPC Restart Blacklist - description: | - We deny restart of the blacklisted targets (avoid midnight to 5am) - actor: APPC - recipe: Restart - limit_constraints: - - blacklist: - - TargetName1 - - TargetName2 - time_in_range: - arg2: 00:00:00-05:00 - arg3: 23:59:59-05:00 -``` - - -### ONAP vDNS Guard -``` -guard: - version: 2.0.0 - -guards: - - id: unique_guard_ONAP_vDNS_1 - name: SO Spinup - description: We only spin up 1 instance over a 10 minute window - actor: SO - recipe: VF Module Create - limit_constraints: - - num: 1 - duration: PT10M -``` - diff --git a/controlloop/common/policy-yaml/README-v1.0.0.md b/controlloop/common/policy-yaml/README-v1.0.0.md deleted file mode 100644 index 2485f48bb..000000000 --- a/controlloop/common/policy-yaml/README-v1.0.0.md +++ /dev/null @@ -1,263 +0,0 @@ -Copyright 2018 AT&T Intellectual Property. All rights reserved. -This file is licensed under the CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE -Full license text at https://creativecommons.org/licenses/by/4.0/legalcode - -ONAP Control Loop Policy v1.0.0 - -A control loop policy is a YAML specification for creating and chaining policies for ControlLoop. - -Features of ONAP Control Loop Policy v1.0.0: - -* A single DCAE Closed Loop Event is the trigger for the overall Control Loop Policy -* APPC is the only Actor that Policy will interact with. The operations available are: RESTART, REBUILD, MIGRATE. -* An overall timeout for the Control Loop Policy must be provided -* The Control Loop Policy can contain zero or more Operational Policies each chained together via outcomes of each policy. -* If there are zero Operational Policies, i.e. no automated action is to be taken, then the policy is an Open Loop policy. -* Operational Policies can have retries and timeout's given to control how they are processed. - -This SDK helps build the YAML specification for ONAP Control Loop Policy v1.0.0. - -# Create Builder Object - -To begin with, the ControlLoopPolicyBuilder.Factory class has static methods that one should use to begin building a Control Loop Policy. It will return a [ControlLoopPolicyBuilder object](src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java) that can then be used to continue to build and define the Control Loop Policy. - -```java - ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop( - UUID.randomUUID().toString(), - 2400, - new Resource("sampleResource", ResourceType.VF), - new Service("sampleService") - ); -``` - -# Define the Trigger Policy - -After the name of the Control Loop and the resource and services have been defined, the next step would be to define the Operation Policy that is first to respond to an incoming DCAE Closed Loop Event. Use the setTriggerPolicy() method to do so. - -```java - Policy triggerPolicy = builder.setTriggerPolicy( - "Restart the VM", - "Upon getting the trigger event, restart the VM", - Actor.APPC, - Target.VM, - "Restart", - 2, - 300); -``` - -# Chain Operational Policies Together Using Operational Results - -Operational Policies are chained together using the results of each Operational Policy. The results are defined in [PolicyResult.java](src/main/java/org/onap/policy/controlloop/policy/PolicyResult.java). To create an Operational Policy that is tied to the result of another, use the -setPolicyForPolicyResult() method. - -```java - Policy onRestartFailurePolicy = builder.setPolicyForPolicyResult( - "Rebuild VM", - "If the restart fails, rebuild it.", - Actor.APPC, - Target.VM, - "Rebuild", - 1, - 600, - triggerPolicy.id, - PolicyResult.FAILURE, - PolicyResult.FAILURE_RETRIES, - PolicyResult.FAILURE_TIMEOUT); -``` - -An Operational Policy MUST have place to go for every one of its results. By default, each result type goes to a Final Result. Optionally, using the setPolicyForPolicyResult() method is what allows the chaining of policies. Be aware of creating loops and set the overall Control Loop timeout to reasonable value. All paths MUST lead to a Final Result. - -# Build the YAML Specification - -When finished defining the Policies, build the specification and analyze the [Results.java](src/main/java/org/onap/policy/controlloop/policy/builder/Results.java) - -```java - Results results = builder.buildSpecification(); - if (results.isValid()) { - System.out.println(results.getSpecification()); - } else { - System.err.println("Builder failed"); - for (Message message : results.getMessages()) { - System.err.println(message.getMessage()); - } - } -``` - - -# Use the YAML Specification to call the Create Policy API - -Now that you have a valid YAML specification, call the createPolicy API via the ONAP Policy Platform API. - -# YAML Specification - -The YAML specification has 2 sections to it: [controlLoop](#controlloop-object) and [policies](#policies-array). The [controlLoop section](#controlloop-object) section is simply a header defining the Control Loop Policy, what services its for, which resource its for, or if its for a pnf, the overall timeout, and which Operational Policy is triggered upon receiving the event. The [policies section](#policies-array) is simply an array of [Policy Objects](#policy-object). - -## controlLoop Object - -| Field Name | Type | Required | Description | -| ------------- |:-------------:| -----------| ------------:| -| controlLoopName | string | required | Unique ID for the control Loop | -| version | string | required | Value for this release if 1.0.0 | -| services | array of [service](#service-object) objects | optional | Zero or more services associated with this Control Loop | -| resources | array of [resource](#resource-object) object | required (If NOT a pnf control loop) | The resource's associated with this Control Loop. | -| pnf | [pnf](#pnf-object) object | required (If NOT a resource control loop) | The physical network function associated with this Control Loop. | -| trigger_policy | string | required | Either this is the ID of an Operation Policy (see policy object), or "Final_OpenLoop" indicating an Open Loop | -| timeout | int | required | This is the overall timeout for the Control Loop Policy. It can be 0 for an Open Loop, but otherwise should total more than the timeouts specified in any Operational Policies | - -### resource Object - -This object was derived via SDC Catalog API and SDC Data Dictionary (POC) in an attempt to use common naming conventions. - -| Field Name | Type | Required | Description | -| ------------- |:-------------:| -----------| ------------:| -| resourceInvariantUUID | string - UUID | optional | via SDC, the unique ID for the resource version | -| resourceName | string | required if NO resourceUUID available | Name of the resource, ideally from SDC catalog. But if not available, use well-known name. | -| resourceType | string | optional | Use values defined by SDC: VF, VFC, VL, CP. | -| resourceUUID | string - UUID | required IF available, else populate resourceName | Unique ID for the resource as assigned via SDC. -| resourceVersion | string | optional | string version of the resource via SDC catalog - -SDC catalog is not fully available and resources have not been defined yet, use resourceName. Eg. vFW - -### service Object - -This object was derived via SDC Catalog API and SDC Data Dictionary (POC) in an attempt to use common naming conventions. - -| Field Name | Type | Required | Description | -| ------------- |:-------------:| -----------| ------------:| -| serviceInvariantUUID | string - UUID | optional | via SDC catalog, the unique ID for the service version | -| serviceName | string | required if NO serviceUUID available | Name of the service, ideally from SDC catalog. But if not available, use well-known name. | -| serviceUUID | string - UUID | required IF available, else populate serviceName | Unique ID fort he service as assigned via SDC -| serviceVersion | string | optional | string version of the service via SDC catalog - -SDC catalog is not fully available and some services have not been defined yet, use serviceName. Eg. vLB. - -### pnf Object - -This object is used for a physical network function. Expect this object to change in the future when ONAP Policy fully integrates with A&AI. - -| Field Name | Type | Required | Description | -| ------------- |:-------------:| -----------| ------------:| -| PNFName | string | required | Name of the PNF. Should be supplied via A&AI. If not available use a well-known name. | -| PNFType | string | optional | Type of PNF if available. | - - -## policies array - -The policies section is an array of [Policy objects](#policy-object). - -### Policy Object - -This is an Operation Policy. It is used to instruct an actor (eg. APPC) to invoke a recipe (eg. "Restart") on a target entity (eg. a "VM"). An operation is simply defined as performing a recipe (or operation) on an actor. - -| Field Name | Type | Required | Description | -| ------------- |:-------------:| -----------| ------------:| -| id | string | required | Unique ID for the policy. -| name | string | required | Policy name | -| description | string | optional | Policy description | -| actor | string | required | Name of the actor for this operation: Example: APPC | -| recipe | string | required | Name of recipe to be performed. Example "Restart" | -| target | string | required | Entity being targeted. Example: VM | -| timeout | int | required | Timeout for the actor to perform the recipe. | -| retry | int | optional | Optional number of retries for ONAP Policy to invoke the recipe on the actor. | -| success | string | required | By default, this value should be FINAL_SUCCESS. Otherwise this can be the ID of the operational Policy (included in this specification) to invoke upon successfully completing the recipe on the actor. -| failure | string | required | By default, this value should be FINAL_FAILURE. Otherwise this can be the ID of the operational Policy (included in this specification) to invoke upon failure to perform the operation. | -| failure_exception | string | required | By default, this value should be FINAL_FAILURE_EXCEPTION. Otherwise this can be the ID of an Operational Policy (included in this specification) to invoke upon an exception occurring while attempting to perform the operation. | -| failure_retries | string | required | By default, this value should be the FINAL_FAILURE_RETRIES. Otherwise this can be the ID of an Operational Policy (included in this specification) to invoke upon maxing out on retries while attempting to perform the operation. | -| failure_timeout | string | required | By default, this value should be FINAL_FAILURE_TIMEOUT. Otherwise this can be the ID of the operational Policy (included in this specification) to invoke upon a timeout occuring while performing an operation. | - -Every Operational Policy MUST have a place to go for every possible result (success, failure, failure_retries, failure_timeout, failure_exception). By default, all the results are final results. - -## Examples of YAML Control Loops v1.0.0 - -[vService](src/test/resources/v1.0.0/policy_vService.yaml) -[Open-Loop](src/test/resources/v1.0.0/policy_OpenLoop.yaml) - - -### vService -``` -controlLoop: - version: 1.0.0 - controlLoopName: ControlLoop-vService-cbed919f-2212-4ef7-8051-fe6308da1bda - services: - - serviceName: service1 - resources: - - resourceName: resource1 - resourceType: VF - - resourceName: resource2 - resourceType: VF - - resourceName: resource3 - resourceType: VF - - resourceName: resource4 - resourceType: VF - - resourceName: resource5 - resourceType: VF - trigger_policy: unique-policy-id-1-restart - timeout: 1200 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy - description: - actor: APPC - recipe: Restart - target: VM - retry: 2 - timeout: 300 - success: final_success - failure: unique-policy-id-2-rebuild - failure_timeout: unique-policy-id-2-rebuild - failure_retries: unique-policy-id-2-rebuild - failure_exception: final_failure_exception - - - id: unique-policy-id-2-rebuild - name: Rebuild Policy - description: - actor: APPC - recipe: Rebuild - target: VM - retry: 0 - timeout: 600 - success: final_success - failure: unique-policy-id-3-migrate - failure_timeout: unique-policy-id-3-migrate - failure_retries: unique-policy-id-3-migrate - failure_exception: final_failure_exception - - - id: unique-policy-id-3-migrate - name: Migrate Policy - description: - actor: APPC - recipe: Migrate - target: VM - retry: 0 - timeout: 600 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception - -``` - -### Open Loop -``` -controlLoop: - version: 1.0.0 - controlLoopName: ControlLoop-Open-fac4ae3d-c3f5-4bab-8e54-0a8581ede132 - services: - - serviceName: service1 - resources: - - resourceType: VF - resourceName: resource1 - trigger_policy: final_openloop - timeout: 0 - -policies: -``` - - - -# Control Loop Final Results Explained - -A Control Loop Policy has the following set of final results, as defined in [FinalResult.java](src/main/java/org/onap/policy/controlloop/policy/FinalResult.java). A final result indicates when a Control Loop Policy has finished execution and is finished processing a Closed Loop Event. All paths must lead to a Final Result. - diff --git a/controlloop/common/policy-yaml/README-v2.0.0.md b/controlloop/common/policy-yaml/README-v2.0.0.md deleted file mode 100644 index 4d79fce98..000000000 --- a/controlloop/common/policy-yaml/README-v2.0.0.md +++ /dev/null @@ -1,354 +0,0 @@ -Copyright 2018 AT&T Intellectual Property. All rights reserved. -This file is licensed under the CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE -Full license text at https://creativecommons.org/licenses/by/4.0/legalcode - -ONAP Control Loop Policy v2.0.0 - -A control loop policy is a YAML specification for creating and chaining policies for ControlLoop. - -Features of ONAP Control Loop Policy v2.0.0: - -* Backward compatible with ONAP Control Loop Policy v1.0.0 -* A single DCAE Closed Loop Event is the trigger for the overall Control Loop Policy. -* An overall timeout for the Control Loop Policy must be provided. -* An abatement flag indicating whether Policy will receive abatement event for the Control Loop could be provided. -* The Control Loop Policy can contain zero or more Operational Policies each chained together via outcomes of each policy. -* If there are zero Operational Policies, i.e. no automated action is to be taken, then the policy is an Open Loop policy. -* Operational policies can have target, retries and timeout's given to control how they are processed. -* Type and resourceID of the target could be provided to support the target in operational policies. -* Payload could be provided to support the recipe. -* Multiple actors along with their supported recipes can be specified in operational policies that Policy will interact with. The following table summarizes the supported actors and recipes. - -| Actor | Recipe | Target | Payload | -| -------------|:---------------------------:| ---------| ------------:| -| APPC | Restart | VM | CloudVServerSelfLink, CloudIdentity | -| APPC | Rebuild | VM | CloudVServerSelfLink, CloudIdentity | -| APPC | Migrate | VM | CloudVServerSelfLink, CloudIdentity | -| APPC | ModifyConfig | VNF | generic-vnf.vnf-id | -| SO | VF Module Create | VFC | optional | - - -This SDK helps build the YAML specification for ONAP Control Loop Policy v2.0.0. - -# Create Builder Object - -To begin with, the ControlLoopPolicyBuilder.Factory class has static methods that one should use to begin building a Control Loop Policy. It will return a [ControlLoopPolicyBuilder object](src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java) that can then be used to continue to build and define the Control Loop Policy. - -```java - ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop( - UUID.randomUUID().toString(), - 2400, - new Resource("sampleResource", ResourceType.VF), - new Service("sampleService") - ); -``` - -# Define the Trigger Policy - -After the name of the Control Loop and the resource and services have been defined, the next step would be to define the Operation Policy that is first to respond to an incoming DCAE Closed Loop Event. Use the setTriggerPolicy() method to do so. - -```java - Policy triggerPolicy = builder.setTriggerPolicy( - "Restart the VM", - "Upon getting the trigger event, restart the VM", - "APPC", - new Target(TargetType.VM), - "Restart", - null, - 2, - 300); -``` - -# Set the Abatement Flag for the Control Loop - -After the trigger policy, the name, the resource(s) and services of the Control Loop have been defined, the next optional step would be to set the abatement flag that indicates whether DCAE will send Policy the abatement event for this Control Loop. If the abatement is not explicitly set, it is assumed that Policy will not receive the abatement event. Use the setAbatement() method to do so. - -```java - builder = builder.setAbatement(false); -``` - -# Chain Operational Policies Together Using Operational Results - -Operational Policies are chained together using the results of each Operational Policy. The results are defined in [PolicyResult.java](src/main/java/org/onap/policy/controlloop/policy/PolicyResult.java). To create an Operational Policy that is tied to the result of another, use the -setPolicyForPolicyResult() method. - -```java - Policy onRestartFailurePolicy = builder.setPolicyForPolicyResult( - "Rebuild VM", - "If the restart fails, rebuild it.", - "APPC", - new Target(TargetType.VM), - "Rebuild", - null, - 1, - 600, - triggerPolicy.id, - PolicyResult.FAILURE, - PolicyResult.FAILURE_RETRIES, - PolicyResult.FAILURE_TIMEOUT, - PolicyResult.FAILURE_GUARD); -``` - -An Operational Policy MUST have place to go for every one of its results. By default, each result type goes to a Final Result. Optionally, using the setPolicyForPolicyResult() method is what allows the chaining of policies. Be aware of creating loops and set the overall Control Loop timeout to reasonable value. All paths MUST lead to a Final Result. - - - -# Build the YAML Specification - -When finished defining the Policies, build the specification and analyze the [Results.java](src/main/java/org/onap/policy/controlloop/policy/builder/Results.java) - -```java - Results results = builder.buildSpecification(); - if (results.isValid()) { - System.out.println(results.getSpecification()); - } else { - System.err.println("Builder failed"); - for (Message message : results.getMessages()) { - System.err.println(message.getMessage()); - } - } -``` - - -# Use the YAML Specification to call the Create Policy API - -Now that you have a valid YAML specification, call the createPolicy API via the ONAP Policy Platform API. - - -# YAML Specification - -The YAML specification has 2 sections to it: [controlLoop](#controlloop-object) and [policies](#policies-array). The [controlLoop section](#controlloop-object) section is simply a header defining the Control Loop Policy, what services its for, which resource its for, or if its for a pnf, the overall timeout, the abatement flag, and which Operational Policy is triggered upon receiving the event. The [policies section](#policies-array) is simply an array of [Policy Objects](#policy-object). - -## controlLoop Object - -| Field Name | Type | Required | Description | -| ------------- |:-------------:| -----------| ------------:| -| controlLoopName | string | required | Unique ID for the control Loop | -| version | string | required | Value for this release if 1.0.0 | -| services | array of [service](#service-object) objects | optional | Zero or more services associated with this Control Loop | -| resources | array of [resource](#resource-object) object | required (If NOT a pnf control loop) | The resource's associated with this Control Loop. | -| pnf | [pnf](#pnf-object) object | required (If NOT a resource control loop) | The physical network function associated with this Control Loop. | -| trigger_policy | string | required | Either this is the ID of an Operation Policy (see policy object), or "Final_OpenLoop" indicating an Open Loop | -| timeout | int | required | This is the overall timeout for the Control Loop Policy. It can be 0 for an Open Loop, but otherwise should total more than the timeouts specified in any Operational Policies | -| abatement | boolean | optional | This is an abatement flag indicating if DCAE will send abatement event to Policy for this Control Loop | - -### resource Object - -This object was derived via SDC Catalog API and SDC Data Dictionary (POC) in an attempt to use common naming conventions. - -| Field Name | Type | Required | Description | -| ------------- |:-------------:| -----------| ------------:| -| resourceInvariantUUID | string - UUID | optional | via SDC, the unique ID for the resource version | -| resourceName | string | required if NO resourceUUID available | Name of the resource, ideally from SDC catalog. But if not available, use well-known name. | -| resourceType | string | optional | Use values defined by SDC: VF, VFC, VL, CP. | -| resourceUUID | string - UUID | required IF available, else populate resourceName | Unique ID for the resource as assigned via SDC. -| resourceVersion | string | optional | string version of the resource via SDC catalog - - -### service Object - -This object was derived via SDC Catalog API and SDC Data Dictionary (POC) in an attempt to use common naming conventions. - -| Field Name | Type | Required | Description | -| ---------------:| -------------:| ----------:| ------------:| -| serviceInvariantUUID | string - UUID | optional | via SDC catalog, the unique ID for the service version | -| serviceName | string | required if NO serviceUUID available | Name of the service, ideally from SDC catalog. But if not available, use well-known name. | -| serviceUUID | string - UUID | required IF available, else populate serviceName | Unique ID fort he service as assigned via SDC -| serviceVersion | string | optional | string version of the service via SDC catalog - - -### pnf Object - -This object is used for a physical network function. Expect this object to change in the future when ONAP Policy fully integrates with A&AI. - -| Field Name | Type | Required | Description | -| ------------- |:-------------:| -----------| ------------:| -| PNFName | string | required | Name of the PNF. Should be supplied via A&AI. If not available use a well-known name. | -| PNFType | string | optional | Type of PNF if available. | - - -## policies array - -The policies section is an array of [Policy objects](#policy-object). - -### Policy Object - -This is an Operation Policy. It is used to instruct an actor (eg. APPC) to invoke a recipe (eg. "Restart") on a target entity (eg. a "VM"). An operation is simply defined as performing a recipe (or operation) on an actor. - -| Field Name | Type | Required | Description | -| ------------- |:-------------:| -----------| ------------:| -| id | string | required | Unique ID for the policy. -| name | string | required | Policy name | -| description | string | optional | Policy description | -| actor | string | required | Name of the actor for this operation: Example: APPC | -| recipe | string | required | Name of recipe to be performed. Example "Restart" | -| target | [target](#target-object) object | required | Entity being targeted. Example: VM | -| timeout | int | required | Timeout for the actor to perform the recipe. | -| retry | int | optional | Optional number of retries for ONAP Policy to invoke the recipe on the actor. | -| success | string | required | By default, this value should be FINAL_SUCCESS. Otherwise this can be the ID of the operational Policy (included in this specification) to invoke upon successfully completing the recipe on the actor. -| failure | string | required | By default, this value should be FINAL_FAILURE. Otherwise this can be the ID of the operational Policy (included in this specification) to invoke upon failure to perform the operation. | -| failure_exception | string | required | By default, this value should be FINAL_FAILURE_EXCEPTION. Otherwise this can be the ID of an Operational Policy (included in this specification) to invoke upon an exception occurring while attempting to perform the operation. | -| failure_retries | string | required | By default, this value should be the FINAL_FAILURE_RETRIES. Otherwise this can be the ID of an Operational Policy (included in this specification) to invoke upon maxing out on retries while attempting to perform the operation. | -| failure_timeout | string | required | By default, this value should be FINAL_FAILURE_TIMEOUT. Otherwise this can be the ID of the operational Policy (included in this specification) to invoke upon a timeout occuring while performing an operation. | -| failure_guard | string | required | By default, this value should be FINAL_FAILURE_GUARD. Otherwise this can be the ID of the operational Policy (included in this specification) to invoke upon Guard denies this operation. | - -Every Operational Policy MUST have a place to go for every possible result (success, failure, failure_retries, failure_timeout, failure_exception, failure_guard). By default, all the results are final results. - -#### target Object - -This object is used for defining a target entity of a recipe. - -| Field Name | Type | Required | Description | -| ------------- |:-------------:| -----------| ------------:| -| type | enums of VM, PNF and VNC | required | Type of the target. | -| resourceID | string | optional | Resource ID of the target. Should be supplied via SDC Catalog. | - - -## Examples of YAML Control Loops v2.0.0 - -[vService](src/test/resources/v2.0.0/policy_vService.yaml) -[ONAP-vFirewall](src/test/resources/v2.0.0/policy_ONAP_demo_vFirewall.yaml) -[ONAP-vDNS](src/test/resources/v2.0.0/policy_ONAP_demo_vDNS.yaml) - -### vService -``` -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-vService-cbed919f-2212-4ef7-8051-fe6308da1bda - services: - - serviceName: service1 - resources: - - resourceName: resource1 - resourceType: VFC - - resourceName: resource2 - resourceType: VFC - - resourceName: resource3 - resourceType: VFC - - resourceName: resource4 - resourceType: VFC - - resourceName: resource5 - resourceType: VFC - trigger_policy: unique-policy-id-1-restart - timeout: 1200 - abatement: false - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy - description: - actor: APPC - recipe: Restart - target: - type: VM - retry: 2 - timeout: 300 - success: final_success - failure: unique-policy-id-2-rebuild - failure_timeout: unique-policy-id-2-rebuild - failure_retries: unique-policy-id-2-rebuild - failure_exception: final_failure_exception - failure_guard: unique-policy-id-2-rebuild - - - id: unique-policy-id-2-rebuild - name: Rebuild Policy - description: - actor: APPC - recipe: Rebuild - target: - type: VM - retry: 0 - timeout: 600 - success: final_success - failure: unique-policy-id-3-migrate - failure_timeout: unique-policy-id-3-migrate - failure_retries: unique-policy-id-3-migrate - failure_exception: final_failure_exception - failure_guard: unique-policy-id-3-migrate - - - id: unique-policy-id-3-migrate - name: Migrate Policy - description: - actor: APPC - recipe: Migrate - target: - type: VM - retry: 0 - timeout: 600 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception - failure_guard: final_failure_guard -``` - - - -### ONAP vFirewall -``` -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a - services: - - serviceInvariantUUID: 5cfe6f4a-41bc-4247-8674-ebd4b98e35cc - serviceUUID: 0f40bba5-986e-4b3c-803f-ddd1b7b25f24 - serviceName: 57e66ea7-0ed6-45c7-970f - trigger_policy: unique-policy-id-1-modifyConfig - timeout: 1200 - -policies: - - id: unique-policy-id-1-modifyConfig - name: Change the Load Balancer - description: - actor: APPC - recipe: ModifyConfig - target: - resourceID: Eace933104d443b496b8.nodes.heat.vpg - payload: - generic-vnf.vnf-id: {generic-vnf.vnf-id} - ref$: pgstreams.json - retry: 0 - timeout: 300 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception - failure_guard: final_failure_guard -``` - -### ONAP vDNS -``` -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 - trigger_policy: unique-policy-id-1-scale-up - timeout: 1200 - abatement: false - -policies: - - id: unique-policy-id-1-scale-up - name: Create a new VF Module - description: - actor: SO - recipe: VF Module Create - target: - type: VNF - payload: - requestParameters: '{"usePreload":true,"userParams":[]}' - configurationParameters: '[{"ip-addr":"$.vf-module-topology.vf-module-parameters.param[9]","oam-ip-addr":"$.vf-module-topology.vf-module-parameters.param[16]","enabled":"$.vf-module-topology.vf-module-parameters.param[23]"}]' - retry: 0 - timeout: 1200 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception - failure_guard: final_failure_guard -``` - - -# Control Loop Final Results Explained - -A Control Loop Policy has the following set of final results, as defined in [FinalResult.java](src/main/java/org/onap/policy/controlloop/policy/FinalResult.java). A final result indicates when a Control Loop Policy has finished execution and is finished processing a Closed Loop Event. All paths must lead to a Final Result. - diff --git a/controlloop/common/policy-yaml/checkstyle-suppressions.xml b/controlloop/common/policy-yaml/checkstyle-suppressions.xml deleted file mode 100644 index 01e66442b..000000000 --- a/controlloop/common/policy-yaml/checkstyle-suppressions.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- - ============LICENSE_START======================================================= - Copyright (C) 2018 AT&T Technologies. 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========================================================= ---> - -<!DOCTYPE suppressions PUBLIC - "-//Puppy Crawl//DTD Suppressions 1.0//EN" - "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd"> - -<suppressions> - <suppress checks="AbbreviationAsWordInName" - files="Target.java|ControlLoopPolicyBuilder.java" - lines="1-9999"/> -</suppressions> diff --git a/controlloop/common/policy-yaml/pom.xml b/controlloop/common/policy-yaml/pom.xml deleted file mode 100644 index 548c92896..000000000 --- a/controlloop/common/policy-yaml/pom.xml +++ /dev/null @@ -1,131 +0,0 @@ -<!-- - ============LICENSE_START======================================================= - drools-pdp-apps - ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - Modifications Copyright (C) 2019 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========================================================= - --> - -<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.drools-applications.controlloop.common</groupId> - <artifactId>common</artifactId> - <version>1.4.0-SNAPSHOT</version> - </parent> - - <artifactId>policy-yaml</artifactId> - - <dependencies> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.yaml</groupId> - <artifactId>snakeyaml</artifactId> - <version>1.17</version> - </dependency> - <dependency> - <groupId>org.jgrapht</groupId> - <artifactId>jgrapht-core</artifactId> - <version>0.9.2</version> - </dependency> - <dependency> - <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> - <artifactId>sdc</artifactId> - <version>${policy.models.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> - <artifactId>aai</artifactId> - <version>${policy.models.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.common</groupId> - <artifactId>utils-test</artifactId> - <version>${version.policy.common}</version> - <scope>test</scope> - </dependency> - </dependencies> - - <!-- - Without this defined here, the checkstyle plugin just simply fails outright. This needs to be investigated - further as there was no real debugging details as to why or any configuration issue detected. - NOTE: I had to append src/main/java to the sourceDirectory. - Is it a reactor ordering issue? I'm wondering why it is being compiled after aai, in between the sub-modules - in model-impl. Dependency ordering?? Circular dependency?? - --> - <build> - <plugins> - <plugin> - <artifactId>maven-checkstyle-plugin</artifactId> - <executions> - <execution> - <id>onap-java-style</id> - <goals> - <goal>check</goal> - </goals> - <phase>process-sources</phase> - <configuration> - <!-- Use Google Java Style Guide: - https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml - with minor changes --> - <configLocation>onap-checkstyle/onap-java-style.xml</configLocation> - <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory --> - <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory> - <includeResources>true</includeResources> - <includeTestSourceDirectory>true</includeTestSourceDirectory> - <includeTestResources>true</includeTestResources> - <excludes> - </excludes> - <suppressionsLocation>${project.basedir}/checkstyle-suppressions.xml</suppressionsLocation> - <consoleOutput>true</consoleOutput> - <failsOnViolation>true</failsOnViolation> - <violationSeverity>warning</violationSeverity> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.onap.oparent</groupId> - <artifactId>checkstyle</artifactId> - <version>${oparent.version}</version> - <scope>compile</scope> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> -</project> diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/CompilerException.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/CompilerException.java deleted file mode 100644 index d2b8d2b8d..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/CompilerException.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017 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.controlloop.compiler; - -public class CompilerException extends Exception { - - private static final long serialVersionUID = -7262217239867898601L; - - public CompilerException() { - } - - public CompilerException(String message) { - super(message); - } - - public CompilerException(Throwable cause) { - super(cause); - } - - public CompilerException(String message, Throwable cause) { - super(message, cause); - } - - public CompilerException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java deleted file mode 100644 index b98cb0bb4..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java +++ /dev/null @@ -1,738 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.compiler; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -import java.io.InputStream; -import java.io.Serializable; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.jgrapht.DirectedGraph; -import org.jgrapht.graph.ClassBasedEdgeFactory; -import org.jgrapht.graph.DefaultEdge; -import org.jgrapht.graph.DirectedMultigraph; -import org.onap.policy.controlloop.policy.ControlLoop; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.controlloop.policy.FinalResult; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.controlloop.policy.PolicyResult; -import org.onap.policy.controlloop.policy.TargetType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.Constructor; - - -public class ControlLoopCompiler implements Serializable { - private static final String OPERATION_POLICY = "Operation Policy "; - private static final long serialVersionUID = 1L; - private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopCompiler.class.getName()); - - /** - * Compiles the policy from an object. - */ - public static ControlLoopPolicy compile(ControlLoopPolicy policy, - ControlLoopCompilerCallback callback) throws CompilerException { - // - // Ensure the control loop is sane - // - validateControlLoop(policy.getControlLoop(), callback); - // - // Validate the policies - // - validatePolicies(policy, callback); - - return policy; - } - - /** - * Compiles the policy from an input stream. - * - * @param yamlSpecification the yaml input stream - * @param callback method to callback during compilation - * @return Control Loop object - * @throws CompilerException throws any compile exception found - */ - public static ControlLoopPolicy compile(InputStream yamlSpecification, - ControlLoopCompilerCallback callback) throws CompilerException { - Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class)); - Object obj = yaml.load(yamlSpecification); - if (obj == null) { - throw new CompilerException("Could not parse yaml specification."); - } - if (! (obj instanceof ControlLoopPolicy)) { - throw new CompilerException("Yaml could not parse specification into required ControlLoopPolicy object"); - } - return ControlLoopCompiler.compile((ControlLoopPolicy) obj, callback); - } - - private static void validateControlLoop(ControlLoop controlLoop, - ControlLoopCompilerCallback callback) throws CompilerException { - if (controlLoop == null && callback != null) { - callback.onError("controlLoop cannot be null"); - } - if (controlLoop != null) { - if ((controlLoop.getControlLoopName() == null || controlLoop.getControlLoopName().length() < 1) - && callback != null) { - callback.onError("Missing controlLoopName"); - } - if ((!controlLoop.getVersion().contentEquals(ControlLoop.getCompilerVersion())) && callback != null) { - callback.onError("Unsupported version for this compiler"); - } - if (controlLoop.getTrigger_policy() == null || controlLoop.getTrigger_policy().length() < 1) { - throw new CompilerException("trigger_policy is not valid"); - } - } - } - - private static void validatePolicies(ControlLoopPolicy policy, - ControlLoopCompilerCallback callback) throws CompilerException { - if (policy == null) { - throw new CompilerException("policy cannot be null"); - } - if (policy.getPolicies() == null) { - callback.onWarning("controlLoop is an open loop."); - } else { - // - // For this version we can use a directed multigraph, in the future we may not be able to - // - DirectedGraph<NodeWrapper, LabeledEdge> graph = - new DirectedMultigraph<>(new ClassBasedEdgeFactory<NodeWrapper, - LabeledEdge>(LabeledEdge.class)); - // - // Check to see if the trigger Event is for OpenLoop, we do so by - // attempting to create a FinalResult object from it. If its a policy id, this should - // return null. - // - FinalResult triggerResult = FinalResult.toResult(policy.getControlLoop().getTrigger_policy()); - TriggerNodeWrapper triggerNode; - // - // Did this turn into a FinalResult object? - // - if (triggerResult != null) { - validateOpenLoopPolicy(policy, triggerResult, callback); - return; - // - } else { - validatePoliciesContainTriggerPolicyAndCombinedTimeoutIsOk(policy, callback); - triggerNode = new TriggerNodeWrapper(policy.getControlLoop().getControlLoopName()); - } - // - // Add in the trigger node - // - graph.addVertex(triggerNode); - // - // Add in our Final Result nodes. All paths should end to these nodes. - // - FinalResultNodeWrapper finalSuccess = new FinalResultNodeWrapper(FinalResult.FINAL_SUCCESS); - FinalResultNodeWrapper finalFailure = new FinalResultNodeWrapper(FinalResult.FINAL_FAILURE); - FinalResultNodeWrapper finalFailureTimeout = new FinalResultNodeWrapper(FinalResult.FINAL_FAILURE_TIMEOUT); - FinalResultNodeWrapper finalFailureRetries = new FinalResultNodeWrapper(FinalResult.FINAL_FAILURE_RETRIES); - FinalResultNodeWrapper finalFailureException = - new FinalResultNodeWrapper(FinalResult.FINAL_FAILURE_EXCEPTION); - FinalResultNodeWrapper finalFailureGuard = new FinalResultNodeWrapper(FinalResult.FINAL_FAILURE_GUARD); - graph.addVertex(finalSuccess); - graph.addVertex(finalFailure); - graph.addVertex(finalFailureTimeout); - graph.addVertex(finalFailureRetries); - graph.addVertex(finalFailureException); - graph.addVertex(finalFailureGuard); - // - // Work through the policies and add them in as nodes. - // - Map<Policy, PolicyNodeWrapper> mapNodes = addPoliciesAsNodes(policy, graph, triggerNode, callback); - // - // last sweep to connect remaining edges for policy results - // - for (Policy operPolicy : policy.getPolicies()) { - PolicyNodeWrapper node = mapNodes.get(operPolicy); - // - // Just ensure this has something - // - if (node == null) { - continue; - } - addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getSuccess(), finalSuccess, - PolicyResult.SUCCESS, node); - addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getFailure(), finalFailure, - PolicyResult.FAILURE, node); - addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getFailure_timeout(), finalFailureTimeout, - PolicyResult.FAILURE_TIMEOUT, node); - addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getFailure_retries(), finalFailureRetries, - PolicyResult.FAILURE_RETRIES, node); - addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getFailure_exception(), finalFailureException, - PolicyResult.FAILURE_EXCEPTION, node); - addEdge(graph, mapNodes, operPolicy.getId(), operPolicy.getFailure_guard(), finalFailureGuard, - PolicyResult.FAILURE_GUARD, node); - } - validateNodesAndEdges(graph, callback); - } - } - - private static void validateOpenLoopPolicy(ControlLoopPolicy policy, FinalResult triggerResult, - ControlLoopCompilerCallback callback) throws CompilerException { - // - // Ensure they didn't use some other FinalResult code - // - if (triggerResult != FinalResult.FINAL_OPENLOOP) { - throw new CompilerException("Unexpected Final Result for trigger_policy, should only be " - + FinalResult.FINAL_OPENLOOP.toString() + " or a valid Policy ID"); - } - // - // They really shouldn't have any policies attached. - // - if ((policy.getPolicies() != null || policy.getPolicies().isEmpty()) && callback != null ) { - callback.onWarning("Open Loop policy contains policies. The policies will never be invoked."); - } - } - - private static void validatePoliciesContainTriggerPolicyAndCombinedTimeoutIsOk(ControlLoopPolicy policy, - ControlLoopCompilerCallback callback) throws CompilerException { - int sum = 0; - boolean triggerPolicyFound = false; - for (Policy operPolicy : policy.getPolicies()) { - sum += operPolicy.getTimeout().intValue(); - if (policy.getControlLoop().getTrigger_policy().equals(operPolicy.getId())) { - triggerPolicyFound = true; - } - } - if (policy.getControlLoop().getTimeout().intValue() < sum && callback != null) { - callback.onError("controlLoop overall timeout is less than the sum of operational policy timeouts."); - } - - if (!triggerPolicyFound) { - throw new CompilerException("Unexpected value for trigger_policy, should only be " - + FinalResult.FINAL_OPENLOOP.toString() + " or a valid Policy ID"); - } - } - - private static Map<Policy, PolicyNodeWrapper> addPoliciesAsNodes(ControlLoopPolicy policy, - DirectedGraph<NodeWrapper, LabeledEdge> graph, TriggerNodeWrapper triggerNode, - ControlLoopCompilerCallback callback) { - Map<Policy, PolicyNodeWrapper> mapNodes = new HashMap<>(); - for (Policy operPolicy : policy.getPolicies()) { - // - // Is it still ok to add? - // - if (!okToAdd(operPolicy, callback)) { - // - // Do not add it in - // - continue; - } - // - // Create wrapper policy node and save it into our map so we can - // easily retrieve it. - // - PolicyNodeWrapper node = new PolicyNodeWrapper(operPolicy); - mapNodes.put(operPolicy, node); - graph.addVertex(node); - // - // Is this the trigger policy? - // - if (operPolicy.getId().equals(policy.getControlLoop().getTrigger_policy())) { - // - // Yes add an edge from our trigger event node to this policy - // - graph.addEdge(triggerNode, node, new LabeledEdge(triggerNode, node, new TriggerEdgeWrapper("ONSET"))); - } - } - return mapNodes; - } - - private static void addEdge(DirectedGraph<NodeWrapper, LabeledEdge> graph, Map<Policy, PolicyNodeWrapper> mapNodes, - String policyId, String connectedPolicy, - FinalResultNodeWrapper finalResultNodeWrapper, - PolicyResult policyResult, NodeWrapper node) throws CompilerException { - FinalResult finalResult = FinalResult.toResult(finalResultNodeWrapper.getId()); - if (FinalResult.isResult(connectedPolicy, finalResult)) { - graph.addEdge(node, finalResultNodeWrapper, new LabeledEdge(node, finalResultNodeWrapper, - new FinalResultEdgeWrapper(finalResult))); - } else { - PolicyNodeWrapper toNode = findPolicyNode(mapNodes, connectedPolicy); - if (toNode == null) { - throw new CompilerException(OPERATION_POLICY + policyId + " is connected to unknown policy " - + connectedPolicy); - } else { - graph.addEdge(node, toNode, new LabeledEdge(node, toNode, new PolicyResultEdgeWrapper(policyResult))); - } - } - } - - private static void validateNodesAndEdges(DirectedGraph<NodeWrapper, LabeledEdge> graph, - ControlLoopCompilerCallback callback) throws CompilerException { - for (NodeWrapper node : graph.vertexSet()) { - if (node instanceof TriggerNodeWrapper) { - validateTriggerNodeWrapper(graph, node); - } else if (node instanceof FinalResultNodeWrapper) { - validateFinalResultNodeWrapper(graph, node); - } else if (node instanceof PolicyNodeWrapper) { - validatePolicyNodeWrapper(graph, node, callback); - } - for (LabeledEdge edge : graph.outgoingEdgesOf(node)) { - LOGGER.info("{} invokes {} upon {}", edge.from.getId(), edge.to.getId(), edge.edge.getId()); - } - } - } - - private static void validateTriggerNodeWrapper(DirectedGraph<NodeWrapper, LabeledEdge> graph, - NodeWrapper node) throws CompilerException { - if (LOGGER.isDebugEnabled()) { - LOGGER.info("Trigger Node {}", node); - } - if (graph.inDegreeOf(node) > 0 ) { - // - // Really should NEVER get here unless someone messed up the code above. - // - throw new CompilerException("No inputs to event trigger"); - } - // - // Should always be 1, except in the future we may support multiple events - // - if (graph.outDegreeOf(node) > 1) { - throw new CompilerException("The event trigger should only go to ONE node"); - } - } - - private static void validateFinalResultNodeWrapper(DirectedGraph<NodeWrapper, LabeledEdge> graph, - NodeWrapper node) throws CompilerException { - if (LOGGER.isDebugEnabled()) { - LOGGER.info("FinalResult Node {}", node); - } - // - // FinalResult nodes should NEVER have an out edge - // - if (graph.outDegreeOf(node) > 0) { - throw new CompilerException("FinalResult nodes should never have any out edges."); - } - } - - private static void validatePolicyNodeWrapper(DirectedGraph<NodeWrapper, LabeledEdge> graph, - NodeWrapper node, ControlLoopCompilerCallback callback) throws CompilerException { - if (LOGGER.isDebugEnabled()) { - LOGGER.info("Policy Node {}", node); - } - // - // All Policy Nodes should have the 5 out degrees defined. - // - if (graph.outDegreeOf(node) != 6) { - throw new CompilerException("Policy node should ALWAYS have 6 out degrees."); - } - // - // All Policy Nodes should have at least 1 in degrees - // - if (graph.inDegreeOf(node) == 0 && callback != null) { - callback.onWarning("Policy " + node.getId() + " is not reachable."); - } - } - - private static boolean okToAdd(Policy operPolicy, ControlLoopCompilerCallback callback) { - boolean isOk = isPolicyIdOk(operPolicy, callback); - if (! isActorOk(operPolicy, callback)) { - isOk = false; - } - if (! isRecipeOk(operPolicy, callback)) { - isOk = false; - } - if (! isTargetOk(operPolicy, callback) ) { - isOk = false; - } - if (! arePolicyResultsOk(operPolicy, callback) ) { - isOk = false; - } - return isOk; - } - - private static boolean isPolicyIdOk(Policy operPolicy, ControlLoopCompilerCallback callback) { - boolean isOk = true; - if (operPolicy.getId() == null || operPolicy.getId().length() < 1) { - if (callback != null) { - callback.onError("Operational Policy has an bad ID"); - } - isOk = false; - } else { - // - // Check if they decided to make the ID a result object - // - if (PolicyResult.toResult(operPolicy.getId()) != null) { - if (callback != null) { - callback.onError("Policy id is set to a PolicyResult " + operPolicy.getId()); - } - isOk = false; - } - if (FinalResult.toResult(operPolicy.getId()) != null) { - if (callback != null) { - callback.onError("Policy id is set to a FinalResult " + operPolicy.getId()); - } - isOk = false; - } - } - return isOk; - } - - private static boolean isActorOk(Policy operPolicy, ControlLoopCompilerCallback callback) { - boolean isOk = true; - if (operPolicy.getActor() == null) { - if (callback != null) { - callback.onError("Policy actor is null"); - } - isOk = false; - } - // - // Construct a list for all valid actors - // - ImmutableList<String> actors = ImmutableList.of("APPC", "SDNC", "SDNR", "SO", "VFC"); - // - if (operPolicy.getActor() != null && (!actors.contains(operPolicy.getActor())) ) { - if (callback != null) { - callback.onError("Policy actor is invalid"); - } - isOk = false; - } - return isOk; - } - - private static boolean isRecipeOk(Policy operPolicy, ControlLoopCompilerCallback callback) { - boolean isOk = true; - if (operPolicy.getRecipe() == null) { - if (callback != null) { - callback.onError("Policy recipe is null"); - } - isOk = false; - } - // - // NOTE: We need a way to find the acceptable recipe values (either Enum or a database that has these) - // - ImmutableMap<String, List<String>> recipes = new ImmutableMap.Builder<String, List<String>>() - .put("APPC", ImmutableList.of("Restart", "Rebuild", "Migrate", "ModifyConfig")) - .put("SDNC", ImmutableList.of("Reroute")) - .put("SDNR", ImmutableList.of("ModifyConfig", "ModifyConfigANR")) - .put("SO", ImmutableList.of("VF Module Create", "VF Module Delete")) - .put("VFC", ImmutableList.of("Restart")) - .build(); - // - if (operPolicy.getRecipe() != null - && (!recipes.getOrDefault(operPolicy.getActor(), - Collections.emptyList()).contains(operPolicy.getRecipe()))) { - if (callback != null) { - callback.onError("Policy recipe is invalid"); - } - isOk = false; - } - return isOk; - } - - private static boolean isTargetOk(Policy operPolicy, ControlLoopCompilerCallback callback) { - boolean isOk = true; - if (operPolicy.getTarget() == null) { - if (callback != null) { - callback.onError("Policy target is null"); - } - isOk = false; - } - if (operPolicy.getTarget() != null - && operPolicy.getTarget().getType() != TargetType.VM - && operPolicy.getTarget().getType() != TargetType.VFC - && operPolicy.getTarget().getType() != TargetType.PNF) { - if (callback != null) { - callback.onError("Policy target is invalid"); - } - isOk = false; - } - return isOk; - } - - private static boolean arePolicyResultsOk(Policy operPolicy, ControlLoopCompilerCallback callback) { - // - // Check that policy results are connected to either default final * or another policy - // - boolean isOk = isSuccessPolicyResultOk(operPolicy, callback); - if (! isFailurePolicyResultOk(operPolicy, callback) ) { - isOk = false; - } - if (! isFailureRetriesPolicyResultOk(operPolicy, callback) ) { - isOk = false; - } - if (! isFailureTimeoutPolicyResultOk(operPolicy, callback) ) { - isOk = false; - } - if (! isFailureExceptionPolicyResultOk(operPolicy, callback) ) { - isOk = false; - } - if (! isFailureGuardPolicyResultOk(operPolicy, callback) ) { - isOk = false; - } - return isOk; - } - - private static boolean isSuccessPolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback) { - boolean isOk = true; - if (FinalResult.toResult(operPolicy.getSuccess()) != null - && !operPolicy.getSuccess().equals(FinalResult.FINAL_SUCCESS.toString())) { - if (callback != null) { - callback.onError("Policy success is neither another policy nor FINAL_SUCCESS"); - } - isOk = false; - } - return isOk; - } - - private static boolean isFailurePolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback) { - boolean isOk = true; - if (FinalResult.toResult(operPolicy.getFailure()) != null - && !operPolicy.getFailure().equals(FinalResult.FINAL_FAILURE.toString())) { - if (callback != null) { - callback.onError("Policy failure is neither another policy nor FINAL_FAILURE"); - } - isOk = false; - } - return isOk; - } - - private static boolean isFailureRetriesPolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback) { - boolean isOk = true; - if (FinalResult.toResult(operPolicy.getFailure_retries()) != null - && !operPolicy.getFailure_retries().equals(FinalResult.FINAL_FAILURE_RETRIES.toString())) { - if (callback != null) { - callback.onError("Policy failure retries is neither another policy nor FINAL_FAILURE_RETRIES"); - } - isOk = false; - } - return isOk; - } - - private static boolean isFailureTimeoutPolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback) { - boolean isOk = true; - if (FinalResult.toResult(operPolicy.getFailure_timeout()) != null - && !operPolicy.getFailure_timeout().equals(FinalResult.FINAL_FAILURE_TIMEOUT.toString())) { - if (callback != null) { - callback.onError("Policy failure timeout is neither another policy nor FINAL_FAILURE_TIMEOUT"); - } - isOk = false; - } - return isOk; - } - - private static boolean isFailureExceptionPolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback) { - boolean isOk = true; - if (FinalResult.toResult(operPolicy.getFailure_exception()) != null - && !operPolicy.getFailure_exception().equals(FinalResult.FINAL_FAILURE_EXCEPTION.toString())) { - if (callback != null) { - callback.onError("Policy failure exception is neither another policy nor FINAL_FAILURE_EXCEPTION"); - } - isOk = false; - } - return isOk; - } - - private static boolean isFailureGuardPolicyResultOk(Policy operPolicy, ControlLoopCompilerCallback callback) { - boolean isOk = true; - if (FinalResult.toResult(operPolicy.getFailure_guard()) != null - && !operPolicy.getFailure_guard().equals(FinalResult.FINAL_FAILURE_GUARD.toString())) { - if (callback != null) { - callback.onError("Policy failure guard is neither another policy nor FINAL_FAILURE_GUARD"); - } - isOk = false; - } - return isOk; - } - - private static PolicyNodeWrapper findPolicyNode(Map<Policy, PolicyNodeWrapper> mapNodes, String id) { - for (Entry<Policy, PolicyNodeWrapper> entry : mapNodes.entrySet()) { - if (entry.getKey().getId().equals(id)) { - return entry.getValue(); - } - } - return null; - } - - @FunctionalInterface - private interface NodeWrapper extends Serializable { - public String getId(); - } - - private static class TriggerNodeWrapper implements NodeWrapper { - private static final long serialVersionUID = -187644087811478349L; - private String closedLoopControlName; - - public TriggerNodeWrapper(String closedLoopControlName) { - this.closedLoopControlName = closedLoopControlName; - } - - @Override - public String toString() { - return "TriggerNodeWrapper [closedLoopControlName=" + closedLoopControlName + "]"; - } - - @Override - public String getId() { - return closedLoopControlName; - } - - } - - private static class FinalResultNodeWrapper implements NodeWrapper { - private static final long serialVersionUID = 8540008796302474613L; - private FinalResult result; - - public FinalResultNodeWrapper(FinalResult result) { - this.result = result; - } - - @Override - public String toString() { - return "FinalResultNodeWrapper [result=" + result + "]"; - } - - @Override - public String getId() { - return result.toString(); - } - } - - private static class PolicyNodeWrapper implements NodeWrapper { - private static final long serialVersionUID = 8170162175653823082L; - private transient Policy policy; - - public PolicyNodeWrapper(Policy operPolicy) { - this.policy = operPolicy; - } - - @Override - public String toString() { - return "PolicyNodeWrapper [policy=" + policy + "]"; - } - - @Override - public String getId() { - return policy.getId(); - } - } - - @FunctionalInterface - private interface EdgeWrapper extends Serializable { - public String getId(); - - } - - private static class TriggerEdgeWrapper implements EdgeWrapper { - private static final long serialVersionUID = 2678151552623278863L; - private String trigger; - - public TriggerEdgeWrapper(String trigger) { - this.trigger = trigger; - } - - @Override - public String getId() { - return trigger; - } - - @Override - public String toString() { - return "TriggerEdgeWrapper [trigger=" + trigger + "]"; - } - - } - - private static class PolicyResultEdgeWrapper implements EdgeWrapper { - private static final long serialVersionUID = 6078569477021558310L; - private PolicyResult policyResult; - - public PolicyResultEdgeWrapper(PolicyResult policyResult) { - super(); - this.policyResult = policyResult; - } - - @Override - public String toString() { - return "PolicyResultEdgeWrapper [policyResult=" + policyResult + "]"; - } - - @Override - public String getId() { - return policyResult.toString(); - } - - - } - - private static class FinalResultEdgeWrapper implements EdgeWrapper { - private static final long serialVersionUID = -1486381946896779840L; - private FinalResult finalResult; - - public FinalResultEdgeWrapper(FinalResult result) { - this.finalResult = result; - } - - @Override - public String toString() { - return "FinalResultEdgeWrapper [finalResult=" + finalResult + "]"; - } - - @Override - public String getId() { - return finalResult.toString(); - } - } - - - private static class LabeledEdge extends DefaultEdge { - private static final long serialVersionUID = 579384429573385524L; - - private NodeWrapper from; - private NodeWrapper to; - private EdgeWrapper edge; - - public LabeledEdge(NodeWrapper from, NodeWrapper to, EdgeWrapper edge) { - this.from = from; - this.to = to; - this.edge = edge; - } - - @SuppressWarnings("unused") - public NodeWrapper from() { - return from; - } - - @SuppressWarnings("unused") - public NodeWrapper to() { - return to; - } - - @SuppressWarnings("unused") - public EdgeWrapper edge() { - return edge; - } - - @Override - public String toString() { - return "LabeledEdge [from=" + from + ", to=" + to + ", edge=" + edge + "]"; - } - } - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerCallback.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerCallback.java deleted file mode 100644 index bdbc68167..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerCallback.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.compiler; - -public interface ControlLoopCompilerCallback { - - public boolean onWarning(String message); - - public boolean onError(String message); - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java deleted file mode 100644 index 4cee39cb4..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/guard/compiler/ControlLoopGuardCompiler.java +++ /dev/null @@ -1,157 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.guard.compiler; - -import java.io.InputStream; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.onap.policy.controlloop.compiler.CompilerException; -import org.onap.policy.controlloop.compiler.ControlLoopCompilerCallback; -import org.onap.policy.controlloop.policy.guard.Constraint; -import org.onap.policy.controlloop.policy.guard.ControlLoopGuard; -import org.onap.policy.controlloop.policy.guard.GuardPolicy; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.Constructor; - -public class ControlLoopGuardCompiler { - - private static final String GUARD_POLICIES_SHOULD_NOT_BE_NULL = "Guard policies should not be null"; - private static final String GUARD_POLICY = "Guard policy "; - - private ControlLoopGuardCompiler(){ - // Private Constructor - } - - /** - * Compile the control loop guard. - * - * @param clGuard the guard - * @param callback callback routine - * @return the guard object - * @throws CompilerException compilation exception - */ - public static ControlLoopGuard compile(ControlLoopGuard clGuard, - ControlLoopCompilerCallback callback) throws CompilerException { - // - // Ensure ControlLoopGuard has at least one guard policies - // - validateControlLoopGuard(clGuard, callback); - // - // Ensure each guard policy has at least one constraints and all guard policies are unique - // - validateGuardPolicies(clGuard.getGuards(), callback); - // - // Ensure constraints for each guard policy are unique - // - validateConstraints(clGuard.getGuards(), callback); - - return clGuard; - } - - /** - * Compile the control loop guard. - * - * @param yamlSpecification yaml specification as a stream - * @param callback callback method - * @return guard object - * @throws CompilerException throws compile exception - */ - public static ControlLoopGuard compile(InputStream yamlSpecification, - ControlLoopCompilerCallback callback) throws CompilerException { - Yaml yaml = new Yaml(new Constructor(ControlLoopGuard.class)); - Object obj = yaml.load(yamlSpecification); - if (obj == null) { - throw new CompilerException("Could not parse yaml specification."); - } - if (! (obj instanceof ControlLoopGuard)) { - throw new CompilerException("Yaml could not parse specification into required ControlLoopGuard object"); - } - return ControlLoopGuardCompiler.compile((ControlLoopGuard) obj, callback); - } - - private static void validateControlLoopGuard(ControlLoopGuard clGuard, - ControlLoopCompilerCallback callback) throws CompilerException { - if (clGuard == null) { - if (callback != null) { - callback.onError("ControlLoop Guard cannot be null"); - } - throw new CompilerException("ControlLoop Guard cannot be null"); - } - if (clGuard.getGuard() == null && callback != null) { - callback.onError("Guard version cannot be null"); - } - if (clGuard.getGuards() == null) { - if (callback != null) { - callback.onError("ControlLoop Guard should have at least one guard policies"); - } - } else if (clGuard.getGuards().isEmpty() && callback != null) { - callback.onError("ControlLoop Guard should have at least one guard policies"); - } - } - - private static void validateGuardPolicies(List<GuardPolicy> policies, - ControlLoopCompilerCallback callback) throws CompilerException { - if (policies == null) { - if (callback != null) { - callback.onError(GUARD_POLICIES_SHOULD_NOT_BE_NULL); - } - throw new CompilerException(GUARD_POLICIES_SHOULD_NOT_BE_NULL); - } - // - // Ensure all guard policies are unique - // - Set<GuardPolicy> newSet = new HashSet<>(policies); - if (newSet.size() != policies.size() && callback != null) { - callback.onWarning("There are duplicate guard policies"); - } - // - // Ensure each guard policy has at least one constraints - // - for (GuardPolicy policy : policies) { - if (policy.getLimit_constraints() == null || policy.getLimit_constraints().isEmpty()) { - if (callback != null) { - callback.onError(GUARD_POLICY + policy.getName() + " does not have any limit constraint"); - } - throw new CompilerException(GUARD_POLICY + policy.getName() + " does not have any limit constraint"); - } - } - } - - private static void validateConstraints(List<GuardPolicy> policies, - ControlLoopCompilerCallback callback) throws CompilerException { - if (policies == null) { - if (callback != null) { - callback.onError(GUARD_POLICIES_SHOULD_NOT_BE_NULL); - } - throw new CompilerException(GUARD_POLICIES_SHOULD_NOT_BE_NULL); - } - for (GuardPolicy policy : policies) { - Set<Constraint> newSet = new HashSet<>(policy.getLimit_constraints()); - if (newSet.size() != policy.getLimit_constraints().size() && callback != null) { - callback.onWarning(GUARD_POLICY + policy.getName() + " has duplicate limit constraints"); - } - } - } - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java deleted file mode 100644 index b924c2d14..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoop.java +++ /dev/null @@ -1,187 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy; - -import java.io.Serializable; -import java.util.LinkedList; -import java.util.List; - -import org.onap.policy.aai.Pnf; -import org.onap.policy.sdc.Resource; -import org.onap.policy.sdc.Service; - -public class ControlLoop implements Serializable { - private static final long serialVersionUID = 1L; - - private static final String COMPILER_VERSION = "2.0.0"; - - private String controlLoopName; - private String version = COMPILER_VERSION; - private List<Service> services; - private List<Resource> resources; - private Pnf pnf; - private String triggerPolicy = FinalResult.FINAL_OPENLOOP.toString(); - private Integer timeout; - private Boolean abatement = false; - - public ControlLoop() { - // Empty Constructor. - } - - /** - * Constructor. - * - * @param controlLoop copy object - */ - public ControlLoop(ControlLoop controlLoop) { - this.controlLoopName = controlLoop.controlLoopName; - this.services = new LinkedList<>(); - if (controlLoop.services != null) { - for (Service service : controlLoop.services) { - this.services.add(service); - } - } - this.resources = new LinkedList<>(); - if (controlLoop.resources != null) { - for (Resource resource : controlLoop.resources) { - this.resources.add(resource); - } - } - this.triggerPolicy = controlLoop.triggerPolicy; - this.timeout = controlLoop.timeout; - this.abatement = controlLoop.abatement; - } - - public static String getCompilerVersion() { - return ControlLoop.COMPILER_VERSION; - } - - public String getControlLoopName() { - return controlLoopName; - } - - public void setControlLoopName(String controlLoopName) { - this.controlLoopName = controlLoopName; - } - - public List<Service> getServices() { - return services; - } - - public void setServices(List<Service> services) { - this.services = services; - } - - public List<Resource> getResources() { - return resources; - } - - public void setResources(List<Resource> resources) { - this.resources = resources; - } - - public String getTrigger_policy() { - return triggerPolicy; - } - - public void setTrigger_policy(String triggerPolicy) { - this.triggerPolicy = triggerPolicy; - } - - public Integer getTimeout() { - return timeout; - } - - public void setTimeout(Integer timeout) { - this.timeout = timeout; - } - - public Boolean getAbatement() { - return abatement; - } - - public void setAbatement(Boolean abatement) { - this.abatement = abatement; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public Pnf getPnf() { - return pnf; - } - - public void setPnf(Pnf pnf) { - this.pnf = pnf; - } - - @Override - public String toString() { - return "ControlLoop [controlLoopName=" + controlLoopName + ", version=" + version + ", services=" + services - + ", resources=" + resources + ", trigger_policy=" + triggerPolicy + ", timeout=" + timeout - + ", abatement=" + abatement + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((controlLoopName == null) ? 0 : controlLoopName.hashCode()); - result = prime * result + ((resources == null) ? 0 : resources.hashCode()); - result = prime * result + ((services == null) ? 0 : services.hashCode()); - result = prime * result + ((timeout == null) ? 0 : timeout.hashCode()); - result = prime * result + ((triggerPolicy == null) ? 0 : triggerPolicy.hashCode()); - result = prime * result + ((version == null) ? 0 : version.hashCode()); - result = prime * result + ((abatement == null) ? 0 : abatement.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ControlLoop other = (ControlLoop) obj; - return equalsMayBeNull(controlLoopName, other.controlLoopName) && equalsMayBeNull(resources, other.resources) - && equalsMayBeNull(services, other.services) && equalsMayBeNull(timeout, other.timeout) - && equalsMayBeNull(triggerPolicy, other.triggerPolicy) && equalsMayBeNull(version, other.version) - && equalsMayBeNull(abatement, other.abatement); - } - - private boolean equalsMayBeNull(final Object obj1, final Object obj2) { - if (obj1 == null) { - return obj2 == null; - } - return obj1.equals(obj2); - } - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoopPolicy.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoopPolicy.java deleted file mode 100644 index bbc7747e4..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/ControlLoopPolicy.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy; - -import java.io.Serializable; -import java.util.List; - -public class ControlLoopPolicy implements Serializable { - private static final long serialVersionUID = 1L; - - private ControlLoop controlLoop; - - private List<Policy> policies; - - public ControlLoop getControlLoop() { - return controlLoop; - } - - public void setControlLoop(ControlLoop controlLoop) { - this.controlLoop = controlLoop; - } - - public List<Policy> getPolicies() { - return policies; - } - - public void setPolicies(List<Policy> policies) { - this.policies = policies; - } - - @Override - public String toString() { - return "ControlLoopPolicy [controlLoop=" + controlLoop + ", policies=" + policies + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((controlLoop == null) ? 0 : controlLoop.hashCode()); - result = prime * result + ((policies == null) ? 0 : policies.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ControlLoopPolicy other = (ControlLoopPolicy) obj; - if (controlLoop == null) { - if (other.controlLoop != null) { - return false; - } - } else if (!controlLoop.equals(other.controlLoop)) { - return false; - } - if (policies == null) { - if (other.policies != null) { - return false; - } - } else if (!policies.equals(other.policies)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/FinalResult.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/FinalResult.java deleted file mode 100644 index 473b102e7..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/FinalResult.java +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy; - -public enum FinalResult { - /** - * The Control Loop Policy successfully completed its Operations. - */ - FINAL_SUCCESS("Final_Success"), - /** - * The Control Loop Policy was an Open Loop and is finished. - */ - FINAL_OPENLOOP("Final_OpenLoop"), - /** - * The Control Loop Policy failed in its last Operation Policy. - * NOTE: Previous Operation Policies may have been successful. - */ - FINAL_FAILURE("Final_Failure"), - /** - * The Control Loop Policy failed because the overall timeout was met. - */ - FINAL_FAILURE_TIMEOUT("Final_Failure_Timeout"), - /** - * The Control Loop Policy failed because an Operation Policy met its retry limit. - */ - FINAL_FAILURE_RETRIES("Final_Failure_Retries"), - /** - * The Control Loop Policy failed due to an exception. - */ - FINAL_FAILURE_EXCEPTION("Final_Failure_Exception"), - /** - * The Control Loop Policy failed due to guard denied. - */ - FINAL_FAILURE_GUARD("Final_Failure_Guard") - ; - - String result; - - private FinalResult(String result) { - this.result = result; - } - - /** - * Converts to a result object. - * - * @param result input string - * @return result object - */ - public static FinalResult toResult(String result) { - if (result.equalsIgnoreCase(FINAL_SUCCESS.toString())) { - return FINAL_SUCCESS; - } - if (result.equalsIgnoreCase(FINAL_OPENLOOP.toString())) { - return FINAL_OPENLOOP; - } - if (result.equalsIgnoreCase(FINAL_FAILURE.toString())) { - return FINAL_FAILURE; - } - if (result.equalsIgnoreCase(FINAL_FAILURE_TIMEOUT.toString())) { - return FINAL_FAILURE_TIMEOUT; - } - if (result.equalsIgnoreCase(FINAL_FAILURE_RETRIES.toString())) { - return FINAL_FAILURE_RETRIES; - } - if (result.equalsIgnoreCase(FINAL_FAILURE_EXCEPTION.toString())) { - return FINAL_FAILURE_EXCEPTION; - } - if (result.equalsIgnoreCase(FINAL_FAILURE_GUARD.toString())) { - return FINAL_FAILURE_GUARD; - } - return null; - } - - /** - * Check if the result really is a result. - * - * @param result string - * @param finalResult result object - * @return true if a result - */ - public static boolean isResult(String result, FinalResult finalResult) { - FinalResult toResult = FinalResult.toResult(result); - if (toResult == null) { - return false; - } - return toResult.equals(finalResult); - } - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/OperationsAccumulateParams.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/OperationsAccumulateParams.java deleted file mode 100644 index 594c42023..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/OperationsAccumulateParams.java +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy; - -import java.io.Serializable; - -public class OperationsAccumulateParams implements Serializable { - - private static final long serialVersionUID = -3597358159130168247L; - - private String period; - private Integer limit; - - public OperationsAccumulateParams() { - // Does Nothing - } - - public OperationsAccumulateParams(OperationsAccumulateParams ops) { - this.period = ops.period; - this.limit = ops.limit; - } - - public OperationsAccumulateParams(String period, Integer limit) { - this.period = period; - this.limit = limit; - } - - public String getPeriod() { - return period; - } - - public void setPeriod(String period) { - this.period = period; - } - - public Integer getLimit() { - return limit; - } - - public void setLimit(Integer limit) { - this.limit = limit; - } - - @Override - public String toString() { - return "OperationsAccumulateParams [period=" + period + ", limit=" + limit + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((period == null) ? 0 : period.hashCode()); - result = prime * result + ((limit == null) ? 0 : limit.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - OperationsAccumulateParams other = (OperationsAccumulateParams) obj; - if (period == null) { - if (other.period != null) { - return false; - } - } else if (!period.equals(other.period)) { - return false; - } - if (limit == null) { - if (other.limit != null) { - return false; - } - } else if (!limit.equals(other.limit)) { - return false; - } - return true; - } - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Policy.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Policy.java deleted file mode 100644 index b7cb78711..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Policy.java +++ /dev/null @@ -1,336 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy; - -import java.io.Serializable; -import java.util.Collections; -import java.util.Map; -import java.util.UUID; - -public class Policy implements Serializable { - private static final long serialVersionUID = 1L; - - private String id = UUID.randomUUID().toString(); - private String name; - private String description; - private String actor; - private String recipe; - private Map<String, String> payload; - private Target target; - private OperationsAccumulateParams operationsAccumulateParams; - private Integer retry = 0; - private Integer timeout = 300; - private String success = FinalResult.FINAL_SUCCESS.toString(); - private String failure = FinalResult.FINAL_FAILURE.toString(); - private String failureRetries = FinalResult.FINAL_FAILURE_RETRIES.toString(); - private String failureTimeout = FinalResult.FINAL_FAILURE_TIMEOUT.toString(); - private String failureException = FinalResult.FINAL_FAILURE_EXCEPTION.toString(); - private String failureGuard = FinalResult.FINAL_FAILURE_GUARD.toString(); - - - public Policy() { - //Does Nothing Empty Constructor - } - - public Policy(String id) { - this.id = id; - } - - /** - * Constructor. - * - * @param name name - * @param actor actor - * @param recipe recipe - * @param payload payload - * @param target target - */ - public Policy(String name, String actor, String recipe, Map<String, String> payload, Target target) { - this.name = name; - this.actor = actor; - this.recipe = recipe; - this.target = target; - if (payload != null) { - this.payload = Collections.unmodifiableMap(payload); - } - } - - /** - * Constructor. - * - * @param name name - * @param actor actor - * @param recipe recipe - * @param payload payload - * @param target target - * @param retries retries - * @param timeout timeout - */ - public Policy(String name, String actor, String recipe, Map<String, String> payload, Target target, - Integer retries, Integer timeout) { - this(name, actor, recipe, payload, target); - this.retry = retries; - this.timeout = timeout; - } - - /** - * Constructor. - * - * @param policyParam provide parameter object - */ - public Policy(PolicyParam policyParam) { - this(policyParam.getName(), policyParam.getActor(), policyParam.getRecipe(), policyParam.getPayload(), - policyParam.getTarget(), policyParam.getRetries(), policyParam.getTimeout()); - this.id = policyParam.getId(); - this.description = policyParam.getDescription(); - } - - /** - * Constructor. - * - * @param policy copy object - */ - public Policy(Policy policy) { - this.id = policy.id; - this.name = policy.name; - this.description = policy.description; - this.actor = policy.actor; - this.recipe = policy.recipe; - if (policy.payload != null) { - this.payload = Collections.unmodifiableMap(policy.payload); - } - this.target = policy.target; - this.operationsAccumulateParams = policy.operationsAccumulateParams; - this.retry = policy.retry; - this.timeout = policy.timeout; - this.success = policy.success; - this.failure = policy.failure; - this.failureException = policy.failureException; - this.failureGuard = policy.failureGuard; - this.failureRetries = policy.failureRetries; - this.failureTimeout = policy.failureTimeout; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getActor() { - return actor; - } - - public void setActor(String actor) { - this.actor = actor; - } - - public String getRecipe() { - return recipe; - } - - public void setRecipe(String recipe) { - this.recipe = recipe; - } - - public Map<String, String> getPayload() { - return payload; - } - - public void setPayload(Map<String, String> payload) { - this.payload = payload; - } - - public Target getTarget() { - return target; - } - - public void setTarget(Target target) { - this.target = target; - } - - public OperationsAccumulateParams getOperationsAccumulateParams() { - return operationsAccumulateParams; - } - - public void setOperationsAccumulateParams(OperationsAccumulateParams operationsAccumulateParams) { - this.operationsAccumulateParams = operationsAccumulateParams; - } - - public Integer getRetry() { - return retry; - } - - public void setRetry(Integer retry) { - this.retry = retry; - } - - public Integer getTimeout() { - return timeout; - } - - public void setTimeout(Integer timeout) { - this.timeout = timeout; - } - - public String getSuccess() { - return success; - } - - public void setSuccess(String success) { - this.success = success; - } - - public String getFailure() { - return failure; - } - - public void setFailure(String failure) { - this.failure = failure; - } - - public String getFailure_retries() { - return failureRetries; - } - - public void setFailure_retries(String failureRetries) { - this.failureRetries = failureRetries; - } - - public String getFailure_timeout() { - return failureTimeout; - } - - public void setFailure_timeout(String failureTimeout) { - this.failureTimeout = failureTimeout; - } - - public String getFailure_exception() { - return failureException; - } - - public void setFailure_exception(String failureException) { - this.failureException = failureException; - } - - public String getFailure_guard() { - return failureGuard; - } - - public void setFailure_guard(String failureGuard) { - this.failureGuard = failureGuard; - } - - public boolean isValid() { - return id != null && name != null && actor != null && recipe != null && target != null; - } - - @Override - public String toString() { - return "Policy [id=" + id + ", name=" + name + ", description=" + description + ", actor=" + actor + ", recipe=" - + recipe + ", payload=" + payload + ", target=" + target + ", operationsAccumulateParams=" - + operationsAccumulateParams + ", retry=" + retry + ", timeout=" + timeout - + ", success=" + success + ", failure=" + failure + ", failure_retries=" + failureRetries - + ", failure_timeout=" + failureTimeout + ", failure_exception=" + failureException - + ", failure_guard=" + failureGuard + "]"; - } - - @Override - public int hashCode() { - int result = 1; - result = addHashCodeForField(result, actor); - result = addHashCodeForField(result, description); - result = addHashCodeForField(result, failure); - result = addHashCodeForField(result, failureException); - result = addHashCodeForField(result, failureGuard); - result = addHashCodeForField(result, failureRetries); - result = addHashCodeForField(result, failureTimeout); - result = addHashCodeForField(result, id); - result = addHashCodeForField(result, name); - result = addHashCodeForField(result, payload); - result = addHashCodeForField(result, recipe); - result = addHashCodeForField(result, retry); - result = addHashCodeForField(result, success); - result = addHashCodeForField(result, target); - result = addHashCodeForField(result, operationsAccumulateParams); - result = addHashCodeForField(result, timeout); - return result; - } - - private int addHashCodeForField(int hashCode, Object field) { - final int prime = 31; - return prime * hashCode + ((field == null) ? 0 : field.hashCode()); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Policy other = (Policy) obj; - return equalsMayBeNull(actor, other.actor) - && equalsMayBeNull(description, other.description) - && equalsMayBeNull(failure, other.failure) - && equalsMayBeNull(failureException, other.failureException) - && equalsMayBeNull(failureGuard, other.failureGuard) - && equalsMayBeNull(failureRetries, other.failureRetries) - && equalsMayBeNull(id, other.id) - && equalsMayBeNull(name, other.name) - && equalsMayBeNull(payload, other.payload) - && equalsMayBeNull(recipe, other.recipe) - && equalsMayBeNull(retry, other.retry) - && equalsMayBeNull(success, other.success) - && equalsMayBeNull(operationsAccumulateParams, other.operationsAccumulateParams) - && equalsMayBeNull(target, other.target) - && equalsMayBeNull(timeout, other.timeout); - } - - private boolean equalsMayBeNull(final Object obj1, final Object obj2) { - if ( obj1 == null ) { - return obj2 == null; - } - return obj1.equals(obj2); - } -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/PolicyParam.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/PolicyParam.java deleted file mode 100644 index 8891a3f5b..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/PolicyParam.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * policy-endpoints - * ================================================================================ - * Copyright (C) 2018 Samsung Electronics Co., Ltd. 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.controlloop.policy; - -import java.util.Map; - -public class PolicyParam { - private String id; - private String name; - private String description; - private String actor; - private Map<String, String> payload; - private Target target; - private String recipe; - private Integer retries; - private Integer timeout; - - public static PolicyParamBuilder builder() { - return new PolicyParamBuilder(); - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public String getActor() { - return actor; - } - - public Map<String, String> getPayload() { - return payload; - } - - public Target getTarget() { - return target; - } - - public String getRecipe() { - return recipe; - } - - public Integer getRetries() { - return retries; - } - - public Integer getTimeout() { - return timeout; - } - - public static class PolicyParamBuilder { - - PolicyParam policyParm = new PolicyParam(); - - private PolicyParamBuilder() { - } - - public PolicyParam build() { - return policyParm; - } - - public PolicyParamBuilder id(String id) { - policyParm.id = id; - return this; - } - - public PolicyParamBuilder name(String name) { - policyParm.name = name; - return this; - } - - public PolicyParamBuilder description(String description) { - policyParm.description = description; - return this; - } - - public PolicyParamBuilder actor(String actor) { - policyParm.actor = actor; - return this; - } - - public PolicyParamBuilder payload(Map<String, String> payload) { - policyParm.payload = payload; - return this; - } - - public PolicyParamBuilder target(Target target) { - policyParm.target = target; - return this; - } - - public PolicyParamBuilder recipe(String recipe) { - policyParm.recipe = recipe; - return this; - } - - public PolicyParamBuilder retries(Integer retries) { - policyParm.retries = retries; - return this; - } - - public PolicyParamBuilder timeout(Integer timeout) { - policyParm.timeout = timeout; - return this; - } - } -}
\ No newline at end of file diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/PolicyResult.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/PolicyResult.java deleted file mode 100644 index d9e1557d4..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/PolicyResult.java +++ /dev/null @@ -1,89 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy; - -public enum PolicyResult { - /** - * Operation was successful. - */ - SUCCESS("Success"), - /** - * Operation failed. - */ - FAILURE("Failure"), - /** - * Operation failed due to maximum retries being met. - */ - FAILURE_RETRIES("Failure_Retries"), - /** - * Operation failed due to timeout occurring. - */ - FAILURE_TIMEOUT("Failure_Timeout"), - /** - * Operation failed due to an exception. - */ - FAILURE_EXCEPTION("Failure_Exception"), - /** - * Operation failed since Guard did not permit. - */ - FAILURE_GUARD("Failure_Guard") - ; - - private String result; - - private PolicyResult(String result) { - this.result = result; - } - - @Override - public String toString() { - return this.result; - } - - /** - * Convert to a result. - * - * @param result result string - * @return Result object - */ - public static PolicyResult toResult(String result) { - if (result.equalsIgnoreCase(SUCCESS.toString())) { - return SUCCESS; - } - if (result.equalsIgnoreCase(FAILURE.toString())) { - return FAILURE; - } - if (result.equalsIgnoreCase(FAILURE_RETRIES.toString())) { - return FAILURE_RETRIES; - } - if (result.equalsIgnoreCase(FAILURE_TIMEOUT.toString())) { - return FAILURE_TIMEOUT; - } - if (result.equalsIgnoreCase(FAILURE_EXCEPTION.toString())) { - return FAILURE_EXCEPTION; - } - if (result.equalsIgnoreCase(FAILURE_GUARD.toString())) { - return FAILURE_GUARD; - } - return null; - } - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Target.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Target.java deleted file mode 100644 index eab6967f1..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/Target.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy; - -import java.io.Serializable; - -public class Target implements Serializable { - - private static final long serialVersionUID = 2180988443264988319L; - - private String resourceId; - private TargetType type; - - public Target() { - //Does Nothing Empty Constructor - } - - public Target(TargetType type) { - this.type = type; - } - - public Target(String resourceId) { - this.resourceId = resourceId; - } - - public Target(TargetType type, String resourceId) { - this.type = type; - this.resourceId = resourceId; - } - - public Target(Target target) { - this.type = target.type; - this.resourceId = target.resourceId; - } - - public String getResourceID() { - return resourceId; - } - - public void setResourceID(String resourceId) { - this.resourceId = resourceId; - } - - public TargetType getType() { - return type; - } - - public void setType(TargetType type) { - this.type = type; - } - - @Override - public String toString() { - return "Target [type=" + type + ", resourceId=" + resourceId + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + ((resourceId == null) ? 0 : resourceId.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Target other = (Target) obj; - if (type == null) { - if (other.type != null) { - return false; - } - } else if (!type.equals(other.type)) { - return false; - } - if (resourceId == null) { - if (other.resourceId != null) { - return false; - } - } else if (!resourceId.equals(other.resourceId)) { - return false; - } - return true; - } -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/TargetType.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/TargetType.java deleted file mode 100644 index 7c8ca89cf..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/TargetType.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017 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.controlloop.policy; - -public enum TargetType { - VM("VM"), - PNF("PNF"), - VFC("VFC"), - VNF("VNF") - ; - - private String target; - - private TargetType(String targetType) { - this.target = targetType; - } - - @Override - public String toString() { - return this.target; - } - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/BuilderException.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/BuilderException.java deleted file mode 100644 index 4038f3b74..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/BuilderException.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.builder; - -public class BuilderException extends Exception { - - private static final long serialVersionUID = 610064813684337895L; - - public BuilderException(String string) { - super(string); - } - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java deleted file mode 100644 index 533e19b72..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java +++ /dev/null @@ -1,314 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.builder; - -import org.onap.policy.aai.Pnf; -import org.onap.policy.controlloop.policy.ControlLoop; -import org.onap.policy.controlloop.policy.OperationsAccumulateParams; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.controlloop.policy.PolicyParam; -import org.onap.policy.controlloop.policy.PolicyResult; -import org.onap.policy.controlloop.policy.builder.impl.ControlLoopPolicyBuilderImpl; -import org.onap.policy.sdc.Resource; -import org.onap.policy.sdc.Service; - -public interface ControlLoopPolicyBuilder { - - /** - * Adds one or more services to the ControlLoop. - * - * @param services service to add - * @return builder object - * @throws BuilderException builder exception - */ - public ControlLoopPolicyBuilder addService(Service... services) throws BuilderException; - - /** - * Remove service. - * - * @param services to remove - * @return builder object - * @throws BuilderException builder exception - */ - public ControlLoopPolicyBuilder removeService(Service... services) throws BuilderException; - - /** - * Remove all the services. - * - * @return builder object - * @throws BuilderException builder exception - */ - public ControlLoopPolicyBuilder removeAllServices() throws BuilderException; - - /** - * Adds one or more resources to the ControlLoop. - * - * @return builder object - * @throws BuilderException builder exception - */ - public ControlLoopPolicyBuilder addResource(Resource... resources) throws BuilderException; - - /** - * Remove the resources. - * - * @param resources resources to be removed - * @return object - * @throws BuilderException builder exception - */ - public ControlLoopPolicyBuilder removeResource(Resource... resources) throws BuilderException; - - /** - * Remove all resources. - * - * @return object - * @throws BuilderException builder exception - */ - public ControlLoopPolicyBuilder removeAllResources() throws BuilderException; - - /** - * Set the PNF. - * - * @param pnf input pnf - * @return builder object - * @throws BuilderException builder exception - */ - public ControlLoopPolicyBuilder setPNF(Pnf pnf) throws BuilderException; - - /** - * Remove PNF. - * - * @return the object - * @throws BuilderException builder exception - */ - public ControlLoopPolicyBuilder removePNF() throws BuilderException; - - /** - * Set the abatement. - * - * @param abatement whether abatement is possible - * @return object - * @throws BuilderException builder exception - */ - public ControlLoopPolicyBuilder setAbatement(Boolean abatement) throws BuilderException; - - - /** - * Sets the overall timeout value for the Control Loop. If any operational policies have retries - * and timeouts, then this overall timeout value should exceed all those values. - * - * @param timeout timeout value - * @return control loop policy builder - * @throws BuilderException builder exception - */ - public ControlLoopPolicyBuilder setTimeout(Integer timeout) throws BuilderException; - - /** - * Scans the operational policies and calculate an minimum overall timeout for the Control Loop. - * - * - * @return Integer - */ - public Integer calculateTimeout(); - - /** - * Sets the initial trigger policy when a DCAE Closed Loop Event arrives in the ONAP Policy - * Platform. - * - * - * @param policy Policy parameters object - * @return Policy object - * @throws BuilderException builder exception - */ - public Policy setTriggerPolicy(PolicyParam policy) throws BuilderException; - - /** - * Changes the trigger policy to point to another existing Policy. - * - * @param id the id - * @return ControlLoop object - * @throws BuilderException build exception - */ - public ControlLoop setExistingTriggerPolicy(String id) throws BuilderException; - - /** - * Is an open loop. - * - * @return true or false - */ - public boolean isOpenLoop(); - - /** - * Get the trigger policy. - * - * @return the policy object - * @throws BuilderException if there is a builder exception - */ - public Policy getTriggerPolicy() throws BuilderException; - - /** - * Simply returns a copy of the ControlLoop information. - * - * - * @return ControlLoop - */ - public ControlLoop getControlLoop(); - - /** - * Creates a policy that is chained to the result of another Policy. - * - * @param policyParam policy parameters object - * @param results results - * @return Policy that was set - * @throws BuilderException builder exception - */ - public Policy setPolicyForPolicyResult(PolicyParam policyParam, PolicyResult... results) - throws BuilderException; - - - /** - * Sets the policy result(s) to an existing Operational Policy. - * - * @param policyResultId result ID - * @param policyId id - * @param results results - * @return Policy that was set - * @throws BuilderException builder exception - */ - public Policy setPolicyForPolicyResult(String policyResultId, String policyId, PolicyResult... results) - throws BuilderException; - - /** - * Removes an Operational Policy. Be mindful that if any other Operational Policies have results - * that point to this policy, any policies that have results pointing to this policy will have - * their result reset to the appropriate default FINAL_* result. - * - * - * @param policyID id for the policy - * @return true if removed else false - * @throws BuilderException builder exception - */ - public boolean removePolicy(String policyID) throws BuilderException; - - /** - * Resets a policy's results to defualt FINAL_* codes. - * - * @return Policy object - * @throws BuilderException - Policy does not exist - */ - public Policy resetPolicyResults(String policyID) throws BuilderException; - - /** - * Removes all existing Operational Policies and reverts back to an Open Loop. - * - * @return Policy builder object - */ - public ControlLoopPolicyBuilder removeAllPolicies(); - - /** - * Adds an operationsAccumulateParams to an existing operational policy. - * - * @return Policy - * @throws BuilderException - Policy does not exist - */ - public Policy addOperationsAccumulateParams(String policyID, OperationsAccumulateParams operationsAccumulateParams) - throws BuilderException; - - /** - * This will compile and build the YAML specification for the Control Loop Policy. Please - * iterate the Results object for details. The Results object will contains warnings and errors. - * If the specification compiled successfully, you will be able to retrieve the YAML. - * - * @return Results - */ - public Results buildSpecification(); - - /** - * The Factory is used to build a ControlLoopPolicyBuilder implementation. - * - * @author pameladragosh - * - */ - public static class Factory { - private Factory() { - // Private Constructor. - } - - /** - * Builds a basic Control Loop with an overall timeout. Use this method if you wish to - * create an OpenLoop, or if you want to interactively build a Closed Loop. - * - * @param controlLoopName - Per Closed Loop AID v1.0, unique string for the closed loop. - * @param timeout - Overall timeout for the Closed Loop to execute. - * @return ControlLoopPolicyBuilder object - */ - public static ControlLoopPolicyBuilder buildControlLoop(String controlLoopName, Integer timeout) { - return new ControlLoopPolicyBuilderImpl(controlLoopName, timeout); - } - - /** - * Build a Control Loop for a resource and services associated with the resource. - * - * @param controlLoopName - Per Closed Loop AID v1.0, unique string for the closed loop. - * @param timeout - Overall timeout for the Closed Loop to execute. - * @param resource - Resource this closed loop is for. Should come from ASDC, but if not - * available use resourceName to distinguish. - * @param services - Zero or more services associated with this resource. Should come from - * ASDC, but if not available use serviceName to distinguish. - * @return ControlLoopPolicyBuilder object - * @throws BuilderException builder exception - */ - public static ControlLoopPolicyBuilder buildControlLoop(String controlLoopName, Integer timeout, - Resource resource, Service... services) throws BuilderException { - return new ControlLoopPolicyBuilderImpl(controlLoopName, timeout, resource, services); - } - - /** - * Build the control loop. - * - * @param controlLoopName control loop id - * @param timeout timeout - * @param service service - * @param resources resources - * @return builder object - * @throws BuilderException builder exception - */ - public static ControlLoopPolicyBuilder buildControlLoop(String controlLoopName, Integer timeout, - Service service, Resource... resources) throws BuilderException { - return new ControlLoopPolicyBuilderImpl(controlLoopName, timeout, service, resources); - } - - /** - * Build control loop. - * - * @param controlLoopName - Per Closed Loop AID v1.0, unique string for the closed loop. - * @param timeout - Overall timeout for the Closed Loop to execute. - * @param pnf - Physical Network Function. Should come from AIC, but if not available use - * well-known name to distinguish. Eg. eNodeB - * @return ControlLoopPolicyBuilder object - * @throws BuilderException builder exception - */ - public static ControlLoopPolicyBuilder buildControlLoop(String controlLoopName, Integer timeout, Pnf pnf) - throws BuilderException { - return new ControlLoopPolicyBuilderImpl(controlLoopName, timeout, pnf); - } - } - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Message.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Message.java deleted file mode 100644 index 3a71c6d26..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Message.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.builder; - -public interface Message { - - public String getMessage(); - - public MessageLevel getLevel(); - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/MessageLevel.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/MessageLevel.java deleted file mode 100644 index bfe6fc080..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/MessageLevel.java +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.builder; - -public enum MessageLevel { - INFO, - WARNING, - ERROR, - EXCEPTION; -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Results.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Results.java deleted file mode 100644 index 9ad89c7cf..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/Results.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.builder; - -import java.util.List; - -public interface Results { - - public List<Message> getMessages(); - - public String getSpecification(); - - public boolean isValid(); - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java deleted file mode 100644 index efc0f11d4..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java +++ /dev/null @@ -1,543 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.builder.impl; - -import com.google.common.base.Strings; -import java.util.LinkedList; -import java.util.UUID; - -import org.onap.policy.aai.Pnf; -import org.onap.policy.controlloop.compiler.CompilerException; -import org.onap.policy.controlloop.compiler.ControlLoopCompiler; -import org.onap.policy.controlloop.compiler.ControlLoopCompilerCallback; -import org.onap.policy.controlloop.policy.ControlLoop; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.controlloop.policy.FinalResult; -import org.onap.policy.controlloop.policy.OperationsAccumulateParams; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.controlloop.policy.PolicyParam; -import org.onap.policy.controlloop.policy.PolicyResult; -import org.onap.policy.controlloop.policy.builder.BuilderException; -import org.onap.policy.controlloop.policy.builder.ControlLoopPolicyBuilder; -import org.onap.policy.controlloop.policy.builder.MessageLevel; -import org.onap.policy.controlloop.policy.builder.Results; -import org.onap.policy.sdc.Resource; -import org.onap.policy.sdc.Service; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.yaml.snakeyaml.DumperOptions; -import org.yaml.snakeyaml.DumperOptions.FlowStyle; -import org.yaml.snakeyaml.Yaml; - -public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { - private static final String UNKNOWN_POLICY = "Unknown policy "; - private static Logger logger = LoggerFactory.getLogger(ControlLoopPolicyBuilderImpl.class.getName()); - private ControlLoopPolicy controlLoopPolicy; - - /** - * Constructor. - * - * @param controlLoopName control loop id - * @param timeout timeout value - */ - public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout) { - controlLoopPolicy = new ControlLoopPolicy(); - ControlLoop controlLoop = new ControlLoop(); - controlLoop.setControlLoopName(controlLoopName); - controlLoop.setTimeout(timeout); - controlLoopPolicy.setControlLoop(controlLoop); - } - - /** - * Constructor. - * - * @param controlLoopName control loop id - * @param timeout timeout value - * @param resource resource - * @param services services - * @throws BuilderException builder exception - */ - public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout, Resource resource, Service... services) - throws BuilderException { - this(controlLoopName, timeout); - this.addResource(resource); - this.addService(services); - } - - public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout, Pnf pnf) throws BuilderException { - this(controlLoopName, timeout); - this.setPNF(pnf); - } - - /** - * Constructor. - * - * @param controlLoopName control loop id - * @param timeout timeout - * @param service service - * @param resources resources - * @throws BuilderException builder exception - */ - public ControlLoopPolicyBuilderImpl(String controlLoopName, Integer timeout, Service service, Resource[] resources) - throws BuilderException { - this(controlLoopName, timeout); - this.addService(service); - this.addResource(resources); - } - - @Override - public ControlLoopPolicyBuilder removePNF() throws BuilderException { - controlLoopPolicy.getControlLoop().setPnf(null); - return this; - } - - @Override - public ControlLoopPolicyBuilder addService(Service... services) throws BuilderException { - for (Service service : services) { - if (service == null) { - throw new BuilderException("Service must not be null"); - } - if (service.getServiceUUID() == null && Strings.isNullOrEmpty(service.getServiceName())) { - throw new BuilderException("Invalid service - need either a serviceUUID or serviceName"); - } - if (controlLoopPolicy.getControlLoop().getServices() == null) { - controlLoopPolicy.getControlLoop().setServices(new LinkedList<>()); - } - controlLoopPolicy.getControlLoop().getServices().add(service); - } - return this; - } - - @Override - public ControlLoopPolicyBuilder removeService(Service... services) throws BuilderException { - if (controlLoopPolicy.getControlLoop().getServices() == null) { - throw new BuilderException("No existing services to remove"); - } - for (Service service : services) { - if (service == null) { - throw new BuilderException("Service must not be null"); - } - if (service.getServiceUUID() == null && Strings.isNullOrEmpty(service.getServiceName())) { - throw new BuilderException("Invalid service - need either a serviceUUID or serviceName"); - } - boolean removed = controlLoopPolicy.getControlLoop().getServices().remove(service); - if (!removed) { - throw new BuilderException("Unknown service " + service.getServiceName()); - } - } - return this; - } - - @Override - public ControlLoopPolicyBuilder removeAllServices() throws BuilderException { - controlLoopPolicy.getControlLoop().getServices().clear(); - return this; - } - - - @Override - public ControlLoopPolicyBuilder addResource(Resource... resources) throws BuilderException { - for (Resource resource : resources) { - if (resource == null) { - throw new BuilderException("Resource must not be null"); - } - if (resource.getResourceUuid() == null && Strings.isNullOrEmpty(resource.getResourceName())) { - throw new BuilderException("Invalid resource - need either resourceUUID or resourceName"); - } - if (controlLoopPolicy.getControlLoop().getResources() == null) { - controlLoopPolicy.getControlLoop().setResources(new LinkedList<>()); - } - controlLoopPolicy.getControlLoop().getResources().add(resource); - } - return this; - } - - @Override - public ControlLoopPolicyBuilder setPNF(Pnf pnf) throws BuilderException { - if (pnf == null) { - throw new BuilderException("PNF must not be null"); - } - if (pnf.getPnfName() == null && pnf.getPnfType() == null) { - throw new BuilderException("Invalid PNF - need either pnfName or pnfType"); - } - controlLoopPolicy.getControlLoop().setPnf(pnf); - return this; - } - - @Override - public ControlLoopPolicyBuilder setAbatement(Boolean abatement) throws BuilderException { - if (abatement == null) { - throw new BuilderException("abatement must not be null"); - } - controlLoopPolicy.getControlLoop().setAbatement(abatement); - return this; - } - - @Override - public ControlLoopPolicyBuilder setTimeout(Integer timeout) { - controlLoopPolicy.getControlLoop().setTimeout(timeout); - return this; - } - - @Override - public Policy setTriggerPolicy(PolicyParam policyParam) - throws BuilderException { - - Policy trigger = new Policy(policyParam); - - controlLoopPolicy.getControlLoop().setTrigger_policy(trigger.getId()); - - this.addNewPolicy(trigger); - // - // Return a copy of the policy - // - return new Policy(trigger); - } - - @Override - public ControlLoop setExistingTriggerPolicy(String id) throws BuilderException { - if (id == null) { - throw new BuilderException("Id must not be null"); - } - Policy trigger = this.findPolicy(id); - if (trigger == null) { - throw new BuilderException(UNKNOWN_POLICY + id); - } else { - this.controlLoopPolicy.getControlLoop().setTrigger_policy(id); - } - return new ControlLoop(this.controlLoopPolicy.getControlLoop()); - } - - @Override - public Policy setPolicyForPolicyResult(PolicyParam policyParam, PolicyResult... results) - throws BuilderException { - // - // Find the existing policy - // - Policy existingPolicy = this.findPolicy(policyParam.getId()); - if (existingPolicy == null) { - throw new BuilderException(UNKNOWN_POLICY + policyParam.getId()); - } - // - // Create the new Policy - // - Policy newPolicy = new Policy( - PolicyParam.builder().id(UUID.randomUUID().toString()) - .name(policyParam.getName()) - .description(policyParam.getDescription()) - .actor(policyParam.getActor()) - .payload(policyParam.getPayload()) - .target(policyParam.getTarget()) - .recipe(policyParam.getRecipe()) - .retries(policyParam.getRetries()) - .timeout(policyParam.getTimeout()) - .build()); - // - // Connect the results - // - for (PolicyResult result : results) { - switch (result) { - case FAILURE: - existingPolicy.setFailure(newPolicy.getId()); - break; - case FAILURE_EXCEPTION: - existingPolicy.setFailure_exception(newPolicy.getId()); - break; - case FAILURE_RETRIES: - existingPolicy.setFailure_retries(newPolicy.getId()); - break; - case FAILURE_TIMEOUT: - existingPolicy.setFailure_timeout(newPolicy.getId()); - break; - case FAILURE_GUARD: - existingPolicy.setFailure_guard(newPolicy.getId()); - break; - case SUCCESS: - existingPolicy.setSuccess(newPolicy.getId()); - break; - default: - throw new BuilderException("Invalid PolicyResult " + result); - } - } - // - // Add it to our list - // - this.controlLoopPolicy.getPolicies().add(newPolicy); - // - // Return a policy to them - // - return new Policy(newPolicy); - } - - @Override - public Policy setPolicyForPolicyResult(String policyResultId, String policyId, PolicyResult... results) - throws BuilderException { - // - // Find the existing policy - // - Policy existingPolicy = this.findPolicy(policyId); - if (existingPolicy == null) { - throw new BuilderException(policyId + " does not exist"); - } - if (this.findPolicy(policyResultId) == null) { - throw new BuilderException("Operational policy " + policyResultId + " does not exist"); - } - // - // Connect the results - // - for (PolicyResult result : results) { - switch (result) { - case FAILURE: - existingPolicy.setFailure(policyResultId); - break; - case FAILURE_EXCEPTION: - existingPolicy.setFailure_exception(policyResultId); - break; - case FAILURE_RETRIES: - existingPolicy.setFailure_retries(policyResultId); - break; - case FAILURE_TIMEOUT: - existingPolicy.setFailure_timeout(policyResultId); - break; - case FAILURE_GUARD: - existingPolicy.setFailure_guard(policyResultId); - break; - case SUCCESS: - existingPolicy.setSuccess(policyResultId); - break; - default: - throw new BuilderException("Invalid PolicyResult " + result); - } - } - return new Policy(this.findPolicy(policyResultId)); - } - - private class BuilderCompilerCallback implements ControlLoopCompilerCallback { - - private ResultsImpl results = new ResultsImpl(); - - @Override - public boolean onWarning(String message) { - results.addMessage(new MessageImpl(message, MessageLevel.WARNING)); - return false; - } - - @Override - public boolean onError(String message) { - results.addMessage(new MessageImpl(message, MessageLevel.ERROR)); - return false; - } - } - - @Override - public Results buildSpecification() { - // - // Dump the specification - // - DumperOptions options = new DumperOptions(); - options.setDefaultFlowStyle(FlowStyle.BLOCK); - options.setPrettyFlow(true); - Yaml yaml = new Yaml(options); - String dumpedYaml = yaml.dump(controlLoopPolicy); - // - // This is our callback class for our compiler - // - BuilderCompilerCallback callback = new BuilderCompilerCallback(); - // - // Compile it - // - try { - ControlLoopCompiler.compile(controlLoopPolicy, callback); - } catch (CompilerException e) { - logger.error(e.getMessage() + e); - callback.results.addMessage(new MessageImpl(e.getMessage(), MessageLevel.EXCEPTION)); - } - // - // Save the spec - // - callback.results.setSpecification(dumpedYaml); - return callback.results; - } - - private void addNewPolicy(Policy policy) { - if (this.controlLoopPolicy.getPolicies() == null) { - this.controlLoopPolicy.setPolicies(new LinkedList<>()); - } - this.controlLoopPolicy.getPolicies().add(policy); - } - - private Policy findPolicy(String id) { - if (this.controlLoopPolicy.getPolicies() != null) { - for (Policy policy : this.controlLoopPolicy.getPolicies()) { - if (policy.getId().equals(id)) { - return policy; - } - } - } - return null; - } - - @Override - public ControlLoopPolicyBuilder removeResource(Resource... resources) throws BuilderException { - if (controlLoopPolicy.getControlLoop().getResources() == null) { - throw new BuilderException("No existing resources to remove"); - } - for (Resource resource : resources) { - if (resource == null) { - throw new BuilderException("Resource must not be null"); - } - if (resource.getResourceUuid() == null && Strings.isNullOrEmpty(resource.getResourceName())) { - throw new BuilderException("Invalid resource - need either a resourceUUID or resourceName"); - } - boolean removed = controlLoopPolicy.getControlLoop().getResources().remove(resource); - if (!removed) { - throw new BuilderException("Unknown resource " + resource.getResourceName()); - } - } - return this; - } - - @Override - public ControlLoopPolicyBuilder removeAllResources() throws BuilderException { - controlLoopPolicy.getControlLoop().getResources().clear(); - return this; - } - - @Override - public Integer calculateTimeout() { - int sum = 0; - for (Policy policy : this.controlLoopPolicy.getPolicies()) { - sum += policy.getTimeout().intValue(); - } - return Integer.valueOf(sum); - } - - @Override - public boolean isOpenLoop() { - return this.controlLoopPolicy.getControlLoop().getTrigger_policy() - .equals(FinalResult.FINAL_OPENLOOP.toString()); - } - - @Override - public Policy getTriggerPolicy() throws BuilderException { - if (this.controlLoopPolicy.getControlLoop().getTrigger_policy().equals(FinalResult.FINAL_OPENLOOP.toString())) { - return null; - } else { - return new Policy(this.findPolicy(this.controlLoopPolicy.getControlLoop().getTrigger_policy())); - } - } - - @Override - public ControlLoop getControlLoop() { - return new ControlLoop(this.controlLoopPolicy.getControlLoop()); - } - - @Override - public boolean removePolicy(String policyId) throws BuilderException { - Policy existingPolicy = this.findPolicy(policyId); - if (existingPolicy == null) { - throw new BuilderException(UNKNOWN_POLICY + policyId); - } - // - // Check if the policy to remove is trigger_policy - // - if (this.controlLoopPolicy.getControlLoop().getTrigger_policy().equals(policyId)) { - this.controlLoopPolicy.getControlLoop().setTrigger_policy(FinalResult.FINAL_OPENLOOP.toString()); - } else { - updateChainedPoliciesForPolicyRemoval(policyId); - } - // - // remove the policy - // - return this.controlLoopPolicy.getPolicies().remove(existingPolicy); - } - - private void updateChainedPoliciesForPolicyRemoval(String idOfPolicyBeingRemoved) { - for (Policy policy : this.controlLoopPolicy.getPolicies()) { - final int index = this.controlLoopPolicy.getPolicies().indexOf(policy); - if (policy.getSuccess().equals(idOfPolicyBeingRemoved)) { - policy.setSuccess(FinalResult.FINAL_SUCCESS.toString()); - } - if (policy.getFailure().equals(idOfPolicyBeingRemoved)) { - policy.setFailure(FinalResult.FINAL_FAILURE.toString()); - } - if (policy.getFailure_retries().equals(idOfPolicyBeingRemoved)) { - policy.setFailure_retries(FinalResult.FINAL_FAILURE_RETRIES.toString()); - } - if (policy.getFailure_timeout().equals(idOfPolicyBeingRemoved)) { - policy.setFailure_timeout(FinalResult.FINAL_FAILURE_TIMEOUT.toString()); - } - if (policy.getFailure_exception().equals(idOfPolicyBeingRemoved)) { - policy.setFailure_exception(FinalResult.FINAL_FAILURE_EXCEPTION.toString()); - } - if (policy.getFailure_guard().equals(idOfPolicyBeingRemoved)) { - policy.setFailure_guard(FinalResult.FINAL_FAILURE_GUARD.toString()); - } - this.controlLoopPolicy.getPolicies().set(index, policy); - } - } - - @Override - public Policy resetPolicyResults(String policyId) throws BuilderException { - Policy existingPolicy = this.findPolicy(policyId); - if (existingPolicy == null) { - throw new BuilderException(UNKNOWN_POLICY + policyId); - } - // - // reset policy results - // - existingPolicy.setSuccess(FinalResult.FINAL_SUCCESS.toString()); - existingPolicy.setFailure(FinalResult.FINAL_FAILURE.toString()); - existingPolicy.setFailure_retries(FinalResult.FINAL_FAILURE_RETRIES.toString()); - existingPolicy.setFailure_timeout(FinalResult.FINAL_FAILURE_TIMEOUT.toString()); - existingPolicy.setFailure_exception(FinalResult.FINAL_FAILURE_EXCEPTION.toString()); - existingPolicy.setFailure_guard(FinalResult.FINAL_FAILURE_GUARD.toString()); - return new Policy(existingPolicy); - } - - @Override - public ControlLoopPolicyBuilder removeAllPolicies() { - // - // Remove all existing operational policies - // - this.controlLoopPolicy.getPolicies().clear(); - // - // Revert controlLoop back to an open loop - // - this.controlLoopPolicy.getControlLoop().setTrigger_policy(FinalResult.FINAL_OPENLOOP.toString()); - return this; - } - - @Override - public Policy addOperationsAccumulateParams(String policyId, OperationsAccumulateParams operationsAccumulateParams) - throws BuilderException { - Policy existingPolicy = this.findPolicy(policyId); - if (existingPolicy == null) { - throw new BuilderException(UNKNOWN_POLICY + policyId); - } - // - // Add operationsAccumulateParams to existingPolicy - // - existingPolicy.setOperationsAccumulateParams(operationsAccumulateParams); - return new Policy(existingPolicy); - } - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/MessageImpl.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/MessageImpl.java deleted file mode 100644 index 22244e09b..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/MessageImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.builder.impl; - -import org.onap.policy.controlloop.policy.builder.Message; -import org.onap.policy.controlloop.policy.builder.MessageLevel; - -public class MessageImpl implements Message { - - private String message; - private MessageLevel level; - - public MessageImpl(String message, MessageLevel level) { - this.message = message; - this.level = level; - } - - @Override - public String getMessage() { - return message; - } - - @Override - public MessageLevel getLevel() { - return level; - } - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ResultsImpl.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ResultsImpl.java deleted file mode 100644 index f9a9a474f..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ResultsImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.builder.impl; - -import java.util.LinkedList; -import java.util.List; - -import org.onap.policy.controlloop.policy.builder.Message; -import org.onap.policy.controlloop.policy.builder.Results; - -public class ResultsImpl implements Results { - - private String specification; - private List<Message> messages = new LinkedList<>(); - - @Override - public List<Message> getMessages() { - return messages; - } - - @Override - public String getSpecification() { - return specification; - } - - @Override - public boolean isValid() { - return (this.specification != null); - } - - public void addMessage(Message message) { - this.messages.add(message); - } - - public void setSpecification(String spec) { - this.specification = spec; - } -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Constraint.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Constraint.java deleted file mode 100644 index 9332bfbe4..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Constraint.java +++ /dev/null @@ -1,255 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.guard; - -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -public class Constraint { - - private Integer freqLimitPerTarget; - private Map<String,String> timeWindow; - private Map<String, String> activeTimeRange; - private Integer minVnfCount; - private Integer maxVnfCount; - - private List<String> blacklist; - - public Constraint() { - // Do Nothing empty constructor. - } - - /** - * Constructor. - * - * @param freqLimitPerTarget frequency limit - * @param timeWindow time window - */ - public Constraint(Integer freqLimitPerTarget, Map<String, String> timeWindow) { - this.freqLimitPerTarget = freqLimitPerTarget; - if (timeWindow != null) { - this.timeWindow = Collections.unmodifiableMap(timeWindow); - } - } - - /** - * Constructor. - * - * @param minVnfCount minimum VNF count - * @param maxVnfCount maximum VNF count - * @param activeTimeRange active time range - */ - public Constraint(Integer minVnfCount, Integer maxVnfCount, Map<String, String> activeTimeRange) { - this.minVnfCount = minVnfCount; - this.maxVnfCount = maxVnfCount; - - if (activeTimeRange != null) { - this.activeTimeRange = Collections.unmodifiableMap(activeTimeRange); - } - } - - public Constraint(List<String> blacklist) { - this.blacklist = new LinkedList<>(blacklist); - } - - /** - * Constructor. - * - * @param freqLimitPerTarget frequency limit - * @param timeWindow time window - * @param blacklist blacklist - */ - public Constraint(Integer freqLimitPerTarget, Map<String, String> timeWindow, List<String> blacklist) { - this.freqLimitPerTarget = freqLimitPerTarget; - this.timeWindow = Collections.unmodifiableMap(timeWindow); - this.blacklist = new LinkedList<>(blacklist); - } - - /** - * Constructor. - * - * @param freqLimitPerTarget frequency limit - * @param timeWindow time window - * @param activeTimeRange active time range - */ - public Constraint(Integer freqLimitPerTarget, Map<String, String> timeWindow, Map<String, String> activeTimeRange) { - this(freqLimitPerTarget, timeWindow); - if (activeTimeRange != null) { - this.activeTimeRange = Collections.unmodifiableMap(activeTimeRange); - } - } - - /** - * Constructor. - * - * @param freqLimitPerTarget frequency limit - * @param timeWindow the time window - * @param activeTimeRange active time range - * @param blacklist incoming blacklist - */ - public Constraint(Integer freqLimitPerTarget, Map<String, String> timeWindow, Map<String, String> activeTimeRange, - List<String> blacklist) { - this(freqLimitPerTarget, timeWindow); - if (activeTimeRange != null) { - this.activeTimeRange = Collections.unmodifiableMap(activeTimeRange); - } - if (blacklist != null) { - this.blacklist = new LinkedList<>(blacklist); - } - } - - /** - * Constructor. - * - * @param constraint objec to copy - */ - public Constraint(Constraint constraint) { - this.freqLimitPerTarget = constraint.freqLimitPerTarget; - this.timeWindow = constraint.timeWindow; - if (constraint.activeTimeRange != null) { - this.activeTimeRange = Collections.unmodifiableMap(constraint.activeTimeRange); - } - this.blacklist = new LinkedList<>(constraint.blacklist); - } - - public Integer getFreq_limit_per_target() { - return freqLimitPerTarget; - } - - - public void setFreq_limit_per_target(Integer freqLimitPerTarget) { - this.freqLimitPerTarget = freqLimitPerTarget; - } - - - public Map<String, String> getTime_window() { - return timeWindow; - } - - - public void setTime_window(Map<String, String> timeWindow) { - this.timeWindow = timeWindow; - } - - - public Map<String, String> getActive_time_range() { - return activeTimeRange; - } - - - public void setActive_time_range(Map<String, String> activeTimeRange) { - this.activeTimeRange = activeTimeRange; - } - - - public List<String> getBlacklist() { - return blacklist; - } - - - public void setBlacklist(List<String> blacklist) { - this.blacklist = blacklist; - } - - - public Integer getMinVnfCount() { - return minVnfCount; - } - - - public void setMinVnfCount(Integer minVnfCount) { - this.minVnfCount = minVnfCount; - } - - - public Integer getMaxVnfCount() { - return maxVnfCount; - } - - - public void setMaxVnfCount(Integer maxVnfCount) { - this.maxVnfCount = maxVnfCount; - } - - /** - * Check if these constraint values are valid. - * - * @return true if valid - */ - public boolean isValid() { - // - // Sonar likes these statements combined as well as not use - // boolean literals. - // - // If the freqLimitPerTarget is null AND the timeWindow is NOT null - // OR - // timeWindow is null AND the freqLimitPerTarget is NOT null - // - // then we want to return false (hence the preceding !) - // - return ! ((freqLimitPerTarget == null && timeWindow != null) - || (timeWindow == null && freqLimitPerTarget != null)); - } - - @Override - public String toString() { - return "Constraint [freq_limit_per_target=" + freqLimitPerTarget + ", time_window=" - + timeWindow + ", active_time_range=" + activeTimeRange + ", blacklist=" + blacklist + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((freqLimitPerTarget == null) ? 0 : freqLimitPerTarget.hashCode()); - result = prime * result + ((timeWindow == null) ? 0 : timeWindow.hashCode()); - result = prime * result + ((activeTimeRange == null) ? 0 : activeTimeRange.hashCode()); - result = prime * result + ((blacklist == null) ? 0 : blacklist.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Constraint other = (Constraint) obj; - return equalsMayBeNull(freqLimitPerTarget, other.freqLimitPerTarget) - && equalsMayBeNull(timeWindow, other.timeWindow) - && equalsMayBeNull(activeTimeRange, other.activeTimeRange) - && equalsMayBeNull(blacklist, other.blacklist); - } - - private boolean equalsMayBeNull(final Object obj1, final Object obj2) { - if (obj1 == null) { - return obj2 == null; - } - return obj1.equals(obj2); - } -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuard.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuard.java deleted file mode 100644 index cad32c273..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuard.java +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.guard; - -import java.util.LinkedList; - -public class ControlLoopGuard { - - private Guard guard; - - private LinkedList<GuardPolicy> guards; - - public ControlLoopGuard() { - //DO Nothing Empty Constructor - } - - public ControlLoopGuard(ControlLoopGuard clGuard) { - this.guard = new Guard(); - this.guards = new LinkedList<>(clGuard.guards); - } - - public Guard getGuard() { - return guard; - } - - public void setGuard(Guard guard) { - this.guard = guard; - } - - public LinkedList<GuardPolicy> getGuards() { - return guards; - } - - public void setGuards(LinkedList<GuardPolicy> guards) { - this.guards = guards; - } - - @Override - public String toString() { - return "Guard [guard=" + guard + ", GuardPolicies=" + guards + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((guard == null) ? 0 : guard.hashCode()); - result = prime * result + ((guards == null) ? 0 : guards.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ControlLoopGuard other = (ControlLoopGuard) obj; - if (guard == null) { - if (other.guard != null) { - return false; - } - } else if (!guard.equals(other.guard)) { - return false; - } - if (guards == null) { - if (other.guards != null) { - return false; - } - } else if (!guards.equals(other.guards)) { - return false; - } - return true; - } - - -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Guard.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Guard.java deleted file mode 100644 index dcce13597..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/Guard.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.guard; - -public class Guard { - - private static final String DEFAULTVERSION = "2.0.0"; - - private String version = DEFAULTVERSION; - - public Guard() { - //DO Nothing empty Constructor. - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - @Override - public String toString() { - return "Guard [version=" + version + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((version == null) ? 0 : version.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - Guard other = (Guard) obj; - if (version == null) { - if (other.version != null) { - return false; - } - } else if (!version.equals(other.version)) { - return false; - } - return true; - } -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/GuardPolicy.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/GuardPolicy.java deleted file mode 100644 index b76c4578e..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/GuardPolicy.java +++ /dev/null @@ -1,190 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.guard; - -import java.util.LinkedList; -import java.util.List; -import java.util.UUID; - -public class GuardPolicy { - - private String id = UUID.randomUUID().toString(); - private String name; - private String description; - private MatchParameters matchParameters; - private LinkedList<Constraint> limitConstraints; - - public GuardPolicy() { - //Do Nothing Empty Constructor. - } - - public GuardPolicy(String id) { - this.id = id; - } - - public GuardPolicy(String name, MatchParameters matchParameters) { - this.name = name; - this.matchParameters = matchParameters; - } - - /** - * Constructor. - * - * @param id id - * @param name name - * @param description description - * @param matchParameters match parameters - */ - public GuardPolicy(String id, String name, String description, MatchParameters matchParameters) { - this(name, matchParameters); - this.id = id; - this.description = description; - } - - /** - * Constructor. - * - * @param name name - * @param matchParameters match parameters - * @param limitConstraints limit constraints - */ - public GuardPolicy(String name, MatchParameters matchParameters, List<Constraint> limitConstraints) { - this(name, matchParameters); - if (limitConstraints != null) { - this.limitConstraints = (LinkedList<Constraint>) limitConstraints; - } - } - - public GuardPolicy(String name, String description, MatchParameters matchParameters, - List<Constraint> limitConstraints) { - this(name, matchParameters, limitConstraints); - this.description = description; - } - - public GuardPolicy(String id, String name, String description, MatchParameters matchParameters, - List<Constraint> limitConstraints) { - this(name, description, matchParameters, limitConstraints); - this.id = id; - } - - /** - * Constructor. - * - * @param policy copy object - */ - public GuardPolicy(GuardPolicy policy) { - this.id = policy.id; - this.name = policy.name; - this.description = policy.description; - this.matchParameters = new MatchParameters(policy.matchParameters); - if (policy.limitConstraints != null) { - this.limitConstraints = policy.limitConstraints; - } - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public MatchParameters getMatch_parameters() { - return matchParameters; - } - - public void setMatch_parameters(MatchParameters matchParameters) { - this.matchParameters = matchParameters; - } - - public LinkedList<Constraint> getLimit_constraints() { - return limitConstraints; - } - - public void setLimit_constraints(LinkedList<Constraint> limitConstraints) { - this.limitConstraints = limitConstraints; - } - - public boolean isValid() { - return (id == null || name == null) ? false : true; - } - - @Override - public String toString() { - return "Policy [id=" + id + ", name=" + name + ", description=" + description + ", match_parameters=" - + matchParameters + ", limitConstraints=" + limitConstraints + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((limitConstraints == null) ? 0 : limitConstraints.hashCode()); - result = prime * result + ((matchParameters == null) ? 0 : matchParameters.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - GuardPolicy other = (GuardPolicy) obj; - return equalsMayBeNull(description, other.description) - && equalsMayBeNull(id, other.id) - && equalsMayBeNull(name, other.name) - && equalsMayBeNull(limitConstraints, other.limitConstraints) - && equalsMayBeNull(matchParameters, other.matchParameters); - } - - private boolean equalsMayBeNull(final Object obj1, final Object obj2) { - if ( obj1 == null ) { - return obj2 == null; - } - return obj1.equals(obj2); - } -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/MatchParameters.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/MatchParameters.java deleted file mode 100644 index 0b1380972..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/MatchParameters.java +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.guard; - -import java.util.LinkedList; -import java.util.List; - - -public class MatchParameters { - private String controlLoopName; - private String actor; - private String recipe; - private List<String> targets; - - public MatchParameters() { - // Do Nothing Empty Constructor. - } - - public MatchParameters(String actor, String recipe) { - this.actor = actor; - this.recipe = recipe; - } - - /** - * Constructor. - * - * @param actor actor - * @param recipe recipe - * @param targets targets - */ - public MatchParameters(String actor, String recipe, List<String> targets) { - this(actor, recipe); - if (targets != null) { - this.targets = new LinkedList<>(targets); - } - } - - public MatchParameters(String controlLoopName, String actor, String recipe, List<String> targets) { - this(actor, recipe, targets); - this.controlLoopName = controlLoopName; - } - - /** - * Constructor. - * - * @param matchParameters match parameters - */ - public MatchParameters(MatchParameters matchParameters) { - - this.controlLoopName = matchParameters.controlLoopName; - this.actor = matchParameters.actor; - this.recipe = matchParameters.recipe; - if (matchParameters.targets != null) { - this.targets = new LinkedList<>(matchParameters.targets); - } - } - - public String getControlLoopName() { - return controlLoopName; - } - - public void setControlLoopName(String controlLoopName) { - this.controlLoopName = controlLoopName; - } - - public String getActor() { - return actor; - } - - public void setActor(String actor) { - this.actor = actor; - } - - public String getRecipe() { - return recipe; - } - - public void setRecipe(String recipe) { - this.recipe = recipe; - } - - public List<String> getTargets() { - return targets; - } - - public void setTargets(List<String> targets) { - this.targets = targets; - } - - @Override - public String toString() { - return "MatchParameters [controlLoopName=" + controlLoopName + ", actor=" + actor + ", recipe=" + recipe - + ", targets=" + targets + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((actor == null) ? 0 : actor.hashCode()); - result = prime * result + ((controlLoopName == null) ? 0 : controlLoopName.hashCode()); - result = prime * result + ((recipe == null) ? 0 : recipe.hashCode()); - result = prime * result + ((targets == null) ? 0 : targets.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - MatchParameters other = (MatchParameters) obj; - - return equalsMayBeNull(actor, other.actor) - && equalsMayBeNull(controlLoopName, other.controlLoopName) - && equalsMayBeNull(recipe, other.recipe) - && equalsMayBeNull(targets, other.targets); - } - - private boolean equalsMayBeNull(final Object obj1, final Object obj2) { - if (obj1 == null) { - return obj2 == null; - } - return obj1.equals(obj2); - } -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java deleted file mode 100644 index 850b487a7..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/ControlLoopGuardBuilder.java +++ /dev/null @@ -1,128 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.guard.builder; - -import org.onap.policy.controlloop.policy.builder.BuilderException; -import org.onap.policy.controlloop.policy.builder.Results; -import org.onap.policy.controlloop.policy.guard.Constraint; -import org.onap.policy.controlloop.policy.guard.ControlLoopGuard; -import org.onap.policy.controlloop.policy.guard.Guard; -import org.onap.policy.controlloop.policy.guard.GuardPolicy; -import org.onap.policy.controlloop.policy.guard.builder.impl.ControlLoopGuardBuilderImpl; - -public interface ControlLoopGuardBuilder { - - /** - * Adds one or more guard policies to the Control Loop Guard. - * - * @param policies policies to add - * @return builder object - * @throws BuilderException builder exception - */ - public ControlLoopGuardBuilder addGuardPolicy(GuardPolicy... policies) throws BuilderException; - - /** - * Removes one or more guard policies from the Control Loop Guard. - * - * @param policies policies to add - * @return builder object - * @throws BuilderException builder exception - */ - public ControlLoopGuardBuilder removeGuardPolicy(GuardPolicy... policies) throws BuilderException; - - /** - * Removes all guard policies from the Control Loop Guard. - * - * @return builder object - * @throws BuilderException builder exception - */ - public ControlLoopGuardBuilder removeAllGuardPolicies() throws BuilderException; - - /** - * Adds one or more time limit constraints to the guard policy. - * - * @param id (guard policy id) - * @param constraints the constraints to add - * @return builder object - * @throws BuilderException builder exception - */ - public ControlLoopGuardBuilder addLimitConstraint(String id, Constraint... constraints) throws BuilderException; - - /** - * Removes one or more time limit constraints from the guard policy. - * - * @param id (guard policy id) - * @param constraints constraints to remove - * @return builder object - * @throws BuilderException builder exception - */ - public ControlLoopGuardBuilder removeLimitConstraint(String id, Constraint... constraints) throws BuilderException; - - /** - * Removes all time limit constraints from the guard policy. - * - * @param id (guard policy id) - * @return builder object - * @throws BuilderException builder exception - */ - public ControlLoopGuardBuilder removeAllLimitConstraints(String id) throws BuilderException; - - /** - * Simply return a copy of control loop guard. - * - * @return ControlLoopGuard - */ - public ControlLoopGuard getControlLoopGuard(); - - /** - * This will compile and build the YAML specification for the Control Loop Guard. - * Please iterate the Results object for details. - * The Results object will contains warnings and errors. - * If the specification compiled successfully, you will be able to retrieve the - * YAML. - * - * @return Results - */ - public Results buildSpecification(); - - /** - * The Factory is used to build a ControlLoopGuardBuilder implementation. - * - */ - public static class Factory { - - private Factory(){ - //Do Nothing Private Constructor. - } - /** - * Build the control loop guard. - * - * @param guard the guard - * @return ControlLoopGuardBuilder object - */ - - public static ControlLoopGuardBuilder buildControlLoopGuard(Guard guard) { - - return new ControlLoopGuardBuilderImpl(guard); - - } - } -} diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java deleted file mode 100644 index da2b9a122..000000000 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/guard/builder/impl/ControlLoopGuardBuilderImpl.java +++ /dev/null @@ -1,248 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.guard.builder.impl; - -import java.util.LinkedList; - -import org.onap.policy.controlloop.compiler.CompilerException; -import org.onap.policy.controlloop.compiler.ControlLoopCompilerCallback; -import org.onap.policy.controlloop.guard.compiler.ControlLoopGuardCompiler; -import org.onap.policy.controlloop.policy.builder.BuilderException; -import org.onap.policy.controlloop.policy.builder.MessageLevel; -import org.onap.policy.controlloop.policy.builder.Results; -import org.onap.policy.controlloop.policy.builder.impl.MessageImpl; -import org.onap.policy.controlloop.policy.builder.impl.ResultsImpl; -import org.onap.policy.controlloop.policy.guard.Constraint; -import org.onap.policy.controlloop.policy.guard.ControlLoopGuard; -import org.onap.policy.controlloop.policy.guard.Guard; -import org.onap.policy.controlloop.policy.guard.GuardPolicy; -import org.onap.policy.controlloop.policy.guard.builder.ControlLoopGuardBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.yaml.snakeyaml.DumperOptions; -import org.yaml.snakeyaml.DumperOptions.FlowStyle; -import org.yaml.snakeyaml.Yaml; - -public class ControlLoopGuardBuilderImpl implements ControlLoopGuardBuilder { - private static final String NO_EXISTING_GUARD_POLICY_MATCHING_THE_ID = "No existing guard policy matching the id: "; - private static final String THE_ID_OF_TARGET_GUARD_POLICY_MUST_NOT_BE_NULL = - "The id of target guard policy must not be null"; - private static Logger logger = LoggerFactory.getLogger(ControlLoopGuardBuilderImpl.class.getName()); - private ControlLoopGuard clGuard; - - public ControlLoopGuardBuilderImpl(Guard guard) { - clGuard = new ControlLoopGuard(); - clGuard.setGuard(guard); - } - - @Override - public ControlLoopGuardBuilder addGuardPolicy(GuardPolicy... policies) throws BuilderException { - if (policies == null) { - throw new BuilderException("GuardPolicy must not be null"); - } - for (GuardPolicy policy : policies) { - if (!policy.isValid()) { - throw new BuilderException("Invalid guard policy - some required fields are missing"); - } - if (clGuard.getGuards() == null) { - clGuard.setGuards(new LinkedList<>()); - } - clGuard.getGuards().add(policy); - } - return this; - } - - @Override - public ControlLoopGuardBuilder removeGuardPolicy(GuardPolicy... policies) throws BuilderException { - if (policies == null) { - throw new BuilderException("GuardPolicy must not be null"); - } - if (clGuard.getGuards() == null) { - throw new BuilderException("No existing guard policies to remove"); - } - for (GuardPolicy policy : policies) { - if (!policy.isValid()) { - throw new BuilderException("Invalid guard policy - some required fields are missing"); - } - boolean removed = clGuard.getGuards().remove(policy); - if (!removed) { - throw new BuilderException("Unknown guard policy: " + policy.getName()); - } - } - return this; - } - - @Override - public ControlLoopGuardBuilder removeAllGuardPolicies() throws BuilderException { - clGuard.getGuards().clear(); - return this; - } - - @Override - public ControlLoopGuardBuilder addLimitConstraint(String id, Constraint... constraints) throws BuilderException { - if (id == null) { - throw new BuilderException(THE_ID_OF_TARGET_GUARD_POLICY_MUST_NOT_BE_NULL); - } - if (constraints == null) { - throw new BuilderException("Constraint much not be null"); - } - if (!addLimitConstraints(id,constraints)) { - throw new BuilderException(NO_EXISTING_GUARD_POLICY_MATCHING_THE_ID + id); - } - return this; - } - - private boolean addLimitConstraints(String id, Constraint... constraints) throws BuilderException { - boolean exist = false; - for (GuardPolicy policy: clGuard.getGuards()) { - // - // We could have only one guard policy matching the id - // - if (policy.getId().equals(id)) { - exist = true; - for (Constraint cons: constraints) { - if (!cons.isValid()) { - throw new BuilderException("Invalid guard constraint - some required fields are missing"); - } - if (policy.getLimit_constraints() == null) { - policy.setLimit_constraints(new LinkedList<>()); - } - policy.getLimit_constraints().add(cons); - } - break; - } - } - return exist; - } - - @Override - public ControlLoopGuardBuilder removeLimitConstraint(String id, Constraint... constraints) throws BuilderException { - if (id == null) { - throw new BuilderException(THE_ID_OF_TARGET_GUARD_POLICY_MUST_NOT_BE_NULL); - } - if (constraints == null) { - throw new BuilderException("Constraint much not be null"); - } - if (!removeConstraints(id, constraints)) { - throw new BuilderException(NO_EXISTING_GUARD_POLICY_MATCHING_THE_ID + id); - } - return this; - } - - private boolean removeConstraints(String id, Constraint... constraints) throws BuilderException { - boolean exist = false; - for (GuardPolicy policy: clGuard.getGuards()) { - // - // We could have only one guard policy matching the id - // - if (policy.getId().equals(id)) { - exist = true; - for (Constraint cons: constraints) { - if (!cons.isValid()) { - throw new BuilderException("Invalid guard constraint - some required fields are missing"); - } - boolean removed = policy.getLimit_constraints().remove(cons); - if (!removed) { - throw new BuilderException("Unknown guard constraint: " + cons); - } - } - break; - } - } - return exist; - } - - @Override - public ControlLoopGuardBuilder removeAllLimitConstraints(String id) throws BuilderException { - if (clGuard.getGuards() == null || clGuard.getGuards().isEmpty()) { - throw new BuilderException("No guard policies exist"); - } - if (id == null) { - throw new BuilderException(THE_ID_OF_TARGET_GUARD_POLICY_MUST_NOT_BE_NULL); - } - boolean exist = false; - for (GuardPolicy policy: clGuard.getGuards()) { - if (policy.getId().equals(id)) { - exist = true; - policy.getLimit_constraints().clear(); - } - } - if (!exist) { - throw new BuilderException(NO_EXISTING_GUARD_POLICY_MATCHING_THE_ID + id); - } - return this; - } - - - private class BuilderCompilerCallback implements ControlLoopCompilerCallback { - - private ResultsImpl results = new ResultsImpl(); - - @Override - public boolean onWarning(String message) { - results.addMessage(new MessageImpl(message, MessageLevel.WARNING)); - return false; - } - - @Override - public boolean onError(String message) { - results.addMessage(new MessageImpl(message, MessageLevel.ERROR)); - return false; - } - } - - @Override - public ControlLoopGuard getControlLoopGuard() { - return new ControlLoopGuard(this.clGuard); - } - - - @Override - public Results buildSpecification() { - // - // Dump the specification - // - DumperOptions options = new DumperOptions(); - options.setDefaultFlowStyle(FlowStyle.BLOCK); - options.setPrettyFlow(true); - Yaml yaml = new Yaml(options); - String dumpedYaml = yaml.dump(clGuard); - // - // This is our callback class for our compiler - // - BuilderCompilerCallback callback = new BuilderCompilerCallback(); - // - // Compile it - // - try { - ControlLoopGuardCompiler.compile(clGuard, callback); - } catch (CompilerException e) { - logger.error("Build specification threw ", e); - callback.results.addMessage(new MessageImpl(e.getMessage(), MessageLevel.EXCEPTION)); - } - // - // Save the spec - // - callback.results.setSpecification(dumpedYaml); - return callback.results; - } - -} diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/CompilerExceptionTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/CompilerExceptionTest.java deleted file mode 100644 index d48336b3d..000000000 --- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/CompilerExceptionTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. 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.controlloop.compiler; - -import org.junit.Test; -import org.onap.policy.common.utils.test.ExceptionsTester; - -public class CompilerExceptionTest extends ExceptionsTester { - - @Test - public void test() throws Exception { - test(CompilerException.class); - } - -} diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerTest.java deleted file mode 100644 index 56b695b96..000000000 --- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopCompilerTest.java +++ /dev/null @@ -1,220 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml unit test - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.compiler; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.controlloop.policy.FinalResult; - -public class ControlLoopCompilerTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Test - public void testTest() throws Exception { - List<String> expectedOnErrorMessages = new ArrayList<>(); - expectedOnErrorMessages.add("Operational Policy has an bad ID"); - expectedOnErrorMessages.add("Policy id is set to a PolicyResult SUCCESS"); - expectedOnErrorMessages.add("Policy id is set to a FinalResult FINAL_SUCCESS"); - expectedOnErrorMessages.add("Policy actor is null"); - expectedOnErrorMessages.add("Policy actor is invalid"); - expectedOnErrorMessages.add("Policy recipe is null"); - expectedOnErrorMessages.add("Policy recipe is invalid"); - expectedOnErrorMessages.add("Policy recipe is invalid"); - expectedOnErrorMessages.add("Policy recipe is invalid"); - expectedOnErrorMessages.add("Policy target is null"); - expectedOnErrorMessages.add("Policy target is invalid"); - expectedOnErrorMessages.add("Policy success is neither another policy nor FINAL_SUCCESS"); - expectedOnErrorMessages.add("Policy failure is neither another policy nor FINAL_FAILURE"); - expectedOnErrorMessages.add("Policy failure retries is neither another policy nor FINAL_FAILURE_RETRIES"); - expectedOnErrorMessages.add("Policy failure timeout is neither another policy nor FINAL_FAILURE_TIMEOUT"); - expectedOnErrorMessages.add("Policy failure exception is neither another policy nor FINAL_FAILURE_EXCEPTION"); - expectedOnErrorMessages.add("Policy failure guard is neither another policy nor FINAL_FAILURE_GUARD"); - expectedOnErrorMessages.add("Unsupported version for this compiler"); - expectedOnErrorMessages.add("controlLoop overall timeout is less than the sum of operational policy timeouts."); - - TestControlLoopCompilerCallback testControlLoopCompilerCallback = - new TestControlLoopCompilerCallback(expectedOnErrorMessages); - ControlLoopPolicy controlLoopPolicy = this.test("src/test/resources/v1.0.0/test.yaml", - testControlLoopCompilerCallback); - assertEquals(22, controlLoopPolicy.getPolicies().size()); - assertTrue(testControlLoopCompilerCallback.areAllExpectedOnErrorsReceived()); - } - - @Test - public void testSuccessConnectedToUnknownPolicy() throws Exception { - expectedException.expect(CompilerException.class); - expectedException.expectMessage( - "Operation Policy unique-policy-id-1-restart is connected to unknown policy unknown-policy"); - this.test("src/test/resources/v1.0.0/bad_policy_success_connected_to_unknown_policy.yaml"); - } - - @Test - public void testFailureConnectedToUnknownPolicy() throws Exception { - expectedException.expect(CompilerException.class); - expectedException.expectMessage( - "Operation Policy unique-policy-id-1-restart is connected to unknown policy unknown-policy"); - this.test("src/test/resources/v1.0.0/bad_policy_failure_connected_to_unknown_policy.yaml"); - } - - @Test - public void testFailureTimeoutToUnknownPolicy() throws Exception { - expectedException.expect(CompilerException.class); - expectedException.expectMessage( - "Operation Policy unique-policy-id-1-restart is connected to unknown policy unknown-policy"); - this.test("src/test/resources/v1.0.0/bad_policy_failure_timeout_connected_to_unknown_policy.yaml"); - } - - @Test - public void testFailureRetriesToUnknownPolicy() throws Exception { - expectedException.expect(CompilerException.class); - expectedException.expectMessage( - "Operation Policy unique-policy-id-1-restart is connected to unknown policy unknown-policy"); - this.test("src/test/resources/v1.0.0/bad_policy_failure_retries_connected_to_unknown_policy.yaml"); - } - - @Test - public void testFailureExceptionToUnknownPolicy() throws Exception { - expectedException.expect(CompilerException.class); - expectedException.expectMessage( - "Operation Policy unique-policy-id-1-restart is connected to unknown policy unknown-policy"); - this.test("src/test/resources/v1.0.0/bad_policy_failure_exception_connected_to_unknown_policy.yaml"); - } - - @Test - public void testFailureGuardToUnknownPolicy() throws Exception { - expectedException.expect(CompilerException.class); - expectedException.expectMessage( - "Operation Policy unique-policy-id-1-restart is connected to unknown policy unknown-policy"); - this.test("src/test/resources/v1.0.0/bad_policy_failure_guard_connected_to_unknown_policy.yaml"); - } - - @Test - public void testInvalidTriggerPolicyId() throws Exception { - expectedException.expect(CompilerException.class); - expectedException.expectMessage( - "Unexpected value for trigger_policy, should only be " - + FinalResult.FINAL_OPENLOOP.toString() + " or a valid Policy ID"); - this.test("src/test/resources/v1.0.0/bad_trigger_1.yaml"); - } - - @Test - public void testNoTriggerPolicyId() throws Exception { - expectedException.expect(CompilerException.class); - this.test("src/test/resources/v1.0.0/bad_trigger_no_trigger_id.yaml"); - } - - @Test - public void testNoControlLoopName() throws Exception { - List<String> expectedOnErrorMessages = new ArrayList<>(); - expectedOnErrorMessages.add("Missing controlLoopName"); - expectedOnErrorMessages.add("Unsupported version for this compiler"); - TestControlLoopCompilerCallback testControlLoopCompilerCallback = - new TestControlLoopCompilerCallback(expectedOnErrorMessages); - this.test("src/test/resources/v1.0.0/bad_control_loop_no_control_loop_name.yaml", - testControlLoopCompilerCallback); - assertTrue(testControlLoopCompilerCallback.areAllExpectedOnErrorsReceived()); - } - - @Test - public void testInvalidFinalResult() throws Exception { - expectedException.expect(CompilerException.class); - expectedException.expectMessage( - "Unexpected Final Result for trigger_policy, should only be FINAL_OPENLOOP or a valid Policy ID"); - this.test("src/test/resources/v1.0.0/bad_trigger_2.yaml"); - } - - @Test - public void testCompileEmptyFile() throws Exception { - expectedException.expect(CompilerException.class); - expectedException.expectMessage("Could not parse yaml specification."); - this.test("src/test/resources/v1.0.0/empty.yaml"); - } - - public ControlLoopPolicy test(String testFile) throws Exception { - return test(testFile, null); - } - - /** - * Does the actual test. - * - * @param testFile test file - * @param controlLoopCompilerCallback callback method - * @return the policy object - * @throws Exception exception - */ - public ControlLoopPolicy test(String testFile, - ControlLoopCompilerCallback controlLoopCompilerCallback) throws Exception { - try (InputStream is = new FileInputStream(new File(testFile))) { - return ControlLoopCompiler.compile(is, controlLoopCompilerCallback); - } catch (FileNotFoundException e) { - fail(e.getMessage()); - } catch (IOException e) { - fail(e.getMessage()); - } catch (Exception e) { - throw e; - } - return null; - } - - class TestControlLoopCompilerCallback implements ControlLoopCompilerCallback { - - private List<String> expectedOnErrorMessages; - - public TestControlLoopCompilerCallback(List<String> expectedOnErrorMessages) { - this.expectedOnErrorMessages = expectedOnErrorMessages; - } - - @Override - public boolean onWarning(String message) { - return true; - } - - @Override - public boolean onError(String message) { - if (!expectedOnErrorMessages.remove(message)) { - fail("Unexpected onError message: " + message); - } - return true; - } - - public boolean areAllExpectedOnErrorsReceived() { - return expectedOnErrorMessages.size() == 0; - } - - } - -} diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java deleted file mode 100644 index 28e59d9ad..000000000 --- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/compiler/ControlLoopGuardCompilerTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml unit test - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.compiler; - -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; - -import org.junit.Test; - -import org.onap.policy.controlloop.guard.compiler.ControlLoopGuardCompiler; - -public class ControlLoopGuardCompilerTest { - - @Test - public void testTest1() { - try { - this.test("src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml"); - } catch (Exception e) { - fail(e.getMessage()); - } - } - - @Test - public void testTest2() { - try { - this.test("src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml"); - } catch (Exception e) { - fail(e.getMessage()); - } - } - - @Test - public void testBad1() { - try { - this.test("src/test/resources/v2.0.0-guard/no_guard_policy.yaml"); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testBad2() { - try { - this.test("src/test/resources/v2.0.0-guard/duplicate_guard_policy.yaml"); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testBad3() { - try { - this.test("src/test/resources/v2.0.0-guard/no_guard_constraint.yaml"); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testBad4() { - try { - this.test("src/test/resources/v2.0.0-guard/duplicate_guard_constraint.yaml"); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * Does the actual test. - * - * @param testFile input test file - * @throws Exception exception thrown - */ - public void test(String testFile) throws Exception { - try (InputStream is = new FileInputStream(new File(testFile))) { - ControlLoopGuardCompiler.compile(is, null); - } catch (FileNotFoundException e) { - fail(e.getMessage()); - } catch (IOException e) { - fail(e.getMessage()); - } catch (Exception e) { - throw e; - } - } - -} diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java deleted file mode 100644 index be5e488d0..000000000 --- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyBuilderTest.java +++ /dev/null @@ -1,946 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml unit test - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.UUID; - -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.policy.aai.Pnf; -import org.onap.policy.aai.PnfType; -import org.onap.policy.controlloop.policy.builder.BuilderException; -import org.onap.policy.controlloop.policy.builder.ControlLoopPolicyBuilder; -import org.onap.policy.controlloop.policy.builder.Message; -import org.onap.policy.controlloop.policy.builder.MessageLevel; -import org.onap.policy.controlloop.policy.builder.Results; -import org.onap.policy.sdc.Resource; -import org.onap.policy.sdc.ResourceType; -import org.onap.policy.sdc.Service; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.Constructor; -import org.yaml.snakeyaml.error.YAMLException; - - -public class ControlLoopPolicyBuilderTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Test - public void testControlLoop() { - try { - // - // Create a builder for our policy - // - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - // - // Test add services - // - Service scp = new Service("vSCP"); - Service usp = new Service("vUSP"); - Service trinity = new Service("Trinity"); - builder = builder.addService(scp, usp, trinity); - assertTrue(builder.getControlLoop().getServices().size() == 3); - // - // Test remove services - // - builder = builder.removeService(scp); - assertTrue(builder.getControlLoop().getServices().size() == 2); - builder = builder.removeAllServices(); - assertTrue(builder.getControlLoop().getServices().size() == 0); - // - // Test add resources - // - Resource cts = new Resource("vCTS", ResourceType.VF); - Resource com = new Resource("vCTS", ResourceType.VF); - Resource rar = new Resource("vCTS", ResourceType.VF); - builder = builder.addResource(cts, com, rar); - assertTrue(builder.getControlLoop().getResources().size() == 3); - // - // Test remove resources - // - builder = builder.removeResource(cts); - assertTrue(builder.getControlLoop().getResources().size() == 2); - builder = builder.removeAllResources(); - assertTrue(builder.getControlLoop().getResources().size() == 0); - } catch (BuilderException e) { - fail(e.getMessage()); - } - } - - @Test - public void testAddNullService() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - expectedException.expect(BuilderException.class); - expectedException.expectMessage("Service must not be null"); - builder.addService((Service) null); - } - - @Test - public void testAddInvalidService() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - expectedException.expect(BuilderException.class); - expectedException.expectMessage("Invalid service - need either a serviceUUID or serviceName"); - builder.addService(new Service()); - } - - @Test - public void testAddServiceWithUuid() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - UUID uuid = UUID.randomUUID(); - Service serviceWithUuid = new Service(uuid); - builder.addService(serviceWithUuid); - assertTrue(builder.getControlLoop().getServices().size() == 1); - } - - @Test - public void testAddNullResource() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - expectedException.expect(BuilderException.class); - expectedException.expectMessage("Resource must not be null"); - builder.addResource((Resource) null); - } - - - @Test - public void testAddInvalidResource() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - expectedException.expect(BuilderException.class); - expectedException.expectMessage("Invalid resource - need either resourceUUID or resourceName"); - builder.addResource(new Resource()); - } - - @Test - public void testAddAndRemoveResourceWithUuid() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - UUID uuid = UUID.randomUUID(); - Resource resourceWithUuid = new Resource(uuid); - builder.addResource(resourceWithUuid); - assertTrue(builder.getControlLoop().getResources().size() == 1); - - builder.removeResource(resourceWithUuid); - assertTrue(builder.getControlLoop().getResources().size() == 0); - } - - @Test - public void testRemoveNullResource() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - Resource resource = new Resource("resource1", ResourceType.VF); - builder.addResource(resource); - expectedException.expect(BuilderException.class); - expectedException.expectMessage("Resource must not be null"); - builder.removeResource((Resource) null); - } - - @Test - public void testRemoveResourceNoExistingResources() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - expectedException.expect(BuilderException.class); - expectedException.expectMessage("No existing resources to remove"); - builder.removeResource(new Resource("resource1", ResourceType.VF)); - } - - @Test - public void testRemoveInvalidResource() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - Resource resource = new Resource("resource1", ResourceType.VF); - builder.addResource(resource); - expectedException.expect(BuilderException.class); - expectedException.expectMessage("Invalid resource - need either a resourceUUID or resourceName"); - builder.removeResource(new Resource()); - } - - @Test - public void testRemoveUnknownResource() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - Resource resource = new Resource("resource1", ResourceType.VF); - builder.addResource(resource); - final String unknownResourceName = "reource2"; - expectedException.expect(BuilderException.class); - expectedException.expectMessage("Unknown resource " + unknownResourceName); - builder.removeResource(new Resource(unknownResourceName, ResourceType.VF)); - } - - @Test - public void testControlLoopWithInitialResourceAndServices() { - try { - Resource cts = new Resource("vCTS", ResourceType.VF); - Service scp = new Service("vSCP"); - Service usp = new Service("vUSP"); - ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory - .buildControlLoop(UUID.randomUUID().toString(), 2400, cts, scp, usp); - assertTrue(builder.getControlLoop().getResources().size() == 1); - assertTrue(builder.getControlLoop().getServices().size() == 2); - } catch (BuilderException e) { - fail(e.getMessage()); - } - } - - @Test - public void testControlLoopWithInitialResourcesAndService() { - try { - Resource cts = new Resource("vCTS", ResourceType.VF); - Resource com = new Resource("vCTS", ResourceType.VF); - Service scp = new Service("vSCP"); - ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory - .buildControlLoop(UUID.randomUUID().toString(), 2400, scp, cts, com); - assertTrue(builder.getControlLoop().getServices().size() == 1); - assertTrue(builder.getControlLoop().getResources().size() == 2); - } catch (BuilderException e) { - fail(e.getMessage()); - } - } - - @Test - @Ignore - // I'VE MARKED THIS TEST CASE AS IGNORE BECAUSE THE TEST CASE FAILS - // This test case fails because builder.getControlLoop() returns an instance of ControlLoop - // copied using - // the ControlLoop(ControlLoop controlLoop) constructor. - // This constructor does not copy the value of pnf into the newly created object - // On the face of it, this looks like a bug, but perhaps there is a reason for this - // PLEASE ADVISE IF THE BEHAVIOUR IS INCORRECT OR THE TEST CASE IS INVALID - public void testControlLoopForPnf() { - try { - Pnf pnf = new Pnf(); - pnf.setPnfType(PnfType.ENODEB); - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400, pnf); - assertEquals(pnf, builder.getControlLoop().getPnf()); - - builder.removePNF(); - assertNull(builder.getControlLoop().getPnf()); - } catch (BuilderException e) { - fail(e.getMessage()); - } - } - - @Test - @Ignore - // Fails for the same reason as the above test case - public void testSetAndRemovePnf() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - assertNull(builder.getControlLoop().getPnf()); - - Pnf pnf = new Pnf(); - pnf.setPnfType(PnfType.ENODEB); - builder.setPNF(pnf); - assertEquals(pnf, builder.getControlLoop().getPnf()); - - builder.removePNF(); - assertNull(builder.getControlLoop().getPnf()); - } - - @Test - public void testSetNullPnf() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - expectedException.expect(BuilderException.class); - expectedException.expectMessage("PNF must not be null"); - builder.setPNF(null); - } - - @Test - public void testSetInvalidPnf() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - expectedException.expect(BuilderException.class); - expectedException.expectMessage("Invalid PNF - need either pnfName or pnfType"); - builder.setPNF(new Pnf()); - } - - @Test - public void testSetAbatement() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - assertFalse(builder.getControlLoop().getAbatement()); - builder = builder.setAbatement(true); - assertTrue(builder.getControlLoop().getAbatement()); - } - - @Test - public void testSetNullAbatement() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - expectedException.expect(BuilderException.class); - expectedException.expectMessage("abatement must not be null"); - builder = builder.setAbatement(null); - } - - @Test - public void testTimeout() { - try { - // - // Create a builder for our policy - // - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - // - // Test setTimeout - // - assertTrue(builder.getControlLoop().getTimeout() == 2400); - builder = builder.setTimeout(800); - assertTrue(builder.getControlLoop().getTimeout() == 800); - // - // Test calculateTimeout - // - Policy trigger = - builder.setTriggerPolicy(PolicyParam.builder().id(UUID.randomUUID().toString()) - .name("Restart the VM") - .description("Upon getting the trigger event, restart the VM") - .actor("APPC") - .target(new Target(TargetType.VM)) - .recipe("Restart") - .payload(null) - .retries(2) - .timeout(300).build()); - @SuppressWarnings("unused") - Policy onRestartFailurePolicy = builder.setPolicyForPolicyResult( - PolicyParam.builder() - .name("Rebuild VM") - .description("If the restart fails, rebuild it") - .actor("APPC") - .target(new Target(TargetType.VM)) - .recipe("Rebuild") - .payload(null) - .retries(1) - .timeout(600) - .id(trigger.getId()).build(), - PolicyResult.FAILURE, - PolicyResult.FAILURE_RETRIES, - PolicyResult.FAILURE_TIMEOUT); - assertTrue(builder.calculateTimeout().equals(new Integer(300 + 600))); - // - } catch (BuilderException e) { - fail(e.getMessage()); - } - } - - @Test - public void testTriggerPolicyMethods() { - try { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - // - // Test isOpenLoop - // - assertTrue(builder.isOpenLoop()); - // - // Test set initial trigger policy - // - Policy triggerPolicy1 = - builder.setTriggerPolicy( - PolicyParam.builder().id(UUID.randomUUID().toString()) - .name("Restart the VM") - .description("Upon getting the trigger event, restart the VM") - .actor("APPC") - .target(new Target(TargetType.VM)) - .recipe("Restart") - .payload(null) - .retries(2) - .timeout(300).build()); - assertTrue(builder.isOpenLoop() == false); - assertTrue(builder.getControlLoop().getTrigger_policy().equals(triggerPolicy1.getId())); - // - // Set trigger policy to a new policy - // - @SuppressWarnings("unused") - Policy triggerPolicy2 = - builder.setTriggerPolicy( - PolicyParam.builder() - .id(UUID.randomUUID().toString()) - .name("Rebuild the VM") - .description("Upon getting the trigger event, rebuild the VM") - .actor("APPC") - .target(new Target(TargetType.VM)) - .recipe("Rebuild") - .payload(null) - .retries(2) - .timeout(300).build()); - // - // Test set trigger policy to another existing policy - // - @SuppressWarnings("unused") - ControlLoop cl = builder.setExistingTriggerPolicy(triggerPolicy1.getId()); - assertTrue(builder.getControlLoop().getTrigger_policy().equals(triggerPolicy1.getId())); - // - // Test get trigger policy - // - assertTrue(builder.getTriggerPolicy().equals(triggerPolicy1)); - // - } catch (BuilderException e) { - fail(e.getMessage()); - } - } - - @Test - public void testSetTriggerPolicyNullPolicyId() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - expectedException.expect(BuilderException.class); - expectedException.expectMessage("Id must not be null"); - builder.setExistingTriggerPolicy(null); - } - - @Test - public void testSetTriggerPolicyNoPoliciesExist() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - final String unknownPolicyId = "100"; - expectedException.expect(BuilderException.class); - expectedException.expectMessage("Unknown policy " + unknownPolicyId); - builder.setExistingTriggerPolicy(unknownPolicyId); - } - - @Test - public void testSetTriggerPolicyUnknownPolicy() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - builder.setTriggerPolicy( - PolicyParam.builder() - .id(UUID.randomUUID().toString()) - .name("Restart the VM") - .description("Upon getting the trigger event, restart the VM") - .actor("APPC") - .target(new Target(TargetType.VM)) - .recipe("Restart") - .payload(null) - .retries(2) - .timeout(300).build()); - final String unknownPolicyId = "100"; - expectedException.expect(BuilderException.class); - expectedException.expectMessage("Unknown policy " + unknownPolicyId); - builder.setExistingTriggerPolicy(unknownPolicyId); - } - - @Test - public void testAddRemovePolicies() { - try { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - Policy triggerPolicy = - builder.setTriggerPolicy( - PolicyParam.builder() - .id(UUID.randomUUID().toString()) - .name("Restart the VM") - .description("Upon getting the trigger event, restart the VM") - .actor("APPC") - .target(new Target(TargetType.VM)) - .recipe("Restart") - .payload(null) - .retries(2) - .timeout(300).build()); - // - // Test create a policy and chain it to the results of trigger policy - // - Policy onRestartFailurePolicy1 = builder.setPolicyForPolicyResult( - PolicyParam.builder() - .name("Rebuild VM") - .description("If the restart fails, rebuild it.") - .actor("APPC") - .target(new Target(TargetType.VM)) - .recipe("Rebuild") - .payload(null) - .retries(1) - .timeout(600) - .id(triggerPolicy.getId()).build(), - PolicyResult.FAILURE, - PolicyResult.FAILURE_EXCEPTION, - PolicyResult.FAILURE_RETRIES, - PolicyResult.FAILURE_TIMEOUT, - PolicyResult.FAILURE_GUARD); - // - assertTrue(builder.getTriggerPolicy().getFailure().equals(onRestartFailurePolicy1.getId())); - assertTrue(builder.getTriggerPolicy().getFailure_exception().equals(onRestartFailurePolicy1.getId())); - assertTrue(builder.getTriggerPolicy().getFailure_retries().equals(onRestartFailurePolicy1.getId())); - assertTrue(builder.getTriggerPolicy().getFailure_timeout().equals(onRestartFailurePolicy1.getId())); - assertTrue(builder.getTriggerPolicy().getFailure_guard().equals(onRestartFailurePolicy1.getId())); - - // - // Test create a policy and chain it to the results of trigger policy success - // - Policy onSuccessPolicy1 = builder.setPolicyForPolicyResult( - PolicyParam.builder() - .name("Do something") - .description("If the restart succeeds, do something else.") - .actor("APPC") - .target(new Target(TargetType.VM)) - .recipe("SomethingElse") - .payload(null) - .retries(1) - .timeout(600) - .id(triggerPolicy.getId()).build(), - PolicyResult.SUCCESS); - // - assertTrue(builder.getTriggerPolicy().getSuccess().equals(onSuccessPolicy1.getId())); - - // - // Test remove policy - // - boolean removed = builder.removePolicy(onRestartFailurePolicy1.getId()); - assertTrue(removed); - assertTrue(builder.getTriggerPolicy().getFailure().equals(FinalResult.FINAL_FAILURE.toString())); - assertTrue(builder.getTriggerPolicy().getFailure_retries() - .equals(FinalResult.FINAL_FAILURE_RETRIES.toString())); - assertTrue(builder.getTriggerPolicy().getFailure_timeout() - .equals(FinalResult.FINAL_FAILURE_TIMEOUT.toString())); - assertTrue( - builder.getTriggerPolicy().getFailure_guard().equals(FinalResult.FINAL_FAILURE_GUARD.toString())); - // - // Create another policy and chain it to the results of trigger policy - // - final Policy onRestartFailurePolicy2 = - builder.setPolicyForPolicyResult( - PolicyParam.builder() - .name("Rebuild VM") - .description("If the restart fails, rebuild it.") - .actor("APPC") - .target(new Target(TargetType.VM)) - .recipe("Rebuild") - .payload(null) - .retries(2) - .timeout(600) - .id(triggerPolicy.getId()).build(), - PolicyResult.FAILURE, - PolicyResult.FAILURE_RETRIES, - PolicyResult.FAILURE_TIMEOUT); - // - // Test reset policy results - // - triggerPolicy = builder.resetPolicyResults(triggerPolicy.getId()); - assertTrue(builder.getTriggerPolicy().getFailure().equals(FinalResult.FINAL_FAILURE.toString())); - assertTrue(builder.getTriggerPolicy().getFailure_retries() - .equals(FinalResult.FINAL_FAILURE_RETRIES.toString())); - assertTrue(builder.getTriggerPolicy().getFailure_timeout() - .equals(FinalResult.FINAL_FAILURE_TIMEOUT.toString())); - // - // Test set the policy results to an existing operational policy - // - Policy onRestartFailurePolicy3 = - builder.setPolicyForPolicyResult(onRestartFailurePolicy2.getId(), triggerPolicy.getId(), - PolicyResult.FAILURE, PolicyResult.FAILURE_RETRIES, PolicyResult.FAILURE_TIMEOUT); - assertTrue(builder.getTriggerPolicy().getFailure().equals(onRestartFailurePolicy3.getId())); - assertTrue(builder.getTriggerPolicy().getFailure_retries().equals(onRestartFailurePolicy3.getId())); - assertTrue(builder.getTriggerPolicy().getFailure_timeout().equals(onRestartFailurePolicy3.getId())); - // - // Test set the policy result for success to an existing operational policy - // - Policy onRestartFailurePolicy4 = - builder.setPolicyForPolicyResult(onRestartFailurePolicy2.getId(), triggerPolicy.getId(), - PolicyResult.FAILURE, PolicyResult.FAILURE_EXCEPTION, PolicyResult.FAILURE_GUARD, - PolicyResult.FAILURE_RETRIES, PolicyResult.FAILURE_TIMEOUT, PolicyResult.SUCCESS); - assertTrue(builder.getTriggerPolicy().getFailure().equals(onRestartFailurePolicy4.getId())); - assertTrue(builder.getTriggerPolicy().getFailure_exception().equals(onRestartFailurePolicy4.getId())); - assertTrue(builder.getTriggerPolicy().getFailure_guard().equals(onRestartFailurePolicy4.getId())); - assertTrue(builder.getTriggerPolicy().getFailure_retries().equals(onRestartFailurePolicy4.getId())); - assertTrue(builder.getTriggerPolicy().getFailure_timeout().equals(onRestartFailurePolicy4.getId())); - assertTrue(builder.getTriggerPolicy().getSuccess().equals(onRestartFailurePolicy4.getId())); - - // - // Test remove all existing operational policies - // - builder = builder.removeAllPolicies(); - assertTrue(builder.getControlLoop().getTrigger_policy().equals(FinalResult.FINAL_OPENLOOP.toString())); - // - } catch (BuilderException e) { - fail(e.getMessage()); - } - } - - @Test - public void testAddToUnknownPolicy() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - final String policyId = "100"; - expectedException.expect(BuilderException.class); - expectedException.expectMessage("Unknown policy " + policyId); - - builder.setPolicyForPolicyResult( - PolicyParam.builder() - .name("Rebuild VM") - .description("If the restart fails, rebuild it.") - .actor("APPC") - .target(new Target(TargetType.VM)) - .recipe("Rebuild") - .payload(null) - .retries(1) - .timeout(600) - .id(policyId).build(), - PolicyResult.FAILURE, - PolicyResult.FAILURE_RETRIES, - PolicyResult.FAILURE_TIMEOUT, - PolicyResult.FAILURE_GUARD); - } - - @Test - public void testAddExistingPolicyToUnknownPolicy() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - Policy triggerPolicy = - builder.setTriggerPolicy( - PolicyParam.builder() - .id(UUID.randomUUID().toString()) - .name("Restart the VM") - .description("Upon getting the trigger event, restart the VM") - .actor("APPC") - .target(new Target(TargetType.VM)) - .recipe("Restart") - .payload(null) - .retries(2) - .timeout(300).build()); - - - Policy onRestartFailurePolicy = builder.setPolicyForPolicyResult( - PolicyParam.builder() - .name("Rebuild VM") - .description("If the restart fails, rebuild it.") - .actor("APPC") - .target(new Target(TargetType.VM)) - .recipe("Rebuild") - .payload(null) - .retries(1) - .timeout(600) - .id(triggerPolicy.getId()).build(), - PolicyResult.FAILURE); - - final String unknownPolicyId = "100"; - expectedException.expect(BuilderException.class); - expectedException.expectMessage(unknownPolicyId + " does not exist"); - - builder.setPolicyForPolicyResult(onRestartFailurePolicy.getId(), unknownPolicyId, PolicyResult.FAILURE); - } - - @Test - public void testAddUnknownExistingPolicyToPolicy() throws BuilderException { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - Policy triggerPolicy = - builder.setTriggerPolicy( - PolicyParam.builder() - .id(UUID.randomUUID().toString()) - .name("Restart the VM") - .description("Upon getting the trigger event, restart the VM") - .actor("APPC") - .target(new Target(TargetType.VM)) - .recipe("Restart") - .payload(null) - .retries(2) - .timeout(300).build()); - - final String unknownPolicyId = "100"; - expectedException.expect(BuilderException.class); - expectedException.expectMessage("Operational policy " + unknownPolicyId + " does not exist"); - - builder.setPolicyForPolicyResult(unknownPolicyId, triggerPolicy.getId(), PolicyResult.FAILURE); - } - - @Test - public void testAddOperationsAccumulateParams() { - try { - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 2400); - Policy triggerPolicy = - builder.setTriggerPolicy( - PolicyParam.builder() - .id(UUID.randomUUID().toString()) - .name("Restart the eNodeB") - .description("Upon getting the trigger event, restart the eNodeB") - .actor("RANController") - .target(new Target(TargetType.PNF)) - .recipe("Restart") - .payload(null) - .retries(2) - .timeout(300).build()); - // - // Add the operationsAccumulateParams - // - triggerPolicy = builder.addOperationsAccumulateParams(triggerPolicy.getId(), - new OperationsAccumulateParams("15m", 5)); - assertNotNull(builder.getTriggerPolicy().getOperationsAccumulateParams()); - assertTrue(builder.getTriggerPolicy().getOperationsAccumulateParams().getPeriod().equals("15m")); - assertTrue(builder.getTriggerPolicy().getOperationsAccumulateParams().getLimit() == 5); - // - } catch (BuilderException e) { - fail(e.getMessage()); - } - } - - - @Test - public void testBuildSpecification() { - try { - // - // Create the builder - // - ControlLoopPolicyBuilder builder = - ControlLoopPolicyBuilder.Factory.buildControlLoop(UUID.randomUUID().toString(), 800); - // - // Set the first invalid trigger policy - // - final Policy policy1 = builder.setTriggerPolicy( - PolicyParam.builder() - .id(UUID.randomUUID().toString()) - .name("Restart the VM") - .description("Upon getting the trigger event, restart the VM") - .actor(null) - .target(null) - .recipe("Instantiate") - .payload(null) - .retries(2) - .timeout(300).build()); - Results results = builder.buildSpecification(); - // - // Check that ERRORs are in results for invalid policy arguments - // - boolean invalidActor = false; - boolean invalidRecipe = false; - boolean invalidTarget = false; - for (Message m : results.getMessages()) { - if (m.getMessage().equals("Policy actor is null") && m.getLevel() == MessageLevel.ERROR) { - invalidActor = true; - } - if (m.getMessage().equals("Policy recipe is invalid") && m.getLevel() == MessageLevel.ERROR) { - invalidRecipe = true; - } - if (m.getMessage().equals("Policy target is null") && m.getLevel() == MessageLevel.ERROR) { - invalidTarget = true; - } - } - // - assertTrue(invalidActor); - assertTrue(invalidRecipe); - assertTrue(invalidTarget); - // - // Remove the invalid policy - // - // @SuppressWarnings("unused") - boolean removed = builder.removePolicy(policy1.getId()); - assertTrue(removed); - assertTrue(builder.getTriggerPolicy() == null); - // - // Set a valid trigger policy - // - Policy policy1a = builder.setTriggerPolicy( - PolicyParam.builder() - .id(UUID.randomUUID().toString()) - .name("Rebuild VM") - .description("If the restart fails, rebuild it.") - .actor("APPC") - .target(new Target(TargetType.VM)) - .recipe("Rebuild") - .payload(null) - .retries(1) - .timeout(600).build()); - // - // Set a second valid trigger policy - // - final Policy policy2 = - builder.setTriggerPolicy( - PolicyParam.builder() - .id(UUID.randomUUID().toString()) - .name("Restart the VM") - .description("Upon getting the trigger event, restart the VM") - .actor("APPC") - .target(new Target(TargetType.VM)) - .recipe("Restart") - .payload(null) - .retries(2) - .timeout(300).build()); - // - // Now, we have policy1 unreachable - // - results = builder.buildSpecification(); - boolean unreachable = false; - for (Message m : results.getMessages()) { - if (m.getMessage().equals("Policy " + policy1a.getId() + " is not reachable.") - && m.getLevel() == MessageLevel.WARNING) { - unreachable = true; - break; - } - } - assertTrue(unreachable); - // - // Set policy1a for the failure results of policy2 - // - policy1a = builder.setPolicyForPolicyResult(policy1a.getId(), policy2.getId(), PolicyResult.FAILURE, - PolicyResult.FAILURE_RETRIES, PolicyResult.FAILURE_TIMEOUT); - results = builder.buildSpecification(); - boolean invalidTimeout = false; - for (Message m : results.getMessages()) { - if (m.getMessage() - .equals("controlLoop overall timeout is less than the sum of operational policy timeouts.") - && m.getLevel() == MessageLevel.ERROR) { - invalidTimeout = true; - break; - } - } - assertTrue(invalidTimeout); - // - // Remove policy2 (revert controlLoop back to open loop) - // - removed = builder.removePolicy(policy2.getId()); - // - // ControlLoop is open loop now, but it still has policies (policy1) - // - results = builder.buildSpecification(); - unreachable = false; - for (Message m : results.getMessages()) { - if (m.getMessage().equals("Open Loop policy contains policies. The policies will never be invoked.") - && m.getLevel() == MessageLevel.WARNING) { - unreachable = true; - break; - } - } - assertTrue(unreachable); - // - } catch (BuilderException e) { - fail(e.getMessage()); - } - } - - - @Test - public void test1() { - this.test("src/test/resources/v1.0.0/policy_Test.yaml"); - } - - @Test - public void testEvilYaml() { - try (InputStream is = new FileInputStream(new File("src/test/resources/v1.0.0/test_evil.yaml"))) { - // - // Read the yaml into our Java Object - // - Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class)); - yaml.load(is); - } catch (FileNotFoundException e) { - fail(e.getLocalizedMessage()); - } catch (IOException e) { - fail(e.getLocalizedMessage()); - } catch (YAMLException e) { - // - // Should have this - // - } - } - - /** - * Does the actual test. - * - * @param testFile input file - */ - public void test(String testFile) { - try (InputStream is = new FileInputStream(new File(testFile))) { - // - // Read the yaml into our Java Object - // - Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class)); - Object obj = yaml.load(is); - assertNotNull(obj); - assertTrue(obj instanceof ControlLoopPolicy); - ControlLoopPolicy policyTobuild = (ControlLoopPolicy) obj; - // - // Now we're going to try to use the builder to build this. - // - ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop( - policyTobuild.getControlLoop().getControlLoopName(), policyTobuild.getControlLoop().getTimeout()); - // - // Add services - // - if (policyTobuild.getControlLoop().getServices() != null) { - builder = builder.addService(policyTobuild.getControlLoop().getServices() - .toArray(new Service[policyTobuild.getControlLoop().getServices().size()])); - } - // - // Add resources - // - if (policyTobuild.getControlLoop().getResources() != null) { - builder = builder.addResource(policyTobuild.getControlLoop().getResources() - .toArray(new Resource[policyTobuild.getControlLoop().getResources().size()])); - } - // - // Set pnf - // - if (policyTobuild.getControlLoop().getPnf() != null) { - builder = builder.setPNF(policyTobuild.getControlLoop().getPnf()); - } - // - // Add the policies and be sure to set the trigger policy - // - if (policyTobuild.getPolicies() != null) { - for (Policy policy : policyTobuild.getPolicies()) { - if (policy.getId() == policyTobuild.getControlLoop().getTrigger_policy()) { - builder.setTriggerPolicy( - PolicyParam.builder() - .id(UUID.randomUUID().toString()) - .name(policy.getName()) - .description(policy.getDescription()) - .actor(policy.getActor()) - .target(policy.getTarget()) - .recipe(policy.getRecipe()) - .payload(null) - .retries(policy.getRetry()) - .timeout(policy.getTimeout()).build()); - } - } - } - - // Question : how to change policy ID and results by using builder ?? - - @SuppressWarnings("unused") - Results results = builder.buildSpecification(); - - } catch (FileNotFoundException e) { - fail(e.getLocalizedMessage()); - } catch (IOException e) { - fail(e.getLocalizedMessage()); - } catch (BuilderException e) { - fail(e.getLocalizedMessage()); - } - - } - -} diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyTest.java deleted file mode 100644 index 109a365a8..000000000 --- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopPolicyTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml unit test - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; - -import org.junit.Test; -import org.onap.policy.common.utils.io.Serializer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.yaml.snakeyaml.DumperOptions; -import org.yaml.snakeyaml.DumperOptions.FlowStyle; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.Constructor; - - -public class ControlLoopPolicyTest { - private static final Logger logger = LoggerFactory.getLogger(ControlLoopPolicyTest.class); - - @Test - public void test1() { - this.test("src/test/resources/v1.0.0/policy_Test.yaml"); - } - - @Test - public void testvService1() { - this.test("src/test/resources/v1.0.0/policy_vService.yaml"); - } - - @Test - public void testOpenLoop() { - this.test("src/test/resources/v1.0.0/policy_OpenLoop.yaml"); - } - - @Test - public void testvdns() { - this.test("src/test/resources/v2.0.0/policy_ONAP_demo_vDNS.yaml"); - } - - @Test - public void testvFirewall() { - // Chenfei to fix this. - // this.test("src/test/resources/v2.0.0/policy_ONAP_demo_vFirewall.yaml"); - } - - @Test - public void testvcpe() { - this.test("src/test/resources/v2.0.0/policy_ONAP_UseCase_vCPE.yaml"); - } - - @Test - public void testvpci() { - this.test("src/test/resources/v2.0.0/policy_ONAP_UseCase_vPCI.yaml"); - } - - @Test - public void testvsonh() { - this.test("src/test/resources/v2.0.0/policy_ONAP_UseCase_vSONH.yaml"); - } - - @Test - public void testvolte() { - this.test("src/test/resources/v2.0.0/policy_ONAP_UseCase_VOLTE.yaml"); - } - - /** - * Does the actual test. - * - * @param testFile input file - */ - public void test(String testFile) { - try (InputStream is = new FileInputStream(new File(testFile))) { - // - // Read the yaml into our Java Object - // - Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class)); - Object obj = yaml.load(is); - assertNotNull(obj); - assertTrue(obj instanceof ControlLoopPolicy); - dump(obj); - // - // Now dump it to a yaml string - // - DumperOptions options = new DumperOptions(); - options.setDefaultFlowStyle(FlowStyle.BLOCK); - options.setPrettyFlow(true); - yaml = new Yaml(options); - String dumpedYaml = yaml.dump(obj); - logger.debug(dumpedYaml); - // - // Read that string back into our java object - // - Object newObject = yaml.load(dumpedYaml); - dump(newObject); - assertNotNull(newObject); - assertTrue(newObject instanceof ControlLoopPolicy); - // - // Have to comment it out tentatively since it causes junit to fail. - // Seems we cannot use assertEquals here. Need advice. - // - //assertEquals(newObject, obj); - - // test serialization - ControlLoopPolicy policy = (ControlLoopPolicy) obj; - ControlLoopPolicy policy2 = Serializer.roundTrip(policy); - assertTrue(policy.equals(policy2)); - - } catch (FileNotFoundException e) { - fail(e.getLocalizedMessage()); - } catch (IOException e) { - fail(e.getLocalizedMessage()); - } - } - - public void dump(Object obj) { - logger.debug("Dumping ", obj.getClass().getCanonicalName()); - logger.debug("{}", obj); - } -} diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopTest.java deleted file mode 100644 index 0349552af..000000000 --- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/ControlLoopTest.java +++ /dev/null @@ -1,181 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 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.controlloop.policy; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Ignore; -import org.junit.Test; -import org.onap.policy.aai.Pnf; -import org.onap.policy.common.utils.io.Serializer; -import org.onap.policy.sdc.Resource; -import org.onap.policy.sdc.ResourceType; -import org.onap.policy.sdc.Service; - -public class ControlLoopTest { - - private String controlLoopName = "control loop 1"; - private String version = "1.0.1"; - private String triggerPolicy = FinalResult.FINAL_OPENLOOP.toString(); - private Integer timeout = 100; - private Boolean abatement = false; - - @Test - public void testEqualsSameInstance() { - ControlLoop controlLoop1 = new ControlLoop(); - assertTrue(controlLoop1.equals(controlLoop1)); - } - - @Test - public void testEqualsNull() { - ControlLoop controlLoop1 = new ControlLoop(); - assertFalse(controlLoop1.equals(null)); - } - - @Test - public void testEqualsInstanceOfDiffClass() { - ControlLoop controlLoop1 = new ControlLoop(); - assertFalse(controlLoop1.equals("")); - } - - @Test - public void testEqualsNoServicesAndResourcesOrTimeout() { - final Pnf pnf = new Pnf(); - pnf.setPnfName("pnf 1"); - - ControlLoop controlLoop1 = new ControlLoop(); - controlLoop1.setControlLoopName(controlLoopName); - controlLoop1.setVersion(version); - controlLoop1.setPnf(pnf); - controlLoop1.setTrigger_policy(triggerPolicy); - controlLoop1.setAbatement(abatement); - - ControlLoop controlLoop2 = new ControlLoop(); - controlLoop2.setControlLoopName(controlLoopName); - controlLoop2.setVersion(version); - controlLoop2.setPnf(pnf); - controlLoop2.setTrigger_policy(triggerPolicy); - controlLoop2.setAbatement(abatement); - - assertTrue(controlLoop1.equals(controlLoop2)); - } - - @Test - public void testEquals() throws IOException { - final Pnf pnf = new Pnf(); - pnf.setPnfName("pnf 1"); - - ControlLoop controlLoop1 = new ControlLoop(); - controlLoop1.setControlLoopName(controlLoopName); - controlLoop1.setVersion(version); - Service service1 = new Service("service1"); - Service service2 = new Service("service2"); - List<Service> services = new ArrayList<>(); - services.add(service1); - services.add(service2); - controlLoop1.setServices(services); - Resource resource1 = new Resource("resource1", ResourceType.VF); - Resource resource2 = new Resource("resource2", ResourceType.VFC); - List<Resource> resources = new ArrayList<>(); - resources.add(resource1); - resources.add(resource2); - controlLoop1.setResources(resources); - controlLoop1.setPnf(pnf); - controlLoop1.setTrigger_policy(triggerPolicy); - controlLoop1.setTimeout(timeout); - controlLoop1.setAbatement(abatement); - - ControlLoop controlLoop2 = new ControlLoop(); - controlLoop2.setControlLoopName(controlLoopName); - controlLoop2.setVersion(version); - Service controlLoop2Service1 = new Service("service1"); - Service controlLoop2Service2 = new Service("service2"); - List<Service> controlLoop2Services = new ArrayList<>(); - controlLoop2Services.add(controlLoop2Service1); - controlLoop2Services.add(controlLoop2Service2); - controlLoop2.setServices(controlLoop2Services); - Resource controlLoop2Resource1 = new Resource("resource1", ResourceType.VF); - Resource controlLoop2Resource2 = new Resource("resource2", ResourceType.VFC); - List<Resource> controlLoop2Resources = new ArrayList<>(); - controlLoop2Resources.add(controlLoop2Resource1); - controlLoop2Resources.add(controlLoop2Resource2); - controlLoop2.setResources(controlLoop2Resources); - controlLoop2.setPnf(pnf); - controlLoop2.setTrigger_policy(triggerPolicy); - controlLoop2.setTimeout(timeout); - controlLoop1.setAbatement(abatement); - - assertTrue(controlLoop1.equals(controlLoop2)); - assertEquals(controlLoop1.hashCode(), controlLoop2.hashCode()); - - controlLoop2 = Serializer.roundTrip(controlLoop1); - assertTrue(controlLoop1.equals(controlLoop2)); - assertEquals(controlLoop1.hashCode(), controlLoop2.hashCode()); - } - - @Test - @Ignore - // I'VE MARKED THIS TEST CASE AS IGNORE BECAUSE THE TEST CASE FAILS - // This test case fails because the ControlLoop(ControlLoop controlLoop) constructor. - // does not copy the value of pnf and version into the newly created object - // PLEASE ADVISE IF THE EXISTING BEHAVIOUR IS CORRECT - public void testControlLoop() { - final Pnf pnf = new Pnf(); - pnf.setPnfName("pnf 1"); - - ControlLoop controlLoop1 = new ControlLoop(); - controlLoop1.setControlLoopName(controlLoopName); - controlLoop1.setVersion(version); - Service service1 = new Service("service1"); - Service service2 = new Service("service2"); - List<Service> services = new ArrayList<>(); - services.add(service1); - services.add(service2); - controlLoop1.setServices(services); - Resource resource1 = new Resource("resource1", ResourceType.VF); - Resource resource2 = new Resource("resource2", ResourceType.VFC); - List<Resource> resources = new ArrayList<>(); - resources.add(resource1); - resources.add(resource2); - controlLoop1.setResources(resources); - controlLoop1.setPnf(pnf); - controlLoop1.setTrigger_policy(triggerPolicy); - controlLoop1.setAbatement(abatement); - - ControlLoop controlLoop2 = new ControlLoop(controlLoop1); - - assertEquals(controlLoop1.getControlLoopName(), controlLoop2.getControlLoopName()); - assertEquals(controlLoop1.getVersion(), controlLoop2.getVersion()); - assertEquals(controlLoop1.getServices(), controlLoop2.getServices()); - assertEquals(controlLoop1.getResources(), controlLoop2.getResources()); - assertEquals(controlLoop1.getPnf(), controlLoop2.getPnf()); - assertEquals(controlLoop1.getTrigger_policy(), controlLoop2.getTrigger_policy()); - assertEquals(controlLoop1.getAbatement(), controlLoop2.getAbatement()); - - assertTrue(controlLoop1.equals(controlLoop2)); - } - -} diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/OperationsAccumulateParamsTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/OperationsAccumulateParamsTest.java deleted file mode 100644 index 9e68a7389..000000000 --- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/OperationsAccumulateParamsTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 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.controlloop.policy; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class OperationsAccumulateParamsTest { - - @Test - public void testConstructor() { - OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(); - assertNull(operationsAccumulateParams.getPeriod()); - assertNull(operationsAccumulateParams.getLimit()); - } - - @Test - public void testConstructorOperationsAccumulateParams() { - String period = "15m"; - Integer limit = 10; - OperationsAccumulateParams operationsAccumulateParams1 = - new OperationsAccumulateParams(period, limit); - OperationsAccumulateParams operationsAccumulateParams2 = - new OperationsAccumulateParams(operationsAccumulateParams1); - assertEquals(period, operationsAccumulateParams1.getPeriod()); - assertEquals(limit, operationsAccumulateParams2.getLimit()); - } - - @Test - public void testOperationsAccumulateParamsStringInteger() { - String period = "15m"; - Integer limit = 10; - OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(period, limit); - assertEquals(period, operationsAccumulateParams.getPeriod()); - assertEquals(limit, operationsAccumulateParams.getLimit()); - } - - @Test - public void testSetAndGetPeriod() { - String period = "15m"; - OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(); - operationsAccumulateParams.setPeriod(period); - assertEquals(period, operationsAccumulateParams.getPeriod()); - } - - @Test - public void testSetLimit() { - Integer limit = 10; - OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(); - operationsAccumulateParams.setLimit(limit); - assertEquals(limit, operationsAccumulateParams.getLimit()); - } - - @Test - public void testToString() { - String period = "15m"; - Integer limit = 10; - OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(period, limit); - assertEquals("OperationsAccumulateParams [period=15m, limit=10]", operationsAccumulateParams.toString()); - } - - @Test - public void testEqualsAndHashCode() { - final String period = "15m"; - final Integer limit = 10; - OperationsAccumulateParams operationsAccumulateParams1 = new OperationsAccumulateParams(); - OperationsAccumulateParams operationsAccumulateParams2 = new OperationsAccumulateParams(); - - assertTrue(operationsAccumulateParams1.equals(operationsAccumulateParams2)); - - operationsAccumulateParams1.setPeriod(period); - assertFalse(operationsAccumulateParams1.equals(operationsAccumulateParams2)); - operationsAccumulateParams2.setPeriod(period); - assertTrue(operationsAccumulateParams1.equals(operationsAccumulateParams2)); - assertEquals(operationsAccumulateParams1.hashCode(), operationsAccumulateParams2.hashCode()); - - operationsAccumulateParams1.setLimit(limit);; - assertFalse(operationsAccumulateParams1.equals(operationsAccumulateParams2)); - operationsAccumulateParams2.setLimit(limit); - assertTrue(operationsAccumulateParams1.equals(operationsAccumulateParams2)); - assertEquals(operationsAccumulateParams1.hashCode(), operationsAccumulateParams2.hashCode()); - } - - - @Test - public void testEqualsSameObject() { - OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(); - assertTrue(operationsAccumulateParams.equals(operationsAccumulateParams)); - } - - @Test - public void testEqualsNull() { - OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(); - assertFalse(operationsAccumulateParams.equals(null)); - } - - @Test - public void testEqualsInstanceOfDiffClass() { - OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(); - assertFalse(operationsAccumulateParams.equals("")); - } - -} diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/PolicyTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/PolicyTest.java deleted file mode 100644 index d903b1534..000000000 --- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/PolicyTest.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * policy-yaml unit test - * ================================================================================ - * Copyright (C) 2018 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.controlloop.policy; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.Map; -import java.util.TreeMap; -import org.junit.Before; -import org.junit.Test; -import org.onap.policy.common.utils.io.Serializer; - -public class PolicyTest { - private Policy policy; - - @Before - public void setUp() { - policy = new Policy(); - } - - @Test - public void testHashCode() { - assertTrue(policy.hashCode() != 0); - - policy.setActor("a"); - int hc1 = policy.hashCode(); - - policy.setActor("b"); - assertTrue(hc1 != policy.hashCode()); - } - - @Test - public void test() throws IOException { - OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(); - operationsAccumulateParams.setLimit(10); - - Map<String, String> payload = new TreeMap<>(); - payload.put("mykey", "myvalue"); - - Target target = new Target(); - target.setResourceID("myresource"); - - policy.setActor("act"); - policy.setDescription("desc"); - policy.setFailure("fail"); - policy.setFailure_exception("failex"); - policy.setFailure_guard("failguard"); - policy.setFailure_retries("failretry"); - policy.setFailure_timeout("failtimeout"); - policy.setId("myid"); - policy.setName("myname"); - policy.setOperationsAccumulateParams(operationsAccumulateParams); - policy.setPayload(payload); - policy.setRecipe("myrecipe"); - policy.setRetry(20); - policy.setSuccess("succ"); - policy.setTarget(target); - policy.setTimeout(30); - - assertEquals("act", policy.getActor()); - assertEquals("desc", policy.getDescription()); - assertEquals("fail", policy.getFailure()); - assertEquals("failex", policy.getFailure_exception()); - assertEquals("failguard", policy.getFailure_guard()); - assertEquals("failretry", policy.getFailure_retries()); - assertEquals("failtimeout", policy.getFailure_timeout()); - assertEquals("myid", policy.getId()); - assertEquals("myname", policy.getName()); - assertEquals(operationsAccumulateParams, policy.getOperationsAccumulateParams()); - assertEquals(payload, policy.getPayload()); - assertEquals("myrecipe", policy.getRecipe()); - assertEquals(20, policy.getRetry().intValue()); - assertEquals("succ", policy.getSuccess()); - assertEquals(target, policy.getTarget()); - assertEquals(30, policy.getTimeout().intValue()); - - assertTrue(policy.equals(policy)); - assertTrue(policy.hashCode() != new Policy().hashCode()); - assertFalse(policy.equals(new Policy())); - - Policy policy2 = Serializer.roundTrip(policy); - assertTrue(policy.equals(policy2)); - assertEquals(policy.hashCode(), policy2.hashCode()); - - policy2 = new Policy(policy); - assertTrue(policy.equals(policy2)); - assertEquals(policy.hashCode(), policy2.hashCode()); - } - - @Test - public void testPolicyString() { - policy = new Policy("justId"); - assertEquals("justId", policy.getId()); - } - - @Test - public void testPolicyStringStringStringMapOfStringStringTarget() { - Map<String, String> payload = new TreeMap<>(); - payload.put("mykeyB", "myvalueB"); - - Target target = new Target(); - target.setResourceID("myresourceB"); - - policy = new Policy("nameB", "actorB", "recipeB", payload, target); - assertEquals("nameB", policy.getName()); - assertEquals("actorB", policy.getActor()); - assertEquals("recipeB", policy.getRecipe()); - assertEquals(payload, policy.getPayload()); - assertEquals(target, policy.getTarget()); - - assertTrue(policy.hashCode() != new Policy().hashCode()); - } - - @Test - public void testPolicyStringStringStringMapOfStringStringTargetIntegerInteger() { - Map<String, String> payload = new TreeMap<>(); - payload.put("mykeyC", "myvalueC"); - - Target target = new Target(); - target.setResourceID("myresourceC"); - - policy = new Policy("nameC", "actorC", "recipeC", payload, target, 201, 202); - assertEquals("nameC", policy.getName()); - assertEquals("actorC", policy.getActor()); - assertEquals("recipeC", policy.getRecipe()); - assertEquals(payload, policy.getPayload()); - assertEquals(target, policy.getTarget()); - assertEquals(201, policy.getRetry().intValue()); - assertEquals(202, policy.getTimeout().intValue()); - - assertTrue(policy.hashCode() != new Policy().hashCode()); - } - - @Test - public void testPolicyStringStringStringStringMapOfStringStringTargetStringIntegerInteger() { - Map<String, String> payload = new TreeMap<>(); - payload.put("mykeyD", "myvalueD"); - - Target target = new Target(); - target.setResourceID("myresourceD"); - - policy = new Policy( - PolicyParam.builder().id("idD") - .name("nameD") - .description("descD") - .actor("actorD") - .payload(payload) - .target(target) - .recipe("recipeD") - .retries(301) - .timeout(302) - .build()); - assertEquals("idD", policy.getId()); - assertEquals("nameD", policy.getName()); - assertEquals("descD", policy.getDescription()); - assertEquals("actorD", policy.getActor()); - assertEquals(payload, policy.getPayload()); - assertEquals(target, policy.getTarget()); - assertEquals("recipeD", policy.getRecipe()); - assertEquals(301, policy.getRetry().intValue()); - assertEquals(302, policy.getTimeout().intValue()); - - assertTrue(policy.hashCode() != new Policy().hashCode()); - } - - @Test - public void testIsValid() { - assertFalse(policy.isValid()); - - Target target = new Target(); - target.setResourceID("myresourceV"); - - policy = new Policy("nameV", "actorV", "recipeV", null, target); - assertEquals(null, policy.getPayload()); - assertTrue(policy.isValid()); - } - - @Test - public void testToString() { - assertNotNull(policy.toString()); - } - - @Test - public void testEqualsObject() { - assertTrue(policy.equals(policy)); - - policy.setId("idE"); - assertFalse(policy.equals(new Policy())); - - Policy policy2 = new Policy(); - policy2.setId(policy.getId()); - assertTrue(policy.equals(policy2)); - - policy2.setId("idX"); - assertFalse(policy.equals(policy2)); - } - -} diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ConstraintTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ConstraintTest.java deleted file mode 100644 index 2d497ac4b..000000000 --- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ConstraintTest.java +++ /dev/null @@ -1,256 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 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.controlloop.policy.guard; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Test; - -public class ConstraintTest { - - @Test - public void testConstraint() { - Constraint constraint = new Constraint(); - - assertNull(constraint.getFreq_limit_per_target()); - assertNull(constraint.getTime_window()); - assertNull(constraint.getActive_time_range()); - assertNull(constraint.getBlacklist()); - } - - @Test - public void testGetAndSetFreq_limit_per_target() { - Integer freqLimitPerTarget = 10; - Constraint constraint = new Constraint(); - constraint.setFreq_limit_per_target(freqLimitPerTarget); - assertEquals(freqLimitPerTarget, constraint.getFreq_limit_per_target()); - } - - @Test - public void testGetAndSetTime_window() { - Map<String, String> timeWindow = new HashMap<>(); - timeWindow.put("timeWindowKey", "timeWindowValue"); - Constraint constraint = new Constraint(); - constraint.setTime_window(timeWindow); - assertEquals(timeWindow, constraint.getTime_window()); - } - - @Test - public void testGetAndSetActive_time_range() { - Map<String, String> activeTimeRange = new HashMap<>(); - activeTimeRange.put("timeWindowKey", "timeWindowValue"); - Constraint constraint = new Constraint(); - constraint.setActive_time_range(activeTimeRange);; - assertEquals(activeTimeRange, constraint.getActive_time_range()); - } - - @Test - public void testGetAndSetBlacklist() { - List<String> blacklist = new ArrayList<>(); - blacklist.add("blacklist item"); - Constraint constraint = new Constraint(); - constraint.setBlacklist(blacklist); - assertEquals(blacklist, constraint.getBlacklist()); - } - - @Test - public void testConstraintIntegerMapOfStringString() { - Integer freqLimitPerTarget = 10; - Map<String, String> timeWindow = new HashMap<>(); - - Constraint constraint = new Constraint(freqLimitPerTarget, timeWindow); - - assertEquals(freqLimitPerTarget, constraint.getFreq_limit_per_target()); - assertEquals(timeWindow, constraint.getTime_window()); - assertNull(constraint.getActive_time_range()); - assertNull(constraint.getBlacklist()); - } - - @Test - public void testConstraintListOfString() { - List<String> blacklist = new ArrayList<>(); - blacklist.add("blacklist item"); - Constraint constraint = new Constraint(blacklist); - - assertNull(constraint.getFreq_limit_per_target()); - assertNull(constraint.getTime_window()); - assertNull(constraint.getActive_time_range()); - assertEquals(blacklist, constraint.getBlacklist()); - } - - @Test - public void testConstraintIntegerMapOfStringStringListOfString() { - Integer freqLimitPerTarget = 10; - Map<String, String> timeWindow = new HashMap<>(); - List<String> blacklist = new ArrayList<>(); - blacklist.add("blacklist item"); - Constraint constraint = new Constraint(freqLimitPerTarget, timeWindow, blacklist); - - assertEquals(freqLimitPerTarget, constraint.getFreq_limit_per_target()); - assertEquals(timeWindow, constraint.getTime_window()); - assertNull(constraint.getActive_time_range()); - assertEquals(blacklist, constraint.getBlacklist()); - } - - @Test - public void testConstraintIntegerMapOfStringStringMapOfStringString() { - Integer freqLimitPerTarget = 10; - Map<String, String> timeWindow = new HashMap<>(); - Map<String, String> activeTimeRange = new HashMap<>(); - activeTimeRange.put("timeWindowKey", "timeWindowValue"); - Constraint constraint = new Constraint(freqLimitPerTarget, timeWindow, activeTimeRange); - - assertEquals(freqLimitPerTarget, constraint.getFreq_limit_per_target()); - assertEquals(timeWindow, constraint.getTime_window()); - assertEquals(activeTimeRange, constraint.getActive_time_range()); - assertNull(constraint.getBlacklist()); - - } - - @Test - public void testConstraintIntegerMapOfStringStringMapOfStringStringListOfString() { - Integer freqLimitPerTarget = 10; - Map<String, String> timeWindow = new HashMap<>(); - Map<String, String> activeTimeRange = new HashMap<>(); - activeTimeRange.put("timeWindowKey", "timeWindowValue"); - List<String> blacklist = new ArrayList<>(); - blacklist.add("blacklist item"); - Constraint constraint = new Constraint(freqLimitPerTarget, timeWindow, activeTimeRange, blacklist); - - assertEquals(freqLimitPerTarget, constraint.getFreq_limit_per_target()); - assertEquals(timeWindow, constraint.getTime_window()); - assertEquals(activeTimeRange, constraint.getActive_time_range()); - assertEquals(blacklist, constraint.getBlacklist()); - } - - @Test - public void testConstraintConstraint() { - Integer freqLimitPerTarget = 10; - Map<String, String> timeWindow = new HashMap<>(); - Map<String, String> activeTimeRange = new HashMap<>(); - activeTimeRange.put("timeWindowKey", "timeWindowValue"); - List<String> blacklist = new ArrayList<>(); - blacklist.add("blacklist item"); - Constraint constraint1 = new Constraint(freqLimitPerTarget, timeWindow, activeTimeRange, blacklist); - Constraint constraint2 = new Constraint(constraint1); - - assertEquals(freqLimitPerTarget, constraint2.getFreq_limit_per_target()); - assertEquals(timeWindow, constraint2.getTime_window()); - assertEquals(activeTimeRange, constraint2.getActive_time_range()); - assertEquals(blacklist, constraint2.getBlacklist()); - } - - @Test - public void testIsValid() { - Integer freqLimitPerTarget = 10; - final Map<String, String> timeWindow = new HashMap<>(); - - Constraint constraint = new Constraint(); - assertTrue(constraint.isValid()); - - constraint.setFreq_limit_per_target(freqLimitPerTarget); - assertFalse(constraint.isValid()); - - constraint.setTime_window(timeWindow); - assertTrue(constraint.isValid()); - - constraint.setFreq_limit_per_target(null); - assertFalse(constraint.isValid()); - } - - @Test - public void testToString() { - Integer freqLimitPerTarget = 10; - Map<String, String> timeWindow = new HashMap<>(); - Map<String, String> activeTimeRange = new HashMap<>(); - activeTimeRange.put("timeWindowKey", "timeWindowValue"); - List<String> blacklist = new ArrayList<>(); - blacklist.add("blacklist item"); - Constraint constraint = new Constraint(freqLimitPerTarget, timeWindow, activeTimeRange, blacklist); - - assertEquals(constraint.toString(), "Constraint [freq_limit_per_target=" + freqLimitPerTarget - + ", time_window=" + timeWindow + ", active_time_range=" + activeTimeRange - + ", blacklist=" + blacklist + "]"); - } - - @Test - public void testEquals() { - Integer freqLimitPerTarget = 10; - final Map<String, String> timeWindow = new HashMap<>(); - final Map<String, String> activeTimeRange = new HashMap<>(); - List<String> blacklist = new ArrayList<>(); - blacklist.add("blacklist item"); - - Constraint constraint1 = new Constraint(); - Constraint constraint2 = new Constraint(); - assertTrue(constraint1.equals(constraint2)); - - constraint1.setFreq_limit_per_target(freqLimitPerTarget); - assertFalse(constraint1.equals(constraint2)); - constraint2.setFreq_limit_per_target(freqLimitPerTarget); - assertTrue(constraint1.equals(constraint2)); - assertEquals(constraint1.hashCode(), constraint2.hashCode()); - - constraint1.setTime_window(timeWindow); - assertFalse(constraint1.equals(constraint2)); - constraint2.setTime_window(timeWindow); - assertTrue(constraint1.equals(constraint2)); - assertEquals(constraint1.hashCode(), constraint2.hashCode()); - - constraint1.setActive_time_range(activeTimeRange); - assertFalse(constraint1.equals(constraint2)); - constraint2.setActive_time_range(activeTimeRange); - assertTrue(constraint1.equals(constraint2)); - assertEquals(constraint1.hashCode(), constraint2.hashCode()); - - constraint1.setBlacklist(blacklist); - assertFalse(constraint1.equals(constraint2)); - constraint2.setBlacklist(blacklist); - assertTrue(constraint1.equals(constraint2)); - assertEquals(constraint1.hashCode(), constraint2.hashCode()); - } - - @Test - public void testEqualsSameObject() { - Constraint constraint = new Constraint(); - assertTrue(constraint.equals(constraint)); - } - - @Test - public void testEqualsNull() { - Constraint constraint = new Constraint(); - assertFalse(constraint.equals(null)); - } - - @Test - public void testEqualsInstanceOfDiffClass() { - Constraint constraint = new Constraint(); - assertFalse(constraint.equals("")); - } - -} diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java deleted file mode 100644 index 782f6d5e8..000000000 --- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardBuilderTest.java +++ /dev/null @@ -1,217 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml unit test - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.guard; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.junit.Test; -import org.onap.policy.controlloop.policy.builder.BuilderException; -import org.onap.policy.controlloop.policy.builder.Message; -import org.onap.policy.controlloop.policy.builder.MessageLevel; -import org.onap.policy.controlloop.policy.builder.Results; -import org.onap.policy.controlloop.policy.guard.builder.ControlLoopGuardBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.Constructor; - -public class ControlLoopGuardBuilderTest { - private static final Logger logger = LoggerFactory.getLogger(ControlLoopGuardBuilderTest.class); - - @Test - public void testControlLoopGuard() { - try { - // - // Create a builder - // - ControlLoopGuardBuilder builder = ControlLoopGuardBuilder.Factory.buildControlLoopGuard(new Guard()); - // - // Assert there is no guard policies yet - // - Results results = builder.buildSpecification(); - boolean noGuardPolicies = false; - for (Message m : results.getMessages()) { - if (m.getMessage().equals("ControlLoop Guard should have at least one guard policies") - && m.getLevel() == MessageLevel.ERROR) { - noGuardPolicies = true; - break; - } - } - assertTrue(noGuardPolicies); - // - // Add a guard policy without limit constraint - // - String clname = "CL_vUSP123"; - LinkedList<String> targets = new LinkedList<String>(); - targets.add("s1"); - targets.add("s2"); - targets.add("s3"); - MatchParameters matchParameters = new MatchParameters(clname, "APPC", "Restart", targets); - GuardPolicy policy1 = new GuardPolicy("id123", "guardpolicy1", "description aaa", matchParameters); - builder = builder.addGuardPolicy(policy1); - // - // Assert there is no limit constraint associated with the only guard policy - // - results = builder.buildSpecification(); - boolean noConstraint = false; - for (Message m : results.getMessages()) { - if (m.getMessage().equals("Guard policy guardpolicy1 does not have any limit constraint") - && m.getLevel() == MessageLevel.ERROR) { - noConstraint = true; - break; - } - } - assertTrue(noConstraint); - // - // Add a constraint to policy1 - // - Map<String, String> activeTimeRange = new HashMap<String, String>(); - activeTimeRange.put("start", "00:00:00-05:00"); - activeTimeRange.put("end", "23:59:59-05:00"); - List<String> blacklist = new LinkedList<String>(); - blacklist.add("eNodeB_common_id1"); - blacklist.add("eNodeB_common_id2"); - Map<String, String> timeWindow = new HashMap<String, String>(); - timeWindow.put("value", "10"); - timeWindow.put("units", "minute"); - Constraint cons = new Constraint(5, timeWindow, activeTimeRange, blacklist); - builder = builder.addLimitConstraint(policy1.getId(), cons); - // - // Add a duplicate constraint to policy1 - // - builder = builder.addLimitConstraint(policy1.getId(), cons); - // - // Assert there are duplicate constraints associated with the only guard policy - // - results = builder.buildSpecification(); - boolean duplicateConstraint = false; - for (Message m : results.getMessages()) { - if (m.getMessage().equals("Guard policy guardpolicy1 has duplicate limit constraints") - && m.getLevel() == MessageLevel.WARNING) { - duplicateConstraint = true; - break; - } - } - assertTrue(duplicateConstraint); - // - // Remove the duplicate constraint - // - builder = builder.removeLimitConstraint(policy1.getId(), cons); - // - // Add a duplicate guard policy - // - builder = builder.addGuardPolicy(policy1); - builder = builder.addLimitConstraint(policy1.getId(), cons); - // - // Assert there are duplicate guard policies - // - results = builder.buildSpecification(); - boolean duplicateGuardPolicy = false; - for (Message m : results.getMessages()) { - if (m.getMessage().equals("There are duplicate guard policies") - && m.getLevel() == MessageLevel.WARNING) { - duplicateGuardPolicy = true; - break; - } - } - assertTrue(duplicateGuardPolicy); - // - // Remove the duplicate guard policy - // - builder = builder.removeGuardPolicy(policy1); - // - // Assert there are no Error/Warning message - // - results = builder.buildSpecification(); - assertTrue(results.getMessages().size() == 1); - // - } catch (BuilderException e) { - fail(e.getMessage()); - } - } - - @Test - public void test1() { - this.test("src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml"); - } - - @Test - public void test2() { - this.test("src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml"); - } - - /** - * Do the actual test. - * - * @param testFile input test file - */ - public void test(String testFile) { - try (InputStream is = new FileInputStream(new File(testFile))) { - // - // Read the yaml into our Java Object - // - Yaml yaml = new Yaml(new Constructor(ControlLoopGuard.class)); - Object obj = yaml.load(is); - assertNotNull(obj); - assertTrue(obj instanceof ControlLoopGuard); - ControlLoopGuard guardTobuild = (ControlLoopGuard) obj; - // - // Now we're going to try to use the builder to build this. - // - ControlLoopGuardBuilder builder = - ControlLoopGuardBuilder.Factory.buildControlLoopGuard(guardTobuild.getGuard()); - // - // Add guard policy - // - if (guardTobuild.getGuards() != null) { - builder = builder.addGuardPolicy(guardTobuild.getGuards().toArray( - new GuardPolicy[guardTobuild.getGuards().size()])); - } - // - // Build the specification - // - Results results = builder.buildSpecification(); - // - // Print out the specification - // - logger.debug(results.getSpecification()); - // - } catch (FileNotFoundException e) { - fail(e.getLocalizedMessage()); - } catch (IOException e) { - fail(e.getLocalizedMessage()); - } catch (BuilderException e) { - fail(e.getLocalizedMessage()); - } - } -} diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java deleted file mode 100644 index 1a5b5e92a..000000000 --- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/ControlLoopGuardTest.java +++ /dev/null @@ -1,169 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * policy-yaml unit test - * ================================================================================ - * Copyright (C) 2017-2018 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.controlloop.policy.guard; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.LinkedList; - -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.yaml.snakeyaml.DumperOptions; -import org.yaml.snakeyaml.DumperOptions.FlowStyle; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.Constructor; - - -public class ControlLoopGuardTest { - private static final Logger logger = LoggerFactory.getLogger(ControlLoopGuardTest.class); - - @Test - public void testGuardvdns() { - this.test("src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml"); - } - - @Test - public void testGuardvusp() { - this.test("src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml"); - } - - @Test - public void testConstructorControlLoopGuard() { - Guard guard1 = new Guard(); - GuardPolicy guardPolicy1 = new GuardPolicy(); - GuardPolicy guardPolicy2 = new GuardPolicy(); - LinkedList<GuardPolicy> guardPolicies = new LinkedList<>(); - guardPolicies.add(guardPolicy1); - guardPolicies.add(guardPolicy2); - - ControlLoopGuard controlLoopGuard1 = new ControlLoopGuard(); - controlLoopGuard1.setGuard(guard1); - controlLoopGuard1.setGuards(guardPolicies); - ControlLoopGuard controlLoopGuard2 = new ControlLoopGuard(controlLoopGuard1); - - assertEquals(guard1, controlLoopGuard2.getGuard()); - assertEquals(guardPolicies, controlLoopGuard2.getGuards()); - } - - @Test - public void testEqualsAndHashCode() { - final Guard guard1 = new Guard(); - GuardPolicy guardPolicy1 = new GuardPolicy(); - GuardPolicy guardPolicy2 = new GuardPolicy(); - LinkedList<GuardPolicy> guardPolicies = new LinkedList<>(); - guardPolicies.add(guardPolicy1); - guardPolicies.add(guardPolicy2); - - ControlLoopGuard controlLoopGuard1 = new ControlLoopGuard(); - ControlLoopGuard controlLoopGuard2 = new ControlLoopGuard(); - - assertTrue(controlLoopGuard1.equals(controlLoopGuard2)); - assertEquals(controlLoopGuard1.hashCode(), controlLoopGuard2.hashCode()); - - controlLoopGuard1.setGuard(guard1); - assertFalse(controlLoopGuard1.equals(controlLoopGuard2)); - controlLoopGuard2.setGuard(guard1); - assertTrue(controlLoopGuard1.equals(controlLoopGuard2)); - assertEquals(controlLoopGuard1.hashCode(), controlLoopGuard2.hashCode()); - - controlLoopGuard1.setGuards(guardPolicies); - assertFalse(controlLoopGuard1.equals(controlLoopGuard2)); - controlLoopGuard2.setGuards(guardPolicies); - assertTrue(controlLoopGuard1.equals(controlLoopGuard2)); - assertEquals(controlLoopGuard1.hashCode(), controlLoopGuard2.hashCode()); - } - - @Test - public void testEqualsSameObject() { - ControlLoopGuard controlLoopGuard = new ControlLoopGuard(); - assertTrue(controlLoopGuard.equals(controlLoopGuard)); - } - - @Test - public void testEqualsNull() { - ControlLoopGuard controlLoopGuard = new ControlLoopGuard(); - assertFalse(controlLoopGuard.equals(null)); - } - - @Test - public void testEqualsInstanceOfDiffClass() { - ControlLoopGuard controlLoopGuard = new ControlLoopGuard(); - assertFalse(controlLoopGuard.equals("")); - } - - /** - * Does the actual test. - * - * @param testFile input file - */ - public void test(String testFile) { - try (InputStream is = new FileInputStream(new File(testFile))) { - // - // Read the yaml into our Java Object - // - Yaml yaml = new Yaml(new Constructor(ControlLoopGuard.class)); - Object obj = yaml.load(is); - assertNotNull(obj); - assertTrue(obj instanceof ControlLoopGuard); - dump(obj); - // - // Now dump it to a yaml string - // - DumperOptions options = new DumperOptions(); - options.setDefaultFlowStyle(FlowStyle.BLOCK); - options.setPrettyFlow(true); - yaml = new Yaml(options); - String dumpedYaml = yaml.dump(obj); - logger.debug(dumpedYaml); - // - // Read that string back into our java object - // - Object newObject = yaml.load(dumpedYaml); - dump(newObject); - assertNotNull(newObject); - assertTrue(newObject instanceof ControlLoopGuard); - // - // Have to comment it out tentatively since it causes junit to fail. - // Seems we cannot use assertEquals here. Need advice. - // - //assertEquals(newObject, obj); - } catch (FileNotFoundException e) { - fail(e.getLocalizedMessage()); - } catch (IOException e) { - fail(e.getLocalizedMessage()); - } - } - - public void dump(Object obj) { - logger.debug("Dumping {}", obj.getClass().getCanonicalName()); - logger.debug("{}", obj); - } -} diff --git a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/GuardPolicyTest.java b/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/GuardPolicyTest.java deleted file mode 100644 index 7019595b3..000000000 --- a/controlloop/common/policy-yaml/src/test/java/org/onap/policy/controlloop/policy/guard/GuardPolicyTest.java +++ /dev/null @@ -1,271 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 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.controlloop.policy.guard; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.LinkedList; -import java.util.List; - -import org.junit.Test; - -public class GuardPolicyTest { - - @Test - public void testConstructor() { - GuardPolicy guardPolicy = new GuardPolicy(); - - assertNotNull(guardPolicy.getId()); - assertNull(guardPolicy.getName()); - assertNull(guardPolicy.getDescription()); - assertNull(guardPolicy.getMatch_parameters()); - assertNull(guardPolicy.getLimit_constraints()); - } - - @Test - public void testConstructorString() { - String id = "guard id"; - GuardPolicy guardPolicy = new GuardPolicy(id); - - assertEquals(id, guardPolicy.getId()); - assertNull(guardPolicy.getName()); - assertNull(guardPolicy.getDescription()); - assertNull(guardPolicy.getMatch_parameters()); - assertNull(guardPolicy.getLimit_constraints()); - } - - @Test - public void testConstructorStringStringStringMatchParameters() { - String id = "guard id"; - String name = "guard name"; - String description = "guard description"; - MatchParameters matchParameters = new MatchParameters(); - List<Constraint> limitConstraints = new LinkedList<>(); - limitConstraints.add(new Constraint()); - GuardPolicy guardPolicy = new GuardPolicy(id, name, description, matchParameters); - - assertNotNull(guardPolicy.getId()); - assertEquals(name, guardPolicy.getName()); - assertEquals(description, guardPolicy.getDescription()); - assertEquals(matchParameters, guardPolicy.getMatch_parameters()); - assertNull(guardPolicy.getLimit_constraints()); - } - - @Test - public void testConstructorStringMatchParametersList() { - String name = "guard name"; - MatchParameters matchParameters = new MatchParameters(); - List<Constraint> limitConstraints = new LinkedList<>(); - limitConstraints.add(new Constraint()); - GuardPolicy guardPolicy = new GuardPolicy(name, matchParameters, limitConstraints); - - assertNotNull(guardPolicy.getId()); - assertEquals(name, guardPolicy.getName()); - assertNull(guardPolicy.getDescription()); - assertEquals(matchParameters, guardPolicy.getMatch_parameters()); - assertEquals(limitConstraints, guardPolicy.getLimit_constraints()); - } - - @Test - public void testConstructorStringStringMatchParametersList() { - String name = "guard name"; - String description = "guard description"; - MatchParameters matchParameters = new MatchParameters(); - List<Constraint> limitConstraints = new LinkedList<>(); - limitConstraints.add(new Constraint()); - GuardPolicy guardPolicy = new GuardPolicy(name, description, matchParameters, limitConstraints); - - assertNotNull(guardPolicy.getId()); - assertEquals(name, guardPolicy.getName()); - assertEquals(description, guardPolicy.getDescription()); - assertEquals(matchParameters, guardPolicy.getMatch_parameters()); - assertEquals(limitConstraints, guardPolicy.getLimit_constraints()); - } - - @Test - public void testConstructorStringStringStringMatchParametersList() { - String id = "guard id"; - String name = "guard name"; - String description = "guard description"; - MatchParameters matchParameters = new MatchParameters(); - List<Constraint> limitConstraints = new LinkedList<>(); - limitConstraints.add(new Constraint()); - GuardPolicy guardPolicy = new GuardPolicy(id, name, description, matchParameters, limitConstraints); - - assertEquals(id, guardPolicy.getId()); - assertEquals(name, guardPolicy.getName()); - assertEquals(description, guardPolicy.getDescription()); - assertEquals(matchParameters, guardPolicy.getMatch_parameters()); - assertEquals(limitConstraints, guardPolicy.getLimit_constraints()); - } - - @Test - public void testConstructorGuardPolicy() { - String id = "guard id"; - String name = "guard name"; - String description = "guard description"; - MatchParameters matchParameters = new MatchParameters(); - List<Constraint> limitConstraints = new LinkedList<>(); - limitConstraints.add(new Constraint()); - GuardPolicy guardPolicy1 = new GuardPolicy(id, name, description, matchParameters, limitConstraints); - - GuardPolicy guardPolicy2 = new GuardPolicy(guardPolicy1); - - - assertEquals(id, guardPolicy2.getId()); - assertEquals(name, guardPolicy2.getName()); - assertEquals(description, guardPolicy2.getDescription()); - assertEquals(matchParameters, guardPolicy2.getMatch_parameters()); - assertEquals(limitConstraints, guardPolicy2.getLimit_constraints()); - } - - @Test - public void testSetAndGetId() { - String id = "guard id"; - GuardPolicy guardPolicy = new GuardPolicy(); - guardPolicy.setId(id); - assertEquals(id, guardPolicy.getId()); - } - - @Test - public void testSetAndGetName() { - String name = "guard name"; - GuardPolicy guardPolicy = new GuardPolicy(); - guardPolicy.setName(name); - assertEquals(name, guardPolicy.getName()); - } - - @Test - public void testSetAndGetDescription() { - String description = "guard description"; - GuardPolicy guardPolicy = new GuardPolicy(); - guardPolicy.setDescription(description); - assertEquals(description, guardPolicy.getDescription()); - } - - @Test - public void testSetAndGetMatchParameters() { - MatchParameters matchParameters = new MatchParameters(); - GuardPolicy guardPolicy = new GuardPolicy(); - guardPolicy.setMatch_parameters(matchParameters); - assertEquals(matchParameters, guardPolicy.getMatch_parameters()); - } - - @Test - public void testSetAndGetLimitConstraints() { - LinkedList<Constraint> limitConstraints = new LinkedList<>(); - limitConstraints.add(new Constraint()); - GuardPolicy guardPolicy = new GuardPolicy(); - guardPolicy.setLimit_constraints(limitConstraints); - assertEquals(limitConstraints, guardPolicy.getLimit_constraints()); - } - - @Test - public void testIsValid() { - GuardPolicy guardPolicy = new GuardPolicy(); - assertFalse(guardPolicy.isValid()); - - guardPolicy.setName("guard name"); - assertTrue(guardPolicy.isValid()); - - guardPolicy.setId(null); - assertFalse(guardPolicy.isValid()); - } - - @Test - public void testToString() { - String id = "guard id"; - String name = "guard name"; - String description = "guard description"; - MatchParameters matchParameters = new MatchParameters(); - List<Constraint> limitConstraints = new LinkedList<>(); - limitConstraints.add(new Constraint()); - GuardPolicy guardPolicy = new GuardPolicy(id, name, description, matchParameters, limitConstraints); - - assertEquals(guardPolicy.toString(), "Policy [id=guard id, name=guard name, description=guard description, " - + "match_parameters=MatchParameters [controlLoopName=null, actor=null, recipe=null, targets=null], " - + "limitConstraints=[Constraint [freq_limit_per_target=null, time_window=null, active_time_range=null," - + " blacklist=null]]]", - guardPolicy.toString()); - } - - @Test - public void testEquals() { - final String id = "guard id"; - final String name = "guard name"; - final String description = "guard description"; - GuardPolicy guardPolicy1 = new GuardPolicy(id); - GuardPolicy guardPolicy2 = new GuardPolicy(); - assertFalse(guardPolicy1.equals(guardPolicy2)); - - guardPolicy2.setId(id); - assertTrue(guardPolicy1.equals(guardPolicy2)); - assertEquals(guardPolicy1.hashCode(), guardPolicy2.hashCode()); - - guardPolicy1.setName(name); - assertFalse(guardPolicy1.equals(guardPolicy2)); - guardPolicy2.setName(name); - assertTrue(guardPolicy1.equals(guardPolicy2)); - assertEquals(guardPolicy1.hashCode(), guardPolicy2.hashCode()); - - guardPolicy1.setDescription(description); - assertFalse(guardPolicy1.equals(guardPolicy2)); - guardPolicy2.setDescription(description); - assertTrue(guardPolicy1.equals(guardPolicy2)); - assertEquals(guardPolicy1.hashCode(), guardPolicy2.hashCode()); - - MatchParameters matchParameters = new MatchParameters(); - guardPolicy1.setMatch_parameters(matchParameters); - assertFalse(guardPolicy1.equals(guardPolicy2)); - guardPolicy2.setMatch_parameters(matchParameters); - assertTrue(guardPolicy1.equals(guardPolicy2)); - assertEquals(guardPolicy1.hashCode(), guardPolicy2.hashCode()); - - LinkedList<Constraint> limitConstraints = new LinkedList<>(); - limitConstraints.add(new Constraint()); - guardPolicy1.setLimit_constraints(limitConstraints); - assertFalse(guardPolicy1.equals(guardPolicy2)); - guardPolicy2.setLimit_constraints(limitConstraints); - assertTrue(guardPolicy1.equals(guardPolicy2)); - assertEquals(guardPolicy1.hashCode(), guardPolicy2.hashCode()); - } - - @Test - public void testEqualsSameObject() { - GuardPolicy guardPolicy = new GuardPolicy(); - assertTrue(guardPolicy.equals(guardPolicy)); - } - - @Test - public void testEqualsNull() { - GuardPolicy guardPolicy = new GuardPolicy(); - assertFalse(guardPolicy.equals(null)); - } - - @Test - public void testEqualsInstanceOfDiffClass() { - GuardPolicy guardPolicy = new GuardPolicy(); - assertFalse(guardPolicy.equals("")); - } -} diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_control_loop_no_control_loop_name.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_control_loop_no_control_loop_name.yaml deleted file mode 100644 index 950052a25..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_control_loop_no_control_loop_name.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2018 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. -controlLoop: - controlLoopName: - version: 1.0.0 - services: - - serviceName: Foo Service - resources: - - resourceName: Bar VNF - resourceType: VF - trigger_policy: unique-policy-id-1-restart - timeout: 1200 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy for Trigger Event - description: - actor: APPC - recipe: Restart - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_failure_connected_to_unknown_policy.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_failure_connected_to_unknown_policy.yaml deleted file mode 100644 index 66d0dfc17..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_failure_connected_to_unknown_policy.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2018 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. -controlLoop: - controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 - version: 1.0.0 - services: - - serviceName: Foo Service - resources: - - resourceName: Bar VNF - resourceType: VF - trigger_policy: unique-policy-id-1-restart - timeout: 1200 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy for Trigger Event - description: - actor: APPC - recipe: Restart - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - failure: unknown-policy diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_failure_exception_connected_to_unknown_policy.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_failure_exception_connected_to_unknown_policy.yaml deleted file mode 100644 index 5d6454511..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_failure_exception_connected_to_unknown_policy.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2018 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. -controlLoop: - controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 - version: 1.0.0 - services: - - serviceName: Foo Service - resources: - - resourceName: Bar VNF - resourceType: VF - trigger_policy: unique-policy-id-1-restart - timeout: 1200 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy for Trigger Event - description: - actor: APPC - recipe: Restart - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - failure_exception: unknown-policy diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_failure_guard_connected_to_unknown_policy.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_failure_guard_connected_to_unknown_policy.yaml deleted file mode 100644 index b09206ca4..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_failure_guard_connected_to_unknown_policy.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2018 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. -controlLoop: - controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 - version: 1.0.0 - services: - - serviceName: Foo Service - resources: - - resourceName: Bar VNF - resourceType: VF - trigger_policy: unique-policy-id-1-restart - timeout: 1200 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy for Trigger Event - description: - actor: APPC - recipe: Restart - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - failure_guard: unknown-policy diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_failure_retries_connected_to_unknown_policy.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_failure_retries_connected_to_unknown_policy.yaml deleted file mode 100644 index c4bb6c52f..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_failure_retries_connected_to_unknown_policy.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2018 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. -controlLoop: - controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 - version: 1.0.0 - services: - - serviceName: Foo Service - resources: - - resourceName: Bar VNF - resourceType: VF - trigger_policy: unique-policy-id-1-restart - timeout: 1200 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy for Trigger Event - description: - actor: APPC - recipe: Restart - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - failure_retries: unknown-policy diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_failure_timeout_connected_to_unknown_policy.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_failure_timeout_connected_to_unknown_policy.yaml deleted file mode 100644 index 59d073e0b..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_failure_timeout_connected_to_unknown_policy.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2018 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. -controlLoop: - controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 - version: 1.0.0 - services: - - serviceName: Foo Service - resources: - - resourceName: Bar VNF - resourceType: VF - trigger_policy: unique-policy-id-1-restart - timeout: 1200 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy for Trigger Event - description: - actor: APPC - recipe: Restart - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - failure_timeout: unknown-policy diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_success_connected_to_unknown_policy.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_success_connected_to_unknown_policy.yaml deleted file mode 100644 index 803528380..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_policy_success_connected_to_unknown_policy.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2018 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. -controlLoop: - controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 - version: 1.0.0 - services: - - serviceName: Foo Service - resources: - - resourceName: Bar VNF - resourceType: VF - trigger_policy: unique-policy-id-1-restart - timeout: 1200 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy for Trigger Event - description: - actor: APPC - recipe: Restart - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - success: unknown-policy diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_trigger_1.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_trigger_1.yaml deleted file mode 100644 index 4ab910ba4..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_trigger_1.yaml +++ /dev/null @@ -1,108 +0,0 @@ -# Copyright 2018 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. -controlLoop: - controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 - version: 1.0.0 - services: - - serviceName: Foo Service - resources: - - resourceName: Bar VNF - resourceType: VF - trigger_policy: FOO - timeout: 1200 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy for Trigger Event - description: - actor: APPC - recipe: Restart - target: VM - retry: 2 - timeout: 300 - success: unique-policy-id-2-healthcheck-restart - failure: unique-policy-id-3-rebuild - failure_timeout: unique-policy-id-3-rebuild - failure_retries: unique-policy-id-3-rebuild - failure_exception: final_failure_exception - - - id: unique-policy-id-2-healthcheck-restart - name: HealthCheck Policy - description: - actor: APPC - recipe: HealthCheck - target: VM - retry: 2 - timeout: 300 - success: final_success - failure: unique-policy-id-3-rebuild - failure_timeout: unique-policy-id-3-rebuild - failure_retries: unique-policy-id-3-rebuild - failure_exception: final_failure_exception - - - id: unique-policy-id-3-rebuild - name: Rebuild Policy - description: - actor: APPC - recipe: Rebuild - target: VM - retry: 0 - timeout: 600 - success: unique-policy-id-4-healthcheck-rebuild - failure: unique-policy-id-5-migrate - failure_timeout: unique-policy-id-5-migrate - failure_retries: unique-policy-id-5-migrate - failure_exception: final_failure_exception - - - id: unique-policy-id-4-healthcheck-rebuild - name: HealthCheck the Rebuild Policy - description: - actor: APPC - recipe: HealthCheck - target: VM - retry: 2 - timeout: 300 - success: final_success - failure: unique-policy-id-5-migrate - failure_timeout: unique-policy-id-5-migrate - failure_retries: unique-policy-id-5-migrate - failure_exception: final_failure_exception - - - id: unique-policy-id-5-migrate - name: Migrate Policy - description: - actor: APPC - recipe: Migrate - target: VM - retry: 0 - timeout: 600 - success: unique-policy-id-6-healthcheck-migrate - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception - - - id: unique-policy-id-6-healthcheck-migrate - name: Healthcheck the Migrate Policy - description: - actor: APPC - recipe: HealthCheck - target: VM - retry: 2 - timeout: 300 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_trigger_2.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_trigger_2.yaml deleted file mode 100644 index 4f6fbb86f..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_trigger_2.yaml +++ /dev/null @@ -1,108 +0,0 @@ -# Copyright 2018 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. -controlLoop: - controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 - version: 1.0.0 - services: - - serviceName: Foo Service - resources: - - resourceName: Bar VNF - resourceType: VF - trigger_policy: FINAL_SUCCESS - timeout: 1200 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy for Trigger Event - description: - actor: APPC - recipe: Restart - target: VM - retry: 2 - timeout: 300 - success: unique-policy-id-2-healthcheck-restart - failure: unique-policy-id-3-rebuild - failure_timeout: unique-policy-id-3-rebuild - failure_retries: unique-policy-id-3-rebuild - failure_exception: final_failure_exception - - - id: unique-policy-id-2-healthcheck-restart - name: HealthCheck Policy - description: - actor: APPC - recipe: HealthCheck - target: VM - retry: 2 - timeout: 300 - success: final_success - failure: unique-policy-id-3-rebuild - failure_timeout: unique-policy-id-3-rebuild - failure_retries: unique-policy-id-3-rebuild - failure_exception: final_failure_exception - - - id: unique-policy-id-3-rebuild - name: Rebuild Policy - description: - actor: APPC - recipe: Rebuild - target: VM - retry: 0 - timeout: 600 - success: unique-policy-id-4-healthcheck-rebuild - failure: unique-policy-id-5-migrate - failure_timeout: unique-policy-id-5-migrate - failure_retries: unique-policy-id-5-migrate - failure_exception: final_failure_exception - - - id: unique-policy-id-4-healthcheck-rebuild - name: HealthCheck the Rebuild Policy - description: - actor: APPC - recipe: HealthCheck - target: VM - retry: 2 - timeout: 300 - success: final_success - failure: unique-policy-id-5-migrate - failure_timeout: unique-policy-id-5-migrate - failure_retries: unique-policy-id-5-migrate - failure_exception: final_failure_exception - - - id: unique-policy-id-5-migrate - name: Migrate Policy - description: - actor: APPC - recipe: Migrate - target: VM - retry: 0 - timeout: 600 - success: unique-policy-id-6-healthcheck-migrate - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception - - - id: unique-policy-id-6-healthcheck-migrate - name: Healthcheck the Migrate Policy - description: - actor: APPC - recipe: HealthCheck - target: VM - retry: 2 - timeout: 300 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_trigger_no_trigger_id.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_trigger_no_trigger_id.yaml deleted file mode 100644 index 798e869ce..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/bad_trigger_no_trigger_id.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2018 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. -controlLoop: - controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 - version: 1.0.0 - services: - - serviceName: Foo Service - resources: - - resourceName: Bar VNF - resourceType: VF - trigger_policy: - timeout: 1200 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy for Trigger Event - description: - actor: APPC - recipe: Restart - target: VM - retry: 2 - timeout: 300 - diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/empty.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/empty.yaml deleted file mode 100644 index 6034d661a..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/empty.yaml +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2018 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. diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/policy_OpenLoop.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/policy_OpenLoop.yaml deleted file mode 100644 index a27071df8..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/policy_OpenLoop.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2018 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. -controlLoop: - version: 1.0.0 - controlLoopName: ControlLoop-Open-fac4ae3d-c3f5-4bab-8e54-0a8581ede132 - services: - - serviceName: Service - resources: - - resourceType: VF - resourceName: Example - trigger_policy: final_openloop - timeout: 0 - -policies: diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/policy_Test.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/policy_Test.yaml deleted file mode 100644 index 723954cdb..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/policy_Test.yaml +++ /dev/null @@ -1,108 +0,0 @@ -# Copyright 2018 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. -controlLoop: - controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 - version: 1.0.0 - services: - - serviceName: Foo Service - resources: - - resourceName: Bar VNF - resourceType: VF - trigger_policy: unique-policy-id-1-restart - timeout: 1200 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy for Trigger Event - description: - actor: APPC - recipe: Restart - target: VM - retry: 2 - timeout: 300 - success: unique-policy-id-2-healthcheck-restart - failure: unique-policy-id-3-rebuild - failure_timeout: unique-policy-id-3-rebuild - failure_retries: unique-policy-id-3-rebuild - failure_exception: final_failure_exception - - - id: unique-policy-id-2-healthcheck-restart - name: HealthCheck Policy - description: - actor: APPC - recipe: HealthCheck - target: VM - retry: 2 - timeout: 300 - success: final_success - failure: unique-policy-id-3-rebuild - failure_timeout: unique-policy-id-3-rebuild - failure_retries: unique-policy-id-3-rebuild - failure_exception: final_failure_exception - - - id: unique-policy-id-3-rebuild - name: Rebuild Policy - description: - actor: APPC - recipe: Rebuild - target: VM - retry: 0 - timeout: 600 - success: unique-policy-id-4-healthcheck-rebuild - failure: unique-policy-id-5-migrate - failure_timeout: unique-policy-id-5-migrate - failure_retries: unique-policy-id-5-migrate - failure_exception: final_failure_exception - - - id: unique-policy-id-4-healthcheck-rebuild - name: HealthCheck the Rebuild Policy - description: - actor: APPC - recipe: HealthCheck - target: VM - retry: 2 - timeout: 300 - success: final_success - failure: unique-policy-id-5-migrate - failure_timeout: unique-policy-id-5-migrate - failure_retries: unique-policy-id-5-migrate - failure_exception: final_failure_exception - - - id: unique-policy-id-5-migrate - name: Migrate Policy - description: - actor: APPC - recipe: Migrate - target: VM - retry: 0 - timeout: 600 - success: unique-policy-id-6-healthcheck-migrate - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception - - - id: unique-policy-id-6-healthcheck-migrate - name: Healthcheck the Migrate Policy - description: - actor: APPC - recipe: HealthCheck - target: VM - retry: 2 - timeout: 300 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/policy_vService.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/policy_vService.yaml deleted file mode 100644 index 8611c83aa..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/policy_vService.yaml +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2018 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. -controlLoop: - version: 1.0.0 - controlLoopName: ControlLoop-vUSP-vCTS-cbed919f-2212-4ef7-8051-fe6308da1bda - services: - - serviceName: vUSP - resources: - - resourceName: vCTS - resourceType: VF - - resourceName: vCOM - resourceType: VF - - resourceName: vRAR - resourceType: VF - - resourceName: vLCS - resourceType: VF - - resourceName: v3CB - resourceType: VF - trigger_policy: unique-policy-id-1-restart - timeout: 1200 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy - description: - actor: APPC - recipe: Restart - target: VM - retry: 2 - timeout: 300 - success: final_success - failure: unique-policy-id-2-rebuild - failure_timeout: unique-policy-id-2-rebuild - failure_retries: unique-policy-id-2-rebuild - failure_exception: final_failure_exception - - - id: unique-policy-id-2-rebuild - name: Rebuild Policy - description: - actor: APPC - recipe: Rebuild - target: VM - retry: 0 - timeout: 600 - success: final_success - failure: unique-policy-id-3-migrate - failure_timeout: unique-policy-id-3-migrate - failure_retries: unique-policy-id-3-migrate - failure_exception: final_failure_exception - - - id: unique-policy-id-3-migrate - name: Migrate Policy - description: - actor: APPC - recipe: Migrate - target: VM - retry: 0 - timeout: 600 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/test.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/test.yaml deleted file mode 100644 index d6348f5e0..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/test.yaml +++ /dev/null @@ -1,317 +0,0 @@ -# Copyright 2018 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. -controlLoop: - controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 - version: 1.0.0 - services: - - serviceName: Foo Service - resources: - - resourceName: Bar VNF - resourceType: VF - trigger_policy: unique-policy-id-1-restart - timeout: 1200 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy for Trigger Event - description: - actor: APPC - recipe: Restart - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - success: unique-policy-id-2-modifyconfig - failure: unique-policy-id-3-rebuild - failure_timeout: unique-policy-id-3-rebuild - failure_retries: unique-policy-id-3-rebuild - failure_exception: unique-policy-id-7-modifyconfig-for-failure - failure_guard: unique-policy-id-7-modifyconfig-for-failure - - - id: unique-policy-id-2-modifyconfig - name: ModifyConfig Policy - description: - actor: APPC - recipe: ModifyConfig - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - success: FINAL_SUCCESS - failure: unique-policy-id-3-rebuild - failure_timeout: unique-policy-id-3-rebuild - failure_retries: unique-policy-id-3-rebuild - failure_exception: FINAL_FAILURE_EXCEPTION - - - id: unique-policy-id-3-rebuild - name: Rebuild Policy - description: - actor: APPC - recipe: Rebuild - target: - type: VM - resourceID: vm1 - retry: 0 - timeout: 600 - success: unique-policy-id-4-modifyconfig - failure: unique-policy-id-5-migrate - failure_timeout: unique-policy-id-5-migrate - failure_retries: unique-policy-id-5-migrate - failure_exception: FINAL_FAILURE_EXCEPTION - - - id: unique-policy-id-4-modifyconfig - name: HealthCheck the Rebuild Policy - description: - actor: APPC - recipe: ModifyConfig - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - success: FINAL_SUCCESS - failure: unique-policy-id-5-migrate - failure_timeout: unique-policy-id-5-migrate - failure_retries: unique-policy-id-5-migrate - failure_exception: FINAL_FAILURE_EXCEPTION - - - id: unique-policy-id-5-migrate - name: Migrate Policy - description: - actor: APPC - recipe: Migrate - target: - type: VM - resourceID: vm1 - retry: 0 - timeout: 600 - success: unique-policy-id-6-modifyconfig - failure: FINAL_FAILURE - failure_timeout: FINAL_FAILURE_TIMEOUT - failure_retries: FINAL_FAILURE_RETRIES - failure_exception: FINAL_FAILURE_EXCEPTION - - - id: unique-policy-id-6-modifyconfig - name: ModifyConfig after Migrate Policy - description: - actor: APPC - recipe: ModifyConfig - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - success: FINAL_SUCCESS - failure: FINAL_FAILURE - failure_timeout: FINAL_FAILURE_TIMEOUT - failure_retries: FINAL_FAILURE_RETRIES - failure_exception: FINAL_FAILURE_EXCEPTION - - - id: unique-policy-id-7-modifyconfig-for-failure - name: ModifyConfig for Failure - description: - actor: APPC - recipe: ModifyConfig - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - success: FINAL_SUCCESS - failure: FINAL_FAILURE - failure_timeout: FINAL_FAILURE_TIMEOUT - failure_retries: FINAL_FAILURE_RETRIES - failure_exception: FINAL_FAILURE_EXCEPTION - - - id: - name: invalid policy - id is null - description: - actor: APPC - recipe: ModifyConfig - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - success: FINAL_SUCCESS - - - id: SUCCESS - name: invalid policy - id is a PolicyResult - description: - actor: APPC - recipe: ModifyConfig - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - success: FINAL_SUCCESS - - - id: FINAL_SUCCESS - name: invalid policy - id is a FinalResult - description: - actor: APPC - recipe: ModifyConfig - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - success: FINAL_SUCCESS - - - id: invalid-policy-null-actor - name: invalid policy - actor is null - description: - actor: - recipe: ModifyConfig - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - success: FINAL_SUCCESS - - - id: invalid-policy-unknown-actor - name: invalid policy - actor is unknown - description: - actor: UnknownActor - recipe: ModifyConfig - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - success: FINAL_SUCCESS - - - id: invalid-policy-null-receipe - name: invalid policy - receipe is null - description: - actor: APPC - recipe: - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - success: FINAL_SUCCESS - - - id: invalid-policy-unknown-receipe - name: invalid policy - unknown receipe - description: - actor: APPC - recipe: UnknownReceipe - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - success: FINAL_SUCCESS - - - id: invalid-policy-null-target - name: invalid policy - target is null - description: - actor: APPC - recipe: ModifyConfig - target: - retry: 2 - timeout: 300 - success: FINAL_SUCCESS - - - id: invalid-policy-null-target-type - name: invalid policy - target type is null - description: - actor: APPC - recipe: ModifyConfig - target: - type: - resourceID: vm1 - retry: 2 - timeout: 300 - success: FINAL_SUCCESS - - - id: invalid-policy-invalid-success-policy - name: invalid policy - success policy is invalid - description: - actor: APPC - recipe: ModifyConfig - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - success: FINAL_FAILURE - - - id: invalid-policy-invalid-failure-policy - name: invalid policy - failure policy is invalid - description: - actor: APPC - recipe: ModifyConfig - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - failure: FINAL_FAILURE_TIMEOUT - - - id: invalid-policy-invalid-failure-timeout-policy - name: invalid policy - failure timeout policy is invalid - description: - actor: APPC - recipe: ModifyConfig - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - failure_timeout: FINAL_FAILURE_RETRIES - - - id: invalid-policy-invalid-failure-retries-policy - name: invalid policy - failure retries policy is invalid - description: - actor: APPC - recipe: ModifyConfig - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - failure_retries: FINAL_FAILURE_EXCEPTION - - - id: invalid-policy-invalid-failure-exception-policy - name: invalid policy - failure exception policy is invalid - description: - actor: APPC - recipe: ModifyConfig - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - failure_exception: FINAL_FAILURE_GUARD - - - id: invalid-policy-invalid-failure-guard-policy - name: invalid policy - failure guard policy is invalid - description: - actor: APPC - recipe: ModifyConfig - target: - type: VM - resourceID: vm1 - retry: 2 - timeout: 300 - failure_guard: FINAL_SUCCESS - - diff --git a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/test_evil.yaml b/controlloop/common/policy-yaml/src/test/resources/v1.0.0/test_evil.yaml deleted file mode 100644 index f964619c8..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v1.0.0/test_evil.yaml +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2018 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. -controlLoop: - controlLoopName: ControlLoop-TEST-5dfa8fce-bd7a-4424-b60d-ee2ad2f254a3 - version: 1.0.0 - services: - - serviceName: Foo Service - resources: - - resourceName: Bar VNF - resourceType: VF - trigger_policy: unique-policy-id-1-restart - timeout: 1200 - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy for Trigger Event - description: - actor: MSO - recipe: Instantiate - target: VM - retry: 2 - timeout: 300 - success: final_failure_exception - failure: final_success - failure_timeout: final_success - failure_retries: final_success - failure_exception: final_failure_exception diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/duplicate_guard_constraint.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/duplicate_guard_constraint.yaml deleted file mode 100644 index b0550f295..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/duplicate_guard_constraint.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2018 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. -guard: - version: 2.0.0 - -guards: - - id: unique_guard_vUSP_1 - name: APPC 5 Restart - description: - We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am) - actor: APPC - recipe: Restart - limit_constraints: - # - - num: 5 - time_in_range: - arg2: PT5H - arg3: PT24H - # - - num: 5 - time_in_range: - arg2: PT5H - arg3: PT24H
\ No newline at end of file diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/duplicate_guard_policy.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/duplicate_guard_policy.yaml deleted file mode 100644 index 522737981..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/duplicate_guard_policy.yaml +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2018 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. -guard: - version: 2.0.0 - -guards: - - id: unique_guard_vUSP_1 - name: APPC 5 Restart - description: - We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am) - actor: APPC - recipe: Restart - limit_constraints: - - num: 5 - time_in_range: - arg2: PT5H - arg3: PT24H - # - - id: unique_guard_vUSP_1 - name: APPC 5 Restart - description: - We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am) - actor: APPC - recipe: Restart - limit_constraints: - - num: 5 - time_in_range: - arg2: PT5H - arg3: PT24H
\ No newline at end of file diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/no_guard_constraint.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/no_guard_constraint.yaml deleted file mode 100644 index 75860bae7..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/no_guard_constraint.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2018 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. -guard: - version: 2.0.0 - -guards: - - id: unique_guard_vUSP_1 - name: APPC 5 Restart - description: - We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am) - actor: APPC - recipe: Restart -
\ No newline at end of file diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/no_guard_policy.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/no_guard_policy.yaml deleted file mode 100644 index 8431e5c30..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/no_guard_policy.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2018 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. -guard: - version: 2.0.0 diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml deleted file mode 100644 index 25290c323..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2018 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. -guard: - version: 2.0.0 - -guards: - - id: unique_guard_ONAP_vDNS_1 - name: MSO Spinup - description: We only spin up 1 instance over a 10 minute window - match_parameters: - actor: MSO - recipe: VF Module Create - limit_constraints: - - freq_limit_per_target: 1 - # - # https://www.w3.org/TR/xmlschema-2/#duration - # - time_window: - value: 10 - units: hour -
\ No newline at end of file diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml deleted file mode 100644 index 3eb615535..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_appc_restart.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2018 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. -guard: - version: 2.0.0 - -guards: - - id: unique_guard_1 - name: APPC 5 Restart - description: - We only allow 5 restarts over 15 minute window during the day time hours (i.e. avoid midnight to 5am) - match_parameters: - controlLoopName: CL_NAME_ABC_123 - actor: APPC - recipe: Restart - targets: - - s1 - s2 - s3 - limit_constraints: - - freq_limit_per_target: 5 - time_window: - value: 15 - units: minute - active_time_range: - start: 00:00:00-05:00 - end: 23:59:59-05:00
\ No newline at end of file diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_blacklist.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_blacklist.yaml deleted file mode 100644 index 3b267e955..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0-guard/policy_guard_blacklist.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2018 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. -guard: - version: 2.0.0 - -guards: - - id: unique_guard_vService_blacklist - name: APPC Restart Blacklist - description: | - We deny restart of the blacklisted targets (avoid midnight to 5am) - actor: APPC - recipe: Restart - limit_constraints: - - blacklist: - - TargetName1 - - TargetName2 - time_in_range: - arg2: 00:00:00-05:00 - arg3: 23:59:59-05:00
\ No newline at end of file diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/resource-59a2ee3fB58045feB5a1-template.yml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/resource-59a2ee3fB58045feB5a1-template.yml deleted file mode 100644 index 4b501953c..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/resource-59a2ee3fB58045feB5a1-template.yml +++ /dev/null @@ -1,1698 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_0 -metadata: - invariantUUID: 4b8d4018-068b-4c33-b9bb-d980798e52c2 - UUID: d7d28881-b24d-4512-bfee-1e2eb335591f - name: 59a2ee3f-b580-45fe-b5a1 - description: vendor software product - type: VF - category: Generic - subcategory: Abstract - resourceVendor: 185c637a-3885-463e-8fd0 - resourceVendorRelease: '1.0' -imports: -- NeutronNet: - file: resource-Neutronnet-template.yml -- NeutronPort: - file: resource-Neutronport-template.yml -- 59a2ee3fB58045feB5a1.nodes.heat.vlb: - file: resource-59a2ee3fb58045feb5a1NodesHeatVlb-template.yml -- 59a2ee3fB58045feB5a1.nodes.heat.vdns: - file: resource-59a2ee3fb58045feb5a1NodesHeatVdns-template.yml -topology_template: - inputs: - vf_module_id: - type: string - description: The vLoadBalancer Module ID is provided by ONAP - onap_private_subnet_id: - type: string - description: Private sub-network that connects ONAP component and the VNF - repo_url_blob: - type: string - description: URL of the repository that hosts the demo packages - vlb_private_net_cidr: - type: string - description: The CIDR of the vLoadBalancer private network - vlb_private_net_id: - type: string - description: Private network that connects vLoadBalancer with vDNSs - public_net_id: - type: string - default: 00000000-0000-0000-0000-000000000000 - description: Public network that enables remote connection to VNF - demo_artifacts_version: - type: string - description: Artifacts (jar, tar.gz) version used in demo vnfs - onap_private_net_id: - type: string - description: Private network that connects ONAP component and the VNF - pub_key: - type: string - description: Public key to be installed on the compute instance - vlb_private_ip_1: - type: string - description: Private IP address that is assigned to the vLoadBalancer to communicate with ONAP components - key_name: - type: string - description: Public/Private key pair name - vdns_name_0: - type: string - description: Name of the vDNS - repo_url_artifacts: - type: string - description: URL of the repository that hosts the demo packages - vlb_name_0: - type: string - description: Name of the vLoadBalancer - vdns_private_ip_0: - type: string - description: Private IP address that is assigned to the vDNS to communicate with the vLoadBalancer - vnf_id: - type: string - description: The VNF ID is provided by ONAP - dcae_collector_ip: - type: string - description: IP address of the DCAE collector - vdns_private_ip_1: - type: string - description: Private IP address that is assigned to the vDNS to communicate with ONAP components - dcae_collector_port: - type: string - description: Port of the DCAE collector - vlb_image_name: - type: string - default: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM) - description: Image to be used for compute instance - vlb_flavor_name: - type: string - default: 4 GB General Purpose v1 - description: Type of instance (flavor) to be used - vlb_private_ip_0: - type: string - description: Private IP address that is assigned to the vLoadBalancer to communicate with the vDNSs - onap_private_net_cidr: - type: string - description: The CIDR of the protected private network - node_templates: - vdns_private_1_port: - type: org.onap.resource.cp.nodes.heat.network.neutron.Port - metadata: - invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 - UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 - version: '1.0' - name: NeutronPort - description: Represents a logical entity that associates between Compute and Network normative types. - type: CP - category: Generic - subcategory: Network Elements - properties: - fixed_ips: - - subnet: - get_input: onap_private_subnet_id - ip_address: - get_input: vdns_private_ip_1 - network: - get_input: onap_private_net_id - requirements: - - binding: - capability: tosca.capabilities.network.Bindable - node: vdns_0 - relationship: tosca.relationships.network.BindsTo - vlb_private_network: - type: org.onap.resource.vl.nodes.heat.network.neutron.Net - metadata: - invariantUUID: 2870cc3a-d6cd-4423-b7f6-2d63619b0eeb - UUID: b7e764ba-17f9-4f0a-ad29-29877766ef21 - version: '1.0' - name: NeutronNet - description: Represents a network service with optional subnets and advanced configurations. - type: VL - category: Generic - subcategory: Network Elements - properties: - network_name: - get_input: vlb_private_net_id - subnets: - vlb_private_subnet: - name: - get_input: vlb_private_net_id - cidr: - get_input: vlb_private_net_cidr - vlb_private_1_port: - type: org.onap.resource.cp.nodes.heat.network.neutron.Port - metadata: - invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 - UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 - version: '1.0' - name: NeutronPort - description: Represents a logical entity that associates between Compute and Network normative types. - type: CP - category: Generic - subcategory: Network Elements - properties: - fixed_ips: - - subnet: - get_input: onap_private_subnet_id - ip_address: - get_input: vlb_private_ip_1 - network: - get_input: onap_private_net_id - requirements: - - binding: - capability: tosca.capabilities.network.Bindable - node: vlb_0 - relationship: tosca.relationships.network.BindsTo - vdns_0: - type: org.onap.resource.vfc.59a2ee3fB58045feB5a1.abstact.nodes.heat.vdns - metadata: - invariantUUID: ee585c30-127b-492e-b2c1-871dc61d1dde - UUID: d816cb01-b5d0-4bbb-b614-f7c3e230ab19 - version: '1.0' - name: 59a2ee3fB58045feB5a1.nodes.heat.vdns - description: Not reusable inner VFC - type: VFC - category: Generic - subcategory: Abstract - properties: - key_name: UNSUPPORTED_RESOURCE_my_keypair - flavor: - get_input: vlb_flavor_name - image: - get_input: vlb_image_name - metadata: - vf_module_id: - get_input: vf_module_id - vnf_id: - get_input: vnf_id - user_data_format: RAW - name: - get_input: vdns_name_0 - vlb_private_0_port: - type: org.onap.resource.cp.nodes.heat.network.neutron.Port - metadata: - invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 - UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 - version: '1.0' - name: NeutronPort - description: Represents a logical entity that associates between Compute and Network normative types. - type: CP - category: Generic - subcategory: Network Elements - properties: - fixed_ips: - - subnet: vlb_private_network - ip_address: - get_input: vlb_private_ip_0 - network: vlb_private_network - requirements: - - link: - capability: tosca.capabilities.network.Linkable - node: vlb_private_network - relationship: tosca.relationships.network.LinksTo - - binding: - capability: tosca.capabilities.network.Bindable - node: vlb_0 - relationship: tosca.relationships.network.BindsTo - vdns_private_0_port: - type: org.onap.resource.cp.nodes.heat.network.neutron.Port - metadata: - invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 - UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 - version: '1.0' - name: NeutronPort - description: Represents a logical entity that associates between Compute and Network normative types. - type: CP - category: Generic - subcategory: Network Elements - properties: - fixed_ips: - - subnet: - get_input: vlb_private_net_id - ip_address: - get_input: vdns_private_ip_0 - network: - get_input: vlb_private_net_id - requirements: - - binding: - capability: tosca.capabilities.network.Bindable - node: vdns_0 - relationship: tosca.relationships.network.BindsTo - vlb_0: - type: org.onap.resource.vfc.59a2ee3fB58045feB5a1.abstact.nodes.heat.vlb - metadata: - invariantUUID: f7f1d745-cfb1-4aa9-83fc-31280d0ce513 - UUID: 1821f13e-411f-4b29-87a5-ae935897b2e1 - version: '1.0' - name: 59a2ee3fB58045feB5a1.nodes.heat.vlb - description: Not reusable inner VFC - type: VFC - category: Generic - subcategory: Abstract - properties: - key_name: UNSUPPORTED_RESOURCE_my_keypair - flavor: - get_input: vlb_flavor_name - image: - get_input: vlb_image_name - metadata: - vf_module_id: - get_input: vf_module_id - vnf_id: - get_input: vnf_id - user_data_format: RAW - name: - get_input: vlb_name_0 - groups: - base_vlb: - type: org.onap.groups.heat.HeatStack - members: - - vdns_private_1_port - - vlb_private_network - - vlb_private_1_port - - vdns_0 - - vlb_private_0_port - - vdns_private_0_port - - vlb_0 - metadata: - invariantUUID: 097f71b3-90a1-4064-bc83-f76bf30195fe - UUID: 4daf7600-0a06-4515-859a-c45ec11abd29 - version: '1' - name: base_vlb - 59a2ee3fB58045feB5a1..dnsscaling..module-1: - type: org.onap.groups.VfModule - members: - - vdns_private_1_port - - vdns_0 - - vdns_private_0_port - metadata: - vfModuleModelName: 59a2ee3fB58045feB5a1..dnsscaling..module-1 - vfModuleModelInvariantUUID: 395d61a9-309b-4c0f-a442-ca47903e231e - vfModuleModelUUID: 40846490-abf4-4e1d-8f1a-2286968fa231 - vfModuleModelVersion: '1' - properties: - vf_module_type: Expansion - vf_module_description: - volume_group: false - 59a2ee3fB58045feB5a1..base_vlb..module-0: - type: org.onap.groups.VfModule - members: - - vdns_private_1_port - - vlb_private_network - - vlb_private_1_port - - vdns_0 - - vlb_private_0_port - - vdns_private_0_port - - vlb_0 - metadata: - vfModuleModelName: 59a2ee3fB58045feB5a1..base_vlb..module-0 - vfModuleModelInvariantUUID: 5ae76f74-6324-4835-a86c-0c96d16afd38 - vfModuleModelUUID: 17c4f752-a3da-4f3d-9cc5-1c4d28e5442d - vfModuleModelVersion: '1' - properties: - vf_module_type: Base - vf_module_description: - volume_group: false - dnsscaling: - type: org.onap.groups.heat.HeatStack - members: - - vdns_private_1_port - - vdns_0 - - vdns_private_0_port - metadata: - invariantUUID: 7c2971fa-9369-4fed-a449-a5e21c022f97 - UUID: ae8c3b79-77d3-425a-8bab-6558007f8392 - version: '1' - name: dnsscaling - substitution_mappings: - node_type: org.onap.resource.vf.59a2ee3fB58045feB5a1 - capabilities: - vdns_0.memory: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM allocated to the instance - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vdns_0.memory.resident: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM used by the instance on the physical machine - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory.resident - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vdns_0.cpu: - type: org.onap.capabilities.metric.Ceilometer - description: CPU time used - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Cumulative - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ns - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vdns_0.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vdns_private_0_port.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vdns_0.host: - type: tosca.capabilities.Container - occurrences: - - 1 - - UNBOUNDED - valid_source_types: - - tosca.nodes.SoftwareComponent - properties: - num_cpus: - type: integer - required: false - disk_size: - type: scalar-unit.size - required: false - cpu_frequency: - type: scalar-unit.frequency - required: false - mem_size: - type: scalar-unit.size - required: false - vdns_0.endpoint: - type: tosca.capabilities.Endpoint.Admin - occurrences: - - 1 - - UNBOUNDED - properties: - port_name: - type: string - required: false - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - secure: - type: boolean - default: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - url_path: - type: string - required: false - vlb_private_1_port.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - vlb_0.memory: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM allocated to the instance - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vdns_private_1_port.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - vlb_0.scalable: - type: tosca.capabilities.Scalable - occurrences: - - 1 - - UNBOUNDED - properties: - max_instances: - type: integer - default: 1 - min_instances: - type: integer - default: 1 - default_instances: - type: integer - vlb_0.binding: - type: tosca.capabilities.network.Bindable - occurrences: - - 0 - - UNBOUNDED - vlb_0.vcpus: - type: org.onap.capabilities.metric.Ceilometer - description: Average disk latency - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ms - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: vcpus - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vlb_0.instance: - type: org.onap.capabilities.metric.Ceilometer - description: Existence of instance - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: instance - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: instance - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vdns_0.os: - type: tosca.capabilities.OperatingSystem - occurrences: - - 1 - - UNBOUNDED - properties: - distribution: - type: string - required: false - type: - type: string - required: false - version: - type: version - required: false - architecture: - type: string - required: false - vlb_private_0_port.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vlb_private_1_port.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vlb_0.cpu: - type: org.onap.capabilities.metric.Ceilometer - description: CPU time used - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Cumulative - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ns - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vdns_0.cpu.delta: - type: org.onap.capabilities.metric.Ceilometer - description: CPU time used since previous datapoint - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Delta - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ns - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu.delta - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vlb_0.memory.resident: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM used by the instance on the physical machine - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory.resident - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vdns_0.vcpus: - type: org.onap.capabilities.metric.Ceilometer - description: Average disk latency - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ms - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: vcpus - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vdns_0.memory.usage: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM used by the instance from the amount of its allocated memory - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory.usage - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vlb_0.cpu.delta: - type: org.onap.capabilities.metric.Ceilometer - description: CPU time used since previous datapoint - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Delta - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ns - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu.delta - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vdns_0.instance:type: - type: org.onap.capabilities.metric.Ceilometer - description: Existence of instance <type> (OpenStack types) - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: instance - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: instance:type - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vlb_0.os: - type: tosca.capabilities.OperatingSystem - occurrences: - - 1 - - UNBOUNDED - properties: - distribution: - type: string - required: false - type: - type: string - required: false - version: - type: version - required: false - architecture: - type: string - required: false - vlb_private_0_port.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - vlb_0.host: - type: tosca.capabilities.Container - occurrences: - - 1 - - UNBOUNDED - valid_source_types: - - tosca.nodes.SoftwareComponent - properties: - num_cpus: - type: integer - required: false - disk_size: - type: scalar-unit.size - required: false - cpu_frequency: - type: scalar-unit.frequency - required: false - mem_size: - type: scalar-unit.size - required: false - vlb_0.instance:type: - type: org.onap.capabilities.metric.Ceilometer - description: Existence of instance <type> (OpenStack types) - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: instance - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: instance:type - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vlb_private_network.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vdns_0.binding: - type: tosca.capabilities.network.Bindable - occurrences: - - 0 - - UNBOUNDED - vlb_private_network.link: - type: tosca.capabilities.network.Linkable - occurrences: - - 0 - - UNBOUNDED - vlb_0.cpu_util: - type: org.onap.capabilities.metric.Ceilometer - description: Average CPU utilization - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: '%' - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu_util - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vlb_0.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vdns_private_0_port.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - vdns_0.cpu_util: - type: org.onap.capabilities.metric.Ceilometer - description: Average CPU utilization - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: '%' - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu_util - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vdns_0.instance: - type: org.onap.capabilities.metric.Ceilometer - description: Existence of instance - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: instance - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: instance - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vlb_private_network.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - vdns_0.scalable: - type: tosca.capabilities.Scalable - occurrences: - - 1 - - UNBOUNDED - properties: - max_instances: - type: integer - default: 1 - min_instances: - type: integer - default: 1 - default_instances: - type: integer - vdns_private_1_port.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vlb_0.memory.usage: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM used by the instance from the amount of its allocated memory - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory.usage - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vlb_0.endpoint: - type: tosca.capabilities.Endpoint.Admin - occurrences: - - 1 - - UNBOUNDED - properties: - port_name: - type: string - required: false - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - secure: - type: boolean - default: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - url_path: - type: string - required: false - requirements: - vdns_0.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vlb_private_1_port.link: - occurrences: - - 1 - - 1 - capability: tosca.capabilities.network.Linkable - relationship: tosca.relationships.network.LinksTo - vlb_private_0_port.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vdns_private_0_port.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vlb_0.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vdns_private_0_port.link: - occurrences: - - 1 - - 1 - capability: tosca.capabilities.network.Linkable - relationship: tosca.relationships.network.LinksTo - vdns_0.local_storage: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Attachment - node: tosca.nodes.BlockStorage - relationship: tosca.relationships.AttachesTo - vlb_private_1_port.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vlb_private_network.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vlb_0.local_storage: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Attachment - node: tosca.nodes.BlockStorage - relationship: tosca.relationships.AttachesTo - vdns_private_1_port.link: - occurrences: - - 1 - - 1 - capability: tosca.capabilities.network.Linkable - relationship: tosca.relationships.network.LinksTo - vdns_private_1_port.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/resource-Eace933104d443b496b8-template.yml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/resource-Eace933104d443b496b8-template.yml deleted file mode 100644 index c0f4f4d39..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/resource-Eace933104d443b496b8-template.yml +++ /dev/null @@ -1,2525 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_0 -metadata: - invariantUUID: 06fe411e-d006-4ac3-8b0e-fb4f13cd78d3 - UUID: 172ce7c5-c2e4-4f8d-b66c-edb49e8e548a - name: eace9331-04d4-43b4-96b8 - description: vendor software product - type: VF - category: Generic - subcategory: Abstract - resourceVendor: 31125954-23a0-4d41-95e5 - resourceVendorRelease: '1.0' -imports: -- NeutronPort: - file: resource-Neutronport-template.yml -- Eace933104d443b496b8.nodes.heat.vfw: - file: resource-Eace933104d443b496b8NodesHeatVfw-template.yml -- Eace933104d443b496b8.nodes.heat.vpg: - file: resource-Eace933104d443b496b8NodesHeatVpg-template.yml -- NeutronNet: - file: resource-Neutronnet-template.yml -- Eace933104d443b496b8.nodes.heat.vsn: - file: resource-Eace933104d443b496b8NodesHeatVsn-template.yml -topology_template: - inputs: - vf_module_id: - type: string - description: The vFirewall Module ID is provided by onap - repo_url_blob: - type: string - description: URL of the repository that hosts the demo packages - public_net_id: - type: string - default: 00000000-0000-0000-0000-000000000000 - description: Public network that enables remote connection to VNF - vfw_private_ip_1: - type: string - description: Private IP address that is assigned to the vFirewall to communicate with the vSink - vfw_private_ip_0: - type: string - description: Private IP address that is assigned to the vFirewall to communicate with the vPacketGenerator - vfw_private_ip_2: - type: string - description: Private IP address that is assigned to the vFirewall to communicate with ONAP components - vfw_name_0: - type: string - description: Name of the vFirewall - vnf_id: - type: string - description: The VNF ID is provided by onap - dcae_collector_ip: - type: string - description: IP address of the DCAE collector - dcae_collector_port: - type: string - description: Port of the DCAE collector - vpg_private_ip_1: - type: string - description: Private IP address that is assigned to the vPacketGenerator to communicate with ONAP components - vsn_private_ip_0: - type: string - description: Private IP address that is assigned to the vSink to communicate with the vFirewall - vpg_name_0: - type: string - description: Name of the vPacketGenerator - vpg_private_ip_0: - type: string - description: Private IP address that is assigned to the vPacketGenerator to communicate with the vFirewall - vsn_private_ip_1: - type: string - description: Private IP address that is assigned to the vSink to communicate with ONAP components - protected_private_net_cidr: - type: string - description: The CIDR of the protected private network - onap_private_net_cidr: - type: string - description: The CIDR of the protected private network - unprotected_private_net_cidr: - type: string - description: The CIDR of the unprotected private network - onap_private_subnet_id: - type: string - description: Private sub-network that connects ONAP component and the VNF - vsn_name_0: - type: string - description: Name of the vSink - unprotected_private_net_id: - type: string - description: Private network that connects vPacketGenerator with vFirewall - vfw_flavor_name: - type: string - default: 4 GB General Purpose v1 - description: Type of instance (flavor) to be used - demo_artifacts_version: - type: string - description: Artifacts (jar, tar.gz) version used in demo vnfs - onap_private_net_id: - type: string - description: Private network that connects ONAP component and the VNF - pub_key: - type: string - description: Public key to be installed on the compute instance - key_name: - type: string - description: Public/Private key pair name - repo_url_artifacts: - type: string - description: URL of the repository that hosts the demo packages - vfw_image_name: - type: string - default: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM) - description: Image to be used for compute instance - protected_private_net_id: - type: string - description: Private network that connects vFirewall with vSink - node_templates: - vfw_private_0_port: - type: org.onap.resource.cp.nodes.heat.network.neutron.Port - metadata: - invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 - UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 - version: '1.0' - name: NeutronPort - description: Represents a logical entity that associates between Compute and Network normative types. - type: CP - category: Generic - subcategory: Network Elements - properties: - fixed_ips: - - subnet: unprotected_private_network - ip_address: - get_input: vfw_private_ip_0 - network: unprotected_private_network - requirements: - - link: - capability: tosca.capabilities.network.Linkable - node: unprotected_private_network - relationship: tosca.relationships.network.LinksTo - - binding: - capability: tosca.capabilities.network.Bindable - node: vfw_0 - relationship: tosca.relationships.network.BindsTo - vsn_private_1_port: - type: org.onap.resource.cp.nodes.heat.network.neutron.Port - metadata: - invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 - UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 - version: '1.0' - name: NeutronPort - description: Represents a logical entity that associates between Compute and Network normative types. - type: CP - category: Generic - subcategory: Network Elements - properties: - fixed_ips: - - subnet: - get_input: onap_private_subnet_id - ip_address: - get_input: vsn_private_ip_1 - network: - get_input: onap_private_net_id - requirements: - - binding: - capability: tosca.capabilities.network.Bindable - node: vsn_0 - relationship: tosca.relationships.network.BindsTo - unprotected_private_network: - type: org.onap.resource.vl.nodes.heat.network.neutron.Net - metadata: - invariantUUID: 2870cc3a-d6cd-4423-b7f6-2d63619b0eeb - UUID: b7e764ba-17f9-4f0a-ad29-29877766ef21 - version: '1.0' - name: NeutronNet - description: Represents a network service with optional subnets and advanced configurations. - type: VL - category: Generic - subcategory: Network Elements - properties: - network_name: - get_input: unprotected_private_net_id - subnets: - unprotected_private_subnet: - cidr: - get_input: unprotected_private_net_cidr - vpg_private_1_port: - type: org.onap.resource.cp.nodes.heat.network.neutron.Port - metadata: - invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 - UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 - version: '1.0' - name: NeutronPort - description: Represents a logical entity that associates between Compute and Network normative types. - type: CP - category: Generic - subcategory: Network Elements - properties: - fixed_ips: - - subnet: - get_input: onap_private_subnet_id - ip_address: - get_input: vpg_private_ip_1 - network: - get_input: onap_private_net_id - requirements: - - binding: - capability: tosca.capabilities.network.Bindable - node: vpg_0 - relationship: tosca.relationships.network.BindsTo - vfw_0: - type: org.onap.resource.vfc.Eace933104d443b496b8.abstact.nodes.heat.vfw - metadata: - invariantUUID: 0129e34c-d9fa-442d-bb2c-f925d018000a - UUID: 7fa1f6c7-c6bd-4444-8db2-63334a5aed1b - version: '1.0' - name: Eace933104d443b496b8.nodes.heat.vfw - description: Not reusable inner VFC - type: VFC - category: Generic - subcategory: Abstract - properties: - key_name: UNSUPPORTED_RESOURCE_my_keypair - flavor: - get_input: vfw_flavor_name - image: - get_input: vfw_image_name - metadata: - vf_module_id: - get_input: vf_module_id - vnf_id: - get_input: vnf_id - user_data_format: RAW - name: - get_input: vfw_name_0 - vsn_0: - type: org.onap.resource.vfc.Eace933104d443b496b8.abstact.nodes.heat.vsn - metadata: - invariantUUID: b19f6643-3db0-4d73-b280-94d6f21caa71 - UUID: 6dca6eb9-330c-4090-a542-7aca5f446e21 - version: '1.0' - name: Eace933104d443b496b8.nodes.heat.vsn - description: Not reusable inner VFC - type: VFC - category: Generic - subcategory: Abstract - properties: - key_name: UNSUPPORTED_RESOURCE_my_keypair - flavor: - get_input: vfw_flavor_name - image: - get_input: vfw_image_name - metadata: - vf_module_id: - get_input: vf_module_id - vnf_id: - get_input: vnf_id - user_data_format: RAW - name: - get_input: vsn_name_0 - vpg_private_0_port: - type: org.onap.resource.cp.nodes.heat.network.neutron.Port - metadata: - invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 - UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 - version: '1.0' - name: NeutronPort - description: Represents a logical entity that associates between Compute and Network normative types. - type: CP - category: Generic - subcategory: Network Elements - properties: - fixed_ips: - - subnet: unprotected_private_network - ip_address: - get_input: vpg_private_ip_0 - network: unprotected_private_network - requirements: - - link: - capability: tosca.capabilities.network.Linkable - node: unprotected_private_network - relationship: tosca.relationships.network.LinksTo - - binding: - capability: tosca.capabilities.network.Bindable - node: vpg_0 - relationship: tosca.relationships.network.BindsTo - vsn_private_0_port: - type: org.onap.resource.cp.nodes.heat.network.neutron.Port - metadata: - invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 - UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 - version: '1.0' - name: NeutronPort - description: Represents a logical entity that associates between Compute and Network normative types. - type: CP - category: Generic - subcategory: Network Elements - properties: - fixed_ips: - - subnet: protected_private_network - ip_address: - get_input: vsn_private_ip_0 - network: protected_private_network - requirements: - - link: - capability: tosca.capabilities.network.Linkable - node: protected_private_network - relationship: tosca.relationships.network.LinksTo - - binding: - capability: tosca.capabilities.network.Bindable - node: vsn_0 - relationship: tosca.relationships.network.BindsTo - vfw_private_1_port: - type: org.onap.resource.cp.nodes.heat.network.neutron.Port - metadata: - invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 - UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 - version: '1.0' - name: NeutronPort - description: Represents a logical entity that associates between Compute and Network normative types. - type: CP - category: Generic - subcategory: Network Elements - properties: - fixed_ips: - - subnet: protected_private_network - ip_address: - get_input: vfw_private_ip_1 - network: protected_private_network - requirements: - - link: - capability: tosca.capabilities.network.Linkable - node: protected_private_network - relationship: tosca.relationships.network.LinksTo - - binding: - capability: tosca.capabilities.network.Bindable - node: vfw_0 - relationship: tosca.relationships.network.BindsTo - vfw_private_2_port: - type: org.onap.resource.cp.nodes.heat.network.neutron.Port - metadata: - invariantUUID: 7feb77d3-dcc5-4826-8a78-0c9089814a45 - UUID: 06bc8ea7-0f6a-489a-9f8f-c7253653b457 - version: '1.0' - name: NeutronPort - description: Represents a logical entity that associates between Compute and Network normative types. - type: CP - category: Generic - subcategory: Network Elements - properties: - fixed_ips: - - subnet: - get_input: onap_private_subnet_id - ip_address: - get_input: vfw_private_ip_2 - network: - get_input: onap_private_net_id - requirements: - - binding: - capability: tosca.capabilities.network.Bindable - node: vfw_0 - relationship: tosca.relationships.network.BindsTo - vpg_0: - type: org.onap.resource.vfc.Eace933104d443b496b8.abstact.nodes.heat.vpg - metadata: - invariantUUID: 7654ae14-4e98-45bc-a8c0-2c43e1805bb4 - UUID: 5267d6dd-f676-4f98-abec-6387ce6beaf2 - version: '1.0' - name: Eace933104d443b496b8.nodes.heat.vpg - description: Not reusable inner VFC - type: VFC - category: Generic - subcategory: Abstract - properties: - key_name: UNSUPPORTED_RESOURCE_my_keypair - flavor: - get_input: vfw_flavor_name - image: - get_input: vfw_image_name - metadata: - vf_module_id: - get_input: vf_module_id - vnf_id: - get_input: vnf_id - user_data_format: RAW - name: - get_input: vpg_name_0 - protected_private_network: - type: org.onap.resource.vl.nodes.heat.network.neutron.Net - metadata: - invariantUUID: 2870cc3a-d6cd-4423-b7f6-2d63619b0eeb - UUID: b7e764ba-17f9-4f0a-ad29-29877766ef21 - version: '1.0' - name: NeutronNet - description: Represents a network service with optional subnets and advanced configurations. - type: VL - category: Generic - subcategory: Network Elements - properties: - network_name: - get_input: protected_private_net_id - subnets: - protected_private_subnet: - cidr: - get_input: protected_private_net_cidr - groups: - base_vfw: - type: org.onap.groups.heat.HeatStack - members: - - vfw_private_0_port - - vsn_private_1_port - - unprotected_private_network - - vpg_private_1_port - - vfw_0 - - vsn_0 - - vpg_private_0_port - - vsn_private_0_port - - vfw_private_1_port - - vfw_private_2_port - - vpg_0 - - protected_private_network - metadata: - invariantUUID: 44b0c172-7b61-49b5-a68a-810042087e1f - UUID: 24cb02f0-1d72-441f-a327-22d80180deaa - version: '1' - name: base_vfw - Eace933104d443b496b8..base_vfw..module-0: - type: org.onap.groups.VfModule - members: - - vfw_private_0_port - - vsn_private_1_port - - unprotected_private_network - - vpg_private_1_port - - vfw_0 - - vsn_0 - - vpg_private_0_port - - vsn_private_0_port - - vfw_private_1_port - - vfw_private_2_port - - vpg_0 - - protected_private_network - metadata: - vfModuleModelName: Eace933104d443b496b8..base_vfw..module-0 - vfModuleModelInvariantUUID: 58c105fd-9c12-4fb7-8a3e-a5ec280183fb - vfModuleModelUUID: ab251d24-4001-4926-aa5c-c01736b36c68 - vfModuleModelVersion: '1' - properties: - vf_module_type: Base - vf_module_description: - volume_group: false - substitution_mappings: - node_type: org.onap.resource.vf.Eace933104d443b496b8 - capabilities: - vfw_0.instance: - type: org.onap.capabilities.metric.Ceilometer - description: Existence of instance - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: instance - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: instance - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vfw_0.scalable: - type: tosca.capabilities.Scalable - occurrences: - - 1 - - UNBOUNDED - properties: - max_instances: - type: integer - default: 1 - min_instances: - type: integer - default: 1 - default_instances: - type: integer - vfw_0.instance:type: - type: org.onap.capabilities.metric.Ceilometer - description: Existence of instance <type> (OpenStack types) - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: instance - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: instance:type - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - protected_private_network.link: - type: tosca.capabilities.network.Linkable - occurrences: - - 0 - - UNBOUNDED - vsn_0.cpu: - type: org.onap.capabilities.metric.Ceilometer - description: CPU time used - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Cumulative - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ns - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vpg_0.instance:type: - type: org.onap.capabilities.metric.Ceilometer - description: Existence of instance <type> (OpenStack types) - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: instance - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: instance:type - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - unprotected_private_network.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - vfw_0.memory: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM allocated to the instance - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vpg_0.cpu_util: - type: org.onap.capabilities.metric.Ceilometer - description: Average CPU utilization - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: '%' - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu_util - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vpg_0.endpoint: - type: tosca.capabilities.Endpoint.Admin - occurrences: - - 1 - - UNBOUNDED - properties: - port_name: - type: string - required: false - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - secure: - type: boolean - default: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - url_path: - type: string - required: false - vpg_private_0_port.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - vfw_private_1_port.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vfw_private_0_port.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - vpg_0.cpu: - type: org.onap.capabilities.metric.Ceilometer - description: CPU time used - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Cumulative - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ns - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vpg_private_1_port.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - vsn_0.vcpus: - type: org.onap.capabilities.metric.Ceilometer - description: Average disk latency - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ms - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: vcpus - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vpg_0.cpu.delta: - type: org.onap.capabilities.metric.Ceilometer - description: CPU time used since previous datapoint - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Delta - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ns - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu.delta - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vsn_private_1_port.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - vsn_0.cpu_util: - type: org.onap.capabilities.metric.Ceilometer - description: Average CPU utilization - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: '%' - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu_util - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vpg_0.instance: - type: org.onap.capabilities.metric.Ceilometer - description: Existence of instance - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: instance - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: instance - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vpg_0.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vpg_0.scalable: - type: tosca.capabilities.Scalable - occurrences: - - 1 - - UNBOUNDED - properties: - max_instances: - type: integer - default: 1 - min_instances: - type: integer - default: 1 - default_instances: - type: integer - vpg_0.memory: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM allocated to the instance - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vfw_private_2_port.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - vsn_0.os: - type: tosca.capabilities.OperatingSystem - occurrences: - - 1 - - UNBOUNDED - properties: - distribution: - type: string - required: false - type: - type: string - required: false - version: - type: version - required: false - architecture: - type: string - required: false - vfw_0.memory.resident: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM used by the instance on the physical machine - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory.resident - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vsn_0.scalable: - type: tosca.capabilities.Scalable - occurrences: - - 1 - - UNBOUNDED - properties: - max_instances: - type: integer - default: 1 - min_instances: - type: integer - default: 1 - default_instances: - type: integer - vsn_0.instance: - type: org.onap.capabilities.metric.Ceilometer - description: Existence of instance - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: instance - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: instance - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vfw_0.endpoint: - type: tosca.capabilities.Endpoint.Admin - occurrences: - - 1 - - UNBOUNDED - properties: - port_name: - type: string - required: false - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - secure: - type: boolean - default: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - url_path: - type: string - required: false - vsn_0.cpu.delta: - type: org.onap.capabilities.metric.Ceilometer - description: CPU time used since previous datapoint - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Delta - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ns - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu.delta - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vfw_0.os: - type: tosca.capabilities.OperatingSystem - occurrences: - - 1 - - UNBOUNDED - properties: - distribution: - type: string - required: false - type: - type: string - required: false - version: - type: version - required: false - architecture: - type: string - required: false - vsn_private_1_port.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vsn_private_0_port.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vfw_0.memory.usage: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM used by the instance from the amount of its allocated memory - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory.usage - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vsn_0.host: - type: tosca.capabilities.Container - occurrences: - - 1 - - UNBOUNDED - valid_source_types: - - tosca.nodes.SoftwareComponent - properties: - num_cpus: - type: integer - required: false - disk_size: - type: scalar-unit.size - required: false - cpu_frequency: - type: scalar-unit.frequency - required: false - mem_size: - type: scalar-unit.size - required: false - vsn_0.memory: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM allocated to the instance - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - unprotected_private_network.link: - type: tosca.capabilities.network.Linkable - occurrences: - - 0 - - UNBOUNDED - vfw_0.host: - type: tosca.capabilities.Container - occurrences: - - 1 - - UNBOUNDED - valid_source_types: - - tosca.nodes.SoftwareComponent - properties: - num_cpus: - type: integer - required: false - disk_size: - type: scalar-unit.size - required: false - cpu_frequency: - type: scalar-unit.frequency - required: false - mem_size: - type: scalar-unit.size - required: false - vsn_private_0_port.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - vfw_private_2_port.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - unprotected_private_network.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vpg_0.vcpus: - type: org.onap.capabilities.metric.Ceilometer - description: Average disk latency - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ms - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: vcpus - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vpg_0.binding: - type: tosca.capabilities.network.Bindable - occurrences: - - 0 - - UNBOUNDED - vpg_0.host: - type: tosca.capabilities.Container - occurrences: - - 1 - - UNBOUNDED - valid_source_types: - - tosca.nodes.SoftwareComponent - properties: - num_cpus: - type: integer - required: false - disk_size: - type: scalar-unit.size - required: false - cpu_frequency: - type: scalar-unit.frequency - required: false - mem_size: - type: scalar-unit.size - required: false - vsn_0.binding: - type: tosca.capabilities.network.Bindable - occurrences: - - 0 - - UNBOUNDED - protected_private_network.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - vfw_0.binding: - type: tosca.capabilities.network.Bindable - occurrences: - - 0 - - UNBOUNDED - vpg_0.memory.usage: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM used by the instance from the amount of its allocated memory - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory.usage - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vfw_private_0_port.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vsn_0.endpoint: - type: tosca.capabilities.Endpoint.Admin - occurrences: - - 1 - - UNBOUNDED - properties: - port_name: - type: string - required: false - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - secure: - type: boolean - default: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - url_path: - type: string - required: false - vfw_0.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - protected_private_network.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vfw_0.cpu: - type: org.onap.capabilities.metric.Ceilometer - description: CPU time used - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Cumulative - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ns - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vsn_0.instance:type: - type: org.onap.capabilities.metric.Ceilometer - description: Existence of instance <type> (OpenStack types) - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: instance - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: instance:type - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vpg_0.os: - type: tosca.capabilities.OperatingSystem - occurrences: - - 1 - - UNBOUNDED - properties: - distribution: - type: string - required: false - type: - type: string - required: false - version: - type: version - required: false - architecture: - type: string - required: false - vsn_0.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vfw_0.vcpus: - type: org.onap.capabilities.metric.Ceilometer - description: Average disk latency - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ms - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: vcpus - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vfw_0.cpu.delta: - type: org.onap.capabilities.metric.Ceilometer - description: CPU time used since previous datapoint - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Delta - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ns - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu.delta - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vsn_0.memory.resident: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM used by the instance on the physical machine - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory.resident - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vsn_0.memory.usage: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM used by the instance from the amount of its allocated memory - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory.usage - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vfw_private_1_port.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - vfw_0.cpu_util: - type: org.onap.capabilities.metric.Ceilometer - description: Average CPU utilization - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: '%' - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu_util - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vpg_0.memory.resident: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM used by the instance on the physical machine - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory.resident - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - vpg_private_0_port.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - vpg_private_1_port.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - requirements: - vsn_private_1_port.link: - occurrences: - - 1 - - 1 - capability: tosca.capabilities.network.Linkable - relationship: tosca.relationships.network.LinksTo - vfw_0.local_storage: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Attachment - node: tosca.nodes.BlockStorage - relationship: tosca.relationships.AttachesTo - vfw_private_1_port.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vpg_private_1_port.link: - occurrences: - - 1 - - 1 - capability: tosca.capabilities.network.Linkable - relationship: tosca.relationships.network.LinksTo - vsn_0.local_storage: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Attachment - node: tosca.nodes.BlockStorage - relationship: tosca.relationships.AttachesTo - protected_private_network.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vfw_private_2_port.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vfw_private_2_port.link: - occurrences: - - 1 - - 1 - capability: tosca.capabilities.network.Linkable - relationship: tosca.relationships.network.LinksTo - unprotected_private_network.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vsn_private_0_port.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vpg_0.local_storage: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Attachment - node: tosca.nodes.BlockStorage - relationship: tosca.relationships.AttachesTo - vsn_private_1_port.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vfw_0.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vpg_0.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vpg_private_1_port.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vsn_0.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vpg_private_0_port.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - vfw_private_0_port.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/service-57e66ea70ed645c7970f-template.yml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/service-57e66ea70ed645c7970f-template.yml deleted file mode 100644 index 4bfd629e9..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/service-57e66ea70ed645c7970f-template.yml +++ /dev/null @@ -1,677 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_0 -metadata: - invariantUUID: 5cfe6f4a-41bc-4247-8674-ebd4b98e35cc - UUID: 0f40bba5-986e-4b3c-803f-ddd1b7b25f24 - name: 57e66ea7-0ed6-45c7-970f - description: catalog service description - type: Service - category: Network L1-3 - serviceOnapNaming: false - serviceHoming: false -imports: -- eace9331-04d4-43b4-96b8: - file: resource-Eace933104d443b496b8-template.yml -topology_template: - node_templates: - eace9331-04d4-43b4-96b8 1: - type: org.onap.resource.vf.Eace933104d443b496b8 - metadata: - invariantUUID: 06fe411e-d006-4ac3-8b0e-fb4f13cd78d3 - UUID: 172ce7c5-c2e4-4f8d-b66c-edb49e8e548a - version: '1.0' - name: eace9331-04d4-43b4-96b8 - description: vendor software product - type: VF - category: Generic - subcategory: Abstract - substitution_mappings: - node_type: org.onap.service.57e66ea70ed645c7970f - capabilities: - eace9331-04d4-43b4-96b8 1.memory.resident: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM used by the instance on the physical machine - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory.resident - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - eace9331-04d4-43b4-96b8 1.os: - type: tosca.capabilities.OperatingSystem - occurrences: - - 1 - - UNBOUNDED - properties: - distribution: - type: string - required: false - type: - type: string - required: false - version: - type: version - required: false - architecture: - type: string - required: false - eace9331-04d4-43b4-96b8 1.binding: - type: tosca.capabilities.network.Bindable - occurrences: - - 0 - - UNBOUNDED - eace9331-04d4-43b4-96b8 1.host: - type: tosca.capabilities.Container - occurrences: - - 1 - - UNBOUNDED - valid_source_types: - - tosca.nodes.SoftwareComponent - properties: - num_cpus: - type: integer - required: false - disk_size: - type: scalar-unit.size - required: false - cpu_frequency: - type: scalar-unit.frequency - required: false - mem_size: - type: scalar-unit.size - required: false - eace9331-04d4-43b4-96b8 1.instance: - type: org.onap.capabilities.metric.Ceilometer - description: Existence of instance - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: instance - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: instance - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - eace9331-04d4-43b4-96b8 1.scalable: - type: tosca.capabilities.Scalable - occurrences: - - 1 - - UNBOUNDED - properties: - max_instances: - type: integer - default: 1 - min_instances: - type: integer - default: 1 - default_instances: - type: integer - eace9331-04d4-43b4-96b8 1.memory: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM allocated to the instance - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - eace9331-04d4-43b4-96b8 1.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - eace9331-04d4-43b4-96b8 1.vcpus: - type: org.onap.capabilities.metric.Ceilometer - description: Average disk latency - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ms - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: vcpus - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - eace9331-04d4-43b4-96b8 1.cpu_util: - type: org.onap.capabilities.metric.Ceilometer - description: Average CPU utilization - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: '%' - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu_util - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - eace9331-04d4-43b4-96b8 1.cpu.delta: - type: org.onap.capabilities.metric.Ceilometer - description: CPU time used since previous datapoint - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Delta - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ns - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu.delta - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - eace9331-04d4-43b4-96b8 1.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - eace9331-04d4-43b4-96b8 1.cpu: - type: org.onap.capabilities.metric.Ceilometer - description: CPU time used - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Cumulative - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ns - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - eace9331-04d4-43b4-96b8 1.instance:type: - type: org.onap.capabilities.metric.Ceilometer - description: Existence of instance <type> (OpenStack types) - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: instance - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: instance:type - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - eace9331-04d4-43b4-96b8 1.link: - type: tosca.capabilities.network.Linkable - occurrences: - - 0 - - UNBOUNDED - eace9331-04d4-43b4-96b8 1.memory.usage: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM used by the instance from the amount of its allocated memory - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory.usage - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - eace9331-04d4-43b4-96b8 1.endpoint: - type: tosca.capabilities.Endpoint.Admin - occurrences: - - 1 - - UNBOUNDED - properties: - port_name: - type: string - required: false - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - secure: - type: boolean - default: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - url_path: - type: string - required: false - requirements: - eace9331-04d4-43b4-96b8 1.local_storage: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Attachment - node: tosca.nodes.BlockStorage - relationship: tosca.relationships.AttachesTo - eace9331-04d4-43b4-96b8 1.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - eace9331-04d4-43b4-96b8 1.link: - occurrences: - - 1 - - 1 - capability: tosca.capabilities.network.Linkable - relationship: tosca.relationships.network.LinksTo diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/service-D473899264974dca9db9-template.yml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/service-D473899264974dca9db9-template.yml deleted file mode 100644 index 2293b3aca..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/Demo-1.0.0-HeatTemplates/service-D473899264974dca9db9-template.yml +++ /dev/null @@ -1,677 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_0 -metadata: - invariantUUID: dc112d6e-7e73-4777-9c6f-1a7fb5fd1b6f - UUID: 2eea06c6-e1d3-4c3a-b9c4-478c506eeedf - name: d4738992-6497-4dca-9db9 - description: catalog service description - type: Service - category: Network L1-3 - serviceOnapNaming: false - serviceHoming: false -imports: -- 59a2ee3f-b580-45fe-b5a1: - file: resource-59a2ee3fB58045feB5a1-template.yml -topology_template: - node_templates: - 59a2ee3f-b580-45fe-b5a1 1: - type: org.onap.resource.vf.59a2ee3fB58045feB5a1 - metadata: - invariantUUID: 4b8d4018-068b-4c33-b9bb-d980798e52c2 - UUID: d7d28881-b24d-4512-bfee-1e2eb335591f - version: '1.0' - name: 59a2ee3f-b580-45fe-b5a1 - description: vendor software product - type: VF - category: Generic - subcategory: Abstract - substitution_mappings: - node_type: org.onap.service.D473899264974dca9db9 - capabilities: - 59a2ee3f-b580-45fe-b5a1 1.memory.resident: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM used by the instance on the physical machine - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory.resident - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - 59a2ee3f-b580-45fe-b5a1 1.endpoint: - type: tosca.capabilities.Endpoint.Admin - occurrences: - - 1 - - UNBOUNDED - properties: - port_name: - type: string - required: false - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - secure: - type: boolean - default: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - url_path: - type: string - required: false - 59a2ee3f-b580-45fe-b5a1 1.attachment: - type: tosca.capabilities.Attachment - occurrences: - - 1 - - UNBOUNDED - 59a2ee3f-b580-45fe-b5a1 1.feature: - type: tosca.capabilities.Node - occurrences: - - 1 - - UNBOUNDED - 59a2ee3f-b580-45fe-b5a1 1.binding: - type: tosca.capabilities.network.Bindable - occurrences: - - 0 - - UNBOUNDED - 59a2ee3f-b580-45fe-b5a1 1.vcpus: - type: org.onap.capabilities.metric.Ceilometer - description: Average disk latency - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ms - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: vcpus - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - 59a2ee3f-b580-45fe-b5a1 1.host: - type: tosca.capabilities.Container - occurrences: - - 1 - - UNBOUNDED - valid_source_types: - - tosca.nodes.SoftwareComponent - properties: - num_cpus: - type: integer - required: false - disk_size: - type: scalar-unit.size - required: false - cpu_frequency: - type: scalar-unit.frequency - required: false - mem_size: - type: scalar-unit.size - required: false - 59a2ee3f-b580-45fe-b5a1 1.memory.usage: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM used by the instance from the amount of its allocated memory - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory.usage - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - 59a2ee3f-b580-45fe-b5a1 1.instance: - type: org.onap.capabilities.metric.Ceilometer - description: Existence of instance - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: instance - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: instance - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - 59a2ee3f-b580-45fe-b5a1 1.scalable: - type: tosca.capabilities.Scalable - occurrences: - - 1 - - UNBOUNDED - properties: - max_instances: - type: integer - default: 1 - min_instances: - type: integer - default: 1 - default_instances: - type: integer - 59a2ee3f-b580-45fe-b5a1 1.cpu_util: - type: org.onap.capabilities.metric.Ceilometer - description: Average CPU utilization - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: '%' - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu_util - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - 59a2ee3f-b580-45fe-b5a1 1.instance:type: - type: org.onap.capabilities.metric.Ceilometer - description: Existence of instance <type> (OpenStack types) - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: instance - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: instance:type - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - 59a2ee3f-b580-45fe-b5a1 1.cpu.delta: - type: org.onap.capabilities.metric.Ceilometer - description: CPU time used since previous datapoint - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Delta - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ns - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu.delta - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - 59a2ee3f-b580-45fe-b5a1 1.memory: - type: org.onap.capabilities.metric.Ceilometer - description: Volume of RAM allocated to the instance - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Gauge - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: MB - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: memory - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - 59a2ee3f-b580-45fe-b5a1 1.link: - type: tosca.capabilities.network.Linkable - occurrences: - - 0 - - UNBOUNDED - 59a2ee3f-b580-45fe-b5a1 1.cpu: - type: org.onap.capabilities.metric.Ceilometer - description: CPU time used - occurrences: - - 1 - - UNBOUNDED - properties: - initiator: - type: string - default: source - network_name: - type: string - default: PRIVATE - required: false - description: - type: string - description: Description of the metric - required: false - type: - type: string - default: Cumulative - description: Type of the metric value, for an example, Cumulative, Delta, Gauge and etc. - required: true - ports: - type: map - required: false - entry_schema: - type: PortSpec - secure: - type: boolean - default: false - port_name: - type: string - required: false - unit: - type: string - default: ns - description: Unit of the metric value - required: true - protocol: - type: string - default: tcp - port: - type: PortDef - required: false - name: - type: string - default: cpu - description: Ceilometer metric type name to monitor. (The name ceilometer is using) - required: true - category: - type: string - default: compute - description: Category of the metric, for an example, compute, disk, network, storage and etc. - required: false - url_path: - type: string - required: false - 59a2ee3f-b580-45fe-b5a1 1.os: - type: tosca.capabilities.OperatingSystem - occurrences: - - 1 - - UNBOUNDED - properties: - distribution: - type: string - required: false - type: - type: string - required: false - version: - type: version - required: false - architecture: - type: string - required: false - requirements: - 59a2ee3f-b580-45fe-b5a1 1.local_storage: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Attachment - node: tosca.nodes.BlockStorage - relationship: tosca.relationships.AttachesTo - 59a2ee3f-b580-45fe-b5a1 1.dependency: - occurrences: - - 0 - - UNBOUNDED - capability: tosca.capabilities.Node - node: tosca.nodes.Root - relationship: tosca.relationships.DependsOn - 59a2ee3f-b580-45fe-b5a1 1.link: - occurrences: - - 1 - - 1 - capability: tosca.capabilities.network.Linkable - relationship: tosca.relationships.network.LinksTo diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/pgstreams.json b/controlloop/common/policy-yaml/src/test/resources/v2.0.0/pgstreams.json deleted file mode 100644 index 4d118afa1..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/pgstreams.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "pg-streams": { - "pg-stream": [ - { - "id": "fw_udp1", - "is-enabled": "true" - }, - { - "id": "fw_udp2", - "is-enabled": "true" - }, - { - "id": "fw_udp3", - "is-enabled": "true" - }, - { - "id": "fw_udp4", - "is-enabled": "true" - }, - { - "id": "fw_udp5", - "is-enabled": "true" - } - ] - } -}
\ No newline at end of file diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_UseCase_VOLTE.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_UseCase_VOLTE.yaml deleted file mode 100644 index 61462261d..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_UseCase_VOLTE.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2018 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. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-VOLTE-2179b738-fd36-4843-a71a-a8c24c70c55b - - trigger_policy: unique-policy-id-1-restart - timeout: 3600 - -policies: - - id: unique-policy-id-1-restart - name: Restart the VM - description: - actor: VFC - recipe: Restart - target: - type: VM - retry: 3 - timeout: 1200 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception - failure_guard: final_failure_guard diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_UseCase_vCPE.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_UseCase_vCPE.yaml deleted file mode 100644 index 543a9779b..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_UseCase_vCPE.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2018 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. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e - - trigger_policy: unique-policy-id-1-restart - timeout: 3600 - -policies: - - id: unique-policy-id-1-restart - name: Restart the VM - description: - actor: APPC - recipe: Restart - target: - type: VM - retry: 3 - timeout: 1200 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception - failure_guard: final_failure_guard diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_UseCase_vPCI.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_UseCase_vPCI.yaml deleted file mode 100644 index 3d47b643a..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_UseCase_vPCI.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2018 Wipro Limited 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. -controlLoop: - version: 3.0.0 - controlLoopName: ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459 - trigger_policy: unique-policy-id-123-modifyconfig - timeout: 1200 - abatement: false - -policies: - - id: unique-policy-id-123-modifyconfig - name: modify PCI config - description: - actor: SDNR - recipe: ModifyConfig - target: - # These fields are not used - resourceID: Eace933104d443b496b8.nodes.heat.vpg - type: VNF - retry: 0 - timeout: 300 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception - failure_guard: final_failure_guard - diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_UseCase_vSONH.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_UseCase_vSONH.yaml deleted file mode 100644 index 3f965a967..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_UseCase_vSONH.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2019 Wipro Limited 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. -controlLoop: - version: 3.0.0 - controlLoopName: ControlLoop-vSONH-7d4baf04-8875-4d1f-946d-06b874048b61 - trigger_policy: unique-policy-id-456-modifyconfig - timeout: 1200 - abatement: false - -policies: - - id: unique-policy-id-456-modifyconfig - name: modify ANR config - description: - actor: SDNR - recipe: ModifyConfigANR - target: - # These fields are not used - resourceID: Eace933104d443b496b8.nodes.heat.vpg - type: VNF - retry: 0 - timeout: 300 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception - failure_guard: final_failure_guard - diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_demo_vDNS.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_demo_vDNS.yaml deleted file mode 100644 index dc8d5e7b6..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_demo_vDNS.yaml +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright 2018 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. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 - services: - - serviceName: d4738992-6497-4dca-9db9 - serviceInvariantUUID: dc112d6e-7e73-4777-9c6f-1a7fb5fd1b6f - serviceUUID: 2eea06c6-e1d3-4c3a-b9c4-478c506eeedf -# -# OPTIONAL to specify the exact resource VF and/or VFC(s) -# -# resources: -# - resourceInvariantUUID: 4b8d4018-068b-4c33-b9bb-d980798e52c2 -# resourceUUID: d7d28881-b24d-4512-bfee-1e2eb335591f -# resourceVersion: '1.0' -# resourceName: 59a2ee3f-b580-45fe-b5a1 -# resourceType: VF -# -# resources: -# - resourceInvariantUUID: ee585c30-127b-492e-b2c1-871dc61d1dde -# resourceUUID: d816cb01-b5d0-4bbb-b614-f7c3e230ab19 -# resourceVersion: '1.0' -# resourceName: 59a2ee3fB58045feB5a1.nodes.heat.vdns -# resourceType: VFC -# - resourceInvariantUUID: f7f1d745-cfb1-4aa9-83fc-31280d0ce513 -# resourceUUID: 1821f13e-411f-4b29-87a5-ae935897b2e1 -# resourceVersion: '1.0' -# resourceName: 59a2ee3fB58045feB5a1.nodes.heat.vlb -# resourceType: VFC - trigger_policy: unique-policy-id-1-scale-up - timeout: 1200 - -policies: - - id: unique-policy-id-1-scale-up - name: Create a new VF Module - description: - actor: SO - recipe: VF Module Create - target: - type: VNF - payload: - requestParameters: '{"usePreload":true,"userParams":[]}' - configurationParameters: '[{"ip-addr":"$.vf-module-topology.vf-module-parameters.param[9]","oam-ip-addr":"$.vf-module-topology.vf-module-parameters.param[16]","enabled":"$.vf-module-topology.vf-module-parameters.param[23]"}]' - retry: 0 - timeout: 1200 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception - failure_guard: final_failure_guard diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_demo_vFirewall.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_demo_vFirewall.yaml deleted file mode 100644 index f872db7b2..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_demo_vFirewall.yaml +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright 2018 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. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a - services: - - serviceInvariantUUID: 5cfe6f4a-41bc-4247-8674-ebd4b98e35cc - serviceUUID: 0f40bba5-986e-4b3c-803f-ddd1b7b25f24 - serviceName: 57e66ea7-0ed6-45c7-970f -# -# OPTIONAL -# -# IF they want this CL restricted to a particular VFC(s) -# -#resources: -# - resourceInvariantUUID: 06fe411e-d006-4ac3-8b0e-fb4f13cd78d3 -# resourceUUID: 172ce7c5-c2e4-4f8d-b66c-edb49e8e548a -# resourceVersion: '1.0' -# resourceName: eace9331-04d4-43b4-96b8 -# resourceType: VF - -# resources: -# - resourceType: VFC -# resourceInvariantUUID: b19f6643-3db0-4d73-b280-94d6f21caa71 -# resourceUUID: 6dca6eb9-330c-4090-a542-7aca5f446e21 -# resourceVersion: '1.0' -# resourceName: Eace933104d443b496b8.nodes.heat.vsn -# - resourceName: vFW -# resourceType: VFC -# resourceInvariantUUID: 0129e34c-d9fa-442d-bb2c-f925d018000a -# resourceUUID: 7fa1f6c7-c6bd-4444-8db2-63334a5aed1b -# resourceVersion: '1.0' -# resourceName: Eace933104d443b496b8.nodes.heat.vfw -# - resourceType: VFC -# resourceInvariantUUID: 7654ae14-4e98-45bc-a8c0-2c43e1805bb4 -# resourceUUID: 5267d6dd-f676-4f98-abec-6387ce6beaf2 -# resourceVersion: '1.0' -# resourceName: Eace933104d443b496b8.nodes.heat.vpg - trigger_policy: unique-policy-id-1-modifyConfig - timeout: 1200 - -policies: - - id: unique-policy-id-1-modifyConfig - name: Change the Load Balancer - description: - actor: APPC - recipe: ModifyConfig - target: - resourceID: Eace933104d443b496b8.nodes.heat.vpg - payload: - generic-vnf.vnf-id: {generic-vnf.vnf-id} - ref$: pgstreams.json - retry: 0 - timeout: 300 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception - failure_guard: final_failure_guard diff --git a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_vService.yaml b/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_vService.yaml deleted file mode 100644 index 504daee3b..000000000 --- a/controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_vService.yaml +++ /dev/null @@ -1,134 +0,0 @@ -# Copyright 2018 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. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-GENERIC-64cdc9fa-6601-4989-9de7-8f47134aa043 - # - # Example of how someone can fine-grain this - # policy for a specific service and/or resources - # contained within the service. - # - services: - - serviceName: vFooService - - resources: - - resourceName: vVNF1 - resourceType: VFC - - resourceName: vVNF2 - resourceType: VFC - - resourceName: vVNF3 - resourceType: VFC - - resourceName: vVNF4 - resourceType: VFC - - trigger_policy: unique-policy-id-1-restart - timeout: 1200 - # - # Example of case where an abatement isn't possible - # from DCAE to Policy. So Policy should NOT expect - # - abatement: false - -policies: - - - id: unique-policy-id-1-restart - name: Restart Policy - description: - actor: APPC - recipe: Restart - target: - type: VM - retry: 2 - timeout: 300 - success: unique-policy-id-1-healthdiagnostic - failure: unique-policy-id-2-rebuild - failure_timeout: unique-policy-id-2-rebuild - failure_retries: unique-policy-id-2-rebuild - failure_exception: final_failure_exception - failure_guard: unique-policy-id-2-rebuild - - - - id: unique-policy-id-2-rebuild - name: Rebuild Policy - description: - actor: APPC - recipe: Rebuild - target: - type: VM - retry: 0 - timeout: 600 - success: unique-policy-id-2-healthdiagnostic - failure: unique-policy-id-3-migrate - failure_timeout: unique-policy-id-3-migrate - failure_retries: unique-policy-id-3-migrate - failure_exception: final_failure_exception - failure_guard: unique-policy-id-3-migrate - - - id: unique-policy-id-3-migrate - name: Migrate Policy - description: - actor: APPC - recipe: Migrate - target: - type: VM - retry: 0 - timeout: 600 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception - failure_guard: final_failure_guard - - - id: unique-policy-id-1-healthdiagnostic - name: Do A Health Diagnostic - description: - actor: APPC - recipe: health-diagnostic - # Example of a payload - payload: - health-diagnostic-code: HC01234 - health-diagnostic-code-parameters: "{\"Junk\":\"--version\",\"Junk2\":\"--help\"}" - target: - type: VM - retry: 0 - timeout: 600 - success: final_success - failure: unique-policy-id-2-rebuild - failure_timeout: unique-policy-id-2-rebuild - failure_retries: unique-policy-id-2-rebuild - failure_exception: final_failure_exception - failure_guard: unique-policy-id-2-rebuild - - - - id: unique-policy-id-2-healthdiagnostic - name: Do Health Diagnostic - description: - actor: APPC - recipe: health-diagnostic - payload: - health-diagnostic-code: HC01234 - health-diagnostic-code-parameters: "{\"Junk\":\"--version\",\"Junk2\":\"--help\"}" - target: - type: VM - retry: 0 - timeout: 600 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_exception: final_failure_exception - failure_guard: final_failure_guard - - diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/pom.xml b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/pom.xml index 2fb5d868b..ccb8951f4 100644 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/pom.xml +++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/pom.xml @@ -95,15 +95,10 @@ <version>${dependenciesVersion}</version> </dependency> <dependency> - <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> - <artifactId>trafficgenerator</artifactId> - <version>${dependenciesVersion}</version> - </dependency> - <dependency> <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> <artifactId>eventmanager</artifactId> <version>${dependenciesVersion}</version> - </dependency> + </dependency> <dependency> <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> <artifactId>guard</artifactId> diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.legacy.success.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.legacy.success.json index 2c6570d03..4f956885e 100644 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.legacy.success.json +++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.legacy.success.json @@ -12,30 +12,7 @@ "Value": "SUCCESS" }, "Payload": { - "generic-vnf.vnf-id": "jimmy-test-vnf2", - "pg-streams": { - "pg-stream": [ - { - "id": "fw_udp1", - "is-enabled": "true" - }, - { - "id": "fw_udp2", - "is-enabled": "true" - }, - { - "id": "fw_udp3", - "is-enabled": "true" - }, - { - "id": "fw_udp4", - "is-enabled": "true" - }, - { - "id": "fw_udp5", - "is-enabled": "true" - } - ] + "generic-vnf.vnf-id": "jimmy-test-vnf2" } } }
\ No newline at end of file diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vFW.yaml b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vFW.yaml index 7d0ac84be..b517e76b3 100644 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vFW.yaml +++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vFW.yaml @@ -1,4 +1,4 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved +# Copyright 2018-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. @@ -17,7 +17,7 @@ controlLoop: trigger_policy: unique-policy-id-1-modifyConfig timeout: 3600 abatement: false - + policies: - id: unique-policy-id-1-modifyConfig name: modify packet gen config @@ -27,6 +27,8 @@ policies: target: resourceID: Eace933104d443b496b8.nodes.heat.vpg type: VNF + payload: + streams: '{"active-streams":5}' retry: 2 timeout: 1200 success: final_success diff --git a/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/pom.xml b/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/pom.xml index 40e65da88..bef11cd1b 100644 --- a/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/pom.xml +++ b/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/pom.xml @@ -95,15 +95,10 @@ <version>${dependenciesVersion}</version> </dependency> <dependency> - <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> - <artifactId>trafficgenerator</artifactId> - <version>${dependenciesVersion}</version> - </dependency> - <dependency> <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> <artifactId>eventmanager</artifactId> <version>${dependenciesVersion}</version> - </dependency> + </dependency> <dependency> <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> <artifactId>guard</artifactId> diff --git a/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/config/appc.legacy.success.json b/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/config/appc.legacy.success.json index 2c6570d03..4f956885e 100644 --- a/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/config/appc.legacy.success.json +++ b/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/config/appc.legacy.success.json @@ -12,30 +12,7 @@ "Value": "SUCCESS" }, "Payload": { - "generic-vnf.vnf-id": "jimmy-test-vnf2", - "pg-streams": { - "pg-stream": [ - { - "id": "fw_udp1", - "is-enabled": "true" - }, - { - "id": "fw_udp2", - "is-enabled": "true" - }, - { - "id": "fw_udp3", - "is-enabled": "true" - }, - { - "id": "fw_udp4", - "is-enabled": "true" - }, - { - "id": "fw_udp5", - "is-enabled": "true" - } - ] + "generic-vnf.vnf-id": "jimmy-test-vnf2" } } }
\ No newline at end of file diff --git a/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/config/vFW.yaml b/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/config/vFW.yaml index dcbdf5459..01f67959f 100644 --- a/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/config/vFW.yaml +++ b/controlloop/templates/archetype-cl-usecases/src/main/resources/archetype-resources/src/main/config/vFW.yaml @@ -1,4 +1,4 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved +# Copyright 2018-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. @@ -17,7 +17,7 @@ controlLoop: trigger_policy: unique-policy-id-1-modifyConfig timeout: 3600 abatement: false - + policies: - id: unique-policy-id-1-modifyConfig name: modify packet gen config @@ -27,6 +27,8 @@ policies: target: resourceID: Eace933104d443b496b8.nodes.heat.vpg type: VNF + payload: + streams: '{"active-streams":5}' retry: 2 timeout: 1200 success: final_success diff --git a/controlloop/templates/template.demo/pom.xml b/controlloop/templates/template.demo/pom.xml index 862fa2809..d12fc4490 100644 --- a/controlloop/templates/template.demo/pom.xml +++ b/controlloop/templates/template.demo/pom.xml @@ -85,12 +85,6 @@ </dependency> <dependency> <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> - <artifactId>trafficgenerator</artifactId> - <version>${policy.models.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> <artifactId>vfc</artifactId> <version>${policy.models.version}</version> <scope>provided</scope> |