-
Notifications
You must be signed in to change notification settings - Fork 6
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 #78 from dcrissman/Join-NeedDistrict
fix Join needDistinct and add unit test
- Loading branch information
Showing
2 changed files
with
55 additions
and
6 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
50 changes: 50 additions & 0 deletions
50
metadata/src/test/java/com/redhat/lightblue/metadata/rdbms/model/JoinTest.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,50 @@ | ||
package com.redhat.lightblue.metadata.rdbms.model; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.IOException; | ||
|
||
import org.junit.Test; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.node.JsonNodeFactory; | ||
import com.redhat.lightblue.metadata.parser.Extensions; | ||
import com.redhat.lightblue.metadata.parser.JSONMetadataParser; | ||
import com.redhat.lightblue.metadata.parser.MetadataParser; | ||
import com.redhat.lightblue.metadata.types.DefaultTypes; | ||
import com.redhat.lightblue.util.JsonUtils; | ||
|
||
public class JoinTest { | ||
|
||
@Test | ||
public void testParse_DistinctTrue() throws IOException{ | ||
MetadataParser<JsonNode> p = new JSONMetadataParser( | ||
new Extensions<JsonNode>(), | ||
new DefaultTypes(), | ||
new JsonNodeFactory(true)); | ||
|
||
JsonNode node = JsonUtils.json("{\"tables\":[{\"name\":\"tname\"}],\"needDistinct\":true,\"projectionMappings\":[{\"column\":\"c\",\"field\":\"f\"}]}"); | ||
|
||
Join join = new Join(); | ||
join.parse(p, node); | ||
|
||
assertTrue(join.isNeedDistinct()); | ||
} | ||
|
||
@Test | ||
public void testParse_DistinctFalse() throws IOException{ | ||
MetadataParser<JsonNode> p = new JSONMetadataParser( | ||
new Extensions<JsonNode>(), | ||
new DefaultTypes(), | ||
new JsonNodeFactory(true)); | ||
|
||
JsonNode node = JsonUtils.json("{\"tables\":[{\"name\":\"tname\"}],\"needDistinct\":false,\"projectionMappings\":[{\"column\":\"c\",\"field\":\"f\"}]}"); | ||
|
||
Join join = new Join(); | ||
join.parse(p, node); | ||
|
||
assertFalse(join.isNeedDistinct()); | ||
} | ||
|
||
} |