Skip to content

Commit

Permalink
another fix for test initial objects test
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Jan 18, 2023
1 parent d64a91f commit 8c09c65
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
5 changes: 5 additions & 0 deletions model/model-intest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@
<artifactId>test-ng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

package com.evolveum.midpoint.model.intest;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
Expand Down Expand Up @@ -47,16 +47,13 @@ public void testInitialObjects() throws Exception {
.getResources(INITIAL_OBJECTS_RESOURCE_PATTERN);

for (Resource resource : resources) {
File file = resource.getFile();
if (file.isFile()) {
try {
testInitialObject(validator, errorsSb, file);
} catch (Throwable e) {
String msg = "Error processing file " + file.getName() + ": " + e.getMessage();
logger.error(msg, e);
displayException(msg, e);
throw e;
}
try (InputStream is = resource.getInputStream()) {
testInitialObject(validator, errorsSb, is, resource.getFilename());
} catch (Throwable e) {
String msg = "Error processing file " + resource.getFilename() + ": " + e.getMessage();
logger.error(msg, e);
displayException(msg, e);
throw e;
}
}

Expand All @@ -65,16 +62,16 @@ public void testInitialObjects() throws Exception {
}
}

private <O extends ObjectType> void testInitialObject(ObjectValidator validator, StringBuilder errorsSb, File file) throws SchemaException, IOException {
PrismObject<O> object = prismContext.parseObject(file);
private <O extends ObjectType> void testInitialObject(ObjectValidator validator, StringBuilder errorsSb, InputStream is, String fileName) throws SchemaException, IOException {
PrismObject<O> object = prismContext.parserFor(is).xml().parse();
ValidationResult validationResult = validator.validate(object);
if (validationResult.isEmpty() || isIgnoredWarning(validationResult)) {
display("Checked " + object + ": no warnings");
return;
}
displayDumpable("Validation warnings for " + object, validationResult);
for (ValidationItem valItem : validationResult.getItems()) {
errorsSb.append(file.getName());
errorsSb.append(fileName);
errorsSb.append(" ");
errorsSb.append(object);
errorsSb.append(" ");
Expand Down

0 comments on commit 8c09c65

Please sign in to comment.