package <%=packageName%>.web.rest;
<% if (databaseType == 'cassandra') { %>
import <%=packageName%>.AbstractCassandraTest;<% } %>
import <%=packageName%>.<%= mainClass %>;
import <%=packageName%>.domain.User;
import <%=packageName%>.repository.UserRepository;
import <%=packageName%>.service.UserService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

import javax.inject.Inject;

import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

/**
 * Test class for the UserResource REST controller.
 *
 * @see UserResource
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = <%= mainClass %>.class)
public class UserResourceIntTest <% if (databaseType == 'cassandra') { %>extends AbstractCassandraTest <% } %>{

    @Inject
    private UserRepository userRepository;

    @Inject
    private UserService userService;

    private MockMvc restUserMockMvc;

    @Before
    public void setup() {
        UserResource userResource = new UserResource();
        ReflectionTestUtils.setField(userResource, "userRepository", userRepository);
        ReflectionTestUtils.setField(userResource, "userService", userService);
        this.restUserMockMvc = MockMvcBuilders.standaloneSetup(userResource).build();
    }

    @Test
    public void testGetExistingUser() throws Exception {
        restUserMockMvc.perform(get("/api/users/admin")
                .accept(MediaType.APPLICATION_JSON))
                .andExpect(status().isOk())
                .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
                .andExpect(jsonPath("$.lastName").value("Administrator"));
    }

    @Test
    public void testGetUnknownUser() throws Exception {
        restUserMockMvc.perform(get("/api/users/unknown")
                .accept(MediaType.APPLICATION_JSON))
                .andExpect(status().isNotFound());
    }

    <%_ if (enableSocialSignIn) { _%>
    @Test
    public void testGetExistingUserWithAnEmailLogin() throws Exception {
        User user = userService.createUser("john.doe@localhost.com", "johndoe", "John", "Doe", "john.doe@localhost.com", "en-US");

        restUserMockMvc.perform(get("/api/users/john.doe@localhost.com")
                .accept(MediaType.APPLICATION_JSON))
                .andExpect(status().isOk())
                .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
                .andExpect(jsonPath("$.login").value("john.doe@localhost.com"));

        userRepository.delete(user);
    }

    @Test
    public void testDeleteExistingUserWithAnEmailLogin() throws Exception {
        User user = userService.createUser("john.doe@localhost.com", "johndoe", "John", "Doe", "john.doe@localhost.com", "en-US");

        restUserMockMvc.perform(delete("/api/users/john.doe@localhost.com")
                .accept(MediaType.APPLICATION_JSON))
                .andExpect(status().isOk());

        assertThat(userRepository.findOneByLogin("john.doe@localhost.com").isPresent()).isFalse();

        userRepository.delete(user);
    }
    <%_ } _%>
}

@@ -298,16 +298,109 @@
 ervice;%0A
+%3C%25 if (databaseType == 'sql') %7B %25%3E%0Aimport org.apache.commons.lang3.RandomStringUtils;%3C%25 %7D %25%3E%0A
 import o
@@ -843,17 +843,132 @@
 .Inject;
-%0A
+%3C%25 if (databaseType == 'sql') %7B %25%3E%0Aimport javax.persistence.EntityManager;%3C%25 %7D %25%3E%0A%0A%3C%25_ if (enableSocialSignIn) %7B _%25%3E
 %0Aimport 
@@ -1108,16 +1108,26 @@
 delete;%0A
+%3C%25_ %7D _%25%3E%0A
 import s
@@ -1707,16 +1707,694 @@
 MockMvc;
+%0A%3C%25_ if (databaseType == 'sql') %7B _%25%3E%0A%0A    /**%0A     * Create a User.%0A     *%0A     * This is a static method, as tests for other entities might also need it,%0A     * if they test an entity which has a required relationship to the User entity.%0A     */%0A    public static User createEntity(EntityManager em) %7B%0A        User user = new User();%0A        user.setLogin(%22test%22);%0A        user.setPassword(RandomStringUtils.random(60));%0A        user.setActivated(true);%0A        user.setEmail(%22test@test.com%22);%0A        user.setFirstName(%22test%22);%0A        user.setLastName(%22test%22);%0A        user.setLangKey(%22en%22);%0A        em.persist(user);%0A        em.flush();%0A        return user;%0A    %7D%0A%3C%25_ %7D _%25%3E
 %0A%0A    @B
@@ -3361,25 +3361,24 @@
 d());%0A    %7D%0A
-%0A
     %3C%25_ if (
@@ -3403,16 +3403,17 @@
 ) %7B _%25%3E%0A
+%0A
     @Tes

Add a static method for entities that require a relationship to the User