Search in sources :

Example 1 with CreateIssueParams

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

the class CreateIssueCommandTest method create.

@Test
public void create() {
    final CreateIssueParams params = createIssueParams().build();
    final CreateIssueCommand command = createIssueCommand(params);
    Mockito.when(this.nodeService.findByQuery(Mockito.any(NodeQuery.class))).thenReturn(FindNodesByQueryResult.create().build());
    final Issue issue = command.execute();
    assertNotNull(issue);
    assertEquals("title", issue.getTitle());
    assertEquals(IssueStatus.OPEN, issue.getStatus());
    assertEquals(IssueNameFactory.create(issue.getIndex()), issue.getName());
}
Also used : Issue(com.enonic.xp.issue.Issue) NodeQuery(com.enonic.xp.node.NodeQuery) CreateIssueParams(com.enonic.xp.issue.CreateIssueParams) Test(org.junit.jupiter.api.Test)

Example 2 with CreateIssueParams

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

the class IssueDataSerializerTest method testCreate.

@Test
public void testCreate() {
    IssueDataSerializer issueDataSerializer = new IssueDataSerializer();
    CreateIssueParams params = CreateIssueParams.create().title("title").description("descr").setApproverIds(PrincipalKeys.from("user:myStore:approver")).setPublishRequest(PublishRequest.create().addItem(PublishRequestItem.create().id(ContentId.from("content-id")).includeChildren(false).build()).addExcludeId(ContentId.from("exclude-id")).build()).build();
    final PropertyTree data = issueDataSerializer.toCreateNodeData(params);
    assertNotNull(data);
    assertEquals("title", data.getString(TITLE));
    assertEquals("descr", data.getString(DESCRIPTION));
    assertEquals("OPEN", data.getString(STATUS));
    assertEquals("user:myStore:approver", data.getStrings(APPROVERS).iterator().next());
    assertEquals("exclude-id", data.getSet(PUBLISH_REQUEST).getStrings(PublishRequestPropertyNames.EXCLUDE_IDS).iterator().next());
    final Iterable<PropertySet> itemSets = data.getSet(PUBLISH_REQUEST).getSets(PublishRequestPropertyNames.ITEMS);
    final ArrayList<PropertySet> itemSetsAsList = Lists.newArrayList(itemSets);
    assertEquals(1, itemSetsAsList.size());
    assertFalse(itemSetsAsList.get(0).getBoolean(PublishRequestPropertyNames.ITEM_RECURSIVE));
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) CreateIssueParams(com.enonic.xp.issue.CreateIssueParams) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 3 with CreateIssueParams

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

the class CreateIssueCommandTest method testNoTitle.

@Test
public void testNoTitle() {
    final CreateIssueParams params = CreateIssueParams.create().build();
    final CreateIssueCommand command = createIssueCommand(params);
    assertThrows(IllegalArgumentException.class, () -> command.execute());
}
Also used : CreateIssueParams(com.enonic.xp.issue.CreateIssueParams) Test(org.junit.jupiter.api.Test)

Example 4 with CreateIssueParams

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

the class IssueServiceImplTest_create method create_issue.

@Test
public void create_issue() throws Exception {
    final CreateIssueParams params = 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()).build();
    final Issue issue = this.issueService.create(params);
    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(ContentId.from("exclude-id"), issue.getPublishRequest().getExcludeIds().first());
    assertEquals(IssueNameFactory.create(issue.getIndex()), issue.getName());
}
Also used : Issue(com.enonic.xp.issue.Issue) PublishRequestIssue(com.enonic.xp.issue.PublishRequestIssue) CreateIssueParams(com.enonic.xp.issue.CreateIssueParams) Test(org.junit.jupiter.api.Test)

Aggregations

CreateIssueParams (com.enonic.xp.issue.CreateIssueParams)4 Test (org.junit.jupiter.api.Test)4 Issue (com.enonic.xp.issue.Issue)2 PropertySet (com.enonic.xp.data.PropertySet)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 PublishRequestIssue (com.enonic.xp.issue.PublishRequestIssue)1 NodeQuery (com.enonic.xp.node.NodeQuery)1