use of com.epam.pipeline.vo.EntityVO in project cloud-pipeline by epam.
the class IssueLoaderTest method shouldLoadIssueTest.
@Test
void shouldLoadIssueTest() throws EntityNotFoundException {
Attachment attachment = new Attachment();
attachment.setPath(TEST_PATH);
attachment.setOwner(USER_NAME);
IssueComment comment = IssueComment.builder().author(USER_NAME).text(TEST_DESCRIPTION).build();
EntityVO entity = new EntityVO(1L, AclClass.TOOL);
Issue expectedIssue = Issue.builder().id(1L).name(TEST_NAME).text(TEST_DESCRIPTION).status(IssueStatus.OPEN).labels(Collections.singletonList(TEST_LABEL)).attachments(Collections.singletonList(attachment)).comments(Collections.singletonList(comment)).entity(entity).author(TEST_NAME).build();
IssueLoader issueLoader = new IssueLoader(apiClient);
when(apiClient.loadIssue(anyLong())).thenReturn(expectedIssue);
Optional<EntityContainer<Issue>> container = issueLoader.loadEntity(1L);
EntityContainer<Issue> issueEntityContainer = container.orElseThrow(AssertionError::new);
Issue actualIssue = issueEntityContainer.getEntity();
assertNotNull(actualIssue);
verifyIssue(expectedIssue, actualIssue);
verifyPipelineUser(issueEntityContainer.getOwner());
verifyPermissions(PERMISSIONS_CONTAINER_WITH_OWNER, issueEntityContainer.getPermissions());
verifyMetadata(EXPECTED_METADATA, new ArrayList<>(issueEntityContainer.getMetadata().values()));
}
use of com.epam.pipeline.vo.EntityVO in project cloud-pipeline by epam.
the class ObjectCreationUtils method buildMetadataEntry.
public static MetadataEntry buildMetadataEntry(final AclClass aclClass, final Long entityId, final String metadataValue) {
EntityVO entityVO = new EntityVO(entityId, aclClass);
MetadataEntry metadataEntry = new MetadataEntry();
metadataEntry.setEntity(entityVO);
metadataEntry.setData(Collections.singletonMap(TEST_NAME, new PipeConfValue(TEST_NAME, metadataValue)));
return metadataEntry;
}
use of com.epam.pipeline.vo.EntityVO in project cloud-pipeline by epam.
the class IssueMapperTest method shouldMapIssue.
@Test
void shouldMapIssue() throws IOException {
IssueMapper mapper = new IssueMapper();
Attachment attachment = new Attachment();
attachment.setPath(TEST_PATH);
attachment.setOwner(USER_NAME);
IssueComment comment = IssueComment.builder().author(USER_NAME).text(TEST_DESCRIPTION).build();
EntityVO entity = new EntityVO(1L, AclClass.TOOL);
Issue issue = Issue.builder().id(1L).name(TEST_NAME).text(TEST_DESCRIPTION).status(IssueStatus.OPEN).labels(Collections.singletonList(TEST_LABEL)).attachments(Collections.singletonList(attachment)).comments(Collections.singletonList(comment)).entity(entity).build();
EntityContainer<Issue> container = EntityContainer.<Issue>builder().entity(issue).owner(USER).permissions(PERMISSIONS_CONTAINER).build();
XContentBuilder contentBuilder = mapper.map(container);
verifyIssue(issue, contentBuilder);
verifyAttachments(Collections.singletonList(attachment.getPath()), contentBuilder);
verifyComments(Collections.singletonList(comment.getAuthor() + " : " + comment.getText()), contentBuilder);
verifyPipelineUser(USER, contentBuilder);
verifyPermissions(PERMISSIONS_CONTAINER, contentBuilder);
}
Aggregations