-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from zapr-oss/develop
Version bumped to 2.1
- Loading branch information
Showing
6 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/test/java/in/zapr/druid/druidry/filter/BoundFilterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package in.zapr.druid.druidry.filter; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
import org.skyscreamer.jsonassert.JSONAssert; | ||
import org.skyscreamer.jsonassert.JSONCompareMode; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
import in.zapr.druid.druidry.SortingOrder; | ||
|
||
public class BoundFilterTest { | ||
|
||
private static ObjectMapper objectMapper; | ||
|
||
@BeforeClass | ||
public void init() { | ||
objectMapper = new ObjectMapper(); | ||
} | ||
|
||
@Test | ||
public void testAllFields() throws JSONException, JsonProcessingException { | ||
|
||
BoundFilter filter = BoundFilter.builder() | ||
.dimension("Hello") | ||
.lower("21") | ||
.upper("31") | ||
.lowerStrict(true) | ||
.upperStrict(false) | ||
.ordering(SortingOrder.ALPHANUMERIC) | ||
.build(); | ||
|
||
JSONObject jsonObject = new JSONObject(); | ||
jsonObject.put("type", "bound"); | ||
jsonObject.put("dimension", "Hello"); | ||
jsonObject.put("lower", "21"); | ||
jsonObject.put("upper", "31"); | ||
jsonObject.put("lowerStrict", true); | ||
jsonObject.put("upperStrict", false); | ||
jsonObject.put("ordering", "alphanumeric"); | ||
|
||
String actualJSON = objectMapper.writeValueAsString(filter); | ||
String expectedJSON = jsonObject.toString(); | ||
JSONAssert.assertEquals(expectedJSON, actualJSON, JSONCompareMode.NON_EXTENSIBLE); | ||
} | ||
|
||
@Test(expectedExceptions = NullPointerException.class) | ||
public void testRequiredFieldsMissing() { | ||
BoundFilter filter = BoundFilter.builder() | ||
.build(); | ||
} | ||
|
||
@Test(expectedExceptions = NullPointerException.class) | ||
public void testSettingRequiredFieldAsNull() { | ||
BoundFilter filter = BoundFilter.builder() | ||
.dimension("Hello") | ||
.lower("21") | ||
.upper("31") | ||
.lowerStrict(true) | ||
.upperStrict(false) | ||
.ordering(SortingOrder.ALPHANUMERIC) | ||
.build(); | ||
|
||
filter.setDimension(null); | ||
} | ||
} |