Skip to content

Commit

Permalink
elimu-ai#1396 Created CsvSoundExtractionHelperTest with basic test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
vrudas committed Jul 2, 2022
1 parent e32dece commit a52e3fd
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/test/java/ai/elimu/util/csv/CsvSoundExtractionHelperTest.java
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);
}

}

0 comments on commit a52e3fd

Please sign in to comment.