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