From 1f7a7db265e2f98356e4006631535dd90eab6b7c Mon Sep 17 00:00:00 2001 From: marcinrzepeckiwroc Date: Tue, 30 Jun 2020 11:41:31 +0200 Subject: Removed the declarations of thrown exceptions which were a subclass od java.io.IOException, Added one test to cover not covered usecase, Added constant field instead of multiple literal duplication. Issue-ID: SO-1841 Signed-off-by: marcinrzepeckiwroc Change-Id: I686df90ecb463f036687b93069f8d1341ee4e597 --- .../adapters/tasks/audit/AuditDataServiceTest.java | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'adapters/mso-openstack-adapters/src/test/java/org') diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java index fd36995f3d..76e5bbc47f 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java @@ -1,10 +1,9 @@ package org.onap.so.adapters.tasks.audit; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; +import static org.assertj.core.api.Assertions.assertThat; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -13,7 +12,6 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.Vserver; -import org.onap.so.adapters.tasks.audit.AuditDataService; import org.onap.so.audit.beans.AuditInventory; import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.db.request.beans.RequestProcessingData; @@ -22,6 +20,7 @@ import org.onap.so.objects.audit.AAIObjectAudit; import org.onap.so.objects.audit.AAIObjectAuditList; import com.fasterxml.jackson.core.JsonProcessingException; + @RunWith(MockitoJUnitRunner.Silent.class) public class AuditDataServiceTest { @@ -56,9 +55,8 @@ public class AuditDataServiceTest { vserver.setVserverId("testVserverId"); audit.setAaiObject(vserver); auditList.getAuditList().add(audit); - GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); - String auditListString = objectMapper.getMapper().writeValueAsString(auditList);; + String auditListString = objectMapper.getMapper().writeValueAsString(auditList); RequestProcessingData requestProcessingData = new RequestProcessingData(); requestProcessingData.setSoRequestId(auditInventory.getMsoRequestId()); @@ -99,4 +97,17 @@ public class AuditDataServiceTest { "testVnfModuleId", "testVfModuleName1", "AuditStackData"); } + @Test + public void testGetStackDataToRequestDbWhenRequestProcessingDataListIsEmpty() throws Exception { + + Mockito.doReturn(new ArrayList()).when(requestsDbClient) + .getRequestProcessingDataByGroupingIdAndNameAndTag(Mockito.any(), Mockito.any(), Mockito.any()); + Optional result = auditDataService.getStackDataFromRequestDb(auditInventory); + Mockito.verify(requestsDbClient, Mockito.times(1)).getRequestProcessingDataByGroupingIdAndNameAndTag( + "testVnfModuleId", "testVfModuleName1", "AuditStackData"); + assertThat(result).isEmpty(); + + } + + } -- cgit 1.2.3-korg