<commit_before>package com.coding4people.mosquitoreport.api.controllers;

import static org.junit.Assert.assertEquals;

import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;

import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Test;

import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.controllers.FocusController.FocusPostInput;

public class FocusControllerTest extends WithServer {
    @Override
    protected ResourceConfig configure() {
        return super.configure().register(FocusController.class);
    }

    @Test
    public void testGetIt() {
        FocusPostInput data = new FocusPostInput();
        data.setLatitude("lat");
        data.setLongitude("lng");
        
        Response response = target().path("/focus").request()
                .post(Entity.json(data));

        assertEquals(200, response.getStatus());
        assertEquals("application/json;charset=UTF-8", response.getHeaderString("Content-type"));
        assertEquals("\"lat\"", response.readEntity(String.class));
    }
}<commit_msg>Mock FocusRepository<commit_after>package com.coding4people.mosquitoreport.api.controllers;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.verify;

import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;

import org.glassfish.jersey.server.ResourceConfig;
import org.junit.Test;
import org.mockito.Mock;

import com.coding4people.mosquitoreport.api.WithServer;
import com.coding4people.mosquitoreport.api.controllers.FocusController.FocusPostInput;
import com.coding4people.mosquitoreport.api.models.Focus;
import com.coding4people.mosquitoreport.api.repositories.FocusRepository;

public class FocusControllerTest extends WithServer {
    @Mock
    private FocusRepository focusRepository;
    
    @Override
    protected ResourceConfig configure() {
        return super.configure().register(FocusController.class);
    }

    @Test
    public void testGetIt() {
        FocusPostInput data = new FocusPostInput();
        data.setLatitude("01234");
        data.setLongitude("56789");
        
        Response response = target().path("/focus").request()
                .post(Entity.json(data));
        
        assertEquals(200, response.getStatus());
        assertEquals("application/json;charset=UTF-8", response.getHeaderString("Content-type"));
        
        verify(focusRepository).save(any(Focus.class));
        Focus focus = response.readEntity(Focus.class);
        
        assertNotNull(focus.getGuid());
        assertEquals("01234", focus.getLatitude());
        assertEquals("56789", focus.getLongitude());
        assertNotNull(focus.getCreateAt());
    }
}
{'fraction_non_alphanumeric': 0.11651865008880995, 'fraction_numerical': 0.012788632326820605, 'mean_word_length': 3.8219178082191783, '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': '6991762', 'n_tokens_mistral': 808, 'n_tokens_neox': 766, 'n_words': 124}