Search in sources :

Example 6 with ItemAttributeResource

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

the class LaunchControllerTest method bulkUpdateItemAttributes.

@Test
void bulkUpdateItemAttributes() 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.CREATE);
    String comment = "created";
    description.setComment(comment);
    request.setDescription(description);
    UpdateItemAttributeRQ updateItemAttributeRQ = new UpdateItemAttributeRQ();
    updateItemAttributeRQ.setAction(BulkInfoUpdateRQ.Action.UPDATE);
    updateItemAttributeRQ.setFrom(new ItemAttributeResource("testKey", "testValue"));
    updateItemAttributeRQ.setTo(new ItemAttributeResource("updatedKey", "updatedValue"));
    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().noneMatch(attr -> "testKey".equals(attr.getKey()) && attr.getValue().equals("testValue") && !attr.isSystem()));
        assertTrue(it.getAttributes().stream().anyMatch(attr -> "updatedKey".equals(attr.getKey()) && attr.getValue().equals("updatedValue") && !attr.isSystem()));
        assertEquals(comment, it.getDescription());
    });
}
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 7 with ItemAttributeResource

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

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

the class LaunchControllerTest method bulkDeleteAttributes.

@Test
void bulkDeleteAttributes() 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.CREATE);
    String comment = "created";
    description.setComment(comment);
    request.setDescription(description);
    UpdateItemAttributeRQ updateItemAttributeRQ = new UpdateItemAttributeRQ();
    updateItemAttributeRQ.setAction(BulkInfoUpdateRQ.Action.DELETE);
    updateItemAttributeRQ.setFrom(new ItemAttributeResource("testKey", "testValue"));
    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().noneMatch(attr -> "testKey".equals(attr.getKey()) && attr.getValue().equals("testValue") && !attr.isSystem()));
        assertEquals(comment, it.getDescription());
    });
}
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 9 with ItemAttributeResource

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

the class TestItemBuilderTest method addResultsTest.

@Test
void addResultsTest() {
    TestItem item = new TestItem();
    final LocalDateTime now = LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS);
    item.setStartTime(now);
    final TestItemResults itemResults = new TestItemResults();
    itemResults.setEndTime(now.plusSeconds(120));
    item.setItemResults(itemResults);
    final ItemAttribute systemAttribute = new ItemAttribute("key", "val", true);
    item.setAttributes(Sets.newHashSet(new ItemAttribute("key", "val", false), systemAttribute));
    final TestItem resultItem = new TestItemBuilder(item).addTestItemResults(itemResults).addStatus(StatusEnum.PASSED).overwriteAttributes(Sets.newHashSet(new ItemAttributeResource("k", "v"))).get();
    assertEquals(120, resultItem.getItemResults().getDuration(), 0.1);
    assertEquals(StatusEnum.PASSED, resultItem.getItemResults().getStatus());
    assertThat(resultItem.getAttributes()).containsExactlyInAnyOrder(systemAttribute, new ItemAttribute("k", "v", false));
}
Also used : LocalDateTime(java.time.LocalDateTime) ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) ItemAttribute(com.epam.ta.reportportal.entity.ItemAttribute) TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Example 10 with ItemAttributeResource

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

the class NotificationConfigConverterTest method getCaseDTO.

private static SenderCaseDTO getCaseDTO() {
    SenderCaseDTO senderCaseDTO = new SenderCaseDTO();
    senderCaseDTO.setRecipients(Arrays.asList("recipient1", "recipient2"));
    senderCaseDTO.setLaunchNames(Arrays.asList("launch1", "launch2"));
    final ItemAttributeResource launchAttribute = new ItemAttributeResource();
    launchAttribute.setKey("key");
    launchAttribute.setValue("val");
    senderCaseDTO.setAttributes(Sets.newHashSet(launchAttribute));
    senderCaseDTO.setSendCase("always");
    senderCaseDTO.setEnabled(true);
    return senderCaseDTO;
}
Also used : ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) SenderCaseDTO(com.epam.ta.reportportal.ws.model.project.email.SenderCaseDTO)

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