Skip to content

Commit

Permalink
Feature/countries loading (#9)
Browse files Browse the repository at this point in the history
* Implemented countries loading

* update
  • Loading branch information
oleksandrsarapulovgl authored Jun 25, 2021
1 parent d45e32a commit 19cc7cd
Show file tree
Hide file tree
Showing 56 changed files with 913 additions and 112 deletions.
10 changes: 10 additions & 0 deletions .idea/sonarIssues.xml

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

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
34 changes: 1 addition & 33 deletions .idea/sonarlint/issuestore/index.pb

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

2 changes: 2 additions & 0 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ object Deps {

const val room_runtime = "androidx.room:room-runtime:${Versions.room_version}"
const val room_compiler = "androidx.room:room-compiler:${Versions.room_version}"
const val lifecycle_livedata_version = "androidx.lifecycle:lifecycle-livedata-ktx:${Versions.lifecycle_livedata_version}"
const val room_ktx = "androidx.room:room-ktx:${Versions.room_ktx}"
}
2 changes: 2 additions & 0 deletions buildSrc/src/main/java/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ object Versions {
const val retrofit = "2.9.0"
const val appache_commons = "2.9.0"
const val room_version = "2.3.0"
const val lifecycle_livedata_version = "2.4.0-alpha02"
const val room_ktx = "2.4.0-alpha03"

// Tests
const val junit = "4.13.1"
Expand Down
2 changes: 2 additions & 0 deletions engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ dependencies {
implementation Deps.jackson_kotlin
implementation Deps.jackson_datetype
implementation Deps.retrofit2
implementation Deps.lifecycle_livedata_version
implementation Deps.room_ktx

implementation Deps.room_runtime
kapt Deps.room_compiler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ 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.CertificateType
import dgca.verifier.app.engine.data.source.remote.RuleRemote
import dgca.verifier.app.engine.data.source.remote.toRule
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
import org.apache.commons.io.IOUtils
import org.junit.After
import org.junit.Assert.assertEquals
Expand Down Expand Up @@ -43,7 +47,7 @@ import java.nio.charset.Charset
@RunWith(AndroidJUnit4::class)
internal class RulesDaoTest {
private lateinit var rulesDao: RulesDao
private lateinit var db: RulesDatabase
private lateinit var db: EngineDatabase
private val objectMapper = ObjectMapper().apply { this.findAndRegisterModules() }

companion object {
Expand All @@ -62,7 +66,7 @@ internal class RulesDaoTest {
fun createDb() {
val context = ApplicationProvider.getApplicationContext<Context>()
db = Room.inMemoryDatabaseBuilder(
context, RulesDatabase::class.java
context, EngineDatabase::class.java
).build()
rulesDao = db.rulesDao()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dgca.verifier.app.engine

import dgca.verifier.app.engine.data.Rule
import dgca.verifier.app.engine.data.source.remote.RuleRemote

/*-
* ---license-start
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* ---license-start
* eu-digital-green-certificates / dgca-verifier-app-android
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ---license-end
*
* Created by osarapulov on 6/25/21 9:15 AM
*/

package dgca.verifier.app.engine.data.source.countries

import kotlinx.coroutines.flow.Flow

/*-
* ---license-start
* eu-digital-green-certificates / dgc-certlogic-android
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ---license-end
*
* Created by osarapulov on 25.06.21 9:15
*/
interface CountriesDataSource {
/**
* Provides list of countries ISO codes.
*/
fun getCountries(): Flow<List<String>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* ---license-start
* eu-digital-green-certificates / dgca-verifier-app-android
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ---license-end
*
* Created by osarapulov on 6/25/21 9:27 AM
*/

package dgca.verifier.app.engine.data.source.countries

/*-
* ---license-start
* eu-digital-green-certificates / dgc-certlogic-android
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ---license-end
*
* Created by osarapulov on 25.06.21 9:15
*/
interface CountriesRepository: CountriesDataSource {
suspend fun preLoadCountries(countriesUrl: String)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* ---license-start
* eu-digital-green-certificates / dgca-verifier-app-android
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ---license-end
*
* Created by osarapulov on 6/25/21 9:28 AM
*/

package dgca.verifier.app.engine.data.source.countries

import dgca.verifier.app.engine.data.source.local.countries.CountriesLocalDataSource
import dgca.verifier.app.engine.data.source.remote.countries.CountriesRemoteDataSrouce
import kotlinx.coroutines.flow.Flow

/*-
* ---license-start
* eu-digital-green-certificates / dgc-certlogic-android
* ---
* Copyright (C) 2021 T-Systems International GmbH and all other contributors
* ---
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ---license-end
*
* Created by osarapulov on 25.06.21 9:28
*/
class DefaultCountriesRepository(
private val remoteDataSrouce: CountriesRemoteDataSrouce,
private val localDataSource: CountriesLocalDataSource
) : CountriesRepository {

override suspend fun preLoadCountries(countriesUrl: String) {
remoteDataSrouce.getCountries(countriesUrl).apply {
localDataSource.updateCountries(this)
}
}

override fun getCountries(): Flow<List<String>> {
return localDataSource.getCountries()
}
}

This file was deleted.

Loading

0 comments on commit 19cc7cd

Please sign in to comment.