Trim down unit tests.
@@ -248,19 +248,13 @@ public class ImportedFieldsTestCase {
}
private static class ChildPosSdBuilder {
- private boolean import_pos;
private boolean import_pos_zcurve_before;
- private boolean import_pos_zcurve_after;
public ChildPosSdBuilder() {
- import_pos = true;
import_pos_zcurve_before = false;
- import_pos_zcurve_after = false;
}
- ChildPosSdBuilder import_pos(boolean v) { import_pos = v; return this; }
ChildPosSdBuilder import_pos_zcurve_before(boolean v) { import_pos_zcurve_before = v; return this; }
- ChildPosSdBuilder import_pos_zcurve_after(boolean v) { import_pos_zcurve_after = v; return this; }
public String build() {
return joinLines("search child {",
@@ -270,15 +264,10 @@ public class ImportedFieldsTestCase {
" }",
" }",
importPosZCurve(import_pos_zcurve_before),
- importPos(import_pos),
- importPosZCurve(import_pos_zcurve_after),
+ " import field parent_ref.pos as my_pos {}",
"}");
}
- private static String importPos(boolean doImport) {
- return doImport ? "import field parent_ref.pos as my_pos {}" : "";
- }
-
private static String importPosZCurve(boolean doImport) {
return doImport ? "import field parent_ref.pos_zcurve as my_pos_zcurve {}" : "";
}
@@ -295,33 +284,11 @@ public class ImportedFieldsTestCase {
checkPosImport(new ParentPosSdBuilder(), new ChildPosSdBuilder());
}
- private void expectPosImportFailure() {
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("For search 'child', import field 'my_pos_zcurve': Field 'pos_zcurve' via reference field 'parent_ref': Field already imported");
- }
-
@Test
public void check_pos_import_after_pos_zcurve_import() throws ParseException {
- expectPosImportFailure();
- checkPosImport(new ParentPosSdBuilder(), new ChildPosSdBuilder().import_pos_zcurve_before(true));
- }
-
- @Test
- public void check_pos_import_before_pos_zcurve_import() throws ParseException {
- expectPosImportFailure();
- checkPosImport(new ParentPosSdBuilder(), new ChildPosSdBuilder().import_pos_zcurve_after(true));
- }
-
- @Test
- public void check_pos_zcurve_import() throws ParseException {
- checkPosImport(new ParentPosSdBuilder(), new ChildPosSdBuilder().import_pos(false).import_pos_zcurve_after(true));
- }
-
- @Test
- public void check_pos_zcurve_import_twice() throws ParseException {
exception.expect(IllegalArgumentException.class);
- exception.expectMessage("For search 'child', import field as 'my_pos_zcurve': Field already imported");
- checkPosImport(new ParentPosSdBuilder(), new ChildPosSdBuilder().import_pos(false).import_pos_zcurve_before(true).import_pos_zcurve_after(true));
+ exception.expectMessage("For search 'child', import field 'my_pos_zcurve': Field 'pos_zcurve' via reference field 'parent_ref': Field already imported");
+ checkPosImport(new ParentPosSdBuilder(), new ChildPosSdBuilder().import_pos_zcurve_before(true));
}
private static void assertSearchNotContainsImportedField(String fieldName, Search search) {
