HTMLSerialization implements Serialization { public <T> Serializer from(T object, String alias) { result.include(alias, object); result.use(page()).defaultView(); return new IgnoringSerializer(); } HTMLSerialization(Result result, TypeNameExtractor extractor); boolean accepts(String format); Serializer from(T object, String alias); Serializer from(T object);  }
@Test public void shouldForwardToDefaultViewWithoutAlias() throws Exception { serialization.from(new Object()); verify(pageResult).defaultView(); }
@Test public void shouldForwardToDefaultViewWithAlias() throws Exception { serialization.from(new Object(), "Abc"); verify(pageResult).defaultView(); }
@Test public void shouldIncludeOnResultWithoutAlias() throws Exception { Object object = new Object(); when(extractor.nameFor(Object.class)).thenReturn("obj"); serialization.from(object); verify(result).include("obj", object); }
@Test public void shouldIncludeOnResultWithAlias() throws Exception { Object object = new Object(); serialization.from(object, "Abc"); verify(result).include("Abc", object); }
@Test public void shouldReturnAnIgnoringSerializerWithoutAlias() throws Exception { Serializer serializer = serialization.from(new Object()); assertThat(serializer, is(instanceOf(IgnoringSerializer.class))); }
@Test public void shouldReturnAnIgnoringSerializerWithAlias() throws Exception { Serializer serializer = serialization.from(new Object(), "Abc"); assertThat(serializer, is(instanceOf(IgnoringSerializer.class))); }