Search in sources :

Example 1 with BulkRQ

use of com.epam.ta.reportportal.ws.model.BulkRQ in project service-api by reportportal.

the class FinishLaunchHandlerImplTest method bulkStopLaunch.

@Test
void bulkStopLaunch() {
    FinishExecutionRQ finishExecutionRQ = new FinishExecutionRQ();
    finishExecutionRQ.setEndTime(Date.from(LocalDateTime.now().atZone(ZoneId.of("UTC")).toInstant()));
    Map<Long, FinishExecutionRQ> entities = new HashMap<>();
    entities.put(1L, finishExecutionRQ);
    BulkRQ<Long, FinishExecutionRQ> bulkRq = new BulkRQ<>();
    bulkRq.setEntities(entities);
    ReportPortalUser rpUser = getRpUser("test", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
    when(launchRepository.findById(1L)).thenReturn(getLaunch(StatusEnum.IN_PROGRESS, LaunchModeEnum.DEFAULT));
    final List<OperationCompletionRS> response = stopLaunchHandler.stopLaunch(bulkRq, extractProjectDetails(rpUser, "test_project"), rpUser);
    assertNotNull(response);
    assertEquals(1, response.size());
}
Also used : BulkRQ(com.epam.ta.reportportal.ws.model.BulkRQ) HashMap(java.util.HashMap) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) FinishExecutionRQ(com.epam.ta.reportportal.ws.model.FinishExecutionRQ) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) Test(org.junit.jupiter.api.Test)

Example 2 with BulkRQ

use of com.epam.ta.reportportal.ws.model.BulkRQ in project service-api by reportportal.

the class LaunchControllerTest method bulkMoveToDebug.

@Test
void bulkMoveToDebug() throws Exception {
    final List<Long> ids = launchRepository.findByFilter(Filter.builder().withTarget(Launch.class).withCondition(FilterCondition.builder().eq(CRITERIA_PROJECT_ID, String.valueOf(2L)).build()).build()).stream().filter(it -> it.getMode() == LaunchModeEnum.DEFAULT).map(Launch::getId).collect(Collectors.toList());
    final Map<Long, UpdateLaunchRQ> entities = ids.stream().collect(toMap(it -> it, it -> {
        final UpdateLaunchRQ updateLaunchRQ = new UpdateLaunchRQ();
        updateLaunchRQ.setMode(DEBUG);
        return updateLaunchRQ;
    }));
    final BulkRQ<Long, UpdateLaunchRQ> bulkRQ = new BulkRQ<>();
    bulkRQ.setEntities(entities);
    mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/launch/update").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(bulkRQ)).contentType(APPLICATION_JSON)).andExpect(status().is(200));
    launchRepository.findAllById(ids).forEach(it -> assertSame(it.getMode(), LaunchModeEnum.DEBUG));
}
Also used : UpdateLaunchRQ(com.epam.ta.reportportal.ws.model.launch.UpdateLaunchRQ) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) CRITERIA_PROJECT_ID(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_PROJECT_ID) java.util(java.util) MockMvcResultMatchers.jsonPath(org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath) DeleteBulkRQ(com.epam.ta.reportportal.ws.model.DeleteBulkRQ) BulkInfoUpdateRQ(com.epam.ta.reportportal.ws.model.BulkInfoUpdateRQ) BulkRQ(com.epam.ta.reportportal.ws.model.BulkRQ) LocalDateTime(java.time.LocalDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) DEFAULT(com.epam.ta.reportportal.ws.model.launch.Mode.DEFAULT) ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) Lists(com.google.common.collect.Lists) Collectors.toMap(java.util.stream.Collectors.toMap) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) UpdateItemAttributeRQ(com.epam.ta.reportportal.ws.model.attribute.UpdateItemAttributeRQ) Matchers.hasSize(org.hamcrest.Matchers.hasSize) APPLICATION_JSON(org.springframework.http.MediaType.APPLICATION_JSON) MergeLaunchesRQ(com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ) Launch(com.epam.ta.reportportal.entity.launch.Launch) FinishExecutionRQ(com.epam.ta.reportportal.ws.model.FinishExecutionRQ) DEBUG(com.epam.ta.reportportal.ws.model.launch.Mode.DEBUG) Filter(com.epam.ta.reportportal.commons.querygen.Filter) LaunchModeEnum(com.epam.ta.reportportal.entity.enums.LaunchModeEnum) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) Sql(org.springframework.test.context.jdbc.Sql) Collectors(java.util.stream.Collectors) MockMvcRequestBuilders(org.springframework.test.web.servlet.request.MockMvcRequestBuilders) Sets(com.google.common.collect.Sets) ZoneId(java.time.ZoneId) AnalyzeLaunchRQ(com.epam.ta.reportportal.ws.model.launch.AnalyzeLaunchRQ) Test(org.junit.jupiter.api.Test) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) Stream(java.util.stream.Stream) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) LaunchRepository(com.epam.ta.reportportal.dao.LaunchRepository) Assertions(org.junit.jupiter.api.Assertions) DeleteBulkRQ(com.epam.ta.reportportal.ws.model.DeleteBulkRQ) BulkRQ(com.epam.ta.reportportal.ws.model.BulkRQ) UpdateLaunchRQ(com.epam.ta.reportportal.ws.model.launch.UpdateLaunchRQ) Launch(com.epam.ta.reportportal.entity.launch.Launch) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 3 with BulkRQ

use of com.epam.ta.reportportal.ws.model.BulkRQ in project service-api by reportportal.

the class LaunchControllerTest method bulkForceFinish.

@Test
void bulkForceFinish() throws Exception {
    final BulkRQ<Long, FinishExecutionRQ> bulkRQ = new BulkRQ<>();
    bulkRQ.setEntities(Stream.of(3L, 5L).collect(toMap(it -> it, it -> {
        FinishExecutionRQ finishExecutionRQ = new FinishExecutionRQ();
        finishExecutionRQ.setStatus(StatusEnum.PASSED.name());
        finishExecutionRQ.setEndTime(Date.from(LocalDateTime.now().atZone(ZoneId.of("UTC")).toInstant()));
        return finishExecutionRQ;
    })));
    mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/launch/stop").with(token(oAuthHelper.getDefaultToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(bulkRQ))).andExpect(status().isOk());
}
Also used : DeleteBulkRQ(com.epam.ta.reportportal.ws.model.DeleteBulkRQ) BulkRQ(com.epam.ta.reportportal.ws.model.BulkRQ) FinishExecutionRQ(com.epam.ta.reportportal.ws.model.FinishExecutionRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Aggregations

BulkRQ (com.epam.ta.reportportal.ws.model.BulkRQ)3 FinishExecutionRQ (com.epam.ta.reportportal.ws.model.FinishExecutionRQ)3 Test (org.junit.jupiter.api.Test)3 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)2 DeleteBulkRQ (com.epam.ta.reportportal.ws.model.DeleteBulkRQ)2 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 Filter (com.epam.ta.reportportal.commons.querygen.Filter)1 FilterCondition (com.epam.ta.reportportal.commons.querygen.FilterCondition)1 CRITERIA_PROJECT_ID (com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_PROJECT_ID)1 LaunchRepository (com.epam.ta.reportportal.dao.LaunchRepository)1 LaunchModeEnum (com.epam.ta.reportportal.entity.enums.LaunchModeEnum)1 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)1 Launch (com.epam.ta.reportportal.entity.launch.Launch)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 BulkInfoUpdateRQ (com.epam.ta.reportportal.ws.model.BulkInfoUpdateRQ)1 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)1 ItemAttributeResource (com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource)1 ItemAttributesRQ (com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)1 UpdateItemAttributeRQ (com.epam.ta.reportportal.ws.model.attribute.UpdateItemAttributeRQ)1 AnalyzeLaunchRQ (com.epam.ta.reportportal.ws.model.launch.AnalyzeLaunchRQ)1