Search in sources :

Example 1 with IssueId

use of com.enonic.xp.issue.IssueId in project xp by enonic.

the class FindIssueCommentsCommandTest method testFindIssues.

@Test
public void testFindIssues() throws Exception {
    final IssueId issueId = IssueId.create();
    final Node issueNode = Node.create().id(NodeId.from(issueId)).name("parent-issue").build();
    final PrincipalKey creator = PrincipalKey.from("user:store:one");
    final IssueCommentQuery commentQuery = IssueCommentQuery.create().from(0).size(20).issue(issueId).creator(creator).build();
    final FindIssueCommentsCommand command = createCommand(commentQuery);
    Mockito.when(this.nodeService.getById(Mockito.any(NodeId.class))).thenReturn(issueNode);
    Mockito.when(nodeService.findByQuery(Mockito.any(NodeQuery.class))).thenReturn(FindNodesByQueryResult.create().hits(20).totalHits(40).build());
    Mockito.when(nodeService.getByIds(Mockito.any(NodeIds.class))).thenReturn(Nodes.from(IssueCommentNodeTranslatorTest.createNode(Instant.now())));
    FindIssueCommentsResult result = command.execute();
    Mockito.verify(nodeService, Mockito.times(1)).findByQuery(Mockito.any(NodeQuery.class));
    Mockito.verify(nodeService, Mockito.times(1)).getByIds(Mockito.any(NodeIds.class));
    assertEquals(20, result.getHits());
    assertEquals(40, result.getTotalHits());
    assertEquals(1, result.getIssueComments().size());
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) Node(com.enonic.xp.node.Node) NodeQuery(com.enonic.xp.node.NodeQuery) NodeId(com.enonic.xp.node.NodeId) FindIssueCommentsResult(com.enonic.xp.issue.FindIssueCommentsResult) IssueId(com.enonic.xp.issue.IssueId) IssueCommentQuery(com.enonic.xp.issue.IssueCommentQuery) PrincipalKey(com.enonic.xp.security.PrincipalKey) Test(org.junit.jupiter.api.Test)

Example 2 with IssueId

use of com.enonic.xp.issue.IssueId in project xp by enonic.

the class FindIssueCommentsCommandTest method testFindIssuesIssueNotExists.

@Test
public void testFindIssuesIssueNotExists() throws Exception {
    final IssueId issueId = IssueId.create();
    final PrincipalKey creator = PrincipalKey.from("user:store:one");
    final IssueCommentQuery commentQuery = IssueCommentQuery.create().from(0).size(20).issue(issueId).creator(creator).build();
    final FindIssueCommentsCommand command = createCommand(commentQuery);
    Mockito.when(this.nodeService.getById(Mockito.any(NodeId.class))).thenThrow(new NodeNotFoundException("Node not found"));
    assertThrows(NodeNotFoundException.class, () -> command.execute());
}
Also used : NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) NodeId(com.enonic.xp.node.NodeId) IssueId(com.enonic.xp.issue.IssueId) IssueCommentQuery(com.enonic.xp.issue.IssueCommentQuery) PrincipalKey(com.enonic.xp.security.PrincipalKey) Test(org.junit.jupiter.api.Test)

Example 3 with IssueId

use of com.enonic.xp.issue.IssueId in project xp by enonic.

the class IssueServiceImplTest_getIssue method get_issue.

@Test
public void get_issue() throws Exception {
    final IssueId issueId = this.createIssue(CreateIssueParams.create().title("title").description("description").setApproverIds(PrincipalKeys.from("user:myStore:approver-1")).setPublishRequest(PublishRequest.create().addExcludeId(ContentId.from("exclude-id")).addItem(PublishRequestItem.create().id(ContentId.from("content-id")).includeChildren(true).build()).build())).getId();
    final Issue issue = this.issueService.getIssue(issueId);
    assertNotNull(issue);
    assertEquals("title", issue.getTitle());
    assertEquals("description", issue.getDescription());
    assertEquals(IssueStatus.OPEN, issue.getStatus());
    assertEquals(PrincipalKey.from("user:system:test-user"), issue.getCreator());
    assertEquals(PrincipalKey.from("user:myStore:approver-1"), issue.getApproverIds().first());
    assertEquals(ContentId.from("content-id"), issue.getPublishRequest().getItems().first().getId());
    assertEquals(IssueNameFactory.create(issue.getIndex()), issue.getName());
}
Also used : Issue(com.enonic.xp.issue.Issue) IssueId(com.enonic.xp.issue.IssueId) Test(org.junit.jupiter.api.Test)

Aggregations

IssueId (com.enonic.xp.issue.IssueId)3 Test (org.junit.jupiter.api.Test)3 IssueCommentQuery (com.enonic.xp.issue.IssueCommentQuery)2 NodeId (com.enonic.xp.node.NodeId)2 PrincipalKey (com.enonic.xp.security.PrincipalKey)2 FindIssueCommentsResult (com.enonic.xp.issue.FindIssueCommentsResult)1 Issue (com.enonic.xp.issue.Issue)1 Node (com.enonic.xp.node.Node)1 NodeIds (com.enonic.xp.node.NodeIds)1 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)1 NodeQuery (com.enonic.xp.node.NodeQuery)1