use of com.enonic.xp.content.WorkflowCheckState 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.WorkflowCheckState 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));
}
use of com.enonic.xp.content.WorkflowCheckState in project xp by enonic.
the class WorkflowInfoSerializer method extract.
public WorkflowInfo extract(final PropertySet workflowInfo) {
if (workflowInfo == null) {
return WorkflowInfo.ready();
}
final ImmutableMap.Builder<String, WorkflowCheckState> mapBuilder = ImmutableMap.builder();
PropertySet checkSet = workflowInfo.getSet(WORKFLOW_INFO_CHECKS);
if (checkSet != null) {
for (String checks : checkSet.getPropertyNames()) {
mapBuilder.put(checks, WorkflowCheckState.valueOf(checkSet.getString(checks)));
}
}
return WorkflowInfo.create().state(workflowInfo.getString(WORKFLOW_INFO_STATE)).checks(mapBuilder.build()).build();
}
Aggregations