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