use of com.enonic.xp.content.WorkflowInfo in project xp by enonic.
the class ContentDataSerializer method extractWorkflowInfo.
private void extractWorkflowInfo(final PropertySet contentAsSet, final Content.Builder<?> builder) {
final PropertySet workflowInfoSet = contentAsSet.getSet(WORKFLOW_INFO);
final WorkflowInfo workflowInfo = workflowInfoSerializer.extract(workflowInfoSet);
builder.workflowInfo(workflowInfo);
}
use of com.enonic.xp.content.WorkflowInfo in project xp by enonic.
the class ContentServiceImplTest_versions method version_workflow_info.
@Test
public void version_workflow_info() throws Exception {
final Map<String, WorkflowCheckState> checks = Map.of("checkName1", WorkflowCheckState.APPROVED, "checkName2", WorkflowCheckState.PENDING);
final WorkflowInfo workflowInfo = WorkflowInfo.create().state(WorkflowState.IN_PROGRESS).checks(checks).build();
final Content content = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my test content").parent(ContentPath.ROOT).name("myContent").type(ContentTypeName.folder()).workflowInfo(workflowInfo).build());
final FindContentVersionsResult versions = this.contentService.getVersions(FindContentVersionsParams.create().contentId(content.getId()).build());
final ContentVersion contentVersion = versions.getContentVersions().iterator().next();
final WorkflowInfo retrievedWorkflowInfo = contentVersion.getWorkflowInfo();
assertEquals(WorkflowState.IN_PROGRESS, retrievedWorkflowInfo.getState());
assertEquals(WorkflowCheckState.APPROVED, retrievedWorkflowInfo.getChecks().get("checkName1"));
assertEquals(WorkflowCheckState.PENDING, retrievedWorkflowInfo.getChecks().get("checkName2"));
}
use of com.enonic.xp.content.WorkflowInfo in project xp by enonic.
the class ContentDataSerializerTest method create_propertyTree_populated_with_workflowInfo.
@Test
public void create_propertyTree_populated_with_workflowInfo() {
final String check1Name = "myCheck1";
final WorkflowCheckState check1State = WorkflowCheckState.APPROVED;
final String check2Name = "myCheck2";
final WorkflowCheckState check2State = WorkflowCheckState.PENDING;
final WorkflowInfo workflowInfo = WorkflowInfo.create().state(WorkflowState.PENDING_APPROVAL).checks(Map.of(check1Name, check1State, check2Name, check2State)).build();
final ContentDataSerializer contentDataSerializer = createContentDataSerializer();
final CreateContentTranslatorParams params = CreateContentTranslatorParams.create().parent(ContentPath.ROOT).name("myContentName").contentData(new PropertyTree()).displayName("myDisplayName").type(ContentTypeName.codeMedia()).creator(PrincipalKey.ofAnonymous()).childOrder(ChildOrder.defaultOrder()).workflowInfo(workflowInfo).build();
final PropertyTree data = contentDataSerializer.toCreateNodeData(params);
final PropertySet workflowData = data.getSet(ContentPropertyNames.WORKFLOW_INFO);
assertEquals(workflowInfo.getState().toString(), workflowData.getString(ContentPropertyNames.WORKFLOW_INFO_STATE));
final PropertySet workflowChecks = workflowData.getPropertySet(ContentPropertyNames.WORKFLOW_INFO_CHECKS);
assertEquals(check1State.toString(), workflowChecks.getString(check1Name));
assertEquals(check2State.toString(), workflowChecks.getString(check2Name));
}
Aggregations