diff --git a/servlet/java-configuration/data/src/main/java/example/SecurityMessageRepository.java b/servlet/java-configuration/data/src/main/java/example/SecurityMessageRepository.java index adc41d2..f54136f 100644 --- a/servlet/java-configuration/data/src/main/java/example/SecurityMessageRepository.java +++ b/servlet/java-configuration/data/src/main/java/example/SecurityMessageRepository.java @@ -16,11 +16,11 @@ package example; +import java.util.List; + import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; -import java.util.List; - /** * A repository that integrates with Spring Security for accessing {@link Message}s. * diff --git a/servlet/java-configuration/data/src/main/java/example/User.java b/servlet/java-configuration/data/src/main/java/example/User.java index c5ca1b5..4785e64 100644 --- a/servlet/java-configuration/data/src/main/java/example/User.java +++ b/servlet/java-configuration/data/src/main/java/example/User.java @@ -22,6 +22,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; /** + * A user. + * * @author Rob Winch */ @Entity @@ -40,7 +42,7 @@ public class User { private String password; public Long getId() { - return id; + return this.id; } public void setId(Long id) { @@ -79,4 +81,4 @@ public class User { this.password = password; } -} \ No newline at end of file +} diff --git a/servlet/java-configuration/data/src/test/java/example/SecurityMessageRepositoryTests.java b/servlet/java-configuration/data/src/test/java/example/SecurityMessageRepositoryTests.java index 3f96b82..25804bc 100644 --- a/servlet/java-configuration/data/src/test/java/example/SecurityMessageRepositoryTests.java +++ b/servlet/java-configuration/data/src/test/java/example/SecurityMessageRepositoryTests.java @@ -16,18 +16,18 @@ package example; +import java.lang.reflect.Method; +import java.util.List; + import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.util.ReflectionUtils; -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.List; - import static org.assertj.core.api.Assertions.assertThat; /** @@ -45,7 +45,7 @@ public class SecurityMessageRepositoryTests { void findAllOnlyToCurrentUser() { Method method = ReflectionUtils.findMethod(SecurityMessageRepositoryTests.class, "findAllOnlyToCurrentUser"); WithMockCustomUser withMockCustomUser = AnnotationUtils.findAnnotation(method, WithMockCustomUser.class); - List messages = repository.findAll(); + List messages = this.repository.findAll(); assertThat(messages).hasSize(3); for (Message m : messages) { assertThat(m.getTo().getId()).isEqualTo(withMockCustomUser.id()); diff --git a/servlet/java-configuration/data/src/test/java/example/WithMockCustomUser.java b/servlet/java-configuration/data/src/test/java/example/WithMockCustomUser.java index b6634d2..e10374d 100644 --- a/servlet/java-configuration/data/src/test/java/example/WithMockCustomUser.java +++ b/servlet/java-configuration/data/src/test/java/example/WithMockCustomUser.java @@ -16,11 +16,11 @@ package example; -import org.springframework.security.test.context.support.WithSecurityContext; - import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import org.springframework.security.test.context.support.WithSecurityContext; + @Retention(RetentionPolicy.RUNTIME) @WithSecurityContext(factory = WithMockCustomUserSecurityContextFactory.class) public @interface WithMockCustomUser {