11package com .flagsmith ;
22
3+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4+ import static org .junit .jupiter .api .Assertions .assertThrows ;
35import static org .mockito .ArgumentMatchers .any ;
46import static org .mockito .ArgumentMatchers .anyBoolean ;
57import static org .mockito .ArgumentMatchers .anyString ;
68import static org .mockito .Mockito .mock ;
79import static org .mockito .Mockito .times ;
810import static org .mockito .Mockito .verify ;
911import static org .mockito .Mockito .when ;
10- import static org .testng .Assert .*;
1112
1213import com .fasterxml .jackson .databind .node .ObjectNode ;
1314import com .flagsmith .config .FlagsmithCacheConfig ;
2829import okhttp3 .Request ;
2930import okhttp3 .RequestBody ;
3031import okhttp3 .mock .MockInterceptor ;
32+ import org .junit .jupiter .api .Test ;
33+ import org .junit .jupiter .api .BeforeEach ;
3134import org .mockito .ArgumentCaptor ;
32- import org .testng .annotations .BeforeMethod ;
33- import org .testng .annotations .Test ;
3435
35- @ Test ( groups = "unit" )
36+
3637public class FlagsmithApiWrapperCachingTest {
3738 private final String API_KEY = "OUR_API_KEY" ;
3839 private final String BASE_URL = "https://unit-test.com" ;
@@ -45,7 +46,7 @@ public class FlagsmithApiWrapperCachingTest {
4546 private MockInterceptor interceptor ;
4647 private RequestProcessor requestProcessor ;
4748
48- @ BeforeMethod ( groups = "unit" )
49+ @ BeforeEach
4950 public void init () {
5051 flagsmithCacheImpl = mock (FlagsmithCacheConfig .FlagsmithCacheImpl .class );
5152
@@ -64,13 +65,13 @@ public void init() {
6465 flagsmithAPIWrapper .setRequestor (requestProcessor );
6566 }
6667
67- @ Test ( groups = "unit" )
68+ @ Test
6869 public void getCache_returnsInternalCache () {
6970 final FlagsmithCache actualInternalCache = flagsmithAPIWrapper .getCache ();
7071 assertEquals (flagsmithCacheImpl , actualInternalCache );
7172 }
7273
73- @ Test ( groups = "unit" )
74+ @ Test
7475 public void getFeatureFlags_envFlags_cacheEnabled_dontFetchFlagsWhenInCache () {
7576 // Arrange
7677 final String cacheKey = "cacheKey" ;
@@ -89,7 +90,7 @@ public void getFeatureFlags_envFlags_cacheEnabled_dontFetchFlagsWhenInCache() {
8990 assertEquals (flagsAndTraits , actualFeatureFlags );
9091 }
9192
92- @ Test ( groups = "unit" )
93+ @ Test
9394 public void getFeatureFlags_fetchFlagsFromFlagsmithAndStoreThemInCache () {
9495 final String cacheKey = "cacheKey" ;
9596 when (flagsmithCacheImpl .getEnvFlagsCacheKey ()).thenReturn (cacheKey );
@@ -110,7 +111,7 @@ public void getFeatureFlags_fetchFlagsFromFlagsmithAndStoreThemInCache() {
110111 assertEquals (1 , cache .estimatedSize ());
111112 }
112113
113- @ Test ( groups = "unit" )
114+ @ Test
114115 public void getFeatureFlags_fetchFlagsFromCacheAndNotFromFlagsmith () {
115116 // Arrange
116117 final String cacheKey = "cacheKey" ;
@@ -127,7 +128,7 @@ public void getFeatureFlags_fetchFlagsFromCacheAndNotFromFlagsmith() {
127128 assertEquals (newFlagsList (flagsAndTraits ), actualFeatureFlags );
128129 }
129130
130- @ Test ( groups = "unit" )
131+ @ Test
131132 public void identifyUserWithTraits_nullUser () {
132133 // Act
133134 assertThrows (IllegalArgumentException .class ,
@@ -138,7 +139,7 @@ public void identifyUserWithTraits_nullUser() {
138139 assertEquals (0 , cache .estimatedSize ());
139140 }
140141
141- @ Test ( groups = "unit" )
142+ @ Test
142143 public void identifyUserWithTraits_nullUserIdentifier () {
143144 // Act
144145 assertThrows (IllegalArgumentException .class ,
@@ -149,7 +150,7 @@ public void identifyUserWithTraits_nullUserIdentifier() {
149150 assertEquals (0 , cache .estimatedSize ());
150151 }
151152
152- @ Test ( groups = "unit" )
153+ @ Test
153154 public void identifyUserWithTraits_fetchFlagsFromFlagsmithAndStoreThemInCache_whenCacheEmpty () {
154155 // Arrange
155156 String identifier = "test-user" ;
@@ -169,7 +170,7 @@ public void identifyUserWithTraits_fetchFlagsFromFlagsmithAndStoreThemInCache_wh
169170 assertEquals (newFlagsList (new ArrayList <>()), actualUserFlagsAndTraits );
170171 }
171172
172- @ Test ( groups = "unit" )
173+ @ Test
173174 public void testGetFeatureFlags_ReturnsFeatureFlagsFromApi_IfCacheButNoEnvCacheKey () {
174175 // Given
175176 when (flagsmithCacheImpl .getEnvFlagsCacheKey ()).thenReturn (null );
@@ -185,7 +186,7 @@ public void testGetFeatureFlags_ReturnsFeatureFlagsFromApi_IfCacheButNoEnvCacheK
185186 assertEquals (flags , Flags .fromFeatureStateModels (featureStateModels , null ));
186187 }
187188
188- @ Test ( groups = "unit" )
189+ @ Test
189190 public void verifyRequestBody () {
190191 String identifier = "test-user" ;
191192 final ArrayList <TraitModel > traits = new ArrayList <>();
0 commit comments