-
Notifications
You must be signed in to change notification settings - Fork 24
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
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8d9e7f4
Initial transfer of AEPTestUtils as new module
timkimadobe 41c9a78
AEPTestUtils API dump
timkimadobe f3255b9
Add AEPTestUtils rules
timkimadobe 84246ee
Remove check style for AEPTestUtils
timkimadobe a3c5d7e
Update Core gradle config to make AEPTestUtils available
timkimadobe 1aa33c8
Update unit test runner to node version for AEPTestUtils java prettie…
timkimadobe 66effd3
Update to include testutils jitpack step
timkimadobe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,5 @@ include ( | |
":macrobenchmark", | ||
":microbenchmark", | ||
":testapp", | ||
) | ||
":testutils" | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
25 changes: 25 additions & 0 deletions
25
code/testutils/src/main/java/com/adobe/marketing/mobile/MobileCoreHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
159 changes: 159 additions & 0 deletions
159
code/testutils/src/main/java/com/adobe/marketing/mobile/services/MockDataStoreService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
code/testutils/src/main/java/com/adobe/marketing/mobile/services/NetworkServiceHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this necessary?
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.
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