Search in sources :

Example 1 with PublishRequestIssue

use of com.enonic.xp.issue.PublishRequestIssue 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 PublishRequestIssue

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

the class IssueServiceImplTest_update method update_publish_request_issue.

@Test
public void update_publish_request_issue() throws Exception {
    Instant from = Instant.ofEpochSecond(1561965725L);
    Instant to = Instant.ofEpochSecond(1575184925L);
    final PublishRequestIssue issue = (PublishRequestIssue) this.issueService.create(CreatePublishRequestIssueParams.create().title("title").description("description").setApproverIds(PrincipalKeys.from("user:myStore:approver-1")).setPublishRequest(PublishRequest.create().addItem(PublishRequestItem.create().id(ContentId.from("content-id")).includeChildren(true).build()).build()).schedule(PublishRequestIssueSchedule.create().from(from).to(to).build()).build());
    Instant newFrom = from.plus(4, ChronoUnit.DAYS);
    Instant newTo = to.plus(8, ChronoUnit.DAYS);
    final UpdateIssueParams updateIssueParams = UpdateIssueParams.create().id(issue.getId()).editor(editMe -> {
        EditablePublishRequestIssue edit = (EditablePublishRequestIssue) editMe;
        edit.title = "updated title";
        edit.description = "updated description";
        edit.approverIds = PrincipalKeys.from(PrincipalKey.from("user:myStore:approver-1"), PrincipalKey.from("user:myStore:approver-2"));
        edit.publishRequest = PublishRequest.create().addExcludeId(ContentId.from("new-exclude-id")).addItem(PublishRequestItem.create().id(ContentId.from("new-content-id")).includeChildren(true).build()).build();
        edit.issueStatus = IssueStatus.CLOSED;
        edit.schedule = PublishRequestIssueSchedule.create().from(newFrom).to(newTo).build();
    }).build();
    final PublishRequestIssue updatedIssue = (PublishRequestIssue) this.issueService.update(updateIssueParams);
    assertNotNull(updatedIssue);
    assertEquals("updated title", updatedIssue.getTitle());
    assertEquals("updated description", updatedIssue.getDescription());
    assertEquals(IssueStatus.CLOSED, updatedIssue.getStatus());
    assertEquals(PrincipalKey.from("user:system:test-user"), updatedIssue.getCreator());
    assertEquals(PrincipalKey.from("user:system:test-user"), updatedIssue.getModifier());
    assertEquals(PrincipalKey.from("user:myStore:approver-1"), updatedIssue.getApproverIds().first());
    assertEquals(ContentId.from("new-exclude-id"), updatedIssue.getPublishRequest().getExcludeIds().first());
    assertEquals(ContentId.from("new-content-id"), updatedIssue.getPublishRequest().getItems().first().getId());
    assertEquals(true, updatedIssue.getPublishRequest().getItems().first().getIncludeChildren());
    assertEquals(IssueNameFactory.create(updatedIssue.getIndex()), updatedIssue.getName());
    assertNotEquals(updatedIssue.getCreatedTime(), updatedIssue.getModifiedTime());
    assertEquals(newFrom, updatedIssue.getSchedule().getFrom());
    assertEquals(newTo, updatedIssue.getSchedule().getTo());
}
Also used : PublishRequestIssue(com.enonic.xp.issue.PublishRequestIssue) EditablePublishRequestIssue(com.enonic.xp.issue.EditablePublishRequestIssue) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) IssueStatus(com.enonic.xp.issue.IssueStatus) CreatePublishRequestIssueParams(com.enonic.xp.issue.CreatePublishRequestIssueParams) Issue(com.enonic.xp.issue.Issue) PublishRequestItem(com.enonic.xp.issue.PublishRequestItem) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) CreateIssueParams(com.enonic.xp.issue.CreateIssueParams) Instant(java.time.Instant) PublishRequestIssueSchedule(com.enonic.xp.issue.PublishRequestIssueSchedule) Test(org.junit.jupiter.api.Test) PublishRequestIssue(com.enonic.xp.issue.PublishRequestIssue) ContentId(com.enonic.xp.content.ContentId) ChronoUnit(java.time.temporal.ChronoUnit) EditablePublishRequestIssue(com.enonic.xp.issue.EditablePublishRequestIssue) PrincipalKey(com.enonic.xp.security.PrincipalKey) UpdateIssueParams(com.enonic.xp.issue.UpdateIssueParams) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PublishRequest(com.enonic.xp.issue.PublishRequest) PrincipalKeys(com.enonic.xp.security.PrincipalKeys) IssueNameFactory(com.enonic.xp.core.impl.issue.IssueNameFactory) Instant(java.time.Instant) UpdateIssueParams(com.enonic.xp.issue.UpdateIssueParams) EditablePublishRequestIssue(com.enonic.xp.issue.EditablePublishRequestIssue) Test(org.junit.jupiter.api.Test)

Example 3 with PublishRequestIssue

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

the class IssueDataSerializer method toUpdateNodeData.

public PropertyTree toUpdateNodeData(final Issue editedIssue) {
    final PropertyTree propertyTree = new PropertyTree();
    final PropertySet issueAsData = propertyTree.getRoot();
    issueAsData.ifNotNull().addEnum(TYPE, editedIssue.getIssueType());
    issueAsData.ifNotNull().addLong(INDEX, editedIssue.getIndex());
    issueAsData.ifNotNull().addString(TITLE, editedIssue.getTitle());
    issueAsData.ifNotNull().addInstant(CREATED_TIME, editedIssue.getCreatedTime());
    issueAsData.ifNotNull().addInstant(MODIFIED_TIME, editedIssue.getModifiedTime());
    issueAsData.ifNotNull().addString(CREATOR, editedIssue.getCreator().toString());
    issueAsData.ifNotNull().addString(MODIFIER, editedIssue.getModifier().toString());
    issueAsData.ifNotNull().addString(STATUS, editedIssue.getStatus().toString());
    issueAsData.addString(DESCRIPTION, editedIssue.getDescription());
    issueAsData.addStrings(APPROVERS, editedIssue.getApproverIds().stream().map(PrincipalKey::toString).collect(Collectors.toList()));
    if (editedIssue.getPublishRequest() != null) {
        addPublishRequest(issueAsData, editedIssue.getPublishRequest());
    }
    if (editedIssue instanceof PublishRequestIssue) {
        publishRequestIssueSerializer.toUpdateNodeData((PublishRequestIssue) editedIssue, issueAsData);
    }
    return propertyTree;
}
Also used : PublishRequestIssue(com.enonic.xp.issue.PublishRequestIssue) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) PrincipalKey(com.enonic.xp.security.PrincipalKey)

Example 4 with PublishRequestIssue

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

the class IssueServiceImplTest_update method update_publish_request_issue_without_schedule.

@Test
public void update_publish_request_issue_without_schedule() throws Exception {
    final PublishRequestIssue issue = (PublishRequestIssue) this.issueService.create(CreatePublishRequestIssueParams.create().title("title").description("description").setApproverIds(PrincipalKeys.from("user:myStore:approver-1")).setPublishRequest(PublishRequest.create().addItem(PublishRequestItem.create().id(ContentId.from("content-id")).includeChildren(true).build()).build()).build());
    final UpdateIssueParams updateIssueParams = UpdateIssueParams.create().id(issue.getId()).editor(editMe -> {
        EditablePublishRequestIssue edit = (EditablePublishRequestIssue) editMe;
        edit.title = "updated title";
        edit.description = "updated description";
        edit.approverIds = PrincipalKeys.from(PrincipalKey.from("user:myStore:approver-1"), PrincipalKey.from("user:myStore:approver-2"));
        edit.publishRequest = PublishRequest.create().addExcludeId(ContentId.from("new-exclude-id")).addItem(PublishRequestItem.create().id(ContentId.from("new-content-id")).includeChildren(true).build()).build();
        edit.issueStatus = IssueStatus.CLOSED;
    }).build();
    final PublishRequestIssue updatedIssue = (PublishRequestIssue) this.issueService.update(updateIssueParams);
    assertNotNull(updatedIssue);
    assertEquals("updated title", updatedIssue.getTitle());
    assertEquals("updated description", updatedIssue.getDescription());
    assertEquals(IssueStatus.CLOSED, updatedIssue.getStatus());
    assertEquals(PrincipalKey.from("user:system:test-user"), updatedIssue.getCreator());
    assertEquals(PrincipalKey.from("user:system:test-user"), updatedIssue.getModifier());
    assertEquals(PrincipalKey.from("user:myStore:approver-1"), updatedIssue.getApproverIds().first());
    assertEquals(ContentId.from("new-exclude-id"), updatedIssue.getPublishRequest().getExcludeIds().first());
    assertEquals(ContentId.from("new-content-id"), updatedIssue.getPublishRequest().getItems().first().getId());
    assertEquals(true, updatedIssue.getPublishRequest().getItems().first().getIncludeChildren());
    assertEquals(IssueNameFactory.create(updatedIssue.getIndex()), updatedIssue.getName());
    assertNotEquals(updatedIssue.getCreatedTime(), updatedIssue.getModifiedTime());
    assertNull(updatedIssue.getSchedule());
}
Also used : PublishRequestIssue(com.enonic.xp.issue.PublishRequestIssue) EditablePublishRequestIssue(com.enonic.xp.issue.EditablePublishRequestIssue) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) IssueStatus(com.enonic.xp.issue.IssueStatus) CreatePublishRequestIssueParams(com.enonic.xp.issue.CreatePublishRequestIssueParams) Issue(com.enonic.xp.issue.Issue) PublishRequestItem(com.enonic.xp.issue.PublishRequestItem) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) CreateIssueParams(com.enonic.xp.issue.CreateIssueParams) Instant(java.time.Instant) PublishRequestIssueSchedule(com.enonic.xp.issue.PublishRequestIssueSchedule) Test(org.junit.jupiter.api.Test) PublishRequestIssue(com.enonic.xp.issue.PublishRequestIssue) ContentId(com.enonic.xp.content.ContentId) ChronoUnit(java.time.temporal.ChronoUnit) EditablePublishRequestIssue(com.enonic.xp.issue.EditablePublishRequestIssue) PrincipalKey(com.enonic.xp.security.PrincipalKey) UpdateIssueParams(com.enonic.xp.issue.UpdateIssueParams) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PublishRequest(com.enonic.xp.issue.PublishRequest) PrincipalKeys(com.enonic.xp.security.PrincipalKeys) IssueNameFactory(com.enonic.xp.core.impl.issue.IssueNameFactory) UpdateIssueParams(com.enonic.xp.issue.UpdateIssueParams) EditablePublishRequestIssue(com.enonic.xp.issue.EditablePublishRequestIssue) Test(org.junit.jupiter.api.Test)

Example 5 with PublishRequestIssue

use of com.enonic.xp.issue.PublishRequestIssue 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

PublishRequestIssue (com.enonic.xp.issue.PublishRequestIssue)5 CreatePublishRequestIssueParams (com.enonic.xp.issue.CreatePublishRequestIssueParams)4 Test (org.junit.jupiter.api.Test)4 PrincipalKey (com.enonic.xp.security.PrincipalKey)3 Instant (java.time.Instant)3 ContentId (com.enonic.xp.content.ContentId)2 IssueNameFactory (com.enonic.xp.core.impl.issue.IssueNameFactory)2 CreateIssueParams (com.enonic.xp.issue.CreateIssueParams)2 EditablePublishRequestIssue (com.enonic.xp.issue.EditablePublishRequestIssue)2 Issue (com.enonic.xp.issue.Issue)2 IssueStatus (com.enonic.xp.issue.IssueStatus)2 PublishRequest (com.enonic.xp.issue.PublishRequest)2 PublishRequestIssueSchedule (com.enonic.xp.issue.PublishRequestIssueSchedule)2 PublishRequestItem (com.enonic.xp.issue.PublishRequestItem)2 UpdateIssueParams (com.enonic.xp.issue.UpdateIssueParams)2 PrincipalKeys (com.enonic.xp.security.PrincipalKeys)2 ChronoUnit (java.time.temporal.ChronoUnit)2 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)2 Assertions.assertNotEquals (org.junit.jupiter.api.Assertions.assertNotEquals)2 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)2