コード例 #1
0
  @Test
  public void whenThereIsNoFormatGivenShouldForwardToDefaultPage() {
    when(formatResolver.getAcceptFormat()).thenReturn(null);

    Serializer serializer = representation.from(new Object());

    assertThat(serializer, is(instanceOf(IgnoringSerializer.class)));

    verify(status).notAcceptable();
  }
コード例 #2
0
  @Test
  public void shouldSend404IfNothingIsRendered() {
    when(formatResolver.getAcceptFormat()).thenReturn(null);

    Serializer serializer = representation.from(null);

    assertThat(serializer, is(instanceOf(IgnoringSerializer.class)));

    verify(status).notFound();
  }
コード例 #3
0
  @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);
  }
コード例 #4
0
  @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);
  }