-
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.
Merge pull request #3 from agstack/feature/clean-architecture
Feature/clean architecture
- Loading branch information
Showing
117 changed files
with
6,994 additions
and
4,399 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
34 changes: 0 additions & 34 deletions
34
app/src/androidTest/java/org/technoserve/farmcollector/GreetingTestKtTest.kt
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
...c/androidTest/java/org/technoserve/farmcollector/ui/components/KeepPolygonDialogKtTest.kt
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,49 @@ | ||
package org.technoserve.farmcollector.ui.components | ||
|
||
import org.junit.Assert.* | ||
|
||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewmodel.compose.viewModel | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
class FakeMapViewModel : ViewModel() { | ||
var coordinatesCleared = false | ||
|
||
fun clearCoordinates() { | ||
coordinatesCleared = true | ||
} | ||
} | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class KeepPolygonDialogIntegrationTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun testKeepPolygonDialogClearsCoordinatesAndCapturesNew() { | ||
val fakeViewModel = FakeMapViewModel() | ||
|
||
composeTestRule.setContent { | ||
KeepPolygonDialog( | ||
onDismiss = {}, | ||
onKeepExisting = {}, | ||
onCaptureNew = { | ||
fakeViewModel.clearCoordinates() | ||
} | ||
) | ||
} | ||
|
||
// Click the "Capture New" button | ||
composeTestRule.onNodeWithText("Capture New").performClick() | ||
|
||
// Assert that coordinates were cleared | ||
assert(fakeViewModel.coordinatesCleared) | ||
} | ||
} |
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
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
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,44 @@ | ||
-- Step 1: Create a new temporary table with the updated schema | ||
CREATE TABLE new_Farms ( | ||
siteId INTEGER NOT NULL, | ||
remote_id BLOB NOT NULL, | ||
farmerPhoto TEXT NOT NULL, | ||
farmerName TEXT NOT NULL, | ||
memberId TEXT NOT NULL, | ||
village TEXT NOT NULL, | ||
district TEXT NOT NULL, | ||
purchases REAL, | ||
size REAL NOT NULL, | ||
latitude TEXT NOT NULL, | ||
longitude TEXT NOT NULL, | ||
coordinates TEXT, | ||
synced INTEGER NOT NULL DEFAULT 0, | ||
scheduledForSync INTEGER NOT NULL DEFAULT 0, | ||
createdAt INTEGER NOT NULL, | ||
updatedAt INTEGER NOT NULL, | ||
needsUpdate INTEGER NOT NULL DEFAULT 0, | ||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, | ||
FOREIGN KEY (siteId) | ||
REFERENCES CollectionSites (siteId) | ||
ON UPDATE NO ACTION | ||
ON DELETE CASCADE | ||
); | ||
|
||
-- Step 2: Copy data from the old table to the new table, setting needsUpdate to 0 | ||
INSERT INTO new_Farms ( | ||
siteId, remote_id, farmerPhoto, farmerName, memberId, | ||
village, district, purchases, size, latitude, longitude, | ||
coordinates, synced, scheduledForSync, createdAt, updatedAt, needsUpdate, id | ||
) | ||
SELECT | ||
siteId, remote_id, farmerPhoto, farmerName, memberId, | ||
village, district, purchases, size, latitude, longitude, | ||
coordinates, synced, scheduledForSync, createdAt, updatedAt, 0 AS needsUpdate, id | ||
FROM Farms; | ||
|
||
-- Step 3: Drop the old table | ||
DROP TABLE Farms; | ||
|
||
-- Step 4: Rename the new table to the original table name | ||
ALTER TABLE new_Farms RENAME TO Farms; | ||
|
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,44 @@ | ||
CREATE TABLE new_Farms ( | ||
siteId INTEGER NOT NULL, | ||
remote_id BLOB NOT NULL, | ||
farmerPhoto TEXT NOT NULL, | ||
farmerName TEXT NOT NULL, | ||
memberId TEXT NOT NULL, | ||
village TEXT NOT NULL, | ||
district TEXT NOT NULL, | ||
purchases REAL, | ||
size REAL NOT NULL, | ||
latitude TEXT NOT NULL, | ||
longitude TEXT NOT NULL, | ||
coordinates TEXT, | ||
synced INTEGER NOT NULL DEFAULT 0, | ||
scheduledForSync INTEGER NOT NULL DEFAULT 0, | ||
createdAt INTEGER NOT NULL, | ||
updatedAt INTEGER NOT NULL, | ||
needsUpdate INTEGER NOT NULL DEFAULT 0, | ||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, | ||
FOREIGN KEY (siteId) | ||
REFERENCES CollectionSites (siteId) ON UPDATE NO ACTION | ||
ON DELETE CASCADE | ||
) | ||
|
||
|
||
// Step 2: Copy data from the old table to the new table, setting needsUpdate to 0 | ||
|
||
INSERT INTO new_Farms ( | ||
siteId, remote_id, farmerPhoto, farmerName, memberId, | ||
village, district, purchases, size, latitude, longitude, | ||
coordinates, synced, scheduledForSync, createdAt, updatedAt, needsUpdate, id | ||
) | ||
SELECT | ||
siteId, remote_id, farmerPhoto, farmerName, memberId, | ||
village, district, purchases, size, latitude, longitude, | ||
coordinates, synced, scheduledForSync, createdAt, updatedAt,0 AS needsUpdate, id | ||
FROM Farms | ||
|
||
|
||
// Step 3: Drop the old table | ||
DROP TABLE Farms | ||
|
||
// Step 4: Rename the new table to the original table name | ||
"ALTER TABLE new_Farms RENAME TO Farms" |
Oops, something went wrong.