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

fix: Error handle null user attribute better and add use case to test file #290

Merged
merged 3 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all 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 .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ jobs:

semantic-release-dryrun:
name: "Test Semantic Release - Dry Run"
needs: [instrumented-tests, instrumented-orchestrator-tests, unit-tests, lint-checks, update-kits]
needs: [instrumented-tests, instrumented-orchestrator-tests, unit-tests, lint-checks, kotlin-lint-checks, update-kits]
runs-on: macos-latest
env:
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class MPUserTest : BaseCleanStartedEachTest() {
setUserAttribute("fooDouble", 10.15)
setUserAttribute("fooNegInt", -10L)
setUserAttribute("fooNegLong", -1010L)
this.userAttributes.put("fooNull", null)
android_test_hack()

getUserAttributes(object : UserAttributeListener {
Expand All @@ -48,6 +49,7 @@ class MPUserTest : BaseCleanStartedEachTest() {
assertEquals("10.15", userAttributes["fooDouble"])
assertEquals("-10", userAttributes["fooNegInt"])
assertEquals("-1010", userAttributes["fooNegLong"])
assertEquals(null, userAttributes["fooNull"])
}
})

Expand All @@ -64,6 +66,7 @@ class MPUserTest : BaseCleanStartedEachTest() {
assertEquals(10.15, userAttributes["fooDouble"])
assertEquals(-10L, userAttributes["fooNegInt"])
assertEquals(-1010L, userAttributes["fooNegLong"])
assertEquals(null, userAttributes["fooNull"])
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ public void logNotification(ProviderCloudMessage cloudMessage, String appState)

@Override
public void logNotification(int contentId, String payload, String appState, int newBehavior) {
try{
try {
BaseMPMessage message = new BaseMPMessage.Builder(MessageType.PUSH_RECEIVED)
.timestamp(System.currentTimeMillis())
.name("gcm")
Expand All @@ -664,7 +664,7 @@ public void logNotification(int contentId, String payload, String appState, int
message.put(MessageKey.APP_STATE, appState);
mMessageHandler.sendMessage(mMessageHandler.obtainMessage(MessageHandler.STORE_MESSAGE, message));

}catch (JSONException e) {
} catch (JSONException e) {

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

import com.mparticle.MParticle;
import com.mparticle.MParticleOptions;
import com.mparticle.TypedUserAttributeListener;
import com.mparticle.UserAttributeListener;
import com.mparticle.UserAttributeListenerType;
import com.mparticle.identity.UserAttributeListenerWrapper;
import com.mparticle.internal.BatchId;
import com.mparticle.internal.ConfigManager;
Expand All @@ -36,8 +33,6 @@
import org.json.JSONException;
import org.json.JSONObject;

import java.text.NumberFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void onUserAttributesReceived(@NonNull Map<String, ?> userAttributes, @No
if (entry.getValue() != null) {
stringifiedAttributes.put(entry.getKey(), entry.getValue().toString());
} else {
stringifiedAttributes.put(entry.getKey(), "");
stringifiedAttributes.put(entry.getKey(), null);
}
}
((UserAttributeListener) listener).onUserAttributesReceived(
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.7.21'
ext.kotlin_version = '1.7.22'
ext.gradle_version = '7.3.1'

repositories {
Expand Down
4 changes: 2 additions & 2 deletions testutils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ dependencies {

api 'androidx.annotation:annotation:1.5.0'
api 'androidx.test.ext:junit:1.1.4'
api 'androidx.test:rules:1.4.0'
api 'androidx.test:rules:1.5.0'

androidTestCompileOnly project(':android-core')

Expand All @@ -66,7 +66,7 @@ dependencies {
}
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test:rules:1.5.0'
androidTestImplementation 'com.google.firebase:firebase-messaging:20.0.0'

androidTestUtil 'androidx.test:orchestrator:1.4.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import androidx.annotation.Nullable;

import com.mparticle.MParticle;
import com.mparticle.UserAttributeListener;
import com.mparticle.UserAttributeListenerType;
import com.mparticle.consent.ConsentState;
import com.mparticle.identity.MParticleUser;
Expand Down
2 changes: 1 addition & 1 deletion tooling/custom-lint-rules/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.android.tools.build:gradle:$gradle_version"
classpath 'com.guardsquare:proguard-gradle:7.2.2'
classpath 'com.guardsquare:proguard-gradle:7.3.0'
}
}

Expand Down