Skip to content

Commit

Permalink
WIP: Test target build issue resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
muzahidul-opti committed Oct 21, 2024
1 parent 1883915 commit 5c97adc
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void setup() throws Exception {

optimizelyManager = OptimizelyManager.builder()
.withSDKKey(testSdkKey)
.withVuid(testVuid)
.withVuidEnabled()
.withODPEventManager(odpEventManager)
.withODPSegmentManager(odpSegmentManager)
.build(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.optimizely.ab.odp.ODPApiManager;
import com.optimizely.ab.odp.ODPEventManager;
import com.optimizely.ab.odp.ODPManager;
import com.optimizely.ab.android.odp.VuidManager;
import com.optimizely.ab.odp.ODPSegmentManager;

import org.junit.Before;
Expand Down Expand Up @@ -68,6 +69,7 @@ public class ODPIntegrationUpdateConfigTest {

private OptimizelyManager optimizelyManager;
private ODPManager odpManager;
private VuidManager vuidManager;
private DefaultDatafileHandler datafileHandler;
private NotificationCenter notificationCenter;
private Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
Expand Down Expand Up @@ -101,6 +103,7 @@ public void setup() throws Exception {

datafileHandler = new DefaultDatafileHandler();
notificationCenter = new NotificationCenter();
vuidManager = new VuidManager(context, true);

optimizelyManager = new OptimizelyManager(
null,
Expand All @@ -117,7 +120,7 @@ public void setup() throws Exception {
notificationCenter,
null,
odpManager,
"test-vuid",
vuidManager,
null,
null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void testBuildWithValidPollingInterval() {
OptimizelyManager manager = OptimizelyManager.builder()
.withSDKKey(testSdkKey)
.withDatafileDownloadInterval(interval, timeUnit)
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.build(mockContext);

assertEquals(interval * 60L, manager.getDatafileDownloadInterval().longValue());
Expand All @@ -128,7 +128,7 @@ public void testBuildWithEventHandler() {
.withSDKKey(testSdkKey)
.withDatafileDownloadInterval(901L, TimeUnit.SECONDS)
.withEventHandler(eventHandler)
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.build(mockContext);

assertEquals(901L, manager.getDatafileDownloadInterval().longValue());
Expand All @@ -142,7 +142,7 @@ public void testBuildWithErrorHandler() {
.withSDKKey(testSdkKey)
.withDatafileDownloadInterval(61L, TimeUnit.SECONDS)
.withErrorHandler(errorHandler)
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.build(mockContext);

manager.initialize(mockContext, minDatafile);
Expand All @@ -157,7 +157,7 @@ public void testBuildWithDatafileHandler() {
.withSDKKey(testSdkKey)
.withDatafileDownloadInterval(61L, TimeUnit.SECONDS)
.withDatafileHandler(dfHandler)
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.build(mockContext);

manager.initialize(mockContext, minDatafile);
Expand All @@ -172,7 +172,7 @@ public void testBuildWithUserProfileService() {
.withSDKKey(testSdkKey)
.withDatafileDownloadInterval(61L, TimeUnit.SECONDS)
.withUserProfileService(ups)
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.build(mockContext);

manager.initialize(mockContext, minDatafile);
Expand All @@ -189,7 +189,7 @@ public void testBuildWithDatafileDownloadInterval_workerScheduled() throws Excep
.withSDKKey(testSdkKey)
.withDatafileHandler(mockDatafileHandler)
.withDatafileDownloadInterval(goodNumber, TimeUnit.MINUTES)
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.build(mockContext);
OptimizelyManager spyManager = spy(manager);
when(spyManager.isAndroidVersionSupported()).thenReturn(true);
Expand All @@ -205,7 +205,7 @@ public void testBuildWithDatafileDownloadInterval_workerCancelledWhenIntervalIsN
.withSDKKey(testSdkKey)
.withDatafileHandler(mockDatafileHandler)
.withDatafileDownloadInterval(-1, TimeUnit.MINUTES)
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.build(mockContext);
OptimizelyManager spyManager = spy(manager);
when(spyManager.isAndroidVersionSupported()).thenReturn(true);
Expand All @@ -220,7 +220,7 @@ public void testBuildWithCustomSdkNameAndVersion() throws Exception {
OptimizelyManager manager = OptimizelyManager.builder()
.withSDKKey(testSdkKey)
.withClientInfo("test-sdk", "test-version")
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.build(mockContext);
assertEquals(manager.getSdkName(mockContext), "test-sdk");
assertEquals(manager.getSdkVersion(), "test-version");
Expand All @@ -232,7 +232,7 @@ public void testBuildWithDefaultODP_defaultEnabled() throws Exception {

OptimizelyManager manager = OptimizelyManager.builder()
.withSDKKey(testSdkKey)
.withVuid("test-vuid")
.withVuidEnabled()
.build(mockContext);

verifyNew(OptimizelyManager.class).withArguments(
Expand Down Expand Up @@ -262,7 +262,7 @@ public void testBuildWithDefaultODP_disabled() throws Exception {
OptimizelyManager manager = OptimizelyManager.builder()
.withSDKKey(testSdkKey)
.withODPDisabled()
.withVuid("test-vuid")
.withVuidEnabled()
.build(mockContext);

verifyNew(OptimizelyManager.class).withArguments(
Expand Down Expand Up @@ -293,7 +293,7 @@ public void testBuildWithODP_defaultCacheSizeAndTimeout() throws Exception {

OptimizelyManager manager = OptimizelyManager.builder()
.withSDKKey(testSdkKey)
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.build(mockContext);

verifyNew(ODPManager.class).withArguments(
Expand All @@ -320,7 +320,7 @@ public void testBuildWithODP_customSegmentCacheSize() throws Exception {
OptimizelyManager manager = OptimizelyManager.builder()
.withSDKKey(testSdkKey)
.withODPSegmentCacheSize(1234)
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.build(mockContext);

verifyNew(ODPSegmentManager.class).withArguments(
Expand All @@ -337,7 +337,7 @@ public void testBuildWithODP_customSegmentCacheTimeout() throws Exception {
OptimizelyManager manager = OptimizelyManager.builder()
.withSDKKey(testSdkKey)
.withODPSegmentCacheTimeout(20, TimeUnit.MINUTES)
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.build(mockContext);

verifyNew(ODPSegmentManager.class).withArguments(
Expand All @@ -351,7 +351,7 @@ public void testBuildWithODP_customSegmentCacheTimeout() throws Exception {
public void testBuildWithODP_defaultSegmentFetchTimeout() throws Exception {
OptimizelyManager manager = OptimizelyManager.builder()
.withSDKKey(testSdkKey)
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.build(mockContext);

assertEquals(ODPSegmentClient.Companion.getCONNECTION_TIMEOUT(), 10*1000);
Expand All @@ -364,7 +364,7 @@ public void testBuildWithODP_customSegmentFetchTimeout() throws Exception {
.withSDKKey(testSdkKey)
.withTimeoutForODPSegmentFetch(20)
.withTimeoutForODPEventDispatch(30)
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.build(mockContext);

assertEquals(ODPSegmentClient.Companion.getCONNECTION_TIMEOUT(), 20*1000);
Expand All @@ -380,7 +380,7 @@ public void testBuildWithODP_defaultCommonDataAndIdentifiers() throws Exception

OptimizelyManager manager = OptimizelyManager.builder()
.withSDKKey(testSdkKey)
.withVuid("test-vuid")
.withVuidEnabled()
.build(mockContext);

ArgumentCaptor<Map<String, Object>> captorData = ArgumentCaptor.forClass(Map.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void setup() throws Exception {
public void testBuildWithDatafileDownloadInterval() throws Exception {
long goodNumber = 27;
OptimizelyManager manager = OptimizelyManager.builder("1")
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.withLogger(logger)
.withDatafileDownloadInterval(goodNumber, TimeUnit.MINUTES)
.build(mockContext);
Expand Down Expand Up @@ -113,7 +113,7 @@ public void testBuildWithDatafileDownloadInterval() throws Exception {
public void testBuildWithDatafileDownloadIntervalDeprecated() throws Exception {
long goodNumber = 1234L;
OptimizelyManager manager = OptimizelyManager.builder("1")
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.withLogger(logger)
.withDatafileDownloadInterval(goodNumber) // deprecated
.build(mockContext);
Expand Down Expand Up @@ -142,7 +142,7 @@ public void testBuildWithDatafileDownloadIntervalDeprecated() throws Exception {
public void testBuildWithEventDispatchInterval() throws Exception {
long goodNumber = 100L;
OptimizelyManager manager = OptimizelyManager.builder("1")
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.withLogger(logger)
.withEventDispatchInterval(goodNumber, TimeUnit.SECONDS)
.build(mockContext);
Expand Down Expand Up @@ -186,7 +186,7 @@ public void testBuildWithEventDispatchRetryInterval() throws Exception {
long defaultEventFlushInterval = 30L; // seconds

OptimizelyManager manager = OptimizelyManager.builder("1")
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.withLogger(logger)
.withEventDispatchRetryInterval(goodNumber, timeUnit)
.build(mockContext);
Expand Down Expand Up @@ -227,7 +227,7 @@ public void testBuildWithEventDispatchRetryInterval() throws Exception {
public void testBuildWithEventDispatchIntervalDeprecated() throws Exception {
long goodNumber = 1234L;
OptimizelyManager manager = OptimizelyManager.builder("1")
.withVuid("any-to-avoid-generate")
.withVuidEnabled()
.withLogger(logger)
.withEventDispatchInterval(goodNumber) // deprecated
.build(mockContext);
Expand Down
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Thu Jan 28 11:38:35 PST 2021
#Fri Oct 18 20:28:21 BDT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
org.gradle.jvmargs=-Xmx1g
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class VuidManager constructor(context: Context, isEnabled: Boolean = false) {
return visitorId.startsWith("vuid_", ignoreCase = true)
}
}

@VisibleForTesting
fun makeVuid(): String {
val maxLength = 32 // required by ODP server
Expand Down

0 comments on commit 5c97adc

Please sign in to comment.