diff --git a/server/src/main/java/org/eclipse/openvsx/search/DatabaseSearchService.java b/server/src/main/java/org/eclipse/openvsx/search/DatabaseSearchService.java index 47d7d31e..579535c5 100644 --- a/server/src/main/java/org/eclipse/openvsx/search/DatabaseSearchService.java +++ b/server/src/main/java/org/eclipse/openvsx/search/DatabaseSearchService.java @@ -151,45 +151,41 @@ public SearchHits search(ISearchService.Options options) { return new SearchHitsImpl<>(totalHits, TotalHitsRelation.OFF, 0f, null, null, searchHits, null, null); } - /** - * Clear the cache when asked to update the search index. It could be done also - * through a cron job as well - */ @Override @CacheEvict(value = CACHE_DATABASE_SEARCH, allEntries = true) public void updateSearchIndex(boolean clear) { - + // The @CacheEvict annotation clears the cache when asked to update the search index } @Override @Async @CacheEvict(value = CACHE_DATABASE_SEARCH, allEntries = true) public void updateSearchEntriesAsync(List extensions) { - + // The @CacheEvict annotation clears the cache when asked to update search entries } @Override @CacheEvict(value = CACHE_DATABASE_SEARCH, allEntries = true) public void updateSearchEntries(List extensions) { - + // The @CacheEvict annotation clears the cache when asked to update search entries } @Override @CacheEvict(value = CACHE_DATABASE_SEARCH, allEntries = true) public void updateSearchEntry(Extension extension) { - + // The @CacheEvict annotation clears the cache when asked to update a search entry } @Override @CacheEvict(value = CACHE_DATABASE_SEARCH, allEntries = true) public void removeSearchEntries(Collection ids) { - + // The @CacheEvict annotation clears the cache when asked to removes search entries } @Override @CacheEvict(value = CACHE_DATABASE_SEARCH, allEntries = true) public void removeSearchEntry(Extension extension) { - + // The @CacheEvict annotation clears the cache when asked to remove a search entry } /** diff --git a/server/src/test/java/org/eclipse/openvsx/MockTransactionTemplate.java b/server/src/test/java/org/eclipse/openvsx/MockTransactionTemplate.java index 98f7f596..4be19619 100644 --- a/server/src/test/java/org/eclipse/openvsx/MockTransactionTemplate.java +++ b/server/src/test/java/org/eclipse/openvsx/MockTransactionTemplate.java @@ -24,6 +24,6 @@ public T execute(TransactionCallback action) throws TransactionException @Override public void afterPropertiesSet() { + // Method override to prevent IllegalArgumentException from being thrown } - } \ No newline at end of file diff --git a/server/src/test/java/org/eclipse/openvsx/adapter/VSCodeAPITest.java b/server/src/test/java/org/eclipse/openvsx/adapter/VSCodeAPITest.java index 02b3cc77..bdd74350 100644 --- a/server/src/test/java/org/eclipse/openvsx/adapter/VSCodeAPITest.java +++ b/server/src/test/java/org/eclipse/openvsx/adapter/VSCodeAPITest.java @@ -35,6 +35,7 @@ import org.eclipse.openvsx.util.VersionService; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; +import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; @@ -415,15 +416,7 @@ void testBrowseVsixManifest() throws Exception { .andExpect(request().asyncStarted()) .andDo(MvcResult::getAsyncResult) .andExpect(status().isOk()) - .andExpect(content().string(new BaseMatcher() { - @Override - public boolean matches(Object o) { - return ((String) o).startsWith("\n"); - } - - @Override - public void describeTo(Description description) {} - })) + .andExpect(content().string(Matchers.startsWith("\n"))) .andDo(result -> Files.delete(path)); } @@ -437,15 +430,7 @@ void testBrowseVsixManifestUniversal() throws Exception { .andExpect(request().asyncStarted()) .andDo(MvcResult::getAsyncResult) .andExpect(status().isOk()) - .andExpect(content().string(new BaseMatcher() { - @Override - public boolean matches(Object o) { - return ((String) o).startsWith("\n"); - } - - @Override - public void describeTo(Description description) {} - })) + .andExpect(content().string(Matchers.startsWith("\n"))) .andDo(result -> Files.delete(path)); } @@ -459,15 +444,7 @@ void testBrowseVsixManifestWindows() throws Exception { .andExpect(request().asyncStarted()) .andDo(MvcResult::getAsyncResult) .andExpect(status().isOk()) - .andExpect(content().string(new BaseMatcher() { - @Override - public boolean matches(Object o) { - return ((String) o).startsWith("\n"); - } - - @Override - public void describeTo(Description description) {} - })) + .andExpect(content().string(Matchers.startsWith("\n"))) .andDo(result -> Files.delete(path)); } @@ -507,23 +484,8 @@ void testBrowsePackageJson() throws Exception { .andExpect(request().asyncStarted()) .andDo(MvcResult::getAsyncResult) .andExpect(status().isOk()) - .andExpect(content().string(new BaseMatcher() { - @Override - public boolean matches(Object o) { - var mapper = new ObjectMapper(); - try { - var json = mapper.readTree((String) o); - return json.get("name").asText().equals(extensionName) - && json.get("publisher").asText().equals(namespaceName) - && json.get("version").asText().equals(version); - } catch (IOException e) { - return false; - } - } - - @Override - public void describeTo(Description description) {} - })) .andDo(result -> Files.delete(path)); + .andExpect(content().json("{\"name\":" + extensionName + ",\"publisher\":" + namespaceName + ",\"version\":" + version + "}")) + .andDo(result -> Files.delete(path)); } @Test