Skip to content

Commit

Permalink
Merge pull request #75 from adobe/dev
Browse files Browse the repository at this point in the history
Merge dev into staging for Assurance 2.2.0 release
  • Loading branch information
prudrabhat authored Oct 19, 2023
2 parents 4f02c06 + 1a97aba commit 728b30f
Show file tree
Hide file tree
Showing 23 changed files with 1,151 additions and 320 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: |
echo $GPG_SECRET_KEYS | base64 --decode | gpg --import --no-tty --batch --yes
echo $GPG_OWNERTRUST | base64 --decode | gpg --import-ownertrust --no-tty --batch --yes
- name: Publish to maven central staging repository
- name: Publish to maven central repository
run: make ci-publish-main
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven-snapshot.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish package to the Maven Central Repository
name: Publish package to the Maven Central Staging Repository
on:
push:
branches:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/update-testapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ jobs:
runs-on: macos-latest

steps:

- name: Set up Java
uses: actions/setup-java@v1
with:
java-version: 11

- name: Checkout
uses: actions/[email protected]
with:
Expand Down
Binary file modified artifacts/assurance-testapp-debug.apk
Binary file not shown.
10 changes: 7 additions & 3 deletions code/assurance-testapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1"

implementation project(':assurance')
implementation 'com.adobe.marketing.mobile:core:2.0.0'
implementation 'com.adobe.marketing.mobile:signal:2.0.0'
implementation 'com.adobe.marketing.mobile:lifecycle:2.0.0'
implementation 'com.adobe.marketing.mobile:core:2.2.3'
implementation 'com.adobe.marketing.mobile:signal:2.0.1'
implementation 'com.adobe.marketing.mobile:lifecycle:2.0.3'
implementation 'com.adobe.marketing.mobile:messaging:2.1.4'
implementation 'com.adobe.marketing.mobile:edge:2.1.0'
implementation 'com.adobe.marketing.mobile:edgeidentity:2.0.0'


//noinspection GradleCompatible
testImplementation 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ package com.adobe.marketing.mobile.assurance.testapp
import android.app.Application
import android.util.Log
import com.adobe.marketing.mobile.Assurance
import com.adobe.marketing.mobile.Edge
import com.adobe.marketing.mobile.Lifecycle
import com.adobe.marketing.mobile.LoggingMode
import com.adobe.marketing.mobile.Messaging
import com.adobe.marketing.mobile.MobileCore
import com.adobe.marketing.mobile.Signal
import com.adobe.marketing.mobile.assurance.testapp.AssuranceTestAppConstants.TAG
import com.adobe.marketing.mobile.edge.identity.Identity

class AssuranceTestApp : Application() {

Expand All @@ -32,9 +35,13 @@ class AssuranceTestApp : Application() {
listOf(
Assurance.EXTENSION,
Lifecycle.EXTENSION,
Signal.EXTENSION
Signal.EXTENSION,
Messaging.EXTENSION,
Edge.EXTENSION,
Identity.EXTENSION
)
) {
MobileCore.lifecycleStart(null)
Log.d(TAG, "AEP Mobile SDK initialization complete.");
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2023 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.assurance;


import android.net.Uri;
import org.junit.Assert;
import org.junit.Test;

/**
* Tests for {@link AssuranceUtil} that involve android specific constructs like {@link
* android.net.Uri} that cannot be mocked.
*/
public class AssuranceUtilTests {

@Test
public void testGetEnvironmentFromSocketUri() {
final Uri devSocketUri = Uri.parse("wss://connect-dev.griffon.adobe.com/client/v1");
Assert.assertEquals(
AssuranceConstants.AssuranceEnvironment.DEV,
AssuranceUtil.getEnvironmentFromSocketUri(devSocketUri));

final Uri qaSocketUri = Uri.parse("wss://connect-qa.griffon.adobe.com/client/v1");
Assert.assertEquals(
AssuranceConstants.AssuranceEnvironment.QA,
AssuranceUtil.getEnvironmentFromSocketUri(qaSocketUri));

final Uri stageSocketUri = Uri.parse("wss://connect-stage.griffon.adobe.com/client/v1");

Assert.assertEquals(
AssuranceConstants.AssuranceEnvironment.STAGE,
AssuranceUtil.getEnvironmentFromSocketUri(stageSocketUri));

final Uri prodSocketUri = Uri.parse("wss://connect.griffon.adobe.com/client/v1");
Assert.assertEquals(
AssuranceConstants.AssuranceEnvironment.PROD,
AssuranceUtil.getEnvironmentFromSocketUri(prodSocketUri));
}

@Test
public void testGetEnvironmentFromSocketUri_InvalidURI() {

final Uri invalidSocketUri = Uri.parse("wss://invalidconnect.griffon.adobe.com/client/v1");
Assert.assertEquals(
AssuranceConstants.AssuranceEnvironment.PROD,
AssuranceUtil.getEnvironmentFromSocketUri(invalidSocketUri));

final Uri invalidFormatUri = Uri.parse("not:://a_valid_uri");
Assert.assertEquals(
AssuranceConstants.AssuranceEnvironment.PROD,
AssuranceUtil.getEnvironmentFromSocketUri(invalidFormatUri));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* Copyright 2023 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

package com.adobe.marketing.mobile.assurance

import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Assert.fail
import org.junit.Test
import org.junit.runner.RunWith
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit

@RunWith(AndroidJUnit4::class)
class InboundEventWorkerTests {

companion object {
private const val WAIT_TIME_SECONDS = 5L
}

@Test
fun testInboundEventWorkerDoesNotNotifyListenerOnEventWhenNotStarted() {
val countDownLatch = CountDownLatch(1)
val inboundQueueEventListener: InboundEventQueueWorker.InboundQueueEventListener =
object : InboundEventQueueWorker.InboundQueueEventListener {
override fun onInboundEvent(event: AssuranceEvent) {
fail("Inbound event listener should not be called when worker is not started")
}
}
val inboundEventQueueWorker = InboundEventQueueWorker(inboundQueueEventListener)

val event1 = constructAssuranceControlEvent(mutableMapOf("key1" to "value1"))
val event2 = constructAssuranceControlEvent(mutableMapOf("key2" to "value2"))
val event3 = constructAssuranceControlEvent(mutableMapOf("key3" to "value3"))

inboundEventQueueWorker.offer(event1)
inboundEventQueueWorker.offer(event2)
inboundEventQueueWorker.offer(event3)

assertFalse(countDownLatch.await(WAIT_TIME_SECONDS, TimeUnit.SECONDS))
}

@Test
fun testInboundEventWorkerNotifiesListenerOnEventWhenStarted() {
val countDownLatch = CountDownLatch(1)
val eventsCollected = mutableListOf<AssuranceEvent>()
val inboundQueueEventListener: InboundEventQueueWorker.InboundQueueEventListener =
object : InboundEventQueueWorker.InboundQueueEventListener {
override fun onInboundEvent(event: AssuranceEvent) {
eventsCollected.add(event)
if (eventsCollected.size == 3) {
countDownLatch.countDown()
}
}
}
val inboundEventQueueWorker = InboundEventQueueWorker(inboundQueueEventListener)

val event1 = constructAssuranceControlEvent(mutableMapOf("key1" to "value1"))
val event2 = constructAssuranceControlEvent(mutableMapOf("key2" to "value2"))
val event3 = constructAssuranceControlEvent(mutableMapOf("key3" to "value3"))

inboundEventQueueWorker.start()

inboundEventQueueWorker.offer(event1)
inboundEventQueueWorker.offer(event2)
inboundEventQueueWorker.offer(event3)

assertTrue(countDownLatch.await(WAIT_TIME_SECONDS, TimeUnit.SECONDS))
}

@Test
fun testInboundEventWorkerQueuesAndNotifiesListenerOnEvents() {
val countDownLatch = CountDownLatch(1)
val eventsCollected = mutableListOf<AssuranceEvent>()
val inboundQueueEventListener: InboundEventQueueWorker.InboundQueueEventListener =
object : InboundEventQueueWorker.InboundQueueEventListener {
override fun onInboundEvent(event: AssuranceEvent) {
eventsCollected.add(event)
if (eventsCollected.size == 3) {
countDownLatch.countDown()
}
}
}
val inboundEventQueueWorker = InboundEventQueueWorker(inboundQueueEventListener)

val event1 = constructAssuranceControlEvent(mutableMapOf("key1" to "value1"))
val event2 = constructAssuranceControlEvent(mutableMapOf("key2" to "value2"))
val event3 = constructAssuranceControlEvent(mutableMapOf("key3" to "value3"))

inboundEventQueueWorker.offer(event1)
inboundEventQueueWorker.offer(event2)
inboundEventQueueWorker.offer(event3)

inboundEventQueueWorker.start()

assertTrue(countDownLatch.await(WAIT_TIME_SECONDS, TimeUnit.SECONDS))
}

private fun constructAssuranceControlEvent(payload: MutableMap<String, Any>): AssuranceEvent {
payload["type"] = AssuranceConstants.AssuranceEventType.CONTROL
return AssuranceEvent(AssuranceConstants.AssuranceEventType.CONTROL, payload)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Assurance {

public static final Class<? extends Extension> EXTENSION = AssuranceExtension.class;
public static final String LOG_TAG = "Assurance";
public static final String EXTENSION_VERSION = "2.1.1";
public static final String EXTENSION_VERSION = "2.2.0";
public static final String EXTENSION_NAME = "com.adobe.assurance";
public static final String EXTENSION_FRIENDLY_NAME = "Assurance";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,23 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.json.JSONObject;

final class AssuranceClientInfo {

private static final String VALUE_UNKNOWN = "Unknown";
private static final String MANIFEST_FILE_NAME = "AndroidManifest.xml";
private static final String EVENT_TYPE_CONNECT = "connect";

private final JSONObject manifestData;

AssuranceClientInfo() {
// parse the manifest file and store it in a JSONObject for later use as this does not
// change
// during the lifetime of the application
manifestData = AssuranceIOUtils.parseXMLResourceFileToJson(MANIFEST_FILE_NAME);
}

/**
* Returns the payload for assurance ClientInfo event. ClientInfo event includes
*
Expand All @@ -57,9 +67,7 @@ Map<String, Object> getData() {
eventPayload.put(AssuranceConstants.ClientInfoKeys.VERSION, Assurance.extensionVersion());
eventPayload.put(AssuranceConstants.ClientInfoKeys.DEVICE_INFO, getDeviceInfo());
eventPayload.put(AssuranceConstants.PayloadDataKeys.TYPE, EVENT_TYPE_CONNECT);
eventPayload.put(
AssuranceConstants.ClientInfoKeys.APP_SETTINGS,
AssuranceIOUtils.parseXMLResourceFileToJson(MANIFEST_FILE_NAME));
eventPayload.put(AssuranceConstants.ClientInfoKeys.APP_SETTINGS, manifestData);
return eventPayload;
}

Expand Down
Loading

0 comments on commit 728b30f

Please sign in to comment.