Adding Junit 65/35165/1
authorAS00465059 <AS00465059@techmahindra.com>
Mon, 12 Mar 2018 10:06:35 +0000 (15:36 +0530)
committerAS00465059 <AS00465059@techmahindra.com>
Mon, 12 Mar 2018 10:06:35 +0000 (15:36 +0530)
Junit for:
1.SDNCServiceError.java
2.SDNCServiceRequest.java
3.SDNCServiceResponse.java
4.ServiceInformation.java

Sonar Link:
https://sonar.onap.org/code?id=org.onap.so%3Aso&selected=org.onap.so.adapters%3Amso-adapters-rest-interface%3Asrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fmso%2Fadapters%2Fsdncrest

Change-Id: I2a4216c509cf0164ad669d391c9af0bbe6a80f25
Issue-ID: SO-470
Signed-off-by: AS00465059 <AS00465059@techmahindra.com>
adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceErrorTest.java [new file with mode: 0644]
adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceRequestTest.java [new file with mode: 0644]
adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceResponseTest.java [new file with mode: 0644]
adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/ServiceInformationTest.java [new file with mode: 0644]

diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceErrorTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceErrorTest.java
new file mode 100644 (file)
index 0000000..df69b37
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : SO
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*/
+
+package org.openecomp.mso.adapters.sdncrest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.mso.adapters.sdncrest.SDNCErrorCommon;
+import org.openecomp.mso.adapters.sdncrest.SDNCServiceError;
+
+public class SDNCServiceErrorTest {
+
+       @Mock
+       SDNCErrorCommon sec;
+       
+       @InjectMocks
+       SDNCServiceError ssc;
+       
+       @Before
+       public void init(){
+           MockitoAnnotations.initMocks(this);
+        }
+       
+       @Test
+       public void testSDNCServiceError() {
+               
+               ssc= new SDNCServiceError("id", "200",
+                               "msg", "indicator");
+               assert(ssc!=null);              
+       }
+}
diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceRequestTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceRequestTest.java
new file mode 100644 (file)
index 0000000..c63f1b8
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : SO
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*/
+
+package org.openecomp.mso.adapters.sdncrest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.mso.adapters.sdncrest.SDNCRequestCommon;
+import org.openecomp.mso.adapters.sdncrest.ServiceInformation;
+import org.openecomp.mso.adapters.sdncrest.RequestInformation;
+
+public class SDNCServiceRequestTest {
+
+       @Mock
+       SDNCRequestCommon src;
+       
+       @Mock
+       ServiceInformation si;
+       
+       @Mock
+       RequestInformation ri;
+       
+       @InjectMocks
+       SDNCServiceRequest ssr;
+       
+       @Before
+       public void init(){
+           MockitoAnnotations.initMocks(this);
+        }
+       
+       @Test
+       public void test() {
+               ssr= new SDNCServiceRequest("url", "timeout",
+                               "sdncRequestId", "sdncService", "sdncOperation",
+                               ri,
+                               si, "sdncServiceDataType",
+                               "sndcServiceData");
+               
+       ssr.setSDNCService("sdncService");
+       ssr.setSDNCServiceData("sndcServiceData");
+       ssr.setSDNCServiceDataType("sdncServiceDataType");
+       ssr.setBPTimeout("timeout");
+       ssr.setBPNotificationUrl("url");
+       ssr.setRequestInformation(ri);
+       ssr.setServiceInformation(si);
+       ssr.setSDNCOperation("sdncOperation");
+       ssr.setSDNCRequestId("sdncRequestId");
+       assert(ssr.getSDNCService().equals("sdncService"));
+       assert(ssr.getSDNCServiceData().equals("sndcServiceData"));
+       assert(ssr.getSDNCServiceDataType().equals("sdncServiceDataType"));
+       assert(ssr.getBPTimeout().equals("timeout"));
+       assert(ssr.getBPNotificationUrl().equals("url"));
+       assert(ssr.getRequestInformation().equals(ri));
+       assert(ssr.getServiceInformation().equals(si));
+       assert(ssr.getSDNCOperation().equals("sdncOperation"));
+       assert(ssr.getSDNCRequestId().equals("sdncRequestId")); 
+       }
+
+}
diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceResponseTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/SDNCServiceResponseTest.java
new file mode 100644 (file)
index 0000000..9c4e98a
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : SO
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*/
+
+package org.openecomp.mso.adapters.sdncrest;
+
+import static org.junit.Assert.*;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.mso.adapters.sdncrest.SDNCResponseCommon;
+
+public class SDNCServiceResponseTest {
+
+       @Mock
+       SDNCResponseCommon src;
+       
+       @InjectMocks
+       SDNCServiceResponse ssr;
+       
+       @Before
+       public void init(){
+           MockitoAnnotations.initMocks(this);
+        }
+       
+       @Test
+       public void test() {
+               ssr=new SDNCServiceResponse("sdncRequestId", "200",
+                               "msg", "indicator");
+               Map<String, String> mp = new HashMap<>();
+               mp.put("name", "value");
+               ssr.setParams(mp);
+               assert(ssr.getParams().equals(mp));
+               assertNotNull(ssr);
+       }
+}
diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/ServiceInformationTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/sdncrest/ServiceInformationTest.java
new file mode 100644 (file)
index 0000000..2b87bbf
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : SO
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*/
+
+package org.openecomp.mso.adapters.sdncrest;
+
+import org.junit.Test;
+
+public class ServiceInformationTest {
+
+       
+       
+       @Test
+       public void test() {
+               ServiceInformation si= new ServiceInformation("id","service","GlobalId","name");
+               
+               si.setServiceInstanceId("id");
+               si.setServiceType("service");
+               si.setSubscriberGlobalId("GlobalId");
+               si.setSubscriberName("name");
+               assert(si.getServiceInstanceId().equals("id"));
+               assert(si.getServiceType().equals("service"));
+               assert(si.getSubscriberGlobalId().equals("GlobalId"));
+               assert(si.getSubscriberName().equals("name"));
+       }
+}