Search in sources :

Example 1 with UpdateLaunchRQ

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

the class LaunchControllerTest method updateLaunchPositive.

@Test
void updateLaunchPositive() throws Exception {
    UpdateLaunchRQ rq = new UpdateLaunchRQ();
    rq.setMode(DEFAULT);
    rq.setDescription("description");
    rq.setAttributes(Sets.newHashSet(new ItemAttributeResource("test", "test")));
    mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/launch/3/update").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON)).andExpect(status().is(200));
}
Also used : ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) UpdateLaunchRQ(com.epam.ta.reportportal.ws.model.launch.UpdateLaunchRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 2 with UpdateLaunchRQ

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

the class UpdateLaunchHandlerImplTest method updateDebugLaunchByCustomer.

@Test
void updateDebugLaunchByCustomer() {
    final ReportPortalUser rpUser = getRpUser("test", UserRole.USER, ProjectRole.CUSTOMER, 1L);
    when(getProjectHandler.getProject(any(ReportPortalUser.ProjectDetails.class))).thenReturn(new Project());
    when(launchRepository.findById(1L)).thenReturn(getLaunch(StatusEnum.PASSED, LaunchModeEnum.DEFAULT));
    final UpdateLaunchRQ updateLaunchRQ = new UpdateLaunchRQ();
    updateLaunchRQ.setMode(Mode.DEBUG);
    final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.updateLaunch(1L, extractProjectDetails(rpUser, "test_project"), rpUser, updateLaunchRQ));
    assertEquals("You do not have enough permissions.", exception.getMessage());
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) TestProjectExtractor.extractProjectDetails(com.epam.ta.reportportal.util.TestProjectExtractor.extractProjectDetails) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) UpdateLaunchRQ(com.epam.ta.reportportal.ws.model.launch.UpdateLaunchRQ) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Test(org.junit.jupiter.api.Test)

Example 3 with UpdateLaunchRQ

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

the class UpdateLaunchHandlerImplTest method updateNotOwnLaunch.

@Test
void updateNotOwnLaunch() {
    final ReportPortalUser rpUser = getRpUser("not owner", UserRole.USER, ProjectRole.MEMBER, 1L);
    rpUser.setUserId(2L);
    when(getProjectHandler.getProject(any(ReportPortalUser.ProjectDetails.class))).thenReturn(new Project());
    when(launchRepository.findById(1L)).thenReturn(getLaunch(StatusEnum.PASSED, LaunchModeEnum.DEFAULT));
    final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.updateLaunch(1L, extractProjectDetails(rpUser, "test_project"), rpUser, new UpdateLaunchRQ()));
    assertEquals("You do not have enough permissions.", exception.getMessage());
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) TestProjectExtractor.extractProjectDetails(com.epam.ta.reportportal.util.TestProjectExtractor.extractProjectDetails) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) UpdateLaunchRQ(com.epam.ta.reportportal.ws.model.launch.UpdateLaunchRQ) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Test(org.junit.jupiter.api.Test)

Example 4 with UpdateLaunchRQ

use of com.epam.ta.reportportal.ws.model.launch.UpdateLaunchRQ 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)

Aggregations

UpdateLaunchRQ (com.epam.ta.reportportal.ws.model.launch.UpdateLaunchRQ)4 Test (org.junit.jupiter.api.Test)4 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)3 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2 Project (com.epam.ta.reportportal.entity.project.Project)2 TestProjectExtractor.extractProjectDetails (com.epam.ta.reportportal.util.TestProjectExtractor.extractProjectDetails)2 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)2 ItemAttributeResource (com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource)2 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 BulkInfoUpdateRQ (com.epam.ta.reportportal.ws.model.BulkInfoUpdateRQ)1 BulkRQ (com.epam.ta.reportportal.ws.model.BulkRQ)1 DeleteBulkRQ (com.epam.ta.reportportal.ws.model.DeleteBulkRQ)1 FinishExecutionRQ (com.epam.ta.reportportal.ws.model.FinishExecutionRQ)1 ItemAttributesRQ (com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)1