@Before public void setUp() throws Exception { handler = new ProjectConfigurationContentHandler(); }
public String toString(final ProjectImports configuration) { if (configuration == null) { return ""; } return createXStream().toXML(configuration); }
public void saveProjectImports(final Path path) { if (ioService.exists(Paths.convert(path))) { throw new FileAlreadyExistsException(path.toString()); } else { ioService.write(Paths.convert(path), projectConfigurationContentHandler.toString(createProjectImports())); } }
@Override public ProjectImports load(final Path path) { try { final org.uberfire.java.nio.file.Path nioPath = Paths.convert(path); if (!ioService.exists(nioPath)) { saveProjectImports(path); } final String content = ioService.readAllString(Paths.convert(path)); final ProjectImports projectImports = projectConfigurationContentHandler.toModel(content); // java.lang.Number imported by default in new guided rule // include it into project imports if not present already final Import javaLangNumber = new Import(Number.class); if (projectImports.getImports().getImports().stream().noneMatch(anImport -> Objects.equals(anImport, javaLangNumber))) { projectImports.getImports().addImport(javaLangNumber); } return projectImports; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Test public void testNullModel() throws Exception { String xml = handler.toString(null); assertEquals("", xml); }
@Test public void testNullSourceXml() throws Exception { ProjectImports imports = handler.toModel(null); assertNotNull(imports); assertEquals(0, imports.getImports().getImports().size()); }
@Override public Path save(final Path resource, final ProjectImports projectImports, final Metadata metadata, final String comment) { try { ioService.write(Paths.convert(resource), projectConfigurationContentHandler.toString(projectImports), metadataService.setUpAttributes(resource, metadata)); //The pom.xml, kmodule.xml and project.imports are all saved from ProjectScreenPresenter //We only raise InvalidateDMOProjectCacheEvent and ResourceUpdatedEvent(pom.xml) events once //in POMService.save to avoid duplicating events (and re-construction of DMO). return resource; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } }
@Test public void testEmptySourceXml() throws Exception { ProjectImports imports = handler.toModel(""); assertNotNull(imports); assertEquals(0, imports.getImports().getImports().size()); }
@Before public void setUp() throws Exception { handler = new ProjectConfigurationContentHandler(); }
public String toString(final ProjectImports configuration) { if (configuration == null) { return ""; } return createXStream().toXML(configuration); }
@Test public void testNullModel() throws Exception { String xml = handler.toString(null); assertEquals("", xml); }
@Test public void testNullSourceXml() throws Exception { ProjectImports imports = handler.toModel(null); assertNotNull(imports); assertEquals(0, imports.getImports().getImports().size()); }
@Before public void setUp() throws Exception { handler = new ProjectConfigurationContentHandler(); }
public String toString(final ProjectImports configuration) { if (configuration == null) { return ""; } return createXStream().toXML(configuration); }
@Test public void testNullModel() throws Exception { String xml = handler.toString(null); assertEquals("", xml); }
@Test public void testEmptySourceXml() throws Exception { ProjectImports imports = handler.toModel(""); assertNotNull(imports); assertEquals(0, imports.getImports().getImports().size()); }
@Before public void setUp() throws Exception { super.startWeld(); //Instantiate Paths used in tests for Path conversion final Bean pathsBean = beanManager.getBeans(Paths.class).iterator().next(); final CreationalContext cc = beanManager.createCreationalContext(pathsBean); Paths paths = (Paths) beanManager.getReference(pathsBean, Paths.class, cc); //Ensure URLs use the default:// scheme fs.forceAsDefault(); final URL packageUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/package-names-white-list"); final org.uberfire.java.nio.file.Path nioPackagePath = fs.getPath(packageUrl.toURI()); final ProjectConfigurationContentHandler contentHandler = new ProjectConfigurationContentHandler(); pathToImports = paths.convert(nioPackagePath); projectImportsService = new ProjectImportsServiceImpl(ioService, contentHandler, renameService, saveAndRenameService); }
public ProjectImports toModel(final String text) { if (text == null || text.isEmpty()) { return new ProjectImports(); } return (ProjectImports) createXStream().fromXML(text); }
@Test public void testEmptyImports() throws Exception { String xml = handler.toString(new ProjectImports()); assertTrue(xml.contains("<imports>")); assertTrue(xml.contains("</imports>")); }
@Test public void testEmptySourceXml() throws Exception { ProjectImports imports = handler.toModel(""); assertNotNull(imports); assertEquals(0, imports.getImports().getImports().size()); }