Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
@RunWith(JukitoRunner.class)
public class UserPresenterTest {
// ...
private static final int USER_ID = 23423890;
@Inject
private UserPresenter presenter;
@Inject
private UserPresenter.MyView view;
@Inject
private ResourceDelegate<UserApi> userApiResourceDelegate;
@Inject
private UserApi userApi;
@Before
public void setUp() {
givenDelegate(userApiResourceDelegate).useResource(userApi);
}
@Test
public void prepareFromRequest_displayUsername() {
PlaceRequest placeRequest = createPlaceRequestWithUserId(USER_ID);
User user = createUser(USER_ID, A_USERNAME);
givenDelegate(userApiResourceDelegate)
.succeed().withResult(user)
.when().getUser(USER_ID);
presenter.prepareFromRequest(placeRequest);
verify(view).displayUser(same(user));
}
private PlaceRequest createPlaceRequestWithUserId(int userId) {
return new PlaceRequest.Builder()
.with(NameTokens.PARAM_ID, String.valueOf(userId))
.build();
}
private User createUser(int userId, String aUsername) {
User user = new User();
user.setId(userId);
user.setName(aUsername);
return user;
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment