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

Transfer AEPTestUtils to Core #723

Merged
merged 7 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
executor:
name: android/android-docker
resource-class: large
tag: 2024.01.1
tag: 2024.01.1-node
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this necessary?

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 one is only necessary to allow test utils: enableSpotlessPrettierForJava = true
Without it, the spotless java check fails because the CI runner can't find a valid npm instance


steps:
- checkout
Expand Down
28 changes: 24 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@ clean:

checkstyle: core-checkstyle signal-checkstyle lifecycle-checkstyle identity-checkstyle

checkformat: core-checkformat signal-checkformat lifecycle-checkformat identity-checkformat
checkformat: core-checkformat signal-checkformat lifecycle-checkformat identity-checkformat testutils-checkformat

format: core-format signal-format lifecycle-format identity-format
format: core-format signal-format lifecycle-format identity-format testutils-format

api-dump:
(./code/gradlew -p code/core apiDump)
(./code/gradlew -p code/testutils apiDump)

api-check:
(./code/gradlew -p code/core apiCheck)
(./code/gradlew -p code/testutils apiCheck)

assemble-phone: core-assemble-phone signal-assemble-phone lifecycle-assemble-phone identity-assemble-phone

assemble-phone-release: core-assemble-phone-release signal-assemble-phone-release lifecycle-assemble-phone-release identity-assemble-phone-release

unit-test: core-unit-test signal-unit-test lifecycle-unit-test
unit-test: core-unit-test signal-unit-test lifecycle-unit-test testutils-unit-test

unit-test-coverage: core-unit-test-coverage signal-unit-test-coverage lifecycle-unit-test-coverage
unit-test-coverage: core-unit-test-coverage signal-unit-test-coverage lifecycle-unit-test-coverage testutils-unit-test-coverage

functional-test: core-functional-test signal-functional-test lifecycle-functional-test identity-functional-test

Expand Down Expand Up @@ -210,3 +212,21 @@ identity-publish-maven-local:
identity-publish-maven-local-jitpack:
(./code/gradlew -p code/identity assemblePhone)
(./code/gradlew -p code/identity publishReleasePublicationToMavenLocal -Pjitpack -x signReleasePublication)

### TestUtils

testutils-checkformat:
(./code/gradlew -p code/testutils spotlessCheck)

testutils-format:
(./code/gradlew -p code/testutils spotlessApply)

testutils-unit-test:
(./code/gradlew -p code/testutils testPhoneDebugUnitTest)

testutils-unit-test-coverage:
(./code/gradlew -p code/testutils createPhoneDebugUnitTestCoverageReport)

testutils-publish-maven-local-jitpack:
(./code/gradlew -p code/testutils assemblePhone)
(./code/gradlew -p code/testutils publishReleasePublicationToMavenLocal -Pjitpack -x signReleasePublication)
2 changes: 2 additions & 0 deletions code/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,7 @@ dependencies {
androidTestImplementation("androidx.test.uiautomator:uiautomator:2.3.0")
//TODO: Consider moving this to the aep-library plugin later
androidTestImplementation("com.linkedin.dexmaker:dexmaker-mockito-inline:2.28.3")
androidTestImplementation(project(":testutils"))
testImplementation("org.robolectric:robolectric:4.7")
testImplementation(project(":testutils"))
}
3 changes: 2 additions & 1 deletion code/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ include (
":macrobenchmark",
":microbenchmark",
":testapp",
)
":testutils"
)
706 changes: 706 additions & 0 deletions code/testutils/api/testutils.api

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions code/testutils/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* 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.
*/

import com.adobe.marketing.mobile.gradle.BuildConstants

plugins {
id("aep-library")
id("binary-compatibility-validator")
}

val coreExtensionVersion: String by project
val jacksonVersion = "2.12.7"

aepLibrary {
namespace = "com.adobe.marketing.mobile.testutils"
moduleName = "testutils"
moduleVersion = "3.0.0"
enableSpotless = true
enableSpotlessPrettierForJava = true
enableDokkaDoc = true

publishing {
mavenRepoName = "AdobeMobileTestUtilsSdk"
mavenRepoDescription = "Android Test Utils for Adobe Mobile Marketing"
gitRepoName = "aepsdk-testutils-android"
addCoreDependency(coreExtensionVersion)
addMavenDependency("androidx.test.ext", "junit", BuildConstants.Versions.ANDROIDX_TEST_EXT_JUNIT)
addMavenDependency("com.fasterxml.jackson.core", "jackson-databind", jacksonVersion)
}
}

dependencies {
implementation(project(":core"))
implementation(BuildConstants.Dependencies.ANDROIDX_TEST_EXT_JUNIT)
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
}
19 changes: 19 additions & 0 deletions code/testutils/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>

<!--

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.

-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
Copyright 2022 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;

/**
* Helper class for testing to access methods provided in Core
*/
public class MobileCoreHelper {

/**
* Wrapper around {@link MobileCore#resetSDK()}
*/
public static void resetSDK() {
MobileCore.resetSDK();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
/*
Copyright 2021 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.services;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public class MockDataStoreService implements DataStoring {

private static final ConcurrentMap<String, NamedCollection> stores = new ConcurrentHashMap<>();

public static void clearStores() {
stores.clear();
}

@Override
public NamedCollection getNamedCollection(String s) {
if (stores.containsKey(s)) {
return stores.get(s);
}

NamedCollection newStore = new MockTestDataStore();
stores.put(s, newStore);
return newStore;
}

public static class MockTestDataStore implements NamedCollection {

private final ConcurrentMap<String, Object> store;

public MockTestDataStore() {
this.store = new ConcurrentHashMap<>();
}

@Override
public void setInt(String s, int i) {
store.put(s, i);
}

@Override
public int getInt(String s, int i) {
if (store.containsKey(s)) {
return (int) store.get(s);
}

return i;
}

@Override
public void setString(String s, String s1) {
store.put(s, s1);
}

@Override
public String getString(String s, String s1) {
if (store.containsKey(s)) {
return (String) store.get(s);
}

return s1;
}

@Override
public void setDouble(String s, double v) {
store.put(s, v);
}

@Override
public double getDouble(String s, double v) {
if (store.containsKey(s)) {
return (double) store.get(s);
}

return v;
}

@Override
public void setLong(String s, long l) {
store.put(s, l);
}

@Override
public long getLong(String s, long l) {
if (store.containsKey(s)) {
return (long) store.get(s);
}

return l;
}

@Override
public void setFloat(String s, float v) {
store.put(s, v);
}

@Override
public float getFloat(String s, float v) {
if (store.containsKey(s)) {
return (float) store.get(s);
}

return v;
}

@Override
public void setBoolean(String s, boolean b) {
store.put(s, b);
}

@Override
public boolean getBoolean(String s, boolean b) {
if (store.containsKey(s)) {
return (boolean) store.get(s);
}

return b;
}

@Override
public void setMap(String s, Map<String, String> map) {
store.put(s, map);
}

@Override
public Map<String, String> getMap(String s) {
if (store.containsKey(s)) {
return (Map<String, String>) store.get(s);
}

return new HashMap<>();
}

@Override
public boolean contains(String s) {
return store.containsKey(s);
}

@Override
public void remove(String s) {
store.remove(s);
}

@Override
public void removeAll() {
store.clear();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
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.services

open class NetworkServiceHelper : Networking {
private val delegate: NetworkService = NetworkService()

override fun connectAsync(request: NetworkRequest?, callback: NetworkCallback?) {
delegate.connectAsync(request, callback)
}
}
Loading