Link implements ParagraphElement { public static LinkBuilder builder(final String text) { return new LinkBuilder(text); } Link(final String text, final TextStyle ts, final String href); static LinkBuilder builder(final String text); @Deprecated static Link create(final String text, final TextStyle ts, final Table table); @Deprecated static Link create(final String text, final Table table); @Deprecated static Link create(final String text, final TextStyle ts, final String relativeRef); @Deprecated static Link create(final String text, final String relativeRef); @Deprecated static Link create(final String text, final TextStyle ts, final File file); @Deprecated static Link create(final String text, final File file); @Deprecated static Link create(final String text, final TextStyle ts, final URL url); @Deprecated static Link create(final String text, final URL url); @Deprecated static Link create(final String text, final TextStyle ts, final URI uri); @Deprecated static Link create(final String text, final TableRef tableRef); @Deprecated static Link create(final String text, final TextStyle ts, final TableRef tableRef); @Deprecated static Link create(final String text, final URI uri); @Override void appendXMLContent(final XMLUtil util, final Appendable appendable); @Override void addEmbeddedStylesFromFooterHeader(final StylesContainer stylesContainer); @Override void addEmbeddedStylesFromCell(final StylesContainer stylesContainer); @Override boolean equals(final Object o); @Override final int hashCode();  }
@Test public final void testTable() throws IOException { final Table table = PowerMock.createMock(Table.class); PowerMock.resetAll(); EasyMock.expect(table.getName()).andReturn("t"); PowerMock.replayAll(); final Link link = Link.builder("table").to(table).build(); TestHelper.assertXMLEquals( "<text:a xlink:href=\"#t\" " + "xlink:type=\"simple\">table</text:a>", link); PowerMock.verifyAll(); }
@Test public final void testStyleTable() throws IOException { final Table table = PowerMock.createMock(Table.class); PowerMock.resetAll(); EasyMock.expect(table.getName()).andReturn("t"); PowerMock.replayAll(); final Link link = Link.builder("table").style(this.ts).to(table).build(); TestHelper.assertXMLEquals("<text:a text:style-name=\"test\" xlink:href=\"#t\" " + "xlink:type=\"simple\">table</text:a>", link); PowerMock.verifyAll(); }
@Test public final void testStyleTableRef() throws IOException { final Link link = Link.builder("table").style(this.ts).to(new TableRef(this.util, "f", "t", 0)) .build(); TestHelper.assertXMLEquals("<text:a text:style-name=\"test\" xlink:href=\"'f'#t\" " + "xlink:type=\"simple\">table</text:a>", link); }
@Test public final void testTableRef() throws IOException { final Link link = Link.builder("table").to(new TableRef(this.util, "f", "t", 0)).build(); TestHelper.assertXMLEquals( "<text:a xlink:href=\"'f'#t\" " + "xlink:type=\"simple\">table</text:a>", link); }
@Test public final void testStyleURL() throws IOException { final Link link = Link.builder("url").style(this.ts) .to(new URL("https: TestHelper.assertXMLEquals( "<text:a text:style-name=\"test\" xlink:href=\"https: ".com/jferard/fastods\" " + "xlink" + ":type=\"simple\">url</text:a>", link); }
@Test public final void testURL() throws IOException { final Link link = Link.builder("url").to(new URL("https: TestHelper.assertXMLEquals( "<text:a xlink:href=\"https: ":type=\"simple\">url</text:a>", link); }
@Test public final void testStyleURI() throws IOException, URISyntaxException { final Link link = Link.builder("A mail").style(this.ts).to(new URI("mailto:mduerst@ifi.unizh.ch")) .build(); TestHelper.assertXMLEquals( "<text:a text:style-name=\"test\" xlink:href=\"mailto:mduerst@ifi.unizh.ch\" " + "xlink" + ":type=\"simple\">A mail</text:a>", link); }
@Test public final void testStyleFile() throws IOException { final File f = new File("generated_files", "fastods_50_5.ods"); final Link link = Link.builder("file").style(this.ts).to(f).build(); TestHelper.assertXMLEquals( "<text:a text:style-name=\"test\" xlink:href=\"" + f.toURI().toString() + "\" xlink:type=\"simple\">file</text:a>", link); }
@Test public final void testFile() throws IOException { final File f = new File("generated_files", "fastods_50_5.ods"); final Link link = Link.builder("file").to(f).build(); TestHelper.assertXMLEquals("<text:a xlink:href=\"" + f.toURI().toString() + "\" xlink:type=\"simple\">file</text:a>", link); }
@Test public final void testStyleString() throws IOException { final Link link = Link.builder("file").style(this.ts).to("s").build(); TestHelper.assertXMLEquals( "<text:a text:style-name=\"test\" xlink:href=\"s\" " + "xlink:type=\"simple\">file</text:a>", link); }
@Test public final void testString() throws IOException { final Link link = Link.builder("file").to("s").build(); TestHelper.assertXMLEquals("<text:a xlink:href=\"s\" xlink:type=\"simple\">file</text:a>", link); }