use of com.enonic.xp.issue.FindIssuesResult in project xp by enonic.
the class FindIssuesCommandTest method testFindIssuesByItems.
@Test
public void testFindIssuesByItems() throws Exception {
final IssueQuery issueQuery = IssueQuery.create().from(0).size(20).status(IssueStatus.OPEN).items(ContentIds.from("content-id")).build();
final FindIssuesCommand command = createCommand(issueQuery);
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(IssueNodeTranslatorTest.createNode()));
FindIssuesResult 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.getIssues().size());
}
use of com.enonic.xp.issue.FindIssuesResult in project xp by enonic.
the class FindIssuesCommandTest method testFindIssues.
@Test
public void testFindIssues() throws Exception {
final IssueQuery issueQuery = IssueQuery.create().from(0).size(20).status(IssueStatus.OPEN).build();
final FindIssuesCommand command = createCommand(issueQuery);
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(IssueNodeTranslatorTest.createNode()));
FindIssuesResult 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.getIssues().size());
}
use of com.enonic.xp.issue.FindIssuesResult in project xp by enonic.
the class IssueServiceImplTest_findIssues method findByContentId1.
@Test
public void findByContentId1() throws Exception {
ContentId contentId = ContentId.from("issue-item-1");
IssueQuery query = IssueQuery.create().items(ContentIds.from(contentId)).build();
final FindIssuesResult result = this.issueService.findIssues(query);
assertNotNull(result);
assertEquals(2, result.getHits());
assertTrue(result.getIssues().stream().allMatch(issue -> issue.getPublishRequest().getItems().stream().anyMatch(item -> item.getId().equals(contentId))));
}
use of com.enonic.xp.issue.FindIssuesResult in project xp by enonic.
the class IssueServiceImplTest_findIssues method findByContentId2.
@Test
public void findByContentId2() throws Exception {
ContentId contentId = ContentId.from("issue-item-2");
IssueQuery query = IssueQuery.create().items(ContentIds.from(contentId)).build();
final FindIssuesResult result = this.issueService.findIssues(query);
assertNotNull(result);
assertEquals(3, result.getHits());
assertTrue(result.getIssues().stream().allMatch(issue -> issue.getPublishRequest().getItems().stream().anyMatch(item -> item.getId().equals(contentId))));
}
use of com.enonic.xp.issue.FindIssuesResult in project xp by enonic.
the class IssueServiceImplTest_findIssues method findByContentId4.
@Test
public void findByContentId4() throws Exception {
ContentId contentId = ContentId.from("issue-item-4");
IssueQuery query = IssueQuery.create().items(ContentIds.from(contentId)).build();
final FindIssuesResult result = this.issueService.findIssues(query);
assertNotNull(result);
assertEquals(1, result.getHits());
assertTrue(result.getIssues().stream().allMatch(issue -> issue.getPublishRequest().getItems().stream().anyMatch(item -> item.getId().equals(contentId))));
}
Aggregations