use of org.guvnor.common.services.shared.validation.model.ValidationMessage in project drools-wb by kiegroup.
the class GuidedRuleTemplateEditorServiceImpl method makeValidationMessages.
private ValidationMessage makeValidationMessages(final Path path, final String message) {
final ValidationMessage msg = new ValidationMessage();
msg.setPath(path);
msg.setLevel(Level.WARNING);
msg.setText(message);
return msg;
}
use of org.guvnor.common.services.shared.validation.model.ValidationMessage in project drools-wb by kiegroup.
the class GuidedRuleTemplateEditorServiceImplCDITest method testValidateAndLoad.
@Test
public void testValidateAndLoad() throws Exception {
final Path testedPath = getPath(CARS);
final TemplateModel testedModel = testedService.load(testedPath);
final List<ValidationMessage> messages = testedService.validate(testedPath, testedModel);
Assertions.assertThat(messages).isEmpty();
Assertions.assertThat(testedModel.getColsCount()).isEqualTo(3);
Assertions.assertThat(testedModel.getRowsCount()).isEqualTo(4);
}
use of org.guvnor.common.services.shared.validation.model.ValidationMessage in project drools-wb by kiegroup.
the class WorkItemsEditorServiceImpl method doValidation.
private List<ValidationMessage> doValidation(final Path path, final String content) {
final List<ValidationMessage> validationMessages = new ArrayList<ValidationMessage>();
final List<String> workItemDefinitions = new ArrayList<String>();
workItemDefinitions.add(content);
try {
WorkDefinitionsParser.parse(workItemDefinitions);
} catch (Exception e) {
final ValidationMessage msg = new ValidationMessage();
msg.setPath(path);
msg.setLevel(Level.ERROR);
msg.setText(e.getMessage());
validationMessages.add(msg);
}
return validationMessages;
}
use of org.guvnor.common.services.shared.validation.model.ValidationMessage in project drools-wb by kiegroup.
the class EnumServiceImplCDITest method testValidate.
@Test
public void testValidate() throws Exception {
final Path path = getPath("enums/src/main/resources/guvnor/feature/enums/personAge.enumeration");
final List<ValidationMessage> validationMessages = enumService.validate(path);
Assertions.assertThat(validationMessages).isEmpty();
}
use of org.guvnor.common.services.shared.validation.model.ValidationMessage in project drools-wb by kiegroup.
the class EnumServiceImpl method doValidation.
private List<ValidationMessage> doValidation(final Path path, final String content) {
try {
final KieModule module = moduleService.resolveModule(path);
final org.kie.api.builder.KieModule kieModule = buildInfoService.getBuildInfo(module).getKieModuleIgnoringErrors();
final ClassLoader classLoader = KieModuleMetaData.Factory.newKieModuleMetaData(kieModule).getClassLoader();
final DataEnumLoader loader = new DataEnumLoader(content, classLoader, evaluator);
if (!loader.hasErrors()) {
return Collections.emptyList();
} else {
final List<ValidationMessage> validationMessages = new ArrayList<>();
final List<String> loaderErrors = loader.getErrors();
for (final String message : loaderErrors) {
validationMessages.add(makeValidationMessages(path, message));
}
return validationMessages;
}
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
Aggregations