From caba11026684552507d1d0c218ecbe594ea6d334 Mon Sep 17 00:00:00 2001 From: Ehren Kret Date: Thu, 18 Nov 2021 10:23:09 -0600 Subject: [PATCH] Revert "Revert "Remove transparent SVG for badging"" This reverts commit 0fdb23c1e9b86600e66f83e676d11e1049e88e1d. --- .../textsecuregcm/entities/BadgeSvg.java | 19 +++---------------- .../ConfiguredProfileBadgeConverterTest.java | 9 ++++----- .../SubscriptionControllerTest.java | 6 +++--- .../controllers/DonationControllerTest.java | 8 ++++---- .../controllers/ProfileControllerTest.java | 10 +++++----- 5 files changed, 19 insertions(+), 33 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/entities/BadgeSvg.java b/service/src/main/java/org/whispersystems/textsecuregcm/entities/BadgeSvg.java index a146b97de..fef8cda78 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/entities/BadgeSvg.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/entities/BadgeSvg.java @@ -14,13 +14,11 @@ import javax.validation.constraints.NotEmpty; public class BadgeSvg { private final String light; private final String dark; - private final String transparent; @JsonCreator public BadgeSvg( @JsonProperty("light") final String light, - @JsonProperty("dark") final String dark, - @JsonProperty("transparent") final String transparent) { + @JsonProperty("dark") final String dark) { if (Strings.isNullOrEmpty(light)) { throw new IllegalArgumentException("light cannot be empty"); } @@ -29,10 +27,6 @@ public class BadgeSvg { throw new IllegalArgumentException("dark cannot be empty"); } this.dark = dark; - if (Strings.isNullOrEmpty(transparent)) { - throw new IllegalArgumentException("transparent cannot be empty"); - } - this.transparent = transparent; } @NotEmpty @@ -45,11 +39,6 @@ public class BadgeSvg { return dark; } - @NotEmpty - public String getTransparent() { - return transparent; - } - @Override public boolean equals(final Object o) { if (this == o) { @@ -60,13 +49,12 @@ public class BadgeSvg { } BadgeSvg badgeSvg = (BadgeSvg) o; return Objects.equals(light, badgeSvg.light) - && Objects.equals(dark, badgeSvg.dark) - && Objects.equals(transparent, badgeSvg.transparent); + && Objects.equals(dark, badgeSvg.dark); } @Override public int hashCode() { - return Objects.hash(light, dark, transparent); + return Objects.hash(light, dark); } @Override @@ -74,7 +62,6 @@ public class BadgeSvg { return "BadgeSvg{" + "light='" + light + '\'' + ", dark='" + dark + '\'' + - ", transparent='" + transparent + '\'' + '}'; } } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/badges/ConfiguredProfileBadgeConverterTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/badges/ConfiguredProfileBadgeConverterTest.java index c5fe27d41..152d24212 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/badges/ConfiguredProfileBadgeConverterTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/badges/ConfiguredProfileBadgeConverterTest.java @@ -69,7 +69,7 @@ public class ConfiguredProfileBadgeConverterTest { private static BadgeConfiguration newBadge(int i) { return new BadgeConfiguration( idFor(i), "other", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", - List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), new BadgeSvg("ll", "ld", "lt"))); + List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld"))); } private BadgesConfiguration createBadges(int count) { @@ -142,8 +142,7 @@ public class ConfiguredProfileBadgeConverterTest { arguments(idFor(0), expired, true, false, null), arguments(idFor(0), notExpired, true, false, new Badge(idFor(0), "other", nameFor(0), desriptionFor(0), List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", - List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), - new BadgeSvg("ll", "ld", "lt")))), + List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld")))), arguments(idFor(1), expired, false, false, null), arguments(idFor(1), notExpired, false, false, null), arguments(idFor(1), expired, true, false, null), @@ -152,13 +151,13 @@ public class ConfiguredProfileBadgeConverterTest { arguments(idFor(0), notExpired, false, true, new SelfBadge(idFor(0), "other", nameFor(0), desriptionFor(0), List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", - List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), new BadgeSvg("ll", "ld", "lt")), + List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld")), notExpired, false)), arguments(idFor(0), expired, true, true, null), arguments(idFor(0), notExpired, true, true, new SelfBadge(idFor(0), "other", nameFor(0), desriptionFor(0), List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", - List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), new BadgeSvg("ll", "ld", "lt")), + List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld")), notExpired, true)), arguments(idFor(1), expired, false, true, null), arguments(idFor(1), notExpired, false, true, null), diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/SubscriptionControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/SubscriptionControllerTest.java index 964b57349..53fc8770c 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/SubscriptionControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/SubscriptionControllerTest.java @@ -82,11 +82,11 @@ class SubscriptionControllerTest { 3L, new SubscriptionLevelConfiguration("B3", "P3", Map.of("USD", new SubscriptionPriceConfiguration("R3", BigDecimal.valueOf(300)))) )); when(BADGE_TRANSLATOR.translate(any(), eq("B1"))).thenReturn(new Badge("B1", "cat1", "name1", "desc1", - List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), new BadgeSvg("ll", "ld", "lt")))); + List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld")))); when(BADGE_TRANSLATOR.translate(any(), eq("B2"))).thenReturn(new Badge("B2", "cat2", "name2", "desc2", - List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), new BadgeSvg("ll", "ld", "lt")))); + List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld")))); when(BADGE_TRANSLATOR.translate(any(), eq("B3"))).thenReturn(new Badge("B3", "cat3", "name3", "desc3", - List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), new BadgeSvg("ll", "ld", "lt")))); + List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld")))); when(LEVEL_TRANSLATOR.translate(any(), eq("B1"))).thenReturn("Z1"); when(LEVEL_TRANSLATOR.translate(any(), eq("B2"))).thenReturn("Z2"); when(LEVEL_TRANSLATOR.translate(any(), eq("B3"))).thenReturn("Z3"); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DonationControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DonationControllerTest.java index 7c7ffb20e..d91451e36 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DonationControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DonationControllerTest.java @@ -91,10 +91,10 @@ class DonationControllerTest { static BadgesConfiguration getBadgesConfiguration() { return new BadgesConfiguration( List.of( - new BadgeConfiguration("TEST", "other", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), new BadgeSvg("ll", "ld", "lt"))), - new BadgeConfiguration("TEST1", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), new BadgeSvg("ll", "ld", "lt"))), - new BadgeConfiguration("TEST2", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), new BadgeSvg("ll", "ld", "lt"))), - new BadgeConfiguration("TEST3", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), new BadgeSvg("ll", "ld", "lt")))), + new BadgeConfiguration("TEST", "other", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld"))), + new BadgeConfiguration("TEST1", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld"))), + new BadgeConfiguration("TEST2", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld"))), + new BadgeConfiguration("TEST3", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld")))), List.of("TEST"), Map.of(1L, "TEST1", 2L, "TEST2", 3L, "TEST3")); } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ProfileControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ProfileControllerTest.java index 011afea75..20f2d654d 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ProfileControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/ProfileControllerTest.java @@ -109,13 +109,13 @@ class ProfileControllerTest { usernamesManager, dynamicConfigurationManager, (acceptableLanguages, accountBadges, isSelf) -> List.of(new Badge("TEST", "other", "Test Badge", - "This badge is in unit tests.", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), new BadgeSvg("ll", "ld", "lt"))) + "This badge is in unit tests.", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld"))) ), new BadgesConfiguration(List.of( - new BadgeConfiguration("TEST", "other", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), new BadgeSvg("ll", "ld", "lt"))), - new BadgeConfiguration("TEST1", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), new BadgeSvg("ll", "ld", "lt"))), - new BadgeConfiguration("TEST2", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), new BadgeSvg("ll", "ld", "lt"))), - new BadgeConfiguration("TEST3", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd", "st"), new BadgeSvg("ml", "md", "mt"), new BadgeSvg("ll", "ld", "lt"))) + new BadgeConfiguration("TEST", "other", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld"))), + new BadgeConfiguration("TEST1", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld"))), + new BadgeConfiguration("TEST2", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld"))), + new BadgeConfiguration("TEST3", "testing", List.of("l", "m", "h", "x", "xx", "xxx"), "SVG", List.of(new BadgeSvg("sl", "sd"), new BadgeSvg("ml", "md"), new BadgeSvg("ll", "ld"))) ), List.of("TEST1"), Map.of(1L, "TEST1", 2L, "TEST2", 3L, "TEST3")), s3client, postPolicyGenerator,