@Override public String getSource(Path path) { return ioService.readAllString(path); } }
@Override public String getSource(Path path) { org.uberfire.java.nio.file.Path convertedPath = Paths.convert(path); return ioService.readAllString(convertedPath); }
@Override public IndexBuilder fillIndexBuilder(final Path path) throws Exception { final String drl = ioService.readAllString(path); return fillDrlIndexBuilder(path, drl); }
@Override public IndexBuilder fillIndexBuilder(final Path path) throws Exception { final String drl = ioService.readAllString(path); return fillDrlIndexBuilder(path, drl); }
@Override public String load(final Path path) { try { final String content = ioService.readAllString(Paths.convert(path)); return content; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Override public String readAllString(Path path) throws IllegalArgumentException, NoSuchFileException, IOException { if (!authManager.authorize(toResource(path), getUser())) { throw new SecurityException(); } return service.readAllString(path); }
@Override protected IndexBuilder fillIndexBuilder(Path path) throws Exception { final String drl = ioService.readAllString(path); return fillDrlIndexBuilder(path, drl); }
@Override public IndexBuilder fillIndexBuilder(final Path path) throws Exception { final String dslr = ioService.readAllString(path); final Expander expander = getDSLExpander(path); final String drl = expander.expand(dslr); return fillDrlIndexBuilder(path, drl); }
@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); }
@Override public TemplateModel load(final Path path) { try { final String content = ioService.readAllString(Paths.convert(path)); return (TemplateModel) RuleTemplateModelXMLPersistenceImpl.getInstance().unmarshal(content); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Override public ProjectRepositories load(final Path path) { final org.uberfire.java.nio.file.Path nioPath = Paths.convert(path); if (ioService.exists(nioPath)) { final String content = ioService.readAllString(nioPath); return contentHandler.toModel(content); } else { return create(path); } }
@Override public GlobalsModel load(final Path path) { try { final String content = ioService.readAllString(Paths.convert(path)); return GlobalsPersistence.getInstance().unmarshal(content); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Test public void testAcceptWithDRLFileDeclaringTypeMidFile() { doReturn("cheese." + ObservableDRLFile.EXTENSION).when(path).getFileName(); doReturn("MyType declaration \ndeclare MyType\nend").when(ioService).readAllString(eq(nioPath)); assertTrue(observer.accept(path)); }
@Test public void testAcceptWithDRLFileDeclaringTypeSingleLine() { doReturn("cheese." + ObservableDRLFile.EXTENSION).when(path).getFileName(); doReturn("declare MyType end").when(ioService).readAllString(eq(nioPath)); assertTrue(observer.accept(path)); }
@Test public void testAcceptWithDRLFileNotDeclaringType() { doReturn("cheese." + ObservableDRLFile.EXTENSION).when(path).getFileName(); doReturn("rule test when then end").when(ioService).readAllString(eq(nioPath)); assertFalse(observer.accept(path)); }
@Test public void testLoadModifyScoreAction() throws Exception { final Path path = getPath("modifyScore.rdrl"); final String ruleFileContent = getFileContent("modifyScore.rdrl"); doReturn(ruleFileContent).when(ioService).readAllString(any()); final RuleModel model = service.load(path); Assertions.assertThat(model.rhs).hasSize(1); final FreeFormLine action = (FreeFormLine) model.rhs[0]; Assertions.assertThat(action.getText()).isEqualTo(MODIFY_SCORE_ACTION); }
@Override protected PersistenceDescriptorEditorContent constructContent(Path path, Overview overview) { PersistenceDescriptorEditorContent content = new PersistenceDescriptorEditorContent(); PersistenceDescriptorModel descriptorModel = descriptorService.load(path); content.setDescriptorModel(descriptorModel); content.setOverview(overview); content.setSource(ioService.readAllString(Paths.convert(path))); return content; }
@Test public void retrieveLockInfoNoSuchFileException() { when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(true); when(ioService.readAllString(any(org.uberfire.java.nio.file.Path.class))).thenThrow(new NoSuchFileException()); final LockInfo info = lockService.retrieveLockInfo(path); assertFalse(info.isLocked()); assertNull(info.lockedBy()); }
public void postProcess(Path source, Path destination) { org.uberfire.java.nio.file.Path destinationNioPath = Paths.convert(destination); FormDefinition formDefinition = serializer.deserialize(ioService.readAllString(destinationNioPath)); processFormDefinition(formDefinition, destination); ioService.write(destinationNioPath, serializer.serialize(formDefinition), commentedOptionFactory.makeCommentedOption("Updating form [" + destination.toURI() + "].")); }
@Test public void testReadAllStringFromExistentFile() { final Path filePath = getFilePath(); ioService().createFile(filePath); ioService().write(filePath, "text"); String content = ioService().readAllString(filePath); assertEquals("text", content); }