use of com.sequenceiq.cloudbreak.service.stackpatch.StackPatchService in project cloudbreak by hortonworks.
the class ExistingStackPatcherJobInitializerTest method alreadyFixedShouldNotBeRescheduled.
@Test
void alreadyFixedShouldNotBeRescheduled() {
when(config.getPatchConfigs()).thenReturn(Map.of(UNBOUND_RESTART, getConfig(true)));
StackPatch stackPatch = createStackPatch(stack1, UNBOUND_RESTART);
stackPatch.setStatus(StackPatchStatus.FIXED);
doReturn(List.of(stackPatch)).when(stackPatchService).findAllByTypeForStackIds(eq(UNBOUND_RESTART), any());
underTest.initJobs();
verify(jobService, times(1)).schedule(captor.capture());
Assertions.assertThat(captor.getAllValues()).noneMatch(a -> a.getJobResource().getLocalId().equals(ID_1) && a.getStackPatchType().equals(UNBOUND_RESTART)).anyMatch(a -> a.getJobResource().getLocalId().equals(ID_2) && a.getStackPatchType().equals(UNBOUND_RESTART));
verify(stackPatchService, never()).getOrCreate(Long.valueOf(ID_1), UNBOUND_RESTART);
verify(stackPatchService).getOrCreate(Long.valueOf(ID_2), UNBOUND_RESTART);
}
Aggregations