コード例 #1
0
  @Test
  public void testContent() throws Exception {

    List<Tutorial> tutorials =
        Arrays.asList(
            new Tutorial(1, "Guava", "Introduction to Guava", "GuavaAuthor"),
            new Tutorial(2, "Android", "Introduction to Android", "AndroidAuthor"));
    Mockito.when(mainController.getTutService().listTutorials()).thenReturn(tutorials);

    String view = mainController.listTutorialsPage(model);

    verify(mainController.getTutService(), times(1)).listTutorials();
    verifyNoMoreInteractions(mainController.getTutService());

    assertEquals("index", view);
    assertEquals(tutorials, model.asMap().get("tutorials"));
  }
コード例 #2
0
  @Test
  public void shouldGoToTutorialListView() {
    Mockito.when(mainController.getTutService().listTutorials()).thenReturn(createTutorialList());

    final String view = mainController.listTutorialsPage(model);
    final List<Tutorial> tutorialListAttribute = (List<Tutorial>) model.asMap().get("tutorials");

    assertEquals("index", view);
    assertNotNull(tutorialListAttribute);
  }