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

[DEV] Fixes for code analyzer and jacoco warnings #39

Merged
merged 5 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
[DEV] Fix analyzer/lint warnings
  • Loading branch information
emdobrin committed Sep 21, 2021
commit 74113afa52d3703326d6f9677cb0e9dc32b43412
9 changes: 3 additions & 6 deletions code/edgeconsent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -251,26 +251,23 @@ task platformFunctionalTestJacocoReport(type: JacocoReport, dependsOn: "createPh


dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'

// Adobe Mobile SDK Core
implementation "com.adobe.marketing.mobile:core:${rootProject.mavenCoreVersion}"

testImplementation "androidx.test.ext:junit:${rootProject.ext.junitVersion}"
testImplementation "org.mockito:mockito-core:${rootProject.ext.mockitoCoreVersion}"
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.9.9'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.10.5'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.0'
testImplementation 'org.powermock:powermock-module-junit4:2.0.0'
testImplementation 'org.json:json:20180813'

androidTestImplementation "androidx.test.ext:junit:${rootProject.ext.junitVersion}"
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// Using older version of PowerMock as it supports minimum Android API < 26
// the root issue appears to be a dependency with Objenesis in Mockito-Core
// where Objenesis 2 requires minimum Android API 26
androidTestImplementation 'org.powermock:powermock-module-junit4:1+'
androidTestImplementation 'com.fasterxml.jackson.core:jackson-databind:2.9.9'

androidTestImplementation 'com.fasterxml.jackson.core:jackson-databind:2.10.5'
}

tasks.withType(Test) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ final class ConsentConstants {

private ConsentConstants() {}

final class EventDataKey {
static final class EventDataKey {

static final String CONSENTS = "consents";
static final String METADATA = "metadata";
static final String PAYLOAD = "payload";

static final String TIME = "time";
static final String VALUE = "val";

private EventDataKey() {}
}

final class EventSource {
static final class EventSource {

static final String CONSENT_PREFERENCE = "consent:preferences";
static final String UPDATE_CONSENT = "com.adobe.eventSource.updateConsent";
Expand All @@ -42,7 +41,7 @@ final class EventSource {
private EventSource() {}
}

final class EventType {
static final class EventType {

static final String CONSENT = "com.adobe.eventType.edgeConsent";
static final String EDGE = "com.adobe.eventType.edge";
Expand All @@ -52,15 +51,15 @@ final class EventType {
private EventType() {}
}

final class DataStoreKey {
static final class DataStoreKey {

static final String DATASTORE_NAME = EXTENSION_NAME;
static final String CONSENT_PREFERENCES = "consent:preferences";

private DataStoreKey() {}
}

final class EventNames {
static final class EventNames {

static final String EDGE_CONSENT_UPDATE = "Edge Consent Update Request";
static final String CONSENT_UPDATE_REQUEST = "Consent Update Request";
Expand All @@ -71,7 +70,7 @@ final class EventNames {
private EventNames() {}
}

final class ConfigurationKey {
static final class ConfigurationKey {

static final String DEFAULT_CONSENT = "consent.default";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

class ConsentExtension extends Extension {

private ConsentManager consentManager;
private final ConsentManager consentManager;

/**
* Constructor.
Expand Down Expand Up @@ -180,8 +180,8 @@ void handleConsentUpdate(final Event event) {
/**
* Handles the event with eventType {@link ConsentConstants.EventType#EDGE} and EventSource {@link ConsentConstants.EventSource#CONSENT_PREFERENCE}.
* <p>
* 1. Reads the event data and extract newconsents from the edge response in XDM Format.
* 2. Merge with the existing consents.
* 1. Reads the event data and extracts new consents from the edge response in XDM Format.
* 2. Merges with the existing consents.
* 3. Creates XDMSharedState and dispatches a Consent response event for other modules to notify the consent change.
*
* @param event the Edge consent preferences response {@link Event} to be processed
Expand Down Expand Up @@ -375,7 +375,7 @@ public void error(final ExtensionError extensionError) {
/**
* Dispatches an {@link ConsentConstants.EventNames#EDGE_CONSENT_UPDATE} event with the latest consents in the event data.
* <p>
* Does not dispatch the event if the latests consents is null/empty.
* Does not dispatch the event if the latest consents are null/empty.
*
* @param consents {@link Consents} object representing the updated consents of AEP SDK
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,12 @@ boolean equalsIgnoreTimestamp(final Consents comparingConsent) {
* Private helper method to remove metadata timestamp from this {@link Consents}
*/
private void removeTimeStamp() {
Map<String, Object> metaDataContents = (Map<String, Object>) consentsMap.get(
ConsentConstants.EventDataKey.METADATA
);
Map<String, Object> metaDataContents;
try {
metaDataContents = (Map<String, Object>) consentsMap.get(ConsentConstants.EventDataKey.METADATA);
} catch (final ClassCastException exp) {
return;
}

if (metaDataContents == null || metaDataContents.isEmpty()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private DateUtility() {}
* For example, 2017-09-26T15:52:25Z
*
* @param timestamp a timestamp
* @return {@code timestamp} formatted to a string in the format of 'yyyy-MM-dd'T'HH:mm:ss'Z'',
* @return {@code timestamp} formatted to a string in the format of {@code yyyy-MM-dd'T'HH:mm:ss'Z'},
* or an empty string if {@code timestamp} is null
*/
static String dateToISO8601String(final Date timestamp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static List<Object> toList(final JSONArray jsonArray) {

for (int i = 0; i < size; i++) {
Object value = null;
Object returnValue = null;
Object returnValue;

try {
value = jsonArray.get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ConsentTestUtil {
private static final String COLLECT = "collect";
private static final String PERSONALIZE = "personalize";
private static final String CONTENT = "content";
private static final String VALUE = "val";

/**
* A fully prepared valid consent JSON looks like :
Expand Down Expand Up @@ -131,7 +132,7 @@ static Map<String, Object> CreateConsentXDMMap(
COLLECT,
new HashMap<String, String>() {
{
put(ConsentConstants.EventDataKey.VALUE, collectConsentString);
put(VALUE, collectConsentString);
}
}
);
Expand All @@ -142,7 +143,7 @@ static Map<String, Object> CreateConsentXDMMap(
ADID,
new HashMap<String, String>() {
{
put(ConsentConstants.EventDataKey.VALUE, adIDConsentString);
put(VALUE, adIDConsentString);
}
}
);
Expand All @@ -157,7 +158,7 @@ static Map<String, Object> CreateConsentXDMMap(
CONTENT,
new HashMap<String, String>() {
{
put(ConsentConstants.EventDataKey.VALUE, personalizeConsentString);
put(VALUE, personalizeConsentString);
}
}
);
Expand Down