diff --git a/NOTICE b/NOTICE index 861fff698251a11123062892e716ebf2f97c3358..6f1bddf934b56d9493b5d9e32fc3508f201b2475 100644 --- a/NOTICE +++ b/NOTICE @@ -344,7 +344,7 @@ The following software have components provided under the terms of this license: - GSON extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-gson) - Google APIs Client Library for Java (from https://repo1.maven.org/maven2/com/google/api-client/google-api-client) - Google App Engine extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-appengine) -- Google Cloud Core (from https://github.com/googleapis/google-cloud-java, https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core, https://github.com/googleapis/java-core) +- Google Cloud Core (from https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core, https://github.com/googleapis/java-core, https://repo1.maven.org/maven2/com/google/cloud/google-cloud-core) - Google Cloud Core HTTP (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-core-http, https://github.com/googleapis/google-cloud-java, https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-http, https://github.com/googleapis/java-core) - Google Cloud Core gRPC (from https://github.com/googleapis/google-cloud-java, https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-core-grpc, https://github.com/googleapis/java-core) - Google Cloud Datastore (from https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-clients/google-cloud-datastore, https://github.com/googleapis/java-datastore) @@ -613,7 +613,6 @@ The following software have components provided under the terms of this license: - PostgreSQL JDBC Driver - Protocol Buffer Java API (from http://code.google.com/p/protobuf, https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java) - Protocol Buffers [Util] (from https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java-util) -- SnakeYAML (from http://code.google.com/p/snakeyaml/, http://www.snakeyaml.org, https://bitbucket.org/snakeyaml/snakeyaml) - Spring Core (from http://www.springframework.org, https://github.com/spring-projects/spring-framework, https://repo1.maven.org/maven2/org/springframework/spring-core) - ThreeTen backport (from https://github.com/ThreeTen/threetenbp, https://www.threeten.org/threetenbp) - google (from http://breakingcode.wordpress.com/) @@ -721,7 +720,6 @@ The following software have components provided under the terms of this license: - Microsoft Application Insights Java SDK Spring Boot starter (from https://github.com/Microsoft/ApplicationInsights-Java) - Microsoft Application Insights Java SDK Web Module (from https://github.com/Microsoft/ApplicationInsights-Java) - Microsoft Application Insights Log4j 2 Appender (from https://github.com/Microsoft/ApplicationInsights-Java) -- SnakeYAML (from http://code.google.com/p/snakeyaml/, http://www.snakeyaml.org, https://bitbucket.org/snakeyaml/snakeyaml) ======================================================================== EPL-2.0 @@ -754,13 +752,6 @@ The following software have components provided under the terms of this license: - RabbitMQ Java Client (from http://www.rabbitmq.com, https://www.rabbitmq.com) - tomcat-embed-core (from http://tomcat.apache.org/) -======================================================================== -GPL-2.0-or-later -======================================================================== -The following software have components provided under the terms of this license: - -- SnakeYAML (from http://code.google.com/p/snakeyaml/, http://www.snakeyaml.org, https://bitbucket.org/snakeyaml/snakeyaml) - ======================================================================== GPL-2.0-with-classpath-exception ======================================================================== @@ -835,7 +826,6 @@ The following software have components provided under the terms of this license: - Java Native Access (from https://github.com/java-native-access/jna, https://github.com/twall/jna) - Java Native Access Platform (from https://github.com/java-native-access/jna) - Javassist (from http://www.javassist.org/) -- SnakeYAML (from http://code.google.com/p/snakeyaml/, http://www.snakeyaml.org, https://bitbucket.org/snakeyaml/snakeyaml) ======================================================================== MIT diff --git a/testing/schema-test-azure/pom.xml b/testing/schema-test-azure/pom.xml index 03c1a6a3f15fc9361ad0ba5f5b2af3e96c37781d..94929243b27df233eddd4d44070ce01aad8a9893 100644 --- a/testing/schema-test-azure/pom.xml +++ b/testing/schema-test-azure/pom.xml @@ -10,160 +10,7 @@ <artifactId>schema-test-azure</artifactId> <version>0.21.0-SNAPSHOT</version> - <properties> - <os-core-lib-ibm.version>0.7.0</os-core-lib-ibm.version> - <os-core-lib-azure.version>0.6.1</os-core-lib-azure.version> - <maven.compiler.target>1.8</maven.compiler.target> - <maven.compiler.source>1.8</maven.compiler.source> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <dependencies> - - <dependency> - <groupId>org.opengroup.osdu</groupId> - <artifactId>os-schema-core</artifactId> - <exclusions> - <exclusion> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-to-slf4j</artifactId> - </exclusion> - </exclusions> - <version>0.21.0-SNAPSHOT</version> - </dependency> - - <!--Rest assured dependency to be placed before JUnit dependency --> - <dependency> - <groupId>io.rest-assured</groupId> - <artifactId>rest-assured</artifactId> - <version>3.2.0</version> - </dependency> - - <dependency> - <groupId>io.cucumber</groupId> - <artifactId>cucumber-java8</artifactId> - <version>5.4.0</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>io.cucumber</groupId> - <artifactId>cucumber-junit</artifactId> - <version>5.4.0</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>io.cucumber</groupId> - <artifactId>cucumber-guice</artifactId> - <version>5.4.0</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>com.google.inject</groupId> - <artifactId>guice</artifactId> - <version>4.2.0</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>com.google.cloud</groupId> - <artifactId>google-cloud-storage</artifactId> - <version>1.76.0</version> - </dependency> - - <dependency> - <groupId>org.opengroup.osdu</groupId> - <artifactId>core-lib-azure</artifactId> - <version>${os-core-lib-azure.version}</version> - </dependency> - - <dependency> - <groupId>org.opengroup.osdu.core.aws</groupId> - <artifactId>os-core-lib-aws</artifactId> - <version>0.3.16</version> - </dependency> - - <dependency> - <groupId>org.opengroup.osdu</groupId> - <artifactId>os-core-lib-ibm</artifactId> - <version>${os-core-lib-ibm.version}</version> - </dependency> - </dependencies> - - <dependencyManagement> - <dependencies> - <!-- Inherit managed dependencies from core-lib-azure --> - <dependency> - <groupId>org.opengroup.osdu</groupId> - <artifactId>core-lib-azure</artifactId> - <version>${os-core-lib-azure.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-failsafe-plugin</artifactId> - <version>3.0.0-M3</version> - <executions> - <execution> - <id>pre-integration-test</id> - <goals> - <goal>integration-test</goal> - </goals> - <configuration> - <skipTests>${skipItTests}</skipTests> - <includes> - <include>org.opengroup.osdu.schema.runner.PreIntegrationTestsRunner</include> - </includes> - </configuration> - </execution> - <execution> - <id>integration-test</id> - <goals> - <goal>integration-test</goal> - </goals> - <configuration> - <skipTests>${skipItTests}</skipTests> - <excludes> - <exclude>none</exclude> - </excludes> - <includes> - <include>org.opengroup.osdu.schema.runner.SchemaServiceTestsRunner</include> - </includes> - </configuration> - </execution> - <execution> - <id>post-integration-test</id> - <goals> - <goal>integration-test</goal> - </goals> - <configuration> - <skipTests>${skipItTests}</skipTests> - <includes> - <include>org.opengroup.osdu.schema.runner.TearDownTestsRunner</include> - </includes> - </configuration> - </execution> - <execution> - <id>verify</id> - <goals> - <goal>verify</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> + <packaging>jar</packaging> + <name>schema-test-azure</name> + <description>Azure integration tests for schema service</description> </project> diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/constants/HttpConnection.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/constants/HttpConnection.java deleted file mode 100644 index c3fba017791efc4b1e3bee23a118a7d49b682d63..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/constants/HttpConnection.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.opengroup.osdu.schema.constants; - -public class HttpConnection { - public static final boolean FOLLOW_REDIRECTS = true; - public static final int CONNECTION_TIMEOUT_IN_MILLISECONDS = 80000; - public static final String HTTP_SOCKET_TIMEOUT = "http.socket.timeout"; - public static final String HTTP_CONNECTION_TIMEOUT = "http.connection.timeout"; - public static final String CONTENT_TYPE = "Content-Type"; - public static final String APPLICATION_JSON = "application/json"; -} diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/constants/TestConstants.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/constants/TestConstants.java deleted file mode 100644 index 101b3224d77542d62de681ae846921156df554cd..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/constants/TestConstants.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.opengroup.osdu.schema.constants; - -public class TestConstants { - public static final String FORWARD_SLASH = "/"; - public static final String PUT_ENDPOINT = "/api/schema-service/v1/schemas/system"; - public static final String POST_ENDPOINT = "/api/schema-service/v1/schema"; - public static final String GET_LIST_ENDPOINT = "/api/schema-service/v1/schema"; - public static final String GET_ENDPOINT = "/api/schema-service/v1/schema/"; - public static final String GET_FLATTENED_ENDPOINT = "/api/schema-service/v1/schema/{id}/IndexerSchemaV1"; - public static final String GET_INFO_ENDPOINT = "/api/schema-service/v1/info"; - //public static final String HOST = "http://localhost:8080"; - public static final String INTERNAL_SERVER_ERROR = "internal server error"; - public static final String INTERNAL = "INTERNAL"; - public static final String SCHEMA_KIND = "schema"; - public static final String AUTHORITY = "authority"; - public static final String LATEST_VERSION = "latestVersion"; - public static final String GET_SUCCESSRESPONSECODE = "200"; - public static final String SOURCE = "source"; - public static final String ENTITY_TYPE = "entityType"; - public static final String MAJOR_VERSION = "majorVersion"; - public static final String MINOR_VERSION = "minorVersion"; - public static final String PATCH_VERSION = "patchVersion"; - public static final String CREATED_BY = "createdBy"; - public static final String SUPERSEDED_BY = "supersededBy"; - public static final String DATE_CREATED = "dateCreated"; - public static final String SCHEMA = "schema"; - public static final String OBSOLETE = "OBSOLETE"; - public static final String PUBLISHED = "PUBLISHED"; - public static final String SCOPE = "scope"; - public static final String STATUS = "status"; - public static final String ALREADY_EXISTS = "ALREADY_EXISTS"; - public static final String DATAECOSYSTEM = "dataecosystem"; - public static final String AUTHORIZATION = "authorization"; - public static final String DATA_PARTITION_ID = "data-partition-id"; - public static final String BEARER = "Bearer "; - public static final String CONTENT_TYPE = "Content-Type"; - public static final String JSON_CONTENT = "application/json"; - public static final String schemaIdOfInputPayload = "schemaInfo.schemaIdentity.id"; - public static final String SCHEMA_IDENTITY = "schemaIdentity"; - public static final String ENTITY = "entityType"; - public static final String SCHEMA_MAJOR_VERSION = "schemaVersionMajor"; - public static final String SCHEMA_MINOR_VERSION = "schemaVersionMinor"; - public static final String SCHEMA_PATCH_VERSION = "schemaVersionPatch"; - public static final String ID = "id"; - public static final String DOT = "."; - public static final String ERROR = "error"; - public static final String MESSAGE = "message"; - public static final String STORAGE_SCHEMA = "StorageSchema"; - public static final String USER = "user"; - public static final String STORAGE_SCHEMA_USER_EMAIL = "testUserEmail@test.com"; - public static final String KIND = "kind"; - public static final String TRUE = "true"; - public static final String HOST = System.getProperty("HOST", System.getenv("HOST")); - public static final String PRIVATE_TENANT1 = System.getProperty("PRIVATE_TENANT1", System.getenv("PRIVATE_TENANT1")); - public static final String PRIVATE_TENANT2 = System.getProperty("PRIVATE_TENANT2", System.getenv("PRIVATE_TENANT2")); - public static final String SHARED_TENANT = System.getProperty("SHARED_TENANT", System.getenv("SHARED_TENANT")); - public static final String SYSTEM_TENANT = System.getProperty("SYSTEM_TENANT", System.getenv("SYSTEM_TENANT")); -} diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/runner/PreIntegrationTestsRunner.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/runner/PreIntegrationTestsRunner.java deleted file mode 100644 index f0cdd4e8480919496e141e78551bab90c7853ba0..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/runner/PreIntegrationTestsRunner.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.opengroup.osdu.schema.runner; - -import org.junit.runner.RunWith; - -import io.cucumber.junit.Cucumber; -import io.cucumber.junit.CucumberOptions; - -@RunWith(Cucumber.class) -@CucumberOptions(features = "classpath:features", glue = { "classpath:org.opengroup.osdu.schema.stepdefs" }, tags = { - "@Startup" }, plugin = { "pretty", "junit:target/cucumber-reports/schema-service-test-report.xml" }) -public class PreIntegrationTestsRunner { - -} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/runner/SchemaServiceTestsRunner.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/runner/SchemaServiceTestsRunner.java deleted file mode 100644 index 385545c2d2ae888156ee6c1ce23a00f6f095c045..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/runner/SchemaServiceTestsRunner.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.opengroup.osdu.schema.runner; - -import org.junit.runner.RunWith; - -import io.cucumber.junit.Cucumber; -import io.cucumber.junit.CucumberOptions; - -@RunWith(Cucumber.class) -@CucumberOptions(features = "classpath:features", glue = { "classpath:org.opengroup.osdu.schema.stepdefs" }, tags = { - "@SchemaServiceAzure" }, plugin = { "pretty", "junit:target/cucumber-reports/schema-service-test-report.xml" }) -public class SchemaServiceTestsRunner { - -} diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/runner/TearDownTestsRunner.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/runner/TearDownTestsRunner.java deleted file mode 100644 index 71de8088ebc7ab9797fb7eafe267764df965288d..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/runner/TearDownTestsRunner.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.opengroup.osdu.schema.runner; - -import org.junit.runner.RunWith; - -import io.cucumber.junit.Cucumber; -import io.cucumber.junit.CucumberOptions; - -@RunWith(Cucumber.class) -@CucumberOptions(features = "classpath:features", glue = { "classpath:org.opengroup.osdu.schema.stepdefs" }, tags = { - "@TearDown" }, plugin = { "pretty", "junit:target/cucumber-reports/schema-service-test-report.xml" }) -public class TearDownTestsRunner { - -} diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/InfoStepDef_GET.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/InfoStepDef_GET.java deleted file mode 100644 index 4241da92313c1d5741c2aeaecd2a294e03730a85..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/InfoStepDef_GET.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.opengroup.osdu.schema.stepdefs; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import com.google.inject.Inject; -import io.cucumber.java8.En; -import org.opengroup.osdu.schema.constants.TestConstants; -import org.opengroup.osdu.schema.stepdefs.model.HttpRequest; -import org.opengroup.osdu.schema.stepdefs.model.HttpResponse; -import org.opengroup.osdu.schema.stepdefs.model.SchemaServiceScope; -import org.opengroup.osdu.schema.util.HttpClientFactory; -import org.opengroup.osdu.schema.util.VersionInfoUtils; - -public class InfoStepDef_GET implements En { - - @Inject - private SchemaServiceScope context; - - private VersionInfoUtils versionInfoUtil = new VersionInfoUtils(); - - public InfoStepDef_GET() { - - Given("I send get request to version info endpoint", () -> { - HttpRequest httpRequest = HttpRequest.builder() - .url(TestConstants.HOST + TestConstants.GET_INFO_ENDPOINT) - .httpMethod(HttpRequest.GET) - .build(); - HttpResponse response = HttpClientFactory.getInstance().send(httpRequest); - this.context.setHttpResponse(response); - }); - - Then("service should respond back with version info in response", () -> { - assertEquals(200, this.context.getHttpResponse().getCode()); - - VersionInfoUtils.VersionInfo responseObject = this.versionInfoUtil - .getVersionInfoFromResponse(this.context.getHttpResponse()); - - assertNotNull(responseObject.groupId); - assertNotNull(responseObject.artifactId); - assertNotNull(responseObject.version); - assertNotNull(responseObject.buildTime); - assertNotNull(responseObject.branch); - assertNotNull(responseObject.commitId); - assertNotNull(responseObject.commitMessage); - }); - } -} diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/LocalSetupStepDef.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/LocalSetupStepDef.java deleted file mode 100644 index c85be6bcba82f1307ed6a89aa3bce80899635162..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/LocalSetupStepDef.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.opengroup.osdu.schema.stepdefs; - -import io.cucumber.java8.En; -import lombok.extern.java.Log; - -@Log -public class LocalSetupStepDef implements En { - - public LocalSetupStepDef() { - - } -} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_GET.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_GET.java deleted file mode 100644 index a043eee8bd028866525de30b8dc04aa2659d0e23..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_GET.java +++ /dev/null @@ -1,182 +0,0 @@ -package org.opengroup.osdu.schema.stepdefs; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeSet; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.opengroup.osdu.schema.constants.TestConstants; -import org.opengroup.osdu.schema.stepdefs.model.HttpRequest; -import org.opengroup.osdu.schema.stepdefs.model.HttpResponse; -import org.opengroup.osdu.schema.stepdefs.model.SchemaServiceScope; -import org.opengroup.osdu.schema.util.AuthUtil; -import org.opengroup.osdu.schema.util.HttpClientFactory; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.inject.Inject; - -import io.cucumber.java8.En; - -public class SchemaServiceStepDef_GET implements En { - - @Inject - private SchemaServiceScope context; - - static String[] GetListBaseFilterArray; - static String[] GetListVersionFilterArray; - String queryParameter; - private static TreeSet<String> LIST_OF_AVAILABLE_SCHEMAS = new TreeSet<String>(); - - private final static Logger LOGGER = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); - List<HashMap<String, String>> list_schemaParameterMap = new ArrayList<HashMap<String, String>>(); - - public SchemaServiceStepDef_GET() { - - Given("I generate user token and set request headers for {string}", (String tenant) -> { - if (this.context.getToken() == null) { - String token = new AuthUtil().getToken(); - this.context.setToken(token); - } - - if (this.context.getAuthHeaders() == null) { - Map<String, String> authHeaders = new HashMap<String, String>(); - authHeaders.put(TestConstants.AUTHORIZATION, this.context.getToken()); - authHeaders.put(TestConstants.DATA_PARTITION_ID, selectTenant(tenant)); - authHeaders.put(TestConstants.CONTENT_TYPE, TestConstants.JSON_CONTENT); - this.context.setAuthHeaders(authHeaders); - } - }); - - Given("I generate user token and set request headers for system API", () -> { - if (this.context.getToken() == null) { - String token = new AuthUtil().getToken(); - this.context.setToken(token); - } - - if (this.context.getAuthHeaders() == null) { - Map<String, String> authHeaders = new HashMap<String, String>(); - authHeaders.put(TestConstants.AUTHORIZATION, this.context.getToken()); - authHeaders.put(TestConstants.CONTENT_TYPE, TestConstants.JSON_CONTENT); - this.context.setAuthHeaders(authHeaders); - } - }); - - Given("I get latest schema with authority, source, entityType as {string}, {string}, {string} respectively", - (String authority, String source, String entityType) -> { - Map<String, String> queryParams = new HashMap<String, String>(); - queryParams.put(TestConstants.AUTHORITY, authority); - queryParams.put(TestConstants.SOURCE, source); - queryParams.put(TestConstants.ENTITY_TYPE, entityType); - queryParams.put(TestConstants.LATEST_VERSION, TestConstants.TRUE); - - HttpRequest httpRequest = HttpRequest.builder() - .url(TestConstants.HOST + TestConstants.GET_LIST_ENDPOINT).queryParams(queryParams) - .httpMethod(HttpRequest.GET).requestHeaders(this.context.getAuthHeaders()).build(); - HttpResponse response = HttpClientFactory.getInstance().send(httpRequest); - - this.context.setHttpResponse(response); - assertEquals("200", String.valueOf(response.getCode())); - LOGGER.log(Level.INFO, "resp - " + response.toString()); - verifyGetListResponse(TestConstants.AUTHORITY, authority); - }); - - Then("schema service should respond back with {string} and {string}", - (String ReponseStatusCode, String ResponseToBeVerified) -> { - HttpRequest httpRequest = HttpRequest.builder() - .url(TestConstants.HOST + TestConstants.GET_ENDPOINT - + this.context.getSchemaIdFromInputPayload()) - .httpMethod(HttpRequest.GET).requestHeaders(this.context.getAuthHeaders()).build(); - HttpResponse response = HttpClientFactory.getInstance().send(httpRequest); - assertEquals(ReponseStatusCode, String.valueOf(response.getCode())); - String body = this.context.getFileUtils().read(ResponseToBeVerified); - Gson gsn = new Gson(); - JsonObject expectedData = gsn.fromJson(body, JsonObject.class); - JsonObject responseMsg = gsn.fromJson(response.getBody().toString(), JsonObject.class); - assertEquals(expectedData.toString(), responseMsg.toString()); - }); - - } - - private void verifyGetListResponse(String parameter, String parameterVal) throws IOException { - prepareSchemaParameterMapList(); - verifySchemaInfoResponse(parameter, parameterVal); - } - - - public void prepareSchemaParameterMapList() throws IOException { - String response = this.context.getHttpResponse().getBody(); - Gson gsn = new Gson(); - JsonObject schemaInfosList = gsn.fromJson(response, JsonObject.class); - JsonArray root = (JsonArray) schemaInfosList.get("schemaInfos"); - if (root.size() > 0) { - for (JsonElement eachSchemaInfo : root) { - Map<String, String> schemaIdentityMap = new HashMap<String, String>(); - - JsonObject schemaIdentity_ForEachSchemaStatus = (JsonObject) (eachSchemaInfo.getAsJsonObject()); - - this.context.setStatus(schemaIdentity_ForEachSchemaStatus.get("status").getAsString()); - - JsonObject schemaIdentity_ForEachSchemaInfo = (JsonObject) eachSchemaInfo.getAsJsonObject() - .get("schemaIdentity"); - schemaIdentityMap.put("authority", schemaIdentity_ForEachSchemaInfo.get("authority").getAsString()); - schemaIdentityMap.put("source", schemaIdentity_ForEachSchemaInfo.get("source").getAsString()); - schemaIdentityMap.put("entityType", schemaIdentity_ForEachSchemaInfo.get("entityType").getAsString()); - - schemaIdentityMap.put("schemaVersionMajor", - schemaIdentity_ForEachSchemaInfo.get("schemaVersionMajor").getAsString()); - this.context.setSchemaVersionMajor( - schemaIdentity_ForEachSchemaInfo.get("schemaVersionMajor").getAsString()); - - schemaIdentityMap.put("schemaVersionMinor", - schemaIdentity_ForEachSchemaInfo.get("schemaVersionMinor").getAsString()); - this.context.setSchemaVersionMinor( - schemaIdentity_ForEachSchemaInfo.get("schemaVersionMinor").getAsString()); - - schemaIdentityMap.put("schemaVersionPatch", - schemaIdentity_ForEachSchemaInfo.get("schemaVersionPatch").getAsString()); - this.context.setSchemaVersionPatch( - schemaIdentity_ForEachSchemaInfo.get("schemaVersionPatch").getAsString()); - - schemaIdentityMap.put("scope", eachSchemaInfo.getAsJsonObject().get("scope").getAsString()); - schemaIdentityMap.put("status", eachSchemaInfo.getAsJsonObject().get("status").getAsString()); - this.list_schemaParameterMap.add((HashMap<String, String>) schemaIdentityMap); - } - LOGGER.log(Level.INFO, "SchemaParameterMapList - " + this.list_schemaParameterMap.toString()); - } - } - - private void verifySchemaInfoResponse(String parameterName, String parameterVal) { - for (HashMap<String, String> schemaInfoMap : this.list_schemaParameterMap) { - assertEquals( - "Response schemaInfoList contains schemaInfo not matching parameter criteria - " + parameterName, - parameterVal.toString(), schemaInfoMap.get(parameterName).toString()); - } - } - - private String selectTenant(String tenant) { - - switch (tenant) { - case "TENANT1": - tenant = TestConstants.PRIVATE_TENANT1; - break; - case "TENANT2": - tenant = TestConstants.PRIVATE_TENANT2; - break; - case "COMMON": - tenant = TestConstants.SHARED_TENANT; - break; - default: - System.out.println("Invalid tenant"); - } - return tenant; - } -} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_PUT.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_PUT.java deleted file mode 100644 index 5935d0247e21fe62a5721f31291365b2b7efd306..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_PUT.java +++ /dev/null @@ -1,437 +0,0 @@ -package org.opengroup.osdu.schema.stepdefs; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.junit.Assert; -import org.opengroup.osdu.schema.constants.TestConstants; -import org.opengroup.osdu.schema.stepdefs.model.HttpRequest; -import org.opengroup.osdu.schema.stepdefs.model.HttpResponse; -import org.opengroup.osdu.schema.stepdefs.model.SchemaServiceScope; -import org.opengroup.osdu.schema.util.AuthUtil; -import org.opengroup.osdu.schema.util.HttpClientFactory; -import org.opengroup.osdu.schema.util.JsonUtils; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.inject.Inject; - -import io.cucumber.java8.En; - -public class SchemaServiceStepDef_PUT implements En { - - @Inject - private SchemaServiceScope context; - - static String[] GetListBaseFilterArray; - static String[] GetListVersionFilterArray; - String queryParameter; - - private final static Logger LOGGER = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); - List<HashMap<String, String>> list_schemaParameterMap = new ArrayList<HashMap<String, String>>(); - - public SchemaServiceStepDef_PUT() { - - - Given("I hit schema service PUT API with {string} only if status is not development", - (String inputPayload) -> { - String resp = this.context.getHttpResponse().getBody(); - Gson gsn = new Gson(); - JsonObject schemaInfosList = gsn.fromJson(resp, JsonObject.class); - JsonArray root = (JsonArray) schemaInfosList.get("schemaInfos"); - if (!"DEVELOPMENT".equals(context.getStatus()) || (root.size() == 0)) { - - String body = this.context.getFileUtils().read(inputPayload); - JsonElement jsonBody = new Gson().fromJson(body, JsonElement.class); - int currentMinorVersion = 0; - int currentMajorVersion = 0; - if (root.size() > 0) { - currentMinorVersion = Integer.parseInt(this.context.getSchemaVersionMinor()); - currentMajorVersion = Integer.parseInt(this.context.getSchemaVersionMajor()); - } - - int nextMinorVersion = currentMinorVersion + 1; - int nextMajorVersion = currentMajorVersion + 1; - String schemaId = "OSDUTest:testSource:testEntity:" + nextMajorVersion + "." - + nextMinorVersion + ".0"; - - this.context.setSchemaIdFromInputPayload(schemaId); - - updateVersionInJsonBody(jsonBody, nextMinorVersion, nextMajorVersion, schemaId); - Map<String, String> headers = this.context.getAuthHeaders(); - HttpRequest httpRequest = HttpRequest.builder().url(TestConstants.HOST + TestConstants.PUT_ENDPOINT) - .body(body).httpMethod(HttpRequest.PUT).requestHeaders(this.context.getAuthHeaders()) - .build(); - HttpResponse response = HttpClientFactory.getInstance().send(httpRequest); - - assertEquals("201", String.valueOf(response.getCode())); - this.context.setHttpResponse(response); - prepareSchemaParameterMapList(); - } - }); - - Given("I hit schema service PUT API with {string} and mark schema as {string}.", - (String inputPayload, String status) -> { - String body = this.context.getFileUtils().read(inputPayload); - JsonElement jsonBody = new Gson().fromJson(body, JsonElement.class); - int currentMinorVersion = Integer.parseInt(this.context.getSchemaVersionMinor()); - int currentMajorVersion = Integer.parseInt(this.context.getSchemaVersionMajor()); - String id = "OSDUTest:testSource:testEntity:" + currentMajorVersion + "." - + currentMinorVersion + ".0"; - updateVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, id); - this.context.setSchemaIdFromInputPayload(id); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject().remove("status"); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject().addProperty("status", - status); - body = new Gson().toJson(jsonBody); - Map<String, String> headers = this.context.getAuthHeaders(); - HttpRequest httpRequest = HttpRequest.builder().url(TestConstants.HOST + TestConstants.PUT_ENDPOINT) - .body(body).httpMethod(HttpRequest.PUT).requestHeaders(this.context.getAuthHeaders()) - .build(); - HttpResponse response = HttpClientFactory.getInstance().send(httpRequest); - this.context.setHttpResponse(response); - }); - - Given("I hit schema service PUT API with {string} and mark schema as {string} for next major version", - (String inputPayload, String status) -> { - String body = this.context.getFileUtils().read(inputPayload); - JsonElement jsonBody = new Gson().fromJson(body, JsonElement.class); - int currentMinorVersion = Integer.parseInt(this.context.getSchemaVersionMinor()); - int currentMajorVersion = Integer.parseInt(this.context.getSchemaVersionMajor()); - currentMajorVersion = currentMajorVersion + 1; - String id = "OSDUTest:testSource:testEntity:" + currentMajorVersion + "." - + currentMinorVersion + ".0"; - updateVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, id); - this.context.setSchemaIdFromInputPayload(id); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject().remove("status"); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject().addProperty("status", - status); - body = new Gson().toJson(jsonBody); - Map<String, String> headers = this.context.getAuthHeaders(); - HttpRequest httpRequest = HttpRequest.builder().url(TestConstants.HOST + TestConstants.PUT_ENDPOINT) - .body(body).httpMethod(HttpRequest.PUT).requestHeaders(this.context.getAuthHeaders()) - .build(); - HttpResponse response = HttpClientFactory.getInstance().send(httpRequest); - this.context.setHttpResponse(response); - }); - - Given("I hit schema service PUT API with {string}", - (String inputPayload) -> { - String body = this.context.getFileUtils().read(inputPayload); - JsonElement jsonBody = new Gson().fromJson(body, JsonElement.class); - int currentMinorVersion = Integer.parseInt(this.context.getSchemaVersionMinor()); - int currentMajorVersion = Integer.parseInt(this.context.getSchemaVersionMajor()); - String id = "OSDUTest:testSource:testEntity:" + currentMajorVersion + "." - + currentMinorVersion + ".0"; - updateVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, id); - this.context.setSchemaIdFromInputPayload(id); - body = new Gson().toJson(jsonBody); - Map<String, String> headers = this.context.getAuthHeaders(); - HttpRequest httpRequest = HttpRequest.builder().url(TestConstants.HOST + TestConstants.PUT_ENDPOINT) - .body(body).httpMethod(HttpRequest.PUT).requestHeaders(this.context.getAuthHeaders()) - .build(); - HttpResponse response = HttpClientFactory.getInstance().send(httpRequest); - this.context.setHttpResponse(response); - }); - - Given("I hit schema service PUT API with {string} for superceded input", - (String inputPayload) -> { - String newSchemaStr = this.context.getFileUtils().read(inputPayload); - JsonElement newSchemaJsonBody = new Gson().fromJson(newSchemaStr, JsonElement.class); - int currentMinorVersion = Integer.parseInt(this.context.getSchemaVersionMinor()); - int currentMajorVersion = Integer.parseInt(this.context.getSchemaVersionMajor()); - int patchMajorVersion = Integer.parseInt(this.context.getSchemaVersionPatch()); - - String latestSchemaResp = this.context.getHttpResponse().getBody(); - JsonElement latestSchemaRespJsonBody = new Gson().fromJson(latestSchemaResp, JsonElement.class); - - JsonElement supersededByBody = new Gson().fromJson(latestSchemaRespJsonBody.getAsJsonObject().getAsJsonArray("schemaInfos") - .get(0).getAsJsonObject().getAsJsonObject(TestConstants.SCHEMA_IDENTITY).toString(), JsonElement.class); - - String newID = "OSDUTest:testSource:testEntity:" + (currentMajorVersion+1) + "." - + currentMinorVersion + "."+patchMajorVersion; - String supersededById = "OSDUTest:testSource:testEntity:" + currentMajorVersion + "." - + currentMinorVersion + "."+patchMajorVersion; - updateVersionInJsonBody(newSchemaJsonBody, currentMinorVersion, currentMajorVersion+1, newID); - - newSchemaStr = new Gson().toJson(newSchemaJsonBody); - Map<String, String> headers = this.context.getAuthHeaders(); - - //Create new Schema - HttpRequest httpPostRequest = HttpRequest.builder().url(TestConstants.HOST + TestConstants.POST_ENDPOINT) - .body(newSchemaStr).httpMethod(HttpRequest.POST).requestHeaders(this.context.getAuthHeaders()) - .build(); - HttpResponse postResponse = HttpClientFactory.getInstance().send(httpPostRequest); - - assertEquals(201, postResponse.getCode()); - - //Update with superceded by ID - String postSchemaBody = postResponse.getBody(); - JsonElement postSchemaJsonBody = new Gson().fromJson(postSchemaBody, JsonElement.class); - - postSchemaJsonBody.getAsJsonObject().add(TestConstants.SUPERSEDED_BY, supersededByBody); - - JsonObject putRequest = new JsonObject(); - putRequest.add("schemaInfo", postSchemaJsonBody); - putRequest.add("schema", new Gson().fromJson("{}", JsonElement.class)); - this.context.setSchemaIdFromInputPayload(newID); - this.context.setSupersededById(supersededById); - HttpRequest httpRequest = HttpRequest.builder().url(TestConstants.HOST + TestConstants.PUT_ENDPOINT) - .body(putRequest.toString()).httpMethod(HttpRequest.PUT).requestHeaders(this.context.getAuthHeaders()) - .build(); - HttpResponse response = HttpClientFactory.getInstance().send(httpRequest); - - this.context.setHttpResponse(response); - }); - - Given("I hit schema service PUT API with {string} with increased minor version only", - (String inputPayload) -> { - String body = this.context.getFileUtils().read(inputPayload); - JsonElement jsonBody = new Gson().fromJson(body, JsonElement.class); - int currentMinorVersion = Integer.parseInt(this.context.getSchemaVersionMinor()); - int currentMajorVersion = Integer.parseInt(this.context.getSchemaVersionMajor()); - currentMinorVersion = currentMinorVersion + 1; - String id = "OSDUTest:testSource:testEntity:" + currentMajorVersion + "." - + currentMinorVersion + ".0"; - updateVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, id); - this.context.setSchemaIdFromInputPayload(id); - body = new Gson().toJson(jsonBody); - Map<String, String> headers = this.context.getAuthHeaders(); - HttpRequest httpRequest = HttpRequest.builder().url(TestConstants.HOST + TestConstants.PUT_ENDPOINT) - .body(body).httpMethod(HttpRequest.PUT).requestHeaders(this.context.getAuthHeaders()) - .build(); - HttpResponse response = HttpClientFactory.getInstance().send(httpRequest); - this.context.setHttpResponse(response); - }); - - Given("I hit schema service PUT API with {string} with different entityType", - (String inputPayload) -> { - String body = this.context.getFileUtils().read(inputPayload); - JsonElement jsonBody = new Gson().fromJson(body, JsonElement.class); - int currentMinorVersion = Integer.parseInt(this.context.getSchemaVersionMinor()); - int currentMajorVersion = Integer.parseInt(this.context.getSchemaVersionMajor()); - int currentPatchVersion = Integer.parseInt(this.context.getSchemaVersionPatch()); - String id = "OSDUTest:testSource:testEntity:" + currentMajorVersion + "." - + currentMinorVersion + ".0"; - updateVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, id); - this.context.setSchemaIdFromInputPayload(id); - int randomNum = (int) (Math.random() * 10000); - String entityVal = "testEntity" + randomNum; - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject() - .remove("entityType"); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject() - .addProperty("entityType", entityVal); - body = new Gson().toJson(jsonBody); - Map<String, String> headers = this.context.getAuthHeaders(); - HttpRequest httpRequest = HttpRequest.builder().url(TestConstants.HOST + TestConstants.PUT_ENDPOINT) - .body(body).httpMethod(HttpRequest.PUT).requestHeaders(this.context.getAuthHeaders()) - .build(); - HttpResponse response = HttpClientFactory.getInstance().send(httpRequest); - this.context.setHttpResponse(response); - String newId = "OSDUTest:testSource:" + entityVal +":" + currentMajorVersion + "." - + currentMinorVersion + "." + currentPatchVersion; - this.context.setSchemaIdFromInputPayload(newId); - }); - - Given("I hit schema service PUT API with {string} with next major version", - (String inputPayload) -> { - - String body = this.context.getFileUtils().read(inputPayload); - JsonElement jsonBody = new Gson().fromJson(body, JsonElement.class); - int currentMinorVersion = Integer.parseInt(this.context.getSchemaVersionMinor()); - int currentMajorVersion = Integer.parseInt(this.context.getSchemaVersionMajor()); - currentMajorVersion = currentMajorVersion + 1; - String id = "OSDUTest:testSource:testEntity:" + currentMajorVersion + "." - + currentMinorVersion + ".0"; - updateVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, id); - this.context.setSchemaIdFromInputPayload(id); - body = new Gson().toJson(jsonBody); - Map<String, String> headers = this.context.getAuthHeaders(); - HttpRequest httpRequest = HttpRequest.builder().url(TestConstants.HOST + TestConstants.PUT_ENDPOINT) - .body(body).httpMethod(HttpRequest.PUT).requestHeaders(this.context.getAuthHeaders()) - .build(); - HttpResponse response = HttpClientFactory.getInstance().send(httpRequest); - this.context.setHttpResponse(response); - }); - - Then("put schema service should respond back with {string}", (String ReponseStatusCode) -> { - HttpResponse response = this.context.getHttpResponse(); - assertEquals(ReponseStatusCode, String.valueOf(response.getCode())); - }); - - Then("service should respond back with {string} and {string} and scope whould be {string}", - (String ReponseStatusCode, String ResponseMessage, String scope) -> { - String body = this.context.getFileUtils().read(ResponseMessage); - JsonObject jsonBody = new Gson().fromJson(body, JsonObject.class); - HttpResponse response = this.context.getHttpResponse(); - if (response != null) { - assertEquals(ReponseStatusCode, String.valueOf(response.getCode())); - - commonAssertion(response, jsonBody); - - Assert.assertNotNull(jsonBody.get(TestConstants.DATE_CREATED)); - Assert.assertNotNull(jsonBody.get(TestConstants.CREATED_BY)); - } - }); - - Then("service should respond back with error {string} and {string}", - (String ReponseStatusCode, String ResponseToBeVerified) -> { - HttpResponse response = this.context.getHttpResponse(); - assertEquals(ReponseStatusCode, String.valueOf(response.getCode())); - String body = this.context.getFileUtils().read(ResponseToBeVerified); - Gson gsn = new Gson(); - JsonObject expectedData = gsn.fromJson(body, JsonObject.class); - JsonObject responseMsg = gsn.fromJson(response.getBody().toString(), JsonObject.class); - if(!response.getBody().isEmpty()) - assertEquals(expectedData.toString(), responseMsg.toString()); - - }); - - Then("service should respond back with {string} and {string}", - (String ReponseStatusCode, String ResponseMessage) -> { - String body = this.context.getFileUtils().read(ResponseMessage); - JsonObject jsonBody = new Gson().fromJson(body, JsonObject.class); - HttpResponse response = this.context.getHttpResponse(); - if (response != null) { - assertEquals(ReponseStatusCode, String.valueOf(response.getCode())); - commonAssertion(response, jsonBody); - Assert.assertNotNull(jsonBody.get(TestConstants.DATE_CREATED)); - Assert.assertNotNull(jsonBody.get(TestConstants.CREATED_BY)); - } - }); - - Then("the put service for supersededBy should respond back with {string}", - (String ReponseStatusCode) -> { - HttpResponse response = this.context.getHttpResponse(); - if (response != null) { - assertEquals(ReponseStatusCode, String.valueOf(response.getCode())); - Assert.assertNotNull(getResponseValue(TestConstants.SUPERSEDED_BY)); - assertEquals( - getResponseValue(TestConstants.SCHEMA_IDENTITY + TestConstants.DOT + TestConstants.ID), - this.context.getSchemaIdFromInputPayload()); - assertEquals( - getResponseValue(TestConstants.SUPERSEDED_BY + TestConstants.DOT + TestConstants.ID), - this.context.getSupersededById()); - } - }); - - Given("I hit schema service PUT API for supersededBy with {string}", - (String inputPayload) -> { - String body = this.context.getFileUtils().read(inputPayload); - - JsonElement jsonBody = new Gson().fromJson(body, JsonElement.class); - int currentMinorVersion = Integer.parseInt(this.context.getSchemaVersionMinor()); - int currentMajorVersion = Integer.parseInt(this.context.getSchemaVersionMajor()); - int currentPatchVersion = Integer.parseInt(this.context.getSchemaVersionPatch()); - String supersededById = "OSDUTest:testSource:testEntity:" + currentMajorVersion + "." - + currentMinorVersion + "." + currentPatchVersion; - updateSupersededByInJsonBody(jsonBody, supersededById, currentMajorVersion, currentMinorVersion, - currentPatchVersion); - this.context.setSupersededById(supersededById); - int nextMinorVersion = currentMinorVersion + 1; - int nextMajorVersion = currentMajorVersion + 1; - String schemaId = "OSDUTest:testSource:testEntity:" + nextMajorVersion + "." - + nextMinorVersion + ".0"; - this.context.setSchemaIdFromInputPayload(schemaId); - updateVersionInJsonBody(jsonBody, nextMinorVersion, nextMajorVersion, schemaId); - body = new Gson().toJson(jsonBody); - Map<String, String> headers = this.context.getAuthHeaders(); - HttpRequest httpRequest = HttpRequest.builder().url(TestConstants.HOST + TestConstants.PUT_ENDPOINT) - .body(body).httpMethod(HttpRequest.PUT).requestHeaders(this.context.getAuthHeaders()) - .build(); - HttpResponse response = HttpClientFactory.getInstance().send(httpRequest); - this.context.setHttpResponse(response); - }); - } - - private void updateVersionInJsonBody(JsonElement jsonBody, int nextMinorVersion, int nextMajorVersion, String id) { - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject() - .remove("schemaVersionMinor"); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject() - .addProperty("schemaVersionMinor", nextMinorVersion); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject() - .remove("schemaVersionMajor"); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject() - .addProperty("schemaVersionMajor", nextMajorVersion); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject().remove("id"); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject() - .addProperty("id", id); - } - - public void prepareSchemaParameterMapList() throws IOException { - String response = this.context.getHttpResponse().getBody(); - Gson gsn = new Gson(); - JsonObject root = gsn.fromJson(response, JsonObject.class); - JsonObject schemaIdentity_ForEachSchemaInfo = (JsonObject) root.get("schemaIdentity"); - this.context.setSchemaVersionMajor(schemaIdentity_ForEachSchemaInfo.get("schemaVersionMajor").getAsString()); - this.context.setSchemaVersionMinor(schemaIdentity_ForEachSchemaInfo.get("schemaVersionMinor").getAsString()); - } - - private void commonAssertion(HttpResponse response, JsonObject jsonBody) { - - assertEquals(getExpectedValue(jsonBody, TestConstants.SCHEMA_IDENTITY, TestConstants.AUTHORITY), - getResponseValue(TestConstants.SCHEMA_IDENTITY + TestConstants.DOT + TestConstants.AUTHORITY)); - - assertEquals(getExpectedValue(jsonBody, TestConstants.SCHEMA_IDENTITY, TestConstants.SOURCE), - getResponseValue(TestConstants.SCHEMA_IDENTITY + TestConstants.DOT + TestConstants.SOURCE)); - - assertEquals(getExpectedValue(jsonBody, TestConstants.SCHEMA_IDENTITY, TestConstants.ENTITY), - getResponseValue(TestConstants.SCHEMA_IDENTITY + TestConstants.DOT + TestConstants.ENTITY)); - - Assert.assertNotNull(jsonBody.get(TestConstants.DATE_CREATED)); - Assert.assertNotNull(jsonBody.get(TestConstants.CREATED_BY)); - } - - private String getExpectedValue(JsonObject jsonBody, String parentAttributeValue, String valueToBeRetrieved) { - String value; - if (parentAttributeValue == null) { - value = jsonBody.get(valueToBeRetrieved).toString(); - return value.substring(1, value.length() - 1); - } else { - value = jsonBody.getAsJsonObject(parentAttributeValue).get(valueToBeRetrieved).toString(); - if (Character.isDigit(value.charAt(0))) { - return value; - } else { - return value.substring(1, value.length() - 1); - } - } - } - - private String getResponseValue(String responseAttribute) { - return JsonUtils.getAsJsonPath(this.context.getHttpResponse().getBody().toString()).get(responseAttribute) - .toString(); - } - - private void updateSupersededByInJsonBody(JsonElement jsonBody, String id, int majorVersion, int minorVersion, - int patchVersion) { - - JsonElement supersededByBody = new Gson().fromJson(jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo") - .getAsJsonObject(TestConstants.SCHEMA_IDENTITY).toString(), JsonElement.class); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").add(TestConstants.SUPERSEDED_BY, supersededByBody); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject(TestConstants.SUPERSEDED_BY) - .remove(TestConstants.ID); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject(TestConstants.SUPERSEDED_BY) - .addProperty(TestConstants.ID, id); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject(TestConstants.SUPERSEDED_BY) - .remove(TestConstants.SCHEMA_MAJOR_VERSION); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject(TestConstants.SUPERSEDED_BY) - .addProperty(TestConstants.SCHEMA_MAJOR_VERSION, majorVersion); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject(TestConstants.SUPERSEDED_BY) - .remove(TestConstants.SCHEMA_MINOR_VERSION); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject(TestConstants.SUPERSEDED_BY) - .addProperty(TestConstants.SCHEMA_MINOR_VERSION, minorVersion); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject(TestConstants.SUPERSEDED_BY) - .remove(TestConstants.SCHEMA_PATCH_VERSION); - jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject(TestConstants.SUPERSEDED_BY) - .addProperty(TestConstants.SCHEMA_PATCH_VERSION, patchVersion); - } -} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/TearDownStepDefs.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/TearDownStepDefs.java deleted file mode 100644 index cd2d0bbf1b101187957e1f8954f6bedc7e14fa31..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/TearDownStepDefs.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.opengroup.osdu.schema.stepdefs; - -public class TearDownStepDefs { - -} diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/model/HttpRequest.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/model/HttpRequest.java deleted file mode 100644 index b29857a31a213ae7a7c5d02ad0cd92d615d3fd77..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/model/HttpRequest.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.opengroup.osdu.schema.stepdefs.model; - - - -import lombok.Builder; -import lombok.Data; - -import java.util.HashMap; -import java.util.Map; - -@Builder -@Data -public class HttpRequest { - public static final String PATCH = "PATCH"; - public static final String POST = "POST"; - public static final String PUT = "PUT"; - public static final String GET = "GET"; - public static final String DELETE = "DELETE"; - - String httpMethod; - String url; - String body; - - @Builder.Default - Map<String, String> requestHeaders = new HashMap<>(); - - @Builder.Default - Map<String, ?> queryParams = new HashMap<>(); - - @Builder.Default - Map<String, ?> pathParams = new HashMap<>(); - - @Override - public String toString() { - return String.format("%s, httpMethod=%s", url, httpMethod); - } -} diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/model/HttpResponse.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/model/HttpResponse.java deleted file mode 100644 index a162b40f1254708ec9df50db3d61df9eb4c1ba8f..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/model/HttpResponse.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.opengroup.osdu.schema.stepdefs.model; -import lombok.Builder; -import lombok.Data; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Data -@Builder -public class HttpResponse { - @Builder.Default - Map<String, List<String>> responseHeaders = new HashMap<>(); - private int code; - private Exception exception; - private String body; -} diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/model/SchemaServiceScope.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/model/SchemaServiceScope.java deleted file mode 100644 index 471f34a7421dcc4fe4e01832f6aac01b966c7dae..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/model/SchemaServiceScope.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.opengroup.osdu.schema.stepdefs.model; - -import java.util.Map; - -import org.opengroup.osdu.schema.util.FileUtils; - -import com.google.inject.Inject; - -import io.cucumber.guice.ScenarioScoped; - -import lombok.Data; - -@ScenarioScoped -@Data -public class SchemaServiceScope { - - @Inject - private FileUtils fileUtils; - - private String token; - private String jobId; - private String schemaVersionMinor; - private String schemaVersionMajor; - private String schemaVersionPatch; - private HttpResponse httpResponse; - private String jsonPayloadForPostPUT; - private String status; - - private Map<String, String> authHeaders; - private Map<String, String> queryParams; - private String SchemaIdFromInputPayload; - private String SchemaFromInputPayload; - private String supersededById; - - public String getToken() { - return token; - } - - public void setToken(String token) { - this.token = token; - } - - public void setJsonPayloadForPostPUT(String jsonPayloadForPostPUT) { - this.jsonPayloadForPostPUT = jsonPayloadForPostPUT; - } - - public String getJsonPayloadForPostPUT() { - return jsonPayloadForPostPUT; - } - - public String getSchemaVersionMinor() { - return schemaVersionMinor; - } - - public void setSchemaIdFromInputPayload(String schemaId) { - this.SchemaIdFromInputPayload = schemaId; - } - - public void setSchemaVersionMinor(String schemaVersionMinor) { - this.schemaVersionMinor = schemaVersionMinor; - } - - public String getSchemaVersionMajor() { - return schemaVersionMajor; - } - - - public void getSchemaVersionMajor(String schemaVersionMajor) { - this.schemaVersionMajor = schemaVersionMajor; - } - - public String getSchemaVersionPatch() { - return schemaVersionPatch; - } - - - public void getSchemaVersionPatch(String schemaVersionPatch) { - this.schemaVersionPatch = schemaVersionPatch; - } - - public String getJobId() { - return jobId; - } - - public void setJobId(String jobId) { - this.jobId = jobId; - } - - public HttpResponse getHttpResponse() { - return httpResponse; - } - - public void setHttpResponse(HttpResponse httpResponse) { - this.httpResponse = httpResponse; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - -} diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/AuthUtil.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/AuthUtil.java deleted file mode 100644 index 72ecdb9a486b63b3d9ebdb5e0ea4953a58dd215a..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/AuthUtil.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.opengroup.osdu.schema.util; - -import com.google.common.base.Strings; -import org.opengroup.osdu.azure.util.AzureServicePrincipal; -import org.opengroup.osdu.core.aws.cognito.AWSCognitoClient; -import org.opengroup.osdu.core.ibm.util.IdentityClient; - - -public class AuthUtil { - public synchronized String getToken() throws Exception { - String token = null; - String vendor = System.getProperty("VENDOR", System.getenv("VENDOR")); - if (Strings.isNullOrEmpty(token) && vendor.equals("azure")) { - String sp_id = System.getProperty("INTEGRATION_TESTER", System.getenv("INTEGRATION_TESTER")); - String sp_secret = System.getProperty("TESTER_SERVICEPRINCIPAL_SECRET", System.getenv("TESTER_SERVICEPRINCIPAL_SECRET")); - String tenant_id = System.getProperty("AZURE_AD_TENANT_ID", System.getenv("AZURE_AD_TENANT_ID")); - String app_resource_id = System.getProperty("AZURE_AD_APP_RESOURCE_ID", System.getenv("AZURE_AD_APP_RESOURCE_ID")); - token = new AzureServicePrincipal().getIdToken(sp_id, sp_secret, tenant_id, app_resource_id); - } - return "Bearer " + token; - } -} diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/FileUtils.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/FileUtils.java deleted file mode 100644 index 4da7d9b2e57f9993b400c4f22173b3c65c28c228..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/FileUtils.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.opengroup.osdu.schema.util; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Collection; - -public class FileUtils { - - public String read(String filePath) throws IOException { - - InputStream inStream = this.getClass().getResourceAsStream(filePath); - BufferedReader br = new BufferedReader(new InputStreamReader(inStream)); - StringBuilder stringBuilder = new StringBuilder(); - - String eachLine = ""; - while((eachLine = br.readLine()) != null){ - stringBuilder.append(eachLine); - } - - return stringBuilder.toString(); - } - - public static boolean isNullOrEmpty( final Collection< ? > c ) { - return c == null || c.isEmpty(); - } -} diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/HttpClient.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/HttpClient.java deleted file mode 100644 index aaeb18eab394e6e3bdace99fbd20b74f469ee1ee..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/HttpClient.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.opengroup.osdu.schema.util; - -import org.opengroup.osdu.schema.stepdefs.model.HttpRequest; -import org.opengroup.osdu.schema.stepdefs.model.HttpResponse; - -public interface HttpClient { - HttpResponse send(HttpRequest httpRequest); - - <T> T send(HttpRequest httpRequest, Class<T> classOfT); -} diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/HttpClientFactory.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/HttpClientFactory.java deleted file mode 100644 index 8b5a8d6f1dcc0081ff82a3ed59684a00376b3934..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/HttpClientFactory.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.opengroup.osdu.schema.util; - -public class HttpClientFactory { - private static HttpClient httpClient = null; - - public static HttpClient getInstance() { - if (httpClient == null) { - httpClient = new RestAssuredClient(); - } - return httpClient; - } -} diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/JsonUtils.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/JsonUtils.java deleted file mode 100644 index 5e29093f0de01f0cc22ac3d205cc28220768f446..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/JsonUtils.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.opengroup.osdu.schema.util; - -import com.google.gson.Gson; - -import io.restassured.path.json.JsonPath; - -public class JsonUtils { - public static String toJson(Object src) { - return new Gson().toJson(src); - } - - public static <T> T fromJson(String json, Class<T> classOfT) { - return new Gson().fromJson(json, classOfT); - } - - public static JsonPath getAsJsonPath(String src) { - return JsonPath.with(src); - } -} diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/RestAssuredClient.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/RestAssuredClient.java deleted file mode 100644 index 6d5b96a1c6d05a704a40b9d0348642a47be12d2d..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/RestAssuredClient.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.opengroup.osdu.schema.util; - -import static io.restassured.RestAssured.given; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.opengroup.osdu.schema.constants.HttpConnection; -import org.opengroup.osdu.schema.stepdefs.model.HttpRequest; -import org.opengroup.osdu.schema.stepdefs.model.HttpResponse; - -import io.restassured.RestAssured; -import io.restassured.builder.RequestSpecBuilder; -import io.restassured.config.HttpClientConfig; -import io.restassured.config.RedirectConfig; -import io.restassured.filter.log.LogDetail; -import io.restassured.filter.log.RequestLoggingFilter; -import io.restassured.filter.log.ResponseLoggingFilter; -import io.restassured.http.Header; -import io.restassured.response.Response; -import io.restassured.specification.RequestSpecification; - -public class RestAssuredClient implements HttpClient { - RestAssuredClient() { - // Due to a known issue in RestAssured the following deprecated methods has to - // be used - // https://github.com/rest-assured/rest-assured/issues/497#issuecomment-143404851 - RestAssured.config = RestAssured.config().httpClient(HttpClientConfig.httpClientConfig() - .setParam(HttpConnection.HTTP_CONNECTION_TIMEOUT, HttpConnection.CONNECTION_TIMEOUT_IN_MILLISECONDS) - .setParam(HttpConnection.HTTP_SOCKET_TIMEOUT, HttpConnection.CONNECTION_TIMEOUT_IN_MILLISECONDS)) - .redirect(RedirectConfig.redirectConfig().followRedirects(HttpConnection.FOLLOW_REDIRECTS)); - RestAssured.urlEncodingEnabled = false; - } - - private RequestSpecification getRequestSpecification(HttpRequest httpRequest) { - return new RequestSpecBuilder().setBaseUri(httpRequest.getUrl()).addHeaders(httpRequest.getRequestHeaders()) - .addQueryParams(httpRequest.getQueryParams()).addPathParams(httpRequest.getPathParams()) - .addFilter(new RequestLoggingFilter(LogDetail.URI)).addFilter(new ResponseLoggingFilter(LogDetail.BODY)) - .build(); - } - - private HttpResponse getHttpResponse(Response response) { - final Map<String, List<String>> responseHeaders = response.getHeaders().asList().stream().collect( - Collectors.groupingBy(Header::getName, Collectors.mapping(Header::getValue, Collectors.toList()))); - - return HttpResponse.builder().code(response.getStatusCode()).responseHeaders(responseHeaders) - .body(response.body().asString()).build(); - } - - @Override - public HttpResponse send(HttpRequest httpRequest) { - RequestSpecification requestSpecification = getRequestSpecification(httpRequest); - - if (httpRequest.getBody() != null) { - requestSpecification.body(httpRequest.getBody()); - } - - try { - Response response = given(requestSpecification).request(httpRequest.getHttpMethod()).then().extract() - .response(); - return getHttpResponse(response); - } catch (Exception e) { - return HttpResponse.builder().exception(e).build(); - } - } - - @Override - public <T> T send(HttpRequest httpRequest, Class<T> classOfT) { - HttpResponse httpResponse = send(httpRequest); - return JsonUtils.fromJson(httpResponse.getBody(), classOfT); - } -} diff --git a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/VersionInfoUtils.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/VersionInfoUtils.java deleted file mode 100644 index 8036ae8957cc5896c4882ed41de522ffad9de403..0000000000000000000000000000000000000000 --- a/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/VersionInfoUtils.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.opengroup.osdu.schema.util; - -import com.google.gson.Gson; -import org.opengroup.osdu.schema.stepdefs.model.HttpResponse; - -public class VersionInfoUtils { - - public VersionInfo getVersionInfoFromResponse(HttpResponse response) { - String json = response.getBody(); - Gson gson = new Gson(); - return gson.fromJson(json, VersionInfo.class); - } - - public class VersionInfo { - - public String groupId; - public String artifactId; - public String version; - public String buildTime; - public String branch; - public String commitId; - public String commitMessage; - } -}