diff options
Diffstat (limited to 'controlloop/common/model-impl/sdnc')
26 files changed, 0 insertions, 1710 deletions
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); - } -} |