Search in sources :

Example 6 with UpdateItemAttributeRQ

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

the class LaunchControllerTest method bulkCreateAttributes.

@Test
void bulkCreateAttributes() throws Exception {
    BulkInfoUpdateRQ request = new BulkInfoUpdateRQ();
    List<Long> launchIds = Arrays.asList(1L, 2L, 3L, 4L);
    request.setIds(launchIds);
    BulkInfoUpdateRQ.Description description = new BulkInfoUpdateRQ.Description();
    description.setAction(BulkInfoUpdateRQ.Action.UPDATE);
    String comment = "updated";
    description.setComment(comment);
    request.setDescription(description);
    UpdateItemAttributeRQ updateItemAttributeRQ = new UpdateItemAttributeRQ();
    updateItemAttributeRQ.setAction(BulkInfoUpdateRQ.Action.CREATE);
    updateItemAttributeRQ.setTo(new ItemAttributeResource("createdKey", "createdValue"));
    request.setAttributes(Lists.newArrayList(updateItemAttributeRQ));
    mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/launch/info").with(token(oAuthHelper.getDefaultToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isOk());
    List<Launch> launches = launchRepository.findAllById(launchIds);
    launches.forEach(it -> launchRepository.refresh(it));
    launches.forEach(it -> {
        assertTrue(it.getAttributes().stream().anyMatch(attr -> "createdKey".equals(attr.getKey()) && attr.getValue().equals("createdValue") && !attr.isSystem()));
        assertTrue(it.getDescription().length() > comment.length() && it.getDescription().contains(comment));
    });
}
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) ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) UpdateItemAttributeRQ(com.epam.ta.reportportal.ws.model.attribute.UpdateItemAttributeRQ) BulkInfoUpdateRQ(com.epam.ta.reportportal.ws.model.BulkInfoUpdateRQ) Launch(com.epam.ta.reportportal.entity.launch.Launch) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Aggregations

LaunchRepository (com.epam.ta.reportportal.dao.LaunchRepository)6 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)6 Launch (com.epam.ta.reportportal.entity.launch.Launch)6 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)6 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)6 BulkInfoUpdateRQ (com.epam.ta.reportportal.ws.model.BulkInfoUpdateRQ)6 ItemAttributeResource (com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource)6 UpdateItemAttributeRQ (com.epam.ta.reportportal.ws.model.attribute.UpdateItemAttributeRQ)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 Lists (com.google.common.collect.Lists)6 Sets (com.google.common.collect.Sets)6 LocalDateTime (java.time.LocalDateTime)6 ZoneId (java.time.ZoneId)6 java.util (java.util)6 Matchers.hasSize (org.hamcrest.Matchers.hasSize)6 Assertions (org.junit.jupiter.api.Assertions)6 Test (org.junit.jupiter.api.Test)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 APPLICATION_JSON (org.springframework.http.MediaType.APPLICATION_JSON)6 Sql (org.springframework.test.context.jdbc.Sql)6