use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedRuleEditorRenameHelperTest method testRDRLFile.
@Test
public void testRDRLFile() {
final Path pathSource = mock(Path.class);
final Path pathDestination = mock(Path.class);
when(pathSource.toURI()).thenReturn("default://p0/src/main/resources/MyFile.rdrl");
when(pathDestination.toURI()).thenReturn("default://p0/src/main/resources/MyNewFile.rdrl");
when(pathDestination.getFileName()).thenReturn("MyNewFile.rdrl");
when(ioService.readAllString(any(org.uberfire.java.nio.file.Path.class))).thenReturn(drl);
helper.postProcess(pathSource, pathDestination);
final ArgumentCaptor<String> drlArgumentCaptor = ArgumentCaptor.forClass(String.class);
verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), drlArgumentCaptor.capture(), any(CommentedOption.class));
final String newDrl = drlArgumentCaptor.getValue();
assertNotNull(newDrl);
assertTrue(newDrl.contains("MyNewFile"));
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedRuleEditorServiceImplTest method checkConstructContentPopulateProjectCollectionTypesAndDSLSentences.
@Test
public void checkConstructContentPopulateProjectCollectionTypesAndDSLSentences() throws Exception {
final Path path = mock(Path.class);
final Overview overview = mock(Overview.class);
final ModuleDataModelOracle projectDataModelOracle = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator()).addClass(List.class).addClass(Set.class).addClass(Collection.class).addClass(Integer.class).build();
final PackageDataModelOracle oracle = PackageDataModelOracleBuilder.newPackageOracleBuilder(new RawMVELEvaluator()).setModuleOracle(projectDataModelOracle).addExtension(DSLActionSentence.INSTANCE, Collections.singletonList(dslSentence)).addExtension(DSLConditionSentence.INSTANCE, Collections.singletonList(dslSentence)).build();
when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/rule.rdrl");
when(dataModelService.getDataModel(any())).thenReturn(oracle);
final GuidedEditorContent content = service.constructContent(path, overview);
assertEquals(3, content.getDataModel().getCollectionTypes().size());
assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.Collection"));
assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.List"));
assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.Set"));
assertTrue(content.getDataModel().getPackageElements(DSLActionSentence.INSTANCE).contains(dslSentence));
assertTrue(content.getDataModel().getPackageElements(DSLConditionSentence.INSTANCE).contains(dslSentence));
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class NewGuidedDecisionTableWizardTest method whenModelIsCreatedWithHitPolicy.
private GuidedDecisionTable52 whenModelIsCreatedWithHitPolicy(final GuidedDecisionTable52.HitPolicy hitPolicy) {
when(summaryPage.getBaseFileName()).thenReturn("basefilename");
NewGuidedDecisionTableWizard.GuidedDecisionTableWizardHandler handler = mock(NewGuidedDecisionTableWizard.GuidedDecisionTableWizardHandler.class);
Path path = mock(Path.class);
wizard.setContent(path, "filename", GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY, hitPolicy, mock(AsyncPackageDataModelOracle.class), handler);
wizard.complete();
final ArgumentCaptor<GuidedDecisionTable52> dtableArgumentCaptor = ArgumentCaptor.forClass(GuidedDecisionTable52.class);
verify(handler).save(eq(path), eq("basefilename"), dtableArgumentCaptor.capture());
return dtableArgumentCaptor.getValue();
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedRuleTemplateEditorServiceImpl method constructContent.
@Override
protected GuidedTemplateEditorContent constructContent(Path path, Overview overview) {
final TemplateModel model = load(path);
final PackageDataModelOracle oracle = dataModelService.getDataModel(path);
final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
// Get FQCN's used by model
final GuidedRuleModelVisitor visitor = new GuidedRuleModelVisitor(model);
final Set<String> consumedFQCNs = visitor.getConsumedModelClasses();
// Get FQCN's used by Globals
consumedFQCNs.addAll(oracle.getPackageGlobals().values());
// Get FQCN's of collections defined in project settings
// they can be used in From Collect expressions
consumedFQCNs.addAll(oracle.getModuleCollectionTypes().entrySet().stream().filter(entry -> entry.getValue()).map(entry -> entry.getKey()).collect(Collectors.toSet()));
DataModelOracleUtilities.populateDataModel(oracle, dataModel, consumedFQCNs);
// Signal opening to interested parties
resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
return new GuidedTemplateEditorContent(model, overview, dataModel);
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class NewScoreCardXLSHandlerTest method testSuccessMultiByteProjectNameAndFileName.
@Test
public void testSuccessMultiByteProjectNameAndFileName() {
final String fileName = "あああ";
final Package pkg = mock(Package.class);
final Path resourcesPath = PathFactory.newPath("resources", "default://" + encode("ああ") + "/src/main/resources");
when(pkg.getPackageMainResourcesPath()).thenReturn(resourcesPath);
handler.create(pkg, fileName, newResourcePresenter);
verify(uploadWidget, times(1)).submit(eq(resourcesPath), eq(fileName + "." + resourceType.getSuffix()), any(String.class), successCmdCaptor.capture(), failureCmdCaptor.capture());
successCmdCaptor.getValue().execute();
verify(busyIndicatorView, times(1)).hideBusyIndicator();
verify(newResourcePresenter, times(1)).complete();
verify(mockNotificationEvent, times(1)).fire(any(NotificationEvent.class));
verify(newResourceSuccessEventMock, times(1)).fire(any(NewResourceSuccessEvent.class));
verify(placeManager, times(1)).goTo(newPathCaptor.capture());
assertEquals("default://%E3%81%82%E3%81%82/src/main/resources/%E3%81%82%E3%81%82%E3%81%82.sxls", newPathCaptor.getValue().toURI());
}
Aggregations