use of org.kie.soup.project.datamodel.imports.Imports in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkInitialiseKieEditorTabs.
@Test
public void checkInitialiseKieEditorTabs() {
final ObservablePath dtGraphPath = mock(ObservablePath.class);
final PlaceRequest dtGraphPlaceRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent(0);
when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
when(dtGraphPath.getFileName()).thenReturn("filename");
when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
when(versionRecordManager.getVersion()).thenReturn("version");
presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
verify(kieEditorWrapperView, times(1)).clear();
final GuidedDecisionTableView.Presenter document = mock(GuidedDecisionTableView.Presenter.class);
final AsyncPackageDataModelOracle dmo = mock(AsyncPackageDataModelOracle.class);
final Imports imports = mock(Imports.class);
final boolean isReadOnly = true;
final ArgumentCaptor<com.google.gwt.user.client.Command> onFocusCommandCaptor = ArgumentCaptor.forClass(com.google.gwt.user.client.Command.class);
presenter.initialiseKieEditorTabs(document, dtGraphContent.getOverview(), dmo, imports, isReadOnly);
verify(kieEditorWrapperView, times(2)).clear();
verify(kieEditorWrapperView, times(2)).addMainEditorPage(view);
verify(kieEditorWrapperView, times(2)).addOverviewPage(eq(overviewWidget), onFocusCommandCaptor.capture());
verify(overviewWidget, times(2)).setContent(eq(dtGraphContent.getOverview()), any(ObservablePath.class));
verify(kieEditorWrapperView, times(1)).addSourcePage(any(ViewDRLSourceWidget.class));
verify(kieEditorWrapperView, times(1)).addImportsTab(eq(importsWidget));
verify(importsWidget, times(1)).setContent(eq(dmo), eq(imports), eq(isReadOnly));
final com.google.gwt.user.client.Command onFocusCommand = onFocusCommandCaptor.getValue();
assertNotNull(onFocusCommand);
onFocusCommand.execute();
verify(overviewWidget, times(1)).refresh(eq("version"));
}
use of org.kie.soup.project.datamodel.imports.Imports in project drools-wb by kiegroup.
the class GuidedScoreCardIndexVisitor method visit.
public void visit() {
// Add type
final String typeName = model.getFactName();
if (typeName == null || typeName.isEmpty()) {
return;
}
final String fullyQualifiedClassName = getFullyQualifiedClassName(typeName);
ResourceReference resRef = addResourceReference(fullyQualifiedClassName, ResourceType.JAVA);
// Add field
final String fieldName = model.getFieldName();
if (fieldName == null || fieldName.isEmpty()) {
return;
}
resRef.addPartReference(fieldName, PartType.FIELD);
final String fieldFullyQualifiedClassName = getFieldFullyQualifiedClassName(fullyQualifiedClassName, fieldName);
addResourceReference(fieldFullyQualifiedClassName, ResourceType.JAVA);
// Add Characteristics
for (Characteristic c : model.getCharacteristics()) {
visit(c);
}
// agenda-group, ruleflow-group
String agendaGroup = model.getAgendaGroup();
if (agendaGroup != null && !agendaGroup.isEmpty()) {
addSharedReference(agendaGroup, PartType.AGENDA_GROUP);
}
String ruleFlowGroup = model.getRuleFlowGroup();
if (ruleFlowGroup != null && !ruleFlowGroup.isEmpty()) {
addSharedReference(ruleFlowGroup, PartType.RULEFLOW_GROUP);
}
Imports imports = model.getImports();
if (imports != null) {
visit(imports);
}
}
use of org.kie.soup.project.datamodel.imports.Imports in project drools-wb by kiegroup.
the class FromAccumulateCompositeFactPatternWidgetTest method setUp.
@Before
public void setUp() throws Exception {
// listBox is used for verification fo added available fact types into UI
GwtMockito.useProviderForType(ListBox.class, aClass -> listBox);
// Mock partially the AsyncPackageDataModelOracle
validatorInstance = new MockInstanceImpl<>();
oracle = spy(new AsyncPackageDataModelOracleImpl(new CallerMock<>(incrementalDataModelService), validatorInstance));
// Mock partially the AsyncPackageDataModelOracleFactory and ensure oracle will contain data form payload below
doReturn(syncBeanDef).when(syncBeanManager).lookupBean(AsyncPackageDataModelOracle.class);
doReturn(oracle).when(syncBeanDef).getInstance();
doReturn(oracle).when(ruleModeller).getDataModelOracle();
// Prepare base payload that simulates two Facts in the package, Person and Car
dataModelPayload = new PackageDataModelOracleBaselinePayload();
dataModelPayload.setModelFields(new HashMap<String, ModelField[]>() {
{
final String fqnPerson = REDHAT_PACKAGE + "." + FACT_TYPE_PERSON;
final String fqnCar = REDHAT_PACKAGE + "." + FACT_TYPE_CAR;
final String fqnNumber = Number.class.getName();
put(fqnPerson, new ModelField[] { modelField(DataType.TYPE_THIS, fqnPerson) });
put(fqnCar, new ModelField[] { modelField(DataType.TYPE_THIS, fqnCar) });
put(fqnNumber, new ModelField[] { modelField(DataType.TYPE_THIS, fqnNumber) });
}
});
// Prevent NPE in FromAccumulateCompositeFactPatternWidget constructor
when(pattern.useFunctionOrCode()).thenReturn(FromAccumulateCompositeFactPattern.USE_FUNCTION);
fromAccumulateWidget = new FromAccumulateCompositeFactPatternWidget(ruleModeller, eventBus, pattern);
ruleModelWithImportedNumber = new RuleModel() {
{
setImports(new Imports() {
{
addImport(new Import(Number.class));
}
});
}
};
}
use of org.kie.soup.project.datamodel.imports.Imports in project drools-wb by kiegroup.
the class ScenarioTestEditorServiceImpl method load.
@Override
public Scenario load(final Path path) {
try {
final String content = ioService.readAllString(Paths.convert(path));
final Scenario scenario = ScenarioXMLPersistence.getInstance().unmarshal(content);
scenario.setName(path.getFileName());
return scenario;
} catch (final Exception e) {
logger.error("Unable to unmarshal content. Returning an empty Test Scenario.", e);
final Package resolvedPackage = moduleService.resolvePackage(path);
final Scenario scenario = new Scenario();
if (resolvedPackage != null) {
scenario.setPackageName(resolvedPackage.getPackageName());
}
scenario.setImports(new Imports());
return scenario;
}
}
use of org.kie.soup.project.datamodel.imports.Imports in project drools-wb by kiegroup.
the class ScenarioTestEditorServiceImplTest method runScenarioWithDependentImportsAndWithoutFactData.
@Test
public void runScenarioWithDependentImportsAndWithoutFactData() throws Exception {
final ArrayList<Fixture> fixtures = new ArrayList<Fixture>();
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()).thenReturn(imports);
testEditorService.addDependentImportsToScenario(scenario, path);
assertEquals(2, scenario.getImports().getImports().size());
}
Aggregations