From 97419aab164b456ca04a559120211f8f08f6b896 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Fri, 18 Nov 2022 15:30:29 +0100
Subject: [PATCH] OZG-2966 OZG-3171 rename GoofyUser -> UserProfile

---
 .../src/main/java/de/itvsh/goofy/JwtTokenUtil.java     |  4 ++--
 .../goofy/common/binaryfile/GoofyUserWithFileId.java   |  4 ++--
 .../common/downloadtoken/DownloadTokenService.java     |  4 ++--
 .../de/itvsh/goofy/common/user/CurrentUserService.java |  6 +++---
 .../common/user/{GoofyUser.java => UserProfile.java}   |  2 +-
 .../de/itvsh/goofy/common/user/UserRemoteService.java  |  8 ++++----
 .../java/de/itvsh/goofy/common/user/UserService.java   |  2 +-
 .../common/downloadtoken/DownloadTokenServiceTest.java | 10 +++++-----
 .../goofy/common/user/UserProfileTestFactory.java      |  6 +++---
 9 files changed, 23 insertions(+), 23 deletions(-)
 rename goofy-server/src/main/java/de/itvsh/goofy/common/user/{GoofyUser.java => UserProfile.java} (98%)

diff --git a/goofy-server/src/main/java/de/itvsh/goofy/JwtTokenUtil.java b/goofy-server/src/main/java/de/itvsh/goofy/JwtTokenUtil.java
index 32d1635401..ac0bb5d701 100644
--- a/goofy-server/src/main/java/de/itvsh/goofy/JwtTokenUtil.java
+++ b/goofy-server/src/main/java/de/itvsh/goofy/JwtTokenUtil.java
@@ -41,7 +41,7 @@ import com.auth0.jwt.exceptions.JWTVerificationException;
 
 import de.itvsh.goofy.common.binaryfile.FileId;
 import de.itvsh.goofy.common.downloadtoken.DownloadTokenProperties;
-import de.itvsh.goofy.common.user.GoofyUser;
+import de.itvsh.goofy.common.user.UserProfile;
 import io.jsonwebtoken.Claims;
 import io.jsonwebtoken.Jwts;
 import io.jsonwebtoken.SignatureAlgorithm;
@@ -96,7 +96,7 @@ public class JwtTokenUtil {
 		return organisationseinheitIds;
 	}
 
-	public String generateToken(FileId fileId, GoofyUser user) {
+	public String generateToken(FileId fileId, UserProfile user) {
 		var claims = new HashMap<String, Object>();
 		claims.put(USERID_CLAIM, user.getId().toString());
 		claims.put(FIRSTNAME_CLAIM, user.getFirstName());
diff --git a/goofy-server/src/main/java/de/itvsh/goofy/common/binaryfile/GoofyUserWithFileId.java b/goofy-server/src/main/java/de/itvsh/goofy/common/binaryfile/GoofyUserWithFileId.java
index 490dc6dd3b..f3156b59ea 100644
--- a/goofy-server/src/main/java/de/itvsh/goofy/common/binaryfile/GoofyUserWithFileId.java
+++ b/goofy-server/src/main/java/de/itvsh/goofy/common/binaryfile/GoofyUserWithFileId.java
@@ -29,14 +29,14 @@ import java.util.Objects;
 
 import org.springframework.security.core.GrantedAuthority;
 
-import de.itvsh.goofy.common.user.GoofyUser;
+import de.itvsh.goofy.common.user.UserProfile;
 import lombok.Builder;
 import lombok.Getter;
 
 @Builder
 @Getter
 public class GoofyUserWithFileId {
-	private GoofyUser user;
+	private UserProfile user;
 
 	private FileId fileId;
 
diff --git a/goofy-server/src/main/java/de/itvsh/goofy/common/downloadtoken/DownloadTokenService.java b/goofy-server/src/main/java/de/itvsh/goofy/common/downloadtoken/DownloadTokenService.java
index 39bc779a5f..e4b234bac5 100644
--- a/goofy-server/src/main/java/de/itvsh/goofy/common/downloadtoken/DownloadTokenService.java
+++ b/goofy-server/src/main/java/de/itvsh/goofy/common/downloadtoken/DownloadTokenService.java
@@ -43,7 +43,7 @@ import de.itvsh.goofy.JwtTokenUtil;
 import de.itvsh.goofy.common.binaryfile.FileId;
 import de.itvsh.goofy.common.binaryfile.GoofyUserWithFileId;
 import de.itvsh.goofy.common.user.CurrentUserService;
-import de.itvsh.goofy.common.user.GoofyUser;
+import de.itvsh.goofy.common.user.UserProfile;
 import de.itvsh.goofy.common.user.UserId;
 import de.itvsh.kop.common.errorhandling.TechnicalException;
 import io.jsonwebtoken.Claims;
@@ -90,7 +90,7 @@ class DownloadTokenService {
 		Optional<Claims> claimsOptional = jwtTokenUtil.getAllClaimsFromToken(token);
 		var downloadUserBuilder = GoofyUserWithFileId.builder();
 		claimsOptional.ifPresent(claims -> downloadUserBuilder.user(
-				GoofyUser.builder()
+				UserProfile.builder()
 						.id(UserId.from(claims.get(USERID_CLAIM, String.class)))
 						.firstName(claims.get(FIRSTNAME_CLAIM, String.class))
 						.lastName(claims.get(LASTNAME_CLAIM, String.class))
diff --git a/goofy-server/src/main/java/de/itvsh/goofy/common/user/CurrentUserService.java b/goofy-server/src/main/java/de/itvsh/goofy/common/user/CurrentUserService.java
index 0b8347c0e7..d1692e4371 100644
--- a/goofy-server/src/main/java/de/itvsh/goofy/common/user/CurrentUserService.java
+++ b/goofy-server/src/main/java/de/itvsh/goofy/common/user/CurrentUserService.java
@@ -53,7 +53,7 @@ public class CurrentUserService {
 		return Collections.unmodifiableCollection(new HashSet<GrantedAuthority>(CurrentUserHelper.getAuthentication().getAuthorities()));
 	}
 
-	public GoofyUser getUser() {
+	public UserProfile getUser() {
 		var dlUser = getDownloadUser();
 		if (dlUser.isPresent()) {
 			return dlUser.get();
@@ -61,7 +61,7 @@ public class CurrentUserService {
 
 		Optional<AccessToken> token = getCurrentSecurityToken();
 
-		var userBuilder = GoofyUser.builder()
+		var userBuilder = UserProfile.builder()
 				.id(getUserId())
 				.authorities(getAuthorities());
 
@@ -83,7 +83,7 @@ public class CurrentUserService {
 				.stream().map(Object::toString).collect(Collectors.toList());
 	}
 
-	private Optional<GoofyUser> getDownloadUser() {
+	private Optional<UserProfile> getDownloadUser() {
 		return Optional.of(CurrentUserHelper.getAuthentication().getPrincipal())
 				.filter(GoofyUserWithFileId.class::isInstance)
 				.map(GoofyUserWithFileId.class::cast)
diff --git a/goofy-server/src/main/java/de/itvsh/goofy/common/user/GoofyUser.java b/goofy-server/src/main/java/de/itvsh/goofy/common/user/UserProfile.java
similarity index 98%
rename from goofy-server/src/main/java/de/itvsh/goofy/common/user/GoofyUser.java
rename to goofy-server/src/main/java/de/itvsh/goofy/common/user/UserProfile.java
index 3f0485edbc..d53b318add 100644
--- a/goofy-server/src/main/java/de/itvsh/goofy/common/user/GoofyUser.java
+++ b/goofy-server/src/main/java/de/itvsh/goofy/common/user/UserProfile.java
@@ -38,7 +38,7 @@ import lombok.Singular;
 @Builder
 @Getter
 @AllArgsConstructor
-public class GoofyUser {
+public class UserProfile {
 
 	@JsonIgnore
 	private UserId id;
diff --git a/goofy-server/src/main/java/de/itvsh/goofy/common/user/UserRemoteService.java b/goofy-server/src/main/java/de/itvsh/goofy/common/user/UserRemoteService.java
index bdcb42cc28..e9000a152d 100644
--- a/goofy-server/src/main/java/de/itvsh/goofy/common/user/UserRemoteService.java
+++ b/goofy-server/src/main/java/de/itvsh/goofy/common/user/UserRemoteService.java
@@ -68,7 +68,7 @@ public class UserRemoteService {
 		}
 	}
 
-	public Optional<GoofyUser> getUser(UserId userId) {
+	public Optional<UserProfile> getUser(UserId userId) {
 		return executeHandlingException(() -> getUserById(userId));
 	}
 
@@ -83,7 +83,7 @@ public class UserRemoteService {
 		}
 	}
 
-	<T> GoofyUser getUserById(UserId userId) {
+	<T> UserProfile getUserById(UserId userId) {
 		return buildUser(getBodyMap(doExchange(userId)));
 	}
 
@@ -111,8 +111,8 @@ public class UserRemoteService {
 		return (LinkedHashMap<String, Object>) responseEntity.getBody();
 	}
 
-	GoofyUser buildUser(LinkedHashMap<String, Object> bodyMap) {
-		return GoofyUser.builder()
+	UserProfile buildUser(LinkedHashMap<String, Object> bodyMap) {
+		return UserProfile.builder()
 				.firstName((String) bodyMap.getOrDefault(FIRST_NAME_KEY, StringUtils.EMPTY))
 				.lastName((String) bodyMap.getOrDefault(LAST_NAME_KEY, StringUtils.EMPTY))
 				.build();
diff --git a/goofy-server/src/main/java/de/itvsh/goofy/common/user/UserService.java b/goofy-server/src/main/java/de/itvsh/goofy/common/user/UserService.java
index 19f64d7ac1..80d1616716 100644
--- a/goofy-server/src/main/java/de/itvsh/goofy/common/user/UserService.java
+++ b/goofy-server/src/main/java/de/itvsh/goofy/common/user/UserService.java
@@ -11,7 +11,7 @@ public class UserService {
 	@Autowired
 	private UserRemoteService remoteService;
 
-	public Optional<GoofyUser> getById(UserId userId) {
+	public Optional<UserProfile> getById(UserId userId) {
 		return remoteService.getUser(userId);
 	}
 }
\ No newline at end of file
diff --git a/goofy-server/src/test/java/de/itvsh/goofy/common/downloadtoken/DownloadTokenServiceTest.java b/goofy-server/src/test/java/de/itvsh/goofy/common/downloadtoken/DownloadTokenServiceTest.java
index 780c244e10..bf9d88ebc2 100644
--- a/goofy-server/src/test/java/de/itvsh/goofy/common/downloadtoken/DownloadTokenServiceTest.java
+++ b/goofy-server/src/test/java/de/itvsh/goofy/common/downloadtoken/DownloadTokenServiceTest.java
@@ -47,7 +47,7 @@ import com.auth0.jwt.exceptions.JWTVerificationException;
 import de.itvsh.goofy.JwtTokenUtil;
 import de.itvsh.goofy.common.binaryfile.FileId;
 import de.itvsh.goofy.common.user.CurrentUserService;
-import de.itvsh.goofy.common.user.GoofyUser;
+import de.itvsh.goofy.common.user.UserProfile;
 import de.itvsh.goofy.common.user.UserProfileTestFactory;
 import de.itvsh.kop.common.errorhandling.TechnicalException;
 import io.jsonwebtoken.Claims;
@@ -73,7 +73,7 @@ class DownloadTokenServiceTest {
 
 		final FileId fileId = FileId.createNew();
 
-		final GoofyUser user = UserProfileTestFactory.create();
+		final UserProfile user = UserProfileTestFactory.create();
 
 		@BeforeEach
 		void mockUserService() {
@@ -111,7 +111,7 @@ class DownloadTokenServiceTest {
 		void shouldGetUserFromTokenWithoutUserFirstname() {
 			mockClaims(null, FIRSTNAME_CLAIM);
 
-			GoofyUser user = service.getUserFromToken(FAKE_TOKEN).getUser();
+			UserProfile user = service.getUserFromToken(FAKE_TOKEN).getUser();
 
 			assertThat(user).isNotNull();
 		}
@@ -120,7 +120,7 @@ class DownloadTokenServiceTest {
 		void shouldGetUserFromTokenWithoutUserLastname() {
 			mockClaims(FIRSTNAME_CLAIM, null);
 
-			GoofyUser user = service.getUserFromToken(FAKE_TOKEN).getUser();
+			UserProfile user = service.getUserFromToken(FAKE_TOKEN).getUser();
 
 			assertThat(user).isNotNull();
 		}
@@ -129,7 +129,7 @@ class DownloadTokenServiceTest {
 		void shouldGetOrganisationseinheitIdsFromToken() {
 			mockClaims(FIRSTNAME_CLAIM, LASTNAME_CLAIM);
 
-			GoofyUser user = service.getUserFromToken(FAKE_TOKEN).getUser();
+			UserProfile user = service.getUserFromToken(FAKE_TOKEN).getUser();
 
 			assertThat(user.getOrganisationseinheitIds()).isEqualTo(ORGE_IDS);
 		}
diff --git a/goofy-server/src/test/java/de/itvsh/goofy/common/user/UserProfileTestFactory.java b/goofy-server/src/test/java/de/itvsh/goofy/common/user/UserProfileTestFactory.java
index 4e31f6e68a..226531aa45 100644
--- a/goofy-server/src/test/java/de/itvsh/goofy/common/user/UserProfileTestFactory.java
+++ b/goofy-server/src/test/java/de/itvsh/goofy/common/user/UserProfileTestFactory.java
@@ -40,12 +40,12 @@ public class UserProfileTestFactory {
 	public static final String ROLE = "TEST_USER";
 	public static final GrantedAuthority AUTHORITY = new SimpleGrantedAuthority(ROLE);
 
-	public static GoofyUser create() {
+	public static UserProfile create() {
 		return createBuilder().build();
 	}
 
-	public static GoofyUser.GoofyUserBuilder createBuilder() {
-		return GoofyUser.builder()
+	public static UserProfile.UserProfileBuilder createBuilder() {
+		return UserProfile.builder()
 				.id(ID)
 				.firstName(FIRSTNAME)
 				.lastName(LASTNAME)
-- 
GitLab