CredentialsValidator { @Nullable @VisibleForTesting protected int validateFields(AptoideCredentials credentials) { if (isEmpty(credentials.getEmail()) && isEmpty(credentials.getCode())) { return AccountValidationException.EMPTY_EMAIL_AND_CODE; } else if (isEmpty(credentials.getCode())) { return AccountValidationException.EMPTY_CODE; } else if (isEmpty(credentials.getEmail())) { return AccountValidationException.EMPTY_EMAIL; } return -1; }  Completable validate(AptoideCredentials credentials); Single<Boolean> isEmailValid(String email);  }
@Test public void validateSuccessTest() { validCredentials = new AptoideCredentials("test@test.com", "mypasstest1", true, "", ""); result = credentialsValidator.validateFields(validCredentials); assertEquals(-1, result); }
@Test public void validateEmptyCredentialsErrorTest() { emptyCredentials = new AptoideCredentials("", "", true, "", ""); result = credentialsValidator.validateFields(emptyCredentials); assertEquals(AccountValidationException.EMPTY_EMAIL_AND_CODE, result); }
@Test public void validateEmptyEmailCredentialsErrorTest() { emptyEmailCredentials = new AptoideCredentials("", "test1", true, "", ""); result = credentialsValidator.validateFields(emptyEmailCredentials); assertEquals(AccountValidationException.EMPTY_EMAIL, result); }
@Test public void validateEmptyPasswordCredentialsErrorTest() { emptyPasswordCredentials = new AptoideCredentials("test@test.com", "", true, "", ""); result = credentialsValidator.validateFields(emptyPasswordCredentials); assertEquals(AccountValidationException.EMPTY_CODE, result); }