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());
});
}
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));
}
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());
});
}
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));
}
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;
}
Aggregations