-
Notifications
You must be signed in to change notification settings - Fork 9
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
Unit tests for Audience and AudienceExtension classes #12
Conversation
@@ -863,8 +875,8 @@ private String getDataProviderUrlVariables(final Event event) { | |||
} | |||
|
|||
// append customer Ids | |||
List<VisitorID> customerIds = DataReader.optTypedList( | |||
VisitorID.class, | |||
List<Map<String, Object>> customerIds = DataReader.optTypedListOfMap( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identity now shares custom visitors as Map, and I removed the usages of VisitorID class. ref https://github.com/adobe/aepsdk-core-android/blob/staging/code/identity/src/main/java/com/adobe/marketing/mobile/identity/IdentityExtension.java#L1389
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class AudiencePublicAPITests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class preserves some of the original tests from AudienceCoreTests
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class AudienceExtensionTests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class preserves most of the original tests from AudienceTests
code/audience/src/test/java/com/adobe/marketing/mobile/audience/AudienceExtensionTests.java
Outdated
Show resolved
Hide resolved
verify(mockState, never()).setVisitorProfile(any()); | ||
verifyNoInteractions(mockNetworkService); | ||
verify(mockExtensionApi, never()).createSharedState(any(), any(Event.class)); | ||
// todo: shared state still gets updated for null responses? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is same as 1.x, but should the shared state be updated on null/empty server responses or can we update the implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update: will not share a new shared state when empty/null responses are received. existing shared state set on boot or by other events will contain the known info
code/audience/src/main/java/com/adobe/marketing/mobile/audience/AudienceExtension.java
Outdated
Show resolved
Hide resolved
code/audience/src/main/java/com/adobe/marketing/mobile/audience/AudienceExtension.java
Show resolved
Hide resolved
code/audience/src/main/java/com/adobe/marketing/mobile/audience/AudienceExtension.java
Show resolved
Hide resolved
code/audience/src/test/java/com/adobe/marketing/mobile/audience/AudiencePublicAPITests.java
Show resolved
Hide resolved
code/audience/src/test/java/com/adobe/marketing/mobile/audience/AudiencePublicAPITests.java
Show resolved
Hide resolved
} | ||
|
||
@Test | ||
public void testReadyForEvent_whenAnyOtherEvent_whenConfigSet_returnsTrue() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add a test for CONFIGURATION/ResponseContent
here too for completion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or can we not block on config shared state for config response content events since the needed data is self-contained?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update: kept this inline with the swift implementation and updated the asserts as you suggested
Description
Fixes and reenables all the unit tests related to Audience and AudienceExtension.
Adds new tests for the new Extension APIs, such as readyForEvent, onRegistered etc
Fixes few code bugs discovered with unit tests
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: