diff --git a/search-service-image-v1/pom.xml b/search-service-image-v1/pom.xml
index c5b40e7..a06d541 100644
--- a/search-service-image-v1/pom.xml
+++ b/search-service-image-v1/pom.xml
@@ -5,7 +5,7 @@
com.iqser.red
platform-docker-dependency
- 1.1.0
+ 1.2.0
4.0.0
@@ -42,7 +42,7 @@
docker-maven-plugin
-
+
@@ -95,4 +95,4 @@
-
\ No newline at end of file
+
diff --git a/search-service-v1/pom.xml b/search-service-v1/pom.xml
index bbea446..1d03e9f 100644
--- a/search-service-v1/pom.xml
+++ b/search-service-v1/pom.xml
@@ -44,7 +44,7 @@
org.sonarsource.scanner.maven
sonar-maven-plugin
3.9.0.2155
-
+
org.owasp
dependency-check-maven
diff --git a/search-service-v1/search-service-api-v1/src/main/java/com/iqser/red/service/search/v1/model/MatchedDocument.java b/search-service-v1/search-service-api-v1/src/main/java/com/iqser/red/service/search/v1/model/MatchedDocument.java
index 6849d7a..cebed22 100644
--- a/search-service-v1/search-service-api-v1/src/main/java/com/iqser/red/service/search/v1/model/MatchedDocument.java
+++ b/search-service-v1/search-service-api-v1/src/main/java/com/iqser/red/service/search/v1/model/MatchedDocument.java
@@ -27,6 +27,9 @@ public class MatchedDocument {
private String assignee;
private Map fileAttributes;
private String workflowStatus;
+ private boolean dossierDeleted;
+ private boolean dossierArchived;
+ private String fileName;
@Builder.Default
private Map> highlights = new HashMap<>();
diff --git a/search-service-v1/search-service-server-v1/pom.xml b/search-service-v1/search-service-server-v1/pom.xml
index a7ccc6f..11fc42a 100644
--- a/search-service-v1/search-service-server-v1/pom.xml
+++ b/search-service-v1/search-service-server-v1/pom.xml
@@ -78,7 +78,7 @@
org.testcontainers
elasticsearch
- 1.15.3
+ 1.16.3
test
diff --git a/search-service-v1/search-service-server-v1/src/main/java/com/iqser/red/service/search/v1/server/service/SearchService.java b/search-service-v1/search-service-server-v1/src/main/java/com/iqser/red/service/search/v1/server/service/SearchService.java
index d0022f7..1174ca8 100644
--- a/search-service-v1/search-service-server-v1/src/main/java/com/iqser/red/service/search/v1/server/service/SearchService.java
+++ b/search-service-v1/search-service-server-v1/src/main/java/com/iqser/red/service/search/v1/server/service/SearchService.java
@@ -62,7 +62,8 @@ public class SearchService {
includeDeletedDossiers, includeArchivedDossiers, workflowStatus, fileAttributes, returnSections))
.from(getPageOrDefault(page) * getPageSizeOrDefault(pageSize))
.size(getPageSizeOrDefault(pageSize))
- .fetchSource(new String[]{"dossierId", "dossierTemplateId", "fileId", "assignee", "dossierStatus", "workflowStatus", "fileAttributes"}, new String[]{"sections"})
+ .fetchSource(new String[]{"dossierId", "dossierTemplateId", "dossierDeleted", "dossierArchived", "filename",
+ "fileId", "assignee", "dossierStatus", "workflowStatus", "fileAttributes"}, new String[]{"sections"})
.highlighter(new HighlightBuilder().field("sections.text").field("filename").field("fileAttributes.value").highlighterType("fvh"))
.trackScores(true);
@@ -233,10 +234,13 @@ public class SearchService {
.assignee((String) hit.getSourceAsMap().get("assignee"))
.fileAttributes(convertFileAttributes(hit.getSourceAsMap().get("fileAttributes")))
.workflowStatus((String) hit.getSourceAsMap().get("workflowStatus"))
+ .fileName((String) hit.getSourceAsMap().get("fileName"))
+ .dossierDeleted((Boolean) hit.getSourceAsMap().get("dossierDeleted"))
+ .dossierArchived((Boolean) hit.getSourceAsMap().get("dossierArchived"))
.highlights(hit.getHighlightFields()
.entrySet()
.stream()
- .collect(Collectors.toMap(e -> e.getKey(), e -> Arrays.stream(e.getValue().getFragments())
+ .collect(Collectors.toMap(Map.Entry::getKey, e -> Arrays.stream(e.getValue().getFragments())
.map(Text::string)
.collect(Collectors.toSet()))))
.matchedTerms(matchesTerms)
diff --git a/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/AbstractElasticsearchIntegrationTest.java b/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/AbstractElasticsearchIntegrationTest.java
index 0a33c17..cea9a24 100644
--- a/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/AbstractElasticsearchIntegrationTest.java
+++ b/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/AbstractElasticsearchIntegrationTest.java
@@ -1,37 +1,61 @@
package com.iqser.red.service.search.v1.server.service;
-import java.time.Duration;
-
-import org.assertj.core.util.Lists;
-import org.junit.ClassRule;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
-import org.springframework.boot.test.mock.mockito.MockBean;
-import org.springframework.cloud.openfeign.EnableFeignClients;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-import org.springframework.context.annotation.Primary;
-import org.springframework.test.annotation.DirtiesContext;
-import org.testcontainers.elasticsearch.ElasticsearchContainer;
-import org.testcontainers.utility.DockerImageName;
-
import com.amazonaws.services.s3.AmazonS3;
import com.iqser.red.service.search.v1.server.Application;
import com.iqser.red.service.search.v1.server.client.ElasticsearchClient;
import com.iqser.red.service.search.v1.server.settings.ElasticsearchSettings;
import com.iqser.red.storage.commons.StorageAutoConfiguration;
import com.iqser.red.storage.commons.service.StorageService;
+import org.junit.ClassRule;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.boot.test.util.TestPropertyValues;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.ApplicationContextInitializer;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.testcontainers.elasticsearch.ElasticsearchContainer;
+import org.testcontainers.utility.DockerImageName;
+
+@ComponentScan
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,
+ properties = {AbstractElasticsearchIntegrationTest.WAIT_FOR_WRITE_REQUESTS})
+@ContextConfiguration(initializers = {AbstractElasticsearchIntegrationTest.Initializer.class})
+@EnableFeignClients(basePackageClasses = AbstractElasticsearchIntegrationTest.TestConfiguration.class)
@DirtiesContext
-public class AbstractElasticsearchIntegrationTest {
+public abstract class AbstractElasticsearchIntegrationTest {
public static final String WAIT_FOR_WRITE_REQUESTS = "elasticsearch.refreshPolicy=IMMEDIATE";
- @ClassRule
- public static ElasticsearchContainer elasticsearchContainer = new ElasticsearchContainer(DockerImageName.parse("nexus.iqser.com:5001/bitnami/elasticsearch:7.13.2-debian-10-r1").asCompatibleSubstituteFor("docker.elastic.co/elasticsearch/elasticsearch"));
+ static class Initializer implements ApplicationContextInitializer {
+ public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
+
+ var esContainer = new ElasticsearchContainer(DockerImageName.parse("elasticsearch:7.17.2").asCompatibleSubstituteFor("docker.elastic.co/elasticsearch/elasticsearch"));
+ esContainer.start();
+
+ String esHost = esContainer.getHttpHostAddress();
+// String host = esHost.substring(0, esHost.indexOf(':'));
+ int port = Integer.parseInt(esHost.substring(esHost.indexOf(':') + 1));
+
+ TestPropertyValues.of(
+// "elasticsearch.cluster.hosts[0]=" + host,
+ "elasticsearch.port=" + port
+ ).applyTo(configurableApplicationContext.getEnvironment());
+ }
+ }
@Autowired
private IndexCreatorService indexCreationService;
@@ -39,27 +63,10 @@ public class AbstractElasticsearchIntegrationTest {
@Autowired
private StorageService storageService;
- @MockBean
- private AmazonS3 amazonS3;
-
@Configuration
- @EnableAutoConfiguration(exclude = {RabbitAutoConfiguration.class, StorageAutoConfiguration.class})
- @Import(Application.class)
- @EnableFeignClients(basePackageClasses = TestConfiguration.class)
+ @EnableAutoConfiguration(exclude = {StorageAutoConfiguration.class, RabbitAutoConfiguration.class})
public static class TestConfiguration {
- @Bean
- public ElasticsearchClient elasticsearchClient() {
-
- ElasticsearchSettings elasticsearchSettings = new ElasticsearchSettings();
- String host = elasticsearchContainer.getHttpHostAddress();
- elasticsearchSettings.setHosts(Lists.newArrayList(host.substring(0, host.indexOf(':'))));
- elasticsearchSettings.setPort(Integer.parseInt(host.substring(host.indexOf(':') + 1)));
-
- return new ElasticsearchClient(elasticsearchSettings);
- }
-
-
@Bean
public IndexCreatorService indexCreationService(ElasticsearchClient elasticsearchClient,
ElasticsearchSettings elasticsearchSettings) {
@@ -77,4 +84,4 @@ public class AbstractElasticsearchIntegrationTest {
}
-}
\ No newline at end of file
+}
diff --git a/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/FileSystemBackedStorageService.java b/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/FileSystemBackedStorageService.java
index df5a0a2..79a2522 100644
--- a/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/FileSystemBackedStorageService.java
+++ b/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/FileSystemBackedStorageService.java
@@ -3,9 +3,11 @@ package com.iqser.red.service.search.v1.server.service;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
+import com.iqser.red.storage.commons.service.StorageService;
import org.apache.commons.io.IOUtils;
import org.springframework.core.io.InputStreamResource;
@@ -14,12 +16,11 @@ import com.iqser.red.storage.commons.service.S3StorageService;
import lombok.SneakyThrows;
-public class FileSystemBackedStorageService extends S3StorageService {
+public class FileSystemBackedStorageService implements StorageService {
private final Map dataMap = new HashMap<>();
public FileSystemBackedStorageService() {
- super(null, null);
}
@SneakyThrows
@@ -34,6 +35,21 @@ public class FileSystemBackedStorageService extends S3StorageService {
}
+ @Override
+ public void deleteObject(String objectId) {
+ dataMap.remove(objectId);
+ }
+
+ @Override
+ public boolean objectExists(String objectId) {
+ return dataMap.containsKey(objectId);
+ }
+
+ @Override
+ public void init() {
+
+ }
+
@SneakyThrows
@Override
public void storeObject(String objectId, byte[] data) {
@@ -44,6 +60,11 @@ public class FileSystemBackedStorageService extends S3StorageService {
dataMap.put(objectId, tempFile);
}
+ @Override
+ public void storeObject(String objectId, InputStream stream) {
+
+ }
+
public void clearStorage() {
this.dataMap.forEach((k, v) -> {
v.delete();
diff --git a/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/IndexTest.java b/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/IndexTest.java
index 1b2e6fa..4e1e171 100644
--- a/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/IndexTest.java
+++ b/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/IndexTest.java
@@ -17,8 +17,6 @@ import com.iqser.red.service.search.v1.server.queue.IndexingMessageReceiver;
import lombok.SneakyThrows;
-@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, properties = {AbstractElasticsearchIntegrationTest.WAIT_FOR_WRITE_REQUESTS})
public class IndexTest extends AbstractElasticsearchIntegrationTest {
@Autowired
diff --git a/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/SearchTest.java b/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/SearchTest.java
index e5606ad..0e0ca85 100644
--- a/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/SearchTest.java
+++ b/search-service-v1/search-service-server-v1/src/test/java/com/iqser/red/service/search/v1/server/service/SearchTest.java
@@ -29,8 +29,6 @@ import com.iqser.red.service.search.v1.server.model.Text;
import lombok.SneakyThrows;
-@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, properties = {AbstractElasticsearchIntegrationTest.WAIT_FOR_WRITE_REQUESTS})
public class SearchTest extends AbstractElasticsearchIntegrationTest {
@Autowired
diff --git a/search-service-v1/search-service-server-v1/src/test/resources/application.yml b/search-service-v1/search-service-server-v1/src/test/resources/application.yml
index 0d75cd7..ed0f0fa 100644
--- a/search-service-v1/search-service-server-v1/src/test/resources/application.yml
+++ b/search-service-v1/search-service-server-v1/src/test/resources/application.yml
@@ -14,4 +14,7 @@ storage:
bucket-name: 'redaction'
region: 'us-east-1'
endpoint: 'https://s3.amazonaws.com'
- backend: 's3'
\ No newline at end of file
+ backend: 's3'
+elasticsearch:
+ hosts:
+ - 'localhost'
diff --git a/search-service-v1/search-service-server-v1/src/test/resources/bootstrap.yml b/search-service-v1/search-service-server-v1/src/test/resources/bootstrap.yml
deleted file mode 100644
index 56e5ad2..0000000
--- a/search-service-v1/search-service-server-v1/src/test/resources/bootstrap.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-spring:
- application:
- name: search-service-v1