Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
aeberhart committed Oct 29, 2023
1 parent 5cb14de commit 97813fa
Showing 1 changed file with 2 additions and 45 deletions.
47 changes: 2 additions & 45 deletions dashjoin-core/src/test/java/org/dashjoin/service/ModelTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.dashjoin.service;

import java.io.File;
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
Expand All @@ -14,14 +12,11 @@
import org.junit.jupiter.api.Test;
import org.reflections.Reflections;
import org.reflections.scanners.ResourcesScanner;
import com.api.jsonata4java.Expression;
import com.dashjoin.jsonata.Jsonata;
import com.dashjoin.jsonata.Jsonata.JFunction;
import com.dashjoin.jsonata.Jsonata.JFunctionCallable;
import com.fasterxml.jackson.core.json.JsonReadFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.TextNode;
Expand Down Expand Up @@ -195,7 +190,8 @@ void checkExpressions(JsonNode tree) throws Exception {
Jsonata jsonata = Jsonata.jsonata(expr);
JFunction x = new JFunction(new JFunctionCallable() {
@Override
public Object call(Object input, List args) throws Throwable {
public Object call(Object input, @SuppressWarnings("rawtypes") List args)
throws Throwable {
return null;
}
}, "<a?a?a?a?:s>");
Expand Down Expand Up @@ -233,43 +229,4 @@ public Object call(Object input, List args) throws Throwable {
}
}
}

public static void testDriver(String file) throws Exception {

ObjectMapper om =
new ObjectMapper().configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
.configure(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature(), true)
.configure(JsonReadFeature.ALLOW_SINGLE_QUOTES.mappedFeature(), true)
.configure(JsonReadFeature.ALLOW_JAVA_COMMENTS.mappedFeature(), true);

JsonNode map = om.readTree(new FileInputStream(new File(file)));
file = map.get("test").get("file").asText();
JsonNode test = om.readTree(new FileInputStream(new File(file)));
String expr =
Expression.jsonata(map.get("test").get("expression").asText()).evaluate(test).asText();

Expression e = Expression.jsonata(expr);
Iterator<String> cases = map.get("cases").fieldNames();
while (cases.hasNext()) {
String name = cases.next();
JsonNode c = map.get("cases").get(name);
ObjectNode basedata = map.get("basedata").deepCopy();

Iterator<String> dataFields = c.get("data").fieldNames();
while (dataFields.hasNext()) {
String field = dataFields.next();
basedata.set(field, c.get("data").get(field));
}

Assertions.assertEquals("error in case: " + name, "" + c.get("expected"),
"" + wrap(e.evaluate(basedata)));
}
}

static JsonNode wrap(JsonNode n) {
if (n instanceof ArrayNode)
return n;
else
return om.createArrayNode().add(n);
}
}

0 comments on commit 97813fa

Please sign in to comment.