@@ -0,0 +1,3188 @@
+package com.jmb.springfactory.integration;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0Aimport static org.hamcrest.CoreMatchers.not;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.mockito.Matchers.notNull;%0A%0Aimport java.util.List;%0A%0Aimport javax.persistence.PersistenceException;%0Aimport javax.validation.ValidationException;%0A%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.internal.matchers.GreaterThan;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.boot.autoconfigure.EnableAutoConfiguration;%0Aimport org.springframework.boot.test.context.SpringBootTest;%0Aimport org.springframework.test.context.junit4.SpringRunner;%0A%0Aimport com.jmb.springfactory.SpringFactoryApplication;%0Aimport com.jmb.springfactory.exceptions.NotFoundException;%0Aimport com.jmb.springfactory.model.dto.UserDto;%0Aimport com.jmb.springfactory.model.factory.user.UserDtoFactory;%0Aimport com.jmb.springfactory.model.factory.user.UserSamples;%0A%0A@RunWith(SpringRunner.class)%0A@SpringBootTest(classes = SpringFactoryApplication.class)%0A@EnableAutoConfiguration%0Apublic class UserCrudIntegrationTest %7B%0A%0A  @Autowired%0A  private UserController userController;%0A  %0A  @Test(expected = PersistenceException.class)%0A  public void ifTheUserAlreadyExistThenShouldThrowPersistenceException() %7B%0A%0A    final UserDto newUser = UserDtoFactory.createSampleDefaultUserDto();%0A%0A    userController.create(newUser);%0A    userController.create(newUser);%0A  %7D%0A  %0A  @Test(expected = ValidationException.class)%0A  public void ifUserDtoHaveAnyEmptyFieldThenShouldThrowValidationException() %7B%0A    %0A    final UserDto newUserWithEmptyField = UserDto.builder().build();%0A    %0A    userController.create(newUserWithEmptyField);%0A  %7D%0A  %0A  @Test(expected = NotFoundException.class)%0A  public void whenSearchUserByNifAndNotExistAnyOneThenShouldThrowNotFoundException() %7B%0A    %0A    final String nif = %2211111111Q%22;%0A%0A    userController.findAll(nif, null);%0A  %7D%0A  %0A  @Test(expected = NotFoundException.class)%0A  public void whenSearchUserByNameContainAndNotExistAnyOneThenShouldThrowNotFoundException() %7B%0A    %0A    final String name = %22some name%22;%0A    %0A    userController.findAll(null, name);%0A  %7D%0A  %0A  @Test%0A  public void whenSearchUserByNifAndExistOneThenShouldReturnAListWithAtLeastOneResult() %7B%0A    %0A    final String nif = UserSamples.NIF_USER_TEST_1;%0A    %0A    List%3CUserDto%3E usersWithNif = userController.findAll(nif, null);%0A    %0A    assertThat(usersWithNif)%0A      .isNotNull()%0A      .isNotEmpty();%0A    assert(usersWithNif.stream().anyMatch(user -%3E user.getNif().equals(nif)));%0A  %7D%0A  %0A  @Test %0A  public void whenSearchUserNyNameContainAndExistOneThenShouldReturnAlistWithAtLeastOneResult() %7B%0A    %0A    final String name = UserSamples.NAME_USER_TEST_1;%0A    %0A    List%3CUserDto%3E usersWithName = userController.findAll(null, name);%0A    %0A    assertThat(usersWithName)%0A      .isNotNull()%0A      .isNotEmpty();%0A    assert(usersWithName.stream().anyMatch(user -%3E user.getName().equals(name)));%0A  %7D%0A  %0A  @Test%0A  public void whenSearchUsersWithoutParameterShouldReturnUserDtoList() %7B%0A    %0A    List%3CUserDto%3E allUsers = userController.findAll(null, null);%0A    %0A    assertNotNull(allUsers);%0A  %7D%0A%7D%0A

Implement integration test to crud user feature