<commit_before>package com.taxtelecom.chelnyedu.dropwizard;

import com.taxtelecom.chelnyedu.dropwizard.dao.ContactDAO;
import com.taxtelecom.chelnyedu.dropwizard.representations.Contact;
import com.taxtelecom.chelnyedu.dropwizard.resources.ContactResources;
import org.junit.Test;

import javax.validation.Validation;
import javax.validation.Validator;
import java.net.URISyntaxException;

import static org.fest.assertions.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

import javax.validation.ValidatorFactory;
import javax.ws.rs.core.Response;

/**
 * Created by user on 13.07.17.
 */
public class TestValidation {
    private Contact contact = new Contact(1, "John", "Doe", "+123456789");
    private Validator validator;
    private ContactDAO dao = mock(ContactDAO.class);


    @Test
    public void validationContact() throws URISyntaxException {
        ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
        Validator validator = vf.getValidator();
        ContactResources res = new ContactResources(dao, validator);
        Response response = res.createContact(contact);
        assertThat(response.getStatus()).isEqualTo(400);
        response = res.updateContact(1, contact);
        assertThat(response.getStatus()).isEqualTo(400);
    }

}<commit_msg>validation test2 by Sagel<commit_after>package com.taxtelecom.chelnyedu.dropwizard;

import com.taxtelecom.chelnyedu.dropwizard.dao.ContactDAO;
import com.taxtelecom.chelnyedu.dropwizard.representations.Contact;
import com.taxtelecom.chelnyedu.dropwizard.resources.ContactResources;
import org.junit.Test;

import javax.validation.Validation;
import javax.validation.Validator;
import java.net.URISyntaxException;

import static org.fest.assertions.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

import javax.validation.ValidatorFactory;
import javax.ws.rs.core.Response;

/**
 * Created by user on 13.07.17.
 */
public class TestValidation {
    private Contact contact;
    private ContactDAO dao = mock(ContactDAO.class);


    @Test
    public void validationContact() throws URISyntaxException {
        ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
        Validator validator = vf.getValidator();
        contact = new Contact(1, "John", "Doe", "+123456789");
        ContactResources res = new ContactResources(dao, validator);
        Response response = res.createContact(contact);
        assertThat(response.getStatus()).isEqualTo(400);
        response = res.updateContact(1, contact);
        assertThat(response.getStatus()).isEqualTo(400);
    }

    @Test
    public void badRequestTest() throws URISyntaxException {
        contact = new Contact(1,"1","1","1");
        ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
        Validator validator = vf.getValidator();
        ContactResources resources = new ContactResources(dao, validator);
        Response response = resources.createContact(contact);
        assertThat(response.getStatus()).isEqualTo(400);
        response = resources.updateContact(1, contact);
         assertThat(response.getStatus()).isEqualTo(400);
    }

}
{'fraction_non_alphanumeric': 0.10486418193303854, 'fraction_numerical': 0.01831964624131396, 'mean_word_length': 4.367796610169491, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1219941', 'n_tokens_mistral': 923, 'n_tokens_neox': 882, 'n_words': 177}