use of com.epam.ta.reportportal.entity.project.ProjectAttribute in project service-api by reportportal.
the class InterruptBrokenLaunchesJobTest method interruptLaunchWithInProgressItemsTest.
@Test
void interruptLaunchWithInProgressItemsTest() {
String name = "name";
Project project = new Project();
final ProjectAttribute projectAttribute = new ProjectAttribute();
final Attribute attribute = new Attribute();
attribute.setName("job.interruptJobTime");
projectAttribute.setAttribute(attribute);
// 1 day in seconds
projectAttribute.setValue(String.valueOf(3600 * 24));
project.setProjectAttributes(Sets.newHashSet(projectAttribute));
project.setName(name);
long launchId = 1L;
when(projectRepository.findAllIdsAndProjectAttributes(any())).thenReturn(new PageImpl<>(Collections.singletonList(project)));
when(launchRepository.streamIdsWithStatusAndStartTimeBefore(any(), any(), any())).thenReturn(Stream.of(launchId));
when(testItemRepository.hasItemsInStatusByLaunch(launchId, StatusEnum.IN_PROGRESS)).thenReturn(true);
when(testItemRepository.hasItemsInStatusAddedLately(launchId, Duration.ofSeconds(3600 * 24), StatusEnum.IN_PROGRESS)).thenReturn(false);
when(testItemRepository.hasLogs(launchId, Duration.ofSeconds(3600 * 24), StatusEnum.IN_PROGRESS)).thenReturn(true);
when(logRepository.hasLogsAddedLately(Duration.ofSeconds(3600 * 24), launchId, StatusEnum.IN_PROGRESS)).thenReturn(false);
when(launchRepository.findById(launchId)).thenReturn(Optional.of(new Launch()));
interruptBrokenLaunchesJob.execute(null);
verify(testItemRepository, times(1)).interruptInProgressItems(launchId);
verify(launchRepository, times(1)).findById(launchId);
verify(launchRepository, times(1)).save(any());
}
Aggregations