DateRangeCondition extends SingleMapperCondition<DateRangeMapper> { static SpatialOperation parseSpatialOperation(String operation) { if (operation == null) { throw new IndexException("Operation is required"); } else if (operation.equalsIgnoreCase("is_within")) { return SpatialOperation.IsWithin; } else if (operation.equalsIgnoreCase("contains")) { return SpatialOperation.Contains; } else if (operation.equalsIgnoreCase("intersects")) { return SpatialOperation.Intersects; } else { throw new IndexException("Operation is invalid: {}", operation); } } DateRangeCondition(Float boost, String field, Object from, Object to, String operation); @Override Query doQuery(DateRangeMapper mapper, Analyzer analyzer); @Override MoreObjects.ToStringHelper toStringHelper(); static final Date DEFAULT_FROM; static final Date DEFAULT_TO; static final String DEFAULT_OPERATION; final Object from; final Object to; final String operation; }
@Test public void testParseSpatialOperationIntersectsLowerCase() { assertEquals("Operation is not properly parsed", Intersects, parseSpatialOperation("intersects")); }
@Test public void testParseSpatialOperationIntersectsUpperCase() { assertEquals("Operation is not properly parsed", Intersects, parseSpatialOperation("INTERSECTS")); }
@Test public void testParseSpatialOperationIsWithinLowerCase() { assertEquals("Operation is not properly parsed", IsWithin, parseSpatialOperation("is_within")); }
@Test public void testParseSpatialOperationIsWithinUpperCase() { assertEquals("Operation is not properly parsed", IsWithin, parseSpatialOperation("IS_WITHIN")); }
@Test public void testParseSpatialOperationIContainsLowerCase() { assertEquals("Operation is not properly parsed", Contains, parseSpatialOperation("contains")); }
@Test public void testParseSpatialOperationContainsUpperCase() { assertEquals("Operation is not properly parsed", Contains, parseSpatialOperation("CONTAINS")); }
@Test(expected = IndexException.class) public void testParseSpatialOperationNull() { parseSpatialOperation(null); }
@Test(expected = IndexException.class) public void testParseSpatialOperationEmpty() { parseSpatialOperation(""); }
@Test(expected = IndexException.class) public void testParseSpatialOperationBlank() { parseSpatialOperation(" "); }