@Test(expected = TaskHandlerException.class) public void shouldThrowExceptionIfDataSourceObjectIsNotFound() throws TaskHandlerException { List<Filter> filters = new ArrayList<>(); List<String> filtersManipulations = new ArrayList<>(); filters.add(new Filter("MRS.Person#2.Age", "ad.2.Person#2.age", INTEGER, false, EXIST.getValue(), "", filtersManipulations)); Task task = new TaskBuilder().addAction(new TaskActionInformation()).build(); TaskContext taskContext = new TaskContext(task, new HashMap<>(), new HashMap<>(), activityService); new TaskFilterExecutor().checkFilters(filters, LogicalOperator.AND, taskContext); }
public boolean checkFilters(List<Filter> filters, LogicalOperator logicalOperator, TaskContext taskContext) throws TaskHandlerException { LOGGER.debug("Checking if task: {} matches the filters", taskContext.getTask().getName()); Map<String, Object> parameters = taskContext.getTriggerParameters(); if (isEmpty(filters) || parameters == null) { return true; } boolean filterCheck = false; for (Filter filter : filters) { KeyInformation key = parse(filter.getKey()); Object value; try { KeyEvaluator keyEvaluator = new KeyEvaluator(taskContext); value = keyEvaluator.getManipulatedValue(key); } catch (TaskHandlerException e) { if (TaskFailureCause.DATA_SOURCE.equals(e.getFailureCause())) { throw e; } value = null; LOGGER.error("Unable to retrieve value for filter", e); } catch (RuntimeException e) { value = null; LOGGER.error("Unable to retrieve value for filter", e); } filterCheck = value != null && checkValue(filter, value); if (!filter.isNegationOperator()) { filterCheck = !filterCheck; } LOGGER.debug("Result of checking filter: {} for task: {} is: {}", filter.getDisplayName(), taskContext.getTask().getName(), filterCheck); if (isFilterConditionFulfilled(filterCheck, logicalOperator)) { LOGGER.debug("Filters condition is fulfilled, because logicalOperator is: {} and filters checking has already: {} value", logicalOperator, filterCheck); break; } } LOGGER.info("Result of checking filters for task: {} is: {}", taskContext.getTask().getName(), filterCheck); return filterCheck; }
TaskFilterExecutor { public boolean checkFilters(List<Filter> filters, LogicalOperator logicalOperator, TaskContext taskContext) throws TaskHandlerException { LOGGER.debug("Checking if task: {} matches the filters", taskContext.getTask().getName()); Map<String, Object> parameters = taskContext.getTriggerParameters(); if (isEmpty(filters) || parameters == null) { return true; } boolean filterCheck = false; for (Filter filter : filters) { KeyInformation key = parse(filter.getKey()); Object value; try { KeyEvaluator keyEvaluator = new KeyEvaluator(taskContext); value = keyEvaluator.getManipulatedValue(key); } catch (TaskHandlerException e) { if (TaskFailureCause.DATA_SOURCE.equals(e.getFailureCause())) { throw e; } value = null; LOGGER.error("Unable to retrieve value for filter", e); } catch (RuntimeException e) { value = null; LOGGER.error("Unable to retrieve value for filter", e); } filterCheck = value != null && checkValue(filter, value); if (!filter.isNegationOperator()) { filterCheck = !filterCheck; } LOGGER.debug("Result of checking filter: {} for task: {} is: {}", filter.getDisplayName(), taskContext.getTask().getName(), filterCheck); if (isFilterConditionFulfilled(filterCheck, logicalOperator)) { LOGGER.debug("Filters condition is fulfilled, because logicalOperator is: {} and filters checking has already: {} value", logicalOperator, filterCheck); break; } } LOGGER.info("Result of checking filters for task: {} is: {}", taskContext.getTask().getName(), filterCheck); return filterCheck; } }
TaskFilterExecutor { public boolean checkFilters(List<Filter> filters, LogicalOperator logicalOperator, TaskContext taskContext) throws TaskHandlerException { LOGGER.debug("Checking if task: {} matches the filters", taskContext.getTask().getName()); Map<String, Object> parameters = taskContext.getTriggerParameters(); if (isEmpty(filters) || parameters == null) { return true; } boolean filterCheck = false; for (Filter filter : filters) { KeyInformation key = parse(filter.getKey()); Object value; try { KeyEvaluator keyEvaluator = new KeyEvaluator(taskContext); value = keyEvaluator.getManipulatedValue(key); } catch (TaskHandlerException e) { if (TaskFailureCause.DATA_SOURCE.equals(e.getFailureCause())) { throw e; } value = null; LOGGER.error("Unable to retrieve value for filter", e); } catch (RuntimeException e) { value = null; LOGGER.error("Unable to retrieve value for filter", e); } filterCheck = value != null && checkValue(filter, value); if (!filter.isNegationOperator()) { filterCheck = !filterCheck; } LOGGER.debug("Result of checking filter: {} for task: {} is: {}", filter.getDisplayName(), taskContext.getTask().getName(), filterCheck); if (isFilterConditionFulfilled(filterCheck, logicalOperator)) { LOGGER.debug("Filters condition is fulfilled, because logicalOperator is: {} and filters checking has already: {} value", logicalOperator, filterCheck); break; } } LOGGER.info("Result of checking filters for task: {} is: {}", taskContext.getTask().getName(), filterCheck); return filterCheck; } TaskFilterExecutor(); }
TaskFilterExecutor { public boolean checkFilters(List<Filter> filters, LogicalOperator logicalOperator, TaskContext taskContext) throws TaskHandlerException { LOGGER.debug("Checking if task: {} matches the filters", taskContext.getTask().getName()); Map<String, Object> parameters = taskContext.getTriggerParameters(); if (isEmpty(filters) || parameters == null) { return true; } boolean filterCheck = false; for (Filter filter : filters) { KeyInformation key = parse(filter.getKey()); Object value; try { KeyEvaluator keyEvaluator = new KeyEvaluator(taskContext); value = keyEvaluator.getManipulatedValue(key); } catch (TaskHandlerException e) { if (TaskFailureCause.DATA_SOURCE.equals(e.getFailureCause())) { throw e; } value = null; LOGGER.error("Unable to retrieve value for filter", e); } catch (RuntimeException e) { value = null; LOGGER.error("Unable to retrieve value for filter", e); } filterCheck = value != null && checkValue(filter, value); if (!filter.isNegationOperator()) { filterCheck = !filterCheck; } LOGGER.debug("Result of checking filter: {} for task: {} is: {}", filter.getDisplayName(), taskContext.getTask().getName(), filterCheck); if (isFilterConditionFulfilled(filterCheck, logicalOperator)) { LOGGER.debug("Filters condition is fulfilled, because logicalOperator is: {} and filters checking has already: {} value", logicalOperator, filterCheck); break; } } LOGGER.info("Result of checking filters for task: {} is: {}", taskContext.getTask().getName(), filterCheck); return filterCheck; } TaskFilterExecutor(); boolean checkFilters(List<Filter> filters, LogicalOperator logicalOperator, TaskContext taskContext); }
TaskFilterExecutor { public boolean checkFilters(List<Filter> filters, LogicalOperator logicalOperator, TaskContext taskContext) throws TaskHandlerException { LOGGER.debug("Checking if task: {} matches the filters", taskContext.getTask().getName()); Map<String, Object> parameters = taskContext.getTriggerParameters(); if (isEmpty(filters) || parameters == null) { return true; } boolean filterCheck = false; for (Filter filter : filters) { KeyInformation key = parse(filter.getKey()); Object value; try { KeyEvaluator keyEvaluator = new KeyEvaluator(taskContext); value = keyEvaluator.getManipulatedValue(key); } catch (TaskHandlerException e) { if (TaskFailureCause.DATA_SOURCE.equals(e.getFailureCause())) { throw e; } value = null; LOGGER.error("Unable to retrieve value for filter", e); } catch (RuntimeException e) { value = null; LOGGER.error("Unable to retrieve value for filter", e); } filterCheck = value != null && checkValue(filter, value); if (!filter.isNegationOperator()) { filterCheck = !filterCheck; } LOGGER.debug("Result of checking filter: {} for task: {} is: {}", filter.getDisplayName(), taskContext.getTask().getName(), filterCheck); if (isFilterConditionFulfilled(filterCheck, logicalOperator)) { LOGGER.debug("Filters condition is fulfilled, because logicalOperator is: {} and filters checking has already: {} value", logicalOperator, filterCheck); break; } } LOGGER.info("Result of checking filters for task: {} is: {}", taskContext.getTask().getName(), filterCheck); return filterCheck; } TaskFilterExecutor(); boolean checkFilters(List<Filter> filters, LogicalOperator logicalOperator, TaskContext taskContext);  }