Skip to content
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class PinpointAnalyticsInstrumentationTest {

// Act: Record the event
Amplify.Analytics.recordEvent(event)
Sleep.milliseconds(RECORD_INSERTION_TIMEOUT)
Sleep.milliseconds(DEFAULT_TIMEOUT)
Amplify.Analytics.flushEvents()
val hubEvents = hubAccumulator.await(10, TimeUnit.SECONDS)
val submittedEvents = combineAndFilterEvents(hubEvents)
Expand Down Expand Up @@ -118,15 +118,15 @@ class PinpointAnalyticsInstrumentationTest {
.addProperty("DemoDoubleProperty2", 2.0)
.build()
Amplify.Analytics.recordEvent(event1)
Sleep.milliseconds(RECORD_INSERTION_TIMEOUT)
Sleep.milliseconds(DEFAULT_TIMEOUT)
val eventName2 = "Amplify-event" + UUID.randomUUID().toString()
val event2 = AnalyticsEvent.builder()
.name(eventName2)
.addProperty("DemoProperty1", "DemoValue1")
.addProperty("DemoProperty2", 2.0)
.build()
Amplify.Analytics.recordEvent(event2)
Sleep.milliseconds(RECORD_INSERTION_TIMEOUT)
Sleep.milliseconds(DEFAULT_TIMEOUT)
Amplify.Analytics.flushEvents()
val hubEvents = analyticsHubEventAccumulator.await(10, TimeUnit.SECONDS)
val hubEvent = analyticsHubEventAccumulator.awaitFirst()
Expand Down Expand Up @@ -189,9 +189,9 @@ class PinpointAnalyticsInstrumentationTest {

// Act: Record two events: the one created above and another just with a key
Amplify.Analytics.recordEvent(event)
Sleep.milliseconds(RECORD_INSERTION_TIMEOUT)
Sleep.milliseconds(DEFAULT_TIMEOUT)
Amplify.Analytics.recordEvent("amplify-test-event")
Sleep.milliseconds(RECORD_INSERTION_TIMEOUT)
Sleep.milliseconds(DEFAULT_TIMEOUT)
Amplify.Analytics.flushEvents()
val hubEvents = analyticsHubEventAccumulator.await(10, TimeUnit.SECONDS)
val submittedEvents = combineAndFilterEvents(hubEvents)
Expand Down Expand Up @@ -226,10 +226,10 @@ class PinpointAnalyticsInstrumentationTest {

// Act: Record an event, unregister the global property, and record another event
Amplify.Analytics.recordEvent("amplify-test-event-with-property")
Sleep.milliseconds(RECORD_INSERTION_TIMEOUT)
Sleep.milliseconds(DEFAULT_TIMEOUT)
Amplify.Analytics.unregisterGlobalProperties("GlobalProperty")
Amplify.Analytics.recordEvent("amplify-test-event-without-property")
Sleep.milliseconds(RECORD_INSERTION_TIMEOUT)
Sleep.milliseconds(DEFAULT_TIMEOUT)
Amplify.Analytics.flushEvents()
val hubEvents = analyticsHubEventAccumulator.await(10, TimeUnit.SECONDS)
val submittedEvents = combineAndFilterEvents(hubEvents)
Expand Down Expand Up @@ -282,9 +282,16 @@ class PinpointAnalyticsInstrumentationTest {
.customProperties(properties)
.userAttributes(userAttributes)
.build()
Amplify.Analytics.identifyUser(UUID.randomUUID().toString(), pinpointUserProfile)
val uuid = UUID.randomUUID().toString()
Amplify.Analytics.identifyUser(uuid, pinpointUserProfile)
Sleep.milliseconds(PINPOINT_ROUNDTRIP_TIMEOUT)
val endpointResponse = fetchEndpointResponse()
var endpointResponse = fetchEndpointResponse()
var retry_count = 0
while (retry_count < MAX_RETRIES && endpointResponse.attributes.isNullOrEmpty()) {
Sleep.milliseconds(DEFAULT_TIMEOUT)
endpointResponse = fetchEndpointResponse()
retry_count++
}
assertCommonEndpointResponseProperties(endpointResponse)
Assert.assertEquals(
"User attribute value",
Expand All @@ -310,7 +317,7 @@ class PinpointAnalyticsInstrumentationTest {
}

private fun assertCommonEndpointResponseProperties(endpointResponse: EndpointResponse) {
Log.i("DEBUG", endpointResponse.toString())
Log.d("PinpointAnalyticsInstrumentationTest", endpointResponse.toString())
val attributes = endpointResponse.attributes!!
Assert.assertEquals("[email protected]", attributes["email"]!![0])
Assert.assertEquals("test-user", attributes["name"]!![0])
Expand Down Expand Up @@ -369,7 +376,8 @@ class PinpointAnalyticsInstrumentationTest {
private const val CONFIGURATION_NAME = "amplifyconfiguration"
private const val COGNITO_CONFIGURATION_TIMEOUT = 10 * 1000L
private const val PINPOINT_ROUNDTRIP_TIMEOUT = 10 * 1000L
private const val RECORD_INSERTION_TIMEOUT = 5 * 1000L
private const val DEFAULT_TIMEOUT = 5 * 1000L
private const val MAX_RETRIES = 10
private const val UNIQUE_ID_KEY = "UniqueId"
private const val PREFERENCES_AND_FILE_MANAGER_SUFFIX = "515d6767-01b7-49e5-8273-c8d11b0f331d"
private lateinit var synchronousAuth: SynchronousAuth
Expand Down