Skip to content
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

Merged
merged 17 commits into from
Jan 26, 2023

Conversation

emdobrin
Copy link
Contributor

@emdobrin emdobrin commented Jan 26, 2023

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

  • 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.

@emdobrin emdobrin requested a review from sbenedicadb January 26, 2023 03:12
@@ -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(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

import org.mockito.junit.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class AudiencePublicAPITests {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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

verify(mockState, never()).setVisitorProfile(any());
verifyNoInteractions(mockNetworkService);
verify(mockExtensionApi, never()).createSharedState(any(), any(Event.class));
// todo: shared state still gets updated for null responses?
Copy link
Contributor Author

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?

Copy link
Contributor Author

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

}

@Test
public void testReadyForEvent_whenAnyOtherEvent_whenConfigSet_returnsTrue() {
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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

@emdobrin emdobrin merged commit 40db849 into adobe:dev-v2.0.0 Jan 26, 2023
@emdobrin emdobrin deleted the unit-tests-part3-br branch January 26, 2023 23:26
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