### Question:
AuditDataService { public Optional<AAIObjectAuditList> getStackDataFromRequestDb(AuditInventory auditInventory) throws IOException { List<RequestProcessingData> requestProcessingDataList = requestsDbClient.getRequestProcessingDataByGroupingIdAndNameAndTag(auditInventory.getVfModuleId(), auditInventory.getHeatStackName(), AUDIT_STACK_DATA); if (!requestProcessingDataList.isEmpty()) { RequestProcessingData requestProcessingData = requestProcessingDataList.get(0); String auditListString = requestProcessingData.getValue(); GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); AAIObjectAuditList auditList = objectMapper.getMapper().readValue(auditListString, AAIObjectAuditList.class); return Optional.of(auditList); } else { return Optional.empty(); } }  void writeStackDataToRequestDb(AuditInventory auditInventory, AAIObjectAuditList auditList); Optional<AAIObjectAuditList> getStackDataFromRequestDb(AuditInventory auditInventory);  }### Answer:
@Test public void testGetStackDataToRequestDb() throws Exception { AAIObjectAuditList auditList = new AAIObjectAuditList(); auditList.setHeatStackName("testHeatStackName"); AAIObjectAudit audit = new AAIObjectAudit(); Vserver vserver = new Vserver(); vserver.setVserverId("testVserverId"); audit.setAaiObject(vserver); auditList.getAuditList().add(audit); GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); String auditListString = objectMapper.getMapper().writeValueAsString(audit); List<RequestProcessingData> list = new ArrayList(); RequestProcessingData requestProcessingData = new RequestProcessingData(); requestProcessingData.setId(234321432); requestProcessingData.setGroupingId("testVfModuleId"); requestProcessingData.setName("heatStackName"); requestProcessingData.setTag("AuditStackData"); requestProcessingData.setValue(auditListString); list.add(requestProcessingData); Mockito.doReturn(list).when(requestsDbClient).getRequestProcessingDataByGroupingIdAndNameAndTag(Mockito.any(), Mockito.any(), Mockito.any()); auditDataService.getStackDataFromRequestDb(auditInventory); Mockito.verify(requestsDbClient, Mockito.times(1)).getRequestProcessingDataByGroupingIdAndNameAndTag( "testVnfModuleId", "testVfModuleName1", "AuditStackData"); }
@Test public void testGetStackDataToRequestDbWhenRequestProcessingDataListIsEmpty() throws Exception { Mockito.doReturn(new ArrayList<RequestProcessingData>()).when(requestsDbClient) .getRequestProcessingDataByGroupingIdAndNameAndTag(Mockito.any(), Mockito.any(), Mockito.any()); Optional<AAIObjectAuditList> result = auditDataService.getStackDataFromRequestDb(auditInventory); Mockito.verify(requestsDbClient, Mockito.times(1)).getRequestProcessingDataByGroupingIdAndNameAndTag( "testVnfModuleId", "testVfModuleName1", "AuditStackData"); assertThat(result).isEmpty(); }