use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorServiceImpl method save.
@Override
public Path save(final Path resource, final GuidedDecisionTable52 model, final Metadata metadata, final String comment) {
try {
final Package pkg = moduleService.resolvePackage(resource);
final String packageName = (pkg == null ? null : pkg.getPackageName());
model.setPackageName(packageName);
Metadata currentMetadata = metadataService.getMetadata(resource);
ioService.write(Paths.convert(resource), GuidedDTXMLPersistence.getInstance().marshal(model), metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment));
fireMetadataSocialEvents(resource, currentMetadata, metadata);
return resource;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class NewDecisionTableXLSHandlerTest 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 + "." + decisionTableXLSResourceType.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(placeManager, times(1)).goTo(newPathCaptor.capture());
assertEquals("default://project/src/main/resources/%E3%81%82%E3%81%82%E3%81%82.xls", newPathCaptor.getValue().toURI());
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class NewDecisionTableXLSHandlerTest 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 + "." + decisionTableXLSResourceType.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.xls", newPathCaptor.getValue().toURI());
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class GlobalsEditorServiceImpl method save.
@Override
public Path save(final Path resource, final GlobalsModel content, final Metadata metadata, final String comment) {
try {
final Package pkg = moduleService.resolvePackage(resource);
final String packageName = (pkg == null ? null : pkg.getPackageName());
content.setPackageName(packageName);
Metadata currentMetadata = metadataService.getMetadata(resource);
ioService.write(Paths.convert(resource), GlobalsPersistence.getInstance().marshal(content), metadataService.setUpAttributes(resource, metadata), commentedOptionFactory.makeCommentedOption(comment));
// Invalidate Package-level DMO cache as Globals have changed.
invalidatePackageDMOEvent.fire(new InvalidateDMOPackageCacheEvent(resource));
fireMetadataSocialEvents(resource, currentMetadata, metadata);
return resource;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.guvnor.common.services.project.model.Package in project drools-wb by kiegroup.
the class NewGuidedDecisionTableHandlerTest method testResolvedHitPolicy.
@Test
public void testResolvedHitPolicy() throws Exception {
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);
when(options.getHitPolicy()).thenReturn(GuidedDecisionTable52.HitPolicy.RESOLVED_HIT);
handler.create(pkg, "fileName", newResourcePresenter);
final ArgumentCaptor<GuidedDecisionTable52> dtableArgumentCaptor = ArgumentCaptor.forClass(GuidedDecisionTable52.class);
verify(service, times(1)).create(eq(resourcesPath), eq("fileName." + resourceType.getSuffix()), dtableArgumentCaptor.capture(), any(String.class));
final GuidedDecisionTable52 model = dtableArgumentCaptor.getValue();
assertEquals(1, model.getMetadataCols().size());
final MetadataCol52 metadataCol52 = model.getMetadataCols().get(0);
assertEquals(GuidedDecisionTable52.HitPolicy.RESOLVED_HIT_METADATA_NAME, metadataCol52.getMetadata());
}
Aggregations