diff --git a/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/deleteschema/Steps.java b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/deleteschema/Steps.java index 03e6c19cd112870bf72adc87eaacfc1e7572c162..88c29484649c4f718b628da3874f85643ff4bc26 100644 --- a/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/deleteschema/Steps.java +++ b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/deleteschema/Steps.java @@ -9,13 +9,15 @@ import cucumber.api.DataTable; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; +import org.opengroup.osdu.util.ElasticUtils; +import org.opengroup.osdu.util.ElasticUtilsAws; import java.util.List; public class Steps extends DeleteSchemaSteps { public Steps() { - super(new AWSHTTPClient()); + super(new AWSHTTPClient(), new ElasticUtilsAws()); } @Before diff --git a/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/getschema/Steps.java b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/getschema/Steps.java index a0ab3f66354b9bb183605b49a677a8d06c1602ee..e5f419970fd601aafefdf943608b0015de5e9962 100644 --- a/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/getschema/Steps.java +++ b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/getschema/Steps.java @@ -9,10 +9,11 @@ import cucumber.api.DataTable; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; +import org.opengroup.osdu.util.ElasticUtilsAws; public class Steps extends GetSchemaSteps { public Steps() { - super(new AWSHTTPClient()); + super(new AWSHTTPClient(), new ElasticUtilsAws()); } @Before diff --git a/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java index 0c103694faf851f3343f520abb87af3403ffe51b..e18f3b5f5142c33fe9dcf156462786d140778216 100644 --- a/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java +++ b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/record/Steps.java @@ -10,12 +10,13 @@ import cucumber.api.DataTable; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; +import org.opengroup.osdu.util.ElasticUtilsAws; @Log public class Steps extends RecordSteps { public Steps() { - super(new AWSHTTPClient()); + super(new AWSHTTPClient(), new ElasticUtilsAws()); } @Before diff --git a/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/util/JwtTokenUtil.java b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/util/JwtTokenUtil.java index 289fdaa14088c6b5172572f95e3be777421416bb..7c13aaae6539701a93daf5793be42e12a2e9da3b 100644 --- a/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/util/JwtTokenUtil.java +++ b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/util/JwtTokenUtil.java @@ -36,8 +36,7 @@ class JwtTokenUtil { if (Strings.isNullOrEmpty(accessToken)) { accessToken = getServiceAccountAccessToken(getJwtForIntegrationTesterAccount()); } - // return accessToken; - return null; + return accessToken; } private static String getServiceAccountAccessToken(String key) throws IOException { diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/DeleteSchemaSteps.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/DeleteSchemaSteps.java index a6a9404c68bf35b90955d43ea05f376a98ebf79f..2966fd5dad34fa1e5156082834e8ac5027ef6dab 100644 --- a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/DeleteSchemaSteps.java +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/DeleteSchemaSteps.java @@ -8,6 +8,7 @@ import org.opengroup.osdu.models.Setup; import org.opengroup.osdu.models.TestIndex; import org.opengroup.osdu.response.ErrorResponseMock; import org.opengroup.osdu.util.Config; +import org.opengroup.osdu.util.ElasticUtils; import org.opengroup.osdu.util.HTTPClient; import java.util.HashMap; @@ -33,6 +34,10 @@ public class DeleteSchemaSteps extends TestsBase { super(httpClient); } + public DeleteSchemaSteps(HTTPClient httpClient, ElasticUtils elasticUtils) { + super(httpClient, elasticUtils); + } + /******************One time cleanup for whole feature**************/ public void tearDown() { for (String kind : inputRecordMap.keySet()) { @@ -44,7 +49,7 @@ public class DeleteSchemaSteps extends TestsBase { public void the_elastic_search_is_initialized_with_the_following_data(DataTable dataTable) throws Throwable { List<Setup> inputlist = dataTable.asList(Setup.class); for (Setup input : inputlist) { - TestIndex testIndex = new TestIndex(); + TestIndex testIndex = getTextIndex(); testIndex.setHttpClient(httpClient); testIndex.setIndex(generateActualName(input.getIndex(), timeStamp)); testIndex.setKind(generateActualName(input.getKind(), timeStamp)); diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/GetSchemaSteps.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/GetSchemaSteps.java index 5031153ebd8200657ce8929521cac995979ff1cb..0993a09b34d8ab18087010210eef27bb3d34c7e8 100644 --- a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/GetSchemaSteps.java +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/GetSchemaSteps.java @@ -7,6 +7,7 @@ import org.opengroup.osdu.models.Setup; import org.opengroup.osdu.models.TestIndex; import org.opengroup.osdu.response.ErrorResponseMock; import org.opengroup.osdu.util.Config; +import org.opengroup.osdu.util.ElasticUtils; import org.opengroup.osdu.util.HTTPClient; import com.sun.jersey.api.client.ClientResponse; @@ -30,7 +31,12 @@ public class GetSchemaSteps extends TestsBase { super(httpClient); } - + public GetSchemaSteps(HTTPClient httpClient, ElasticUtils elasticUtils) { + super(httpClient, elasticUtils); + } + + + /******************One time cleanup for whole feature**************/ public void tearDown() { for (String kind : inputRecordMap.keySet()) { @@ -42,7 +48,7 @@ public class GetSchemaSteps extends TestsBase { public void the_elastic_search_is_initialized_with_the_following_data(DataTable dataTable) throws Throwable { List<Setup> inputlist = dataTable.asList(Setup.class); for (Setup input : inputlist) { - TestIndex testIndex = new TestIndex(); + TestIndex testIndex = getTextIndex(); testIndex.setHttpClient(httpClient); testIndex.setIndex(generateActualName(input.getIndex(), timeStamp)); testIndex.setKind(generateActualName(input.getKind(), timeStamp)); diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/MappingSteps.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/MappingSteps.java index 47e6fdbb215673724f557695f957a3981de170ec..76a524806b6ab644d4c162a0f009668d9768f9cf 100644 --- a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/MappingSteps.java +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/MappingSteps.java @@ -42,6 +42,13 @@ public class MappingSteps extends TestsBase { timeStamp = String.valueOf(System.currentTimeMillis()); } + public MappingSteps(HTTPClient httpClient, ElasticUtils elasticUtils) { + super(httpClient, elasticUtils); + headers = httpClient.getCommonHeader(); + fieldName=""; + timeStamp = String.valueOf(System.currentTimeMillis()); + } + public void the_elastic_search_is_initialized_with_the_following_data(DataTable dataTable) { if (!dunit) { List<Setup> inputlist = dataTable.asList(Setup.class); diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/RecordSteps.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/RecordSteps.java index 9dbfc60604e9f28e711b1c55c4949633bc91d603..1001f731f1a3f6720b421da8bc6c05c87791441b 100644 --- a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/RecordSteps.java +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/RecordSteps.java @@ -42,6 +42,12 @@ public class RecordSteps extends TestsBase { timeStamp = String.valueOf(System.currentTimeMillis()); headers = httpClient.getCommonHeader(); } + + public RecordSteps(HTTPClient httpClient, ElasticUtils elasticUtils) { + super(httpClient, elasticUtils); + timeStamp = String.valueOf(System.currentTimeMillis()); + headers = httpClient.getCommonHeader(); + } /******************One time cleanup for whole feature**************/ public void tearDown() { @@ -63,7 +69,7 @@ public class RecordSteps extends TestsBase { List<Setup> inputList = dataTable.asList(Setup.class); for (Setup input : inputList) { - TestIndex testIndex = new TestIndex(); + TestIndex testIndex = getTextIndex(); testIndex.setHttpClient(httpClient); testIndex.setIndex(generateActualName(input.getIndex(), timeStamp)); testIndex.setKind(generateActualName(input.getKind(), timeStamp)); diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/TestsBase.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/TestsBase.java index 89fbb2a05f445d4075f93c81883620bc98c1acf5..12d5ed607b69203ad000d10ad5ebeed91821e24c 100644 --- a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/TestsBase.java +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/TestsBase.java @@ -6,6 +6,7 @@ import org.opengroup.osdu.models.Legal; import org.opengroup.osdu.models.Setup; import org.opengroup.osdu.models.TestIndex; import org.opengroup.osdu.response.ResponseBase; +import org.opengroup.osdu.util.ElasticUtils; import org.opengroup.osdu.util.HTTPClient; import com.sun.jersey.api.client.ClientResponse; @@ -28,17 +29,33 @@ public abstract class TestsBase { protected Scenario scenario; protected Map<String, String> tenantMap = new HashMap<>(); protected Map<String, TestIndex> inputRecordMap = new HashMap<>(); + protected ElasticUtils elasticUtils; public TestsBase(HTTPClient httpClient) { this.httpClient = httpClient; tenantMap.put("tenant1", getDataPartitionIdTenant1()); tenantMap.put("tenant2", getDataPartitionIdTenant2()); tenantMap.put("common", "common"); + + elasticUtils = new ElasticUtils(); + } + + public TestsBase(HTTPClient httpClient, ElasticUtils elasticUtils) { + this.httpClient = httpClient; + tenantMap.put("tenant1", getDataPartitionIdTenant1()); + tenantMap.put("tenant2", getDataPartitionIdTenant2()); + tenantMap.put("common", "common"); + + this.elasticUtils = elasticUtils; + } + + protected TestIndex getTextIndex(){ + return new TestIndex(elasticUtils); } protected void setUp(List<Setup> inputList, String timeStamp) { for (Setup input : inputList) { - TestIndex testIndex = new TestIndex(); + TestIndex testIndex = getTextIndex(); testIndex.setHttpClient(httpClient); testIndex.setIndex(generateActualName(input.getIndex(), timeStamp)); testIndex.setKind(generateActualName(input.getKind(), timeStamp)); diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/models/TestIndex.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/models/TestIndex.java index 00ac7b1c9bd2fe9780c5d2f40baf761e8aa429c5..d8c611d8b5a3aff19a5ab23606f45476d9f57609 100644 --- a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/models/TestIndex.java +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/models/TestIndex.java @@ -21,7 +21,6 @@ import static org.junit.Assert.assertEquals; import static org.opengroup.osdu.util.Config.*; @Data -@NoArgsConstructor public class TestIndex { private static final Logger LOGGER = Logger.getLogger(TestIndex.class.getName()); private String kind; @@ -35,9 +34,13 @@ public class TestIndex { private String[] ownerGroup; private HTTPClient httpClient; private Map<String, String> headers; - private ElasticUtils elasticUtils = new ElasticUtils(); + private ElasticUtils elasticUtils; private Gson gson = new Gson(); + public TestIndex(ElasticUtils elasticUtils){ + this.elasticUtils = elasticUtils; + } + public void setHttpClient(HTTPClient httpClient) { this.httpClient = httpClient; headers = httpClient.getCommonHeader(); diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/util/Config.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/util/Config.java index e252dc55724c9ad7771a6fa13451943f91cca4b5..be1a9e8a78618cd52215593e8a0c9787b54097d6 100644 --- a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/util/Config.java +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/util/Config.java @@ -7,12 +7,12 @@ public class Config { private static final String DEFAULT_ELASTIC_PASSWORD = "us-east-1"; static final int PORT = 9243; - private static final String DEFAULT_INDEXER_HOST = ""; - private static final String DEFAULT_SEARCH_HOST = ""; - private static final String DEFAULT_STORAGE_HOST = ""; - private static final String DEFAULT_DATA_PARTITION_ID_TENANT1 = ""; - private static final String DEFAULT_DATA_PARTITION_ID_TENANT2 = ""; - private static final String DEFAULT_SEARCH_INTEGRATION_TESTER = ""; + private static final String DEFAULT_INDEXER_HOST = "https://search-dev-osdu-indexer-i5bpf2gv4iv6ha2xi7rook2rga.us-east-1.es.amazonaws.com/"; + private static final String DEFAULT_SEARCH_HOST = "https://search-dev-osdu-indexer-i5bpf2gv4iv6ha2xi7rook2rga.us-east-1.es.amazonaws.com/"; + private static final String DEFAULT_STORAGE_HOST = "http://localhost:8081/api/storage/v2/"; + private static final String DEFAULT_DATA_PARTITION_ID_TENANT1 = "common"; + private static final String DEFAULT_DATA_PARTITION_ID_TENANT2 = "common"; + private static final String DEFAULT_SEARCH_INTEGRATION_TESTER = "common"; private static final String DEFAULT_TARGET_AUDIENCE = "";