Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed column type of timestamp in LocalChangeEntity #2101

Merged
merged 6 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed compilation issues
  • Loading branch information
aditya-07 committed Jul 28, 2023
commit b28791063a83efcc11a0fcf3e20be297f3300982
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 Google LLC
* Copyright 2022-2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,7 @@ import ca.uhn.fhir.context.FhirVersionEnum
import com.google.android.fhir.LocalChange
import com.google.android.fhir.db.impl.entities.LocalChangeEntity
import com.google.common.truth.Truth.assertThat
import java.time.Instant
import junit.framework.TestCase
import kotlinx.coroutines.runBlocking
import org.hl7.fhir.r4.model.HumanName
Expand Down Expand Up @@ -53,7 +54,8 @@ class LocalChangeUtilsTest : TestCase() {
}
)
}
)
),
timestamp = Instant.now()
)

val localChange = localChangeEntity.toLocalChange()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ class FhirEngineImplTest {
filter(
LOCAL_LAST_UPDATED_PARAM,
{
value = of(DateTimeType(localChangeTimestamp))
value = of(DateTimeType(Date.from(localChangeTimestamp)))
prefix = ParamPrefixEnum.EQUAL
}
)
Expand Down Expand Up @@ -609,14 +609,14 @@ class FhirEngineImplTest {
filter(
LOCAL_LAST_UPDATED_PARAM,
{
value = of(DateTimeType(localChangeTimestampWhenUpdated))
value = of(DateTimeType(Date.from(localChangeTimestampWhenUpdated)))
prefix = ParamPrefixEnum.EQUAL
}
)
}

assertThat(DateTimeType(localChangeTimestampWhenUpdated).value)
.isGreaterThan(DateTimeType(localChangeTimestampWhenCreated).value)
assertThat(DateTimeType(Date.from(localChangeTimestampWhenUpdated)).value)
.isGreaterThan(DateTimeType(Date.from(localChangeTimestampWhenCreated)).value)
assertThat(result).isNotEmpty()
assertThat(result.map { it.logicalId }).containsExactly("patient-id-update").inOrder()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 Google LLC
* Copyright 2022-2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,7 @@ import com.google.android.fhir.sync.UploadResult
import com.google.android.fhir.testing.BundleDataSource
import com.google.common.truth.Truth.assertThat
import java.net.ConnectException
import java.time.Instant
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.runBlocking
import org.hl7.fhir.r4.model.Bundle
Expand Down Expand Up @@ -133,7 +134,8 @@ class BundleUploaderTest {
}
)
}
)
),
timestamp = Instant.now()
)
.toLocalChange()
.apply { LocalChangeToken(listOf(1)) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 Google LLC
* Copyright 2022-2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,7 @@ package com.google.android.fhir.sync.upload
import com.google.android.fhir.LocalChange
import com.google.android.fhir.db.impl.dao.LocalChangeToken
import com.google.common.truth.Truth.assertThat
import java.time.Instant
import org.hl7.fhir.r4.model.ResourceType
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -36,35 +37,40 @@ class LocalChangesPaginatorTest {
"patient-001",
type = LocalChange.Type.INSERT,
payload = "{}",
token = LocalChangeToken(listOf(1L))
token = LocalChangeToken(listOf(1L)),
timestamp = Instant.now()
),
LocalChange(
ResourceType.Patient.name,
"patient-002",
type = LocalChange.Type.INSERT,
payload = "{}",
token = LocalChangeToken(listOf(2L))
token = LocalChangeToken(listOf(2L)),
timestamp = Instant.now()
),
LocalChange(
ResourceType.Patient.name,
"patient-003",
type = LocalChange.Type.INSERT,
payload = "{}",
token = LocalChangeToken(listOf(3L))
token = LocalChangeToken(listOf(3L)),
timestamp = Instant.now()
),
LocalChange(
ResourceType.Patient.name,
"patient-004",
type = LocalChange.Type.INSERT,
payload = "{}",
token = LocalChangeToken(listOf(4L))
token = LocalChangeToken(listOf(4L)),
timestamp = Instant.now()
),
LocalChange(
ResourceType.Patient.name,
"patient-005",
type = LocalChange.Type.INSERT,
payload = "{}",
token = LocalChangeToken(listOf(5L))
token = LocalChangeToken(listOf(5L)),
timestamp = Instant.now()
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.google.android.fhir.db.impl.dao.toLocalChange
import com.google.android.fhir.db.impl.entities.LocalChangeEntity
import com.google.android.fhir.db.impl.entities.LocalChangeEntity.Type
import com.google.common.truth.Truth.assertThat
import java.time.Instant
import kotlinx.coroutines.runBlocking
import org.hl7.fhir.r4.model.Bundle
import org.hl7.fhir.r4.model.HumanName
Expand Down Expand Up @@ -64,7 +65,8 @@ class TransactionBundleGeneratorTest {
}
)
}
)
),
timestamp = Instant.now()
)
.toLocalChange()
.apply { token = LocalChangeToken(listOf(1)) },
Expand Down Expand Up @@ -95,7 +97,8 @@ class TransactionBundleGeneratorTest {
)
}
)
.toString()
.toString(),
timestamp = Instant.now()
)
.toLocalChange()
.apply { LocalChangeToken(listOf(2)) },
Expand All @@ -115,7 +118,8 @@ class TransactionBundleGeneratorTest {
}
)
}
)
),
timestamp = Instant.now()
)
.toLocalChange()
.apply { LocalChangeToken(listOf(3)) }
Expand Down Expand Up @@ -153,7 +157,8 @@ class TransactionBundleGeneratorTest {
}
)
}
)
),
timestamp = Instant.now()
)
.toLocalChange()
.apply { token = LocalChangeToken(listOf(1)) },
Expand Down Expand Up @@ -185,7 +190,8 @@ class TransactionBundleGeneratorTest {
}
)
.toString(),
versionId = "v-p002-01"
versionId = "v-p002-01",
timestamp = Instant.now()
)
.toLocalChange()
.apply { LocalChangeToken(listOf(2)) },
Expand All @@ -206,7 +212,8 @@ class TransactionBundleGeneratorTest {
)
}
),
versionId = "v-p003-01"
versionId = "v-p003-01",
timestamp = Instant.now()
)
.toLocalChange()
.apply { LocalChangeToken(listOf(3)) }
Expand Down Expand Up @@ -240,7 +247,8 @@ class TransactionBundleGeneratorTest {
resourceId = "Patient-002",
type = Type.UPDATE,
payload = "[]",
versionId = "patient-002-version-1"
versionId = "patient-002-version-1",
timestamp = Instant.now()
)
.toLocalChange()
)
Expand All @@ -261,7 +269,8 @@ class TransactionBundleGeneratorTest {
resourceId = "Patient-002",
type = Type.UPDATE,
payload = "[]",
versionId = "patient-002-version-1"
versionId = "patient-002-version-1",
timestamp = Instant.now()
)
.toLocalChange()
)
Expand All @@ -283,7 +292,8 @@ class TransactionBundleGeneratorTest {
resourceId = "Patient-002",
type = Type.UPDATE,
payload = "[]",
versionId = ""
versionId = "",
timestamp = Instant.now()
)
.toLocalChange(),
LocalChangeEntity(
Expand All @@ -292,7 +302,8 @@ class TransactionBundleGeneratorTest {
resourceId = "Patient-003",
type = Type.UPDATE,
payload = "[]",
versionId = null
versionId = null,
timestamp = Instant.now()
)
.toLocalChange()
)
Expand Down
Loading