Adjust tests of class LocalizedPriority.
package io.jenkins.plugins.analysis.core.views;
+import java.util.Locale;
import edu.hm.hafner.analysis.Priority;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static edu.hm.hafner.analysis.assertj.Assertions.*;
+import hudson.plugins.analysis.Messages;
/**
* Tests the class {@link LocalizedPriority}.
@@ -10,64 +13,36 @@ import static edu.hm.hafner.analysis.assertj.Assertions.*;
* @author Anna-Maria Hardi
*/
class LocalizedPriorityTest {
- @Test
- void priorityIsHigh() {
- String actualResult = LocalizedPriority.getLocalizedString(Priority.HIGH);
- assertThat(actualResult).isNotEmpty();
- //assertThat(actualResult).contains("Hoch");
- assertThat(actualResult).inUnicode();
- }
-
- @Test
- void priorityIsHighLong() {
- String actualResult = LocalizedPriority.getLongLocalizedString(Priority.HIGH);
- assertThat(actualResult).isNotEmpty();
- //assertThat(actualResult).contains("Hohe Prioritt");
- assertThat(actualResult).inUnicode();
- }
-
- @Test
- void priorityIsLow() {
- String actualResult = LocalizedPriority.getLocalizedString(Priority.LOW);
- assertThat(actualResult).isNotEmpty();
- //assertThat(actualResult).contains("Niedrig");
- assertThat(actualResult).inUnicode();
- }
- @Test
- void priorityIsLowLong() {
- String actualResult = LocalizedPriority.getLongLocalizedString(Priority.LOW);
- assertThat(actualResult).isNotEmpty();
- //assertThat(actualResult).contains("Niedrige Prioritt");
- assertThat(actualResult).inUnicode();
- }
-
- @Test
- void priorityIsNormal() {
- String actualResult = LocalizedPriority.getLocalizedString(Priority.NORMAL);
- assertThat(actualResult).isNotEmpty();
- //assertThat(actualResult).contains("Normal");
- assertThat(actualResult).inUnicode();
- }
-
- @Test
- void priorityIsNormalLong() {
- String actualResult = LocalizedPriority.getLongLocalizedString(Priority.NORMAL);
- assertThat(actualResult).isNotEmpty();
- //assertThat(actualResult).contains("Normale Prioritt");
- assertThat(actualResult).inUnicode();
+ @BeforeAll
+ static void initializeLocale() {
+ Locale.setDefault(Locale.ENGLISH);
}
@Test
- void priorityIsNull() {
- String actualResult = LocalizedPriority.getLocalizedString(null);
- //assertThat(actualResult).contains("Normal");
+ void testLocalizedStringHighLowNormalNull() {
+ String actualResult;
+ actualResult = LocalizedPriority.getLocalizedString(Priority.HIGH);
+ assertThat(actualResult).isEqualTo(Messages.Priority_High());
+ actualResult = LocalizedPriority.getLocalizedString(Priority.LOW);
+ assertThat(actualResult).isEqualTo(Messages.Priority_Low());
+ actualResult = LocalizedPriority.getLocalizedString(Priority.NORMAL);
+ assertThat(actualResult).isEqualTo(Messages.Priority_Normal());
+ actualResult = LocalizedPriority.getLocalizedString(null);
+ assertThat(actualResult).isEqualTo(Messages.Priority_Normal());
}
@Test
- void priorityIsNullLong() {
- String actualResult = LocalizedPriority.getLongLocalizedString(null);
- //assertThat(actualResult).contains("Normale Prioritt");
+ void testLongLocalizedStringHighLowNormalNull() {
+ String actualResult;
+ actualResult = LocalizedPriority.getLongLocalizedString(Priority.HIGH);
+ assertThat(actualResult).isEqualTo(Messages.HighPriority());
+ actualResult = LocalizedPriority.getLongLocalizedString(Priority.LOW);
+ assertThat(actualResult).isEqualTo(Messages.LowPriority());
+ actualResult = LocalizedPriority.getLongLocalizedString(Priority.NORMAL);
+ assertThat(actualResult).isEqualTo(Messages.NormalPriority());
+ actualResult = LocalizedPriority.getLongLocalizedString(null);
+ assertThat(actualResult).isEqualTo(Messages.NormalPriority());
}
}
\ No newline at end of file
