use of com.epam.ta.reportportal.ws.model.BulkInfoUpdateRQ in project service-api by reportportal.
the class TestItemControllerTest method bulkUpdateItemAttributes.
@Test
void bulkUpdateItemAttributes() throws Exception {
BulkInfoUpdateRQ request = new BulkInfoUpdateRQ();
List<Long> launchIds = Arrays.asList(1L, 2L, 3L, 4L, 5L, 6L);
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 + "/item/info").with(token(oAuthHelper.getDefaultToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isOk());
List<TestItem> items = testItemRepository.findAllById(launchIds);
items.forEach(it -> testItemRepository.refresh(it));
items.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.BulkInfoUpdateRQ in project service-api by reportportal.
the class TestItemControllerTest method bulkDeleteAttributes.
@Test
void bulkDeleteAttributes() throws Exception {
BulkInfoUpdateRQ request = new BulkInfoUpdateRQ();
List<Long> launchIds = Arrays.asList(1L, 2L, 3L, 4L, 5L, 6L);
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 + "/item/info").with(token(oAuthHelper.getDefaultToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isOk());
List<TestItem> items = testItemRepository.findAllById(launchIds);
items.forEach(it -> testItemRepository.refresh(it));
items.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.BulkInfoUpdateRQ in project service-api by reportportal.
the class TestItemControllerTest method bulkCreateAttributes.
@Test
void bulkCreateAttributes() throws Exception {
BulkInfoUpdateRQ request = new BulkInfoUpdateRQ();
List<Long> launchIds = Arrays.asList(1L, 2L, 3L, 4L, 5L, 6L);
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 + "/item/info").with(token(oAuthHelper.getDefaultToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isOk());
List<TestItem> items = testItemRepository.findAllById(launchIds);
items.forEach(it -> testItemRepository.refresh(it));
items.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.BulkInfoUpdateRQ 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.BulkInfoUpdateRQ 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());
});
}
Aggregations