Skip to content

Commit

Permalink
Updates segmentation tests with valid update time
Browse files Browse the repository at this point in the history
  • Loading branch information
adam1929 authored Oct 11, 2024
1 parent d0b7f3c commit 83ded52
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions sdk/src/test/java/com/exponea/sdk/models/SegmentTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -249,24 +249,27 @@ internal class SegmentTest {

@Test
fun `should compare SegmentsData that are equal by default customerIds and data`() {
assertEquals(getSegmentsData(), getSegmentsData())
val now = System.currentTimeMillis()
assertEquals(getSegmentsData(updateMillis = now), getSegmentsData(updateMillis = now))
}

@Test
fun `should compare SegmentsData that are equal by custom customerIds and default data`() {
val now = System.currentTimeMillis()
val data1 = getSegmentsData(customerIds = hashMapOf(
"cookie" to "cookie1",
"registered" to "registered1"
))
), updateMillis = now)
val data2 = getSegmentsData(customerIds = hashMapOf(
"cookie" to "cookie1",
"registered" to "registered1"
))
), updateMillis = now)
assertEquals(data1, data2)
}

@Test
fun `should compare SegmentsData that are equal by default customerIDs and custom data`() {
val now = System.currentTimeMillis()
val data1 = getSegmentsData(data = getSegmentations(
discovery = arrayListOf(
getSegment(mapOf(
Expand All @@ -275,7 +278,7 @@ internal class SegmentTest {
"segment3" to "true"
))
)
))
), updateMillis = now)
val data2 = getSegmentsData(data = getSegmentations(
discovery = arrayListOf(
getSegment(mapOf(
Expand All @@ -284,12 +287,13 @@ internal class SegmentTest {
"segment3" to "true"
))
)
))
), updateMillis = now)
assertEquals(data1, data2)
}

@Test
fun `should compare SegmentsData that are equal by custom customerIDs and custom data`() {
val now = System.currentTimeMillis()
val data1 = getSegmentsData(
customerIds = hashMapOf(
"cookie" to "cookie1",
Expand All @@ -303,7 +307,8 @@ internal class SegmentTest {
"segment3" to "true"
))
)
)
),
updateMillis = now
)
val data2 = getSegmentsData(
customerIds = hashMapOf(
Expand All @@ -318,26 +323,29 @@ internal class SegmentTest {
"segment3" to "true"
))
)
)
),
updateMillis = now
)
assertEquals(data1, data2)
}

@Test
fun `should compare SegmentsData that are non-equal by custom customerIds and default data`() {
val now = System.currentTimeMillis()
val data1 = getSegmentsData(customerIds = hashMapOf(
"cookie" to "cookie1",
"registered" to "registered1"
))
), updateMillis = now)
val data2 = getSegmentsData(customerIds = hashMapOf(
"cookie" to "cookie2",
"registered" to "registered2"
))
), updateMillis = now)
assertNotEquals(data1, data2)
}

@Test
fun `should compare SegmentsData that are non-equal by default customerIDs and custom data`() {
val now = System.currentTimeMillis()
val data1 = getSegmentsData(data = getSegmentations(
discovery = arrayListOf(
getSegment(mapOf(
Expand All @@ -346,7 +354,7 @@ internal class SegmentTest {
"segment3" to "true"
))
)
))
), updateMillis = now)
val data2 = getSegmentsData(data = getSegmentations(
discovery = arrayListOf(
getSegment(mapOf(
Expand All @@ -355,12 +363,13 @@ internal class SegmentTest {
"segment3" to "false"
))
)
))
), updateMillis = now)
assertNotEquals(data1, data2)
}

@Test
fun `should compare SegmentsData that are non-equal by custom customerIDs and custom data`() {
val now = System.currentTimeMillis()
val data1 = getSegmentsData(
customerIds = hashMapOf(
"cookie" to "cookie1",
Expand All @@ -374,7 +383,8 @@ internal class SegmentTest {
"segment3" to "true"
))
)
)
),
updateMillis = now
)
val data2 = getSegmentsData(
customerIds = hashMapOf(
Expand All @@ -389,7 +399,8 @@ internal class SegmentTest {
"segment3" to "false"
))
)
)
),
updateMillis = now
)
assertNotEquals(data1, data2)
}
Expand Down

0 comments on commit 83ded52

Please sign in to comment.