Last active
February 17, 2016 19:41
-
-
Save Pacane/7ef0b293a9c1a2a869db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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