ElementInSetExpression extends BinaryBooleanExpression { @Override public IJsonNode evaluate(final IJsonNode node, final IJsonNode target, final EvaluationContext context) { return this.quantor.evaluate(this.elementExpr.evaluate(node, null, context), ElementInSetExpression.asIterator(this.setExpr.evaluate(node, null, context))); } ElementInSetExpression(final EvaluationExpression elementExpr, final Quantor quantor,
			final EvaluationExpression setExpr); @Override IJsonNode evaluate(final IJsonNode node, final IJsonNode target, final EvaluationContext context); @Override EvaluationExpression transformRecursively(final TransformFunction function); EvaluationExpression getElementExpr(); Quantor getQuantor(); EvaluationExpression getSetExpr(); @Override void toString(final StringBuilder builder); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void shouldFindElementInSet() { final IJsonNode result = new ElementInSetExpression(new InputSelection(0), Quantor.EXISTS_IN, new InputSelection(1)).evaluate( createArrayNode(IntNode.valueOf(2), createArrayNode(IntNode.valueOf(1), IntNode.valueOf(2), IntNode.valueOf(3))), null, this.context); Assert.assertEquals(BooleanNode.TRUE, result); }
@Test public void shouldNotFindElementInSet() { final IJsonNode result = new ElementInSetExpression(new InputSelection(0), Quantor.EXISTS_IN, new InputSelection(1)).evaluate( createArrayNode(IntNode.valueOf(0), createArrayNode(IntNode.valueOf(1), IntNode.valueOf(2), IntNode.valueOf(3))), null, this.context); Assert.assertEquals(BooleanNode.FALSE, result); }
@Test public void shouldFindNonexistingElementInSet() { final IJsonNode result = new ElementInSetExpression(new InputSelection(0), Quantor.EXISTS_NOT_IN, new InputSelection(1)).evaluate( createArrayNode(IntNode.valueOf(2), createArrayNode(IntNode.valueOf(1), IntNode.valueOf(2), IntNode.valueOf(3))), null, this.context); Assert.assertEquals(BooleanNode.FALSE, result); }
@Test public void shouldNotFindNonexistingElementInSet() { final IJsonNode result = new ElementInSetExpression(new InputSelection(0), Quantor.EXISTS_NOT_IN, new InputSelection(1)).evaluate( createArrayNode(IntNode.valueOf(0), createArrayNode(IntNode.valueOf(1), IntNode.valueOf(2), IntNode.valueOf(3))), null, this.context); Assert.assertEquals(BooleanNode.TRUE, result); }
@Test public void shouldReturnFalseIfSetIsEmpty() { final IJsonNode result = new ElementInSetExpression(new InputSelection(0), Quantor.EXISTS_IN, new InputSelection(1)).evaluate( createArrayNode(IntNode.valueOf(2), createArrayNode()), null, this.context); Assert.assertEquals(BooleanNode.FALSE, result); }