Skip to content
Snippets Groups Projects

Elastic search EOL version upgrade

Closed Harshika Dhoot requested to merge es-version into azure/m18-master
1 file
+ 1
0
Compare changes
  • Side-by-side
  • Inline
@@ -38,9 +38,8 @@ import org.apache.http.StatusLine;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.IndicesClient;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.PutMappingRequest;
import org.junit.Assert;
import org.junit.Before;
@@ -71,10 +70,6 @@ public class IndexerMappingServiceTest {
private final String validMapping = "{\"dynamic\":false,\"properties\":{\"data\":{\"properties\":{\"Msg\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"null_value\":\"null\",\"ignore_above\":256,\"type\":\"keyword\"}}},\"Intervals\":{\"properties\":{\"StopMarkerID\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"null_value\":\"null\",\"ignore_above\":256,\"type\":\"keyword\"}}},\"GeologicUnitInterpretationIDs\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"null_value\":\"null\",\"ignore_above\":256,\"type\":\"keyword\"}}},\"StopMeasuredDepth\":{\"type\":\"double\"}}},\"Location\":{\"type\":\"geo_point\"}}},\"authority\":{\"type\":\"constant_keyword\",\"value\":\"tenant\"},\"id\":{\"type\":\"keyword\"},\"acl\":{\"properties\":{\"viewers\":{\"type\":\"keyword\"},\"owners\":{\"type\":\"keyword\"}}}}}";
private final String emptyDataValidMapping = "{\"dynamic\":false,\"properties\":{\"id\":{\"type\":\"keyword\"},\"acl\":{\"properties\":{\"viewers\":{\"type\":\"keyword\"},\"owners\":{\"type\":\"keyword\"}}},\"authority\":{\"type\":\"constant_keyword\",\"value\":\"tenant\"}}}";
@Mock
private RestClient restClient;
@Mock
private Response response;
@Mock
private StatusLine statusLine;
@Mock
@@ -106,9 +101,7 @@ public class IndexerMappingServiceTest {
this.restHighLevelClient = PowerMockito.mock(RestHighLevelClient.class);
when(this.elasticIndexNameResolver.getIndexNameFromKind(kind)).thenReturn(index);
when(this.restHighLevelClient.getLowLevelClient()).thenReturn(restClient);
when(this.restClient.performRequest(any())).thenReturn(response);
when(this.response.getStatusLine()).thenReturn(statusLine);
when(this.restHighLevelClient.indices()).thenReturn(indicesClient);
when(this.statusLine.getStatusCode()).thenReturn(200);
}
@@ -135,7 +128,8 @@ public class IndexerMappingServiceTest {
}
@Test
public void should_returnValidMapping_givenFalseMerge_createMappingTest() {
public void should_returnValidMapping_givenFalseMerge_createMappingTest() throws IOException {
when(this.indicesClient.exists((GetIndexRequest) any(),any())).thenReturn(true);
try {
String mapping = this.sut.createMapping(restHighLevelClient, indexSchema, index, false);
assertEquals(validMapping, mapping);
@@ -147,7 +141,7 @@ public class IndexerMappingServiceTest {
@Test
public void should_returnValidMapping_givenTrueMerge_createMappingTest() {
try {
AcknowledgedResponse mappingResponse = new AcknowledgedResponse(true);
AcknowledgedResponse mappingResponse = AcknowledgedResponse.TRUE;
doReturn(this.indicesClient).when(this.restHighLevelClient).indices();
doReturn(mappingResponse).when(this.indicesClient).putMapping(any(PutMappingRequest.class), any(RequestOptions.class));
@@ -161,12 +155,12 @@ public class IndexerMappingServiceTest {
@Test
public void should_returnValidMapping_givenExistType_createMappingTest() {
try {
AcknowledgedResponse mappingResponse = new AcknowledgedResponse(true);
AcknowledgedResponse mappingResponse = AcknowledgedResponse.TRUE;
doReturn(this.indicesClient).when(this.restHighLevelClient).indices();
doReturn(mappingResponse).when(this.indicesClient).putMapping(any(PutMappingRequest.class), any(RequestOptions.class));
IndexerMappingServiceImpl indexerMappingServiceLocal = spy(new IndexerMappingServiceImpl());
doReturn(false).when(indexerMappingServiceLocal).isTypeExist(any(), any(), any());
doReturn(false).when(indexerMappingServiceLocal).isTypeExist(any(), any());
String mapping = this.sut.createMapping(this.restHighLevelClient, this.indexSchema, this.index, true);
assertEquals(this.validMapping, mapping);
} catch (Exception e) {
@@ -314,7 +308,7 @@ public class IndexerMappingServiceTest {
final String mapping = "{\"dynamic\":\"false\",\"properties\":{\"acl\":{\"properties\":{\"owners\":{\"type\":\"keyword\"},\"viewers\":{\"type\":\"keyword\"}}},\"ancestry\":{\"properties\":{\"parents\":{\"type\":\"keyword\"}}},\"data\":{\"properties\":{\"message\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"null_value\":\"null\",\"ignore_above\":256}}}}},\"id\":{\"type\":\"keyword\"},\"index\":{\"properties\":{\"lastUpdateTime\":{\"type\":\"date\"},\"statusCode\":{\"type\":\"integer\"},\"trace\":{\"type\":\"text\"}}},\"kind\":{\"type\":\"keyword\"},\"legal\":{\"properties\":{\"legaltags\":{\"type\":\"keyword\"},\"otherRelevantDataCountries\":{\"type\":\"keyword\"},\"status\":{\"type\":\"keyword\"}}},\"namespace\":{\"type\":\"keyword\"},\"tags\":{\"type\":\"flattened\"},\"type\":{\"type\":\"keyword\"},\"version\":{\"type\":\"long\"},\"x-acl\":{\"type\":\"keyword\"}}}";
doReturn(mapping).when(this.sut).getIndexMapping(restHighLevelClient, index);
AcknowledgedResponse mappingResponse = new AcknowledgedResponse(true);
AcknowledgedResponse mappingResponse = AcknowledgedResponse.TRUE;
doReturn(this.indicesClient).when(this.restHighLevelClient).indices();
doReturn(mappingResponse).when(this.indicesClient).putMapping(any(PutMappingRequest.class), any(RequestOptions.class));
Loading