use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class GuidedRuleTemplateEditorServiceImpl method create.
public Path create(final Path context, final String fileName, final TemplateModel content, final String comment) {
try {
final Package pkg = moduleService.resolvePackage(context);
final String packageName = (pkg == null ? null : pkg.getPackageName());
content.setPackageName(packageName);
final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName);
final Path newPath = Paths.convert(nioPath);
if (ioService.exists(nioPath)) {
throw new FileAlreadyExistsException(nioPath.toString());
}
ioService.write(nioPath, RuleTemplateModelXMLPersistenceImpl.getInstance().marshal(content), commentedOptionFactory.makeCommentedOption(comment));
return newPath;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class NewScoreCardXLSHandlerTest method testSuccess.
@Test
public void testSuccess() {
final String fileName = "fileName";
final Package pkg = mock(Package.class);
final Path resourcesPath = PathFactory.newPath("resources", "default://project/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://project/src/main/resources/fileName.sxls", newPathCaptor.getValue().toURI());
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class NewScoreCardXLSHandlerTest method testSuccessMultiByteFileName.
@Test
public void testSuccessMultiByteFileName() {
final String fileName = "あああ";
final Package pkg = mock(Package.class);
final Path resourcesPath = PathFactory.newPath("resources", "default://project/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://project/src/main/resources/%E3%81%82%E3%81%82%E3%81%82.sxls", newPathCaptor.getValue().toURI());
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class NewScoreCardXLSHandlerTest method testSuccessMultiByteProjectName.
@Test
public void testSuccessMultiByteProjectName() {
final String fileName = "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/fileName.sxls", newPathCaptor.getValue().toURI());
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class TestScenarioFileIndexer method fillIndexBuilder.
@Override
public DefaultIndexBuilder fillIndexBuilder(final Path path) throws Exception {
final String content = ioService.readAllString(path);
final Scenario model = ScenarioXMLPersistence.getInstance().unmarshal(content);
final ModuleDataModelOracle dmo = getModuleDataModelOracle(path);
final Module project = moduleService.resolveModule(Paths.convert(path));
final Package pkg = moduleService.resolvePackage(Paths.convert(path));
final DefaultIndexBuilder builder = new DefaultIndexBuilder(Paths.convert(path).getFileName(), project, pkg);
final TestScenarioIndexVisitor visitor = new TestScenarioIndexVisitor(dmo, builder, model);
visitor.visit();
addReferencedResourcesToIndexBuilder(builder, visitor);
return builder;
}
Aggregations