Skip to content

Commit

Permalink
Stop auto-assigning task archetypes in tests
Browse files Browse the repository at this point in the history
Generally, in tests we do not have all the archetypes imported.
So (maybe temporarily) we do not auto-assign them.

This fixes some failing story tests.
  • Loading branch information
mederly committed Jul 7, 2021
1 parent a70ed50 commit 868084b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti

// This is generally useful in tests, to avoid long waiting for bucketed tasks.
bucketingManager.setFreeBucketWaitIntervalOverride(100L);

// We generally do not import all the archetypes for all kinds of tasks (at least not now).
genericTaskHandler.setAvoidAutoAssigningArchetypes(true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public TaskRunResult run(OperationResult result) throws TaskException {
}

private void setupTaskArchetypeIfNeeded(OperationResult result) throws ActivityExecutionException {
if (genericTaskHandler.isAvoidAutoAssigningArchetypes()) {
return;
}
try {
RunningTask task = getRunningTask();
String defaultArchetypeOid = activityTree.getRootActivity().getHandler().getDefaultArchetypeOid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ public class GenericTaskHandler implements TaskHandler {
*/
@NotNull private final Map<String, GenericTaskExecution> currentTaskExecutions = Collections.synchronizedMap(new HashMap<>());

/**
* Should we avoid auto-assigning task archetypes based on activity handler?
* This is useful for restricted environments (like in tests) when there are no archetypes present.
*/
private boolean avoidAutoAssigningArchetypes;

/** Common beans */
@Autowired private CommonTaskBeans beans;
@Autowired private TaskManager taskManager;
Expand Down Expand Up @@ -130,4 +136,12 @@ public void registerLegacyHandlerUri(String handlerUri) {
public void unregisterLegacyHandlerUri(String handlerUri) {
beans.taskManager.unregisterHandler(handlerUri);
}

public boolean isAvoidAutoAssigningArchetypes() {
return avoidAutoAssigningArchetypes;
}

public void setAvoidAutoAssigningArchetypes(boolean avoidAutoAssigningArchetypes) {
this.avoidAutoAssigningArchetypes = avoidAutoAssigningArchetypes;
}
}

0 comments on commit 868084b

Please sign in to comment.