public void onCreateAccountButtonClicked(Go99ApplicationconfigureApplication) {
Log.i(TAG, " On create account button clicked");
PasswordAndEmailValidator passwordAndEmailValidator = new PasswordAndEmailValidator();
if (signUpView.getFirstName().isEmpty() || signUpView.getLastName().isEmpty() || signUpView.getEmailAddress().isEmpty() || signUpView.getPassword().isEmpty()
|| signUpView.getConfirmPassword().isEmpty()) {
signUpView.showErrorMessage("Field empty");
return;
}
if (!passwordAndEmailValidator.validatePassword(signUpView.getPassword())) {
signUpView.showErrorMessage("Password must be a at least 6 characters long.");
return;
}
if (!signUpView.getConfirmPassword().equals(signUpView.getPassword())) {
signUpView.showErrorMessage("Passwords don't match");
return;
}
RequestGSON requestGSON = new RequestGSON();
requestGSON.setEmail(signUpView.getEmailAddress().replaceAll("\\s", "").toLowerCase());
requestGSON.setFirstName(signUpView.getFirstName());
requestGSON.setLastName(signUpView.getLastName());
requestGSON.setPassword(signUpView.getPassword());
creationService.createUser(requestGSON).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SingleSubscriber<RestResponse>() {
@Override
public void onSuccess(RestResponse value) {
Object data = value.getData();
String dataString = gson.toJson(data);
CreatedUserObjectData createdUserObjectData = gson.fromJson(dataString, CreatedUserObjectData.class);
signUpView.login(configureApplication, createdUserObjectData.getUserId(), signUpView.getEmailAddress().toLowerCase().replaceAll("\\s", ""), signUpView.getPassword());
}
@Override
public void onError(Throwable error) {
}
});
}
このメソッドをテストする必要があります。私はMockitoを使用しています。 RxJavaを使用しているときにonSuccess()メソッドのテストを手伝ってください。ユニットテストOnSuccess in RxJava
SignUpView.login(...)を確認する必要があります。 – Rick