@@ -40,10 +40,10 @@ public void testCaching() {
4040 // Emulated search requests that an enrich processor could generate:
4141 // (two unique searches for two enrich policies)
4242 var projectId = randomProjectIdOrDefault ();
43- var cacheKey1 = new EnrichCache .CacheKey ("policy1-1" , projectId , "1" , 1 );
44- var cacheKey2 = new EnrichCache .CacheKey ("policy1-1" , projectId , "2" , 1 );
45- var cacheKey3 = new EnrichCache .CacheKey ("policy2-1" , projectId , "1" , 1 );
46- var cacheKey4 = new EnrichCache .CacheKey ("policy2-1" , projectId , "2" , 1 );
43+ var cacheKey1 = new EnrichCache .CacheKey (projectId , "policy1-1" , "1" , 1 );
44+ var cacheKey2 = new EnrichCache .CacheKey (projectId , "policy1-1" , "2" , 1 );
45+ var cacheKey3 = new EnrichCache .CacheKey (projectId , "policy2-1" , "1" , 1 );
46+ var cacheKey4 = new EnrichCache .CacheKey (projectId , "policy2-1" , "2" , 1 );
4747 // Emulated search response (content doesn't matter, since it isn't used, it just a cache entry)
4848 EnrichCache .CacheValue searchResponse = new EnrichCache .CacheValue (List .of (Map .of ("test" , "entry" )), 1L );
4949
@@ -77,10 +77,10 @@ public void testCaching() {
7777 assertThat (cacheStats .evictions (), equalTo (1L ));
7878 assertThat (cacheStats .cacheSizeInBytes (), equalTo (3L ));
7979
80- cacheKey1 = new EnrichCache .CacheKey ("policy1-2" , projectId , "1" , 1 );
81- cacheKey2 = new EnrichCache .CacheKey ("policy1-2" , projectId , "2" , 1 );
82- cacheKey3 = new EnrichCache .CacheKey ("policy2-2" , projectId , "1" , 1 );
83- cacheKey4 = new EnrichCache .CacheKey ("policy2-2" , projectId , "2" , 1 );
80+ cacheKey1 = new EnrichCache .CacheKey (projectId , "policy1-2" , "1" , 1 );
81+ cacheKey2 = new EnrichCache .CacheKey (projectId , "policy1-2" , "2" , 1 );
82+ cacheKey3 = new EnrichCache .CacheKey (projectId , "policy2-2" , "1" , 1 );
83+ cacheKey4 = new EnrichCache .CacheKey (projectId , "policy2-2" , "2" , 1 );
8484
8585 // Because enrich index has changed, cache can't serve cached entries
8686 assertThat (enrichCache .get (cacheKey1 ), nullValue ());
@@ -123,7 +123,7 @@ public void testComputeIfAbsent() throws InterruptedException {
123123 // Do initial computeIfAbsent, assert that it is a cache miss and the search is performed:
124124 CountDownLatch queriedDatabaseLatch = new CountDownLatch (1 );
125125 CountDownLatch notifiedOfResultLatch = new CountDownLatch (1 );
126- enrichCache .computeIfAbsent ("policy1-1" , projectId , "1" , 1 , (searchResponseActionListener ) -> {
126+ enrichCache .computeIfAbsent (projectId , "policy1-1" , "1" , 1 , (searchResponseActionListener ) -> {
127127 SearchResponse searchResponse = convertToSearchResponse (searchResponseMap );
128128 searchResponseActionListener .onResponse (searchResponse );
129129 searchResponse .decRef ();
@@ -146,7 +146,7 @@ public void testComputeIfAbsent() throws InterruptedException {
146146 {
147147 // Do the same call, assert that it is a cache hit and no search is performed:
148148 CountDownLatch notifiedOfResultLatch = new CountDownLatch (1 );
149- enrichCache .computeIfAbsent ("policy1-1" , projectId , "1" , 1 , (searchResponseActionListener ) -> {
149+ enrichCache .computeIfAbsent (projectId , "policy1-1" , "1" , 1 , (searchResponseActionListener ) -> {
150150 fail ("Expected no call to the database because item should have been in the cache" );
151151 }, assertNoFailureListener (r -> notifiedOfResultLatch .countDown ()));
152152 assertThat (notifiedOfResultLatch .await (5 , TimeUnit .SECONDS ), equalTo (true ));
@@ -163,7 +163,7 @@ public void testComputeIfAbsent() throws InterruptedException {
163163 // Do a computeIfAbsent with a different index, assert that it is a cache miss and the search is performed:
164164 CountDownLatch queriedDatabaseLatch = new CountDownLatch (1 );
165165 CountDownLatch notifiedOfResultLatch = new CountDownLatch (1 );
166- enrichCache .computeIfAbsent ("policy1-2" , projectId , "1" , 1 , (searchResponseActionListener ) -> {
166+ enrichCache .computeIfAbsent (projectId , "policy1-2" , "1" , 1 , (searchResponseActionListener ) -> {
167167 SearchResponse searchResponse = convertToSearchResponse (searchResponseMap );
168168 searchResponseActionListener .onResponse (searchResponse );
169169 searchResponse .decRef ();
@@ -182,7 +182,7 @@ public void testComputeIfAbsent() throws InterruptedException {
182182 // Do a computeIfAbsent with a different project, assert that it is a cache miss and the search is performed:
183183 CountDownLatch queriedDatabaseLatch = new CountDownLatch (1 );
184184 CountDownLatch notifiedOfResultLatch = new CountDownLatch (1 );
185- enrichCache .computeIfAbsent ("policy1-1" , randomUniqueProjectId () , "1" , 1 , (searchResponseActionListener ) -> {
185+ enrichCache .computeIfAbsent (randomUniqueProjectId (), "policy1-1" , "1" , 1 , (searchResponseActionListener ) -> {
186186 SearchResponse searchResponse = convertToSearchResponse (searchResponseMap );
187187 searchResponseActionListener .onResponse (searchResponse );
188188 searchResponse .decRef ();
@@ -201,7 +201,7 @@ public void testComputeIfAbsent() throws InterruptedException {
201201 // Do a computeIfAbsent with a different lookup value, assert that it is a cache miss and the search is performed:
202202 CountDownLatch queriedDatabaseLatch = new CountDownLatch (1 );
203203 CountDownLatch notifiedOfResultLatch = new CountDownLatch (1 );
204- enrichCache .computeIfAbsent ("policy1-1" , projectId , "2" , 1 , (searchResponseActionListener ) -> {
204+ enrichCache .computeIfAbsent (projectId , "policy1-1" , "2" , 1 , (searchResponseActionListener ) -> {
205205 SearchResponse searchResponse = convertToSearchResponse (searchResponseMap );
206206 searchResponseActionListener .onResponse (searchResponse );
207207 searchResponse .decRef ();
@@ -220,7 +220,7 @@ public void testComputeIfAbsent() throws InterruptedException {
220220 // Do a computeIfAbsent with a different max matches, assert that it is a cache miss and the search is performed:
221221 CountDownLatch queriedDatabaseLatch = new CountDownLatch (1 );
222222 CountDownLatch notifiedOfResultLatch = new CountDownLatch (1 );
223- enrichCache .computeIfAbsent ("policy1-1" , projectId , "1" , 3 , (searchResponseActionListener ) -> {
223+ enrichCache .computeIfAbsent (projectId , "policy1-1" , "1" , 3 , (searchResponseActionListener ) -> {
224224 SearchResponse searchResponse = convertToSearchResponse (searchResponseMap );
225225 searchResponseActionListener .onResponse (searchResponse );
226226 searchResponse .decRef ();
0 commit comments