@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 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 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 @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)); }