fixed broken tests in persistence-modules/spring-data-jpa-3

This commit is contained in:
fejera 2019-11-05 11:06:30 +01:00
parent c125574acb
commit 24ef45fcc5
6 changed files with 14 additions and 14 deletions

View File

@ -5,7 +5,7 @@ import java.util.Set;
@Entity
@Table(name = "users")
public class User {
public class BasicUser {
@Id
@GeneratedValue

View File

@ -1,17 +1,17 @@
package com.baeldung.repository;
import com.baeldung.model.User;
import com.baeldung.model.BasicUser;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional;
public interface UserRepository extends JpaRepository<User, Long> {
public interface UserRepository extends JpaRepository<BasicUser, Long> {
@EntityGraph(attributePaths = "permissions")
Optional<User> findDetailedByUsername(String username);
Optional<BasicUser> findDetailedByUsername(String username);
Optional<User> findSummaryByUsername(String username);
Optional<BasicUser> findSummaryByUsername(String username);
Optional<User> findByUsername(String username);
Optional<BasicUser> findByUsername(String username);
}

View File

@ -1,6 +1,6 @@
package com.baeldung.service;
import com.baeldung.model.User;
import com.baeldung.model.BasicUser;
import com.baeldung.repository.UserRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -18,7 +18,7 @@ public class SimpleUserService implements UserService {
@Override
@Transactional(readOnly = true)
public Optional<User> findOne(String username) {
public Optional<BasicUser> findOne(String username) {
return userRepository.findDetailedByUsername(username);
}
}

View File

@ -1,9 +1,9 @@
package com.baeldung.service;
import com.baeldung.model.User;
import com.baeldung.model.BasicUser;
import java.util.Optional;
public interface UserService {
Optional<User> findOne(String username);
Optional<BasicUser> findOne(String username);
}

View File

@ -1,6 +1,6 @@
package com.baeldung.web;
import com.baeldung.model.User;
import com.baeldung.model.BasicUser;
import java.util.Set;
@ -34,7 +34,7 @@ public class DetailedUserDto {
this.permissions = permissions;
}
public static DetailedUserDto fromEntity(User user) {
public static DetailedUserDto fromEntity(BasicUser user) {
DetailedUserDto detailed = new DetailedUserDto();
detailed.setId(user.getId());
detailed.setUsername(user.getUsername());

View File

@ -1,6 +1,6 @@
package com.baeldung.osiv;
import com.baeldung.model.User;
import com.baeldung.model.BasicUser;
import com.baeldung.repository.UserRepository;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@ -32,7 +32,7 @@ class UserControllerIntegrationTest {
@BeforeEach
void setUp() {
User user = new User();
BasicUser user = new BasicUser();
user.setUsername("root");
user.setPermissions(new HashSet<>(Arrays.asList("PERM_READ", "PERM_WRITE")));