Search in sources :

Example 1 with ValidationMessage

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;
}
Also used : ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage)

Example 2 with ValidationMessage

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);
}
Also used : Path(org.uberfire.backend.vfs.Path) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel) Test(org.junit.Test)

Example 3 with ValidationMessage

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;
}
Also used : ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) ArrayList(java.util.ArrayList) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

Example 4 with ValidationMessage

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();
}
Also used : Path(org.uberfire.backend.vfs.Path) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) Test(org.junit.Test)

Example 5 with ValidationMessage

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);
    }
}
Also used : ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) ArrayList(java.util.ArrayList) DataEnumLoader(org.kie.workbench.common.services.datamodel.backend.server.builder.util.DataEnumLoader) KieModule(org.kie.workbench.common.services.shared.project.KieModule) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

Aggregations

ValidationMessage (org.guvnor.common.services.shared.validation.model.ValidationMessage)19 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 Path (org.uberfire.backend.vfs.Path)6 List (java.util.List)3 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)3 IOException (java.io.IOException)2 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)2 ObservablePath (org.uberfire.backend.vfs.ObservablePath)2 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)2 StringReader (java.io.StringReader)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 NotThreadSafe (javax.annotation.concurrent.NotThreadSafe)1 Assertions (org.assertj.core.api.Assertions)1 DSLMappingParseException (org.drools.compiler.lang.dsl.DSLMappingParseException)1 DSLTokenizedMappingFile (org.drools.compiler.lang.dsl.DSLTokenizedMappingFile)1 ConnectiveConstraint (org.drools.workbench.models.datamodel.rule.ConnectiveConstraint)1 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)1 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)1