mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 21:48:06 +01:00
Extract logic for created header controlled resource bundles
This commit is contained in:
@@ -29,6 +29,8 @@ import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.signal.i18n.HeaderControlledResourceBundleLookup;
|
||||
import org.signal.i18n.ResourceBundleFactory;
|
||||
import org.whispersystems.textsecuregcm.configuration.BadgeConfiguration;
|
||||
import org.whispersystems.textsecuregcm.configuration.BadgesConfiguration;
|
||||
import org.whispersystems.textsecuregcm.entities.Badge;
|
||||
@@ -66,7 +68,8 @@ 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")));
|
||||
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")));
|
||||
}
|
||||
|
||||
private BadgesConfiguration createBadges(int count) {
|
||||
@@ -104,7 +107,7 @@ public class ConfiguredProfileBadgeConverterTest {
|
||||
void testConvertEmptyList() {
|
||||
BadgesConfiguration badgesConfiguration = createBadges(1);
|
||||
ConfiguredProfileBadgeConverter badgeConverter = new ConfiguredProfileBadgeConverter(clock, badgesConfiguration,
|
||||
resourceBundleFactory);
|
||||
new HeaderControlledResourceBundleLookup(resourceBundleFactory));
|
||||
assertThat(badgeConverter.convert(List.of(Locale.getDefault()), List.of(), false)).isNotNull().isEmpty();
|
||||
}
|
||||
|
||||
@@ -113,7 +116,8 @@ public class ConfiguredProfileBadgeConverterTest {
|
||||
void testNoLocales(String name, Instant expiration, boolean visible, boolean isSelf, Badge expectedBadge) {
|
||||
BadgesConfiguration badgesConfiguration = createBadges(1);
|
||||
ConfiguredProfileBadgeConverter badgeConverter =
|
||||
new ConfiguredProfileBadgeConverter(clock, badgesConfiguration, resourceBundleFactory);
|
||||
new ConfiguredProfileBadgeConverter(clock, badgesConfiguration,
|
||||
new HeaderControlledResourceBundleLookup(resourceBundleFactory));
|
||||
setupResourceBundle(Locale.getDefault());
|
||||
|
||||
if (expectedBadge != null) {
|
||||
@@ -136,15 +140,26 @@ public class ConfiguredProfileBadgeConverterTest {
|
||||
arguments(idFor(0), expired, false, false, null),
|
||||
arguments(idFor(0), notExpired, false, false, null),
|
||||
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")))),
|
||||
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")))),
|
||||
arguments(idFor(1), expired, false, false, null),
|
||||
arguments(idFor(1), notExpired, false, false, null),
|
||||
arguments(idFor(1), expired, true, false, null),
|
||||
arguments(idFor(1), notExpired, true, false, null),
|
||||
arguments(idFor(0), expired, false, true, null),
|
||||
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")), notExpired, false)),
|
||||
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")),
|
||||
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")), notExpired, true)),
|
||||
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")),
|
||||
notExpired, true)),
|
||||
arguments(idFor(1), expired, false, true, null),
|
||||
arguments(idFor(1), notExpired, false, true, null),
|
||||
arguments(idFor(1), expired, true, true, null),
|
||||
@@ -155,7 +170,8 @@ public class ConfiguredProfileBadgeConverterTest {
|
||||
void testCustomControl() {
|
||||
BadgesConfiguration badgesConfiguration = createBadges(1);
|
||||
ConfiguredProfileBadgeConverter badgeConverter =
|
||||
new ConfiguredProfileBadgeConverter(clock, badgesConfiguration, resourceBundleFactory);
|
||||
new ConfiguredProfileBadgeConverter(clock, badgesConfiguration,
|
||||
new HeaderControlledResourceBundleLookup(resourceBundleFactory));
|
||||
|
||||
Locale defaultLocale = Locale.getDefault();
|
||||
Locale enGb = new Locale("en", "GB");
|
||||
|
||||
Reference in New Issue
Block a user