From 4932142db22b52582f761b9de712b3c0d12e7391 Mon Sep 17 00:00:00 2001 From: Risto Lahtela <24460436+Rsl1122@users.noreply.github.com> Date: Sat, 30 Jan 2021 19:30:31 +0200 Subject: [PATCH] Added tests for ActivityIndex --- .../domain/mutators/ActivityIndexTest.java | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 Plan/common/src/test/java/com/djrapitops/plan/delivery/domain/mutators/ActivityIndexTest.java diff --git a/Plan/common/src/test/java/com/djrapitops/plan/delivery/domain/mutators/ActivityIndexTest.java b/Plan/common/src/test/java/com/djrapitops/plan/delivery/domain/mutators/ActivityIndexTest.java new file mode 100644 index 000000000..0ec175d81 --- /dev/null +++ b/Plan/common/src/test/java/com/djrapitops/plan/delivery/domain/mutators/ActivityIndexTest.java @@ -0,0 +1,109 @@ +package com.djrapitops.plan.delivery.domain.mutators; + +import com.djrapitops.plan.settings.locale.Locale; +import com.djrapitops.plan.settings.locale.Message; +import com.djrapitops.plan.settings.locale.lang.HtmlLang; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + +class ActivityIndexTest { + + @Test + void localeIsUsedWhenGivenForGetGroups() { + Locale locale = createTestLocale(); + + String[] expected = new String[]{"A", "B", "C", "D", "E"}; + String[] result = ActivityIndex.getGroups(locale); + assertArrayEquals(expected, result); + } + + private Locale createTestLocale() { + Locale locale = new Locale(); + locale.put(HtmlLang.INDEX_VERY_ACTIVE, new Message("A")); + locale.put(HtmlLang.INDEX_ACTIVE, new Message("B")); + locale.put(HtmlLang.INDEX_REGULAR, new Message("C")); + locale.put(HtmlLang.INDEX_IRREGULAR, new Message("D")); + locale.put(HtmlLang.INDEX_INACTIVE, new Message("E")); + return locale; + } + + @Test + void localeDefaultGroups() { + String[] expected = new String[]{"Very Active", "Active", "Regular", "Irregular", "Inactive"}; + String[] result = ActivityIndex.getDefaultGroups(); + assertArrayEquals(expected, result); + } + + @Test + void veryActiveGroup() { + String expected = HtmlLang.INDEX_VERY_ACTIVE.getDefault(); + String result = new ActivityIndex(ActivityIndex.VERY_ACTIVE, 0).getGroup(); + assertEquals(expected, result); + } + + @Test + void activeGroup() { + String expected = HtmlLang.INDEX_ACTIVE.getDefault(); + String result = new ActivityIndex(ActivityIndex.ACTIVE, 0).getGroup(); + assertEquals(expected, result); + } + + @Test + void regularGroup() { + String expected = HtmlLang.INDEX_REGULAR.getDefault(); + String result = new ActivityIndex(ActivityIndex.REGULAR, 0).getGroup(); + assertEquals(expected, result); + } + + @Test + void irregularGroup() { + String expected = HtmlLang.INDEX_IRREGULAR.getDefault(); + String result = new ActivityIndex(ActivityIndex.IRREGULAR, 0).getGroup(); + assertEquals(expected, result); + } + + @Test + void inactiveGroup() { + String expected = HtmlLang.INDEX_INACTIVE.getDefault(); + String result = new ActivityIndex(0.0, 0).getGroup(); + assertEquals(expected, result); + } + + @Test + void veryActiveGroupWithLocale() { + String expected = "A"; + String result = new ActivityIndex(ActivityIndex.VERY_ACTIVE, 0).getGroup(createTestLocale()); + assertEquals(expected, result); + } + + @Test + void activeGroupWithLocale() { + String expected = "B"; + String result = new ActivityIndex(ActivityIndex.ACTIVE, 0).getGroup(createTestLocale()); + assertEquals(expected, result); + } + + @Test + void regularGroupWithLocale() { + String expected = "C"; + String result = new ActivityIndex(ActivityIndex.REGULAR, 0).getGroup(createTestLocale()); + assertEquals(expected, result); + } + + @Test + void irregularGroupWithLocale() { + String expected = "D"; + String result = new ActivityIndex(ActivityIndex.IRREGULAR, 0).getGroup(createTestLocale()); + assertEquals(expected, result); + } + + @Test + void inactiveGroupWithLocale() { + String expected = "E"; + String result = new ActivityIndex(0.0, 0).getGroup(createTestLocale()); + assertEquals(expected, result); + } + +} \ No newline at end of file