MacroLibrary { public void add(final XMLUtil util, final OdsDocument document) throws IOException { final String nameSlash = MacroLibraryContainer.CONTAINER_NAME_SLASH + this.name + "/"; document.addExtraDir(nameSlash); document.addExtraFile(nameSlash + "script-lb.xml", "text/xml", this.index(util)); for (final MacroModule module : this.modules) { module.add(util, document, nameSlash); } } MacroLibrary(final String name, final boolean readOnly,
                        final List<MacroModule> modules); static MacroLibraryBuilder builder(); void add(final XMLUtil util, final OdsDocument document); void appendIndexLine(final XMLUtil util, final Appendable appendable);  }
@Test public void testAdd() throws IOException { final OdsDocument document = PowerMock.createMock(OdsDocument.class); final MacroLibrary lib = new MacroLibrary("ml", false, Collections.singletonList(this.module)); final Capture<StringBuilder> sb1 = Capture.newInstance(); final Capture<byte[]> bs = Capture.newInstance(); PowerMock.resetAll(); document.addExtraDir("Basic/ml/"); this.module.appendIndexLine(EasyMock.eq(this.util), EasyMock.capture(sb1)); document.addExtraFile(EasyMock.eq("Basic/ml/script-lb.xml"), EasyMock.eq("text/xml"), EasyMock.capture(bs)); this.module.add(this.util, document, "Basic/ml/"); PowerMock.replayAll(); lib.add(this.util, document); PowerMock.verifyAll(); Assert.assertEquals(XMLUtil.XML_PROLOG + "<!DOCTYPE library:library " + "PUBLIC \"- ".dtd\"><library:library xmlns:library=\"http: "library:name=\"ml\" library:readonly=\"false\" " + "library:passwordprotected=\"false\"></library:library>", sb1.toString()); Assert.assertEquals(XMLUtil.XML_PROLOG + "<!DOCTYPE library:library " + "PUBLIC \"- ".dtd\"><library:library xmlns:library=\"http: ".org/2000/library\" " + "library:name=\"ml\" library:readonly=\"false\" " + "library:passwordprotected=\"false\"></library:library>", new String(bs.getValue(), CharsetUtil.UTF_8)); }