use of org.kie.workbench.common.services.shared.project.KieModule in project drools-wb by kiegroup.
the class ScenarioRunnerServiceTest method testRunEmptyScenario.
@Test
public void testRunEmptyScenario() throws Exception {
initKieSession();
TestScenarioResult result = service.run("userName", makeScenario("test.scenario"), new KieModule());
assertNotNull(result);
ArgumentCaptor<TestResultMessage> argumentCaptor = ArgumentCaptor.forClass(TestResultMessage.class);
verify(defaultTestResultMessageEvent).fire(argumentCaptor.capture());
assertEquals("userName", argumentCaptor.getValue().getIdentifier());
}
use of org.kie.workbench.common.services.shared.project.KieModule in project drools-wb by kiegroup.
the class ScenarioTestEditorServiceImplTest method checkScenarioRunnerIsRan.
@Test
public void checkScenarioRunnerIsRan() throws Exception {
final Imports imports = new Imports() {
{
addImport(new Import("java.sql.ClientInfoStatus"));
}
};
when(dataModelService.getDataModel(path)).thenReturn(modelOracle);
when(scenario.getImports()).thenCallRealMethod();
doCallRealMethod().when(scenario).setImports(any(Imports.class));
scenario.setImports(imports);
testEditorService.runScenario("userName", path, scenario);
KieModule module = mock(KieModule.class);
when(moduleService.resolveModule(path)).thenReturn(module);
testEditorService.runScenario("userName", path, scenario);
verify(scenarioRunner).run("userName", scenario, module);
}
use of org.kie.workbench.common.services.shared.project.KieModule 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);
}
}
use of org.kie.workbench.common.services.shared.project.KieModule in project drools-wb by kiegroup.
the class DecisionTableXLSToDecisionTableGuidedConverter method makeNewJavaTypes.
private void makeNewJavaTypes(final Path context, final List<String> declaredTypes, final ConversionResult result) {
if (declaredTypes == null || declaredTypes.isEmpty()) {
return;
}
final KieModule module = moduleService.resolveModule(context);
for (String declaredType : declaredTypes) {
final FactModels factModels = FactModelPersistence.unmarshal(declaredType);
final String packageName = factModels.getPackageName();
final DataModel dataModel = new DataModelImpl();
for (FactMetaModel factMetaModel : factModels.getModels()) {
final DataObject dataObject = new DataObjectImpl(packageName, factMetaModel.getName());
dataObject.setSuperClassName(factMetaModel.getSuperType());
final List<AnnotationMetaModel> annotationMetaModel = factMetaModel.getAnnotations();
addAnnotations(dataObject, annotationMetaModel);
final List<FieldMetaModel> fields = factMetaModel.getFields();
for (FieldMetaModel fieldMetaModel : fields) {
final String fieldName = fieldMetaModel.name;
final String fieldType = fieldMetaModel.type;
// Guvnor 5.5 (and earlier) does not have MultipleType
boolean isMultiple = false;
ObjectProperty property = new ObjectPropertyImpl(fieldName, fieldType, isMultiple);
// field has no annotation in Guvnor 5.5 (and earlier)
dataObject.addProperty(property);
result.addMessage("Created Java Type " + getJavaTypeFQCN(dataObject), ConversionMessageType.INFO);
}
dataModel.getDataObjects().add(dataObject);
}
modellerService.saveModel(dataModel, module);
}
}
use of org.kie.workbench.common.services.shared.project.KieModule in project drools-wb by kiegroup.
the class ScenarioRunnerServiceTest method testScenario.
private void testScenario(String scenarioName, boolean isExpectedSuccess) throws Exception {
final KieModule module = mock(KieModule.class);
final URL scenarioResource = getClass().getResource(scenarioName);
final Path scenarioPath = PathFactory.newPath(scenarioResource.getFile(), scenarioResource.toURI().toString());
final Scenario scenario = testEditorService.load(scenarioPath);
assertFalse(scenario.wasSuccessful());
final TestScenarioResult result = service.run("userName", scenario, module);
assertEquals(isExpectedSuccess, scenario.wasSuccessful());
assertEquals(isExpectedSuccess, result.getScenario().wasSuccessful());
verify(defaultTestResultMessageEvent).fire(testResultMessageCaptor.capture());
final TestResultMessage resultMessage = testResultMessageCaptor.getValue();
assertEquals(isExpectedSuccess, resultMessage.getFailures().size() == 0);
assertEquals(isExpectedSuccess, resultMessage.wasSuccessful());
}
Aggregations