use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class NewGuidedDecisionTableHandlerTest method testCreate_WithoutWizard.
@Test
public void testCreate_WithoutWizard() {
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);
when(options.isUsingWizard()).thenReturn(false);
handler.create(pkg, fileName, newResourcePresenter);
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(pathCaptor.capture());
assertEquals("default://project/src/main/resources/fileName.gdst", pathCaptor.getValue().toURI());
verify(service, times(1)).create(eq(resourcesPath), eq(fileName + "." + resourceType.getSuffix()), any(GuidedDecisionTable52.class), any(String.class));
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class NewGuidedDecisionTableHandlerTest method testCreate_WithWizard.
@Test
public void testCreate_WithWizard() {
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);
when(options.isUsingWizard()).thenReturn(true);
when(options.getTableFormat()).thenReturn(TableFormat.EXTENDED_ENTRY);
when(options.getHitPolicy()).thenReturn(GuidedDecisionTable52.HitPolicy.FIRST_HIT);
handler.create(pkg, fileName, newResourcePresenter);
verify(wizardBean, times(1)).setContent(pathCaptor.capture(), fileNameCaptor.capture(), eq(TableFormat.EXTENDED_ENTRY), eq(GuidedDecisionTable52.HitPolicy.FIRST_HIT), any(AsyncPackageDataModelOracle.class), any(NewGuidedDecisionTableWizard.GuidedDecisionTableWizardHandler.class));
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class NewGuidedDecisionTableGraphHandlerTest method testCreate.
@Test
public void testCreate() {
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(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(pathCaptor.capture());
assertEquals("default://project/src/main/resources/fileName." + resourceType.getSuffix(), pathCaptor.getValue().toURI());
verify(service, times(1)).create(eq(resourcesPath), eq(fileName + "." + resourceType.getSuffix()), any(GuidedDecisionTableEditorGraphModel.class), any(String.class));
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorServiceImpl method create.
@Override
public Path create(final Path context, final String fileName, final GuidedDecisionTable52 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, GuidedDTXMLPersistence.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 GuidedDecisionTableGraphEditorServiceImpl method listDecisionTablesInPackage.
@Override
public List<Path> listDecisionTablesInPackage(final Path path) {
try {
final Package pkg = moduleService.resolvePackage(path);
if (pkg == null) {
return Collections.emptyList();
}
final Path pkgPath = pkg.getPackageMainResourcesPath();
final org.uberfire.java.nio.file.Path nioPkgPath = Paths.convert(pkgPath);
final List<Path> paths = findDecisionTables(nioPkgPath);
return paths;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
Aggregations