Skip to content

[MOB-17093] Part 2 - Unit tests with mockito and core 2.x#10

Merged
emdobrin merged 16 commits intoadobe:dev-v2.0.0from
emdobrin:MOB-17093-part2
Dec 16, 2022
Merged

[MOB-17093] Part 2 - Unit tests with mockito and core 2.x#10
emdobrin merged 16 commits intoadobe:dev-v2.0.0from
emdobrin:MOB-17093-part2

Conversation

@emdobrin
Copy link
Copy Markdown
Contributor

Description

  • Fixes unit tests in EdgeExtensionTests
  • Found and fixed few small bugs with reading event data with the tests, updates are reflected in this PR.
  • Removes MockHitQueue, using Mockito instead
  • Removed listeners tests class, and the majority of the test cases are covered as part of the other test classes now

Related Issue

Changes are based on #9 which would need to be merged first.

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Copy Markdown

@prudrabhat prudrabhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar suggestion as https://github.com/adobe/aepsdk-edge-android/pull/9/files#r1048941752 which will be addressed later. Looks good to me otherwise.

}

private void mockHubSharedState(final Map<String, Object> hub) {
private void verifyGetSharedStateCalls(final int configTimes, final int identityTimes, final int consentTimes) {
Copy link
Copy Markdown

@prudrabhat prudrabhat Dec 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may be better if these verify calls are invoked individually inline within the unit test because the utility method masks whether a normal shared state or xdm shared state is verified, the exact event and the resolution being queried for.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would defer this in order to keep the test body concise and easy to read, but I can document the utility API if that helps

* @param event an event containing {@link ExperienceEvent} data for processing; the event data should not be null/empty
*/
void handleExperienceEventRequest(@NonNull final Event event) {
if (Utils.isNullOrEmpty(event.getEventData())) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These checks were moved from listeners to handlers, I compared them with the iOS implementation also and they now match that. The only handler that does not check for event data payload is getLocationHint, seems like we don't do that check in iOS.


//verify
assertEquals(1, edgeExtension.getCachedEvents().size());
verifyEventQueued(event1);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the queued events are now verified with a mocked hit queue

}

@Test
public void testBootupIfNeeded_whenConsentNotRegistered_updatesConsentYes() {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved from EdgeExtensionTests

}

@Test
public void testHandleExperienceEventRequest_whenEmptyEventData_ignoresEvent() {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved from the ListenerTests class

@emdobrin emdobrin merged commit 9cbad04 into adobe:dev-v2.0.0 Dec 16, 2022
@emdobrin emdobrin deleted the MOB-17093-part2 branch October 14, 2023 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants