aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/schema/processing/ReferenceFieldTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/test/java/com/yahoo/schema/processing/ReferenceFieldTestCase.java')
-rw-r--r--config-model/src/test/java/com/yahoo/schema/processing/ReferenceFieldTestCase.java79
1 files changed, 36 insertions, 43 deletions
diff --git a/config-model/src/test/java/com/yahoo/schema/processing/ReferenceFieldTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/ReferenceFieldTestCase.java
index 57b4d928a52..5f26e7b2964 100644
--- a/config-model/src/test/java/com/yahoo/schema/processing/ReferenceFieldTestCase.java
+++ b/config-model/src/test/java/com/yahoo/schema/processing/ReferenceFieldTestCase.java
@@ -9,43 +9,35 @@ import com.yahoo.schema.Schema;
import com.yahoo.schema.ApplicationBuilder;
import com.yahoo.schema.document.SDDocumentType;
import com.yahoo.schema.parser.ParseException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author bjorncs
*/
public class ReferenceFieldTestCase {
- @SuppressWarnings("deprecation")
- @Rule
- public final ExpectedException exceptionRule = ExpectedException.none();
-
@Test
- public void reference_fields_are_parsed_from_search_definition() throws ParseException {
+ void reference_fields_are_parsed_from_search_definition() throws ParseException {
ApplicationBuilder builder = new ApplicationBuilder();
String campaignSdContent =
"schema campaign {\n" +
- " document campaign {\n" +
- " }\n" +
- "}";
+ " document campaign {\n" +
+ " }\n" +
+ "}";
String salespersonSdContent =
"schema salesperson {\n" +
- " document salesperson {\n" +
- " }\n" +
- "}";
+ " document salesperson {\n" +
+ " }\n" +
+ "}";
String adSdContent =
"schema ad {\n" +
- " document ad {\n" +
- " field campaign_ref type reference<campaign> { indexing: attribute }\n" +
- " field salesperson_ref type reference<salesperson> { indexing: attribute }\n" +
- " }\n" +
- "}";
+ " document ad {\n" +
+ " field campaign_ref type reference<campaign> { indexing: attribute }\n" +
+ " field salesperson_ref type reference<salesperson> { indexing: attribute }\n" +
+ " }\n" +
+ "}";
builder.addSchema(campaignSdContent);
builder.addSchema(salespersonSdContent);
builder.addSchema(adSdContent);
@@ -56,37 +48,38 @@ public class ReferenceFieldTestCase {
}
@Test
- public void cyclic_document_dependencies_are_detected() throws ParseException {
- var builder = new ApplicationBuilder(new TestProperties());
- String campaignSdContent =
- "schema campaign {\n" +
- " document campaign {\n" +
- " field ad_ref type reference<ad> { indexing: attribute }\n" +
- " }\n" +
- "}";
- String adSdContent =
- "schema ad {\n" +
- " document ad {\n" +
- " field campaign_ref type reference<campaign> { indexing: attribute }\n" +
- " }\n" +
- "}";
- builder.addSchema(campaignSdContent);
- builder.addSchema(adSdContent);
- exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("reference cycle for documents");
- builder.build(true);
+ void cyclic_document_dependencies_are_detected() throws ParseException {
+ Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
+ var builder = new ApplicationBuilder(new TestProperties());
+ String campaignSdContent =
+ "schema campaign {\n" +
+ " document campaign {\n" +
+ " field ad_ref type reference<ad> { indexing: attribute }\n" +
+ " }\n" +
+ "}";
+ String adSdContent =
+ "schema ad {\n" +
+ " document ad {\n" +
+ " field campaign_ref type reference<campaign> { indexing: attribute }\n" +
+ " }\n" +
+ "}";
+ builder.addSchema(campaignSdContent);
+ builder.addSchema(adSdContent);
+ builder.build(true);
+ });
+ assertTrue(exception.getMessage().contains("reference cycle for documents"));
}
private static void assertSearchContainsReferenceField(String expectedFieldname,
String referencedDocType,
SDDocumentType documentType) {
Field field = documentType.getDocumentType().getField(expectedFieldname);
- assertNotNull("Field does not exist in document type: " + expectedFieldname, field);
+ assertNotNull(field, "Field does not exist in document type: " + expectedFieldname);
DataType dataType = field.getDataType();
assertTrue(dataType instanceof NewDocumentReferenceDataType);
NewDocumentReferenceDataType refField = (NewDocumentReferenceDataType) dataType;
assertEquals(referencedDocType, refField.getTargetTypeName());
- assertTrue(! refField.isTemporary());
+ assertFalse(refField.isTemporary());
}
}