Skip to content

Commit

Permalink
fix: lint issues and one test case
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdebs committed Sep 18, 2023
1 parent 5012775 commit 0b2b1ee
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 91 deletions.
8 changes: 3 additions & 5 deletions gsonrudderadapter/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"dependsOn": [
{
"projects":[
"rudderjsonadapter",
"models"
],
"rudderjsonadapter"],
"target":"build"
}
],
Expand All @@ -34,7 +32,7 @@
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"baseBranch": "master",
"baseBranch": "master-v2",
"preset": "conventional",
"tagPrefix": "${projectName}@"
}
Expand All @@ -48,7 +46,7 @@
"github": {
"executor": "@jscutlery/semver:github",
"options": {
"tag": "gsonrudderadapter@0.1.0",
"tag": "gsonrudderadapter@1.0.0",
"notesFile": "./gsonrudderadapter/CHANGELOG_LATEST.md"
}
},
Expand Down
7 changes: 3 additions & 4 deletions jacksonrudderadapter/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"dependsOn": [
{
"projects":[
"rudderjsonadapter",
"models"
"rudderjsonadapter"
],
"target":"build"
}
Expand All @@ -34,7 +33,7 @@
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"baseBranch": "master",
"baseBranch": "master-v2",
"preset": "conventional",
"tagPrefix": "${projectName}@"
}
Expand All @@ -48,7 +47,7 @@
"github": {
"executor": "@jscutlery/semver:github",
"options": {
"tag": "jacksonrudderadapter@0.1.0",
"tag": "jacksonrudderadapter@1.0.0",
"notesFile": "./jacksonrudderadapter/CHANGELOG_LATEST.md"
}
},
Expand Down
21 changes: 10 additions & 11 deletions moshirudderadapter/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
"projectType": "library",
"sourceRoot": "./moshirudderadapter/src",
"targets": {
"dependsOn": [
{
"projects":[
"rudderjsonadapter",
"models"
],
"target":"build"
}
],
"build": {
"dependsOn": [
{
"projects":[
"rudderjsonadapter"
],
"target":"build"
}
],
"executor": "@jnxplus/nx-gradle:build",
"outputs": ["./moshirudderadapter/build"]
},
Expand All @@ -32,7 +31,7 @@
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"baseBranch": "master",
"baseBranch": "master-v2",
"preset": "conventional",
"tagPrefix": "${projectName}@"
}
Expand All @@ -46,7 +45,7 @@
"github": {
"executor": "@jscutlery/semver:github",
"options": {
"tag": "moshirudderadapter@0.1.0",
"tag": "moshirudderadapter@1.0.0",
"notesFile": "./moshirudderadapter/CHANGELOG_LATEST.md"
}
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"test": "nx affected --base=origin/master-v2 --target='test' --parallel=1 --exclude=app,core,android --skipCommitTypes=docs,ci,chore",
"release": "nx affected --base=origin/master-v2 --target=version --parallel=1 --exclude=app,core,android --skipCommitTypes=docs,ci,chore && npm run sync-version-gradle",
"release:github": "nx affected --target=github --parallel=1 --exclude=app,core,android --skipCommitTypes=docs,ci,chore",
"release:sonatype": "nx affected --target=release-sonatype --parallel=1 --exclude=app,core,android",
"release-snapshot:sonatype": "nx affected --target=snapshot-release --parallel=4 --exclude=app,core,android"
"release:sonatype": "nx affected --base=origin/master-v2 --target=release-sonatype --parallel=1 --exclude=app,core,android",
"release-snapshot:sonatype": "nx affected --base=origin/master-v2 --target=snapshot-release --parallel=1 --exclude=app,core,android"
},
"private": true,
"devDependencies": {
Expand Down
12 changes: 0 additions & 12 deletions repository/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,13 @@ dependencies {

testImplementation deps.androidXTestExtJunitKtx
testImplementation deps.androidXTestRules
// implementation 'androidx.appcompat:appcompat:1.3.1'
// implementation 'com.google.android.material:material:1.4.0'
// implementation(project(":rudderjsonadapter"))

testImplementation deps.junit
// testImplementation(project(':moshirudderadapter'))
// testImplementation(project(':gsonrudderadapter'))
// testImplementation(project(':jacksonrudderadapter'))
// testImplementation deps.moshi.kotlin
// testImplementation deps.moshi.core
// testImplementation deps.gson
// testImplementation deps.jackson
testImplementation deps.androidXTest
testImplementation deps.hamcrest
testImplementation deps.mockito
testImplementation deps.awaitility
testImplementation deps.robolectric
// androidTestImplementation deps.androidXTestExtJunitKtx
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
apply from: rootProject.file('gradle/artifacts-aar.gradle')
apply from: rootProject.file('gradle/mvn-publish.gradle')
Expand Down
4 changes: 2 additions & 2 deletions repository/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"baseBranch": "master",
"baseBranch": "master-v2",
"preset": "conventional",
"tagPrefix": "${projectName}@"
}
Expand All @@ -39,7 +39,7 @@
"github": {
"executor": "@jscutlery/semver:github",
"options": {
"tag": "repository@0.1.0",
"tag": "repository@1.0.0",
"notesFile": "./repository/CHANGELOG_LATEST.md"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.annotation.Config
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicBoolean

Expand All @@ -40,13 +38,16 @@ import java.util.concurrent.atomic.AtomicBoolean
@Config(sdk = [29])
class RudderDatabaseTest {
// private lateinit var
// private val delayedExecutor = Executors.newSingleThreadExecutor()
@Before
fun initialize() {
// RudderDatabase.init(
// ApplicationProvider.getApplicationContext(),
//// RuntimeEnvironment.application,
// "testDb", TestEntityFactory, executorService = TestExecutor()
// )
RudderDatabase.init(
ApplicationProvider.getApplicationContext(),
"testDb",
TestEntityFactory,
false,
executorService = TestExecutor()
)

}

Expand All @@ -56,19 +57,18 @@ class RudderDatabaseTest {
}

@Test
fun `test race condition in dao list initialisation`(){
val delayedExecutor = Executors.newSingleThreadExecutor()
RudderDatabase.init(
ApplicationProvider.getApplicationContext(), "testDb", TestEntityFactory,false,
executorService = delayedExecutor)
fun `test race condition in dao list initialisation`() {

val sampleDao = RudderDatabase.createNewDao(SampleEntity::class.java, TestExecutor())
val sampleAutoGenDao = RudderDatabase.createNewDao(SampleAutoGenEntity::class.java,
TestExecutor())
val sampleAutoGenDao = RudderDatabase.createNewDao(
SampleAutoGenEntity::class.java, TestExecutor()
)
val sampleDaoCheck = RudderDatabase.getDao(SampleEntity::class.java)
MatcherAssert.assertThat(sampleDao, Matchers.equalTo(sampleDaoCheck))
MatcherAssert.assertThat(sampleAutoGenDao, Matchers.equalTo(sampleAutoGenDao))
Thread.sleep(5000)
}

@Test
fun multipleDaoCallsToReturnSameDaoObject() {
val sampleDaoCheck = RudderDatabase.getDao(SampleEntity::class.java)
Expand Down Expand Up @@ -98,8 +98,7 @@ class RudderDatabaseTest {

MatcherAssert.assertThat(
savedData, allOf(
Matchers.iterableWithSize(2),
contains(*sampleEntitiesToSave.toTypedArray())
Matchers.iterableWithSize(2), contains(*sampleEntitiesToSave.toTypedArray())
)
)

Expand Down Expand Up @@ -128,8 +127,7 @@ class RudderDatabaseTest {
getAll() {
assertThat(
it, allOf(
Matchers.iterableWithSize(2),
contains(*sampleEntitiesToSave.toTypedArray())
Matchers.iterableWithSize(2), contains(*sampleEntitiesToSave.toTypedArray())
)
)
isGetComplete.set(true)
Expand Down Expand Up @@ -161,8 +159,7 @@ class RudderDatabaseTest {
val items = getAllSync()
assertThat(
items, allOf(
iterableWithSize(1),
contains(sampleEntitiesToSave[2])
iterableWithSize(1), contains(sampleEntitiesToSave[2])
)
)
isCompleted.set(true)
Expand All @@ -171,12 +168,11 @@ class RudderDatabaseTest {
Awaitility.await().atMost(5, TimeUnit.SECONDS).untilTrue(isCompleted)

}

@Test
fun testAutoGenEntities() {
val entitiesToSave = listOf(
SampleAutoGenEntity("abc"),
SampleAutoGenEntity("fgh"),
SampleAutoGenEntity("def")
SampleAutoGenEntity("abc"), SampleAutoGenEntity("fgh"), SampleAutoGenEntity("def")
)
val sampleDao = RudderDatabase.getDao(SampleAutoGenEntity::class.java)
//save data
Expand All @@ -196,8 +192,7 @@ class RudderDatabaseTest {
val items = getAllSync()
assertThat(
items, allOf(
iterableWithSize(1),
contains(savedEntities[2])
iterableWithSize(1), contains(savedEntities[2])
)
)
isCompleted.set(true)
Expand Down
4 changes: 2 additions & 2 deletions rudderjsonadapter/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"baseBranch": "master",
"baseBranch": "master-v2",
"preset": "conventional",
"tagPrefix": "${projectName}@"
}
Expand All @@ -39,7 +39,7 @@
"github": {
"executor": "@jscutlery/semver:github",
"options": {
"tag": "rudderjsonadapter@0.1.0",
"tag": "rudderjsonadapter@1.0.0",
"notesFile": "./rudderjsonadapter/CHANGELOG_LATEST.md"
}
},
Expand Down
34 changes: 28 additions & 6 deletions rudderreporter/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,36 @@
"sourceRoot": "./rudderreporter/src",
"targets": {
"build": {
"dependsOn": [
{
"projects": [
"gsonrudderadapter",
"jacksonrudderadapter",
"moshirudderadapter",
"repository",
"web"
],
"target": "build"
}
],
"executor": "@jnxplus/nx-gradle:build",
"outputs": ["./rudderreporter/build"]
"outputs": [
"./rudderreporter/build"
]
},
"lint": {
"dependsOn": ["build"],
"dependsOn": [
"build"
],
"executor": "@jnxplus/nx-gradle:lint",
"options": {
"linter": "ktlint"
}
},
"test": {
"dependsOn": ["build"],
"dependsOn": [
"build"
],
"executor": "@jnxplus/nx-gradle:test"
},
"ktformat": {
Expand All @@ -25,7 +43,7 @@
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"baseBranch": "master",
"baseBranch": "master-v2",
"preset": "conventional",
"tagPrefix": "${projectName}@"
}
Expand All @@ -44,14 +62,18 @@
}
},
"release-sonatype": {
"dependsOn": ["build"],
"dependsOn": [
"build"
],
"executor": "nx:run-commands",
"options": {
"command": "echo 'rudderreporter-release' && ./gradlew publishToSonatype -p rudderreporter -Prelease && ./gradlew closeAndReleaseSonatypeStagingRepository"
}
},
"snapshot-release": {
"dependsOn": ["build"],
"dependsOn": [
"build"
],
"executor": "nx:run-commands",
"options": {
"command": "echo 'rudder-reporter-snapshot' && sh ./gradlew generatePomFileForReleasePublication -p rudderreporter && ./gradlew publishToSonatype -p rudderreporter"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import com.rudderstack.android.ruddermetricsreporterandroid.internal.di.ContextM
import com.rudderstack.android.ruddermetricsreporterandroid.internal.di.SystemServiceModule
import com.rudderstack.android.ruddermetricsreporterandroid.internal.error.MemoryTrimState
import com.rudderstack.android.ruddermetricsreporterandroid.internal.metrics.DefaultAggregatorHandler
import com.rudderstack.moshirudderadapter.MoshiAdapter
import com.rudderstack.rudderjsonadapter.JsonAdapter
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
Expand Down Expand Up @@ -171,7 +170,7 @@ class DefaultRudderReporter(
isMetricsEnabled: Boolean = true,
isErrorEnabled: Boolean = true,
backgroundTaskService: BackgroundTaskService? = null
):this(contextModule, reservoir, configuration, configModule, syncer, jsonAdapter.manipulate(),
):this(contextModule, reservoir, configuration, configModule, syncer, jsonAdapter,
memoryTrimState,
ConnectivityCompat(contextModule.ctx, RudderReporterNetworkChangeCallback(syncer)),
isMetricsEnabled, isErrorEnabled, backgroundTaskService)
Expand Down Expand Up @@ -238,14 +237,14 @@ class DefaultRudderReporter(
}
}

companion object{
internal fun JsonAdapter.manipulate(): JsonAdapter {
if(this is MoshiAdapter){
add(CustomDateAdapterMoshi())
}
return this
}
}
// companion object{
// internal fun JsonAdapter.manipulate(): JsonAdapter {
// if(this is MoshiAdapter){
// add(CustomDateAdapterMoshi())
// }
// return this
// }
// }
}


Loading

0 comments on commit 0b2b1ee

Please sign in to comment.