@Override public String getSimpleWildcardPattern() { return "*." + getSuffix(); }
@Override public String getSimpleWildcardPattern() { return "*." + getSuffix(); }
@Override public boolean accept(final Path path) { return path.getFileName().endsWith("." + getSuffix()); } }
@Override public boolean accept(final Path path) { return path.getFileName().endsWith("." + getSuffix()); } }
@Test public void checkLoad() { final Path path = mock(Path.class); when(path.toURI()).thenReturn("default://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); }
@Test public void checkLoad() { final Path path = mock(Path.class); when(path.toURI()).thenReturn("default://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); }
@Test public void checkSuffix() { assertEquals( "gdst-set", type.getSuffix() ); }
@Test public void checkSuffix() { assertEquals( "gdst-set", type.getSuffix() ); }
@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("default://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(CommentedOption.class)); }
@Test public void checkCreate() { final Path context = mock(Path.class); final String fileName = "filename." + dtGraphResourceType.getSuffix(); final GuidedDecisionTableEditorGraphModel content = new GuidedDecisionTableEditorGraphModel(); final String comment = "comment"; when(context.toURI()).thenReturn("default://project/src/main/resources/mypackage"); final Path p = service.create(context, fileName, content, comment); verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), any(String.class), any(CommentedOption.class)); assertTrue(p.toURI().contains("src/main/resources/mypackage/filename." + dtGraphResourceType.getSuffix())); }
@Test public void checkAcceptGraphPath() { final Path path = mock( Path.class ); when( path.getFileName() ).thenReturn( "a-file." + type.getSuffix() ); assertTrue( type.accept( path ) ); }
@Test public void checkConstructContent() { final Path path = mock(Path.class); final Overview overview = mock(Overview.class); when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable." + dtGraphResourceType.getSuffix()); final GuidedDecisionTableEditorGraphContent content = service.constructContent(path, overview); verify(resourceOpenedEvent, times(1)).fire(any(ResourceOpenedEvent.class)); assertNotNull(content.getModel()); assertEquals(overview, content.getOverview()); }
@Test public void checkAcceptGraphPath() { final Path path = mock( Path.class ); when( path.getFileName() ).thenReturn( "a-file." + type.getSuffix() ); assertTrue( type.accept( path ) ); }
@Test public void checkCreate() { final Path context = mock(Path.class); final String fileName = "filename." + dtGraphResourceType.getSuffix(); final GuidedDecisionTableEditorGraphModel content = new GuidedDecisionTableEditorGraphModel(); final String comment = "comment"; when(context.toURI()).thenReturn("default://project/src/main/resources/mypackage"); final Path p = service.create(context, fileName, content, comment); verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), any(String.class), any(CommentedOption.class)); assertTrue(p.toURI().contains("src/main/resources/mypackage/filename." + dtGraphResourceType.getSuffix())); }
@Test public void checkConstructContent() { final Path path = mock(Path.class); final Overview overview = mock(Overview.class); when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable." + dtGraphResourceType.getSuffix()); final GuidedDecisionTableEditorGraphContent content = service.constructContent(path, overview); verify(resourceOpenedEvent, times(1)).fire(any(ResourceOpenedEvent.class)); assertNotNull(content.getModel()); assertEquals(overview, content.getOverview()); }
private void updateGraphElementPaths(final Path source, final Path destination) { try (final DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream = ioService.newDirectoryStream(getParentFolder(source), new FileExtensionFilter(dtableGraphType.getSuffix()))) { directoryStream.forEach((path) -> updateGraphElementPath(source, destination, Paths.convert(path))); } }
@Override public void postProcess(final Path source, final Path destination) { try (DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream = ioService.newDirectoryStream(getParentFolder(source), new FileExtensionFilter(dtableGraphType.getSuffix()))) { directoryStream.forEach((path) -> updateGraphElementPath(source, destination, Paths.convert(path))); } }
@Override public void postProcess(final Path path) { try (final DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream = ioService.newDirectoryStream(getParentFolder(path), new FileExtensionFilter(dtableGraphType.getSuffix()))) { directoryStream.forEach((p) -> updateGraphReferences(path, Paths.convert(p))); } }
@Test public void checkSimpleWildcardPattern() { assertEquals( "*." + type.getSuffix(), type.getSimpleWildcardPattern() ); }
@Test public void checkSimpleWildcardPattern() { assertEquals( "*." + type.getSuffix(), type.getSimpleWildcardPattern() ); }