package de.digitalcollections.blueprints.crud.backend.impl.jpa.repository;

import de.digitalcollections.blueprints.crud.backend.api.repository.UserRepository;
import de.digitalcollections.blueprints.crud.backend.config.SpringConfigBackendForTest;
import de.digitalcollections.blueprints.crud.backend.impl.jpa.entity.TestUserFactory;
import de.digitalcollections.blueprints.crud.backend.impl.jpa.entity.UserImplJpa;
import de.digitalcollections.blueprints.crud.model.api.security.User;
import java.util.Optional;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {SpringConfigBackendForTest.class})
@Transactional
public class UserRepositoryImplJpaTest {

  @Autowired
  private UserRepository repository;

  @Test
  @Rollback(true)
  public void testSaveAndFind() {
    UserImplJpa entity = TestUserFactory.build("test@test.org");
    repository.save(entity);
    Optional result = repository.findById(entity.getId());
    User user = (User) result.get();

    assertNotNull(user);
    assertEquals(entity.getId(), user.getId());
  }

  @Test
  @Rollback(true)
  public void testSaveAndDelete() throws Exception {
    UserImplJpa entity = TestUserFactory.build("test@test.org");
    repository.save(entity);
    Optional result = repository.findById(entity.getId());
    User foundEntity = (User) result.get();
    assertEquals(entity.getId(), foundEntity.getId());

    repository.delete(foundEntity);
    result = repository.findById(entity.getId());
    Assert.assertTrue(!result.isPresent());
  }

  @Test
  @Rollback(true)
  public void testFindByEmail() throws Exception {
    UserImplJpa entity = TestUserFactory.build("test@test.org");
    repository.save(entity);
    User user = repository.findByEmail("test@test.org");
    assertEquals(entity.getId(), user.getId());
  }
}

@@ -527,66 +527,71 @@
 nit.
-Assert;%0Aimport org.junit.Test;%0Aimport org.junit.runner.Run
+jupiter.api.Test;%0Aimport org.junit.jupiter.api.extension.Extend
 With
@@ -819,33 +819,32 @@
 unit
-4.SpringJUnit4ClassRunner
+.jupiter.SpringExtension
 ;%0Aim
@@ -929,114 +929,76 @@
 org.
-junit.Assert.assertEquals;%0Aimport static org.junit
+assertj.core.api
 .Assert
+ions
 .assert
-NotNull;%0A%0A@RunWith(SpringJUnit4ClassRunner
+That;%0A%0A@ExtendWith(SpringExtension
 .cla
@@ -1442,16 +1442,29 @@
 sert
+That(user).is
 NotNull(
 user
@@ -1459,20 +1459,16 @@
 NotNull(
-user
 );%0A    a
@@ -1464,38 +1464,36 @@
 ll();%0A    assert
-Equals
+That
 (entity.getId(),
@@ -1483,34 +1483,44 @@
 t(entity.getId()
-, 
+).isEqualTo(
 user.getId());%0A 
@@ -1801,38 +1801,36 @@
 et();%0A    assert
-Equals
+That
 (entity.getId(),
@@ -1828,18 +1828,28 @@
 .getId()
-, 
+).isEqualTo(
 foundEnt
@@ -1957,25 +1957,18 @@
     
-A
+a
 ssert
-.assertTrue
+That
 (!re
@@ -1984,16 +1984,25 @@
 esent())
+.isTrue()
 ;%0A  %7D%0A%0A 
@@ -2242,14 +2242,12 @@
 sert
-Equals
+That
 (ent
@@ -2261,10 +2261,20 @@
 Id()
-, 
+).isEqualTo(
 user

migrate unit tests to JUnit5. Use assertThat idiom instead of Assert.assert*