Search in sources :

Example 1 with EntityVO

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()));
}
Also used : EntityVO(com.epam.pipeline.vo.EntityVO) LoaderVerificationUtils.verifyIssue(com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyIssue) Issue(com.epam.pipeline.entity.issue.Issue) IssueComment(com.epam.pipeline.entity.issue.IssueComment) EntityContainer(com.epam.pipeline.elasticsearchagent.model.EntityContainer) Attachment(com.epam.pipeline.entity.issue.Attachment) Test(org.junit.jupiter.api.Test)

Example 2 with EntityVO

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;
}
Also used : EntityVO(com.epam.pipeline.vo.EntityVO) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) MetadataEntry(com.epam.pipeline.entity.metadata.MetadataEntry)

Example 3 with EntityVO

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);
}
Also used : EntityVO(com.epam.pipeline.vo.EntityVO) MapperVerificationUtils.verifyIssue(com.epam.pipeline.elasticsearchagent.MapperVerificationUtils.verifyIssue) Issue(com.epam.pipeline.entity.issue.Issue) IssueComment(com.epam.pipeline.entity.issue.IssueComment) Attachment(com.epam.pipeline.entity.issue.Attachment) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

EntityVO (com.epam.pipeline.vo.EntityVO)3 Attachment (com.epam.pipeline.entity.issue.Attachment)2 Issue (com.epam.pipeline.entity.issue.Issue)2 IssueComment (com.epam.pipeline.entity.issue.IssueComment)2 Test (org.junit.jupiter.api.Test)2 LoaderVerificationUtils.verifyIssue (com.epam.pipeline.elasticsearchagent.LoaderVerificationUtils.verifyIssue)1 MapperVerificationUtils.verifyIssue (com.epam.pipeline.elasticsearchagent.MapperVerificationUtils.verifyIssue)1 EntityContainer (com.epam.pipeline.elasticsearchagent.model.EntityContainer)1 MetadataEntry (com.epam.pipeline.entity.metadata.MetadataEntry)1 PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)1 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)1