Skip to content

Commit

Permalink
fix: Change configMaxAge type from Long to int (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
willpassidomo authored Jan 6, 2022
1 parent fc0f658 commit 14ad4b5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -436,22 +436,22 @@ public void testConfigStaleness() {
//0 should return 0
options = MParticleOptions.builder(mContext)
.credentials("key", "secret")
.configMaxAgeSeconds(0L)
.configMaxAgeSeconds(0)
.build();
assertEquals(0, options.getConfigMaxAge().intValue());

//positive number should return positive number
Long testValue = Math.abs(ran.nextLong());
int testValue = Math.abs(ran.nextInt());
options = MParticleOptions.builder(mContext)
.credentials("key", "secret")
.configMaxAgeSeconds(testValue)
.build();
assertEquals(testValue, options.getConfigMaxAge());
assertEquals(testValue, options.getConfigMaxAge().intValue());

//negative number should get thrown out and return null
options = MParticleOptions.builder(mContext)
.credentials("key", "secret")
.configMaxAgeSeconds(-5L)
.configMaxAgeSeconds(-5)
.build();
assertNull(options.getConfigMaxAge());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ConfigStalenessCheckTest: BaseCleanInstallEachTest() {
var latch = MPLatch(1);
val options = MParticleOptions.builder(mContext)
.addCredentials()
.configMaxAgeSeconds(1L)
.configMaxAgeSeconds(1)
.build()

mServer.setupConfigResponse(config1.toString())
Expand Down Expand Up @@ -103,7 +103,7 @@ class ConfigStalenessCheckTest: BaseCleanInstallEachTest() {
var latch = MPLatch(1);
val options = MParticleOptions.builder(mContext)
.addCredentials()
.configMaxAgeSeconds(100L)
.configMaxAgeSeconds(100)
.build()

mServer.setupConfigResponse(config1.toString())
Expand Down Expand Up @@ -143,7 +143,7 @@ class ConfigStalenessCheckTest: BaseCleanInstallEachTest() {
var latch = MPLatch(1);
val options = MParticleOptions.builder(mContext)
.addCredentials()
.configMaxAgeSeconds(0L)
.configMaxAgeSeconds(0)
.build()

mServer.setupConfigResponse(config1.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class MParticleOptions {
private Boolean mAndroidIdDisabled = false;
private Integer mUploadInterval = ConfigManager.DEFAULT_UPLOAD_INTERVAL; //seconds
private Integer mSessionTimeout = ConfigManager.DEFAULT_SESSION_TIMEOUT_SECONDS; //seconds
private Long mConfigMaxAge = null;
private Integer mConfigMaxAge = null;
private Boolean mUnCaughtExceptionLogging = false;
private MParticle.LogLevel mLogLevel = MParticle.LogLevel.DEBUG;
private AttributionListener mAttributionListener;
Expand Down Expand Up @@ -227,7 +227,7 @@ public Integer getSessionTimeout() {
}

@NonNull
public Long getConfigMaxAge() {
public Integer getConfigMaxAge() {
return mConfigMaxAge;
}

Expand Down Expand Up @@ -333,7 +333,7 @@ public static class Builder {
private Boolean androidIdDisabled = null;
private Integer uploadInterval = null;
private Integer sessionTimeout = null;
private Long configMaxAge = null;
private Integer configMaxAge = null;
private Boolean unCaughtExceptionLogging = null;
private MParticle.LogLevel logLevel = null;
BaseIdentityTask identityTask;
Expand Down Expand Up @@ -505,7 +505,7 @@ public Builder sessionTimeout(int sessionTimeout) {
* @return the instance of the builder, for chaining calls
*/
@NonNull
public Builder configMaxAgeSeconds(Long configMaxAge) {
public Builder configMaxAgeSeconds(int configMaxAge) {
this.configMaxAge = configMaxAge;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public class ConfigManager {
private JSONObject mCurrentCookies;
private String mDataplanId;
private Integer mDataplanVersion;
private Long mMaxConfigAge;
private Integer mMaxConfigAge;
public static final int DEFAULT_CONNECTION_TIMEOUT_SECONDS = 30;
public static final int MINIMUM_CONNECTION_TIMEOUT_SECONDS = 1;
public static final int DEFAULT_SESSION_TIMEOUT_SECONDS = 60;
Expand Down Expand Up @@ -130,7 +130,7 @@ public ConfigManager(@NonNull MParticleOptions options) {
this(options.getContext(), options.getEnvironment(), options.getApiKey(), options.getApiSecret(), options.getDataplanOptions(), options.getDataplanId(), options.getDataplanVersion(), options.getConfigMaxAge(), options.getConfigurationsForTarget(ConfigManager.class));
}

public ConfigManager(@NonNull Context context, @Nullable MParticle.Environment environment, @Nullable String apiKey, @Nullable String apiSecret, @Nullable MParticleOptions.DataplanOptions dataplanOptions, @Nullable String dataplanId, @Nullable Integer dataplanVersion, @Nullable Long configMaxAge, @Nullable List<Configuration<ConfigManager>> configurations) {
public ConfigManager(@NonNull Context context, @Nullable MParticle.Environment environment, @Nullable String apiKey, @Nullable String apiSecret, @Nullable MParticleOptions.DataplanOptions dataplanOptions, @Nullable String dataplanId, @Nullable Integer dataplanVersion, @Nullable Integer configMaxAge, @Nullable List<Configuration<ConfigManager>> configurations) {
mContext = context.getApplicationContext();
sPreferences = getPreferences(mContext);
mLocalPrefs = new AppConfig(mContext, environment, sPreferences, apiKey, apiSecret);
Expand Down

0 comments on commit 14ad4b5

Please sign in to comment.