Skip to content

Commit ba575ce

Browse files
update: refactor DefaultCmabService to remove CmabServiceOptions dependency and adjust related tests
1 parent a17becd commit ba575ce

File tree

4 files changed

+6
-60
lines changed

4 files changed

+6
-60
lines changed

core-api/src/main/java/com/optimizely/ab/Optimizely.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import com.optimizely.ab.bucketing.*;
2020
import com.optimizely.ab.cmab.service.CmabCacheValue;
2121
import com.optimizely.ab.cmab.service.CmabService;
22-
import com.optimizely.ab.cmab.service.CmabServiceOptions;
2322
import com.optimizely.ab.cmab.service.DefaultCmabService;
2423
import com.optimizely.ab.config.AtomicProjectConfigManager;
2524
import com.optimizely.ab.config.DatafileProjectConfig;
@@ -1993,8 +1992,7 @@ public Builder withCmabClient(CmabClient cmabClient) {
19931992
int DEFAULT_MAX_SIZE = 1000;
19941993
int DEFAULT_CMAB_CACHE_TIMEOUT = 30 * 60;
19951994
DefaultLRUCache<CmabCacheValue> cmabCache = new DefaultLRUCache<>(DEFAULT_MAX_SIZE, DEFAULT_CMAB_CACHE_TIMEOUT);
1996-
CmabServiceOptions cmabServiceOptions = new CmabServiceOptions(logger, cmabCache, cmabClient);
1997-
DefaultCmabService defaultCmabService = new DefaultCmabService(cmabServiceOptions);
1995+
DefaultCmabService defaultCmabService = new DefaultCmabService(cmabClient, cmabCache, logger);
19981996
this.cmabService = defaultCmabService;
19991997
return this;
20001998
}

core-api/src/main/java/com/optimizely/ab/cmab/service/CmabServiceOptions.java

Lines changed: 0 additions & 49 deletions
This file was deleted.

core-api/src/main/java/com/optimizely/ab/cmab/service/DefaultCmabService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public class DefaultCmabService implements CmabService {
3838
private final CmabClient cmabClient;
3939
private final Logger logger;
4040

41-
public DefaultCmabService(CmabServiceOptions options) {
42-
this.cmabCache = options.getCmabCache();
43-
this.cmabClient = options.getCmabClient();
44-
this.logger = options.getLogger();
41+
public DefaultCmabService(CmabClient cmabClient, DefaultLRUCache<CmabCacheValue> cmabCache, Logger logger) {
42+
this.cmabCache = cmabCache;
43+
this.cmabClient = cmabClient;
44+
this.logger = logger;
4545
}
4646

4747
@Override

core-api/src/test/java/com/optimizely/ab/cmab/DefaultCmabServiceTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import com.optimizely.ab.cmab.client.CmabClient;
4444
import com.optimizely.ab.cmab.service.CmabCacheValue;
4545
import com.optimizely.ab.cmab.service.CmabDecision;
46-
import com.optimizely.ab.cmab.service.CmabServiceOptions;
4746
import com.optimizely.ab.cmab.service.DefaultCmabService;
4847
import com.optimizely.ab.config.Attribute;
4948
import com.optimizely.ab.config.Cmab;
@@ -83,9 +82,7 @@ public DefaultCmabServiceTest() {
8382
@Before
8483
public void setUp() {
8584
MockitoAnnotations.initMocks(this);
86-
87-
CmabServiceOptions options = new CmabServiceOptions(mockLogger, mockCmabCache, mockCmabClient);
88-
cmabService = new DefaultCmabService(options);
85+
cmabService = new DefaultCmabService(mockCmabClient, mockCmabCache, mockLogger);
8986

9087
// Setup mock user context
9188
when(mockUserContext.getUserId()).thenReturn("user123");

0 commit comments

Comments
 (0)