@@ -0,0 +1,3129 @@
+package org.superdev.coddy.user.api;%0A%0A%0Aimport com.shazam.shazamcrest.MatcherAssert;%0Aimport com.shazam.shazamcrest.matcher.Matchers;%0Aimport org.junit.After;%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.boot.test.context.SpringBootTest;%0Aimport org.springframework.boot.test.web.client.TestRestTemplate;%0Aimport org.springframework.http.*;%0Aimport org.springframework.http.HttpHeaders;%0Aimport org.springframework.test.context.junit4.SpringJUnit4ClassRunner;%0Aimport org.superdev.coddy.Main;%0Aimport org.superdev.coddy.application.data.Response;%0Aimport org.superdev.coddy.application.utils.TestUtils;%0Aimport org.superdev.coddy.user.data.Credential;%0Aimport org.superdev.coddy.user.data.Token;%0Aimport org.superdev.coddy.user.elasticsearch.entity.UserEntity;%0Aimport org.superdev.coddy.user.elasticsearch.repository.UserRepository;%0A%0Aimport java.io.IOException;%0Aimport java.util.Arrays;%0A%0A@RunWith(SpringJUnit4ClassRunner.class)%0A@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,%0A        classes = Main.class)%0Apublic class UserTest %7B%0A%0A    private static final String USER_ENDPOINT = %22/user%22;%0A%0A    private TestRestTemplate restTemplate = new TestRestTemplate();%0A%0A    @Autowired%0A    private UserRepository repository;%0A%0A    @Before%0A    public void populateDataBase() throws IOException %7B%0A        UserEntity%5B%5D users = TestUtils.getObjecFromJson(%22user/user.database.json%22, UserEntity%5B%5D.class);%0A%0A        repository.save(Arrays.asList(users));%0A    %7D%0A%0A    @After%0A    public void dropDatabase() %7B%0A        repository.deleteAll();%0A    %7D%0A%0A    @Test%0A    public void testGetUserWithoutToken() %7B%0A        ResponseEntity%3CResponse%3E response =%0A                restTemplate.getForEntity(TestUtils.getUrl(USER_ENDPOINT + %22/napoleon%22), Response.class);%0A%0A        Response expected = new Response(%22HTTP 401 Unauthorized%22);%0A%0A        Assert.assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode());%0A        MatcherAssert.assertThat(response.getBody(), Matchers.sameBeanAs(expected));%0A    %7D%0A%0A    @Test%0A    public void testGetUserWithToken() throws IOException %7B%0A        Credential credential = new Credential(%22ciceron%22, %22tutu%22.toCharArray());%0A        Token token = restTemplate.postForEntity(TestUtils.getUrl(USER_ENDPOINT + %22/auth%22), credential, Token.class).getBody();%0A%0A        HttpHeaders headers = new HttpHeaders();%0A        headers.add(javax.ws.rs.core.HttpHeaders.AUTHORIZATION, token.getToken());%0A        headers.add(javax.ws.rs.core.HttpHeaders.CONTENT_TYPE, javax.ws.rs.core.MediaType.APPLICATION_JSON);%0A        HttpEntity%3CString%3E entity = new HttpEntity%3C%3E(%22parameters%22, headers);%0A%0A        ResponseEntity%3CUserEntity%3E response = restTemplate.exchange(TestUtils.getUrl(USER_ENDPOINT + %22/ciceron%22), HttpMethod.GET, entity, UserEntity.class);%0A%0A        Assert.assertEquals(HttpStatus.OK, response.getStatusCode());%0A        MatcherAssert.assertThat(response.getBody(), Matchers.sameBeanAs(TestUtils.getObjecFromJson(%22user/getUserWithTokenExpected.json%22, UserEntity.class)));%0A    %7D%0A%7D%0A

add e2e user test