use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedRuleEditorServiceImplTest method testValidateModifyScoreAction.
@Test
public void testValidateModifyScoreAction() throws Exception {
final Path path = mock(Path.class);
final FreeFormLine modifyAction = new FreeFormLine();
modifyAction.setText(MODIFY_SCORE_ACTION);
final RuleModel model = new RuleModel();
model.addRhsItem(modifyAction);
service.validate(path, model);
final ArgumentCaptor<String> capturedFileContent = ArgumentCaptor.forClass(String.class);
verify(genericValidator).validate(eq(path), capturedFileContent.capture());
Assertions.assertThat(capturedFileContent.getValue()).contains(MODIFY_SCORE_ACTION);
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedScoreCardEditorServiceImpl method create.
@Override
public Path create(final Path context, final String fileName, final ScoreCardModel 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, GuidedScoreCardXMLPersistence.getInstance().marshal(content), commentedOptionFactory.makeCommentedOption(comment));
return newPath;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedRuleTemplateEditorServiceImplTest method checkConstructContentPopulateProjectCollectionTypes.
@Test
public void checkConstructContentPopulateProjectCollectionTypes() {
final Path path = mock(Path.class);
final Overview overview = mock(Overview.class);
final PackageDataModelOracle oracle = mock(PackageDataModelOracle.class);
when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/rule.template");
when(dataModelService.getDataModel(any())).thenReturn(oracle);
when(oracle.getPackageGlobals()).thenReturn(new HashMap<String, String>() {
{
put("number", "java.lang.Number");
put("collection", "java.util.Collection");
}
});
when(oracle.getModuleCollectionTypes()).thenReturn(new HashMap<String, Boolean>() {
{
put("java.util.List", true);
put("java.util.Set", true);
put("java.util.Collection", true);
put("java.util.UnknownCollection", false);
}
});
final GuidedTemplateEditorContent 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"));
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedScoreCardEditorServiceImplTest method testSaveAndRename.
@Test
public void testSaveAndRename() throws Exception {
final Path path = mock(Path.class);
final String newFileName = "newFileName";
final Metadata metadata = mock(Metadata.class);
final ScoreCardModel content = mock(ScoreCardModel.class);
final String comment = "comment";
service.saveAndRename(path, newFileName, metadata, content, comment);
verify(saveAndRenameService).saveAndRename(path, newFileName, metadata, content, comment);
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class NewGuidedDecisionTableHandler method createEmptyDecisionTable.
private void createEmptyDecisionTable(final Path contextPath, final String baseFileName) {
final GuidedDecisionTable52 model = new GuidedDecisionTable52();
model.setTableFormat(options.getTableFormat());
model.setHitPolicy(options.getHitPolicy());
if (GuidedDecisionTable52.HitPolicy.RESOLVED_HIT.equals(options.getHitPolicy())) {
final MetadataCol52 metadataCol52 = new MetadataCol52();
metadataCol52.setMetadata(GuidedDecisionTable52.HitPolicy.RESOLVED_HIT_METADATA_NAME);
model.getMetadataCols().add(metadataCol52);
}
model.setTableName(baseFileName);
final RemoteCallback<Path> onSaveSuccessCallback = getSuccessCallback(newResourcePresenter);
busyIndicatorView.showBusyIndicator(CommonConstants.INSTANCE.Saving());
service.call((Path path) -> {
busyIndicatorView.hideBusyIndicator();
onSaveSuccessCallback.callback(path);
}, new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)).create(contextPath, buildFileName(baseFileName, resourceType), model, "");
}
Aggregations