|
1 | 1 | package dev.openfeature.javasdk;
|
2 | 2 |
|
3 |
| -import org.junit.jupiter.api.Disabled; |
4 |
| -import org.junit.jupiter.api.Test; |
| 3 | +import org.junit.jupiter.api.*; |
| 4 | +import org.slf4j.*; |
| 5 | +import uk.org.lidalia.slf4jtest.*; |
5 | 6 |
|
6 | 7 | import java.util.List;
|
7 | 8 |
|
| 9 | +import static org.assertj.core.api.Assertions.assertThat; |
8 | 10 | import static org.junit.jupiter.api.Assertions.*;
|
9 | 11 | import static org.mockito.Mockito.*;
|
10 | 12 |
|
11 |
| -public class FlagEvaluationSpecTests { |
| 13 | +class FlagEvaluationSpecTests { |
12 | 14 |
|
13 |
| - Client _client() { |
| 15 | + private static final TestLogger TEST_LOGGER = TestLoggerFactory.getTestLogger(OpenFeatureClient.class); |
| 16 | + |
| 17 | + private Client _client() { |
14 | 18 | OpenFeatureAPI api = OpenFeatureAPI.getInstance();
|
15 | 19 | api.setProvider(new NoOpProvider());
|
16 | 20 | return api.getClient();
|
@@ -160,10 +164,16 @@ Client _client() {
|
160 | 164 | FlagEvaluationDetails<Boolean> details = c.getBooleanDetails("key", false);
|
161 | 165 | assertEquals("BORK", details.getErrorCode());
|
162 | 166 | }
|
| 167 | + |
163 | 168 | @Specification(number="1.4.10", text="In the case of abnormal execution, the client SHOULD log an informative error message.")
|
164 |
| - @Disabled("Not actually sure how to mock out the slf4j logger") |
165 | 169 | @Test void log_on_error() throws NotImplementedException {
|
166 |
| - throw new NotImplementedException("Dunno."); |
| 170 | + TEST_LOGGER.clear(); |
| 171 | + OpenFeatureAPI api = OpenFeatureAPI.getInstance(); |
| 172 | + api.setProvider(new AlwaysBrokenProvider()); |
| 173 | + Client c = api.getClient(); |
| 174 | + FlagEvaluationDetails<Boolean> result = c.getBooleanDetails("test", false); |
| 175 | + assertEquals(Reason.ERROR, result.getReason()); |
| 176 | + assertThat(TEST_LOGGER.getLoggingEvents()).contains(LoggingEvent.error("Unable to correctly evaluate flag with key {} due to exception {}", "test", "BORK")); |
167 | 177 | }
|
168 | 178 |
|
169 | 179 |
|
|
0 commit comments