-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify KanaConverterTest in backend to resolve sonar warnings
- Loading branch information
Showing
1 changed file
with
20 additions
and
16 deletions.
There are no files selected for viewing
36 changes: 20 additions & 16 deletions
36
backend/src/test/java/de/neuefische/koheis/backend/converter/KanaConverterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,39 @@ | ||
package de.neuefische.koheis.backend.converter; | ||
|
||
import com.ibm.icu.text.Transliterator; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.MockitoAnnotations; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import org.mockito.Mockito; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class KanaConverterTest { | ||
|
||
public class KanaConverterTest { | ||
private KanaConverter kanaConverter; | ||
|
||
@Before | ||
public void setUp() { | ||
MockitoAnnotations.initMocks(this); | ||
@Mock | ||
private Transliterator transliterator; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
kanaConverter = new KanaConverter(); | ||
} | ||
|
||
@Test | ||
public void testConvertHiraganaToAlphabet() { | ||
void testConvertHiraganaToAlphabet() { | ||
String hiragana = "ひらがな"; | ||
Transliterator trans = Transliterator.getInstance("Hiragana-Latin"); | ||
String expected = trans.transliterate(hiragana); | ||
Mockito.lenient().when(transliterator.transliterate(hiragana)).thenReturn("hiragana"); | ||
String result = kanaConverter.convertHiraganaToAlphabet(hiragana); | ||
assertEquals(expected, result); | ||
assertEquals("hiragana", result); | ||
} | ||
|
||
@Test | ||
public void testConvertKatakanaToAlphabet() { | ||
void testConvertKatakanaToAlphabet() { | ||
String katakana = "カタカナ"; | ||
Transliterator trans = Transliterator.getInstance("Katakana-Latin"); | ||
String expected = trans.transliterate(katakana); | ||
Mockito.lenient().when(transliterator.transliterate(katakana)).thenReturn("katakana"); | ||
String result = kanaConverter.convertKatakanaToAlphabet(katakana); | ||
assertEquals(expected, result); | ||
assertEquals("katakana", result); | ||
} | ||
} |