@Test public void readAndValidateTaskAssigningServiceConfigDefaults() throws TaskAssigningValidationException { System.setProperty(TASK_ASSIGNING_PROCESS_RUNTIME_TARGET_USER, TARGET_USER); TaskAssigningServiceConfig serviceConfig = TaskAssigningPlanningKieServerExtensionHelper.readAndValidateTaskAssigningServiceConfig(); SolverHandlerConfig handlerConfig = serviceConfig.getSolverHandlerConfig(); assertThat(handlerConfig.getTargetUserId()).isEqualTo(TARGET_USER); assertThat(handlerConfig.getPublishWindowSize()).isEqualTo(DEFAULT_PUBLISH_WINDOW_SIZE); assertThat(handlerConfig.getSyncInterval()).isEqualTo(Duration.parse(DEFAULT_SYNC_INTERVAL)); assertThat(handlerConfig.getSyncQueriesShift()).isEqualTo(Duration.parse(DEFAULT_SYNC_QUERIES_SHIFT)); assertThat(handlerConfig.getUsersSyncInterval()).isEqualTo(Duration.parse(DEFAULT_USERS_SYNC_INTERVAL)); assertThat(handlerConfig.getWaitForImprovedSolutionDuration()).isEqualTo(Duration.parse(DEFAULT_WAIT_FOR_IMPROVED_SOLUTION_DURATION)); assertThat(handlerConfig.getImproveSolutionOnBackgroundDuration()).isEqualTo(Duration.parse(DEFAULT_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION)); }
public static TaskAssigningServiceConfig readAndValidateTaskAssigningServiceConfig() throws TaskAssigningValidationException { String targetUserId; int publishWindowSize; Duration syncInterval; Duration syncQueriesShift; Duration usersSyncInterval; Duration waitForImprovedSolutionDuration; Duration improveSolutionOnBackgroundDuration; targetUserId = trimToNull(System.getProperty(TASK_ASSIGNING_PROCESS_RUNTIME_TARGET_USER)); if (isNull(targetUserId)) { throw new TaskAssigningValidationException(String.format(PARAMETER_MUST_HAVE_A_NON_EMPTY_STRING_VALUE_ERROR, TASK_ASSIGNING_PROCESS_RUNTIME_TARGET_USER)); } publishWindowSize = parseAndValidateGreaterThanZeroInteger(System.getProperty(TASK_ASSIGNING_PUBLISH_WINDOW_SIZE, Integer.toString(DEFAULT_PUBLISH_WINDOW_SIZE)), String.format(PARAMETER_MUST_HAVE_A_GREATER_THAN_ZERO_INTEGER_VALUE_ERROR, TASK_ASSIGNING_PUBLISH_WINDOW_SIZE)); syncInterval = parseAndValidateGreaterThanZeroDuration(System.getProperty(TASK_ASSIGNING_SYNC_INTERVAL, DEFAULT_SYNC_INTERVAL), String.format(PARAMETER_MUST_HAVE_A_GREATER_THAN_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_SYNC_INTERVAL)); syncQueriesShift = parseAndValidateGreaterThanZeroDuration(System.getProperty(TASK_ASSIGNING_SYNC_QUERIES_SHIFT, DEFAULT_SYNC_QUERIES_SHIFT), String.format(PARAMETER_MUST_HAVE_A_GREATER_THAN_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_SYNC_QUERIES_SHIFT)); usersSyncInterval = parseAndValidateGreaterOrEqualThanZeroDuration(System.getProperty(TASK_ASSIGNING_USERS_SYNC_INTERVAL, DEFAULT_USERS_SYNC_INTERVAL), String.format(PARAMETER_MUST_HAVE_A_GREATER_OR_EQUAL_TO_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_USERS_SYNC_INTERVAL)); waitForImprovedSolutionDuration = parseAndValidateGreaterOrEqualThanZeroDuration(System.getProperty(TASK_ASSIGNING_WAIT_FOR_IMPROVED_SOLUTION_DURATION, DEFAULT_WAIT_FOR_IMPROVED_SOLUTION_DURATION), String.format(PARAMETER_MUST_HAVE_A_GREATER_OR_EQUAL_TO_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_WAIT_FOR_IMPROVED_SOLUTION_DURATION)); improveSolutionOnBackgroundDuration = parseAndValidateGreaterOrEqualThanZeroDuration(System.getProperty(TASK_ASSIGNING_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION, DEFAULT_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION), String.format(PARAMETER_MUST_HAVE_A_GREATER_OR_EQUAL_TO_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION)); return new TaskAssigningServiceConfig(targetUserId, publishWindowSize, syncInterval, syncQueriesShift, usersSyncInterval, waitForImprovedSolutionDuration, improveSolutionOnBackgroundDuration); }
TaskAssigningPlanningKieServerExtensionHelper { public static TaskAssigningServiceConfig readAndValidateTaskAssigningServiceConfig() throws TaskAssigningValidationException { String targetUserId; int publishWindowSize; Duration syncInterval; Duration syncQueriesShift; Duration usersSyncInterval; Duration waitForImprovedSolutionDuration; Duration improveSolutionOnBackgroundDuration; targetUserId = trimToNull(System.getProperty(TASK_ASSIGNING_PROCESS_RUNTIME_TARGET_USER)); if (isNull(targetUserId)) { throw new TaskAssigningValidationException(String.format(PARAMETER_MUST_HAVE_A_NON_EMPTY_STRING_VALUE_ERROR, TASK_ASSIGNING_PROCESS_RUNTIME_TARGET_USER)); } publishWindowSize = parseAndValidateGreaterThanZeroInteger(System.getProperty(TASK_ASSIGNING_PUBLISH_WINDOW_SIZE, Integer.toString(DEFAULT_PUBLISH_WINDOW_SIZE)), String.format(PARAMETER_MUST_HAVE_A_GREATER_THAN_ZERO_INTEGER_VALUE_ERROR, TASK_ASSIGNING_PUBLISH_WINDOW_SIZE)); syncInterval = parseAndValidateGreaterThanZeroDuration(System.getProperty(TASK_ASSIGNING_SYNC_INTERVAL, DEFAULT_SYNC_INTERVAL), String.format(PARAMETER_MUST_HAVE_A_GREATER_THAN_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_SYNC_INTERVAL)); syncQueriesShift = parseAndValidateGreaterThanZeroDuration(System.getProperty(TASK_ASSIGNING_SYNC_QUERIES_SHIFT, DEFAULT_SYNC_QUERIES_SHIFT), String.format(PARAMETER_MUST_HAVE_A_GREATER_THAN_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_SYNC_QUERIES_SHIFT)); usersSyncInterval = parseAndValidateGreaterOrEqualThanZeroDuration(System.getProperty(TASK_ASSIGNING_USERS_SYNC_INTERVAL, DEFAULT_USERS_SYNC_INTERVAL), String.format(PARAMETER_MUST_HAVE_A_GREATER_OR_EQUAL_TO_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_USERS_SYNC_INTERVAL)); waitForImprovedSolutionDuration = parseAndValidateGreaterOrEqualThanZeroDuration(System.getProperty(TASK_ASSIGNING_WAIT_FOR_IMPROVED_SOLUTION_DURATION, DEFAULT_WAIT_FOR_IMPROVED_SOLUTION_DURATION), String.format(PARAMETER_MUST_HAVE_A_GREATER_OR_EQUAL_TO_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_WAIT_FOR_IMPROVED_SOLUTION_DURATION)); improveSolutionOnBackgroundDuration = parseAndValidateGreaterOrEqualThanZeroDuration(System.getProperty(TASK_ASSIGNING_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION, DEFAULT_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION), String.format(PARAMETER_MUST_HAVE_A_GREATER_OR_EQUAL_TO_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION)); return new TaskAssigningServiceConfig(targetUserId, publishWindowSize, syncInterval, syncQueriesShift, usersSyncInterval, waitForImprovedSolutionDuration, improveSolutionOnBackgroundDuration); } }
TaskAssigningPlanningKieServerExtensionHelper { public static TaskAssigningServiceConfig readAndValidateTaskAssigningServiceConfig() throws TaskAssigningValidationException { String targetUserId; int publishWindowSize; Duration syncInterval; Duration syncQueriesShift; Duration usersSyncInterval; Duration waitForImprovedSolutionDuration; Duration improveSolutionOnBackgroundDuration; targetUserId = trimToNull(System.getProperty(TASK_ASSIGNING_PROCESS_RUNTIME_TARGET_USER)); if (isNull(targetUserId)) { throw new TaskAssigningValidationException(String.format(PARAMETER_MUST_HAVE_A_NON_EMPTY_STRING_VALUE_ERROR, TASK_ASSIGNING_PROCESS_RUNTIME_TARGET_USER)); } publishWindowSize = parseAndValidateGreaterThanZeroInteger(System.getProperty(TASK_ASSIGNING_PUBLISH_WINDOW_SIZE, Integer.toString(DEFAULT_PUBLISH_WINDOW_SIZE)), String.format(PARAMETER_MUST_HAVE_A_GREATER_THAN_ZERO_INTEGER_VALUE_ERROR, TASK_ASSIGNING_PUBLISH_WINDOW_SIZE)); syncInterval = parseAndValidateGreaterThanZeroDuration(System.getProperty(TASK_ASSIGNING_SYNC_INTERVAL, DEFAULT_SYNC_INTERVAL), String.format(PARAMETER_MUST_HAVE_A_GREATER_THAN_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_SYNC_INTERVAL)); syncQueriesShift = parseAndValidateGreaterThanZeroDuration(System.getProperty(TASK_ASSIGNING_SYNC_QUERIES_SHIFT, DEFAULT_SYNC_QUERIES_SHIFT), String.format(PARAMETER_MUST_HAVE_A_GREATER_THAN_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_SYNC_QUERIES_SHIFT)); usersSyncInterval = parseAndValidateGreaterOrEqualThanZeroDuration(System.getProperty(TASK_ASSIGNING_USERS_SYNC_INTERVAL, DEFAULT_USERS_SYNC_INTERVAL), String.format(PARAMETER_MUST_HAVE_A_GREATER_OR_EQUAL_TO_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_USERS_SYNC_INTERVAL)); waitForImprovedSolutionDuration = parseAndValidateGreaterOrEqualThanZeroDuration(System.getProperty(TASK_ASSIGNING_WAIT_FOR_IMPROVED_SOLUTION_DURATION, DEFAULT_WAIT_FOR_IMPROVED_SOLUTION_DURATION), String.format(PARAMETER_MUST_HAVE_A_GREATER_OR_EQUAL_TO_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_WAIT_FOR_IMPROVED_SOLUTION_DURATION)); improveSolutionOnBackgroundDuration = parseAndValidateGreaterOrEqualThanZeroDuration(System.getProperty(TASK_ASSIGNING_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION, DEFAULT_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION), String.format(PARAMETER_MUST_HAVE_A_GREATER_OR_EQUAL_TO_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION)); return new TaskAssigningServiceConfig(targetUserId, publishWindowSize, syncInterval, syncQueriesShift, usersSyncInterval, waitForImprovedSolutionDuration, improveSolutionOnBackgroundDuration); } private  TaskAssigningPlanningKieServerExtensionHelper(); }
TaskAssigningPlanningKieServerExtensionHelper { public static TaskAssigningServiceConfig readAndValidateTaskAssigningServiceConfig() throws TaskAssigningValidationException { String targetUserId; int publishWindowSize; Duration syncInterval; Duration syncQueriesShift; Duration usersSyncInterval; Duration waitForImprovedSolutionDuration; Duration improveSolutionOnBackgroundDuration; targetUserId = trimToNull(System.getProperty(TASK_ASSIGNING_PROCESS_RUNTIME_TARGET_USER)); if (isNull(targetUserId)) { throw new TaskAssigningValidationException(String.format(PARAMETER_MUST_HAVE_A_NON_EMPTY_STRING_VALUE_ERROR, TASK_ASSIGNING_PROCESS_RUNTIME_TARGET_USER)); } publishWindowSize = parseAndValidateGreaterThanZeroInteger(System.getProperty(TASK_ASSIGNING_PUBLISH_WINDOW_SIZE, Integer.toString(DEFAULT_PUBLISH_WINDOW_SIZE)), String.format(PARAMETER_MUST_HAVE_A_GREATER_THAN_ZERO_INTEGER_VALUE_ERROR, TASK_ASSIGNING_PUBLISH_WINDOW_SIZE)); syncInterval = parseAndValidateGreaterThanZeroDuration(System.getProperty(TASK_ASSIGNING_SYNC_INTERVAL, DEFAULT_SYNC_INTERVAL), String.format(PARAMETER_MUST_HAVE_A_GREATER_THAN_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_SYNC_INTERVAL)); syncQueriesShift = parseAndValidateGreaterThanZeroDuration(System.getProperty(TASK_ASSIGNING_SYNC_QUERIES_SHIFT, DEFAULT_SYNC_QUERIES_SHIFT), String.format(PARAMETER_MUST_HAVE_A_GREATER_THAN_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_SYNC_QUERIES_SHIFT)); usersSyncInterval = parseAndValidateGreaterOrEqualThanZeroDuration(System.getProperty(TASK_ASSIGNING_USERS_SYNC_INTERVAL, DEFAULT_USERS_SYNC_INTERVAL), String.format(PARAMETER_MUST_HAVE_A_GREATER_OR_EQUAL_TO_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_USERS_SYNC_INTERVAL)); waitForImprovedSolutionDuration = parseAndValidateGreaterOrEqualThanZeroDuration(System.getProperty(TASK_ASSIGNING_WAIT_FOR_IMPROVED_SOLUTION_DURATION, DEFAULT_WAIT_FOR_IMPROVED_SOLUTION_DURATION), String.format(PARAMETER_MUST_HAVE_A_GREATER_OR_EQUAL_TO_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_WAIT_FOR_IMPROVED_SOLUTION_DURATION)); improveSolutionOnBackgroundDuration = parseAndValidateGreaterOrEqualThanZeroDuration(System.getProperty(TASK_ASSIGNING_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION, DEFAULT_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION), String.format(PARAMETER_MUST_HAVE_A_GREATER_OR_EQUAL_TO_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION)); return new TaskAssigningServiceConfig(targetUserId, publishWindowSize, syncInterval, syncQueriesShift, usersSyncInterval, waitForImprovedSolutionDuration, improveSolutionOnBackgroundDuration); } private  TaskAssigningPlanningKieServerExtensionHelper(); static TaskAssigningServiceConfig readAndValidateTaskAssigningServiceConfig(); }
TaskAssigningPlanningKieServerExtensionHelper { public static TaskAssigningServiceConfig readAndValidateTaskAssigningServiceConfig() throws TaskAssigningValidationException { String targetUserId; int publishWindowSize; Duration syncInterval; Duration syncQueriesShift; Duration usersSyncInterval; Duration waitForImprovedSolutionDuration; Duration improveSolutionOnBackgroundDuration; targetUserId = trimToNull(System.getProperty(TASK_ASSIGNING_PROCESS_RUNTIME_TARGET_USER)); if (isNull(targetUserId)) { throw new TaskAssigningValidationException(String.format(PARAMETER_MUST_HAVE_A_NON_EMPTY_STRING_VALUE_ERROR, TASK_ASSIGNING_PROCESS_RUNTIME_TARGET_USER)); } publishWindowSize = parseAndValidateGreaterThanZeroInteger(System.getProperty(TASK_ASSIGNING_PUBLISH_WINDOW_SIZE, Integer.toString(DEFAULT_PUBLISH_WINDOW_SIZE)), String.format(PARAMETER_MUST_HAVE_A_GREATER_THAN_ZERO_INTEGER_VALUE_ERROR, TASK_ASSIGNING_PUBLISH_WINDOW_SIZE)); syncInterval = parseAndValidateGreaterThanZeroDuration(System.getProperty(TASK_ASSIGNING_SYNC_INTERVAL, DEFAULT_SYNC_INTERVAL), String.format(PARAMETER_MUST_HAVE_A_GREATER_THAN_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_SYNC_INTERVAL)); syncQueriesShift = parseAndValidateGreaterThanZeroDuration(System.getProperty(TASK_ASSIGNING_SYNC_QUERIES_SHIFT, DEFAULT_SYNC_QUERIES_SHIFT), String.format(PARAMETER_MUST_HAVE_A_GREATER_THAN_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_SYNC_QUERIES_SHIFT)); usersSyncInterval = parseAndValidateGreaterOrEqualThanZeroDuration(System.getProperty(TASK_ASSIGNING_USERS_SYNC_INTERVAL, DEFAULT_USERS_SYNC_INTERVAL), String.format(PARAMETER_MUST_HAVE_A_GREATER_OR_EQUAL_TO_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_USERS_SYNC_INTERVAL)); waitForImprovedSolutionDuration = parseAndValidateGreaterOrEqualThanZeroDuration(System.getProperty(TASK_ASSIGNING_WAIT_FOR_IMPROVED_SOLUTION_DURATION, DEFAULT_WAIT_FOR_IMPROVED_SOLUTION_DURATION), String.format(PARAMETER_MUST_HAVE_A_GREATER_OR_EQUAL_TO_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_WAIT_FOR_IMPROVED_SOLUTION_DURATION)); improveSolutionOnBackgroundDuration = parseAndValidateGreaterOrEqualThanZeroDuration(System.getProperty(TASK_ASSIGNING_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION, DEFAULT_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION), String.format(PARAMETER_MUST_HAVE_A_GREATER_OR_EQUAL_TO_ZERO_DURATION_VALUE_ERROR, TASK_ASSIGNING_IMPROVE_SOLUTION_ON_BACKGROUND_DURATION)); return new TaskAssigningServiceConfig(targetUserId, publishWindowSize, syncInterval, syncQueriesShift, usersSyncInterval, waitForImprovedSolutionDuration, improveSolutionOnBackgroundDuration); } private  TaskAssigningPlanningKieServerExtensionHelper(); static TaskAssigningServiceConfig readAndValidateTaskAssigningServiceConfig();  }