Add serialization tests for GREL controls
This commit is contained in:
parent
326fda7999
commit
802ad77ec5
@ -0,0 +1,15 @@
|
||||
package com.google.refine.tests.grel.controls;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.grel.controls.Filter;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
|
||||
public class FilterTests {
|
||||
@Test
|
||||
public void serializeFilter() {
|
||||
String json = "{\"description\":\"Evaluates expression a to an array. Then for each array element, binds its value to variable name v, evaluates expression test which should return a boolean. If the boolean is true, pushes v onto the result array.\",\"params\":\"expression a, variable v, expression test\",\"returns\":\"array\"}";
|
||||
TestUtils.isSerializedTo(new Filter(), json);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.google.refine.tests.grel.controls;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.grel.controls.ForEachIndex;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
|
||||
public class ForEachIndexTests {
|
||||
@Test
|
||||
public void serializeForEachIndex() {
|
||||
String json = "{\"description\":\"Evaluates expression a to an array. Then for each array element, binds its index to variable i and its value to variable name v, evaluates expression e, and pushes the result onto the result array.\",\"params\":\"expression a, variable i, variable v, expression e\",\"returns\":\"array\"}";
|
||||
TestUtils.isSerializedTo(new ForEachIndex(), json);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.google.refine.tests.grel.controls;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.grel.controls.ForEach;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
|
||||
public class ForEachTests {
|
||||
@Test
|
||||
public void serializeForEach() {
|
||||
String json = "{\"description\":\"Evaluates expression a to an array. Then for each array element, binds its value to variable name v, evaluates expression e, and pushes the result onto the result array.\",\"params\":\"expression a, variable v, expression e\",\"returns\":\"array\"}";
|
||||
TestUtils.isSerializedTo(new ForEach(), json);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.google.refine.tests.grel.controls;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.grel.controls.ForNonBlank;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
|
||||
public class ForNonBlankTests {
|
||||
@Test
|
||||
public void serializeForNonBlank() {
|
||||
String json = "{\"description\":\"Evaluates expression o. If it is non-blank, binds its value to variable name v, evaluates expression eNonBlank and returns the result. Otherwise (if o evaluates to blank), evaluates expression eBlank and returns that result instead.\",\"params\":\"expression o, variable v, expression eNonBlank, expression eBlank\",\"returns\":\"Depends on actual arguments\"}";
|
||||
TestUtils.isSerializedTo(new ForNonBlank(), json);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.google.refine.tests.grel.controls;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.grel.controls.ForRange;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
|
||||
public class ForRangeTests {
|
||||
@Test
|
||||
public void serializeForRange() {
|
||||
String json = "{\"description\":\"Iterates over the variable v starting at \\\"from\\\", incrementing by \\\"step\\\" each time while less than \\\"to\\\". At each iteration, evaluates expression e, and pushes the result onto the result array.\",\"params\":\"number from, number to, number step, variable v, expression e\",\"returns\":\"array\"}";
|
||||
TestUtils.isSerializedTo(new ForRange(), json);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.google.refine.tests.grel.controls;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.grel.controls.If;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
|
||||
public class IfTests {
|
||||
@Test
|
||||
public void serializeIf() {
|
||||
String json = "{\"description\":\"Evaluates expression o. If it is true, evaluates expression eTrue and returns the result. Otherwise, evaluates expression eFalse and returns that result instead.\",\"params\":\"expression o, expression eTrue, expression eFalse\",\"returns\":\"Depends on actual arguments\"}";
|
||||
TestUtils.isSerializedTo(new If(), json);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.google.refine.tests.grel.controls;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.grel.controls.IsBlank;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
|
||||
public class IsBlankTests {
|
||||
@Test
|
||||
public void serializeIsBlank() {
|
||||
String json = "{\"description\":\"Returns whether o is null or an empty string\",\"params\":\"expression o\",\"returns\":\"boolean\"}";
|
||||
TestUtils.isSerializedTo(new IsBlank(), json);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.google.refine.tests.grel.controls;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.grel.controls.IsEmptyString;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
|
||||
public class IsEmptyStringTests {
|
||||
@Test
|
||||
public void serializeIsEmptyString() {
|
||||
String json = "{\"description\":\"Returns whether o is an empty string\",\"params\":\"expression o\",\"returns\":\"boolean\"}";
|
||||
TestUtils.isSerializedTo(new IsEmptyString(), json);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.google.refine.tests.grel.controls;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.grel.controls.IsError;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
|
||||
public class IsErrorTests {
|
||||
@Test
|
||||
public void serializeIsError() {
|
||||
String json = "{\"description\":\"Returns whether o is an error\",\"params\":\"expression o\",\"returns\":\"boolean\"}";
|
||||
TestUtils.isSerializedTo(new IsError(), json);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.google.refine.tests.grel.controls;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.grel.controls.IsNonBlank;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
|
||||
public class IsNonBlankTests {
|
||||
@Test
|
||||
public void serializeIsNonBlank() {
|
||||
String json = "{\"description\":\"Returns whether o is not null and not an empty string\",\"params\":\"expression o\",\"returns\":\"boolean\"}";
|
||||
TestUtils.isSerializedTo(new IsNonBlank(), json);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.google.refine.tests.grel.controls;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.grel.controls.IsNotNull;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
|
||||
public class IsNotNullTests {
|
||||
@Test
|
||||
public void serializeIsNotNull() {
|
||||
String json = "{\"description\":\"Returns whether o is not null\",\"params\":\"expression o\",\"returns\":\"boolean\"}";
|
||||
TestUtils.isSerializedTo(new IsNotNull(), json);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.google.refine.tests.grel.controls;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.grel.controls.IsNull;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
|
||||
public class IsNullTests {
|
||||
@Test
|
||||
public void serializeIsNull() {
|
||||
String json = "{\"description\":\"Returns whether o is null\",\"params\":\"expression o\",\"returns\":\"boolean\"}";
|
||||
TestUtils.isSerializedTo(new IsNull(), json);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.google.refine.tests.grel.controls;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.grel.controls.IsNumeric;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
|
||||
public class IsNumericTests {
|
||||
@Test
|
||||
public void serializeIsNumeric() {
|
||||
String json = "{\"description\":\"Returns whether o can represent a number\",\"params\":\"expression o\",\"returns\":\"boolean\"}";
|
||||
TestUtils.isSerializedTo(new IsNumeric(), json);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.google.refine.tests.grel.controls;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.refine.grel.controls.With;
|
||||
import com.google.refine.tests.util.TestUtils;
|
||||
|
||||
public class WithTests {
|
||||
@Test
|
||||
public void serializeWith() {
|
||||
String json = "{\"description\":\"Evaluates expression o and binds its value to variable name v. Then evaluates expression e and returns that result\",\"params\":\"expression o, variable v, expression e\",\"returns\":\"Depends on actual arguments\"}";
|
||||
TestUtils.isSerializedTo(new With(), json);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user