Cleanup: refactored importers.

This commit is contained in:
Dennis Guse
2021-05-01 00:51:13 +02:00
parent f277347529
commit 92004b0ec7
6 changed files with 49 additions and 69 deletions
@@ -22,7 +22,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.time.Instant;
@@ -154,7 +153,7 @@ public class ExportImportTest {
@LargeTest
@Test
public void kml_with_trackdetail() throws TimeoutException, FileNotFoundException {
public void kml_with_trackdetail() throws TimeoutException, IOException {
setUp(false);
// given
@@ -194,7 +193,7 @@ public class ExportImportTest {
@LargeTest
@Test
public void kml_with_trackdetail_and_sensordata() throws TimeoutException, FileNotFoundException {
public void kml_with_trackdetail_and_sensordata() throws TimeoutException, IOException {
setUp(true);
// given
@@ -248,9 +247,8 @@ public class ExportImportTest {
contentProviderUtils.deleteTrack(context, trackId);
// 2. import
InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri);
TrackImporter trackImporter = new KmzTrackImporter(context, tmpFileUri);
importTrackId = trackImporter.importFile(inputStream).get(0);
KmzTrackImporter trackImporter = new KmzTrackImporter();
importTrackId = trackImporter.importFile(context, tmpFileUri).get(0);
// then
// 1. track
@@ -273,7 +271,7 @@ public class ExportImportTest {
@LargeTest
@Test(expected = ImportAlreadyExistsException.class)
public void kml_with_trackdetail_and_sensordata_duplicate_trackUUID() throws TimeoutException, FileNotFoundException {
public void kml_with_trackdetail_and_sensordata_duplicate_trackUUID() throws TimeoutException, IOException {
setUp(false);
// given
@@ -299,7 +297,7 @@ public class ExportImportTest {
@LargeTest
@Test
public void gpx() throws TimeoutException, FileNotFoundException {
public void gpx() throws TimeoutException, IOException {
setUp(true);
// given
@@ -346,7 +344,7 @@ public class ExportImportTest {
@LargeTest
@Test(expected = ImportAlreadyExistsException.class)
public void gpx_duplicate_trackUUID() throws TimeoutException, FileNotFoundException {
public void gpx_duplicate_trackUUID() throws TimeoutException, IOException {
setUp(false);
// given
@@ -11,6 +11,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
@@ -48,7 +49,7 @@ public class LegacyImportTest {
*/
@LargeTest
@Test
public void kml_with_statistics_marker() {
public void kml_with_statistics_marker() throws IOException {
// given
XMLImporter trackImporter = new XMLImporter(new KmlFileTrackImporter(context));
InputStream inputStream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(de.dennisguse.opentracks.debug.test.R.raw.legacy_kml_statistics_marker);
@@ -90,7 +91,7 @@ public class LegacyImportTest {
*/
@LargeTest
@Test(expected = ImportParserException.class)
public void kml_without_locations() {
public void kml_without_locations() throws IOException {
// given
XMLImporter trackImporter = new XMLImporter(new KmlFileTrackImporter(context));
InputStream inputStream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(de.dennisguse.opentracks.debug.test.R.raw.legacy_kml_empty);
@@ -104,7 +105,7 @@ public class LegacyImportTest {
*/
@LargeTest
@Test
public void gpx_with_pause_resume() {
public void gpx_with_pause_resume() throws IOException {
// given
XMLImporter trackImporter = new XMLImporter(new GpxFileTrackImporter(context));
InputStream inputStream = InstrumentationRegistry.getInstrumentation().getContext().getResources().openRawResource(de.dennisguse.opentracks.debug.test.R.raw.legacy_gpx_pause_resume);