forked from elimu-ai/webapp
-
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.
elimu-ai#1396 Created CsvSoundExtractionHelperTest with basic test cases
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/test/java/ai/elimu/util/csv/CsvSoundExtractionHelperTest.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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package ai.elimu.util.csv; | ||
|
||
import ai.elimu.model.content.Sound; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
import java.io.File; | ||
import java.nio.file.Files; | ||
import java.util.List; | ||
|
||
import static ai.elimu.util.csv.CsvSoundExtractionHelper.getSoundsFromCsvBackup; | ||
import static java.util.Collections.emptyList; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
public class CsvSoundExtractionHelperTest { | ||
|
||
private static final String HEADERS_LINE = "id,value_ipa,audio_id,diacritic,sound_type,usage_count"; | ||
|
||
@Rule | ||
public TemporaryFolder folder = new TemporaryFolder(); | ||
|
||
private File soundsCsv; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
soundsCsv = folder.newFile("sounds.csv"); | ||
} | ||
|
||
@Test | ||
public void extracted_empty_sounds_for_csv_file_with_empty_content() { | ||
List<Sound> soundsFromCsvBackup = getSoundsFromCsvBackup(soundsCsv); | ||
|
||
assertEquals(emptyList(), soundsFromCsvBackup); | ||
} | ||
|
||
@Test | ||
public void extracted_empty_sounds_for_csv_file_only_with_headers() throws Exception { | ||
Files.writeString( | ||
soundsCsv.toPath(), | ||
HEADERS_LINE | ||
); | ||
|
||
List<Sound> soundsFromCsvBackup = getSoundsFromCsvBackup(soundsCsv); | ||
|
||
assertEquals(emptyList(), soundsFromCsvBackup); | ||
} | ||
|
||
} |