Search in sources :

Example 11 with ItemAttributeResource

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

the class LaunchResourceAttributeUpdaterTest method shouldUpdate.

@Test
void shouldUpdate() {
    final LaunchResource launchResource = new LaunchResource();
    final List<ItemAttribute> attributes = List.of(new ItemAttribute("k1", "v1", false), new ItemAttribute("k2", "v2", false));
    launchResourceAttributeUpdater.handle(launchResource, attributes);
    final Set<ItemAttributeResource> resourceAttributes = launchResource.getAttributes();
    Assertions.assertEquals(2, resourceAttributes.size());
    final Map<String, List<ItemAttributeResource>> mapping = resourceAttributes.stream().collect(groupingBy(ItemAttributeResource::getKey));
    final ItemAttributeResource firstResource = mapping.get("k1").get(0);
    final ItemAttributeResource secondResource = mapping.get("k2").get(0);
    final ItemAttribute firstAttribute = attributes.get(0);
    final ItemAttribute secondAttribute = attributes.get(1);
    shouldEqual(firstAttribute, firstResource);
    shouldEqual(secondAttribute, secondResource);
}
Also used : ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) List(java.util.List) ItemAttribute(com.epam.ta.reportportal.entity.ItemAttribute) LaunchResource(com.epam.ta.reportportal.ws.model.launch.LaunchResource) Test(org.junit.jupiter.api.Test)

Example 12 with ItemAttributeResource

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

Example 13 with ItemAttributeResource

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

the class ProjectControllerTest method updateProjectNotificationConfig.

@Test
void updateProjectNotificationConfig() throws Exception {
    ProjectNotificationConfigDTO request = new ProjectNotificationConfigDTO();
    SenderCaseDTO senderCaseDTO = new SenderCaseDTO();
    senderCaseDTO.setSendCase("always");
    senderCaseDTO.setRecipients(Collections.singletonList("default"));
    senderCaseDTO.setLaunchNames(Collections.singletonList("test launch"));
    senderCaseDTO.setEnabled(true);
    ItemAttributeResource launchAttribute = new ItemAttributeResource();
    launchAttribute.setKey("key");
    launchAttribute.setValue("val");
    senderCaseDTO.setAttributes(Sets.newHashSet(launchAttribute));
    request.setSenderCases(singletonList(senderCaseDTO));
    mockMvc.perform(put("/v1/project/default_personal/notification").with(token(oAuthHelper.getDefaultToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isOk());
}
Also used : ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) ProjectNotificationConfigDTO(com.epam.ta.reportportal.ws.model.project.email.ProjectNotificationConfigDTO) SenderCaseDTO(com.epam.ta.reportportal.ws.model.project.email.SenderCaseDTO) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 14 with ItemAttributeResource

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

the class LaunchBuilderTest method overwriteAttributes.

@Test
void overwriteAttributes() {
    Launch launch = new Launch();
    final ItemAttribute systemAttribute = new ItemAttribute("key", "value", true);
    launch.setAttributes(Sets.newHashSet(new ItemAttribute("key", "value", false), systemAttribute));
    final Launch buildLaunch = new LaunchBuilder(launch).overwriteAttributes(Sets.newHashSet(new ItemAttributeResource("newKey", "newVal"))).get();
    assertThat(buildLaunch.getAttributes()).containsExactlyInAnyOrder(new ItemAttribute("newKey", "newVal", false), systemAttribute);
}
Also used : ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) ItemAttribute(com.epam.ta.reportportal.entity.ItemAttribute) Launch(com.epam.ta.reportportal.entity.launch.Launch) Test(org.junit.jupiter.api.Test)

Example 15 with ItemAttributeResource

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

the class LaunchBuilderTest method launchBuilder.

@Test
void launchBuilder() {
    final String description = "description";
    final LocalDateTime now = LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS);
    final Date date = TO_DATE.apply(now);
    final Long projectId = 1L;
    final ItemAttributeResource attributeResource = new ItemAttributeResource("key", "value");
    final Long userId = 2L;
    final String passed = "PASSED";
    final Mode mode = Mode.DEFAULT;
    final Launch launch = new LaunchBuilder().addDescription(description).addEndTime(date).addProject(projectId).addAttribute(attributeResource).addUserId(userId).addStatus(passed).addMode(mode).get();
    assertEquals(description, launch.getDescription());
    assertEquals(now, launch.getEndTime());
    assertEquals(projectId, launch.getProjectId());
    assertTrue(launch.getAttributes().contains(new ItemAttribute("key", "value", false)));
    assertEquals(userId, launch.getUserId());
    assertEquals(passed, launch.getStatus().name());
    assertEquals(LaunchModeEnum.DEFAULT, launch.getMode());
}
Also used : LocalDateTime(java.time.LocalDateTime) ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) Mode(com.epam.ta.reportportal.ws.model.launch.Mode) ItemAttribute(com.epam.ta.reportportal.entity.ItemAttribute) Launch(com.epam.ta.reportportal.entity.launch.Launch) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

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