From 4498fc2617e0003b7d2f53a6b09051fd216c840e Mon Sep 17 00:00:00 2001 From: Xin Miao Date: Mon, 1 Oct 2018 18:09:24 -0500 Subject: Add new actor SDNC to support CCVPN Closed Loop Issue-ID: POLICY-1183 Change-Id: I1b77b5b9cefca104382d9d84dd00bbd63b20e0f2 Signed-off-by: Xin Miao Signed-off-by: Pamela Dragosh --- .../test/java/org/onap/policy/sdnc/TestDemo.java | 71 ++++++ .../policy/sdnc/TestSdncHealAdditionalParams.java | 47 ++++ .../org/onap/policy/sdnc/TestSdncHealRequest.java | 43 ++++ .../onap/policy/sdnc/TestSdncHealServiceInfo.java | 43 ++++ .../java/org/onap/policy/sdnc/TestSdncManager.java | 281 +++++++++++++++++++++ .../java/org/onap/policy/sdnc/TestSdncRequest.java | 53 ++++ .../org/onap/policy/sdnc/TestSdncResponse.java | 48 ++++ .../policy/sdnc/TestSdncResponseDescriptor.java | 54 ++++ .../onap/policy/sdnc/util/TestSerialization.java | 35 +++ 9 files changed, 675 insertions(+) create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestDemo.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealAdditionalParams.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealRequest.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealServiceInfo.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncManager.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncRequest.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncResponse.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncResponseDescriptor.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/util/TestSerialization.java (limited to 'controlloop/common/model-impl/sdnc/src/test/java') diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestDemo.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestDemo.java new file mode 100644 index 000000000..b002b7ced --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestDemo.java @@ -0,0 +1,71 @@ +/*- + * ============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 TestDemo { + + @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/TestSdncHealAdditionalParams.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealAdditionalParams.java new file mode 100644 index 000000000..a282ddc39 --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealAdditionalParams.java @@ -0,0 +1,47 @@ +/*- + * ============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 TestSdncHealAdditionalParams { + + @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/TestSdncHealRequest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealRequest.java new file mode 100644 index 000000000..96d19b7e1 --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealRequest.java @@ -0,0 +1,43 @@ +/*- + * ============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 TestSdncHealRequest { + + @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/TestSdncHealServiceInfo.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealServiceInfo.java new file mode 100644 index 000000000..92bb4a727 --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealServiceInfo.java @@ -0,0 +1,43 @@ +/*- + * ============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 TestSdncHealServiceInfo { + + @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/TestSdncManager.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncManager.java new file mode 100644 index 000000000..ec6c0a5f1 --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncManager.java @@ -0,0 +1,281 @@ +/*- + * ============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.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 TestSdncManager { + private static WorkingMemory mockedWorkingMemory; + + private RESTManager mockedRestManager; + + private Pair httpResponsePutOk; + private Pair httpResponseGetOk; + private Pair httpResponseBadResponse; + private Pair 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/TestSdncRequest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncRequest.java new file mode 100644 index 000000000..adb07b947 --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncRequest.java @@ -0,0 +1,53 @@ +/*- + * ============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 TestSdncRequest { + + @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/TestSdncResponse.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncResponse.java new file mode 100644 index 000000000..5daa12ab9 --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncResponse.java @@ -0,0 +1,48 @@ +/*- + * ============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 TestSdncResponse { + + @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/TestSdncResponseDescriptor.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncResponseDescriptor.java new file mode 100644 index 000000000..5c882282b --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncResponseDescriptor.java @@ -0,0 +1,54 @@ +/*- + * ============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 TestSdncResponseDescriptor { + + @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/util/TestSerialization.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/util/TestSerialization.java new file mode 100644 index 000000000..9d02d4f87 --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/util/TestSerialization.java @@ -0,0 +1,35 @@ +/*- + * ============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 TestSerialization { + + @Test + public void test() { + assertNotNull(Serialization.gsonPretty); + } +} -- cgit 1.2.3-korg