diff options
author | Erlend <erlendniko@hotmail.com> | 2022-07-29 14:26:26 +0200 |
---|---|---|
committer | Erlend <erlendniko@hotmail.com> | 2022-07-29 14:26:26 +0200 |
commit | 79336a368800c0e2b691b34cbeccd9f93be5db90 (patch) | |
tree | 5336ad08fc202c93b680eb3b9b4a4cd1133376f4 /config-model/src/test/java/com/yahoo/schema/processing/ValidateFieldTypesTest.java | |
parent | 362438cc3eb855854aa6110cf01667f80dd10ba0 (diff) | |
parent | 3afb44d4e4328b2732f65b4a436baa2ce2c850b0 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'config-model/src/test/java/com/yahoo/schema/processing/ValidateFieldTypesTest.java')
-rw-r--r-- | config-model/src/test/java/com/yahoo/schema/processing/ValidateFieldTypesTest.java | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/config-model/src/test/java/com/yahoo/schema/processing/ValidateFieldTypesTest.java b/config-model/src/test/java/com/yahoo/schema/processing/ValidateFieldTypesTest.java index 87bb2e96042..5f0940f0d2d 100644 --- a/config-model/src/test/java/com/yahoo/schema/processing/ValidateFieldTypesTest.java +++ b/config-model/src/test/java/com/yahoo/schema/processing/ValidateFieldTypesTest.java @@ -16,12 +16,13 @@ import com.yahoo.schema.document.SDDocumentType; import com.yahoo.schema.document.SDField; import com.yahoo.vespa.documentmodel.DocumentSummary; import com.yahoo.vespa.documentmodel.SummaryField; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Test; import java.util.Collections; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * @author bjorncs */ @@ -30,22 +31,18 @@ public class ValidateFieldTypesTest { private static final String IMPORTED_FIELD_NAME = "imported_myfield"; private static final String DOCUMENT_NAME = "my_doc"; - @SuppressWarnings("deprecation") - @Rule - public final ExpectedException exceptionRule = ExpectedException.none(); - @Test - public void throws_exception_if_type_of_document_field_does_not_match_summary_field() { - Schema schema = createSearchWithDocument(DOCUMENT_NAME); - schema.setImportedFields(createSingleImportedField(IMPORTED_FIELD_NAME, DataType.INT)); - schema.addSummary(createDocumentSummary(IMPORTED_FIELD_NAME, DataType.STRING, schema)); + void throws_exception_if_type_of_document_field_does_not_match_summary_field() { + Throwable exception = assertThrows(IllegalArgumentException.class, () -> { + Schema schema = createSearchWithDocument(DOCUMENT_NAME); + schema.setImportedFields(createSingleImportedField(IMPORTED_FIELD_NAME, DataType.INT)); + schema.addSummary(createDocumentSummary(IMPORTED_FIELD_NAME, DataType.STRING, schema)); - ValidateFieldTypes validator = new ValidateFieldTypes(schema, null, null, null); - exceptionRule.expect(IllegalArgumentException.class); - exceptionRule.expectMessage( - "For schema '" + DOCUMENT_NAME + "', field '" + IMPORTED_FIELD_NAME + "': Incompatible types. " + - "Expected int for summary field '" + IMPORTED_FIELD_NAME + "', got string."); - validator.process(true, false); + ValidateFieldTypes validator = new ValidateFieldTypes(schema, null, null, null); + validator.process(true, false); + }); + assertTrue(exception.getMessage().contains("For schema '" + DOCUMENT_NAME + "', field '" + IMPORTED_FIELD_NAME + "': Incompatible types. " + + "Expected int for summary field '" + IMPORTED_FIELD_NAME + "', got string.")); } private static Schema createSearch(String documentType) { |