Skip to content

Commit

Permalink
Fix contentId on Action messages. (#55)
Browse files Browse the repository at this point in the history
* Fix contentId on Action messages.

* Add test
  • Loading branch information
Y Wang committed Oct 15, 2021
1 parent 76f720a commit 61ef4a3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/build.gradle
Expand Up @@ -8,7 +8,7 @@ plugins {
}

ext {
version = "0.7.2"
version = "0.7.3"
PUBLISH_GROUP_ID = 'ai.promoted'
PUBLISH_VERSION = version
PUBLISH_ARTIFACT_ID = 'android-metrics-sdk'
Expand Down
Expand Up @@ -138,6 +138,7 @@ internal fun createActionMessage(
actionData.impressionId?.let { setImpressionId(it) }
actionData.insertionId?.let { setInsertionId(it) }
actionData.requestId?.let { setRequestId(it) }
actionData.contentId?.let { setContentId(it) }
elementId = actionData.elementId ?: name
if (internalActionData.type == ActionType.NAVIGATE) {
navigateAction = createNavigationMessage(actionData.targetUrl)
Expand Down
Expand Up @@ -36,6 +36,8 @@ class MessageCreationTests {
hasSuperimposedViews = false
),
actionData = ActionData.Builder(
contentId = "foobar",
insertionId = "batman",
targetUrl = "http://google.com"
).build(null)
)
Expand Down Expand Up @@ -64,4 +66,29 @@ class MessageCreationTests {
// Then
assertThat(message.elementId, equalTo("TestNav"))
}

@Test
fun `Should set contentId and insertionId`() {
// When
val message = createActionMessage(
clock = clock,
internalActionData = InternalActionData(
name = "TestNav",
type = ActionType.NAVIGATE,
actionId = "test",
sessionId = "test",
autoViewId = "test",
hasSuperimposedViews = false
),
actionData = ActionData.Builder(
contentId = "foobar",
insertionId = "batman",
targetUrl = "http://google.com"
).build(null)
)

// Then
assertThat(message.contentId, equalTo("foobar"))
assertThat(message.insertionId, equalTo("batman"))
}
}

0 comments on commit 61ef4a3

Please sign in to comment.