Public Access
feat(tiles): store dashboard and profile tile layouts
This commit is contained in:
1 parent
dd4fcd1546
commit
315e22c220
31 files changed
+464
-165
No files matched your search
@@ -73,8 +73,9 @@ class PublicProfileControllerTest extends AbstractIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void publicProfile_TicketCarriesTheSharedStatGroups() throws Exception {
|
||||
jdbc.update("update user_settings set profile_stats = '{PILE,TREND}' where user_id = ?", publicUserId);
|
||||
void publicProfile_TicketCarriesTheStatTilesAsSharedGroups() throws Exception {
|
||||
jdbc.update("update user_settings set profile_tiles = '{STATS_PILE:M,PLAYING:S,STATS_TREND:L}' where user_id = ?",
|
||||
publicUserId);
|
||||
|
||||
String body = mockMvc.perform(get("/api/public/profiles/Lobo")).andReturn().getResponse().getContentAsString();
|
||||
|
||||
@@ -82,12 +83,13 @@ class PublicProfileControllerTest extends AbstractIntegrationTest {
|
||||
PublicKey key = KeyFactory.getInstance("Ed25519").generatePublic(new X509EncodedKeySpec(Base64.getDecoder().decode(publicKey)));
|
||||
Claims claims = Jwts.parser().verifyWith(key).build().parseSignedClaims(ticket).getPayload();
|
||||
assertEquals(List.of("PILE", "TREND"), claims.get("profileStats", List.class));
|
||||
assertEquals(List.of("PLAYING", "STATS"), claims.get("sections", List.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void publicProfile_AnswersWithTheOwnersStyle() throws Exception {
|
||||
jdbc.update("update user_settings set profile_accent = 'red', profile_corners = 'round', profile_banner_appid = 620, "
|
||||
+ "profile_sections = '{PLAYING,SUMMARY}' where user_id = ?", publicUserId);
|
||||
+ "profile_tiles = '{PLAYING:S,STATS_PILE:L}' where user_id = ?", publicUserId);
|
||||
|
||||
mockMvc.perform(get("/api/public/profiles/Lobo"))
|
||||
.andExpect(status().isOk())
|
||||
@@ -95,20 +97,23 @@ class PublicProfileControllerTest extends AbstractIntegrationTest {
|
||||
.andExpect(jsonPath("$.style.corners").value("round"))
|
||||
.andExpect(jsonPath("$.style.bannerAppid").value(620))
|
||||
.andExpect(jsonPath("$.style.backgroundAppid").isEmpty())
|
||||
.andExpect(jsonPath("$.style.sections[0]").value("PLAYING"))
|
||||
.andExpect(jsonPath("$.style.sections[1]").value("SUMMARY"));
|
||||
.andExpect(jsonPath("$.style.tiles[0].id").value("PLAYING"))
|
||||
.andExpect(jsonPath("$.style.tiles[0].size").value("S"))
|
||||
.andExpect(jsonPath("$.style.tiles[1].id").value("STATS_PILE"))
|
||||
.andExpect(jsonPath("$.style.tiles[1].size").value("L"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void publicProfile_NewRowShowsEverySection() throws Exception {
|
||||
void publicProfile_NewRowShowsTheDefaultTiles() throws Exception {
|
||||
mockMvc.perform(get("/api/public/profiles/Lobo"))
|
||||
.andExpect(jsonPath("$.style.accent").value("violet"))
|
||||
.andExpect(jsonPath("$.style.sections.length()").value(5));
|
||||
.andExpect(jsonPath("$.style.tiles.length()").value(4))
|
||||
.andExpect(jsonPath("$.style.tiles[3].id").value("FINISHED"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void publicProfile_TicketCarriesTheShownSections() throws Exception {
|
||||
jdbc.update("update user_settings set profile_sections = '{PLAYING}' where user_id = ?", publicUserId);
|
||||
void publicProfile_NoStatTiles_TicketSharesNoStats() throws Exception {
|
||||
jdbc.update("update user_settings set profile_tiles = '{PLAYING:M}' where user_id = ?", publicUserId);
|
||||
|
||||
String body = mockMvc.perform(get("/api/public/profiles/Lobo")).andReturn().getResponse().getContentAsString();
|
||||
|
||||
@@ -116,6 +121,17 @@ class PublicProfileControllerTest extends AbstractIntegrationTest {
|
||||
PublicKey key = KeyFactory.getInstance("Ed25519").generatePublic(new X509EncodedKeySpec(Base64.getDecoder().decode(publicKey)));
|
||||
Claims claims = Jwts.parser().verifyWith(key).build().parseSignedClaims(ticket).getPayload();
|
||||
assertEquals(List.of("PLAYING"), claims.get("sections", List.class));
|
||||
assertEquals(List.of(), claims.get("profileStats", List.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void publicProfile_TileWithoutSize_IsMedium() throws Exception {
|
||||
jdbc.update("update user_settings set profile_tiles = '{PLAYING}' where user_id = ?", publicUserId);
|
||||
|
||||
mockMvc.perform(get("/api/public/profiles/Lobo"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.style.tiles[0].id").value("PLAYING"))
|
||||
.andExpect(jsonPath("$.style.tiles[0].size").value("M"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package auth_service.modules.user.api;
|
||||
|
||||
import auth_service.modules.user.model.ProfileStyle;
|
||||
import auth_service.modules.user.model.Tile;
|
||||
import auth_service.configuration.security.JwtAuthenticationFilter;
|
||||
import auth_service.configuration.security.JwtService;
|
||||
import auth_service.shared.security.UserPrincipal;
|
||||
@@ -350,10 +351,11 @@ class UserControllerTest extends AbstractWebMvcTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void getCurrentUserV1_ShowsTheSharedStatGroups() throws Exception {
|
||||
void getCurrentUserV1_ShowsTheTileLayouts() throws Exception {
|
||||
String email = "test@example.com";
|
||||
UserSettings settings = UserSettings.builder().language("en").theme("dark")
|
||||
.profileStats(List.of("PILE", "TREND")).build();
|
||||
.dashboardTiles(List.of(new Tile("STATS_TREND", "L")))
|
||||
.profileTiles(List.of(new Tile("PLAYING", "S"))).build();
|
||||
SecurityContextHolder.getContext().setAuthentication(
|
||||
new UsernamePasswordAuthenticationToken(new UserPrincipal("1", email, null), null, Collections.emptyList())
|
||||
);
|
||||
@@ -361,33 +363,100 @@ class UserControllerTest extends AbstractWebMvcTest {
|
||||
|
||||
mockMvc.perform(get("/api/users/me").accept(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.settings.profileStats[0]").value("PILE"))
|
||||
.andExpect(jsonPath("$.settings.profileStats[1]").value("TREND"));
|
||||
.andExpect(jsonPath("$.settings.dashboardTiles[0].id").value("STATS_TREND"))
|
||||
.andExpect(jsonPath("$.settings.dashboardTiles[0].size").value("L"))
|
||||
.andExpect(jsonPath("$.settings.profileTiles[0].id").value("PLAYING"))
|
||||
.andExpect(jsonPath("$.settings.profileTiles[0].size").value("S"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateProfileStats_StoresTheGroups() throws Exception {
|
||||
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(
|
||||
new UserPrincipal("1", "test@example.com", null), null, Collections.emptyList()));
|
||||
void getCurrentUserV1_NeverChangedDashboard_SendsNullTiles() throws Exception {
|
||||
String email = "test@example.com";
|
||||
SecurityContextHolder.getContext().setAuthentication(
|
||||
new UsernamePasswordAuthenticationToken(new UserPrincipal("1", email, null), null, Collections.emptyList())
|
||||
);
|
||||
when(userService.getUserByEmail(email)).thenReturn(User.builder().email(email)
|
||||
.settings(UserSettings.builder().language("en").theme("dark").build()).build());
|
||||
|
||||
mockMvc.perform(put("/api/users/settings/profile-stats")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content("{\"groups\":[\"PILE\",\"TREND\"]}"))
|
||||
.andExpect(status().isNoContent());
|
||||
|
||||
verify(userService).updateProfileStats(1L, List.of("PILE", "TREND"));
|
||||
mockMvc.perform(get("/api/users/me").accept(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.settings.dashboardTiles").isEmpty())
|
||||
.andExpect(jsonPath("$.settings.profileTiles.length()").value(4));
|
||||
}
|
||||
|
||||
// OVERVIEW is public anyway, so it is no choice.
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"{}", "{\"groups\":[\"OVERVIEW\"]}", "{\"groups\":[\"MONEY\"]}", "{\"groups\":[null]}"})
|
||||
void updateProfileStats_UnknownOrMissingGroups_Is400(String body) throws Exception {
|
||||
@Test
|
||||
void updateDashboardTiles_StoresTheTiles() throws Exception {
|
||||
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(
|
||||
new UserPrincipal("1", "test@example.com", null), null, Collections.emptyList()));
|
||||
|
||||
mockMvc.perform(put("/api/users/settings/profile-stats")
|
||||
mockMvc.perform(put("/api/users/settings/dashboard-tiles")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(body))
|
||||
.content("{\"tiles\":[{\"id\":\"STATS_TREND\",\"size\":\"L\"},{\"id\":\"PLAYING\",\"size\":\"S\"}]}"))
|
||||
.andExpect(status().isNoContent());
|
||||
|
||||
verify(userService).updateDashboardTiles(1L, List.of(new Tile("STATS_TREND", "L"), new Tile("PLAYING", "S")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateDashboardTiles_NullTilesResets() throws Exception {
|
||||
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(
|
||||
new UserPrincipal("1", "test@example.com", null), null, Collections.emptyList()));
|
||||
|
||||
mockMvc.perform(put("/api/users/settings/dashboard-tiles")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content("{\"tiles\":null}"))
|
||||
.andExpect(status().isNoContent());
|
||||
|
||||
verify(userService).updateDashboardTiles(1L, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateProfileTiles_StoresTheTiles() throws Exception {
|
||||
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(
|
||||
new UserPrincipal("1", "test@example.com", null), null, Collections.emptyList()));
|
||||
|
||||
mockMvc.perform(put("/api/users/settings/profile-tiles")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content("{\"tiles\":[{\"id\":\"STATS_PILE\",\"size\":\"M\"}]}"))
|
||||
.andExpect(status().isNoContent());
|
||||
|
||||
verify(userService).updateProfileTiles(1L, List.of(new Tile("STATS_PILE", "M")));
|
||||
}
|
||||
|
||||
// A dashboard tile is no profile tile and the other way round; activity and the game count stay private.
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {
|
||||
"dashboard-tiles|{\"tiles\":[{\"id\":\"SUMMARY\",\"size\":\"M\"}]}",
|
||||
"dashboard-tiles|{\"tiles\":[{\"id\":\"PLAYING\",\"size\":\"XL\"}]}",
|
||||
"dashboard-tiles|{\"tiles\":[{\"id\":\"PLAYING\"}]}",
|
||||
"dashboard-tiles|{\"tiles\":[null]}",
|
||||
"profile-tiles|{\"tiles\":[{\"id\":\"ACTIVITY\",\"size\":\"M\"}]}",
|
||||
"profile-tiles|{\"tiles\":[{\"id\":\"STATS_OVERVIEW\",\"size\":\"M\"}]}",
|
||||
"profile-tiles|{\"tiles\":null}",
|
||||
"profile-tiles|{}"
|
||||
})
|
||||
void updateTiles_UnknownIdBadSizeOrMissing_IsRejected(String pathAndBody) throws Exception {
|
||||
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(
|
||||
new UserPrincipal("1", "test@example.com", null), null, Collections.emptyList()));
|
||||
String[] parts = pathAndBody.split("\\|", 2);
|
||||
|
||||
mockMvc.perform(put("/api/users/settings/" + parts[0])
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(parts[1]))
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
verifyNoInteractions(userService);
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateTiles_MoreThanTwentyTiles_IsRejected() throws Exception {
|
||||
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(
|
||||
new UserPrincipal("1", "test@example.com", null), null, Collections.emptyList()));
|
||||
String tiles = String.join(",", Collections.nCopies(21, "{\"id\":\"PLAYING\",\"size\":\"M\"}"));
|
||||
|
||||
mockMvc.perform(put("/api/users/settings/dashboard-tiles")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content("{\"tiles\":[" + tiles + "]}"))
|
||||
.andExpect(status().isBadRequest());
|
||||
}
|
||||
|
||||
@@ -395,7 +464,7 @@ class UserControllerTest extends AbstractWebMvcTest {
|
||||
void getCurrentUserV1_ShowsTheProfileStyle() throws Exception {
|
||||
String email = "test@example.com";
|
||||
UserSettings settings = UserSettings.builder().language("en").theme("dark")
|
||||
.profileStyle(new ProfileStyle("red", "sharp", 620L, null, List.of("PLAYING"))).build();
|
||||
.profileStyle(new ProfileStyle("red", "sharp", 620L, null)).build();
|
||||
SecurityContextHolder.getContext().setAuthentication(
|
||||
new UsernamePasswordAuthenticationToken(new UserPrincipal("1", email, null), null, Collections.emptyList())
|
||||
);
|
||||
@@ -406,8 +475,7 @@ class UserControllerTest extends AbstractWebMvcTest {
|
||||
.andExpect(jsonPath("$.settings.profileStyle.accent").value("red"))
|
||||
.andExpect(jsonPath("$.settings.profileStyle.corners").value("sharp"))
|
||||
.andExpect(jsonPath("$.settings.profileStyle.bannerAppid").value(620))
|
||||
.andExpect(jsonPath("$.settings.profileStyle.backgroundAppid").isEmpty())
|
||||
.andExpect(jsonPath("$.settings.profileStyle.sections[0]").value("PLAYING"));
|
||||
.andExpect(jsonPath("$.settings.profileStyle.backgroundAppid").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -417,23 +485,20 @@ class UserControllerTest extends AbstractWebMvcTest {
|
||||
|
||||
mockMvc.perform(put("/api/users/settings/profile-style")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content("{\"accent\":\"green\",\"corners\":\"round\",\"bannerAppid\":620,"
|
||||
+ "\"sections\":[\"STATS\",\"SUMMARY\"]}"))
|
||||
.content("{\"accent\":\"green\",\"corners\":\"round\",\"bannerAppid\":620}"))
|
||||
.andExpect(status().isNoContent());
|
||||
|
||||
verify(userService).updateProfileStyle(1L, new ProfileStyle("green", "round", 620L, null, List.of("STATS", "SUMMARY")));
|
||||
verify(userService).updateProfileStyle(1L, new ProfileStyle("green", "round", 620L, null));
|
||||
}
|
||||
|
||||
// Each body differs from a valid one in one field only, so the 400 comes from that field's constraint.
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {
|
||||
"{\"accent\":\"hotpink\",\"corners\":\"default\",\"sections\":[]}",
|
||||
"{\"accent\":\"violet\",\"corners\":\"pointy\",\"sections\":[]}",
|
||||
"{\"accent\":\"violet\",\"corners\":\"default\",\"bannerAppid\":0,\"sections\":[]}",
|
||||
"{\"accent\":\"violet\",\"corners\":\"default\",\"backgroundAppid\":-620,\"sections\":[]}",
|
||||
"{\"accent\":\"violet\",\"corners\":\"default\",\"sections\":[\"NOTES\"]}",
|
||||
"{\"accent\":\"violet\",\"corners\":\"default\",\"sections\":[null]}",
|
||||
"{\"accent\":\"violet\",\"corners\":\"default\"}"
|
||||
"{\"accent\":\"hotpink\",\"corners\":\"default\"}",
|
||||
"{\"accent\":\"violet\",\"corners\":\"pointy\"}",
|
||||
"{\"accent\":\"violet\",\"corners\":\"default\",\"bannerAppid\":0}",
|
||||
"{\"accent\":\"violet\",\"corners\":\"default\",\"backgroundAppid\":-620}",
|
||||
"{\"corners\":\"default\"}"
|
||||
})
|
||||
void updateProfileStyle_UnknownOrMissingValue_IsRejected(String body) throws Exception {
|
||||
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package auth_service.modules.user.model;
|
||||
|
||||
import auth_service.shared.test.AbstractUnitTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class ProfileStyleTest extends AbstractUnitTest {
|
||||
|
||||
@Test
|
||||
void keepsEachSectionOnceAtItsFirstPlace() {
|
||||
assertEquals(List.of("STATS", "PLAYING"),
|
||||
new ProfileStyle("red", "round", 620L, null, List.of("STATS", "PLAYING", "STATS")).sections());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package auth_service.modules.user.model;
|
||||
|
||||
import auth_service.shared.test.AbstractUnitTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class TileTest extends AbstractUnitTest {
|
||||
|
||||
@Test
|
||||
void parse_ReadsTheStoredForm() {
|
||||
assertEquals(new Tile("STATS_TOP_GAMES", "L"), Tile.parse("STATS_TOP_GAMES:L"));
|
||||
assertEquals("PLAYING:S", new Tile("PLAYING", "S").stored());
|
||||
}
|
||||
|
||||
@Test
|
||||
void distinct_KeepsEachTileOnceAtItsFirstPlace() {
|
||||
assertEquals(List.of(new Tile("PLAYING", "S"), new Tile("SUMMARY", "M")),
|
||||
Tile.distinct(List.of(new Tile("PLAYING", "S"), new Tile("SUMMARY", "M"), new Tile("PLAYING", "L"))));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package auth_service.modules.user.persistence;
|
||||
|
||||
import auth_service.modules.user.model.ProfileStyle;
|
||||
import auth_service.modules.user.model.Tile;
|
||||
import auth_service.modules.user.exception.UserNotFoundException;
|
||||
import auth_service.modules.user.model.Appearance;
|
||||
import auth_service.modules.user.model.SteamIdHolder;
|
||||
@@ -293,7 +294,7 @@ class UserRepositoryTest extends AbstractPersistenceTest {
|
||||
assertEquals(ProfileStyle.DEFAULT, userRepository.findByEmail("style@example.com").orElseThrow()
|
||||
.getSettings().getProfileStyle());
|
||||
|
||||
ProfileStyle style = new ProfileStyle("pink", "sharp", 620L, 1086940L, List.of("FINISHED", "SUMMARY"));
|
||||
ProfileStyle style = new ProfileStyle("pink", "sharp", 620L, 1086940L);
|
||||
userRepository.updateProfileStyle(userEntity.getId(), style);
|
||||
entityManager.flush();
|
||||
entityManager.clear();
|
||||
@@ -302,26 +303,49 @@ class UserRepositoryTest extends AbstractPersistenceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateProfileStats_IsReadBackAndKeptByUpdateSettings() {
|
||||
void updateTiles_AreReadBackAndKeptByUpdateSettings() {
|
||||
UserEntity userEntity = entityManager.persist(UserEntity.builder()
|
||||
.email("stats@example.com")
|
||||
.email("tiles@example.com")
|
||||
.password("password")
|
||||
.enabled(true)
|
||||
.registrationDate(LocalDateTime.now())
|
||||
.build());
|
||||
entityManager.flush();
|
||||
assertEquals(List.of(), userRepository.findByEmail("stats@example.com").orElseThrow()
|
||||
.getSettings().getProfileStats());
|
||||
UserSettings fresh = userRepository.findByEmail("tiles@example.com").orElseThrow().getSettings();
|
||||
assertNull(fresh.getDashboardTiles());
|
||||
assertEquals(UserSettings.DEFAULT_PROFILE_TILES, fresh.getProfileTiles());
|
||||
|
||||
userRepository.updateProfileStats(userEntity.getId(), List.of("PILE", "TREND"));
|
||||
List<Tile> dashboard = List.of(new Tile("STATS_TREND", "L"), new Tile("PLAYING", "S"));
|
||||
List<Tile> profile = List.of(new Tile("STATS_PILE", "M"), new Tile("SUMMARY", "S"));
|
||||
userRepository.updateDashboardTiles(userEntity.getId(), dashboard);
|
||||
userRepository.updateProfileTiles(userEntity.getId(), profile);
|
||||
entityManager.flush();
|
||||
userRepository.updateSettings(userEntity.getId(), null,
|
||||
UserSettings.builder().language("de").theme("dark").build());
|
||||
entityManager.flush();
|
||||
entityManager.clear();
|
||||
|
||||
assertEquals(List.of("PILE", "TREND"), userRepository.findByEmail("stats@example.com").orElseThrow()
|
||||
.getSettings().getProfileStats());
|
||||
UserSettings saved = userRepository.findByEmail("tiles@example.com").orElseThrow().getSettings();
|
||||
assertEquals(dashboard, saved.getDashboardTiles());
|
||||
assertEquals(profile, saved.getProfileTiles());
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateDashboardTiles_NullResetsToTheDefault() {
|
||||
UserEntity userEntity = entityManager.persist(UserEntity.builder()
|
||||
.email("reset@example.com")
|
||||
.password("password")
|
||||
.enabled(true)
|
||||
.registrationDate(LocalDateTime.now())
|
||||
.build());
|
||||
userRepository.updateDashboardTiles(userEntity.getId(), List.of(new Tile("PLAYING", "S")));
|
||||
entityManager.flush();
|
||||
|
||||
userRepository.updateDashboardTiles(userEntity.getId(), null);
|
||||
entityManager.flush();
|
||||
entityManager.clear();
|
||||
|
||||
assertNull(userRepository.findByEmail("reset@example.com").orElseThrow().getSettings().getDashboardTiles());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package auth_service.modules.user.service;
|
||||
|
||||
import auth_service.modules.user.model.Tile;
|
||||
import auth_service.shared.security.Role;
|
||||
import auth_service.modules.user.exception.DisplayNameAlreadyInUseException;
|
||||
import auth_service.modules.user.exception.UserNotFoundException;
|
||||
@@ -64,10 +65,19 @@ class UserServiceTest extends AbstractUnitTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateProfileStats_StoresEachGroupOnce() {
|
||||
userService.updateProfileStats(1L, List.of("PILE", "TREND", "PILE"));
|
||||
void updateTiles_StoreEachTileOnce() {
|
||||
userService.updateDashboardTiles(1L, List.of(new Tile("PLAYING", "S"), new Tile("PLAYING", "L")));
|
||||
userService.updateProfileTiles(1L, List.of(new Tile("SUMMARY", "M"), new Tile("SUMMARY", "S")));
|
||||
|
||||
verify(userRepository).updateProfileStats(1L, List.of("PILE", "TREND"));
|
||||
verify(userRepository).updateDashboardTiles(1L, List.of(new Tile("PLAYING", "S")));
|
||||
verify(userRepository).updateProfileTiles(1L, List.of(new Tile("SUMMARY", "M")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateDashboardTiles_NullStaysNull() {
|
||||
userService.updateDashboardTiles(1L, null);
|
||||
|
||||
verify(userRepository).updateDashboardTiles(1L, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user