use of com.optimizely.ab.android.shared.Cache in project android-sdk by optimizely.
the class DefaultUserProfileServiceTest method setup.
@Before
public void setup() {
logger = mock(Logger.class);
cache = new Cache(InstrumentationRegistry.getInstrumentation().getTargetContext(), logger);
executor = Executors.newSingleThreadExecutor();
legacyDiskCache = new UserProfileCache.LegacyDiskCache(cache, executor, logger, projectId);
memoryCache = new ConcurrentHashMap<>();
projectId = "123";
diskCache = new UserProfileCache.DiskCache(cache, executor, logger, projectId);
userProfileCache = new UserProfileCache(diskCache, logger, memoryCache, legacyDiskCache);
userProfileService = new DefaultUserProfileService(userProfileCache, logger);
// Test data.
userId1 = "user_1";
Map<String, Map<String, String>> experimentBucketMap1 = new ConcurrentHashMap<>();
Map<String, String> decisionMap1 = new ConcurrentHashMap<>();
decisionMap1.put("variation_id", "var_1");
experimentBucketMap1.put("exp_1", decisionMap1);
Map<String, String> decisionMap2 = new ConcurrentHashMap<>();
decisionMap2.put("variation_id", "var_2");
experimentBucketMap1.put("exp_2", decisionMap2);
userProfileMap1 = new ConcurrentHashMap<>();
userProfileMap1.put("user_id", userId1);
userProfileMap1.put("experiment_bucket_map", experimentBucketMap1);
userId2 = "user_2";
Map<String, Map<String, String>> experimentBucketMap2 = new ConcurrentHashMap<>();
Map<String, String> decisionMap3 = new ConcurrentHashMap<>();
decisionMap3.put("variation_id", "var_3");
experimentBucketMap2.put("exp_1", decisionMap3);
Map<String, String> decisionMap4 = new ConcurrentHashMap<>();
decisionMap4.put("variation_id", "var_4");
experimentBucketMap2.put("exp_2", decisionMap4);
userProfileMap2 = new ConcurrentHashMap<>();
userProfileMap2.put("user_id", userId2);
userProfileMap2.put("experiment_bucket_map", experimentBucketMap2);
}
use of com.optimizely.ab.android.shared.Cache in project android-sdk by optimizely.
the class DiskCacheTest method setup.
@Before
public void setup() {
logger = mock(Logger.class);
cache = new Cache(InstrumentationRegistry.getInstrumentation().getTargetContext(), logger);
memoryCache = new ConcurrentHashMap<>();
projectId = "123";
diskCache = new UserProfileCache.DiskCache(cache, executor, logger, projectId);
userId = "user_1";
// Populate in-memory cache.
Map<String, Map<String, String>> experimentBucketMap = new ConcurrentHashMap<>();
Map<String, String> decisionMap1 = new ConcurrentHashMap<>();
decisionMap1.put("variation_id", "var_1");
experimentBucketMap.put("exp_1", decisionMap1);
Map<String, String> decisionMap2 = new ConcurrentHashMap<>();
decisionMap2.put("variation_id", "var_2");
experimentBucketMap.put("exp_2", decisionMap2);
Map<String, Object> userProfileMap = new ConcurrentHashMap<>();
userProfileMap.put("user_id", userId);
userProfileMap.put("experiment_bucket_map", experimentBucketMap);
memoryCache.put(userId, userProfileMap);
}
use of com.optimizely.ab.android.shared.Cache in project android-sdk by optimizely.
the class LegacyDiskCacheTest method setup.
@Before
public void setup() {
logger = mock(Logger.class);
cache = new Cache(InstrumentationRegistry.getInstrumentation().getTargetContext(), logger);
projectId = "123";
legacyDiskCache = new UserProfileCache.LegacyDiskCache(cache, executor, logger, projectId);
}
Aggregations