use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorServiceImplTest method checkSave.
@Test
@SuppressWarnings("unchecked")
public void checkSave() {
final Path path = mock(Path.class);
final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel();
final Metadata metadata = mock(Metadata.class);
final String comment = "comment";
when(path.toURI()).thenReturn("file://project/src/main/resources/mypackage/dtable." + dtGraphResourceType.getSuffix());
service.save(path, model, metadata, comment);
verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), any(String.class), any(Map.class), any());
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorGraphRenameHelperTest method checkUpdateReferencesWithDecisionTableGraphs.
@Test
public void checkUpdateReferencesWithDecisionTableGraphs() throws URISyntaxException {
final org.uberfire.java.nio.file.Path dtGraphPath = mock(org.uberfire.java.nio.file.Path.class);
when(dtGraphPath.getFileName()).thenReturn(mock(org.uberfire.java.nio.file.Path.class));
when(dtGraphPath.toUri()).thenReturn(new URI("file://test/dtable-set." + dtableGraphType.getSuffix()));
when(dtGraphPath.getFileSystem()).thenReturn(fileSystem);
paths.add(dtGraphPath);
when(source.toURI()).thenReturn("file://test/dtable.gdst");
when(destination.toURI()).thenReturn("file://test/dtable-renamed.gdst");
final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel();
model.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(source, source));
when(dtableGraphService.load(any(Path.class))).thenReturn(model);
helper.postProcess(source, destination);
verify(helper, times(1)).updateGraphElementPath(any(Path.class), any(Path.class), any(Path.class));
final ArgumentCaptor<org.uberfire.java.nio.file.Path> dtGraphPathCaptor = ArgumentCaptor.forClass(org.uberfire.java.nio.file.Path.class);
final ArgumentCaptor<String> modelXmlCaptor = ArgumentCaptor.forClass(String.class);
verify(ioService, times(1)).write(dtGraphPathCaptor.capture(), modelXmlCaptor.capture(), any());
final org.uberfire.java.nio.file.Path dtGraphPath2 = dtGraphPathCaptor.getValue();
assertEquals(dtGraphPath.toUri().getPath(), dtGraphPath2.toUri().getPath());
final String modelXml = modelXmlCaptor.getValue();
final GuidedDecisionTableEditorGraphModel newModel = GuidedDTGraphXMLPersistence.getInstance().unmarshal(modelXml);
assertEquals(1, newModel.getEntries().size());
assertEquals(destination.toURI(), newModel.getEntries().iterator().next().getPathHead().toURI());
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.
the class IndexGuidedDecisionTableGraphFileTest method testIndexGuidedDecisionTableGraphEntries.
@Test
public void testIndexGuidedDecisionTableGraphEntries() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("dtable-graph1.gdst-set");
final Path dtable1Path = basePath.resolve("dtable1.gdst");
final Path dtable2Path = basePath.resolve("dtable2.gdst");
final org.uberfire.backend.vfs.Path vfsDtable1Path = Paths.convert(dtable1Path);
final org.uberfire.backend.vfs.Path vfsDtable2Path = Paths.convert(dtable2Path);
final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel();
model.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(vfsDtable1Path, vfsDtable1Path));
model.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(vfsDtable2Path, vfsDtable2Path));
final String xml = GuidedDTGraphXMLPersistence.getInstance().marshal(model);
ioService().write(path, xml);
// wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
Thread.sleep(5000);
List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId());
{
final Query query = new SingleTermQueryBuilder(new ValueSharedPartIndexTerm(vfsDtable1Path.toURI(), PartType.PATH)).build();
searchFor(index, query, 1, path);
}
{
final Query query = new SingleTermQueryBuilder(new ValueSharedPartIndexTerm(vfsDtable2Path.toURI(), PartType.PATH)).build();
searchFor(index, query, 1, path);
}
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorGraphDeleteHelper method updateGraphReferences.
void updateGraphReferences(final Path path, final Path graphPath) {
final GuidedDecisionTableEditorGraphModel dtGraphModel = dtableGraphService.load(graphPath);
final Set<GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry> dtGraphEntries = dtGraphModel.getEntries();
dtGraphEntries.removeIf((e) -> e.getPathHead().equals(path));
ioService.write(Paths.convert(graphPath), GuidedDTGraphXMLPersistence.getInstance().marshal(dtGraphModel), commentedOptionFactory.makeCommentedOption("File [" + path.toURI() + "] deleted."));
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorServiceImpl method constructContent.
@Override
protected GuidedDecisionTableEditorGraphContent constructContent(final Path path, final Overview overview) {
final GuidedDecisionTableEditorGraphModel model = load(path);
// Signal opening to interested parties
resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
return new GuidedDecisionTableEditorGraphContent(model, overview);
}
Aggregations