Remove all references to org.json in core
This commit is contained in:
parent
d6ca879558
commit
99e98a2e78
@ -59,7 +59,7 @@ public class MassEditCommand extends EngineDependentCommand {
|
||||
engineConfig,
|
||||
columnName,
|
||||
expression,
|
||||
ParsingUtilities.mapper.readValue(ParsingUtilities.evaluateJsonStringToArray(editsString).toString(), new TypeReference<List<Edit>>() {})
|
||||
ParsingUtilities.mapper.readValue(editsString, new TypeReference<List<Edit>>() {})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -33,14 +33,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package com.google.refine.commands.column;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.google.refine.browsing.EngineConfig;
|
||||
import com.google.refine.commands.EngineDependentCommand;
|
||||
import com.google.refine.model.AbstractOperation;
|
||||
import com.google.refine.model.Project;
|
||||
import com.google.refine.operations.column.ColumnReorderOperation;
|
||||
import com.google.refine.util.JSONUtilities;
|
||||
import com.google.refine.util.ParsingUtilities;
|
||||
|
||||
public class ReorderColumnsCommand extends EngineDependentCommand {
|
||||
@ -51,7 +53,6 @@ public class ReorderColumnsCommand extends EngineDependentCommand {
|
||||
|
||||
String columnNames = request.getParameter("columnNames");
|
||||
return new ColumnReorderOperation(
|
||||
JSONUtilities.toStringList(
|
||||
ParsingUtilities.evaluateJsonStringToArray(columnNames)));
|
||||
ParsingUtilities.mapper.readValue(columnNames, new TypeReference<List<String>>() {}));
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,14 @@ public class ReconciledDataExtensionJob {
|
||||
final public String id;
|
||||
final public ReconType expectedType;
|
||||
|
||||
protected ColumnInfo(String name, String id, ReconType expectedType) {
|
||||
@JsonCreator
|
||||
protected ColumnInfo(
|
||||
@JsonProperty("name")
|
||||
String name,
|
||||
@JsonProperty("id")
|
||||
String id,
|
||||
@JsonProperty("type")
|
||||
ReconType expectedType) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
this.expectedType = expectedType;
|
||||
|
@ -33,18 +33,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package com.google.refine.util;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeType;
|
||||
@ -55,14 +45,6 @@ import com.google.refine.expr.util.JsonValueConverter;
|
||||
|
||||
public class JSONUtilities {
|
||||
|
||||
static public JSONObject getObject(JSONObject obj, String key) {
|
||||
try {
|
||||
return obj.getJSONObject(key);
|
||||
} catch (JSONException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static public ObjectNode getObject(ObjectNode obj, String key) {
|
||||
JsonNode node = obj.get(key);
|
||||
if(node != null && node instanceof ObjectNode) {
|
||||
@ -71,14 +53,6 @@ public class JSONUtilities {
|
||||
return null;
|
||||
}
|
||||
|
||||
static public String getString(JSONObject obj, String key, String def) {
|
||||
try {
|
||||
return obj.getString(key);
|
||||
} catch (JSONException e) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
static public String getString(JsonNode obj, String key, String def) {
|
||||
if (obj.has(key)) {
|
||||
return obj.get(key).textValue();
|
||||
@ -87,14 +61,6 @@ public class JSONUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
static public int getInt(JSONObject obj, String key, int def) {
|
||||
try {
|
||||
return obj.getInt(key);
|
||||
} catch (JSONException e) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
static public int getInt(JsonNode obj, String key, int def) {
|
||||
if (obj.has(key)) {
|
||||
return obj.get(key).asInt(def);
|
||||
@ -103,14 +69,6 @@ public class JSONUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
static public boolean getBoolean(JSONObject obj, String key, boolean def) {
|
||||
try {
|
||||
return obj.getBoolean(key);
|
||||
} catch (JSONException e) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
static public boolean getBoolean(JsonNode obj, String key, boolean def) {
|
||||
if (obj.has(key)) {
|
||||
return obj.get(key).asBoolean(def);
|
||||
@ -119,50 +77,6 @@ public class JSONUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
static public double getDouble(JSONObject obj, String key, double def) {
|
||||
try {
|
||||
return obj.getDouble(key);
|
||||
} catch (JSONException e) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
static public long getLong(JSONObject obj, String key, long def) {
|
||||
try {
|
||||
return obj.getLong(key);
|
||||
} catch (JSONException e) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
static public OffsetDateTime getDate(JSONObject obj, String key, OffsetDateTime def) {
|
||||
try {
|
||||
OffsetDateTime d = ParsingUtilities.stringToDate(obj.getString(key));
|
||||
|
||||
return d != null ? d : def;
|
||||
} catch (JSONException e) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
static public LocalDateTime getLocalDate(JSONObject obj, String key, LocalDateTime def) {
|
||||
try {
|
||||
LocalDateTime d = ParsingUtilities.stringToLocalDate(obj.getString(key));
|
||||
|
||||
return d != null ? d : def;
|
||||
} catch (JSONException e) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
static public JSONArray getArray(JSONObject obj, String key) {
|
||||
try {
|
||||
return obj.getJSONArray(key);
|
||||
} catch (JSONException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static public ArrayNode getArray(ObjectNode obj, String key) {
|
||||
JsonNode v = obj.get(key);
|
||||
if( obj.has(key) && obj.get(key) instanceof ArrayNode) {
|
||||
@ -179,25 +93,6 @@ public class JSONUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
static public JSONArray arrayToJSONArray(String[] array) {
|
||||
return new JSONArray(Arrays.asList(array));
|
||||
}
|
||||
|
||||
static public int[] getIntArray(JSONObject obj, String key) {
|
||||
try {
|
||||
JSONArray a = obj.getJSONArray(key);
|
||||
int[] r = new int[a.length()];
|
||||
|
||||
for (int i = 0; i < r.length; i++) {
|
||||
r[i] = a.getInt(i);
|
||||
}
|
||||
|
||||
return r;
|
||||
} catch (JSONException e) {
|
||||
return new int[0];
|
||||
}
|
||||
}
|
||||
|
||||
static public int[] getIntArray(ObjectNode obj, String key) {
|
||||
ArrayNode a = getArray(obj, key);
|
||||
if (a == null) {
|
||||
@ -212,21 +107,6 @@ public class JSONUtilities {
|
||||
return r;
|
||||
}
|
||||
|
||||
static public String[] getStringArray(JSONObject obj, String key) {
|
||||
try {
|
||||
JSONArray a = obj.getJSONArray(key);
|
||||
String[] r = new String[a.length()];
|
||||
|
||||
for (int i = 0; i < r.length; i++) {
|
||||
r[i] = a.getString(i);
|
||||
}
|
||||
|
||||
return r;
|
||||
} catch (JSONException e) {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
static public String[] getStringArray(ObjectNode obj, String key) {
|
||||
ArrayNode a = getArray(obj, key);
|
||||
if (a == null) {
|
||||
@ -241,44 +121,6 @@ public class JSONUtilities {
|
||||
return r;
|
||||
}
|
||||
|
||||
static public void getStringList(JSONObject obj, String key, List<String> list) {
|
||||
try {
|
||||
JSONArray a = obj.getJSONArray(key);
|
||||
int count = a.length();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
list.add(a.getString(i));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
}
|
||||
}
|
||||
|
||||
static public void putField(JSONObject obj, String key, Object value) throws JSONException {
|
||||
if (value instanceof Integer) {
|
||||
obj.put(key, ((Integer) value).intValue());
|
||||
} else if (value instanceof Long) {
|
||||
obj.put(key, ((Long) value).intValue());
|
||||
} else if (value instanceof Number) {
|
||||
obj.put(key, ((Double) value).doubleValue());
|
||||
} else if (value instanceof Boolean) {
|
||||
obj.put(key, value);
|
||||
} else if (value instanceof Calendar) {
|
||||
obj.put(key, ParsingUtilities.dateToString(OffsetDateTime.ofInstant(((Calendar)value).toInstant(), ZoneId.of("Z"))));
|
||||
} else if (value instanceof String) {
|
||||
obj.put(key, value);
|
||||
} else {
|
||||
obj.put(key, value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
static public JSONObject getObjectElement(JSONArray a, int i) {
|
||||
try {
|
||||
return a.getJSONObject(i);
|
||||
} catch (JSONException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static public ObjectNode getObjectElement(ArrayNode a, int i) {
|
||||
JsonNode n = a.get(i);
|
||||
if (n != null && n instanceof ObjectNode) {
|
||||
@ -287,14 +129,6 @@ public class JSONUtilities {
|
||||
return null;
|
||||
}
|
||||
|
||||
static public int getIntElement(JSONArray a, int i, int def) {
|
||||
try {
|
||||
return a.getInt(i);
|
||||
} catch (JSONException e) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
static public int getIntElement(ArrayNode a, int i, int def) {
|
||||
if (a.get(i) != null) {
|
||||
return a.get(i).asInt(def);
|
||||
@ -302,13 +136,6 @@ public class JSONUtilities {
|
||||
return def;
|
||||
}
|
||||
|
||||
static public void append(JSONArray sheetRecords, JSONObject sheetRecord) {
|
||||
try {
|
||||
sheetRecords.put(sheetRecords.length(), sheetRecord);
|
||||
} catch (JSONException e) {
|
||||
}
|
||||
}
|
||||
|
||||
static public void append(ArrayNode sheetRecords, ObjectNode sheetRecord) {
|
||||
sheetRecords.add(sheetRecord);
|
||||
}
|
||||
@ -317,67 +144,12 @@ public class JSONUtilities {
|
||||
array.add(v);
|
||||
}
|
||||
|
||||
static public void append(JSONArray a, Object element) {
|
||||
try {
|
||||
a.put(a.length(), element);
|
||||
} catch (JSONException e) {
|
||||
}
|
||||
}
|
||||
|
||||
static public void append(JSONArray a, int element) {
|
||||
try {
|
||||
a.put(a.length(), element);
|
||||
} catch (JSONException e) {
|
||||
}
|
||||
}
|
||||
|
||||
static public void append(JSONArray a, long element) {
|
||||
try {
|
||||
a.put(a.length(), element);
|
||||
} catch (JSONException e) {
|
||||
}
|
||||
}
|
||||
|
||||
static public void append(JSONArray a, double element) {
|
||||
try {
|
||||
a.put(a.length(), element);
|
||||
} catch (JSONException e) {
|
||||
}
|
||||
}
|
||||
|
||||
static public void append(JSONArray a, boolean element) {
|
||||
try {
|
||||
a.put(a.length(), element);
|
||||
} catch (JSONException e) {
|
||||
}
|
||||
}
|
||||
|
||||
static public void append(JSONArray a, String element) {
|
||||
try {
|
||||
a.put(a.length(), element);
|
||||
} catch (JSONException e) {
|
||||
}
|
||||
}
|
||||
|
||||
static public void append(ArrayNode a, String element) {
|
||||
a.add(element);
|
||||
}
|
||||
|
||||
static public void safePut(ObjectNode options, String key, JsonNode rootElement) {
|
||||
try {
|
||||
options.put(key, rootElement);
|
||||
} catch (JSONException e) {
|
||||
// Ignore: the JSONObject is just too happy about throwing exceptions.
|
||||
}
|
||||
}
|
||||
|
||||
static public void safeInc(JSONObject obj, String key) {
|
||||
try {
|
||||
int currentValue = obj.getInt(key);
|
||||
safePut(obj, key, currentValue + 1);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static public void safeInc(ObjectNode obj, String key) {
|
||||
@ -389,96 +161,18 @@ public class JSONUtilities {
|
||||
obj.put(key, value);
|
||||
}
|
||||
|
||||
static public void safePut(JSONObject obj, String key, long value) {
|
||||
try {
|
||||
obj.put(key, value);
|
||||
} catch (JSONException e) {
|
||||
// Ignore: the JSONObject is just too happy about throwing exceptions.
|
||||
}
|
||||
}
|
||||
|
||||
static public void safePut(ObjectNode obj, String key, double value) {
|
||||
obj.put(key, value);
|
||||
}
|
||||
|
||||
static public void safePut(JSONObject obj, String key, double value) {
|
||||
try {
|
||||
obj.put(key, value);
|
||||
} catch (JSONException e) {
|
||||
// Ignore: the JSONObject is just too happy about throwing exceptions.
|
||||
}
|
||||
}
|
||||
|
||||
static public void safePut(ObjectNode obj, String key, boolean value) {
|
||||
obj.put(key, value);
|
||||
}
|
||||
|
||||
static public void safePut(JSONObject obj, String key, boolean value) {
|
||||
try {
|
||||
obj.put(key, value);
|
||||
} catch (JSONException e) {
|
||||
// Ignore: the JSONObject is just too happy about throwing exceptions.
|
||||
}
|
||||
}
|
||||
|
||||
static public void safePut(ObjectNode obj, String key, String value) {
|
||||
obj.put(key, value);
|
||||
}
|
||||
|
||||
static public void safePut(JSONObject obj, String key, String value) {
|
||||
try {
|
||||
obj.put(key, value);
|
||||
} catch (JSONException e) {
|
||||
// Ignore: the JSONObject is just too happy about throwing exceptions.
|
||||
}
|
||||
}
|
||||
|
||||
static public void safePut(JSONObject obj, String key, Object value) {
|
||||
try {
|
||||
obj.put(key, value);
|
||||
} catch (JSONException e) {
|
||||
// Ignore: the JSONObject is just too happy about throwing exceptions.
|
||||
}
|
||||
}
|
||||
|
||||
static public Object[] toArray(JSONArray a) throws JSONException {
|
||||
int l = a.length();
|
||||
|
||||
Object[] a2 = new Object[l];
|
||||
for (int i = 0; i < l; i++) {
|
||||
a2[i] = a.get(i);
|
||||
}
|
||||
|
||||
return a2;
|
||||
}
|
||||
|
||||
static public List<String> toStringList(JSONArray a) throws JSONException {
|
||||
int l = a.length();
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (int i = 0; i < l; i++) {
|
||||
list.add(a.getString(i));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static public void concatArray(JSONArray destArray, JSONArray srcArray)
|
||||
throws JSONException {
|
||||
for (int i = 0; i < srcArray.length(); i++) {
|
||||
destArray.put(srcArray.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
// temporary method used during migratino
|
||||
static public ObjectNode jsonObjectToObjectNode(JSONObject obj) {
|
||||
return ParsingUtilities.evaluateJsonStringToObjectNode(obj.toString());
|
||||
}
|
||||
|
||||
public static JSONObject objectNodeToJsonNode(ObjectNode fieldJsonObj) {
|
||||
return new JSONObject(fieldJsonObj.toString());
|
||||
}
|
||||
|
||||
public static Object[] toArray(ArrayNode v) {
|
||||
if (v == null) {
|
||||
return null;
|
||||
|
@ -54,10 +54,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.codec.DecoderException;
|
||||
import org.apache.commons.codec.net.URLCodec;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONTokener;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonFactory;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
@ -158,29 +154,6 @@ public class ParsingUtilities {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
static public JSONObject evaluateJsonStringToObject(String s) throws JSONException {
|
||||
if( s == null ) {
|
||||
throw new IllegalArgumentException("parameter 's' should not be null");
|
||||
}
|
||||
JSONTokener t = new JSONTokener(s);
|
||||
Object o = t.nextValue();
|
||||
if (o instanceof JSONObject) {
|
||||
return (JSONObject) o;
|
||||
} else {
|
||||
throw new JSONException(s + " couldn't be parsed as JSON object");
|
||||
}
|
||||
}
|
||||
|
||||
static public JSONArray evaluateJsonStringToArray(String s) throws JSONException {
|
||||
JSONTokener t = new JSONTokener(s);
|
||||
Object o = t.nextValue();
|
||||
if (o instanceof JSONArray) {
|
||||
return (JSONArray) o;
|
||||
} else {
|
||||
throw new JSONException(s + " couldn't be parsed as JSON array");
|
||||
}
|
||||
}
|
||||
|
||||
private static final URLCodec codec = new URLCodec();
|
||||
/**
|
||||
* Encode a string as UTF-8.
|
||||
|
@ -45,9 +45,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
@ -72,7 +69,6 @@ import com.google.refine.model.ModelException;
|
||||
import com.google.refine.model.Project;
|
||||
import com.google.refine.model.Row;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
import com.google.refine.util.JSONUtilities;
|
||||
|
||||
import edu.mit.simile.butterfly.ButterflyModule;
|
||||
|
||||
@ -281,65 +277,32 @@ public class RefineTest {
|
||||
|
||||
//----helpers----
|
||||
|
||||
static public void whenGetBooleanOption(String name, JSONObject options, Boolean def){
|
||||
when(options.has(name)).thenReturn(true);
|
||||
when(JSONUtilities.getBoolean(options, name, def)).thenReturn(def);
|
||||
}
|
||||
|
||||
static public void whenGetBooleanOption(String name, ObjectNode options, Boolean def){
|
||||
when(options.has(name)).thenReturn(true);
|
||||
when(options.get(name)).thenReturn(def ? BooleanNode.TRUE : BooleanNode.FALSE);
|
||||
}
|
||||
|
||||
static public void whenGetIntegerOption(String name, JSONObject options, int def){
|
||||
when(options.has(name)).thenReturn(true);
|
||||
when(JSONUtilities.getInt(options, name, def)).thenReturn(def);
|
||||
}
|
||||
|
||||
static public void whenGetIntegerOption(String name, ObjectNode options, int def){
|
||||
when(options.has(name)).thenReturn(true);
|
||||
when(options.get(name)).thenReturn(new IntNode(def));
|
||||
}
|
||||
|
||||
static public void whenGetStringOption(String name, JSONObject options, String def){
|
||||
when(options.has(name)).thenReturn(true);
|
||||
when(JSONUtilities.getString(options, name, def)).thenReturn(def);
|
||||
}
|
||||
|
||||
static public void whenGetStringOption(String name, ObjectNode options, String def){
|
||||
when(options.has(name)).thenReturn(true);
|
||||
when(options.get(name)).thenReturn(new TextNode(def));
|
||||
}
|
||||
|
||||
static public void whenGetObjectOption(String name, JSONObject options, JSONObject def){
|
||||
when(options.has(name)).thenReturn(true);
|
||||
when(JSONUtilities.getObject(options, name)).thenReturn(def);
|
||||
}
|
||||
|
||||
static public void whenGetObjectOption(String name, ObjectNode options, ObjectNode def){
|
||||
when(options.has(name)).thenReturn(true);
|
||||
when(options.get(name)).thenReturn(def);
|
||||
}
|
||||
|
||||
static public void whenGetArrayOption(String name, JSONObject options, JSONArray def){
|
||||
when(options.has(name)).thenReturn(true);
|
||||
when(JSONUtilities.getArray(options, name)).thenReturn(def);
|
||||
}
|
||||
|
||||
static public void whenGetArrayOption(String name, ObjectNode options, ArrayNode def){
|
||||
when(options.has(name)).thenReturn(true);
|
||||
when(options.get(name)).thenReturn(def);
|
||||
}
|
||||
|
||||
static public void verifyGetOption(String name, JSONObject options){
|
||||
verify(options, times(1)).has(name);
|
||||
try {
|
||||
verify(options, times(1)).get(name);
|
||||
} catch (JSONException e) {
|
||||
Assert.fail("JSONException",e);
|
||||
}
|
||||
}
|
||||
|
||||
// Works for both int, String, and JSON arrays
|
||||
static public void verifyGetArrayOption(String name, ObjectNode options){
|
||||
verify(options, times(1)).has(name);
|
||||
|
@ -35,7 +35,6 @@ package com.google.refine.tests.browsing.facets;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -82,7 +81,7 @@ public class TextSearchFacetTests extends RefineTest {
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
public void setUp() throws JSONException, IOException, ModelException {
|
||||
public void setUp() throws IOException, ModelException {
|
||||
project = createCSVProject("TextSearchFacet",
|
||||
"Value\n"
|
||||
+ "a\n"
|
||||
|
@ -35,7 +35,6 @@ import java.time.OffsetDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
@ -79,7 +78,7 @@ public class ExpressionNominalValueGrouperTests extends RefineTest {
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
public void setUp() throws JSONException, IOException, ModelException {
|
||||
public void setUp() throws IOException, ModelException {
|
||||
project = createProjectWithColumns(projectName, columnName);
|
||||
bindings = new Properties();
|
||||
bindings.put("project", project);
|
||||
|
@ -41,8 +41,6 @@ import static org.mockito.Mockito.when;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
@ -131,8 +129,6 @@ public class CommandTests extends RefineTest {
|
||||
when(request.getParameter("engine")).thenReturn(null);
|
||||
try {
|
||||
Assert.assertNull(SUT.wrapGetEngineConfig(request));
|
||||
} catch (JSONException e) {
|
||||
Assert.fail();
|
||||
} catch (Exception e) {
|
||||
Assert.fail();
|
||||
}
|
||||
@ -142,11 +138,7 @@ public class CommandTests extends RefineTest {
|
||||
public void getEngineConfigReturnsNullWithEmptyOrBadParameterValue() {
|
||||
when(request.getParameter("engine")).thenReturn("sdfasdfas");
|
||||
|
||||
try {
|
||||
Assert.assertNull( SUT.wrapGetEngineConfig(request) );
|
||||
} catch (JSONException e) {
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
verify(request, times(1)).getParameter("engine");
|
||||
}
|
||||
@ -158,8 +150,6 @@ public class CommandTests extends RefineTest {
|
||||
try {
|
||||
o = SUT.wrapGetEngineConfig(request);
|
||||
Assert.assertEquals(Mode.RowBased, o.getMode());
|
||||
} catch (JSONException e) {
|
||||
Assert.fail();
|
||||
} catch (Exception e) {
|
||||
Assert.fail();
|
||||
}
|
||||
|
@ -45,8 +45,6 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
@ -458,27 +456,26 @@ public class SqlExporterTests extends RefineTest {
|
||||
}
|
||||
}
|
||||
|
||||
protected JSONObject createNumericColOptionsFromProject(String tableName, String type, String size) {
|
||||
protected ObjectNode createNumericColOptionsFromProject(String tableName, String type, String size) {
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
JSONArray columns = new JSONArray();
|
||||
json.put("columns", columns);
|
||||
ObjectNode json = ParsingUtilities.mapper.createObjectNode();
|
||||
ArrayNode columns = json.putArray("columns");
|
||||
json.put("tableName", tableName);
|
||||
|
||||
List<Column> cols = project.columnModel.columns;
|
||||
|
||||
cols.forEach(c -> {
|
||||
//logger.info("Column Name = " + c.getName());
|
||||
JSONObject columnModel = new JSONObject();
|
||||
ObjectNode columnModel = ParsingUtilities.mapper.createObjectNode();
|
||||
columnModel.put("name", c.getName());
|
||||
if(type != null) {
|
||||
columnModel.put("type", type);
|
||||
}else {
|
||||
} else {
|
||||
columnModel.put("type", "VARCHAR");
|
||||
}
|
||||
if(size != null) {
|
||||
columnModel.put("size", size);
|
||||
}else {
|
||||
} else {
|
||||
columnModel.put("size", "100");
|
||||
}
|
||||
|
||||
@ -490,7 +487,7 @@ public class SqlExporterTests extends RefineTest {
|
||||
columnModel.put("size", size);
|
||||
}
|
||||
|
||||
columns.put(columnModel);
|
||||
columns.add(columnModel);
|
||||
|
||||
});
|
||||
|
||||
|
@ -36,7 +36,6 @@ package com.google.refine.tests.expr.functions;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
@ -59,7 +58,6 @@ public class FunctionTests extends RefineTest {
|
||||
|
||||
static Properties bindings;
|
||||
Project project;
|
||||
JSONObject engine_config;
|
||||
Engine engine;
|
||||
|
||||
|
||||
|
@ -53,7 +53,6 @@ import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
@ -131,15 +130,11 @@ public class ExcelImporterTests extends ImporterTest {
|
||||
Assert.assertEquals((String)project.rows.get(1).getCellValue(4)," Row 1 Col 5");
|
||||
Assert.assertNull((String)project.rows.get(1).getCellValue(5));
|
||||
|
||||
try {
|
||||
verify(options, times(1)).get("ignoreLines");
|
||||
verify(options, times(1)).get("headerLines");
|
||||
verify(options, times(1)).get("skipDataLines");
|
||||
verify(options, times(1)).get("limit");
|
||||
verify(options, times(1)).get("storeBlankCellsAsNulls");
|
||||
} catch (JSONException e) {
|
||||
Assert.fail("JSON exception",e);
|
||||
}
|
||||
}
|
||||
|
||||
private static File createSpreadsheet(boolean xml) {
|
||||
|
@ -35,8 +35,6 @@ package com.google.refine.tests.model;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
@ -77,7 +75,7 @@ public class CacheTests extends RefineTest {
|
||||
Properties bindings;
|
||||
|
||||
@BeforeMethod
|
||||
public void SetUp() throws JSONException, IOException, ModelException {
|
||||
public void SetUp() throws IOException, ModelException {
|
||||
project = createProjectWithColumns("CacheTests", "Column A");
|
||||
|
||||
engine = new Engine(project);
|
||||
|
@ -4,8 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -51,7 +49,7 @@ public class BlankDownTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeBlankDownOperation() throws JSONException, Exception {
|
||||
public void serializeBlankDownOperation() throws Exception {
|
||||
String json = "{\"op\":\"core/blank-down\","
|
||||
+ "\"description\":\"Blank down cells in column my column\","
|
||||
+ "\"engineConfig\":{\"mode\":\"record-based\",\"facets\":[]},"
|
||||
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -49,7 +48,7 @@ public class FillDownTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeFillDownOperation() throws JSONException, Exception {
|
||||
public void serializeFillDownOperation() throws Exception {
|
||||
String json = "{\"op\":\"core/fill-down\","
|
||||
+ "\"description\":\"Fill down cells in column my key\","
|
||||
+ "\"engineConfig\":{\"mode\":\"record-based\",\"facets\":[]},"
|
||||
|
@ -35,7 +35,6 @@ package com.google.refine.tests.operations.cell;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -79,7 +78,7 @@ public class JoinMultiValuedCellsTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeMultiValuedCellJoinOperation() throws JSONException, Exception {
|
||||
public void serializeMultiValuedCellJoinOperation() throws Exception {
|
||||
String json = "{\"op\":\"core/multivalued-cell-join\","
|
||||
+ "\"description\":\"Join multi-valued cells in column value column\","
|
||||
+ "\"columnName\":\"value column\","
|
||||
|
@ -42,7 +42,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
@ -87,7 +86,7 @@ public class KeyValueColumnizeTests extends RefineTest {
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
public void SetUp() throws JSONException, IOException, ModelException {
|
||||
public void SetUp() throws IOException, ModelException {
|
||||
servlet = new RefineServletStub();
|
||||
File dir = TestUtils.createTempDirectory("openrefine-test-workspace-dir");
|
||||
FileProjectManager.initialize(dir);
|
||||
@ -114,7 +113,7 @@ public class KeyValueColumnizeTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeKeyValueColumnizeOperation() throws JSONException, Exception {
|
||||
public void serializeKeyValueColumnizeOperation() throws Exception {
|
||||
String json = "{\"op\":\"core/key-value-columnize\","
|
||||
+ "\"description\":\"Columnize by key column key column and value column value column\","
|
||||
+ "\"keyColumnName\":\"key column\","
|
||||
|
@ -2,7 +2,6 @@ package com.google.refine.tests.operations.cell;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.Test;
|
||||
@ -26,7 +25,7 @@ public class MassOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeMassEditOperation() throws JSONException, Exception {
|
||||
public void serializeMassEditOperation() throws Exception {
|
||||
String json = "{\"op\":\"core/mass-edit\","
|
||||
+ "\"description\":\"Mass edit cells in column my column\","
|
||||
+ "\"engineConfig\":{\"mode\":\"record-based\",\"facets\":[]},"
|
||||
@ -39,7 +38,7 @@ public class MassOperationTests extends RefineTest {
|
||||
public void testReconstructEditString() throws Exception {
|
||||
editsString = "[{\"from\":[\"String\"],\"to\":\"newString\",\"type\":\"text\"}]";
|
||||
|
||||
editList = ParsingUtilities.mapper.readValue(ParsingUtilities.evaluateJsonStringToArray(editsString).toString(), new TypeReference<List<Edit>>() {});
|
||||
editList = ParsingUtilities.mapper.readValue(editsString, new TypeReference<List<Edit>>() {});
|
||||
|
||||
Assert.assertEquals(editList.get(0).from.size(), 1);
|
||||
Assert.assertEquals(editList.get(0).from.get(0), "String");
|
||||
@ -52,7 +51,7 @@ public class MassOperationTests extends RefineTest {
|
||||
public void testReconstructEditMultiString() throws Exception {
|
||||
editsString = "[{\"from\":[\"String1\",\"String2\"],\"to\":\"newString\",\"type\":\"text\"}]";
|
||||
|
||||
editList = ParsingUtilities.mapper.readValue(ParsingUtilities.evaluateJsonStringToArray(editsString).toString(), new TypeReference<List<Edit>>() {});
|
||||
editList = ParsingUtilities.mapper.readValue(editsString, new TypeReference<List<Edit>>() {});
|
||||
|
||||
Assert.assertEquals(editList.get(0).from.size(), 2);
|
||||
Assert.assertEquals(editList.get(0).from.get(0), "String1");
|
||||
@ -66,7 +65,7 @@ public class MassOperationTests extends RefineTest {
|
||||
public void testReconstructEditBoolean() throws Exception {
|
||||
editsString = "[{\"from\":[true],\"to\":\"newString\",\"type\":\"text\"}]";
|
||||
|
||||
editList = ParsingUtilities.mapper.readValue(ParsingUtilities.evaluateJsonStringToArray(editsString).toString(), new TypeReference<List<Edit>>() {});
|
||||
editList = ParsingUtilities.mapper.readValue(editsString, new TypeReference<List<Edit>>() {});
|
||||
|
||||
Assert.assertEquals(editList.get(0).from.size(), 1);
|
||||
Assert.assertEquals(editList.get(0).from.get(0), "true");
|
||||
@ -79,7 +78,7 @@ public class MassOperationTests extends RefineTest {
|
||||
public void testReconstructEditNumber() throws Exception {
|
||||
editsString = "[{\"from\":[1],\"to\":\"newString\",\"type\":\"text\"}]";
|
||||
|
||||
editList = ParsingUtilities.mapper.readValue(ParsingUtilities.evaluateJsonStringToArray(editsString).toString(), new TypeReference<List<Edit>>() {});
|
||||
editList = ParsingUtilities.mapper.readValue(editsString, new TypeReference<List<Edit>>() {});
|
||||
|
||||
Assert.assertEquals(editList.get(0).from.size(), 1);
|
||||
Assert.assertEquals(editList.get(0).from.get(0), "1");
|
||||
|
@ -36,7 +36,6 @@ package com.google.refine.tests.operations.cell;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -72,7 +71,7 @@ public class SplitMultiValuedCellsTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeMultiValuedCellSplitOperationWithSeparator() throws JSONException, Exception {
|
||||
public void serializeMultiValuedCellSplitOperationWithSeparator() throws Exception {
|
||||
String json = "{\"op\":\"core/multivalued-cell-split\","
|
||||
+ "\"description\":\"Split multi-valued cells in column Value\","
|
||||
+ "\"columnName\":\"Value\","
|
||||
@ -84,7 +83,7 @@ public class SplitMultiValuedCellsTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeMultiValuedCellSplitOperationWithLengths() throws JSONException, Exception {
|
||||
public void serializeMultiValuedCellSplitOperationWithLengths() throws Exception {
|
||||
String json = "{\"op\":\"core/multivalued-cell-split\","
|
||||
+ "\"description\":\"Split multi-valued cells in column Value\","
|
||||
+ "\"columnName\":\"Value\","
|
||||
|
@ -33,7 +33,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
package com.google.refine.tests.operations.cell;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
@ -54,7 +53,7 @@ public class TransposeTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransposeRowsIntoColumnsOperation() throws JSONException, Exception {
|
||||
public void testTransposeRowsIntoColumnsOperation() throws Exception {
|
||||
String json = "{\"op\":\"core/transpose-rows-into-columns\","
|
||||
+ "\"description\":\"Transpose every 3 cells in column start column into separate columns\","
|
||||
+ "\"columnName\":\"start column\","
|
||||
|
@ -39,14 +39,13 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.google.refine.browsing.EngineConfig;
|
||||
import com.google.refine.expr.ExpressionUtils;
|
||||
import com.google.refine.model.AbstractOperation;
|
||||
@ -108,7 +107,7 @@ public class ColumnAdditionByFetchingURLsOperationTests extends RefineTest {
|
||||
private EngineConfig engine_config = EngineConfig.reconstruct(ENGINE_JSON_URLS);
|
||||
|
||||
@BeforeMethod
|
||||
public void SetUp() throws JSONException, IOException, ModelException {
|
||||
public void SetUp() throws IOException, ModelException {
|
||||
project = createProjectWithColumns("UrlFetchingTests", "fruits");
|
||||
}
|
||||
|
||||
@ -125,7 +124,7 @@ public class ColumnAdditionByFetchingURLsOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeColumnAdditionByFetchingURLsOperation() throws JSONException, Exception {
|
||||
public void serializeColumnAdditionByFetchingURLsOperation() throws Exception {
|
||||
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ColumnAdditionByFetchingURLsOperation.class), json);
|
||||
}
|
||||
|
||||
@ -280,21 +279,21 @@ public class ColumnAdditionByFetchingURLsOperationTests extends RefineTest {
|
||||
Assert.assertFalse(process.isRunning());
|
||||
|
||||
int newCol = project.columnModel.getColumnByName("junk").getCellIndex();
|
||||
JSONObject headersUsed = null;
|
||||
ObjectNode headersUsed = null;
|
||||
|
||||
// sometime, we got response:
|
||||
// Error
|
||||
// Over Quota
|
||||
// This application is temporarily over its serving quota. Please try again later.
|
||||
try {
|
||||
headersUsed = new JSONObject(project.rows.get(0).getCellValue(newCol).toString());
|
||||
} catch (JSONException ex) {
|
||||
headersUsed = ParsingUtilities.mapper.readValue(project.rows.get(0).getCellValue(newCol).toString(), ObjectNode.class);
|
||||
} catch (IOException ex) {
|
||||
return;
|
||||
}
|
||||
// Inspect the results we got from remote service
|
||||
Assert.assertEquals(headersUsed.getString("User-Agent"), userAgentValue);
|
||||
Assert.assertEquals(headersUsed.getString("Authorization"), authorizationValue);
|
||||
Assert.assertEquals(headersUsed.getString("Accept"), acceptValue);
|
||||
Assert.assertEquals(headersUsed.get("User-Agent").asText(), userAgentValue);
|
||||
Assert.assertEquals(headersUsed.get("Authorization").asText(), authorizationValue);
|
||||
Assert.assertEquals(headersUsed.get("Accept").asText(), acceptValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.google.refine.tests.operations.column;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -18,7 +17,7 @@ public class ColumnAdditionOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeColumnAdditionOperation() throws JSONException, Exception {
|
||||
public void serializeColumnAdditionOperation() throws Exception {
|
||||
String json = "{"
|
||||
+ " \"op\":\"core/column-addition\","
|
||||
+ " \"description\":\"Create column organization_json at index 3 based on column employments using expression grel:value.parseJson()[\\\"employment-summary\\\"].join('###')\",\"engineConfig\":{\"mode\":\"row-based\",\"facets\":[]},\"newColumnName\":\"organization_json\",\"columnInsertIndex\":3,\"baseColumnName\":\"employments\","
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.google.refine.tests.operations.column;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -18,7 +17,7 @@ public class ColumnMoveOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeColumnMoveOperation() throws JSONException, Exception {
|
||||
public void serializeColumnMoveOperation() throws Exception {
|
||||
String json = "{\"op\":\"core/column-move\","
|
||||
+ "\"description\":\"Move column my column to position 3\","
|
||||
+ "\"columnName\":\"my column\","
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.google.refine.tests.operations.column;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -19,7 +18,7 @@ public class ColumnRemovalOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeColumnRemovalOperation() throws JSONException, Exception {
|
||||
public void serializeColumnRemovalOperation() throws Exception {
|
||||
String json = "{\"op\":\"core/column-removal\","
|
||||
+ "\"description\":\"Remove column my column\","
|
||||
+ "\"columnName\":\"my column\"}";
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.google.refine.tests.operations.column;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -17,7 +16,7 @@ public class ColumnSplitOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeColumnSplitOperationBySeparator() throws JSONException, Exception {
|
||||
public void serializeColumnSplitOperationBySeparator() throws Exception {
|
||||
String json = "{\n" +
|
||||
" \"op\": \"core/column-split\",\n" +
|
||||
" \"description\": \"Split column ea by separator\",\n" +
|
||||
@ -37,7 +36,7 @@ public class ColumnSplitOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeColumnSplitOperationByLengths() throws JSONException, Exception {
|
||||
public void serializeColumnSplitOperationByLengths() throws Exception {
|
||||
String json = "{\n" +
|
||||
" \"op\": \"core/column-split\",\n" +
|
||||
" \"description\": \"Split column ea by field lengths\",\n" +
|
||||
|
@ -43,8 +43,6 @@ import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
@ -116,7 +114,7 @@ public class ExtendDataOperationTests extends RefineTest {
|
||||
" }";
|
||||
|
||||
static public class ReconciledDataExtensionJobStub extends ReconciledDataExtensionJob {
|
||||
public ReconciledDataExtensionJobStub(DataExtensionConfig obj, String endpoint) throws JSONException {
|
||||
public ReconciledDataExtensionJobStub(DataExtensionConfig obj, String endpoint) {
|
||||
super(obj, endpoint);
|
||||
}
|
||||
|
||||
@ -140,7 +138,7 @@ public class ExtendDataOperationTests extends RefineTest {
|
||||
Engine engine;
|
||||
|
||||
@BeforeMethod
|
||||
public void SetUp() throws JSONException, IOException, ModelException {
|
||||
public void SetUp() throws IOException, ModelException {
|
||||
OperationRegistry.registerOperation(getCoreModule(), "extend-reconciled-data", ExtendDataOperation.class);
|
||||
project = createProjectWithColumns("DataExtensionTests", "country");
|
||||
|
||||
@ -165,19 +163,19 @@ public class ExtendDataOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeExtendDataOperation() throws JSONException, Exception {
|
||||
public void serializeExtendDataOperation() throws Exception {
|
||||
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(operationJson, ExtendDataOperation.class), operationJson);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeExtendDataProcess() throws JSONException, Exception {
|
||||
public void serializeExtendDataProcess() throws Exception {
|
||||
Process p = ParsingUtilities.mapper.readValue(operationJson, ExtendDataOperation.class)
|
||||
.createProcess(project, new Properties());
|
||||
TestUtils.isSerializedTo(p, String.format(processJson, p.hashCode()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeDataExtensionConfig() {
|
||||
public void serializeDataExtensionConfig() throws IOException {
|
||||
TestUtils.isSerializedTo(DataExtensionConfig.reconstruct(dataExtensionConfigJson), dataExtensionConfigJson);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -73,12 +72,12 @@ public class ReconOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeReconOperation() throws JSONException, Exception {
|
||||
public void serializeReconOperation() throws Exception {
|
||||
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconOperation.class), json);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeReconProcess() throws JSONException, Exception {
|
||||
public void serializeReconProcess() throws Exception {
|
||||
ReconOperation op = ParsingUtilities.mapper.readValue(json, ReconOperation.class);
|
||||
com.google.refine.process.Process process = op.createProcess(project, new Properties());
|
||||
TestUtils.isSerializedTo(process, String.format(processJson, process.hashCode()));
|
||||
|
@ -5,7 +5,6 @@ import static org.testng.Assert.assertNull;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -35,12 +34,12 @@ public class ReconUseValuesAsIdsOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeReconUseValuesAsIdentifiersOperation() throws JSONException, Exception {
|
||||
public void serializeReconUseValuesAsIdentifiersOperation() throws Exception {
|
||||
TestUtils.isSerializedTo(ParsingUtilities.mapper.readValue(json, ReconUseValuesAsIdentifiersOperation.class), json);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUseValuesAsIds() throws JSONException, Exception {
|
||||
public void testUseValuesAsIds() throws Exception {
|
||||
Project project = createCSVProject("ids,v\n"
|
||||
+ "Q343,hello\n"
|
||||
+ ",world\n"
|
||||
|
@ -1,12 +1,8 @@
|
||||
package com.google.refine.tests.operations.row;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.model.Project;
|
||||
import com.google.refine.operations.OperationRegistry;
|
||||
import com.google.refine.operations.row.DenormalizeOperation;
|
||||
import com.google.refine.tests.RefineTest;
|
||||
@ -20,8 +16,7 @@ public class DenormalizeOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeDenormalizeOperation() throws JSONException, Exception {
|
||||
Project project = mock(Project.class);
|
||||
public void serializeDenormalizeOperation() throws Exception {
|
||||
String json = "{"
|
||||
+ "\"op\":\"core/denormalize\","
|
||||
+ "\"description\":\"Denormalize\"}";
|
||||
|
@ -1,12 +1,8 @@
|
||||
package com.google.refine.tests.operations.row;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.model.Project;
|
||||
import com.google.refine.operations.OperationRegistry;
|
||||
import com.google.refine.operations.row.RowFlagOperation;
|
||||
import com.google.refine.tests.RefineTest;
|
||||
@ -20,8 +16,7 @@ public class RowFlagOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeRowFlagOperation() throws JSONException, Exception {
|
||||
Project project = mock(Project.class);
|
||||
public void serializeRowFlagOperation() throws Exception {
|
||||
String json = "{"
|
||||
+ "\"op\":\"core/row-flag\","
|
||||
+ "\"description\":\"Flag rows\","
|
||||
|
@ -1,14 +1,10 @@
|
||||
package com.google.refine.tests.operations.row;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.model.Project;
|
||||
import com.google.refine.operations.OperationRegistry;
|
||||
import com.google.refine.operations.row.RowRemovalOperation;
|
||||
import com.google.refine.tests.RefineTest;
|
||||
@ -22,8 +18,7 @@ public class RowRemovalOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeRowRemovalOperation() throws JSONException, IOException {
|
||||
Project project = mock(Project.class);
|
||||
public void serializeRowRemovalOperation() throws IOException {
|
||||
String json = "{"
|
||||
+ "\"op\":\"core/row-removal\","
|
||||
+ "\"description\":\"Remove rows\","
|
||||
|
@ -2,7 +2,6 @@ package com.google.refine.tests.operations.row;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
@ -65,7 +64,7 @@ public class RowReorderOperationTests extends RefineTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void serializeRowReorderOperation() throws JSONException, Exception {
|
||||
public void serializeRowReorderOperation() throws Exception {
|
||||
String json = " {\n" +
|
||||
" \"op\": \"core/row-reorder\",\n" +
|
||||
" \"description\": \"Reorder rows\",\n" +
|
||||
|
@ -1,12 +1,8 @@
|
||||
package com.google.refine.tests.operations.row;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.model.Project;
|
||||
import com.google.refine.operations.OperationRegistry;
|
||||
import com.google.refine.operations.row.RowStarOperation;
|
||||
import com.google.refine.tests.RefineTest;
|
||||
@ -20,8 +16,7 @@ public class RowStarOperationTests extends RefineTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serializeRowStarOperation() throws JSONException, Exception {
|
||||
Project project = mock(Project.class);
|
||||
public void serializeRowStarOperation() throws Exception {
|
||||
String json = "{"
|
||||
+ "\"op\":\"core/row-star\","
|
||||
+ "\"description\":\"Star rows\","
|
||||
|
@ -2,7 +2,6 @@ package com.google.refine.tests.sorting;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.sorting.Criterion;
|
||||
@ -11,7 +10,7 @@ import com.google.refine.util.ParsingUtilities;
|
||||
|
||||
public class BooleanCriterionTest {
|
||||
@Test
|
||||
public void serializeBooleanCriterion() throws JSONException, IOException {
|
||||
public void serializeBooleanCriterion() throws IOException {
|
||||
String json =
|
||||
" {\n" +
|
||||
" \"errorPosition\": 1,\n" +
|
||||
|
@ -39,8 +39,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.text.StrSubstitutor;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
@ -57,40 +55,6 @@ public class ParsingUtilitiesTests extends RefineTest {
|
||||
logger = LoggerFactory.getLogger(this.getClass());
|
||||
}
|
||||
|
||||
//--------------evaluateJsonStringToObject tests-----------------------
|
||||
|
||||
@Test
|
||||
public void evaluateJsonStringToObjectRegressionTest(){
|
||||
try {
|
||||
JSONObject o = ParsingUtilities.evaluateJsonStringToObject("{\"foo\":\"bar\"}");
|
||||
Assert.assertNotNull(o);
|
||||
Assert.assertEquals("bar", o.getString("foo"));
|
||||
} catch (JSONException e) {
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void evaluateJsonStringToObjectWithNullParameters(){
|
||||
try {
|
||||
Assert.assertNull(ParsingUtilities.evaluateJsonStringToObject(null));
|
||||
Assert.fail();
|
||||
} catch (IllegalArgumentException e){
|
||||
//expected
|
||||
} catch (JSONException e) {
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void evaluateJsonStringToObjectWithMalformedParameters(){
|
||||
try {
|
||||
ParsingUtilities.evaluateJsonStringToObject("malformed");
|
||||
Assert.fail();
|
||||
} catch (JSONException e) {
|
||||
//expected
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void zonedDateTimeTest() {
|
||||
String d = "2017-12-01T14:53:36Z";
|
||||
|
Loading…
Reference in New Issue
Block a user