@Test
  public void testGetRandomAccountsForManyUsers() throws Exception {

    when(userRepository.getAllUsers()).thenReturn(Lists.newArrayList(user, user, user));
    when(accountFactory.getAccounts(user))
        .thenReturn(Lists.newArrayList(account, account, account));
    controller.setMaxRandomAccount(2);

    handlerAdapter.handle(request, response, controller);

    assertThat(response.getStatus(), equalTo(200));
    JsonNode jsonNode = toJsonNode(response.getContentAsString());
    assertThat(jsonNode.size(), equalTo(2));
  }
  @Test
  public void testGetRandomAccountForAUser() throws Exception {

    when(userRepository.getAllUsers()).thenReturn(Lists.newArrayList(user));
    when(accountFactory.getAccounts(user)).thenReturn(Lists.newArrayList(account));
    controller.setMaxRandomAccount(1);

    handlerAdapter.handle(request, response, controller);

    assertThat(response.getStatus(), equalTo(200));
    JsonNode jsonNode = toJsonNode(response.getContentAsString());
    assertThat(jsonNode.size(), equalTo(1));
    JsonNode connx = jsonNode.get(0);
    JsonNode keyNode = connx.get("key");
    assertThat(keyNode.get("providerId").getValueAsText(), equalTo("provider"));
  }