package com.yevhenpanko.pcommerce.test;

import com.yevhenpanko.pcommerce.entity.user.User;
import com.yevhenpanko.pcommerce.entity.user.UserRole;
import com.yevhenpanko.pcommerce.repository.UserRepository;
import com.yevhenpanko.pcommerce.service.DefaultUserManagement;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.Test;

import java.util.Optional;

import static com.yevhenpanko.pcommerce.entity.user.Permission.READ_PERMISSIONS;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;

public class UserManagementTest extends AbstractTest {
    private static final Logger LOGGER = LogManager.getLogger(UserManagementTest.class);

    @Autowired
    private DefaultUserManagement userManagement;

    @Autowired
    private UserRepository userRepository;

    @Test
    public void testCreatingUserWithSimpleRole() {
        final UserRole userRole = new UserRole(getUniqueName("test"), READ_PERMISSIONS);
        long userId = userManagement.create(getUniqueName("demo") + "@mail.com", "password", userRole);

        final Optional<User> user = userRepository.findById(userId);
        assertTrue(user.isPresent());

        final UserRole role = user.get().getRole();
        assertNotNull(role);

        userManagement.deleteById(userId);
    }

}

@@ -200,16 +200,80 @@
 sitory;%0A
+import com.yevhenpanko.pcommerce.repository.UserRoleRepository;%0A
 import c
@@ -328,16 +328,16 @@
 gement;%0A
-
 import o
@@ -475,16 +475,58 @@
 owired;%0A
+import org.testng.annotations.AfterClass;%0A
 import o
@@ -1025,16 +1025,211 @@
 itory;%0A%0A
+    @Autowired%0A    private UserRoleRepository userRoleRepository;%0A%0A    @AfterClass%0A    private void cleanUp() %7B%0A        userRepository.deleteAll();%0A        userRoleRepository.deleteAll();%0A    %7D%0A%0A
     @Tes
@@ -1667,58 +1667,13 @@
 le);
-%0A%0A        userManagement.deleteById(userId);
 %0A    %7D%0A
-%0A
 %7D%0A

Build fix