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());
}
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;
}
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());
}
Aggregations