-
Notifications
You must be signed in to change notification settings - Fork 7
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
Functional test AEPTestUtils update (part 3) #157
Functional test AEPTestUtils update (part 3) #157
Conversation
…e local getJsonPayload method
…uration state is pending and not because the identity state is not set
* Update EdgeFunctionalTests.java to use AEPTestUtils * Apply lint formatting to EdgeFunctionalTests.java * Update EdgePathOverwriteTests.java to use JSON comparison APIs * Apply lint formatting for EdgePathOverwriteTests.java * Update EdgeFunctionalTests.java to use TestableNetworkRequest Replace local getPayloadJson method and usages * Update EdgePathOverwriteTests.java to use TestableNetworkRequest Replace usage of local getPayloadJson * Update testSendEvent_withXDMDataAndNullData_sendsCorrectRequestEvent to update testValue for clarity * Apply lint formatting for EdgeFunctionalTests.java and EdgePathOverwriteTests.java * Update to use stringValue for test case strings in event payloads * Update EdgeFunctionalTests and TestXDMSchema to use "test" prefixed property names Add code comments for ElementCount cases to make assertion logic clearer * Remove test case comments for JSON assertions with actual expected payloads
…ngConfigurationState_expectEventsQueueIsBlocked to set an identity state beforehand
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feature/functional-test-aeptestutils #157 +/- ##
=======================================================================
Coverage ? 84.69%
Complexity ? 407
=======================================================================
Files ? 30
Lines ? 1639
Branches ? 237
=======================================================================
Hits ? 1388
Misses ? 160
Partials ? 91
Flags with carried forward coverage won't be shown. Click here to find out more. |
networkRequest.getBodyJson(), | ||
new CollectionEqualCount(Subtree, "meta.state.entries"), | ||
new AnyOrderMatch("meta.state.entries"), | ||
new ElementCount(18, Subtree) |
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.
Do we need // Asserting body has 18 total key value elements here?
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.
Added code comment!
networkRequest.getBodyJson(), | ||
new CollectionEqualCount(Subtree, "meta.state.entries"), | ||
new AnyOrderMatch("meta.state.entries"), | ||
new ElementCount(18, Subtree) |
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.
Do we need // Asserting body has 18 total key value elements here?
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.
Added code comment!
" \"title\": \"Failed to process personalization event\"," + | ||
" \"type\": \"personalization\"" + | ||
"}"; | ||
JSONAsserts.assertEquals(expectedEventData2, dispatchEvents.get(1).getEventData()); |
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.
assertEquals also compares agains the expected right? Does it atleast compare the size (no of keys) for both expected vs actual Also we could take scope into account?
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.
I believe assertEquals should have 2 way equality by default and one simple addition would be to by default compare sizes to start with if we are not doing it currently.
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.
Yes the logic for assertEquals
requires exact equality between expected
and actual
:
- keys/array values present must be equal (collection size equal)
- values must be exactly equal (type + literal value)
So in this test case, the actual must be exactly equal to the expectation
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.
" \"title\": \"Failed to process personalization event\"," + | ||
" \"type\": \"personalization\"" + | ||
"}"; | ||
JSONAsserts.assertEquals(expectedEventData2, dispatchEvents.get(1).getEventData()); |
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.
Yes the logic for assertEquals
requires exact equality between expected
and actual
:
- keys/array values present must be equal (collection size equal)
- values must be exactly equal (type + literal value)
So in this test case, the actual must be exactly equal to the expectation
networkRequest.getBodyJson(), | ||
new CollectionEqualCount(Subtree, "meta.state.entries"), | ||
new AnyOrderMatch("meta.state.entries"), | ||
new ElementCount(18, Subtree) |
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.
Added code comment!
networkRequest.getBodyJson(), | ||
new CollectionEqualCount(Subtree, "meta.state.entries"), | ||
new AnyOrderMatch("meta.state.entries"), | ||
new ElementCount(18, Subtree) |
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.
Added code comment!
@@ -56,6 +57,11 @@ public void setup() throws Exception { | |||
resetTestExpectations(); | |||
} | |||
|
|||
@After | |||
public void tearDown() { | |||
mockNetworkService.reset(); |
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.
do we need to update this to resetTestExpectation?
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.
Thank you! Updated
733df31
into
adobe:feature/functional-test-aeptestutils
* Functional test AEPTestUtils update (part 1) (#155) * Replace local test utils with AEPTestUtils * Update ConfigOverridesFunctionalTests.kt to use AEPTestUtils * Remove local test-utils files * Update CompletionHandlerFunctionalTests.java to use AEPTestUtils * Update ConsentStatusChangeFunctionalTests.java to use AEPTestUtils Apply lint formatting * Update ConfigOverridesFunctionalTests.kt to use static assertExactMatch * Update AEPTestUtils to the latest version * Remove unconverted functional tests * Revert "Remove unconverted functional tests" This reverts commit 2d0013a. * Update AEPTestUtils to latest version * Update CompletionHandlerFunctionalTests.java to use TestableNetworkRequest * Update ConsentStatusChangeFunctionalTests.java to use TestableNetworkRequest type Update list get operations to safe versions * Update ConsentStatusChangeFunctionalTests.java to use TestableNetworkRequest * ConsentStatusChangeFunctionalTests.java add collection size check before access * Remove Long conversion for result list size check in ConfigOverridesFunctionalTests.kt * Functional test AEPTestUtils update (part 2) (#156) * Update EdgeFunctionalTests.java to use AEPTestUtils * Apply lint formatting to EdgeFunctionalTests.java * Update EdgePathOverwriteTests.java to use JSON comparison APIs * Apply lint formatting for EdgePathOverwriteTests.java * Update EdgeFunctionalTests.java to use TestableNetworkRequest Replace local getPayloadJson method and usages * Update EdgePathOverwriteTests.java to use TestableNetworkRequest Replace usage of local getPayloadJson * Update testSendEvent_withXDMDataAndNullData_sendsCorrectRequestEvent to update testValue for clarity * Apply lint formatting for EdgeFunctionalTests.java and EdgePathOverwriteTests.java * Update to use stringValue for test case strings in event payloads * Update EdgeFunctionalTests and TestXDMSchema to use "test" prefixed property names Add code comments for ElementCount cases to make assertion logic clearer * Remove test case comments for JSON assertions with actual expected payloads * Functional test AEPTestUtils update (part 3) (#157) * Update IdentityStateFunctionalTests.java to use JSON comparison APIs * Apply lint formatting to IdentityStateFunctionalTests.java * Update NetworkResponseHandlerFunctionalTests.java to use JSON comparison APIs * Apply lint formatting for NetworkResponseHandlerFunctionalTests.java * Update NoConfigFunctionalTests.java to use JSON comparison APIs * Apply lint formatting for NoConfigFunctionalTests.java * Update RestartFunctionalTests.java to use AEPTestUtils * Apply lint formatting to RestartFunctionalTests.java * Update SampleFunctionalTests.java to use JSON comparison APIs * Apply lint formatting for SampleFunctionalTests.java * Update converted test classes to use TestableNetworkRequest and remove local getJsonPayload method * Add missing step to verify the request is not sent because the configuration state is pending and not because the identity state is not set * Functional test AEPTestUtils update (part 2) (#156) * Update EdgeFunctionalTests.java to use AEPTestUtils * Apply lint formatting to EdgeFunctionalTests.java * Update EdgePathOverwriteTests.java to use JSON comparison APIs * Apply lint formatting for EdgePathOverwriteTests.java * Update EdgeFunctionalTests.java to use TestableNetworkRequest Replace local getPayloadJson method and usages * Update EdgePathOverwriteTests.java to use TestableNetworkRequest Replace usage of local getPayloadJson * Update testSendEvent_withXDMDataAndNullData_sendsCorrectRequestEvent to update testValue for clarity * Apply lint formatting for EdgeFunctionalTests.java and EdgePathOverwriteTests.java * Update to use stringValue for test case strings in event payloads * Update EdgeFunctionalTests and TestXDMSchema to use "test" prefixed property names Add code comments for ElementCount cases to make assertion logic clearer * Remove test case comments for JSON assertions with actual expected payloads * Update AEPTestUtils to latest version * Update test case setup for testHandleExperienceEventRequest_withPendingConfigurationState_expectEventsQueueIsBlocked to set an identity state beforehand * Apply lint formatting for NoConfigFunctionalTests.java * Add test case comments for clarity * RestartFunctionalTests.java - update tearDown to reset all test helpers
Description
This PR updates the final part of functional test classes:
IdentityStateFunctionalTests.java
NetworkResponseHandlerFunctionalTests.java
NoConfigFunctionalTests.java
RestartFunctionalTests.java
SampleFunctionalTests.java
to use the AEPTestUtils library, with the following changes:
flatten
.get()
is protected with size checksRelated Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: