@Test void setStatusForDatalakeAndNotify() throws TransactionService.TransactionExecutionException { doAnswer(invocation -> { invocation.getArgument(0, Runnable.class).run(); return null; }).when(transactionService).required(any(Runnable.class)); long deletedTimeStamp = 100L; when(clock.getCurrentTimeMillis()).thenReturn(deletedTimeStamp); SdxCluster sdxCluster = new SdxCluster(); sdxCluster.setRuntime("7.0.2"); sdxCluster.setClusterName("datalake-cluster"); sdxCluster.setId(2L); SdxStatusEntity oldStatus = new SdxStatusEntity(); oldStatus.setStatus(DatalakeStatusEnum.STACK_DELETED); oldStatus.setCreated(1L); oldStatus.setStatusReason("stack deleted"); oldStatus.setId(1L); oldStatus.setDatalake(sdxCluster); when(sdxStatusRepository.findFirstByDatalakeIsOrderByIdDesc(any(SdxCluster.class))).thenReturn(oldStatus); when(sdxClusterRepository.findById(eq(2L))).thenReturn(Optional.of(sdxCluster)); ArgumentCaptor<SdxStatusEntity> statusEntityCaptor = ArgumentCaptor.forClass(SdxStatusEntity.class); when(sdxStatusRepository.save(statusEntityCaptor.capture())).thenReturn(null); ArgumentCaptor<SdxCluster> sdxClusterCaptor = ArgumentCaptor.forClass(SdxCluster.class); when(sdxClusterRepository.save(sdxClusterCaptor.capture())).thenReturn(sdxCluster); sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.DELETED, ResourceEvent.SDX_RDS_DELETION_FINISHED, "deleted", sdxCluster); verify(sdxStatusRepository, times(1)).save(any(SdxStatusEntity.class)); assertEquals(DatalakeStatusEnum.DELETED, statusEntityCaptor.getValue().getStatus()); assertEquals(Long.valueOf(deletedTimeStamp), sdxClusterCaptor.getValue().getDeleted()); verify(transactionService, times(1)).required(any(Runnable.class)); }
public void setStatusForDatalakeAndNotify(DatalakeStatusEnum status, String statusReason, SdxCluster sdxCluster) { setStatusForDatalake(status, statusReason, sdxCluster); sdxNotificationService.send(status.getDefaultResourceEvent(), sdxCluster); }
SdxStatusService { public void setStatusForDatalakeAndNotify(DatalakeStatusEnum status, String statusReason, SdxCluster sdxCluster) { setStatusForDatalake(status, statusReason, sdxCluster); sdxNotificationService.send(status.getDefaultResourceEvent(), sdxCluster); } }
SdxStatusService { public void setStatusForDatalakeAndNotify(DatalakeStatusEnum status, String statusReason, SdxCluster sdxCluster) { setStatusForDatalake(status, statusReason, sdxCluster); sdxNotificationService.send(status.getDefaultResourceEvent(), sdxCluster); }  }
SdxStatusService { public void setStatusForDatalakeAndNotify(DatalakeStatusEnum status, String statusReason, SdxCluster sdxCluster) { setStatusForDatalake(status, statusReason, sdxCluster); sdxNotificationService.send(status.getDefaultResourceEvent(), sdxCluster); }  void setStatusForDatalakeAndNotify(DatalakeStatusEnum status, String statusReason, SdxCluster sdxCluster); SdxCluster setStatusForDatalakeAndNotify(DatalakeStatusEnum status, String statusReason, Long datalakeId); void setStatusForDatalakeAndNotify(DatalakeStatusEnum status, ResourceEvent event, String statusReason, SdxCluster sdxCluster); SdxCluster setStatusForDatalakeAndNotify(DatalakeStatusEnum status, ResourceEvent event, String statusReason, Long datalakeId); List<SdxStatusEntity> findDistinctFirstByStatusInAndDatalakeIdOrderByIdDesc(Collection<DatalakeStatusEnum> datalakeStatusEnums,
            Collection<Long> datalakeIds); SdxStatusEntity getActualStatusForSdx(SdxCluster sdxCluster); void updateInMemoryStateStore(SdxCluster sdxCluster); String getShortStatusMessage(StackV4Response stack); }
SdxStatusService { public void setStatusForDatalakeAndNotify(DatalakeStatusEnum status, String statusReason, SdxCluster sdxCluster) { setStatusForDatalake(status, statusReason, sdxCluster); sdxNotificationService.send(status.getDefaultResourceEvent(), sdxCluster); }  void setStatusForDatalakeAndNotify(DatalakeStatusEnum status, String statusReason, SdxCluster sdxCluster); SdxCluster setStatusForDatalakeAndNotify(DatalakeStatusEnum status, String statusReason, Long datalakeId); void setStatusForDatalakeAndNotify(DatalakeStatusEnum status, ResourceEvent event, String statusReason, SdxCluster sdxCluster); SdxCluster setStatusForDatalakeAndNotify(DatalakeStatusEnum status, ResourceEvent event, String statusReason, Long datalakeId); List<SdxStatusEntity> findDistinctFirstByStatusInAndDatalakeIdOrderByIdDesc(Collection<DatalakeStatusEnum> datalakeStatusEnums,
            Collection<Long> datalakeIds); SdxStatusEntity getActualStatusForSdx(SdxCluster sdxCluster); void updateInMemoryStateStore(SdxCluster sdxCluster); String getShortStatusMessage(StackV4Response stack);  }