Skip to content

Commit

Permalink
test(SDK-4183): adds test to check normalisation in non charged events
Browse files Browse the repository at this point in the history
  • Loading branch information
CTLalit committed Nov 25, 2024
1 parent 30cf30c commit 3ec5ff2
Showing 1 changed file with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.clevertap.android.sdk.inapp.evaluation
import com.clevertap.android.sdk.Constants
import com.clevertap.android.shared.test.BaseTestCase
import org.junit.*
import org.junit.Assert.assertNotEquals
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertNotNull
Expand All @@ -28,6 +29,69 @@ class EventAdapterTest : BaseTestCase() {
assertFalse { expected.isList() }
}

@Test
fun testGetPropertyPresentNormalisations() {
// Arrange
val eventProperties = mapOf(" name " to "John", "a ge " to 30)
val eventAdapter = EventAdapter("eventName", eventProperties)

// Act
val result = eventAdapter.getPropertyValue("name")
val expected = TriggerValue("John")

// Assert
assertNotNull(result)
assertEquals(expected.stringValue(), result.stringValue())
assertNull(result.numberValue())
assertNull(result.listValue())
assertFalse { expected.isList() }

// Act
val result1 = eventAdapter.getPropertyValue("age")
val expected1 = TriggerValue(30)

// Assert
assertNotNull(result1)
assertEquals(expected1.numberValue(), result1.numberValue())
assertNull(result1.stringValue())
assertNull(result1.listValue())
assertFalse { expected1.isList() }
}

@Test
fun testGetPropertyPresentNormalisations2() {
// Arrange
val eventProperties = mapOf(" name " to "John Doe", "Lucky Numbers" to listOf(1, 2))
val eventAdapter = EventAdapter("eventName", eventProperties)

// Act
val result = eventAdapter.getPropertyValue("name")
val expected = TriggerValue("John Doe")
val notExpected = TriggerValue("JohnDoe")

// Assert
assertNotNull(result)
assertEquals(expected.stringValue(), result.stringValue())
assertNotEquals(notExpected.stringValue(), result.stringValue())
assertNull(result.numberValue())
assertNull(result.listValue())
assertFalse { expected.isList() }

// Act
val result1 = eventAdapter.getPropertyValue("luckynumbers")
val expected1 = TriggerValue(
value = null,
listValue = listOf(1, 2)
)

// Assert
assertNotNull(result1)
assertEquals(expected1.listValue(), result1.listValue())
assertNull(result1.stringValue())
assertNull(result1.numberValue())
assertTrue { expected1.isList() }
}

@Test
fun testGetPropertyMissing() {
// Arrange
Expand Down

0 comments on commit 3ec5ff2

Please sign in to comment.