Skip to content

Commit

Permalink
Updated descriptions storing logic (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandrsarapulovgl authored Jul 5, 2021
1 parent dc50401 commit f8d9d3d
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .idea/sonarIssues.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.fasterxml.jackson.databind.ObjectMapper
import dgca.verifier.app.engine.data.RuleCertificateType
import dgca.verifier.app.engine.data.source.local.rules.EngineDatabase
import dgca.verifier.app.engine.data.source.local.rules.RuleWithDescriptionsLocal
import dgca.verifier.app.engine.data.source.local.rules.RulesDao
import dgca.verifier.app.engine.data.source.local.rules.EngineDatabase
import dgca.verifier.app.engine.data.source.local.rules.toRuleWithDescriptionLocal
import dgca.verifier.app.engine.data.source.remote.rules.RuleRemote
import dgca.verifier.app.engine.data.source.remote.rules.toRule
Expand Down Expand Up @@ -105,6 +105,7 @@ internal class RulesDaoTest {

assertTrue(actual.size == 1)
assertEquals(expected.rule.copy(ruleId = 1), actual[0].rule)
assertEquals(2, actual[0].descriptions)
expected.descriptions.forEachIndexed { index, descriptionLocal ->
assertEquals(
descriptionLocal.copy(
Expand Down
66 changes: 51 additions & 15 deletions engine/src/androidTest/resources/rule.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,56 @@
{
"Identifier": "VR-DE-1",
"Identifier": "GR-SE-0001",
"Type": "Acceptance",
"Country": "SE",
"Version": "1.0.0",
"SchemaVersion":"1.0.0",
"Engine":"CERTLOGIC",
"EngineVersion":"1.0.0",
"Type":"Acceptance",
"Country":"DE",
"CertificateType":"Vaccination",
"Description":[{"lang":"en","desc":"Vaccination must be from June and doses must be 2"}],
"ValidFrom":"2021-06-27T07:46:40Z",
"ValidTo":"2021-08-01T07:46:40Z",
"AffectedFields":["dt","dn"],
"Logic":{
"and": [
{">=":[ {"var":"dt"}, "2021-06-01T00:00:00Z" ]},
{">=":[ {"var":"dn"}, 2 ]}
"SchemaVersion": "1.0.0",
"Engine": "CERTLOGIC",
"EngineVersion": "0.7.5",
"CertificateType": "General",
"Description": [
{
"lang": "en",
"desc": "The positive NAA test result (e.g., PCR) must be no older than 6 months."
},
{
"lang": "sv",
"desc": "Ett positivt NAA test resultat (ex PCR) får inte vara äldre än 6 månader"
}
],
"ValidFrom": "2021-07-05T20:27:25Z",
"ValidTo": "2021-07-19T20:27:25Z",
"AffectedFields": [
"r.0",
"r.0.fr"
],
"Logic": {
"if": [
{
"var": "payload.r.0"
},
{
"not-after": [
{
"plusTime": [
{
"var": "external.validationClock"
},
0,
"day"
]
},
{
"plusTime": [
{
"var": "payload.r.0.fr"
},
183,
"day"
]
}
]
},
true
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ data class RuleWithDescriptionsLocal(
@Embedded val rule: RuleLocal,
@Relation(
parentColumn = "ruleId",
entityColumn = "descriptionId"
entityColumn = "ruleContainerId"
)
val descriptions: List<DescriptionLocal>
)
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ abstract class RulesDao {
abstract fun deleteRulesBy(vararg identifiers: String)

@Insert
abstract fun insertDescriptions(descriptions: Collection<DescriptionLocal>)
abstract fun insertDescriptions(vararg descriptions: DescriptionLocal)

fun insertAll(vararg rulesWithDescription: RuleWithDescriptionsLocal) {
rulesWithDescription.forEach { ruleWithDescriptionsLocal ->
Expand All @@ -91,7 +91,7 @@ abstract class RulesDao {
)
)
}
insertDescriptions(descriptionsToBeInserted)
insertDescriptions(*descriptionsToBeInserted.toTypedArray())
}
}

Expand Down

0 comments on commit f8d9d3d

Please sign in to comment.