Skip to content

Commit

Permalink
Issue/1851 group table part8 (#1868)
Browse files Browse the repository at this point in the history
* [#1851] added migration

* [#1851] renamed file + small db fixes

* [#1851] using set to prevent duplicates

* [#1851] fixes after PR comment
  • Loading branch information
Valeria Rogatchevskikh authored Aug 17, 2021
1 parent 8479497 commit 4ab9377
Show file tree
Hide file tree
Showing 26 changed files with 167 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@
import io.reactivex.android.schedulers.AndroidSchedulers;
import timber.log.Timber;

public class SurveyInstaller {
public class TestSurveyInstaller {

private static final String TAG = "SurveyInstaller";
private static final String TAG = "TestSurveyInstaller";
private final SurveyDbDataSource adapter;
//Need an array that holds every File so we can delete them in the end
private final Queue<File> surveyFiles = new ArrayDeque<>();

public SurveyInstaller(Context context) {
public TestSurveyInstaller(Context context) {
SqlBrite sqlBrite = new SqlBrite.Builder().build();
DatabaseHelper databaseHelper = new DatabaseHelper(context, new LanguageTable(), new DataPointDownloadTable(), new FormUpdateNotifiedTable(), new QuestionGroupTable());
BriteDatabase db = sqlBrite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

import org.akvo.flow.R;
import org.akvo.flow.activity.FormActivity;
import org.akvo.flow.activity.form.data.SurveyInstaller;
import org.akvo.flow.activity.form.data.TestSurveyInstaller;
import org.akvo.flow.activity.form.data.SurveyRequisite;
import org.akvo.flow.domain.QuestionGroup;
import org.akvo.flow.domain.Survey;
Expand All @@ -59,7 +59,7 @@
@RunWith(AndroidJUnit4.class)
public class CascadeQuestionViewErrorTest {

private static SurveyInstaller installer;
private static TestSurveyInstaller installer;
private static Survey survey;

@Rule
Expand All @@ -75,7 +75,7 @@ protected Intent getActivityIntent() {
public static void beforeClass() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
SurveyRequisite.setRequisites(targetContext);
installer = new SurveyInstaller(targetContext);
installer = new TestSurveyInstaller(targetContext);
survey = installer.installSurvey(cascade_error_form, InstrumentationRegistry.getInstrumentation().getContext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

import org.akvo.flow.R;
import org.akvo.flow.activity.FormActivity;
import org.akvo.flow.activity.form.data.SurveyInstaller;
import org.akvo.flow.activity.form.data.TestSurveyInstaller;
import org.akvo.flow.activity.form.data.SurveyRequisite;
import org.akvo.flow.domain.Node;
import org.akvo.flow.domain.QuestionGroup;
Expand All @@ -74,7 +74,7 @@
@RunWith(AndroidJUnit4.class)
public class CascadeQuestionViewTest {

private static SurveyInstaller installer;
private static TestSurveyInstaller installer;
private static Survey survey;

private final Random random = new Random();
Expand All @@ -92,7 +92,7 @@ protected Intent getActivityIntent() {
public static void beforeClass() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
SurveyRequisite.setRequisites(targetContext);
installer = new SurveyInstaller(targetContext);
installer = new TestSurveyInstaller(targetContext);
survey = installer.installSurvey(cascade_form, InstrumentationRegistry.getInstrumentation().getContext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import org.akvo.flow.R;
import org.akvo.flow.activity.FormActivity;
import org.akvo.flow.activity.form.data.SurveyInstaller;
import org.akvo.flow.activity.form.data.TestSurveyInstaller;
import org.akvo.flow.activity.form.data.SurveyRequisite;
import org.junit.After;
import org.junit.AfterClass;
Expand Down Expand Up @@ -63,7 +63,7 @@
@RunWith(AndroidJUnit4.class)
public class DateQuestionViewTest {

private static SurveyInstaller installer;
private static TestSurveyInstaller installer;

@Rule
public ActivityTestRule<FormActivity> rule = new ActivityTestRule<FormActivity>(
Expand All @@ -78,7 +78,7 @@ protected Intent getActivityIntent() {
public static void beforeClass() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
SurveyRequisite.setRequisites(targetContext);
installer = new SurveyInstaller(targetContext);
installer = new TestSurveyInstaller(targetContext);
installer.installSurvey(date_form, InstrumentationRegistry.getInstrumentation().getContext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import org.akvo.flow.R;
import org.akvo.flow.activity.FormActivity;
import org.akvo.flow.activity.form.data.SurveyInstaller;
import org.akvo.flow.activity.form.data.TestSurveyInstaller;
import org.akvo.flow.activity.form.data.SurveyRequisite;
import org.junit.After;
import org.junit.AfterClass;
Expand Down Expand Up @@ -61,7 +61,7 @@
public class FreeTextDoubleQuestionViewTest {

private static final String FORM_TITLE = "FreeTextForm";
private static SurveyInstaller installer;
private static TestSurveyInstaller installer;

@Rule
public ActivityTestRule<FormActivity> rule = new ActivityTestRule<FormActivity>(
Expand All @@ -76,7 +76,7 @@ protected Intent getActivityIntent() {
public static void beforeClass() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
SurveyRequisite.setRequisites(targetContext);
installer = new SurveyInstaller(targetContext);
installer = new TestSurveyInstaller(targetContext);
installer.installSurvey(freetext_double_entry_form, InstrumentationRegistry.getInstrumentation().getContext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import android.content.Intent;

import org.akvo.flow.activity.FormActivity;
import org.akvo.flow.activity.form.data.SurveyInstaller;
import org.akvo.flow.activity.form.data.TestSurveyInstaller;
import org.akvo.flow.activity.form.data.SurveyRequisite;
import org.junit.After;
import org.junit.AfterClass;
Expand All @@ -50,7 +50,7 @@
@RunWith(AndroidJUnit4.class)
public class FreeTextQuestionViewTest {

private static SurveyInstaller installer;
private static TestSurveyInstaller installer;

@Rule
public ActivityTestRule<FormActivity> rule = new ActivityTestRule<FormActivity>(FormActivity.class) {
Expand All @@ -64,7 +64,7 @@ protected Intent getActivityIntent() {
public static void beforeClass() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
SurveyRequisite.setRequisites(targetContext);
installer = new SurveyInstaller(targetContext);
installer = new TestSurveyInstaller(targetContext);
installer.installSurvey(freetext_form, InstrumentationRegistry.getInstrumentation().getContext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import org.akvo.flow.activity.FormActivity
import org.akvo.flow.activity.form.FormActivityTestUtil.addExecutionDelay
import org.akvo.flow.activity.form.FormActivityTestUtil.getFormActivityIntent
import org.akvo.flow.activity.form.FormActivityTestUtil.getString
import org.akvo.flow.activity.form.data.SurveyInstaller
import org.akvo.flow.activity.form.data.TestSurveyInstaller
import org.akvo.flow.activity.form.data.SurveyRequisite
import org.akvo.flow.event.TimedLocationListener
import org.hamcrest.Description
Expand Down Expand Up @@ -89,7 +89,8 @@ class LockedGeoQuestionViewTest {

val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
SurveyRequisite.setRequisites(targetContext)
val installer = SurveyInstaller(targetContext)
val installer = TestSurveyInstaller(
targetContext)
installer.installSurvey(
raw.locked_geo_form,
InstrumentationRegistry.getInstrumentation().context
Expand Down Expand Up @@ -344,7 +345,8 @@ class LockedGeoQuestionViewTest {
fun afterClass() {
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
SurveyRequisite.resetRequisites(targetContext)
val installer = SurveyInstaller(targetContext)
val installer = TestSurveyInstaller(
targetContext)
installer.clearSurveys()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import org.akvo.flow.R;
import org.akvo.flow.activity.FormActivity;
import org.akvo.flow.activity.form.data.SurveyInstaller;
import org.akvo.flow.activity.form.data.TestSurveyInstaller;
import org.akvo.flow.activity.form.data.SurveyRequisite;
import org.junit.After;
import org.junit.AfterClass;
Expand Down Expand Up @@ -63,7 +63,7 @@ public class ManualGeoQuestionViewTest {
private static final double MOCK_LATITUDE = 10.0;
private static final double MOCK_LONGITUDE = 20.0;

private static SurveyInstaller installer;
private static TestSurveyInstaller installer;

@Rule
public GrantPermissionRule permissionRule = GrantPermissionRule
Expand All @@ -90,7 +90,7 @@ protected Intent getActivityIntent() {
public static void beforeClass() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
SurveyRequisite.setRequisites(targetContext);
installer = new SurveyInstaller(targetContext);
installer = new TestSurveyInstaller(targetContext);
installer.installSurvey(geo_form, InstrumentationRegistry.getInstrumentation().getContext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import org.akvo.flow.R;
import org.akvo.flow.activity.FormActivity;
import org.akvo.flow.activity.form.data.SurveyInstaller;
import org.akvo.flow.activity.form.data.TestSurveyInstaller;
import org.akvo.flow.activity.form.data.SurveyRequisite;
import org.akvo.flow.domain.Survey;
import org.junit.After;
Expand Down Expand Up @@ -63,7 +63,7 @@
@RunWith(AndroidJUnit4.class)
public class NumberQuestionViewTest {

private static SurveyInstaller installer;
private static TestSurveyInstaller installer;
private static Survey survey;

@Rule
Expand All @@ -79,7 +79,7 @@ protected Intent getActivityIntent() {
public static void beforeClass() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
SurveyRequisite.setRequisites(targetContext);
installer = new SurveyInstaller(targetContext);
installer = new TestSurveyInstaller(targetContext);
survey = installer.installSurvey(number_form, InstrumentationRegistry.getInstrumentation().getContext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import org.akvo.flow.R;
import org.akvo.flow.activity.FormActivity;
import org.akvo.flow.activity.form.data.SurveyInstaller;
import org.akvo.flow.activity.form.data.TestSurveyInstaller;
import org.akvo.flow.activity.form.data.SurveyRequisite;
import org.hamcrest.core.IsInstanceOf;
import org.junit.After;
Expand Down Expand Up @@ -63,7 +63,7 @@
public class OptionsQuestionViewMultipleTest {

private static final String FORM_TITLE = "OptionsQuestionForm";
private static SurveyInstaller installer;
private static TestSurveyInstaller installer;

@Rule
public ActivityTestRule<FormActivity> rule = new ActivityTestRule<FormActivity>(
Expand All @@ -78,7 +78,7 @@ protected Intent getActivityIntent() {
public static void beforeClass() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
SurveyRequisite.setRequisites(targetContext);
installer = new SurveyInstaller(targetContext);
installer = new TestSurveyInstaller(targetContext);
installer.installSurvey(option_multiple_other_form, InstrumentationRegistry.getInstrumentation().getContext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.akvo.flow.activity.FormActivity;
import org.akvo.flow.activity.form.data.SurveyInstaller;
import org.akvo.flow.activity.form.data.TestSurveyInstaller;
import org.akvo.flow.activity.form.data.SurveyRequisite;
import org.junit.After;
import org.junit.AfterClass;
Expand All @@ -55,7 +55,7 @@
public class OptionsQuestionViewSingleTest {

private static final String FORM_TITLE = "OptionsQuestionForm";
private static SurveyInstaller installer;
private static TestSurveyInstaller installer;

@Rule
public ActivityTestRule<FormActivity> rule = new ActivityTestRule<FormActivity>(
Expand All @@ -70,7 +70,7 @@ protected Intent getActivityIntent() {
public static void beforeClass() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
SurveyRequisite.setRequisites(targetContext);
installer = new SurveyInstaller(targetContext);
installer = new TestSurveyInstaller(targetContext);
installer.installSurvey(option_form, InstrumentationRegistry.getInstrumentation().getContext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import org.akvo.flow.R;
import org.akvo.flow.activity.FormActivity;
import org.akvo.flow.activity.form.data.SurveyInstaller;
import org.akvo.flow.activity.form.data.TestSurveyInstaller;
import org.akvo.flow.activity.form.data.SurveyRequisite;
import org.akvo.flow.ui.view.QuestionView;
import org.junit.After;
Expand Down Expand Up @@ -56,7 +56,7 @@
public class PhotoQuestionDependentViewTest {

private static final String FORM_TITLE = "New form";
private static SurveyInstaller installer;
private static TestSurveyInstaller installer;

@Rule
public ActivityTestRule<FormActivity> rule = new ActivityTestRule<FormActivity>(
Expand All @@ -71,7 +71,7 @@ protected Intent getActivityIntent() {
public static void beforeClass() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
SurveyRequisite.setRequisites(targetContext);
installer = new SurveyInstaller(targetContext);
installer = new TestSurveyInstaller(targetContext);
installer.installSurvey(photo_form_dependent, InstrumentationRegistry.getInstrumentation().getContext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.akvo.flow.activity.FormActivity;
import org.akvo.flow.activity.form.data.SurveyInstaller;
import org.akvo.flow.activity.form.data.TestSurveyInstaller;
import org.akvo.flow.activity.form.data.SurveyRequisite;
import org.junit.After;
import org.junit.AfterClass;
Expand All @@ -47,7 +47,7 @@
public class PhotoQuestionMandatoryViewTest {

private static final String FORM_TITLE = "New form";
private static SurveyInstaller installer;
private static TestSurveyInstaller installer;

@Rule
public ActivityTestRule<FormActivity> rule = new ActivityTestRule<FormActivity>(
Expand All @@ -62,7 +62,7 @@ protected Intent getActivityIntent() {
public static void beforeClass() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
SurveyRequisite.setRequisites(targetContext);
installer = new SurveyInstaller(targetContext);
installer = new TestSurveyInstaller(targetContext);
installer.installSurvey(photo_form_mandatory, InstrumentationRegistry.getInstrumentation().getContext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.akvo.flow.activity.FormActivity;
import org.akvo.flow.activity.form.data.SurveyInstaller;
import org.akvo.flow.activity.form.data.TestSurveyInstaller;
import org.akvo.flow.activity.form.data.SurveyRequisite;
import org.junit.After;
import org.junit.AfterClass;
Expand All @@ -47,7 +47,7 @@
public class PhotoQuestionNonMandatoryViewTest {

private static final String FORM_TITLE = "New form";
private static SurveyInstaller installer;
private static TestSurveyInstaller installer;

@Rule
public ActivityTestRule<FormActivity> rule = new ActivityTestRule<FormActivity>(
Expand All @@ -62,7 +62,7 @@ protected Intent getActivityIntent() {
public static void beforeClass() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
SurveyRequisite.setRequisites(targetContext);
installer = new SurveyInstaller(targetContext);
installer = new TestSurveyInstaller(targetContext);
installer.installSurvey(photo_form, InstrumentationRegistry.getInstrumentation().getContext());
}

Expand Down
Loading

0 comments on commit 4ab9377

Please sign in to comment.