Search in sources :

Example 1 with CreatePublishRequestIssueParams

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

the class IssueServiceImplTest_create method create_publish_request_issue.

@Test
public void create_publish_request_issue() throws Exception {
    Instant from = Instant.ofEpochSecond(1561965725L);
    Instant to = Instant.ofEpochSecond(1575184925L);
    final CreatePublishRequestIssueParams params = CreatePublishRequestIssueParams.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()).schedule(PublishRequestIssueSchedule.create().to(to).from(from).build()).build();
    final PublishRequestIssue issue = (PublishRequestIssue) 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());
    assertEquals(from, issue.getSchedule().getFrom());
    assertEquals(to, issue.getSchedule().getTo());
}
Also used : PublishRequestIssue(com.enonic.xp.issue.PublishRequestIssue) CreatePublishRequestIssueParams(com.enonic.xp.issue.CreatePublishRequestIssueParams) Instant(java.time.Instant) Test(org.junit.jupiter.api.Test)

Example 2 with CreatePublishRequestIssueParams

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

the class IssueDataSerializer method toCreateNodeData.

public PropertyTree toCreateNodeData(final CreateIssueParams params) {
    final PropertyTree propertyTree = new PropertyTree();
    final PropertySet issueAsData = propertyTree.getRoot();
    issueAsData.ifNotNull().addEnum(TYPE, params.getIssueType());
    issueAsData.ifNotNull().addString(TITLE, params.getTitle());
    issueAsData.ifNotNull().addString(STATUS, params.getStatus().toString());
    issueAsData.addString(DESCRIPTION, params.getDescription());
    if (params.getApproverIds().getSize() > 0) {
        issueAsData.addStrings(APPROVERS, params.getApproverIds().stream().map(PrincipalKey::toString).collect(Collectors.toList()));
    }
    if (params.getPublishRequest() != null) {
        addPublishRequest(issueAsData, params.getPublishRequest());
    }
    if (params instanceof CreatePublishRequestIssueParams) {
        publishRequestIssueSerializer.toCreateNodeData((CreatePublishRequestIssueParams) params, issueAsData);
    }
    return propertyTree;
}
Also used : CreatePublishRequestIssueParams(com.enonic.xp.issue.CreatePublishRequestIssueParams) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) PrincipalKey(com.enonic.xp.security.PrincipalKey)

Example 3 with CreatePublishRequestIssueParams

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

the class IssueServiceImplTest_create method create_publish_request_issue_without_schedule.

@Test
public void create_publish_request_issue_without_schedule() throws Exception {
    final CreatePublishRequestIssueParams params = CreatePublishRequestIssueParams.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 PublishRequestIssue issue = (PublishRequestIssue) 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());
    assertNull(issue.getSchedule());
}
Also used : PublishRequestIssue(com.enonic.xp.issue.PublishRequestIssue) CreatePublishRequestIssueParams(com.enonic.xp.issue.CreatePublishRequestIssueParams) Test(org.junit.jupiter.api.Test)

Aggregations

CreatePublishRequestIssueParams (com.enonic.xp.issue.CreatePublishRequestIssueParams)3 PublishRequestIssue (com.enonic.xp.issue.PublishRequestIssue)2 Test (org.junit.jupiter.api.Test)2 PropertySet (com.enonic.xp.data.PropertySet)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 PrincipalKey (com.enonic.xp.security.PrincipalKey)1 Instant (java.time.Instant)1