summaryrefslogtreecommitdiffstats
path: root/configbackuprestore
diff options
context:
space:
mode:
authorSoumendu Sekhar Acharya <SA00498080@techmahindra.com>2018-08-07 16:50:48 +0530
committerSoumendu Sekhar Acharya <SA00498080@techmahindra.com>2018-08-24 14:13:44 +0000
commit46cb2d3a105021fe4aeed8aa462c31ce50bad39f (patch)
tree7ce77644dadc51c3947654c0e7bba52d59cd859f /configbackuprestore
parent929c1f13697f338245571694beb73adbd39a5b78 (diff)
Epic-231 cbr junit testcase of SDNC-258
JUNIT Testcase for getBackupVnfDetailService Change-Id: I8b4f96b46bcfb23d35c183eed7c2ee949b956900 Issue-ID: SDNC-413 Signed-off-by: Soumendu Sekhar Acharya <SA00498080@techmahindra.com> Former-commit-id: c07d55ffd5e1838e2ec4fc6204e8a6762674f5e9
Diffstat (limited to 'configbackuprestore')
-rw-r--r--configbackuprestore/getBackupVnfDetailService/src/test/java/com/onap/sdnc/vnfconfigcomparsion/service/VnfComparisonServiceTest.java123
1 files changed, 123 insertions, 0 deletions
diff --git a/configbackuprestore/getBackupVnfDetailService/src/test/java/com/onap/sdnc/vnfconfigcomparsion/service/VnfComparisonServiceTest.java b/configbackuprestore/getBackupVnfDetailService/src/test/java/com/onap/sdnc/vnfconfigcomparsion/service/VnfComparisonServiceTest.java
new file mode 100644
index 00000000..0afcd69c
--- /dev/null
+++ b/configbackuprestore/getBackupVnfDetailService/src/test/java/com/onap/sdnc/vnfconfigcomparsion/service/VnfComparisonServiceTest.java
@@ -0,0 +1,123 @@
+package com.onap.sdnc.vnfconfigcomparsion.service;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyString;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import com.onap.sdnc.vnfcomparsion.dao.VnfComparisonRepository;
+import com.onap.sdnc.vnfconfigcomparsion.model.VnfCompareResponse;
+import com.onap.sdnc.vnfconfigcomparsion.model.VnfConfigDetailsDB;
+import com.onap.sdnc.vnfconfigcomparsion.model.VnfDetails;
+
+
+
+@RunWith(MockitoJUnitRunner.class)
+public class VnfComparisonServiceTest {
+
+ @InjectMocks
+ VnfComparisonService vnfComparisonService;
+
+ @Mock
+ VnfComparisonRepository vnfComparisonRepository;
+
+ @Test
+ public void testGetConfigurationDeatils_1() throws JSONException {
+ VnfCompareResponse response = new VnfCompareResponse();
+ String exampleJson = "{\"vnfname\":\"vnfversion\":[\"vnf1\",\"1.0\"]}";
+ JSONObject vnfVersionNames = new JSONObject("{ \"versionNames\":[\"1.0\"] }");
+ String vnfId = "1a";
+ List<VnfDetails> vnfDetailslist = new ArrayList<VnfDetails>();
+ VnfDetails vnfdetails = new VnfDetails();
+ JSONArray vnfIdArray = vnfVersionNames.getJSONArray("versionNames");
+ VnfConfigDetailsDB value = new VnfConfigDetailsDB();
+ value.setVnfid("1a");
+ value.setConfiginfo(exampleJson);
+ value.setId(1);
+ value.setLastupdated("05-22-2018");
+ value.setStatus("Y");
+ value.setVnfname("vnf1");
+ value.setVnfversion("1.0");
+
+ //Mockito.when(vnfComparisonRepository.getVnfDetails(anyString(), anyString())).thenReturn(value);
+ response.setVnfDetails(vnfDetailslist);
+ response = vnfComparisonService.getConfigurationDeatils(vnfVersionNames, vnfId);
+ assertEquals(value.getConfiginfo(), exampleJson);
+
+ }
+
+ @Test
+ public void testGetConfigurationDeatils() throws Exception {
+ VnfCompareResponse response = new VnfCompareResponse();
+ String exampleJson = "{\"vnfname\":\"vnfversion\":[\"vnf1\",\"1.0\"]}";
+ JSONObject vnfVersionNames = new JSONObject("{ \"versionNames\":[\"1.0\",\"2.0\"] }");
+ // String vnfversion = "{ \"versionNames\":[\"Version-1\"] }";
+ String vnfId = "1a";
+ List<VnfDetails> vnfDetailslist = new ArrayList<VnfDetails>();
+ VnfDetails vnfdetails = new VnfDetails();
+ JSONArray vnfIdArray = vnfVersionNames.getJSONArray("versionNames");
+ VnfConfigDetailsDB value = new VnfConfigDetailsDB();
+ value.setVnfid("1a");
+ value.setConfiginfo(exampleJson);
+ value.setId(1);
+ value.setLastupdated("05-22-2018");
+ value.setStatus("Y");
+ value.setVnfname("vnf1");
+ value.setVnfversion("1.0");
+
+ Mockito.when(vnfComparisonRepository.getVnfDetails(anyString(), anyString())).thenReturn(value);
+ response.setVnfDetails(vnfDetailslist);
+
+ response = vnfComparisonService.getConfigurationDeatils(vnfVersionNames, vnfId);
+ System.out.println(response);
+ assertNotNull(response);
+ assertEquals(value.getConfiginfo(), exampleJson);
+ assertEquals(value.getVnfid(), vnfId);
+ assertEquals(value.getStatus(), "Y");
+ }
+
+ @Test
+ public void testgetConfigDeatilsByVnfIdVnfVersion() throws JSONException {
+ VnfCompareResponse response = new VnfCompareResponse();
+ String exampleJson = "{\"vnfname\":\"vnfversion\":[\"vnf1\",\"1.0\"]}";
+ JSONObject vnfVersionNames = new JSONObject("{ \"versionNames\":[\"1.0\",\"2.0\"] }");
+ // String vnfversion = "{ \"versionNames\":[\"Version-1\"] }";
+ String vnfId = "1a";
+ List<VnfDetails> vnfDetailslist = new ArrayList<VnfDetails>();
+ VnfDetails vnfdetails = new VnfDetails();
+ JSONArray vnfIdArray = vnfVersionNames.getJSONArray("versionNames");
+ VnfConfigDetailsDB value = new VnfConfigDetailsDB();
+ value.setVnfid("1a");
+ value.setConfiginfo(exampleJson);
+ value.setId(1);
+ value.setLastupdated("05-22-2018");
+ value.setStatus("Y");
+ value.setVnfname("vnf1");
+ value.setVnfversion("1.0");
+
+ Mockito.when(vnfComparisonRepository.getVnfDetails(anyString(), anyString())).thenReturn(value);
+ response.setVnfDetails(vnfDetailslist);
+
+ response = vnfComparisonService.getConfigDeatilsByVnfIdVnfVersion(vnfVersionNames, vnfId);
+ System.out.println(response);
+ assertNotNull(response);
+ assertEquals(value.getConfiginfo(), exampleJson);
+ assertEquals(value.getVnfid(), vnfId);
+ assertEquals(value.getStatus(), "Y");
+ }
+
+
+}