EqualsRule extends AbstractRule { public static Rule getRule(final Stack<Object> stack) { if (stack.size() < 2) { throw new IllegalArgumentException("Invalid EQUALS rule - expected two parameters but received " + stack.size()); } String p2 = stack.pop().toString(); String p1 = stack.pop().toString(); return getRule(p1, p2); } private  EqualsRule(final String field, final String value); static Rule getRule(final Stack<Object> stack); static Rule getRule(final String p1, final String p2); @SuppressWarnings({"rawtypes", "unchecked"}) boolean evaluate(final LogData event, Map matches);  }
@Test public void test1() { Stack<Object> stack = new Stack<>(); stack.push("Hello"); try { EqualsRule.getRule(stack); Assert.fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException ignored) { } }
@Test public void test2() { Stack<Object> stack = new Stack<>(); stack.push("Hello"); stack.push("World"); try { EqualsRule.getRule(stack); Assert.fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException ignored) { } }