@Test public void whenThereIsNoFormatGivenShouldForwardToDefaultPage() { when(formatResolver.getAcceptFormat()).thenReturn(null); Serializer serializer = representation.from(new Object()); assertThat(serializer, is(instanceOf(IgnoringSerializer.class))); verify(status).notAcceptable(); }
@Test public void shouldSend404IfNothingIsRendered() { when(formatResolver.getAcceptFormat()).thenReturn(null); Serializer serializer = representation.from(null); assertThat(serializer, is(instanceOf(IgnoringSerializer.class))); verify(status).notFound(); }
@Test public void whenThereIsAFormatGivenShouldUseCorrectSerializer() { when(formatResolver.getAcceptFormat()).thenReturn("xml"); when(serialization.accepts("xml")).thenReturn(true); Object object = new Object(); representation.from(object); verify(serialization).from(object); }
@Test public void whenSerializationDontAcceptsFormatItShouldntBeUsed() { when(formatResolver.getAcceptFormat()).thenReturn("xml"); when(serialization.accepts("xml")).thenReturn(false); Object object = new Object(); representation.from(object); verify(serialization, never()).from(object); }