Search in sources :

Example 1 with FindIssuesResult

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());
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) NodeQuery(com.enonic.xp.node.NodeQuery) IssueQuery(com.enonic.xp.issue.IssueQuery) FindIssuesResult(com.enonic.xp.issue.FindIssuesResult) Test(org.junit.jupiter.api.Test)

Example 2 with FindIssuesResult

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());
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) NodeQuery(com.enonic.xp.node.NodeQuery) IssueQuery(com.enonic.xp.issue.IssueQuery) FindIssuesResult(com.enonic.xp.issue.FindIssuesResult) Test(org.junit.jupiter.api.Test)

Example 3 with FindIssuesResult

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))));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Issue(com.enonic.xp.issue.Issue) PublishRequestItem(com.enonic.xp.issue.PublishRequestItem) CreateIssueParams(com.enonic.xp.issue.CreateIssueParams) Test(org.junit.jupiter.api.Test) ContentId(com.enonic.xp.content.ContentId) ContentIds(com.enonic.xp.content.ContentIds) IssueQuery(com.enonic.xp.issue.IssueQuery) FindIssuesResult(com.enonic.xp.issue.FindIssuesResult) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PublishRequest(com.enonic.xp.issue.PublishRequest) ContentId(com.enonic.xp.content.ContentId) IssueQuery(com.enonic.xp.issue.IssueQuery) FindIssuesResult(com.enonic.xp.issue.FindIssuesResult) Test(org.junit.jupiter.api.Test)

Example 4 with FindIssuesResult

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))));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Issue(com.enonic.xp.issue.Issue) PublishRequestItem(com.enonic.xp.issue.PublishRequestItem) CreateIssueParams(com.enonic.xp.issue.CreateIssueParams) Test(org.junit.jupiter.api.Test) ContentId(com.enonic.xp.content.ContentId) ContentIds(com.enonic.xp.content.ContentIds) IssueQuery(com.enonic.xp.issue.IssueQuery) FindIssuesResult(com.enonic.xp.issue.FindIssuesResult) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PublishRequest(com.enonic.xp.issue.PublishRequest) ContentId(com.enonic.xp.content.ContentId) IssueQuery(com.enonic.xp.issue.IssueQuery) FindIssuesResult(com.enonic.xp.issue.FindIssuesResult) Test(org.junit.jupiter.api.Test)

Example 5 with FindIssuesResult

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))));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Issue(com.enonic.xp.issue.Issue) PublishRequestItem(com.enonic.xp.issue.PublishRequestItem) CreateIssueParams(com.enonic.xp.issue.CreateIssueParams) Test(org.junit.jupiter.api.Test) ContentId(com.enonic.xp.content.ContentId) ContentIds(com.enonic.xp.content.ContentIds) IssueQuery(com.enonic.xp.issue.IssueQuery) FindIssuesResult(com.enonic.xp.issue.FindIssuesResult) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PublishRequest(com.enonic.xp.issue.PublishRequest) ContentId(com.enonic.xp.content.ContentId) IssueQuery(com.enonic.xp.issue.IssueQuery) FindIssuesResult(com.enonic.xp.issue.FindIssuesResult) Test(org.junit.jupiter.api.Test)

Aggregations

FindIssuesResult (com.enonic.xp.issue.FindIssuesResult)6 IssueQuery (com.enonic.xp.issue.IssueQuery)6 Test (org.junit.jupiter.api.Test)6 ContentId (com.enonic.xp.content.ContentId)3 ContentIds (com.enonic.xp.content.ContentIds)3 CreateIssueParams (com.enonic.xp.issue.CreateIssueParams)3 Issue (com.enonic.xp.issue.Issue)3 PublishRequest (com.enonic.xp.issue.PublishRequest)3 PublishRequestItem (com.enonic.xp.issue.PublishRequestItem)3 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)3 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)3 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 NodeIds (com.enonic.xp.node.NodeIds)2 NodeQuery (com.enonic.xp.node.NodeQuery)2