Skip to content
Snippets Groups Projects
Commit ebdff6bd authored by Henry Borasch's avatar Henry Borasch
Browse files

continue schema validation if version is missing, adjusted test

parent 7cd58b1b
No related branches found
No related tags found
No related merge requests found
......@@ -108,9 +108,7 @@ public class DefaultValidationService implements ValidationService {
@Override
public ValidationResult validateMetadataSchema(final Metadata metadata) {
if (metadata.getSchema() == null || metadata.getSchema().isEmpty()) {
return ValidationResult.ok();
} else if (!metadata.getSchema().matches(VALID_SCHEMA_URL_EXPRESSION)) {
if (metadata.getSchema() != null && !metadata.getSchema().isEmpty() && !metadata.getSchema().matches(VALID_SCHEMA_URL_EXPRESSION)) {
return ValidationResult.error(new ValidationException("The provided metadata schema is not supported."));
}
......
......@@ -196,9 +196,15 @@ class DefaultValidationServiceTest {
}
@Test
void validateMetadataWithoutSchemaAttribute() {
void validateMetadataWithoutSchemaAttributeButValidSchema() {
assertTrue(this.underTest.validateMetadataSchema(new Metadata()).isValid());
final var contentStructure = new ContentStructure();
contentStructure.setAttachments(Collections.emptyList());
final var metadata = new Metadata();
metadata.setContentStructure(contentStructure);
assertTrue(this.underTest.validateMetadataSchema(metadata).isValid());
}
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment