@Test public void createExpressionInputNullNullNullOutputNullPointerException() { final ExpressionFactory objectUnderTest = new ExpressionFactory(); final String left = null; final String operand = null; final String right = null; thrown.expect(NullPointerException.class); objectUnderTest.createExpression(left, operand, right); }
public T createExpression(String left, String operand, String right) { if (operand.endsWith(Statement.EQUALS)) { return (T) new Equals(left, right); } if (operand.endsWith(Statement.REGEX)) { return (T) new Regex(left, right); } if (operand.endsWith(Statement.GREATER_THAN)) { return (T) new GreaterThan(left, right); } if (operand.endsWith(Statement.GREATER_EQUAL_THAN)) { return (T) new GreaterEqualThan(left, right); } if (operand.endsWith(Statement.LESS_THAN)) { return (T) new LessThan(left, right); } if (operand.endsWith(Statement.LESS_EQUAL_THAN)) { return (T) new LessEqualThan(left, right); } if (operand.endsWith(Statement.BETWEEN_TIME)) { return (T) new BetweenTime(left, right); } throw new UnsupportedOperationException("Operand " + operand + " is not a " + "recognised expression operand. HINT: check for spelling errors"); }
ExpressionFactory { public T createExpression(String left, String operand, String right) { if (operand.endsWith(Statement.EQUALS)) { return (T) new Equals(left, right); } if (operand.endsWith(Statement.REGEX)) { return (T) new Regex(left, right); } if (operand.endsWith(Statement.GREATER_THAN)) { return (T) new GreaterThan(left, right); } if (operand.endsWith(Statement.GREATER_EQUAL_THAN)) { return (T) new GreaterEqualThan(left, right); } if (operand.endsWith(Statement.LESS_THAN)) { return (T) new LessThan(left, right); } if (operand.endsWith(Statement.LESS_EQUAL_THAN)) { return (T) new LessEqualThan(left, right); } if (operand.endsWith(Statement.BETWEEN_TIME)) { return (T) new BetweenTime(left, right); } throw new UnsupportedOperationException("Operand " + operand + " is not a " + "recognised expression operand. HINT: check for spelling errors"); } }
ExpressionFactory { public T createExpression(String left, String operand, String right) { if (operand.endsWith(Statement.EQUALS)) { return (T) new Equals(left, right); } if (operand.endsWith(Statement.REGEX)) { return (T) new Regex(left, right); } if (operand.endsWith(Statement.GREATER_THAN)) { return (T) new GreaterThan(left, right); } if (operand.endsWith(Statement.GREATER_EQUAL_THAN)) { return (T) new GreaterEqualThan(left, right); } if (operand.endsWith(Statement.LESS_THAN)) { return (T) new LessThan(left, right); } if (operand.endsWith(Statement.LESS_EQUAL_THAN)) { return (T) new LessEqualThan(left, right); } if (operand.endsWith(Statement.BETWEEN_TIME)) { return (T) new BetweenTime(left, right); } throw new UnsupportedOperationException("Operand " + operand + " is not a " + "recognised expression operand. HINT: check for spelling errors"); }  }
ExpressionFactory { public T createExpression(String left, String operand, String right) { if (operand.endsWith(Statement.EQUALS)) { return (T) new Equals(left, right); } if (operand.endsWith(Statement.REGEX)) { return (T) new Regex(left, right); } if (operand.endsWith(Statement.GREATER_THAN)) { return (T) new GreaterThan(left, right); } if (operand.endsWith(Statement.GREATER_EQUAL_THAN)) { return (T) new GreaterEqualThan(left, right); } if (operand.endsWith(Statement.LESS_THAN)) { return (T) new LessThan(left, right); } if (operand.endsWith(Statement.LESS_EQUAL_THAN)) { return (T) new LessEqualThan(left, right); } if (operand.endsWith(Statement.BETWEEN_TIME)) { return (T) new BetweenTime(left, right); } throw new UnsupportedOperationException("Operand " + operand + " is not a " + "recognised expression operand. HINT: check for spelling errors"); }  T createExpression(String left, String operand, String right); }
ExpressionFactory { public T createExpression(String left, String operand, String right) { if (operand.endsWith(Statement.EQUALS)) { return (T) new Equals(left, right); } if (operand.endsWith(Statement.REGEX)) { return (T) new Regex(left, right); } if (operand.endsWith(Statement.GREATER_THAN)) { return (T) new GreaterThan(left, right); } if (operand.endsWith(Statement.GREATER_EQUAL_THAN)) { return (T) new GreaterEqualThan(left, right); } if (operand.endsWith(Statement.LESS_THAN)) { return (T) new LessThan(left, right); } if (operand.endsWith(Statement.LESS_EQUAL_THAN)) { return (T) new LessEqualThan(left, right); } if (operand.endsWith(Statement.BETWEEN_TIME)) { return (T) new BetweenTime(left, right); } throw new UnsupportedOperationException("Operand " + operand + " is not a " + "recognised expression operand. HINT: check for spelling errors"); }  T createExpression(String left, String operand, String right);  }