OperatorPage extends BaseDecisionTableColumnPage<ConditionColumnPlugin> { String[] filterOptionsForConstraintTypeLiteral(final String[] options) { final List<String> operatorOptions = new ArrayList<>(); Collections.addAll(operatorOptions, options); if (getConstraintValueType() != BaseSingleFieldConstraint.TYPE_LITERAL) { operatorOptions.remove("in"); operatorOptions.remove("not in"); } return operatorOptions.toArray(new String[operatorOptions.size()]); } @Inject  OperatorPage(final View view,
                        final Event<WizardPageStatusChangeEvent> changeEvent,
                        final TranslationService translationService); @Override String getTitle(); @Override void prepareView(); @Override void isComplete(final Callback<Boolean> callback); String getOperator();  }
@Test public void testFilterOptionsForConstraintTypeLiteralWhenConstraintValueIsLiteral() { when(plugin.constraintValue()).thenReturn(BaseSingleFieldConstraint.TYPE_LITERAL); final String[] result = page.filterOptionsForConstraintTypeLiteral(OperatorsOracle.EXPLICIT_LIST_OPERATORS); final List<String> operators = Arrays.asList(result); assertTrue(operators.contains("in")); assertTrue(operators.contains("not in")); assertEquals(2, operators.size()); }
@Test public void testFilterOptionsForConstraintTypeLiteralWhenConstraintValueIsPredicate() { when(plugin.constraintValue()).thenReturn(BaseSingleFieldConstraint.TYPE_PREDICATE); final String[] result = page.filterOptionsForConstraintTypeLiteral(OperatorsOracle.EXPLICIT_LIST_OPERATORS); final List<String> operators = Arrays.asList(result); assertEquals(0, operators.size()); }
@Test public void testFilterOptionsForConstraintTypeLiteralWhenConstraintValueIsFormula() { when(plugin.constraintValue()).thenReturn(BaseSingleFieldConstraint.TYPE_RET_VALUE); final String[] result = page.filterOptionsForConstraintTypeLiteral(OperatorsOracle.EXPLICIT_LIST_OPERATORS); final List<String> operators = Arrays.asList(result); assertEquals(0, operators.size()); }