rewrite tests
diff --git a/src/test/java/FoundryRewriteTest.java b/src/test/java/FoundryRewriteTest.java
index a437208..c9e63f2 100644
--- a/src/test/java/FoundryRewriteTest.java
+++ b/src/test/java/FoundryRewriteTest.java
@@ -3,9 +3,6 @@
import de.ids_mannheim.korap.config.KustvaktConfiguration;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
import de.ids_mannheim.korap.resource.LayerMapper;
-import de.ids_mannheim.korap.resource.RewriteProcessor;
-import de.ids_mannheim.korap.resource.rewrite.CollectionCleanupFilter;
-import de.ids_mannheim.korap.resource.rewrite.CollectionConstraint;
import de.ids_mannheim.korap.resource.rewrite.FoundryInject;
import de.ids_mannheim.korap.resource.rewrite.RewriteHandler;
import de.ids_mannheim.korap.utils.JsonUtils;
@@ -35,10 +32,11 @@
@Test
public void testSimpleFoundryAddThrowsNoError() {
- RewriteProcessor processor = new RewriteProcessor(config);
+ RewriteHandler processor = new RewriteHandler();
+ processor.add(new FoundryInject(config));
QuerySerializer s = new QuerySerializer();
s.setQuery(simple_add_query, "poliqarp");
- String result = processor.process(s.toJSON());
+ String result = processor.apply(s.toJSON(), null);
JsonNode node = JsonUtils.readTree(result);
assert node != null;
@@ -113,100 +111,4 @@
assert node.at("/query/wrap/operands/1/rewrites").isMissingNode();
}
- @Test
- public void testCollectionNodeRemoveCorpusIdNoErrors() {
- RewriteHandler handler = new RewriteHandler();
- handler.add(new CollectionConstraint());
- QuerySerializer s = new QuerySerializer();
- s.setQuery(simple_add_query, "poliqarp");
- s.setCollection("textClass=politik & corpusID=WPD");
- String result = s.toJSON();
- JsonNode node = JsonUtils.readTree(handler.apply(result, null));
- assert node != null;
- assert node.at("/collection/operands").size() == 1;
- }
-
- @Test
- public void testCollectionNodeRemoveAllCorpusIdNoErrors() {
- RewriteHandler handler = new RewriteHandler();
- handler.add(new CollectionConstraint());
- QuerySerializer s = new QuerySerializer();
- s.setQuery(simple_add_query, "poliqarp");
- s.setCollection("corpusID=BRZ13 & corpusID=WPD");
- String result = s.toJSON();
- JsonNode node = JsonUtils.readTree(handler.apply(result, null));
-
- assert node != null;
- assert node.at("/collection/operands").size() == 0;
- }
-
- @Test
- public void testCollectionNodeRemoveGroupedCorpusIdNoErrors() {
- RewriteHandler handler = new RewriteHandler();
- handler.add(new CollectionConstraint());
- QuerySerializer s = new QuerySerializer();
- s.setQuery(simple_add_query, "poliqarp");
- s.setCollection(
- "(corpusID=BRZ13 & textClass=Wissenschaft) & corpusID=WPD");
- String result = s.toJSON();
- JsonNode node = JsonUtils.readTree(handler.apply(result, null));
-
- assert node != null;
- assert node.at("/collection/operands/0/@type").asText()
- .equals("koral:docGroup");
- assert node.at("/collection/operands/0/operands/0/key").asText()
- .equals("textClass");
- }
-
- //fixme: will probably fail when one doc groups are being refactored
- @Test
- public void testCollectionCleanEmptyDocGroupNoErrors() {
- RewriteHandler handler = new RewriteHandler();
- handler.add(new CollectionConstraint());
- handler.add(new CollectionCleanupFilter());
- QuerySerializer s = new QuerySerializer();
- s.setQuery(simple_add_query, "poliqarp");
- s.setCollection(
- "(corpusID=BRZ13 & corpusID=WPD) & textClass=Wissenschaft & textClass=Sport");
- String result = s.toJSON();
- JsonNode node = JsonUtils.readTree(handler.apply(result, null));
- assert node != null;
- assert node.at("/collection/@type").asText().equals("koral:docGroup");
- assert node.at("/collection/operands").size() == 2;
- assert node.at("/collection/operands/0/key").asText()
- .equals("textClass");
- assert node.at("/collection/operands/1/key").asText()
- .equals("textClass");
- }
-
- @Test
- public void testCollectionCleanMoveOneDocFromGroupUpNoErrors() {
- RewriteHandler handler = new RewriteHandler();
- handler.add(new CollectionConstraint());
- handler.add(new CollectionCleanupFilter());
- QuerySerializer s = new QuerySerializer();
- s.setQuery(simple_add_query, "poliqarp");
- s.setCollection("(corpusID=BRZ13 & textClass=Wissenschaft)");
- String result = s.toJSON();
- JsonNode node = JsonUtils.readTree(handler.apply(result, null));
- assert node != null;
- assert node.at("/collection/@type").asText().equals("koral:doc");
- }
-
- @Test
- public void testCollectionCleanEmptyGroupAndMoveOneDocFromGroupUpNoErrors() {
- RewriteHandler handler = new RewriteHandler();
- handler.add(new CollectionConstraint());
- handler.add(new CollectionCleanupFilter());
- QuerySerializer s = new QuerySerializer();
- s.setQuery(simple_add_query, "poliqarp");
- s.setCollection(
- "(corpusID=BRZ13 & corpusID=WPD) & textClass=Wissenschaft");
- String result = s.toJSON();
- JsonNode node = JsonUtils.readTree(handler.apply(result, null));
- assert node != null;
- assert node.at("/collection/@type").asText().equals("koral:doc");
- assert node.at("/collection/key").asText().equals("textClass");
- }
-
}