use of com.sequenceiq.flow.domain.FlowLogIdWithTypeAndTimestamp in project cloudbreak by hortonworks.
the class FlowLogDBServiceTest method doNotCancelTooYoungTerminationFlowForResourceTest.
@Test
public void doNotCancelTooYoungTerminationFlowForResourceTest() {
Set<FlowLogIdWithTypeAndTimestamp> flowLogs = new HashSet<>();
FlowLogIdWithTypeAndTimestamp flowLog1 = mock(FlowLogIdWithTypeAndTimestamp.class);
when(flowLog1.getFlowType()).thenReturn(ClassValue.of(TerminationFlowConfig.class));
when(flowLog1.getCreated()).thenReturn(11000L);
flowLogs.add(flowLog1);
FlowLogIdWithTypeAndTimestamp flowLog2 = mock(FlowLogIdWithTypeAndTimestamp.class);
when(flowLog2.getFlowType()).thenReturn(ClassValue.of(Class.class));
flowLogs.add(flowLog2);
when(flowLogRepository.findAllRunningFlowLogByResourceId(eq(1L))).thenReturn(flowLogs);
when(applicationFlowInformation.getTerminationFlow()).thenReturn(Collections.singletonList(TerminationFlowConfig.class));
underTest.cancelTooOldTerminationFlowForResource(1L, 10000L);
verify(flowLogRepository, times(0)).finalizeByFlowId(eq("flow1"));
verify(flowLogRepository, times(0)).finalizeByFlowId(eq("flow2"));
verify(flowLogRepository, times(0)).updateLastLogStatusInFlow(eq(10L), eq(StateStatus.SUCCESSFUL));
}
use of com.sequenceiq.flow.domain.FlowLogIdWithTypeAndTimestamp in project cloudbreak by hortonworks.
the class FlowLogDBServiceTest method cancelTooOldTerminationFlowForResourceTest.
@Test
public void cancelTooOldTerminationFlowForResourceTest() throws TransactionService.TransactionExecutionException {
Set<FlowLogIdWithTypeAndTimestamp> flowLogs = new LinkedHashSet<>();
FlowLogIdWithTypeAndTimestamp flowLog2 = mock(FlowLogIdWithTypeAndTimestamp.class);
when(flowLog2.getFlowType()).thenReturn(ClassValue.of(Class.class));
flowLogs.add(flowLog2);
FlowLogIdWithTypeAndTimestamp flowLog1 = mock(FlowLogIdWithTypeAndTimestamp.class);
when(flowLog1.getFlowType()).thenReturn(ClassValue.of(TerminationFlowConfig.class));
when(flowLog1.getCreated()).thenReturn(9000L);
when(flowLog1.getFlowId()).thenReturn("flow1");
flowLogs.add(flowLog1);
when(flowLogRepository.findAllRunningFlowLogByResourceId(eq(1L))).thenReturn(flowLogs);
FlowLog realFlowLog1 = mock(FlowLog.class);
when(realFlowLog1.getId()).thenReturn(10L);
when(flowLogRepository.findFirstByFlowIdOrderByCreatedDesc(eq("flow1"))).thenReturn(Optional.of(realFlowLog1));
when(applicationFlowInformation.getTerminationFlow()).thenReturn(Collections.singletonList(TerminationFlowConfig.class));
when(transactionService.required(any(Supplier.class))).thenAnswer(invocation -> ((Supplier) invocation.getArguments()[0]).get());
when(nodeConfig.getId()).thenReturn("node1");
underTest.cancelTooOldTerminationFlowForResource(1L, 10000L);
verify(flowLogRepository).finalizeByFlowId(eq("flow1"));
verify(flowLogRepository, times(0)).finalizeByFlowId(eq("flow2"));
verify(flowLogRepository).updateLastLogStatusInFlow(eq(10L), eq(StateStatus.SUCCESSFUL));
}
Aggregations