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 @Entity
@Table(name = "users") @Table(name = "users")
public class User { public class BasicUser {
@Id @Id
@GeneratedValue @GeneratedValue

View File

@ -1,17 +1,17 @@
package com.baeldung.repository; 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.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional; import java.util.Optional;
public interface UserRepository extends JpaRepository<User, Long> { public interface UserRepository extends JpaRepository<BasicUser, Long> {
@EntityGraph(attributePaths = "permissions") @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; package com.baeldung.service;
import com.baeldung.model.User; import com.baeldung.model.BasicUser;
import com.baeldung.repository.UserRepository; import com.baeldung.repository.UserRepository;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -18,7 +18,7 @@ public class SimpleUserService implements UserService {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public Optional<User> findOne(String username) { public Optional<BasicUser> findOne(String username) {
return userRepository.findDetailedByUsername(username); return userRepository.findDetailedByUsername(username);
} }
} }

View File

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

View File

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

View File

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