@SuppressWarnings("unchecked") @Test(dataProvider="expressions2") public void test2(final String expression, Map<String, List<Map<String,String>>> data, final String expectedValue, final String expectedStatus, final boolean isValid) { String[] ids = new String[] {"PARAMETER1","PARAMETER2","PARAMETER3"}; for (String id:ids) { FeedProvider provider = Mockito.mock(FeedProvider.class); Mockito.when(provider.getSubscriptionId()).thenReturn("isp:"+id); Mockito.when(provider.getRenderingInfo(Mockito.anyMap())).thenAnswer(new Answer<FeedProvider.RenderingInfo>() { public FeedProvider.RenderingInfo answer(InvocationOnMock invocation) { Object[] args = invocation.getArguments(); Map<String,String> dataValues = Map.class.cast(args[0]); String statusText = dataValues.get(INDICATOR_KEY); boolean isValid = Boolean.parseBoolean(dataValues.get(FeedProvider.NORMALIZED_IS_VALID_KEY)); FeedProvider.RenderingInfo ri = new FeedProvider.RenderingInfo(dataValues.get(FeedProvider.NORMALIZED_VALUE_KEY), Color.GREEN, statusText, Color.red, isValid); return ri; } }); providers.add(provider); } Executor executor = evaluator.compile(expression); FeedProvider.RenderingInfo ri = executor.evaluate(data, providers); Assert.assertEquals(ri, expectedValue); }
@Override public Executor compile(String code) { Matcher m = multiExpressionPattern.matcher(code); expressions = new ArrayList<MultiExpression>(); while (m.find()){ assert m.groupCount() == 7 : "7 matching groups should be discovered: found " + m.groupCount(); String singleOrAll = m.group(1); String puis = m.group(2); String[] puiList = puis.split(MultiRuleExpression.parameterDelimiter, 0); String pui = m.group(3); String relation = m.group(4); String value = m.group(5); String display = m.group(6); expressions.add(new MultiExpression(Enum.valueOf(MultiExpression.SetLogic.class, singleOrAll), puiList, pui, relation, value, display)); } return new MultiExecutor(expressions); }
MultiEvaluator implements MultiProvider { @Override public Executor compile(String code) { Matcher m = multiExpressionPattern.matcher(code); expressions = new ArrayList<MultiExpression>(); while (m.find()){ assert m.groupCount() == 7 : "7 matching groups should be discovered: found " + m.groupCount(); String singleOrAll = m.group(1); String puis = m.group(2); String[] puiList = puis.split(MultiRuleExpression.parameterDelimiter, 0); String pui = m.group(3); String relation = m.group(4); String value = m.group(5); String display = m.group(6); expressions.add(new MultiExpression(Enum.valueOf(MultiExpression.SetLogic.class, singleOrAll), puiList, pui, relation, value, display)); } return new MultiExecutor(expressions); } }
MultiEvaluator implements MultiProvider { @Override public Executor compile(String code) { Matcher m = multiExpressionPattern.matcher(code); expressions = new ArrayList<MultiExpression>(); while (m.find()){ assert m.groupCount() == 7 : "7 matching groups should be discovered: found " + m.groupCount(); String singleOrAll = m.group(1); String puis = m.group(2); String[] puiList = puis.split(MultiRuleExpression.parameterDelimiter, 0); String pui = m.group(3); String relation = m.group(4); String value = m.group(5); String display = m.group(6); expressions.add(new MultiExpression(Enum.valueOf(MultiExpression.SetLogic.class, singleOrAll), puiList, pui, relation, value, display)); } return new MultiExecutor(expressions); }  }
MultiEvaluator implements MultiProvider { @Override public Executor compile(String code) { Matcher m = multiExpressionPattern.matcher(code); expressions = new ArrayList<MultiExpression>(); while (m.find()){ assert m.groupCount() == 7 : "7 matching groups should be discovered: found " + m.groupCount(); String singleOrAll = m.group(1); String puis = m.group(2); String[] puiList = puis.split(MultiRuleExpression.parameterDelimiter, 0); String pui = m.group(3); String relation = m.group(4); String value = m.group(5); String display = m.group(6); expressions.add(new MultiExpression(Enum.valueOf(MultiExpression.SetLogic.class, singleOrAll), puiList, pui, relation, value, display)); } return new MultiExecutor(expressions); }  @Override Executor compile(String code); @Override String getLanguage(); }
MultiEvaluator implements MultiProvider { @Override public Executor compile(String code) { Matcher m = multiExpressionPattern.matcher(code); expressions = new ArrayList<MultiExpression>(); while (m.find()){ assert m.groupCount() == 7 : "7 matching groups should be discovered: found " + m.groupCount(); String singleOrAll = m.group(1); String puis = m.group(2); String[] puiList = puis.split(MultiRuleExpression.parameterDelimiter, 0); String pui = m.group(3); String relation = m.group(4); String value = m.group(5); String display = m.group(6); expressions.add(new MultiExpression(Enum.valueOf(MultiExpression.SetLogic.class, singleOrAll), puiList, pui, relation, value, display)); } return new MultiExecutor(expressions); }  @Override Executor compile(String code); @Override String getLanguage(); static final String LANGUAGE_STRING; static final String NOT_EQUALS; static final Pattern multiExpressionPattern; }