Search in sources :

Example 6 with ProjectAttribute

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());
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) Attribute(com.epam.ta.reportportal.entity.attribute.Attribute) ProjectAttribute(com.epam.ta.reportportal.entity.project.ProjectAttribute) ProjectAttribute(com.epam.ta.reportportal.entity.project.ProjectAttribute) Launch(com.epam.ta.reportportal.entity.launch.Launch) Test(org.junit.jupiter.api.Test)

Aggregations

ProjectAttribute (com.epam.ta.reportportal.entity.project.ProjectAttribute)6 Project (com.epam.ta.reportportal.entity.project.Project)5 Attribute (com.epam.ta.reportportal.entity.attribute.Attribute)4 Test (org.junit.jupiter.api.Test)4 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2 Launch (com.epam.ta.reportportal.entity.launch.Launch)2 ProjectEvent (com.epam.reportportal.extension.event.ProjectEvent)1 ProjectRepository (com.epam.ta.reportportal.dao.ProjectRepository)1 ProjectType (com.epam.ta.reportportal.entity.enums.ProjectType)1 ProjectUser (com.epam.ta.reportportal.entity.user.ProjectUser)1 User (com.epam.ta.reportportal.entity.user.User)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)1 DeleteBulkRQ (com.epam.ta.reportportal.ws.model.DeleteBulkRQ)1 EntryCreatedRS (com.epam.ta.reportportal.ws.model.EntryCreatedRS)1 ItemAttributeResource (com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource)1 AnalyzeLaunchRQ (com.epam.ta.reportportal.ws.model.launch.AnalyzeLaunchRQ)1 AssignUsersRQ (com.epam.ta.reportportal.ws.model.project.AssignUsersRQ)1 CreateProjectRQ (com.epam.ta.reportportal.ws.model.project.CreateProjectRQ)1 UnassignUsersRQ (com.epam.ta.reportportal.ws.model.project.UnassignUsersRQ)1