<commit_before>package com.example.users;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import java.util.HashMap;
import java.util.Map;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc(secure = false)
public class UsersControllerTest {

  @Autowired
  UsersRepository usersRepository;

  @Autowired
  MockMvc mvc;

  @Before
  public void setup() {
    usersRepository.deleteAll();
  }

  @Test
  public void userController_createsUser() throws Exception {

    Map<String, Object> payload = new HashMap<String, Object>() {
      {
        put("email", "<EMAIL>");
      }
    };

    ObjectMapper mapper = new ObjectMapper();

    String json = mapper.writeValueAsString(payload);

    MockHttpServletRequestBuilder request = post("/users")
      .contentType(MediaType.APPLICATION_JSON)
      .accept(MediaType.APPLICATION_JSON)
      .content(json);

    mvc
      .perform(request)
      .andExpect(status().isOk())
      .andExpect(jsonPath("$.id", notNullValue()));
  }

  @Test
  public void userController_getsAUser() throws Exception {

    User user = new User();
    user.setEmail("<EMAIL>");

    usersRepository.save(user);

    MockHttpServletRequestBuilder getRequest = get("/users")
      .contentType(MediaType.APPLICATION_JSON)
      .accept(MediaType.APPLICATION_JSON);

    mvc.perform(getRequest)
      .andExpect(status().is2xxSuccessful())
      .andExpect(jsonPath("$[0].id", notNullValue()))
      .andExpect(jsonPath("$[0].email", equalTo("<EMAIL>")));
  }
}<commit_msg>fix typo in user test.<commit_after>package com.example.users;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import java.util.HashMap;
import java.util.Map;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc(secure = false)
public class UsersControllerTest {

  @Autowired
  UsersRepository usersRepository;

  @Autowired
  MockMvc mvc;

  @Before
  public void setup() {
    usersRepository.deleteAll();
  }

  @Test
  public void userController_createsUser() throws Exception {

    Map<String, Object> payload = new HashMap<String, Object>() {
      {
        put("email", "<EMAIL>");
      }
    };

    ObjectMapper mapper = new ObjectMapper();

    String json = mapper.writeValueAsString(payload);

    MockHttpServletRequestBuilder request = post("/users")
      .contentType(MediaType.APPLICATION_JSON)
      .accept(MediaType.APPLICATION_JSON)
      .content(json);

    mvc
      .perform(request)
      .andExpect(status().isOk())
      .andExpect(jsonPath("$.id", notNullValue()));
  }

  @Test
  public void userController_getsAUser() throws Exception {

    User user = new User();
    user.setEmail("<EMAIL>");

    usersRepository.save(user);

    MockHttpServletRequestBuilder getRequest = get("/users")
      .contentType(MediaType.APPLICATION_JSON)
      .accept(MediaType.APPLICATION_JSON);

    mvc.perform(getRequest)
      .andExpect(status().is2xxSuccessful())
      .andExpect(jsonPath("$[0].id", notNullValue()))
      .andExpect(jsonPath("$[0].email", equalTo("<EMAIL>")));
  }
}
{'fraction_non_alphanumeric': 0.11779948176200918, 'fraction_numerical': 0.0015945784333266893, 'mean_word_length': 4.79445727482679, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6962363', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1478, 'n_words': 242}