Skip to content

Commit 5d0ebd3

Browse files
authored
do the rename (#26)
1 parent 55c3fce commit 5d0ebd3

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

src/main/java/cloud/eppo/EppoClient.java renamed to src/main/java/cloud/eppo/BaseEppoClient.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
import org.slf4j.Logger;
1818
import org.slf4j.LoggerFactory;
1919

20-
public class EppoClient {
21-
private static final Logger log = LoggerFactory.getLogger(EppoClient.class);
20+
public class BaseEppoClient {
21+
private static final Logger log = LoggerFactory.getLogger(BaseEppoClient.class);
2222
private final ObjectMapper mapper =
2323
new ObjectMapper()
2424
.registerModule(EppoModule.eppoModule()); // TODO: is this the best place for this?
@@ -34,14 +34,14 @@ public class EppoClient {
3434
private final boolean isConfigObfuscated;
3535
private boolean isGracefulMode;
3636

37-
private static EppoClient instance;
37+
private static BaseEppoClient instance;
3838

3939
// Fields useful for testing in situations where we want to mock the http client or configuration
4040
// store (accessed via reflection)
4141
/** @noinspection FieldMayBeFinal */
4242
private static EppoHttpClient httpClientOverride = null;
4343

44-
private EppoClient(
44+
private BaseEppoClient(
4545
String apiKey,
4646
String sdkName,
4747
String sdkVersion,
@@ -78,7 +78,7 @@ private EppoHttpClient buildHttpClient(
7878
return httpClient;
7979
}
8080

81-
public static EppoClient init(
81+
public static BaseEppoClient init(
8282
String apiKey,
8383
String sdkName,
8484
String sdkVersion,
@@ -100,7 +100,7 @@ public static EppoClient init(
100100
log.warn("Reinitializing an Eppo Client instance that was already initialized");
101101
}
102102
instance =
103-
new EppoClient(
103+
new BaseEppoClient(
104104
apiKey,
105105
sdkName,
106106
sdkVersion,
@@ -479,12 +479,12 @@ private <T> T throwIfNotGraceful(Exception e, T defaultValue) {
479479
throw new RuntimeException(e);
480480
}
481481

482-
public static EppoClient getInstance() {
483-
if (EppoClient.instance == null) {
482+
public static BaseEppoClient getInstance() {
483+
if (BaseEppoClient.instance == null) {
484484
throw new IllegalStateException("Eppo SDK has not been initialized");
485485
}
486486

487-
return EppoClient.instance;
487+
return BaseEppoClient.instance;
488488
}
489489

490490
public void setIsGracefulFailureMode(boolean isGracefulFailureMode) {
@@ -535,8 +535,8 @@ public Builder isGracefulMode(boolean isGracefulMode) {
535535
return this;
536536
}
537537

538-
public EppoClient buildAndInit() {
539-
return EppoClient.init(
538+
public BaseEppoClient buildAndInit() {
539+
return BaseEppoClient.init(
540540
apiKey, sdkName, sdkVersion, host, assignmentLogger, banditLogger, isGracefulMode);
541541
}
542542
}

src/test/java/cloud/eppo/EppoClientBanditTest.java renamed to src/test/java/cloud/eppo/BaseEppoClientBanditTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import org.slf4j.Logger;
2828
import org.slf4j.LoggerFactory;
2929

30-
public class EppoClientBanditTest {
31-
private static final Logger log = LoggerFactory.getLogger(EppoClientBanditTest.class);
30+
public class BaseEppoClientBanditTest {
31+
private static final Logger log = LoggerFactory.getLogger(BaseEppoClientBanditTest.class);
3232
private static final String DUMMY_BANDIT_API_KEY =
3333
"dummy-bandits-api-key"; // Will load bandit-flags-v1
3434
private static final String TEST_HOST =
@@ -44,7 +44,7 @@ public class EppoClientBanditTest {
4444
@BeforeAll
4545
public static void initClient() {
4646

47-
new EppoClient.Builder()
47+
new BaseEppoClient.Builder()
4848
.apiKey(DUMMY_BANDIT_API_KEY)
4949
.sdkName("java")
5050
.sdkVersion("3.0.0")
@@ -62,7 +62,7 @@ public void reset() {
6262
clearInvocations(mockAssignmentLogger);
6363
clearInvocations(mockBanditLogger);
6464
doNothing().when(mockBanditLogger).logBanditAssignment(any());
65-
EppoClient.getInstance().setIsGracefulFailureMode(false);
65+
BaseEppoClient.getInstance().setIsGracefulFailureMode(false);
6666
}
6767

6868
@ParameterizedTest
@@ -106,7 +106,7 @@ private void runBanditTestCase(BanditTestCase testCase) {
106106
ContextAttributes attributes = subjectAssignment.getSubjectAttributes();
107107
Actions actions = subjectAssignment.getActions();
108108
BanditResult assignment =
109-
EppoClient.getInstance()
109+
BaseEppoClient.getInstance()
110110
.getBanditAction(flagKey, subjectKey, attributes, actions, defaultValue);
111111
assertBanditAssignment(flagKey, subjectAssignment, assignment);
112112
}
@@ -165,7 +165,7 @@ public void testBanditLogsAction() {
165165
actions.put("reebok", rebookAttributes);
166166

167167
BanditResult banditResult =
168-
EppoClient.getInstance()
168+
BaseEppoClient.getInstance()
169169
.getBanditAction(flagKey, subjectKey, subjectAttributes, actions, "control");
170170

171171
// Verify assignment
@@ -239,7 +239,7 @@ public void testNoBanditLogsWhenNotBandit() {
239239
actions.put("adidas", new Attributes());
240240

241241
BanditResult banditResult =
242-
EppoClient.getInstance()
242+
BaseEppoClient.getInstance()
243243
.getBanditAction(flagKey, subjectKey, subjectAttributes, actions, "default");
244244

245245
// Verify assignment
@@ -267,7 +267,7 @@ public void testNoBanditLogsWhenNoActions() {
267267
BanditActions actions = new BanditActions();
268268

269269
BanditResult banditResult =
270-
EppoClient.getInstance()
270+
BaseEppoClient.getInstance()
271271
.getBanditAction(flagKey, subjectKey, subjectAttributes, actions, "control");
272272

273273
// Verify assignment
@@ -286,7 +286,7 @@ public void testNoBanditLogsWhenNoActions() {
286286

287287
@Test
288288
public void testBanditErrorGracefulModeOff() {
289-
EppoClient.getInstance()
289+
BaseEppoClient.getInstance()
290290
.setIsGracefulFailureMode(
291291
false); // Should be set by @BeforeEach but repeated here for test clarity
292292
try (MockedStatic<BanditEvaluator> mockedStatic = mockStatic(BanditEvaluator.class)) {
@@ -302,15 +302,15 @@ public void testBanditErrorGracefulModeOff() {
302302
assertThrows(
303303
RuntimeException.class,
304304
() ->
305-
EppoClient.getInstance()
305+
BaseEppoClient.getInstance()
306306
.getBanditAction(
307307
"banner_bandit_flag", "subject", new Attributes(), actions, "default"));
308308
}
309309
}
310310

311311
@Test
312312
public void testBanditErrorGracefulModeOn() {
313-
EppoClient.getInstance().setIsGracefulFailureMode(true);
313+
BaseEppoClient.getInstance().setIsGracefulFailureMode(true);
314314
try (MockedStatic<BanditEvaluator> mockedStatic = mockStatic(BanditEvaluator.class)) {
315315
// Configure the mock to throw an exception
316316
mockedStatic
@@ -322,7 +322,7 @@ public void testBanditErrorGracefulModeOn() {
322322
actions.put("nike", new Attributes());
323323
actions.put("adidas", new Attributes());
324324
BanditResult banditResult =
325-
EppoClient.getInstance()
325+
BaseEppoClient.getInstance()
326326
.getBanditAction(
327327
"banner_bandit_flag", "subject", new Attributes(), actions, "default");
328328
assertEquals("banner_bandit", banditResult.getVariation());
@@ -341,7 +341,7 @@ public void testBanditLogErrorNonFatal() {
341341
actions.put("nike", new Attributes());
342342
actions.put("adidas", new Attributes());
343343
BanditResult banditResult =
344-
EppoClient.getInstance()
344+
BaseEppoClient.getInstance()
345345
.getBanditAction("banner_bandit_flag", "subject", new Attributes(), actions, "default");
346346
assertEquals("banner_bandit", banditResult.getVariation());
347347
assertEquals("nike", banditResult.getAction());

src/test/java/cloud/eppo/EppoClientTest.java renamed to src/test/java/cloud/eppo/BaseEppoClientTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
import org.slf4j.Logger;
4040
import org.slf4j.LoggerFactory;
4141

42-
public class EppoClientTest {
43-
private static final Logger log = LoggerFactory.getLogger(EppoClientTest.class);
42+
public class BaseEppoClientTest {
43+
private static final Logger log = LoggerFactory.getLogger(BaseEppoClientTest.class);
4444
private static final String DUMMY_FLAG_API_KEY = "dummy-flags-api-key"; // Will load flags-v1
4545
private static final String TEST_HOST =
4646
"https://us-central1-eppo-qa.cloudfunctions.net/serveGitHubRacTestFile";
@@ -58,7 +58,7 @@ private void initClient(
5858
String host, boolean isGracefulMode, boolean isConfigObfuscated, String apiKey) {
5959
mockAssignmentLogger = mock(AssignmentLogger.class);
6060

61-
new EppoClient.Builder()
61+
new BaseEppoClient.Builder()
6262
.apiKey(apiKey)
6363
.sdkName(isConfigObfuscated ? "android" : "java")
6464
.sdkVersion("3.0.0")
@@ -118,7 +118,7 @@ private AssignmentTestCase parseTestCaseFile(File testCaseFile) {
118118
private void runTestCase(AssignmentTestCase testCase) {
119119
String flagKey = testCase.getFlag();
120120
TestCaseValue defaultValue = testCase.getDefaultValue();
121-
EppoClient eppoClient = EppoClient.getInstance();
121+
BaseEppoClient eppoClient = BaseEppoClient.getInstance();
122122
assertFalse(testCase.getSubjects().isEmpty());
123123

124124
for (SubjectAssignment subjectAssignment : testCase.getSubjects()) {
@@ -222,8 +222,8 @@ private <T> void assertAssignment(
222222
public void testErrorGracefulModeOn() throws JsonProcessingException {
223223
initClient(TEST_HOST, true, false, DUMMY_FLAG_API_KEY);
224224

225-
EppoClient realClient = EppoClient.getInstance();
226-
EppoClient spyClient = spy(realClient);
225+
BaseEppoClient realClient = BaseEppoClient.getInstance();
226+
BaseEppoClient spyClient = spy(realClient);
227227
doThrow(new RuntimeException("Exception thrown by mock"))
228228
.when(spyClient)
229229
.getTypedAssignment(
@@ -271,8 +271,8 @@ public void testErrorGracefulModeOn() throws JsonProcessingException {
271271
public void testErrorGracefulModeOff() {
272272
initClient(TEST_HOST, false, false, DUMMY_FLAG_API_KEY);
273273

274-
EppoClient realClient = EppoClient.getInstance();
275-
EppoClient spyClient = spy(realClient);
274+
BaseEppoClient realClient = BaseEppoClient.getInstance();
275+
BaseEppoClient spyClient = spy(realClient);
276276
doThrow(new RuntimeException("Exception thrown by mock"))
277277
.when(spyClient)
278278
.getTypedAssignment(
@@ -330,7 +330,7 @@ public void testInvalidConfigJSON() {
330330
initClient(TEST_HOST, false, false, DUMMY_FLAG_API_KEY);
331331

332332
String result =
333-
EppoClient.getInstance()
333+
BaseEppoClient.getInstance()
334334
.getStringAssignment("dummy subject", "dummy flag", "not-populated");
335335
assertEquals("not-populated", result);
336336
}
@@ -343,7 +343,7 @@ public void testAssignmentEventCorrectlyCreated() {
343343
subjectAttributes.put("age", EppoValue.valueOf(30));
344344
subjectAttributes.put("employer", EppoValue.valueOf("Eppo"));
345345
double assignment =
346-
EppoClient.getInstance()
346+
BaseEppoClient.getInstance()
347347
.getDoubleAssignment("numeric_flag", "alice", subjectAttributes, 0.0);
348348

349349
assertEquals(3.1415926, assignment, 0.0000001);
@@ -381,7 +381,7 @@ public void testAssignmentLogErrorNonFatal() {
381381
.when(mockAssignmentLogger)
382382
.logAssignment(any());
383383
double assignment =
384-
EppoClient.getInstance()
384+
BaseEppoClient.getInstance()
385385
.getDoubleAssignment("numeric_flag", "alice", new Attributes(), 0.0);
386386

387387
assertEquals(3.1415926, assignment, 0.0000001);
@@ -431,7 +431,7 @@ private void setConfigurationStoreOverrideField(ConfigurationStore configuration
431431
/** Uses reflection to set a static override field used for tests (e.g., httpClientOverride) */
432432
private <T> void setOverrideField(String fieldName, T override) {
433433
try {
434-
Field httpClientOverrideField = EppoClient.class.getDeclaredField(fieldName);
434+
Field httpClientOverrideField = BaseEppoClient.class.getDeclaredField(fieldName);
435435
httpClientOverrideField.setAccessible(true);
436436
httpClientOverrideField.set(null, override);
437437
httpClientOverrideField.setAccessible(false);

0 commit comments

Comments
 (0)