diff --git a/.idea/sonarIssues.xml b/.idea/sonarIssues.xml index 2ffa243..a62a482 100644 --- a/.idea/sonarIssues.xml +++ b/.idea/sonarIssues.xml @@ -118,6 +118,11 @@ + + + + + diff --git a/engine/src/androidTest/java/dgca/verifier/app/engine/data/source/local/RulesDaoTest.kt b/engine/src/androidTest/java/dgca/verifier/app/engine/data/source/local/RulesDaoTest.kt index 0b17c16..85d76c4 100644 --- a/engine/src/androidTest/java/dgca/verifier/app/engine/data/source/local/RulesDaoTest.kt +++ b/engine/src/androidTest/java/dgca/verifier/app/engine/data/source/local/RulesDaoTest.kt @@ -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 @@ -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( diff --git a/engine/src/androidTest/resources/rule.json b/engine/src/androidTest/resources/rule.json index aae1af9..c743ed0 100644 --- a/engine/src/androidTest/resources/rule.json +++ b/engine/src/androidTest/resources/rule.json @@ -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 ] } } \ No newline at end of file diff --git a/engine/src/main/java/dgca/verifier/app/engine/data/source/local/rules/RuleWithDescriptionsLocal.kt b/engine/src/main/java/dgca/verifier/app/engine/data/source/local/rules/RuleWithDescriptionsLocal.kt index dc7bbe1..4fb6abb 100644 --- a/engine/src/main/java/dgca/verifier/app/engine/data/source/local/rules/RuleWithDescriptionsLocal.kt +++ b/engine/src/main/java/dgca/verifier/app/engine/data/source/local/rules/RuleWithDescriptionsLocal.kt @@ -50,7 +50,7 @@ data class RuleWithDescriptionsLocal( @Embedded val rule: RuleLocal, @Relation( parentColumn = "ruleId", - entityColumn = "descriptionId" + entityColumn = "ruleContainerId" ) val descriptions: List ) \ No newline at end of file diff --git a/engine/src/main/java/dgca/verifier/app/engine/data/source/local/rules/RulesDao.kt b/engine/src/main/java/dgca/verifier/app/engine/data/source/local/rules/RulesDao.kt index 2a003f7..c6d3951 100644 --- a/engine/src/main/java/dgca/verifier/app/engine/data/source/local/rules/RulesDao.kt +++ b/engine/src/main/java/dgca/verifier/app/engine/data/source/local/rules/RulesDao.kt @@ -76,7 +76,7 @@ abstract class RulesDao { abstract fun deleteRulesBy(vararg identifiers: String) @Insert - abstract fun insertDescriptions(descriptions: Collection) + abstract fun insertDescriptions(vararg descriptions: DescriptionLocal) fun insertAll(vararg rulesWithDescription: RuleWithDescriptionsLocal) { rulesWithDescription.forEach { ruleWithDescriptionsLocal -> @@ -91,7 +91,7 @@ abstract class RulesDao { ) ) } - insertDescriptions(descriptionsToBeInserted) + insertDescriptions(*descriptionsToBeInserted.toTypedArray()) } }