<commit_before>package com.bogdan;

import com.bogdan.domain.*;
import com.bogdan.domain.httpbinbody.HttpBinBody;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.jayway.restassured.RestAssured;
import com.jayway.restassured.internal.mapper.ObjectMapperType;
import com.jayway.restassured.response.Cookie;
import com.jayway.restassured.response.Cookie.Builder;
import com.jayway.restassured.response.Cookies;
import com.jayway.restassured.response.Response;
import org.json.JSONException;
import org.skyscreamer.jsonassert.JSONAssert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import static com.jayway.restassured.RestAssured.given;
import static com.jayway.restassured.http.ContentType.JSON;
import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath;
import static java.util.Optional.of;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.testng.Assert.assertEquals;

/**
 * Created by zoomout on 12/10/16.
 */
public class RestTest {
    ObjectMapper jacksonObjectMapper = new ObjectMapper();

    @BeforeClass
    public void setup() {
        RestAssured.baseURI = "http://httpbin.org";
    }

    @Test
    public void fluentSettersAndAssertJ() throws IOException {

        ExternalDTO requestBody = generateExternalDTO();

        ExternalDTO responseBody = sendRequestAndExtractExternalDTOFromResponse(requestBody);

        responseBody.setName("Another Name");
        assertThat(responseBody).isEqualToIgnoringGivenFields(requestBody, "name");

    }

    private ExternalDTO sendRequestAndExtractExternalDTOFromResponse(ExternalDTO externalDTO)
      throws IOException {

        String requestBodyJson = jacksonObjectMapper.writeValueAsString(externalDTO);

        Response response = given().
          contentType(JSON).
          body(requestBodyJson).
          when().<commit_msg>added one more test with null expected value<commit_after>package com.bogdan;

import com.bogdan.domain.*;
import com.bogdan.domain.httpbinbody.HttpBinBody;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.jayway.restassured.RestAssured;
import com.jayway.restassured.internal.mapper.ObjectMapperType;
import com.jayway.restassured.response.Cookie;
import com.jayway.restassured.response.Cookie.Builder;
import com.jayway.restassured.response.Cookies;
import com.jayway.restassured.response.Response;
import org.json.JSONException;
import org.skyscreamer.jsonassert.JSONAssert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import static com.jayway.restassured.RestAssured.given;
import static com.jayway.restassured.http.ContentType.JSON;
import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath;
import static java.util.Optional.of;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.testng.Assert.assertEquals;

/**
 * Created by zoomout on 12/10/16.
 */
public class RestTest {
    ObjectMapper jacksonObjectMapper = new ObjectMapper();

    @BeforeClass
    public void setup() {
        RestAssured.baseURI = "http://httpbin.org";
    }

    @Test
    public void fluentSettersAndAssertJWithNotSetField() throws IOException {

        ExternalDTO requestBody = generateExternalDTO();

        ExternalDTO responseBody = sendRequestAndExtractExternalDTOFromResponse(requestBody);

        responseBody.setInternalDTO(null);

        assertThat(responseBody).isEqualToComparingFieldByFieldRecursively(requestBody.setInternalDTO(null));

    }

    @Test
    public void fluentSettersAndAssertJ() throws IOException {

        ExternalDTO requestBody = generateExternalDTO();

        ExternalDTO responseBody = sendRequestAndExtractExternalDTOFromResponse(requestBody);

        responseBody.setName("Another Name");
        responseBody.setInternalDTO(null);
        assertThat(responseBody).isEqualToIgnoringGivenFields(requestBody, "name");

    }

    private ExternalDTO sendRequestAndExtractExternalDTOFromResponse(ExternalDTO externalDTO)
      throws IOException {

        String requestBodyJson = jacksonObjectMapper.writeValueAsString(externalDTO);

        Response response = given().
          contentType(JSON).
          body(requestBodyJson).
          when().
{'fraction_non_alphanumeric': 0.09080188679245282, 'fraction_numerical': 0.0023584905660377358, 'mean_word_length': 4.829324169530355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '5097258', 'n_tokens_mistral': 1503, 'n_tokens_neox': 1460, 'n_words': 259}