### Question:
StackStatusHandler { @Async public void updateStackStatus(Stack stack) { try { String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID); String stackStatus = mapper.writeValueAsString(stack); RequestProcessingData requestProcessingData = requestDBClient.getRequestProcessingDataBySoRequestIdAndNameAndGrouping(requestId, stack.getStackName(), stack.getId()); if (requestProcessingData == null) { requestProcessingData = new RequestProcessingData(); requestProcessingData.setGroupingId(stack.getId()); requestProcessingData.setName(stack.getStackName()); requestProcessingData.setTag("StackInformation"); requestProcessingData.setSoRequestId(requestId); requestProcessingData.setValue(stackStatus); requestDBClient.saveRequestProcessingData(requestProcessingData); } else { requestProcessingData.setValue(stackStatus); requestDBClient.updateRequestProcessingData(requestProcessingData); } } catch (Exception e) { logger.warn("Error adding stack status to request database", e); } }  @Async void updateStackStatus(Stack stack);  }### Answer:
@Test public final void recordExists_Test() throws MsoException, IOException { RequestProcessingData requestProcessingData = new RequestProcessingData(); requestProcessingData.setValue("testMe"); doReturn(requestProcessingData).when(requestDBClient) .getRequestProcessingDataBySoRequestIdAndNameAndGrouping(null, "stackName", "id"); Stack latestStack = new Stack(); latestStack.setId("id"); latestStack.setStackName("stackName"); latestStack.setStackStatus("CREATE_COMPLETE"); latestStack.setStackStatusReason("Stack Finished"); statusHandler.updateStackStatus(latestStack); Mockito.verify(requestDBClient, times(1)).updateRequestProcessingData(requestProcessingData); assertNotEquals("testMe", requestProcessingData.getValue()); }
@Test public final void record_Not_Exists_Test() throws MsoException, IOException { ArgumentCaptor<RequestProcessingData> requestCaptor = ArgumentCaptor.forClass(RequestProcessingData.class); doReturn(null).when(requestDBClient).getRequestProcessingDataBySoRequestIdAndNameAndGrouping(null, "stackName", "id"); Stack latestStack = new Stack(); latestStack.setId("id"); latestStack.setStackName("stackName"); latestStack.setStackStatus("CREATE_COMPLETE"); latestStack.setStackStatusReason("Stack Finished"); statusHandler.updateStackStatus(latestStack); Mockito.verify(requestDBClient, times(1)).saveRequestProcessingData(requestCaptor.capture()); RequestProcessingData actualRequest = requestCaptor.getValue(); assertEquals("id", actualRequest.getGroupingId()); assertEquals("StackInformation", actualRequest.getTag()); assertEquals("stackName", actualRequest.getName()); assertNotNull(actualRequest.getValue()); }