Skip to content

Commit

Permalink
Functional test AEPTestUtils update (#159)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
timkimadobe authored Jun 26, 2024
1 parent 2b1c320 commit b866da2
Show file tree
Hide file tree
Showing 31 changed files with 1,297 additions and 4,966 deletions.
4 changes: 2 additions & 2 deletions code/edge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ dependencies {
implementation("com.adobe.marketing.mobile:core:$mavenCoreVersion")
implementation("com.adobe.marketing.mobile:edgeidentity:$mavenEdgeIdentityVersion")

testImplementation("com.github.adobe:aepsdk-testutils-android:a9182db238")
testImplementation("com.github.adobe:aepsdk-testutils-android:a4991045da")

androidTestImplementation(project(":test-utils"))
androidTestImplementation("com.github.adobe:aepsdk-testutils-android:a4991045da")
androidTestImplementation("com.adobe.marketing.mobile:edgeconsent:3.0.0-SNAPSHOT")
{
exclude(group = "com.adobe.marketing.mobile", module = "edge")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@
import com.adobe.marketing.mobile.services.HttpConnecting;
import com.adobe.marketing.mobile.services.ServiceProvider;
import com.adobe.marketing.mobile.services.TestableNetworkRequest;
import com.adobe.marketing.mobile.util.JSONAsserts;
import com.adobe.marketing.mobile.util.MockNetworkService;
import com.adobe.marketing.mobile.util.MonitorExtension;
import com.adobe.marketing.mobile.util.TestConstants;
import com.adobe.marketing.mobile.util.TestHelper;
import com.adobe.marketing.mobile.util.TestUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.After;
Expand Down Expand Up @@ -128,16 +127,26 @@ public void testSendEvent_withCompletionHandler_callsCompletionCorrectly() throw
assertEquals(1, resultNetworkRequests.size());
assertEquals(1, receivedHandles.size());

assertEquals("personalization:decisions", receivedHandles.get(0).getType());
assertEquals(1, receivedHandles.get(0).getPayload().size());

Map<String, String> data = TestUtils.flattenMap(receivedHandles.get(0).getPayload().get(0));

assertEquals(4, data.size());
assertEquals("AT:eyJhY3Rpdml0eUlkIjoiMTE3NTg4IiwiZXhwZXJpZW5jZUlkIjoiMSJ9", data.get("id"));
assertEquals("#D41DBA", data.get("items[0].data.content.value"));
assertEquals("https://ns.adobe.com/personalization/json-content-item", data.get("items[0].schema"));
assertEquals("buttonColor", data.get("scope"));
EdgeEventHandle edgeEventHandle = receivedHandles.get(0);
assertEquals("personalization:decisions", edgeEventHandle.getType());
assertEquals(1, edgeEventHandle.getPayload().size());

String expected =
"{" +
" \"id\": \"AT:eyJhY3Rpdml0eUlkIjoiMTE3NTg4IiwiZXhwZXJpZW5jZUlkIjoiMSJ9\"," +
" \"items\": [" +
" {" +
" \"data\": {" +
" \"content\": {" +
" \"value\": \"#D41DBA\"" +
" }" +
" }," +
" \"schema\": \"https://ns.adobe.com/personalization/json-content-item\"" +
" }" +
" ]," +
" \"scope\": \"buttonColor\"" +
"}";
JSONAsserts.assertEquals(expected, edgeEventHandle.getPayload().get(0));
}

@Test
Expand Down
Loading

0 comments on commit b866da2

Please sign in to comment.