use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorGraphRenameHelper method updateGraphElementPath.
void updateGraphElementPath(final Path source, final Path destination, final Path graphPath) {
final GuidedDecisionTableEditorGraphModel dtGraphModel = dtableGraphService.load(graphPath);
final Set<GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry> dtGraphEntries = dtGraphModel.getEntries();
dtGraphEntries.forEach((e) -> {
if (e.getPathHead().equals(source)) {
e.setPathHead(destination);
e.setPathVersion(destination);
}
});
ioService.write(Paths.convert(graphPath), GuidedDTGraphXMLPersistence.getInstance().marshal(dtGraphModel), commentedOptionFactory.makeCommentedOption("File [" + source.toURI() + "] renamed to [" + destination.toURI() + "]."));
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorServiceImpl method updateGraphElementPath.
private void updateGraphElementPath(final Path source, final Path destination, final Path graphPath) {
final GuidedDecisionTableEditorGraphModel dtGraphModel = dtableGraphService.load(graphPath);
final Set<GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry> dtGraphEntries = dtGraphModel.getEntries();
dtGraphEntries.stream().filter((e) -> e.getPathHead().equals(source)).forEach((e) -> e.setPathVersion(destination));
ioService.write(Paths.convert(graphPath), GuidedDTGraphXMLPersistence.getInstance().marshal(dtGraphModel), commentedOptionFactory.makeCommentedOption("Updated Path version for [" + source.toURI() + "] to [" + destination.toURI() + "]."));
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorGraphDeleteHelperTest method checkRemoveReferencesWithDecisionTableGraphs.
@Test
public void checkRemoveReferencesWithDecisionTableGraphs() 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(path.toURI()).thenReturn("file://test/dtable.gdst");
final GuidedDecisionTableEditorGraphModel model = new GuidedDecisionTableEditorGraphModel();
model.getEntries().add(new GuidedDecisionTableEditorGraphModel.GuidedDecisionTableGraphEntry(path, path));
when(dtableGraphService.load(any(Path.class))).thenReturn(model);
helper.postProcess(path);
verify(helper, times(1)).updateGraphReferences(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(0, newModel.getEntries().size());
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorServiceImplTest method checkLoad.
@Test
public void checkLoad() {
final Path path = mock(Path.class);
when(path.toURI()).thenReturn("file://project/src/main/resources/mypackage/dtable." + dtGraphResourceType.getSuffix());
when(ioService.readAllString(any(org.uberfire.java.nio.file.Path.class))).thenReturn("");
final GuidedDecisionTableEditorGraphModel model = service.load(path);
verify(ioService, times(1)).readAllString(any(org.uberfire.java.nio.file.Path.class));
assertNotNull(model);
}
use of org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel in project drools-wb by kiegroup.
the class GuidedDTGraphXMLPersistenceTest method checkUnmarshallingEmptyModel.
@Test
public void checkUnmarshallingEmptyModel() {
final GuidedDecisionTableEditorGraphModel model = GuidedDTGraphXMLPersistence.getInstance().unmarshal(emptyModelXml);
assertEmptyModel(model);
}
Aggregations