package com.google.gdata.data; import static org.junit.Assert.*; import java.io.IOException; import org.junit.Assume; import org.junit.Test; import org.mockito.Mockito; import com.google.gdata.data.ILink.Rel; import com.google.gdata.util.common.xml.XmlWriter; public class TestLink { @Test public void generateAtomTest() { Link l = new Link(); XmlWriter writer = Mockito.mock(XmlWriter.class); ExtensionProfile profile = Mockito.mock(ExtensionProfile.class); try { l.generateAtom(writer, profile); } catch (IOException e) { Assume.assumeNoException(e); } l = new Link("rel", "type", "href"); try { l.generateAtom(writer, profile); } catch (IOException e) { Assume.assumeNoException(e); } assertEquals("rel", l.getRel()); assertEquals("type", l.getType()); assertEquals("href", l.getHref()); } @Test public void generateRssTest() { Link l = new Link(); XmlWriter writer = Mockito.mock(XmlWriter.class); try { l.generateRss(writer); } catch (IOException e) { Assume.assumeNoException(e); } l = new Link("comments", "type", "href"); try { l.generateRss(writer); } catch (IOException e) { Assume.assumeNoException(e); } l = new Link(Rel.ALTERNATE, "type", "href"); try { l.generateRss(writer); } catch (IOException e) { Assume.assumeNoException(e); } l = new Link(Rel.VIA, "type", null); try { l.generateRss(writer); } catch (IOException e) { Assume.assumeNoException(e); } l = new Link(Rel.VIA, "type", "href"); try { l.generateRss(writer); } catch (IOException e) { Assume.assumeNoException(e); } } @Test public void matchesTest() { Link l = new Link("rel", "type", "href"); assertFalse(l.matches("relation", "typer")); assertTrue(l.matches("rel", "type")); assertTrue(l.matches(null, null)); } }