<commit_before>package convalida.validators;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;

/**
 * @author <NAME> on 01/11/2017.
 */
public class EmailValidatorTest extends BaseTest {

    @Test
    public void invalidEmail() throws Exception {
        String value = "test@email";

        EmailValidator validator = new EmailValidator();
        EmailValidator validatorWithEditText = new EmailValidator(mockEditText, errorMessage);
        EmailValidator validatorWithTextInputLayout = new EmailValidator(mockTextInputLayout, errorMessage);

        when(mockEditText.getText().toString()).thenReturn(value);

        assertEquals(validator.isNotValid(value), true);
        assertEquals(validatorWithEditText.validate(), false);
        assertEquals(validatorWithTextInputLayout.validate(), false);
    }

    @Test
    public void validEmail() throws Exception {
        String value = "<EMAIL>";

        EmailValidator validator = new EmailValidator();
        EmailValidator validatorWithEditText = new EmailValidator(mockEditText, errorMessage);
        EmailValidator validatorWithTextInputLayout = new EmailValidator(mockTextInputLayout, errorMessage);

        when(mockEditText.getText().toString()).thenReturn(value);

        assertEquals(validator.isNotValid(value), false);
        assertEquals(validatorWithEditText.validate(), true);
        assertEquals(validatorWithTextInputLayout.validate(), true);
    }

}<commit_msg>Update EmailValidatorTest.java<commit_after>package convalida.validators;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;

/**
 * @author <NAME> on 01/11/2017.
 */
public class EmailValidatorTest extends BaseTest {

    @Test
    public void emailIsNull() {
        EmailValidator validator = new EmailValidator();
        assertEquals(validator.isNotValid(null), true);
    }
    
    @Test
    public void invalidEmail() {
        String value = "test@email";

        EmailValidator validator = new EmailValidator();
        EmailValidator validatorWithEditText = new EmailValidator(mockEditText, errorMessage);
        EmailValidator validatorWithTextInputLayout = new EmailValidator(mockTextInputLayout, errorMessage);

        when(mockEditText.getText().toString()).thenReturn(value);

        assertEquals(validator.isNotValid(value), true);
        assertEquals(validatorWithEditText.validate(), false);
        assertEquals(validatorWithTextInputLayout.validate(), false);
    }

    @Test
    public void validEmail() {
        String value = "<EMAIL>";

        EmailValidator validator = new EmailValidator();
        EmailValidator validatorWithEditText = new EmailValidator(mockEditText, errorMessage);
        EmailValidator validatorWithTextInputLayout = new EmailValidator(mockTextInputLayout, errorMessage);

        when(mockEditText.getText().toString()).thenReturn(value);

        assertEquals(validator.isNotValid(value), false);
        assertEquals(validatorWithEditText.validate(), true);
        assertEquals(validatorWithTextInputLayout.validate(), true);
    }

}
{'fraction_non_alphanumeric': 0.09712116418854792, 'fraction_numerical': 0.00506168933881683, 'mean_word_length': 4.1, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2564705', 'n_tokens_mistral': 794, 'n_tokens_neox': 778, 'n_words': 165}