|
57 | 57 | import org.junit.jupiter.api.Test; |
58 | 58 | import org.junit.jupiter.params.ParameterizedTest; |
59 | 59 | import org.junit.jupiter.params.provider.Arguments; |
| 60 | +import org.junit.jupiter.params.provider.CsvSource; |
60 | 61 | import org.junit.jupiter.params.provider.MethodSource; |
61 | 62 | import org.mockito.ArgumentCaptor; |
62 | 63 | import org.mockito.Mockito; |
@@ -1202,21 +1203,26 @@ private static FlagsmithClient localExperimentClient(EventProcessor processor) { |
1202 | 1203 | return client; |
1203 | 1204 | } |
1204 | 1205 |
|
1205 | | - @Test |
1206 | | - public void testGetExperimentFlagRecordsAnExposureWithLocalEvaluationWhenEnrolled() |
| 1206 | + @ParameterizedTest |
| 1207 | + @CsvSource({ |
| 1208 | + "user-1, new checkout, treatment", |
| 1209 | + "user-3, control, control" |
| 1210 | + }) |
| 1211 | + public void testGetExperimentFlagRecordsAnExposureWithLocalEvaluationWhenEnrolled( |
| 1212 | + String identifier, String expectedValue, String expectedVariant) |
1207 | 1213 | throws FlagsmithClientError { |
1208 | 1214 | EventProcessor processor = mock(EventProcessor.class); |
1209 | 1215 | FlagsmithClient client = localExperimentClient(processor); |
1210 | 1216 | Map<String, Object> traits = Collections.singletonMap("plan", "premium"); |
1211 | 1217 |
|
1212 | | - Flag flag = (Flag) client.getExperimentFlag("checkout", "user-1", traits); |
| 1218 | + Flag flag = (Flag) client.getExperimentFlag("checkout", identifier, traits); |
1213 | 1219 |
|
1214 | | - assertEquals("new checkout", flag.getValue()); |
1215 | | - assertEquals("treatment", flag.getVariant()); |
| 1220 | + assertEquals(expectedValue, flag.getValue()); |
| 1221 | + assertEquals(expectedVariant, flag.getVariant()); |
1216 | 1222 | assertEquals(42, flag.getExperiment().getId()); |
1217 | 1223 | assertEquals("Checkout experiment", flag.getExperiment().getName()); |
1218 | 1224 | assertEquals(Boolean.TRUE, flag.getExperiment().getInExperiment()); |
1219 | | - verify(processor).trackExposureEvent("checkout", "user-1", "treatment", traits, |
| 1225 | + verify(processor).trackExposureEvent("checkout", identifier, expectedVariant, traits, |
1220 | 1226 | Collections.singletonMap("experiment_id", 42)); |
1221 | 1227 | } |
1222 | 1228 |
|
|
0 commit comments