Add tests for new Cross errors
This commit is contained in:
parent
3e01c15c37
commit
722db56071
@ -12,6 +12,7 @@ import org.testng.annotations.BeforeMethod;
|
|||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.refine.ProjectManager;
|
||||||
import com.google.refine.expr.EvalError;
|
import com.google.refine.expr.EvalError;
|
||||||
import com.google.refine.expr.HasFieldsListImpl;
|
import com.google.refine.expr.HasFieldsListImpl;
|
||||||
import com.google.refine.expr.WrappedRow;
|
import com.google.refine.expr.WrappedRow;
|
||||||
@ -22,6 +23,7 @@ import com.google.refine.model.Project;
|
|||||||
import com.google.refine.model.Row;
|
import com.google.refine.model.Row;
|
||||||
import com.google.refine.model.Cell;
|
import com.google.refine.model.Cell;
|
||||||
import com.google.refine.tests.RefineTest;
|
import com.google.refine.tests.RefineTest;
|
||||||
|
import com.google.refine.util.GetProjectIDException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test cases for cross function.
|
* Test cases for cross function.
|
||||||
@ -39,6 +41,8 @@ public class CrossFunctionTests extends RefineTest {
|
|||||||
// dependencies
|
// dependencies
|
||||||
Project projectGift;
|
Project projectGift;
|
||||||
Project projectAddress;
|
Project projectAddress;
|
||||||
|
Project projectDuplicate1;
|
||||||
|
Project projectDuplicate2;
|
||||||
|
|
||||||
// data from: https://github.com/OpenRefine/OpenRefine/wiki/GREL-Other-Functions
|
// data from: https://github.com/OpenRefine/OpenRefine/wiki/GREL-Other-Functions
|
||||||
@BeforeMethod
|
@BeforeMethod
|
||||||
@ -64,6 +68,11 @@ public class CrossFunctionTests extends RefineTest {
|
|||||||
+ "integer,1600\n"
|
+ "integer,1600\n"
|
||||||
+ "boolean,true\n";
|
+ "boolean,true\n";
|
||||||
projectGift = createCSVProject(projectName, input);
|
projectGift = createCSVProject(projectName, input);
|
||||||
|
projectName = "Duplicate";
|
||||||
|
input = "Col1,Col2";
|
||||||
|
projectDuplicate1 = createCSVProject(projectName, input);
|
||||||
|
projectDuplicate2 = createCSVProject(projectName, input);
|
||||||
|
|
||||||
|
|
||||||
bindings.put("project", projectGift);
|
bindings.put("project", projectGift);
|
||||||
|
|
||||||
@ -79,6 +88,28 @@ public class CrossFunctionTests extends RefineTest {
|
|||||||
bindings.put("columnName", "recipient");
|
bindings.put("columnName", "recipient");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void crossFunctionMissingProject() throws Exception {
|
||||||
|
String nonExistentProject = "NOPROJECT";
|
||||||
|
Assert.assertEquals(((EvalError) invoke("cross", "Anne", nonExistentProject, "friend")).message,
|
||||||
|
"Unable to find project with name: " + nonExistentProject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void crossFunctionMultipleProjects() throws Exception {
|
||||||
|
String duplicateProjectName = "Duplicate";
|
||||||
|
Assert.assertEquals(((EvalError) invoke("cross", "Anne", duplicateProjectName, "friend")).message,
|
||||||
|
"2 projects found with name: " + duplicateProjectName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void crossFunctionMissingColumn() throws Exception {
|
||||||
|
String nonExistentColumn = "NoColumn";
|
||||||
|
String projectName = "My Address Book";
|
||||||
|
Assert.assertEquals(((EvalError) invoke("cross", "mary", projectName, nonExistentColumn)).message,
|
||||||
|
"Unable to find column " + nonExistentColumn + " in project " + projectName);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void crossFunctionOneToOneTest() throws Exception {
|
public void crossFunctionOneToOneTest() throws Exception {
|
||||||
Row row = ((Row)((WrappedRow) ((HasFieldsListImpl) invoke("cross", "mary", "My Address Book", "friend")).get(0)).row);
|
Row row = ((Row)((WrappedRow) ((HasFieldsListImpl) invoke("cross", "mary", "My Address Book", "friend")).get(0)).row);
|
||||||
|
Loading…
Reference in New Issue
Block a user