You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2017/04/11 12:50:56 UTC
[4/6] syncope git commit: [SYNCOPE-1020] Implementation completed:
now several sub-processes can be managed besides the main workflow definition
http://git-wip-us.apache.org/repos/asf/syncope/blob/4c2dd443/fit/core-reference/src/test/java/org/apache/syncope/fit/core/WorkflowITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/WorkflowITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/WorkflowITCase.java
index 89f4190..529c13e 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/WorkflowITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/WorkflowITCase.java
@@ -28,52 +28,55 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import javax.ws.rs.core.Response;
+import org.apache.commons.collections4.IterableUtils;
+import org.apache.commons.collections4.Predicate;
import org.apache.commons.io.IOUtils;
+import org.apache.syncope.common.lib.to.WorkflowDefinitionTO;
import org.apache.syncope.common.lib.types.AnyTypeKind;
import org.apache.syncope.fit.AbstractITCase;
import org.junit.Assume;
+import org.junit.BeforeClass;
import org.junit.Test;
public class WorkflowITCase extends AbstractITCase {
- private void exportDefinition(final AnyTypeKind type) throws IOException {
- Response response = workflowService.exportDefinition(type);
- assertTrue(response.getMediaType().toString().
- startsWith(clientFactory.getContentType().getMediaType().toString()));
- assertTrue(response.getEntity() instanceof InputStream);
- String definition = IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8);
- assertNotNull(definition);
- assertFalse(definition.isEmpty());
- }
+ private static String defaultUserKey = null;
- @Test
- public void exportUserDefinition() throws IOException {
+ @BeforeClass
+ public static void findDefault() {
Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForUsers(syncopeService));
- exportDefinition(AnyTypeKind.USER);
- }
+ WorkflowDefinitionTO found = IterableUtils.find(
+ workflowService.list(AnyTypeKind.USER.name()), new Predicate<WorkflowDefinitionTO>() {
- @Test
- public void getGroupDefinition() throws IOException {
- Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForGroups(syncopeService));
- exportDefinition(AnyTypeKind.GROUP);
+ @Override
+ public boolean evaluate(final WorkflowDefinitionTO object) {
+ return object.isMain();
+ }
+ });
+ if (found != null) {
+ defaultUserKey = found.getKey();
+ }
+ assertNotNull(defaultUserKey);
}
- private void importDefinition(final AnyTypeKind type) throws IOException {
- Response response = workflowService.exportDefinition(type);
+ @Test
+ public void exportUserDefinition() throws IOException {
+ Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForUsers(syncopeService));
+ Response response = workflowService.get(AnyTypeKind.USER.name(), defaultUserKey);
+ assertTrue(response.getMediaType().toString().
+ startsWith(clientFactory.getContentType().getMediaType().toString()));
+ assertTrue(response.getEntity() instanceof InputStream);
String definition = IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8);
-
- workflowService.importDefinition(type, definition);
+ assertNotNull(definition);
+ assertFalse(definition.isEmpty());
}
@Test
public void updateUserDefinition() throws IOException {
Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForUsers(syncopeService));
- importDefinition(AnyTypeKind.USER);
- }
+ Response response = workflowService.get(AnyTypeKind.USER.name(), defaultUserKey);
+ String definition = IOUtils.toString((InputStream) response.getEntity(), StandardCharsets.UTF_8);
- @Test
- public void updateGroupDefinition() throws IOException {
- Assume.assumeTrue(ActivitiDetector.isActivitiEnabledForGroups(syncopeService));
- importDefinition(AnyTypeKind.GROUP);
+ workflowService.set(AnyTypeKind.USER.name(), defaultUserKey, definition);
}
}