@Test public void testWriteConfig() throws FileNotFoundException { final File out = new File("test_psm.xml"); @SuppressWarnings("unchecked") final PsmConfig<Type> documentation = mock(PsmConfig.class); final List<PsmDocument<Type>> configList = new ArrayList<PsmDocument<Type>>(); final PsmResource resource = new PsmResource("test_resource"); final PsmCollection psmCollection = new PsmCollection("test_collection"); final Type mockType = mock(Type.class); when(mockType.getName()).thenReturn(""); final PsmDocument<Type> psmDoc = new PsmDocument<Type>(mockType, resource, psmCollection); configList.add(psmDoc); when(documentation.getDocuments()).thenReturn(configList); final Model model = mock(Model.class); PsmConfigWriter.writeConfig(documentation, model, out.getAbsolutePath()); final ModelIndex mockIndex = mock(ModelIndex.class); final Set<ModelElement> mockElementSet = new TreeSet<ModelElement>(); mockElementSet.add(mock(ClassType.class)); when(mockIndex.lookupByName(any(QName.class))).thenReturn(mockElementSet); PsmConfig<Type> config = PsmConfigReader.readConfig(out.getAbsoluteFile(), mockIndex); assertNotNull(config); assertEquals("test_resource", config.getDocuments().get(0).getGraphAssociationEndName().getName()); assertEquals("test_collection", config.getDocuments().get(0).getSingularResourceName().getName()); out.deleteOnExit(); }
public static final void writeConfig(final PsmConfig<Type> documentation, final Model model, final OutputStream outstream) { final XMLOutputFactory xof = XMLOutputFactory.newInstance(); try { final XMLStreamWriter xsw = new IndentingXMLStreamWriter(xof.createXMLStreamWriter(outstream, "UTF-8")); xsw.writeStartDocument("UTF-8", "1.0"); try { writeRoot(documentation, model, xsw); } finally { xsw.writeEndDocument(); } xsw.flush(); xsw.close(); } catch (final XMLStreamException e) { throw new PsmConfigRuntimeException(e); } }
PsmConfigWriter { public static final void writeConfig(final PsmConfig<Type> documentation, final Model model, final OutputStream outstream) { final XMLOutputFactory xof = XMLOutputFactory.newInstance(); try { final XMLStreamWriter xsw = new IndentingXMLStreamWriter(xof.createXMLStreamWriter(outstream, "UTF-8")); xsw.writeStartDocument("UTF-8", "1.0"); try { writeRoot(documentation, model, xsw); } finally { xsw.writeEndDocument(); } xsw.flush(); xsw.close(); } catch (final XMLStreamException e) { throw new PsmConfigRuntimeException(e); } } }
PsmConfigWriter { public static final void writeConfig(final PsmConfig<Type> documentation, final Model model, final OutputStream outstream) { final XMLOutputFactory xof = XMLOutputFactory.newInstance(); try { final XMLStreamWriter xsw = new IndentingXMLStreamWriter(xof.createXMLStreamWriter(outstream, "UTF-8")); xsw.writeStartDocument("UTF-8", "1.0"); try { writeRoot(documentation, model, xsw); } finally { xsw.writeEndDocument(); } xsw.flush(); xsw.close(); } catch (final XMLStreamException e) { throw new PsmConfigRuntimeException(e); } }  }
PsmConfigWriter { public static final void writeConfig(final PsmConfig<Type> documentation, final Model model, final OutputStream outstream) { final XMLOutputFactory xof = XMLOutputFactory.newInstance(); try { final XMLStreamWriter xsw = new IndentingXMLStreamWriter(xof.createXMLStreamWriter(outstream, "UTF-8")); xsw.writeStartDocument("UTF-8", "1.0"); try { writeRoot(documentation, model, xsw); } finally { xsw.writeEndDocument(); } xsw.flush(); xsw.close(); } catch (final XMLStreamException e) { throw new PsmConfigRuntimeException(e); } }  static final void writeConfig(final PsmConfig<Type> documentation, final Model model,
            final OutputStream outstream); static final void writeConfig(final PsmConfig<Type> documentation, final Model model, final String fileName); }
PsmConfigWriter { public static final void writeConfig(final PsmConfig<Type> documentation, final Model model, final OutputStream outstream) { final XMLOutputFactory xof = XMLOutputFactory.newInstance(); try { final XMLStreamWriter xsw = new IndentingXMLStreamWriter(xof.createXMLStreamWriter(outstream, "UTF-8")); xsw.writeStartDocument("UTF-8", "1.0"); try { writeRoot(documentation, model, xsw); } finally { xsw.writeEndDocument(); } xsw.flush(); xsw.close(); } catch (final XMLStreamException e) { throw new PsmConfigRuntimeException(e); } }  static final void writeConfig(final PsmConfig<Type> documentation, final Model model,
            final OutputStream outstream); static final void writeConfig(final PsmConfig<Type> documentation, final Model model, final String fileName);  }