use of org.kie.soup.project.datamodel.imports.Imports in project drools by kiegroup.
the class RuleModelDRLPersistenceImpl method getRuleModel.
private RuleModel getRuleModel(final ExpandedDRLInfo expandedDRLInfo, final PackageDataModelOracle dmo, final Collection<RuleModelIActionPersistenceExtension> extensions) throws RuleModelDRLPersistenceException {
// De-serialize model
RuleDescr ruleDescr = parseDrl(expandedDRLInfo);
RuleModel model = new RuleModel();
model.name = ruleDescr.getName();
model.parentName = ruleDescr.getParentName();
for (AnnotationDescr annotation : ruleDescr.getAnnotations()) {
model.addMetadata(new RuleMetadata(annotation.getName(), annotation.getValuesAsString()));
}
// De-serialize Package name
final String packageName = PackageNameParser.parsePackageName(expandedDRLInfo.plainDrl);
model.setPackageName(packageName);
// De-serialize imports
final Imports imports = ImportsParser.parseImports(expandedDRLInfo.plainDrl);
for (Import item : imports.getImports()) {
model.getImports().addImport(item);
}
boolean isJavaDialect = parseAttributes(model, ruleDescr.getAttributes());
Map<String, String> boundParams = parseLhs(model, ruleDescr.getLhs(), isJavaDialect, expandedDRLInfo, dmo);
parseRhs(model, expandedDRLInfo.consequence != null ? expandedDRLInfo.consequence : (String) ruleDescr.getConsequence(), isJavaDialect, boundParams, expandedDRLInfo, dmo, extensions);
return model;
}
use of org.kie.soup.project.datamodel.imports.Imports in project drools by kiegroup.
the class ScenarioXMLPersistence method unmarshal.
public Scenario unmarshal(String xml) {
if (xml == null)
return new Scenario();
if (xml.trim().equals(""))
return new Scenario();
Object o = xt.fromXML(xml);
Scenario scenario = (Scenario) o;
if (scenario.getImports() == null) {
scenario.setImports(new Imports());
}
return scenario;
}
use of org.kie.soup.project.datamodel.imports.Imports in project drools-wb by kiegroup.
the class ScenarioTestEditorServiceImpl method runScenario.
@Override
public TestScenarioResult runScenario(final String userName, final Path path, final Scenario scenario) {
final Imports existingScenarioImports = new Imports(scenario.getImports().getImports());
try {
addDependentImportsToScenario(scenario, path);
final TestScenarioResult result = scenarioRunner.run(userName, scenario, moduleService.resolveModule(path));
return result;
} catch (final Exception e) {
throw ExceptionUtilities.handleException(e);
} finally {
scenario.setImports(existingScenarioImports);
}
}
use of org.kie.soup.project.datamodel.imports.Imports in project drools-wb by kiegroup.
the class ScenarioTestEditorServiceImplTest method checkSingleScenarioMultipleExecution.
@Test
public void checkSingleScenarioMultipleExecution() throws Exception {
final ArrayList<Fixture> fixtures = new ArrayList<>();
final Imports imports = new Imports() {
{
addImport(new Import("java.sql.ClientInfoStatus"));
}
};
final Map<String, ModelField[]> modelFields = new HashMap<String, ModelField[]>() {
{
put("java.sql.ClientInfoStatus", new ModelField[] { modelField("java.sql.JDBCType") });
}
};
when(scenario.getFixtures()).thenReturn(fixtures);
when(dataModelService.getDataModel(path)).thenReturn(modelOracle);
when(modelOracle.getModuleModelFields()).thenReturn(modelFields);
when(scenario.getImports()).thenCallRealMethod();
doCallRealMethod().when(scenario).setImports(any(Imports.class));
scenario.setImports(imports);
testEditorService.runScenario("userName", path, scenario);
assertEquals(1, scenario.getImports().getImports().size());
testEditorService.runScenario("userName", path, scenario);
assertEquals(1, scenario.getImports().getImports().size());
}
use of org.kie.soup.project.datamodel.imports.Imports in project drools-wb by kiegroup.
the class ScenarioTestEditorServiceImplTest method runScenarioWithDependentImports.
@Test
public void runScenarioWithDependentImports() throws Exception {
final ArrayList<Fixture> fixtures = new ArrayList<Fixture>() {
{
add(factData("java.sql.ClientInfoStatus"));
}
};
final Map<String, ModelField[]> modelFields = new HashMap<String, ModelField[]>() {
{
put("java.sql.ClientInfoStatus", new ModelField[] { modelField("java.sql.JDBCType") });
}
};
when(scenario.getFixtures()).thenReturn(fixtures);
when(dataModelService.getDataModel(path)).thenReturn(modelOracle);
when(modelOracle.getModuleModelFields()).thenReturn(modelFields);
when(scenario.getImports()).thenReturn(new Imports());
testEditorService.addDependentImportsToScenario(scenario, path);
assertEquals(2, scenario.getImports().getImports().size());
}
Aggregations