diff --git a/.fossa.yml b/.fossa.yml index 32d19a541d8dfca8bc9f128ac8fc0cc5e0bbe2e2..a9719274d776645c7f6fa92872e51731afbfd2b7 100644 --- a/.fossa.yml +++ b/.fossa.yml @@ -44,6 +44,10 @@ analyze: type: pip target: deployments/scripts/google path: deployments/scripts/google + - name: ibm + type: pip + target: deployments/scripts/ibm + path: deployments/scripts/ibm - name: scripts type: pip target: deployments/scripts diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 45339b7bc036d3b66343bd6c3b80d421e84e0dc7..2d686bd42b5e030a5262168c5dd51156fd7bfc40 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,6 +17,7 @@ variables: AZURE_SERVICE: schema AZURE_BUILD_SUBDIR: provider/schema-azure AZURE_TEST_SUBDIR: testing/schema-test-core + AZURE_ONLY_TEST_SUBDIR: testing/schema-test-azure AZURE_DEPLOYMENTS_SUBDIR: deployments/scripts/azure AZURE_DEPLOYMENTS_SCRIPTS_SUBDIR: deployments/scripts AZURE_CLIENT_ID: $AZURE_PRINCIPAL_ID @@ -37,7 +38,10 @@ variables: OSDU_GCP_VENDOR: gcp OSDU_GCP_APPLICATION_NAME: os-schema OSDU_GCP_TESTS_SUBDIR: testing/schema-test-core - OSDU_GCP_ENV_VARS: AUTHORIZE_API=$OSDU_GCP_ENTITLEMENTS_URL,AUTHORIZE_API_KEY=$OSDU_GCP_AUTHORIZE_API_KEY,LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_WEB=DEBUG,SHARED_TENANT_NAME=$TENANT,PARTITION_API=$OSDU_GCP_PARTITION_API,GOOGLE_AUDIENCES=$GOOGLE_AUDIENCE --vpc-connector=$OSDU_GCP_VPC_CONNECTOR + OSDU_GCP_ENV_VARS: AUTHORIZE_API=$OSDU_GCP_ENTITLEMENTS_V2_URL,AUTHORIZE_API_KEY=$OSDU_GCP_AUTHORIZE_API_KEY,LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_WEB=DEBUG,SHARED_TENANT_NAME=$TENANT,PARTITION_API=$OSDU_GCP_PARTITION_API,GOOGLE_AUDIENCES=$GOOGLE_AUDIENCE --vpc-connector=$OSDU_GCP_VPC_CONNECTOR + OSDU_GCP_HELM_PACKAGE_CHARTS: "devops/gcp/deploy devops/gcp/configmap" + OSDU_GCP_DEPLOYMENTS_SUBDIR: deployments/scripts/google + OSDU_GCP_DEPLOYMENTS_SCRIPTS_SUBDIR: deployments/scripts include: - project: "osdu/platform/ci-cd-pipelines" @@ -68,6 +72,7 @@ include: - local: "/devops/azure/gitlab-bootstrap.yml" - local: "/devops/aws/bootstrap.yaml" - local: "/devops/ibm/bootstrap.yaml" + - local: "/devops/gcp/bootstrap.yaml" osdu-gcp-test: image: maven:3.6.3-jdk-8 diff --git a/NOTICE b/NOTICE index 4465e330da2938afe1276ac2d2b4d54631800ad1..9ef326602603e0f7bfdc3a14ad8492cc5aa08997 100644 --- a/NOTICE +++ b/NOTICE @@ -9,13 +9,6 @@ The following software have components provided under the terms of this license: - Android SDK (from https://www.android.com/) -======================================================================== -Apache-1.1 -======================================================================== -The following software have components provided under the terms of this license: - -- StAX (from http://stax.codehaus.org/) - ======================================================================== Apache-2.0 ======================================================================== @@ -29,18 +22,18 @@ The following software have components provided under the terms of this license: - ASM based accessors helper used by json-smart (from ) - AWS Event Stream (from https://github.com/awslabs/aws-eventstream-java) - AWS Java SDK :: AWS Core (from https://aws.amazon.com/sdkforjava) -- AWS Java SDK :: Annotations (from ) +- AWS Java SDK :: Annotations (from https://repo1.maven.org/maven2/software/amazon/awssdk/annotations) - AWS Java SDK :: Auth (from https://aws.amazon.com/sdkforjava) - AWS Java SDK :: Core :: Protocols :: AWS Json Protocol (from https://aws.amazon.com/sdkforjava) - AWS Java SDK :: Core :: Protocols :: Protocol Core (from https://aws.amazon.com/sdkforjava) -- AWS Java SDK :: HTTP Client Interface (from ) -- AWS Java SDK :: HTTP Clients :: Apache (from ) -- AWS Java SDK :: HTTP Clients :: Netty Non-Blocking I/O (from ) +- AWS Java SDK :: HTTP Client Interface (from https://repo1.maven.org/maven2/software/amazon/awssdk/http-client-spi) +- AWS Java SDK :: HTTP Clients :: Apache (from https://repo1.maven.org/maven2/software/amazon/awssdk/apache-client) +- AWS Java SDK :: HTTP Clients :: Netty Non-Blocking I/O (from https://repo1.maven.org/maven2/software/amazon/awssdk/netty-nio-client) - AWS Java SDK :: Profiles (from https://aws.amazon.com/sdkforjava) -- AWS Java SDK :: Regions (from ) +- AWS Java SDK :: Regions (from https://repo1.maven.org/maven2/software/amazon/awssdk/regions) - AWS Java SDK :: SDK Core (from https://aws.amazon.com/sdkforjava) - AWS Java SDK :: Services :: AWS Simple Systems Management (SSM) (from https://aws.amazon.com/sdkforjava) -- AWS Java SDK :: Utilities (from ) +- AWS Java SDK :: Utilities (from https://repo1.maven.org/maven2/software/amazon/awssdk/utils) - AWS Java SDK for AWS Amplify (from https://aws.amazon.com/sdkforjava) - AWS Java SDK for AWS App Mesh (from https://aws.amazon.com/sdkforjava) - AWS Java SDK for AWS AppSync (from https://aws.amazon.com/sdkforjava) @@ -299,10 +292,11 @@ The following software have components provided under the terms of this license: - AWS Java SDK for the Amazon EC2 Container Service (from https://aws.amazon.com/sdkforjava) - AWS SDK for Java - Core (from https://aws.amazon.com/sdkforjava) - AWS SDK for Java - Models (from https://aws.amazon.com/sdkforjava) -- Adapter: RxJava (from ) -- Apache Commons Codec (from http://commons.apache.org/proper/commons-codec/) -- Apache Commons Collections (from http://commons.apache.org/proper/commons-collections/) -- Apache Commons Lang (from http://commons.apache.org/proper/commons-lang/) +- Adapter: RxJava (from https://repo1.maven.org/maven2/com/squareup/retrofit2/adapter-rxjava) +- Apache Commons Codec (from https://commons.apache.org/proper/commons-codec/) +- Apache Commons Collections (from https://commons.apache.org/proper/commons-collections/) +- Apache Commons Lang (from https://commons.apache.org/proper/commons-lang/) +- Apache Commons Lang (from https://commons.apache.org/proper/commons-lang/) - Apache Commons Logging (from http://commons.apache.org/proper/commons-logging/) - Apache Commons Logging (from http://commons.apache.org/proper/commons-logging/) - Apache Geronimo JMS Spec 2.0 (from http://geronimo.apache.org/maven/${siteId}/${version}) @@ -311,96 +305,93 @@ The following software have components provided under the terms of this license: - Apache HttpClient Cache (from http://hc.apache.org/httpcomponents-client) - Apache HttpCore (from http://hc.apache.org/httpcomponents-core-ga) - Apache HttpCore NIO (from http://hc.apache.org/httpcomponents-core-ga) -- Apache Log4j API (from ) -- Apache Log4j Core (from ) -- Apache Log4j JUL Adapter (from ) -- Apache Log4j SLF4J Binding (from ) -- Apache Log4j to SLF4J Adapter (from ) -- AssertJ fluent assertions (from ) -- Asynchronous Http Client (from ) -- Asynchronous Http Client Netty Utils (from ) -- AutoValue Annotations (from ) -- Azure AD Spring Security Integration Spring Boot Starter (from https://github.com/Microsoft/azure-spring-boot) -- Azure Metrics Spring Boot Starter (from https://github.com/Microsoft/azure-spring-boot) +- Apache Log4j API (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-api) +- Apache Log4j Core (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core) +- Apache Log4j JUL Adapter (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-jul) +- Apache Log4j SLF4J Binding (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-slf4j-impl) +- Apache Log4j to SLF4J Adapter (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-to-slf4j) +- AssertJ fluent assertions (from https://repo1.maven.org/maven2/org/assertj/assertj-core) +- AssertJ fluent assertions (from https://repo1.maven.org/maven2/org/assertj/assertj-core) +- Asynchronous Http Client (from https://repo1.maven.org/maven2/org/asynchttpclient/async-http-client) +- Asynchronous Http Client Netty Utils (from https://repo1.maven.org/maven2/org/asynchttpclient/async-http-client-netty-utils) +- AutoValue Annotations (from https://github.com/google/auto/tree/master/value) +- Azure Spring Boot Starter for Azure AD Spring Security Integration (from https://github.com/Azure/azure-sdk-for-java) +- Bean Validation API (from http://beanvalidation.org) - Bean Validation API (from http://beanvalidation.org) -- Byte Buddy (without dependencies) (from ) -- Byte Buddy Java agent (from ) +- Brave (from https://repo1.maven.org/maven2/io/zipkin/brave/brave) +- Brave Instrumentation: Http Adapters (from https://repo1.maven.org/maven2/io/zipkin/brave/brave-instrumentation-http) +- Brave instrumentation for Reactor Netty HTTP (from https://github.com/reactor/reactor-netty) +- Byte Buddy (without dependencies) (from https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy) +- Byte Buddy Java agent (from https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy-agent) - ClassMate (from http://github.com/cowtowncoder/java-classmate) -- Cloud Storage JSON API v1-rev58-1.21.0 (from ) +- Cloud Storage JSON API v1-rev20210127-1.32.1 (from https://repo1.maven.org/maven2/com/google/apis/google-api-services-storage) - CloudWatch Metrics for AWS Java SDK (from https://aws.amazon.com/sdkforjava) -- Commons IO (from http://commons.apache.org/io/) -- Converter: Jackson (from ) +- Converter: Jackson (from https://repo1.maven.org/maven2/com/squareup/retrofit2/converter-jackson) +- Core functionality for the Reactor Netty library (from https://github.com/reactor/reactor-netty) - Elastic JNA Distribution (from https://github.com/java-native-access/jna) -- Elasticsearch: 5.0.0-alpha5 (from https://github.com/elastic/elasticsearch) - Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) - FindBugs-jsr305 (from http://findbugs.sourceforge.net/) -- Google APIs Client Library for Java (from ) -- Google App Engine extensions to the Google HTTP Client Library for Java. (from ) -- Google Cloud Core (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-core) -- Google Cloud Core HTTP (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-core-http) -- Google Cloud Core gRPC (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-core-grpc) +- 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 Common Protos for Java (from https://github.com/googleapis/common-protos-java) +- Google Cloud Core (from https://github.com/googleapis/java-core) +- Google Cloud Core HTTP (from https://github.com/googleapis/java-core) +- Google Cloud Core gRPC (from https://github.com/googleapis/java-core) - Google Cloud Datastore (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-datastore) -- Google Cloud Key Management Service (KMS) API v1-rev22-1.23.0 (from ) +- Google Cloud Key Management Service (KMS) API v1-rev9-1.22.0 (from https://repo1.maven.org/maven2/com/google/apis/google-api-services-cloudkms) - Google Cloud Logging (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-logging) -- Google Cloud Pub/Sub (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-pubsub) -- Google Cloud Storage (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-storage) +- Google Cloud Pub/Sub (from https://github.com/googleapis/java-pubsub) +- Google Cloud Storage (from https://github.com/googleapis/java-storage) - Google Guice - Core Library (from ) -- Google HTTP Client Library for Java (from https://github.com/google/google-http-java-client.git) -- Google HTTP Client Library for Java (from https://github.com/google/google-http-java-client.git) -- Google OAuth Client Library for Java (from ) +- Google HTTP Client Library for Java (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client) +- Google HTTP Client Library for Java (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client) +- Google OAuth Client Library for Java (from https://repo1.maven.org/maven2/com/google/oauth-client/google-oauth-client) - Gson (from https://github.com/google/gson) -- Guava InternalFutureFailureAccess and InternalFutures (from ) -- Guava ListenableFuture only (from ) -- Guava: Google Core Libraries for Java (from https://github.com/google/guava.git) -- Guava: Google Core Libraries for Java (from https://github.com/google/guava.git) -- Guava: Google Core Libraries for Java (from https://github.com/google/guava.git) -- HPPC Collections (from http://labs.carrotsearch.com) -- Hibernate Validator Engine (from ) -- Hibernate Validator Engine (from ) +- Guava InternalFutureFailureAccess and InternalFutures (from https://repo1.maven.org/maven2/com/google/guava/failureaccess) +- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) +- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) +- HPPC Collections (from https://repo1.maven.org/maven2/com/carrotsearch/hppc) +- HTTP functionality for the Reactor Netty library (from https://github.com/reactor/reactor-netty) +- Hibernate Validator Engine (from https://repo1.maven.org/maven2/org/hibernate/validator/hibernate-validator) +- Hibernate Validator Engine (from https://repo1.maven.org/maven2/org/hibernate/validator/hibernate-validator) - IBM COS Java SDK for Amazon S3 (from https://github.com/ibm/ibm-cos-sdk-java) - IBM COS Java SDK for COS KMS (from https://github.com/ibm/ibm-cos-sdk-java) - IBM COS SDK For Java (from https://github.com/ibm/ibm-cos-sdk-java) - IBM COS SDK for Java - Core (from https://github.com/ibm/ibm-cos-sdk-java) +- IO (from http://jakarta.apache.org/commons/${pom.artifactId.substring(8)}/) - Identity and Access Management (IAM) API v1-rev247-1.23.0 (from ) - IntelliJ IDEA Annotations (from http://www.jetbrains.org) - J2ObjC Annotations (from https://github.com/google/j2objc/) - JBoss Logging 3 (from http://www.jboss.org) - JCIP Annotations under Apache License (from http://stephenc.github.com/jcip-annotations) - JMES Path Query library (from https://aws.amazon.com/sdkforjava) -- JSON Small and Fast Parser (from http://www.minidev.net/) -- JSON Small and Fast Parser (from http://www.minidev.net/) -- JSON Web Token support for the JVM (from https://github.com/jwtk/jjwt.git) +- JSON Small and Fast Parser (from https://repo1.maven.org/maven2/net/minidev/json-smart) +- JSON Small and Fast Parser (from https://repo1.maven.org/maven2/net/minidev/json-smart) +- JSON Web Token support for the JVM (from https://github.com/jwtk/jjwt) - JSON library from Android SDK (from http://developer.android.com/sdk) - JSONassert (from https://github.com/skyscreamer/JSONassert) -- Jackson 2 extensions to the Google HTTP Client Library for Java. (from https://github.com/google/google-http-java-client.git/google-http-client-jackson2) +- Jackson 2 extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-jackson2) - Jackson dataformat: CBOR (from http://github.com/FasterXML/jackson-dataformats-binary) - Jackson dataformat: CBOR (from http://github.com/FasterXML/jackson-dataformats-binary) -- Jackson datatype: JSR310 (from http://wiki.fasterxml.com/JacksonModuleJSR310) -- Jackson datatype: JSR310 (from http://wiki.fasterxml.com/JacksonModuleJSR310) +- Jackson dataformat: Smile (from http://github.com/FasterXML/jackson-dataformats-binary) +- Jackson datatype: JSR310 (from https://repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jsr310) +- Jackson datatype: Joda (from https://github.com/FasterXML/jackson-datatype-joda) +- Jackson datatype: jdk8 (from https://repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jdk8) +- Jackson module: Afterburner (from https://github.com/FasterXML/jackson-modules-base) +- Jackson module: JAXB-annotations (from http://github.com/FasterXML/jackson-module-jaxb-annotations) - Jackson-annotations (from http://github.com/FasterXML/jackson) -- Jackson-annotations (from http://github.com/FasterXML/jackson) -- Jackson-core (from https://github.com/FasterXML/jackson-core) - Jackson-core (from https://github.com/FasterXML/jackson-core) -- Jackson-dataformat-Smile (from http://github.com/FasterXML/jackson-dataformat-smile) - Jackson-dataformat-XML (from http://wiki.fasterxml.com/JacksonExtensionXmlDataBinding) -- Jackson-dataformat-YAML (from https://github.com/FasterXML/jackson) -- Jackson-dataformat-YAML (from https://github.com/FasterXML/jackson) -- Jackson-datatype-Joda (from http://wiki.fasterxml.com/JacksonModuleJoda) -- Jackson-datatype-jdk8 (from ) -- Jackson-datatype-jdk8 (from ) -- Jackson-module-Afterburner (from http://wiki.fasterxml.com/JacksonHome) -- Jackson-module-JAXB-annotations (from http://wiki.fasterxml.com/JacksonJAXBAnnotations) -- Jackson-module-parameter-names (from ) -- Jackson-module-parameter-names (from ) -- Jakarta Bean Validation API (from https://beanvalidation.org) +- Jackson-dataformat-YAML (from https://github.com/FasterXML/jackson-dataformats-text) +- Jackson-module-parameter-names (from https://repo1.maven.org/maven2/com/fasterxml/jackson/module/jackson-module-parameter-names) - Java Libraries for Amazon Simple WorkFlow (from https://aws.amazon.com/sdkforjava) - Java Native Access (from https://github.com/java-native-access/jna) - Java Native Access Platform (from https://github.com/java-native-access/jna) - Java UUID Generator (from http://wiki.fasterxml.com/JugHome) - Javassist (from http://www.javassist.org/) -- Joda-Time (from http://www.joda.org/joda-time/) -- Joda-Time (from http://www.joda.org/joda-time/) -- Joda-Time (from http://www.joda.org/joda-time/) +- Joda-Time (from https://www.joda.org/joda-time/) +- Joda-Time (from https://www.joda.org/joda-time/) +- Joda-Time (from https://www.joda.org/joda-time/) - Json Path (from https://github.com/jayway/JsonPath) - KeePassJava2 :: All (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2) - KeePassJava2 :: DOM (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2-dom) @@ -408,26 +399,27 @@ The following software have components provided under the terms of this license: - KeePassJava2 :: KDB (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2-kdb) - KeePassJava2 :: KDBX (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2-kdbx) - KeePassJava2 :: Simple (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2-simple) +- Kotlin Stdlib (from https://kotlinlang.org/) +- Kotlin Stdlib Common (from https://kotlinlang.org/) - Logback Contrib :: JSON :: Classic (from ) - Logback Contrib :: JSON :: Core (from ) - Logback Contrib :: Jackson (from ) -- Lucene Common Analyzers (from ) -- Lucene Core (from ) -- Lucene Grouping (from ) -- Lucene Highlighter (from ) -- Lucene Join (from ) -- Lucene Memory (from ) -- Lucene Memory (from ) -- Lucene Miscellaneous (from ) -- Lucene Queries (from ) -- Lucene QueryParsers (from ) -- Lucene Sandbox (from ) -- Lucene Spatial (from ) -- Lucene Spatial 3D (from ) -- Lucene Spatial Extras (from ) -- Lucene Suggest (from ) -- MapStruct Core (from ) -- Metrics Core (from https://github.com/dropwizard/metrics) +- Lucene Common Analyzers (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-analyzers-common) +- Lucene Core (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-core) +- Lucene Grouping (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-grouping) +- Lucene Highlighter (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-highlighter) +- Lucene Join (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-join) +- Lucene Memory (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-memory) +- Lucene Memory (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-backward-codecs) +- Lucene Miscellaneous (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-misc) +- Lucene Queries (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-queries) +- Lucene QueryParsers (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-queryparser) +- Lucene Sandbox (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-sandbox) +- Lucene Spatial 3D (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-spatial3d) +- Lucene Spatial Extras (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-spatial-extras) +- Lucene Suggest (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-suggest) +- MapStruct Core (from https://repo1.maven.org/maven2/org/mapstruct/mapstruct) +- Metrics Core (from https://repo1.maven.org/maven2/io/dropwizard/metrics/metrics-core) - Microsoft Application Insights Java SDK Core (from https://github.com/Microsoft/ApplicationInsights-Java) - 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) @@ -435,109 +427,126 @@ The following software have components provided under the terms of this license: - Microsoft Azure Java Core Library (from https://github.com/Azure/azure-sdk-for-java) - Microsoft Azure Netty HTTP Client Library (from https://github.com/Azure/azure-sdk-for-java) - Microsoft Azure SDK for SQL API of Azure Cosmos DB Service (from https://github.com/Azure/azure-sdk-for-java) -- Mockito (from http://mockito.org) - Mockito (from http://www.mockito.org) -- Netty Reactive Streams HTTP support (from ) -- Netty Reactive Streams Implementation (from ) -- Netty/Buffer (from http://netty.io/) -- Netty/Buffer (from http://netty.io/) -- Netty/Codec (from ) -- Netty/Codec (from ) -- Netty/Codec/HTTP (from ) -- Netty/Codec/HTTP (from ) -- Netty/Codec/HTTP2 (from ) -- Netty/Codec/HTTP2 (from ) -- Netty/Codec/Socks (from ) -- Netty/Common (from ) -- Netty/Common (from ) -- Netty/Handler (from ) -- Netty/Handler (from ) -- Netty/Handler/Proxy (from ) -- Netty/Resolver (from ) -- Netty/Resolver (from ) -- Netty/TomcatNative [BoringSSL - Static] (from ) -- Netty/Transport (from http://netty.io/) -- Netty/Transport (from http://netty.io/) -- Netty/Transport/Native/Unix/Common (from ) -- Netty/Transport/Native/Unix/Common (from ) +- Netty Reactive Streams HTTP support (from https://repo1.maven.org/maven2/com/typesafe/netty/netty-reactive-streams-http) +- Netty Reactive Streams Implementation (from https://repo1.maven.org/maven2/com/typesafe/netty/netty-reactive-streams) +- Netty/Buffer (from https://repo1.maven.org/maven2/io/netty/netty-buffer) +- Netty/Codec (from https://repo1.maven.org/maven2/io/netty/netty-codec) +- Netty/Codec/DNS (from https://repo1.maven.org/maven2/io/netty/netty-codec-dns) +- Netty/Codec/HTTP (from https://repo1.maven.org/maven2/io/netty/netty-codec-http) +- Netty/Codec/HTTP2 (from https://repo1.maven.org/maven2/io/netty/netty-codec-http2) +- Netty/Codec/Socks (from https://repo1.maven.org/maven2/io/netty/netty-codec-socks) +- Netty/Common (from https://repo1.maven.org/maven2/io/netty/netty-common) +- Netty/Handler (from https://repo1.maven.org/maven2/io/netty/netty-handler) +- Netty/Handler/Proxy (from https://repo1.maven.org/maven2/io/netty/netty-handler-proxy) +- Netty/Resolver (from https://repo1.maven.org/maven2/io/netty/netty-resolver) +- Netty/Resolver/DNS (from https://repo1.maven.org/maven2/io/netty/netty-resolver-dns) +- Netty/TomcatNative [BoringSSL - Static] (from https://repo1.maven.org/maven2/io/netty/netty-tcnative-boringssl-static) +- Netty/Transport (from https://repo1.maven.org/maven2/io/netty/netty-transport) +- Netty/Transport/Native/Unix/Common (from https://repo1.maven.org/maven2/io/netty/netty-transport-native-unix-common) +- Nimbus Content Type (from https://bitbucket.org/connect2id/nimbus-content-type) - Nimbus Content Type (from https://bitbucket.org/connect2id/nimbus-content-type) - Nimbus JOSE+JWT (from https://bitbucket.org/connect2id/nimbus-jose-jwt) +- Nimbus JOSE+JWT (from https://bitbucket.org/connect2id/nimbus-jose-jwt) - Nimbus LangTag (from https://bitbucket.org/connect2id/nimbus-language-tags) -- Non-Blocking Reactive Foundation for the JVM (from https://github.com/reactor/reactor) +- Non-Blocking Reactive Foundation for the JVM (from https://github.com/reactor/reactor-core) +- OAuth 2.0 SDK with OpenID Connect extensions (from https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions) - OAuth 2.0 SDK with OpenID Connect extensions (from https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions) - Objenesis (from http://objenesis.org) -- OkHttp (from ) -- OkHttp Logging Interceptor (from ) -- OkHttp URLConnection (from ) -- Okio (from ) -- Okio (from ) +- Objenesis (from http://objenesis.org) +- Okio (from https://github.com/square/okio/) +- Okio (from https://github.com/square/okio/) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) - PWDB :: Database (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/database) -- Protocol Buffer extensions to the Google HTTP Client Library for Java. (from ) +- Protocol Buffer extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-protobuf) +- Proton-J (from https://repo1.maven.org/maven2/org/apache/qpid/proton-j) - QpidJMS Client (from ) - Reactive Streams Netty driver (from https://github.com/reactor/reactor-netty) -- Retrofit (from ) -- Simple XML (from http://simple.sourceforge.net) -- SnakeYAML (from http://www.snakeyaml.org) +- Retrofit (from https://github.com/square/retrofit) +- SnakeYAML (from http://code.google.com/p/snakeyaml/) +- Spring AOP (from https://github.com/spring-projects/spring-framework) - Spring AOP (from https://github.com/spring-projects/spring-framework) - Spring Beans (from https://github.com/spring-projects/spring-framework) -- Spring Boot (from http://projects.spring.io/spring-boot/) -- Spring Boot Actuator (from http://projects.spring.io/spring-boot/) +- Spring Beans (from https://github.com/spring-projects/spring-framework) +- Spring Boot (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot) +- Spring Boot (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot) +- Spring Boot Actuator (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-actuator) +- Spring Boot Actuator (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-actuator) - Spring Boot Actuator AutoConfigure (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-actuator-autoconfigure) -- Spring Boot Actuator Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot AutoConfigure (from http://projects.spring.io/spring-boot/) -- Spring Boot Dependencies (from http://projects.spring.io/spring-boot/) -- Spring Boot Dependencies (from http://projects.spring.io/spring-boot/) +- Spring Boot Actuator AutoConfigure (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-actuator-autoconfigure) +- Spring Boot Actuator Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-actuator) +- Spring Boot Actuator Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-actuator) +- Spring Boot AutoConfigure (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-autoconfigure) +- Spring Boot AutoConfigure (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-autoconfigure) +- Spring Boot Dependencies (from https://projects.spring.io/spring-boot/#) +- Spring Boot Dependencies (from https://projects.spring.io/spring-boot/#) +- Spring Boot Json Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-json) - Spring Boot Json Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-json) -- Spring Boot Log4J2 Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Logging Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Security Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Test (from http://projects.spring.io/spring-boot/) -- Spring Boot Test Auto-Configure (from http://projects.spring.io/spring-boot/) -- Spring Boot Test Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Tomcat Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Validation Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Web Starter (from http://projects.spring.io/spring-boot/) +- Spring Boot Logging Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-logging) +- Spring Boot Security Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-security) +- Spring Boot Security Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-security) +- Spring Boot Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter) +- Spring Boot Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter) +- Spring Boot Test (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-test) +- Spring Boot Test (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-test) +- Spring Boot Test Auto-Configure (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-test-autoconfigure) +- Spring Boot Test Auto-Configure (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-test-autoconfigure) +- Spring Boot Test Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-test) +- Spring Boot Test Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-test) +- Spring Boot Tomcat Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-tomcat) +- Spring Boot Tomcat Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-tomcat) +- Spring Boot Validation Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-validation) +- Spring Boot Validation Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-validation) +- Spring Boot Web Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-web) +- Spring Boot Web Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-web) - Spring Commons Logging Bridge (from https://github.com/spring-projects/spring-framework) +- Spring Commons Logging Bridge (from https://github.com/spring-projects/spring-framework) +- Spring Context (from https://github.com/spring-projects/spring-framework) - Spring Context (from https://github.com/spring-projects/spring-framework) - Spring Core (from https://github.com/spring-projects/spring-framework) -- Spring Data Core (from ) +- Spring Core (from https://github.com/spring-projects/spring-framework) +- Spring Data Core (from https://repo1.maven.org/maven2/org/springframework/data/spring-data-commons) +- Spring Expression Language (SpEL) (from https://github.com/spring-projects/spring-framework) - Spring Expression Language (SpEL) (from https://github.com/spring-projects/spring-framework) - Spring JMS (from https://github.com/spring-projects/spring-framework) - Spring Messaging (from https://github.com/spring-projects/spring-framework) - Spring Plugin - Core (from ) -- Spring Plugin - Metadata Extension (from ) +- Spring Plugin - Metadata Extension (from https://repo1.maven.org/maven2/org/springframework/plugin/spring-plugin-metadata) +- Spring TestContext Framework (from https://github.com/spring-projects/spring-framework) - Spring TestContext Framework (from https://github.com/spring-projects/spring-framework) - Spring Transaction (from https://github.com/spring-projects/spring-framework) +- Spring Transaction (from https://github.com/spring-projects/spring-framework) +- Spring Web (from https://github.com/spring-projects/spring-framework) - Spring Web (from https://github.com/spring-projects/spring-framework) - Spring Web MVC (from https://github.com/spring-projects/spring-framework) -- StAX (from http://stax.codehaus.org/) -- StAX API (from http://stax.codehaus.org/) +- Spring Web MVC (from https://github.com/spring-projects/spring-framework) +- Spring WebFlux (from https://github.com/spring-projects/spring-framework) - T-Digest (from https://github.com/tdunning/t-digest) - TypeTools (from http://github.com/jhalterman/typetools/) - Woodstox (from https://github.com/FasterXML/woodstox) +- Zipkin Core Library (from https://repo1.maven.org/maven2/io/zipkin/zipkin2/zipkin) +- Zipkin Reporter Brave (from https://repo1.maven.org/maven2/io/zipkin/reporter2/zipkin-reporter-brave) +- Zipkin Reporter: Core (from https://repo1.maven.org/maven2/io/zipkin/reporter2/zipkin-reporter) - aalto-xml (from ) - aggs-matrix-stats (from https://github.com/elastic/elasticsearch) - aws-ssm-java-caching-client (from https://github.com/awslabs/aws-ssm-java-caching-client) - boto3 (from https://github.com/boto/boto3) - botocore (from https://github.com/boto/botocore) -- cli (from https://github.com/elastic/elasticsearch) - com.google.api.grpc:grpc-google-cloud-pubsub-v1 (from https://github.com/googleapis/googleapis) - com.google.api.grpc:proto-google-cloud-logging-v2 (from https://github.com/googleapis/googleapis) -- com.google.api.grpc:proto-google-cloud-pubsub-v1 (from https://github.com/googleapis/googleapis) -- com.google.api.grpc:proto-google-common-protos (from https://github.com/googleapis/googleapis) -- com.google.api.grpc:proto-google-iam-v1 (from https://github.com/googleapis/googleapis) - compiler (from http://github.com/spullara/mustache.java) - datastore-v1-proto-client (from ) +- elasticsearch-cli (from https://github.com/elastic/elasticsearch) - elasticsearch-core (from https://github.com/elastic/elasticsearch) - elasticsearch-geo (from https://github.com/elastic/elasticsearch) -- error-prone annotations (from ) -- error-prone annotations (from ) +- elasticsearch-secure-sm (from https://github.com/elastic/elasticsearch) +- elasticsearch-x-content (from https://github.com/elastic/elasticsearch) +- error-prone annotations (from https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations) +- error-prone annotations (from https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations) - google-auth (from https://github.com/GoogleCloudPlatform/google-auth-library-python) - io.grpc:grpc-alts (from https://github.com/grpc/grpc-java) - io.grpc:grpc-api (from https://github.com/grpc/grpc-java) @@ -553,37 +562,48 @@ The following software have components provided under the terms of this license: - ion-java (from https://github.com/amznlabs/ion-java/) - ion-java (from https://github.com/amznlabs/ion-java/) - jackson-databind (from http://github.com/FasterXML/jackson) -- jackson-databind (from http://github.com/FasterXML/jackson) - java-cloudant (from https://cloudant.com) - java-cloudant (from https://cloudant.com) - javatuples (from http://www.javatuples.org) - javax.inject (from http://code.google.com/p/atinject/) - jose4j (from https://bitbucket.org/b_c/jose4j/) -- kotlin-stdlib (from ) - lang-mustache (from https://github.com/elastic/elasticsearch) - lettuce (from http://github.com/mp911de/lettuce/wiki) - mapper-extras (from https://github.com/elastic/elasticsearch) - micrometer-core (from https://github.com/micrometer-metrics/micrometer) +- micrometer-core (from https://github.com/micrometer-metrics/micrometer) - micrometer-registry-azure-monitor (from https://github.com/micrometer-metrics/micrometer) +- mockito-core (from https://github.com/mockito/mockito) +- mockito-core (from https://github.com/mockito/mockito) +- okhttp (from https://square.github.io/okhttp/) +- okhttp-logging-interceptor (from https://square.github.io/okhttp/) +- okhttp-urlconnection (from https://github.com/square/okhttp) - org.apiguardian:apiguardian-api (from https://github.com/apiguardian-team/apiguardian) -- org.jetbrains.kotlin:kotlin-stdlib-common (from https://kotlinlang.org/) - org.opentest4j:opentest4j (from https://github.com/ota4j-team/opentest4j) - org.xmlunit:xmlunit-core (from http://www.xmlunit.org/) - parent-join (from https://github.com/elastic/elasticsearch) - proto-google-cloud-datastore-v1 (from https://github.com/googleapis/api-client-staging) -- proton-j (from ) +- proto-google-cloud-pubsub-v1 (from https://github.com/googleapis/java-pubsub/proto-google-cloud-pubsub-v1) +- proto-google-iam-v1 (from https://github.com/googleapis/java-iam/proto-google-iam-v1) - rank-eval (from https://github.com/elastic/elasticsearch) - requests (from http://python-requests.org) - rest (from https://github.com/elastic/elasticsearch) +- rest (from https://github.com/elastic/elasticsearch) - rest-high-level (from https://github.com/elastic/elasticsearch) - rxjava (from https://github.com/ReactiveX/RxJava) -- secure-sm (from https://github.com/elastic/elasticsearch) +- server (from https://github.com/elastic/elasticsearch) +- spring-boot-starter-log4j2 (from https://spring.io/projects/spring-boot) +- spring-boot-starter-reactor-netty (from https://spring.io/projects/spring-boot) +- spring-boot-starter-webflux (from https://spring.io/projects/spring-boot) +- spring-security-config (from http://spring.io/spring-security) - spring-security-config (from http://spring.io/spring-security) - spring-security-core (from http://spring.io/spring-security) +- spring-security-core (from http://spring.io/spring-security) - spring-security-oauth2-core (from http://spring.io/spring-security) - spring-security-oauth2-jose (from http://spring.io/spring-security) - spring-security-oauth2-resource-server (from http://spring.io/spring-security) - spring-security-web (from http://spring.io/spring-security) +- spring-security-web (from http://spring.io/spring-security) - springfox-core (from https://github.com/springfox/springfox) - springfox-schema (from https://github.com/springfox/springfox) - springfox-spi (from https://github.com/springfox/springfox) @@ -591,27 +611,27 @@ The following software have components provided under the terms of this license: - springfox-swagger-common (from https://github.com/springfox/springfox) - springfox-swagger-ui (from https://github.com/springfox/springfox) - springfox-swagger2 (from https://github.com/springfox/springfox) -- swagger-annotations (from ) +- swagger-annotations (from https://repo1.maven.org/maven2/io/swagger/swagger-annotations) - swagger-jaxrs (from ) -- swagger-models (from ) +- swagger-models (from https://repo1.maven.org/maven2/io/swagger/swagger-models) - tomcat-embed-core (from http://tomcat.apache.org/) -- tomcat-embed-websocket (from http://tomcat.apache.org/) -- x-content (from https://github.com/elastic/elasticsearch) +- tomcat-embed-websocket (from https://tomcat.apache.org/) ======================================================================== BSD-2-Clause ======================================================================== The following software have components provided under the terms of this license: -- API Common (from https://github.com/googleapis) -- GAX (Google Api eXtensions) (from https://github.com/googleapis) -- GAX (Google Api eXtensions) (from https://github.com/googleapis) -- GAX (Google Api eXtensions) (from https://github.com/googleapis) +- API Common (from https://github.com/googleapis/api-common-java) +- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) +- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) +- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) - Hamcrest (from http://hamcrest.org/JavaHamcrest/) - Hamcrest Core (from http://hamcrest.org/) - HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) -- Lucene Common Analyzers (from ) -- StAX (from http://stax.codehaus.org/) +- Lucene Common Analyzers (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-analyzers-common) +- Lucene Core (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-core) +- Reflections (from http://github.com/ronmamo/reflections) - Stax2 API (from http://github.com/FasterXML/stax2-api) - ThreeTen backport (from https://www.threeten.org/threetenbp) @@ -620,37 +640,35 @@ BSD-3-Clause ======================================================================== The following software have components provided under the terms of this license: -- API Common (from https://github.com/googleapis) +- API Common (from https://github.com/googleapis/api-common-java) - ASM Core (from ) - ASM Core (from ) -- Apache Commons Codec (from http://commons.apache.org/proper/commons-codec/) -- GAX (Google Api eXtensions) (from https://github.com/googleapis) -- GAX (Google Api eXtensions) (from https://github.com/googleapis) -- GAX (Google Api eXtensions) (from https://github.com/googleapis) -- Google APIs Client Library for Java (from ) -- Google Auth Library for Java - Credentials (from ) -- Google Auth Library for Java - OAuth2 HTTP (from ) +- Apache Commons Codec (from https://commons.apache.org/proper/commons-codec/) +- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) +- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) +- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) +- Google APIs Client Library for Java (from https://repo1.maven.org/maven2/com/google/api-client/google-api-client) +- Google Auth Library for Java - Credentials (from https://repo1.maven.org/maven2/com/google/auth/google-auth-library-credentials) +- Google Auth Library for Java - OAuth2 HTTP (from https://repo1.maven.org/maven2/com/google/auth/google-auth-library-oauth2-http) - Hamcrest (from http://hamcrest.org/JavaHamcrest/) - Hamcrest Core (from http://hamcrest.org/) - HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) - JavaBeans Activation Framework API jar (from ) -- Lucene Common Analyzers (from ) -- Lucene Core (from ) -- Lucene Suggest (from ) +- Lucene Common Analyzers (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-analyzers-common) +- Lucene Core (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-core) +- Lucene Suggest (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-suggest) - Microsoft Application Insights Java SDK Core (from https://github.com/Microsoft/ApplicationInsights-Java) - 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) - Mockito (from http://www.mockito.org) -- NanoHttpd-Core (from ) -- Netty/Codec/HTTP (from ) -- Netty/Codec/HTTP (from ) -- Protocol Buffer Java API (from https://developers.google.com/protocol-buffers/) -- Protocol Buffers [Util] (from ) +- Netty/Codec/HTTP (from https://repo1.maven.org/maven2/io/netty/netty-codec-http) +- Protocol Buffers [Core] (from 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) - Reflections (from http://github.com/ronmamo/reflections) -- SnakeYAML (from http://www.snakeyaml.org) +- SnakeYAML (from http://code.google.com/p/snakeyaml/) +- Spring Core (from https://github.com/spring-projects/spring-framework) - Spring Core (from https://github.com/spring-projects/spring-framework) -- Stax2 API (from http://github.com/FasterXML/stax2-api) - ThreeTen backport (from https://www.threeten.org/threetenbp) - google (from http://breakingcode.wordpress.com/) - jakarta.xml.bind-api (from ) @@ -679,21 +697,18 @@ The following software have components provided under the terms of this license: - reactive-streams (from http://www.reactive-streams.org/) -======================================================================== -CDDL-1.0 -======================================================================== -The following software have components provided under the terms of this license: - -- JavaMail API (from ) -- javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250) - ======================================================================== CDDL-1.1 ======================================================================== The following software have components provided under the terms of this license: +- JSR 353 (JSON Processing) API (from http://json-processing-spec.java.net) +- JSR 353 (JSON Processing) API (from http://json-processing-spec.java.net) +- JSR 353 (JSON Processing) Default Provider (from http://jsonp.java.net) - JavaBeans Activation Framework (from ) - JavaBeans(TM) Activation Framework (from http://java.sun.com/javase/technologies/desktop/javabeans/jaf/index.jsp) +- JavaMail API (from https://repo1.maven.org/maven2/com/sun/mail/javax.mail) +- javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250) - tomcat-embed-core (from http://tomcat.apache.org/) ======================================================================== @@ -704,6 +719,14 @@ The following software have components provided under the terms of this license: - JUnit (from http://junit.org) - JUnit (from http://junit.org) +======================================================================== +DOC +======================================================================== +The following software have components provided under the terms of this license: + +- Lucene Core (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-core) +- Woodstox (from https://github.com/FasterXML/woodstox) + ======================================================================== EPL-1.0 ======================================================================== @@ -711,21 +734,27 @@ The following software have components provided under the terms of this license: - Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) - JUnit Jupiter (Aggregator) (from https://junit.org/junit5/) -- Logback Classic Module (from ) +- JUnit Jupiter (Aggregator) (from https://junit.org/junit5/) +- JUnit Jupiter API (from https://junit.org/junit5/) +- JUnit Jupiter API (from https://junit.org/junit5/) +- JUnit Jupiter Engine (from https://junit.org/junit5/) +- JUnit Jupiter Engine (from https://junit.org/junit5/) +- JUnit Jupiter Params (from https://junit.org/junit5/) +- JUnit Jupiter Params (from https://junit.org/junit5/) +- Logback Classic Module (from https://repo1.maven.org/maven2/ch/qos/logback/logback-classic) - Logback Contrib :: JSON :: Classic (from ) - Logback Contrib :: JSON :: Core (from ) - Logback Contrib :: Jackson (from ) -- Logback Core Module (from ) +- Logback Core Module (from https://repo1.maven.org/maven2/ch/qos/logback/logback-core) - Microsoft Application Insights Java SDK Core (from https://github.com/Microsoft/ApplicationInsights-Java) - 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://www.snakeyaml.org) +- SnakeYAML (from http://code.google.com/p/snakeyaml/) - jakarta.annotation-api (from https://projects.eclipse.org/projects/ee4j.ca) -- org.junit.jupiter:junit-jupiter-api (from http://junit.org/junit5/) -- org.junit.jupiter:junit-jupiter-engine (from http://junit.org/junit5/) -- org.junit.jupiter:junit-jupiter-params (from http://junit.org/junit5/) - org.junit.platform:junit-platform-commons (from http://junit.org/junit5/) +- org.junit.platform:junit-platform-commons (from http://junit.org/junit5/) +- org.junit.platform:junit-platform-engine (from http://junit.org/junit5/) - org.junit.platform:junit-platform-engine (from http://junit.org/junit5/) - org.junit.vintage:junit-vintage-engine (from http://junit.org/junit5/) @@ -736,12 +765,18 @@ The following software have components provided under the terms of this license: - Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) - JUnit Jupiter (Aggregator) (from https://junit.org/junit5/) +- JUnit Jupiter (Aggregator) (from https://junit.org/junit5/) +- JUnit Jupiter API (from https://junit.org/junit5/) +- JUnit Jupiter API (from https://junit.org/junit5/) +- JUnit Jupiter Engine (from https://junit.org/junit5/) +- JUnit Jupiter Engine (from https://junit.org/junit5/) +- JUnit Jupiter Params (from https://junit.org/junit5/) +- JUnit Jupiter Params (from https://junit.org/junit5/) - jakarta.annotation-api (from https://projects.eclipse.org/projects/ee4j.ca) -- org.junit.jupiter:junit-jupiter-api (from http://junit.org/junit5/) -- org.junit.jupiter:junit-jupiter-engine (from http://junit.org/junit5/) -- org.junit.jupiter:junit-jupiter-params (from http://junit.org/junit5/) +- org.junit.platform:junit-platform-commons (from http://junit.org/junit5/) - org.junit.platform:junit-platform-commons (from http://junit.org/junit5/) - org.junit.platform:junit-platform-engine (from http://junit.org/junit5/) +- org.junit.platform:junit-platform-engine (from http://junit.org/junit5/) - org.junit.vintage:junit-vintage-engine (from http://junit.org/junit5/) ======================================================================== @@ -749,8 +784,10 @@ GPL-2.0-only ======================================================================== The following software have components provided under the terms of this license: +- JSR 353 (JSON Processing) API (from http://json-processing-spec.java.net) +- JSR 353 (JSON Processing) API (from http://json-processing-spec.java.net) +- JSR 353 (JSON Processing) Default Provider (from http://jsonp.java.net) - JavaBeans Activation Framework (from ) -- JavaMail API (from ) - javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250) - tomcat-embed-core (from http://tomcat.apache.org/) @@ -759,7 +796,7 @@ GPL-2.0-or-later ======================================================================== The following software have components provided under the terms of this license: -- SnakeYAML (from http://www.snakeyaml.org) +- SnakeYAML (from http://code.google.com/p/snakeyaml/) ======================================================================== GPL-2.0-with-classpath-exception @@ -768,8 +805,10 @@ The following software have components provided under the terms of this license: - Checker Qual (from https://checkerframework.org) - Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) +- JSR 353 (JSON Processing) API (from http://json-processing-spec.java.net) +- JSR 353 (JSON Processing) API (from http://json-processing-spec.java.net) +- JSR 353 (JSON Processing) Default Provider (from http://jsonp.java.net) - JavaBeans Activation Framework (from ) -- JavaMail API (from ) - jakarta.annotation-api (from https://projects.eclipse.org/projects/ee4j.ca) - javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250) - tomcat-embed-core (from http://tomcat.apache.org/) @@ -784,6 +823,14 @@ The following software have components provided under the terms of this license: - Project Lombok (from https://projectlombok.org) - jakarta.annotation-api (from https://projects.eclipse.org/projects/ee4j.ca) +======================================================================== +ImageMagick +======================================================================== +The following software have components provided under the terms of this license: + +- Stax2 API (from http://github.com/FasterXML/stax2-api) +- Woodstox (from https://github.com/FasterXML/woodstox) + ======================================================================== JSON ======================================================================== @@ -800,11 +847,11 @@ The following software have components provided under the terms of this license: - Java Native Access (from https://github.com/java-native-access/jna) - Java Native Access Platform (from https://github.com/java-native-access/jna) - Javassist (from http://www.javassist.org/) -- Logback Classic Module (from ) +- Logback Classic Module (from https://repo1.maven.org/maven2/ch/qos/logback/logback-classic) - Logback Contrib :: JSON :: Classic (from ) - Logback Contrib :: JSON :: Core (from ) - Logback Contrib :: Jackson (from ) -- Logback Core Module (from ) +- Logback Core Module (from https://repo1.maven.org/maven2/ch/qos/logback/logback-core) - Microsoft Application Insights Java SDK Core (from https://github.com/Microsoft/ApplicationInsights-Java) - 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) @@ -815,15 +862,16 @@ LGPL-2.1-or-later ======================================================================== The following software have components provided under the terms of this license: -- SnakeYAML (from http://www.snakeyaml.org) +- Javassist (from http://www.javassist.org/) +- SnakeYAML (from http://code.google.com/p/snakeyaml/) ======================================================================== LGPL-3.0-only ======================================================================== The following software have components provided under the terms of this license: -- Apache Log4j API (from ) -- Apache Log4j Core (from ) +- Apache Log4j API (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-api) +- Apache Log4j Core (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core) ======================================================================== MIT @@ -833,24 +881,21 @@ The following software have components provided under the terms of this license: - AWS Java SDK for AWS Lambda (from https://aws.amazon.com/sdkforjava) - AWS Java SDK for AWS License Manager (from https://aws.amazon.com/sdkforjava) - AWS SDK for Java - Models (from https://aws.amazon.com/sdkforjava) -- Animal Sniffer Annotations (from ) -- Azure AD Spring Security Integration Spring Boot Starter (from https://github.com/Microsoft/azure-spring-boot) +- Animal Sniffer Annotations (from https://repo1.maven.org/maven2/org/codehaus/mojo/animal-sniffer-annotations) - Azure Java Client Authentication Library for AutoRest (from https://github.com/Azure/autorest-clientruntime-for-java) - Azure Java Client Runtime for ARM (from https://github.com/Azure/autorest-clientruntime-for-java) - Azure Java Client Runtime for AutoRest (from https://github.com/Azure/autorest-clientruntime-for-java) -- Azure Metrics Spring Boot Starter (from https://github.com/Microsoft/azure-spring-boot) -- Azure Spring Boot AutoConfigure (from https://github.com/Microsoft/azure-spring-boot) -- Checker Qual (from https://checkerframework.org) +- Azure Spring Boot AutoConfigure (from https://github.com/Azure/azure-sdk-for-java) - Checker Qual (from https://checkerframework.org) - Checker Qual (from https://checkerframework.org) - Cucumber Expressions (from https://github.com/cucumber/cucumber-expressions-java) - Cucumber Tag Expressions (from https://github.com/cucumber/tag-expressions-java) -- Cucumber-JVM: Core (from ) +- Cucumber-JVM: Core (from https://repo1.maven.org/maven2/io/cucumber/cucumber-core) - Cucumber-JVM: Docstring (from https://repo1.maven.org/maven2/io/cucumber/docstring) - Cucumber-JVM: Gherkin (from https://repo1.maven.org/maven2/io/cucumber/cucumber-gherkin) - Cucumber-JVM: Gherkin Vintage (from https://repo1.maven.org/maven2/io/cucumber/cucumber-gherkin-vintage) - Cucumber-JVM: Guice (from ) -- Cucumber-JVM: JUnit (from ) +- Cucumber-JVM: JUnit (from https://repo1.maven.org/maven2/io/cucumber/cucumber-junit) - Cucumber-JVM: Java8 (from ) - Cucumber-JVM: Plugin (from https://repo1.maven.org/maven2/io/cucumber/cucumber-plugin) - DataTable (from ) @@ -858,9 +903,7 @@ The following software have components provided under the terms of this license: - JOpt Simple (from http://pholser.github.io/jopt-simple) - JUL to SLF4J bridge (from http://www.slf4j.org) - Java Client Runtime for AutoRest (from https://github.com/Azure/autorest-clientruntime-for-java) -- Java JWT (from http://www.jwt.io) -- Lucene Core (from ) -- Lucene Sandbox (from ) +- Lucene Core (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-core) - Microsoft Application Insights Java SDK Core (from https://github.com/Microsoft/ApplicationInsights-Java) - 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) @@ -878,12 +921,9 @@ The following software have components provided under the terms of this license: - Microsoft Azure client library for KeyVault Secrets (from https://github.com/Azure/azure-sdk-for-java) - Microsoft Azure common module for Storage (from https://github.com/Azure/azure-sdk-for-java) - Microsoft Azure internal Avro module for Storage (from https://github.com/Azure/azure-sdk-for-java) -- Mockito (from http://mockito.org) - Mockito (from http://www.mockito.org) -- Netty/Codec/HTTP (from ) -- Netty/Codec/HTTP (from ) -- Netty/Common (from ) -- Netty/Common (from ) +- Netty/Codec/HTTP (from https://repo1.maven.org/maven2/io/netty/netty-codec-http) +- Netty/Common (from https://repo1.maven.org/maven2/io/netty/netty-common) - Project Lombok (from https://projectlombok.org) - Project Lombok (from https://projectlombok.org) - PyJWT (from http://github.com/jpadilla/pyjwt) @@ -894,13 +934,19 @@ The following software have components provided under the terms of this license: - azure-documentdb (from https://azure.microsoft.com/en-us/services/cosmos-db/) - botocore (from https://github.com/boto/botocore) - documentdb-bulkexecutor (from http://azure.microsoft.com/en-us/services/documentdb/) +- java jwt (from http://www.jwt.io) - micrometer-core (from https://github.com/micrometer-metrics/micrometer) +- micrometer-core (from https://github.com/micrometer-metrics/micrometer) +- mockito-core (from https://github.com/mockito/mockito) +- mockito-core (from https://github.com/mockito/mockito) - mockito-inline (from https://github.com/mockito/mockito) - mockito-junit-jupiter (from https://github.com/mockito/mockito) +- mockito-junit-jupiter (from https://github.com/mockito/mockito) - msal (from https://github.com/AzureAD/microsoft-authentication-library-for-python) - msal4j (from https://github.com/AzureAD/microsoft-authentication-library-for-java) - msal4j-persistence-extension (from https://github.com/AzureAD/microsoft-authentication-extensions-for-java) - spring-security-core (from http://spring.io/spring-security) +- spring-security-core (from http://spring.io/spring-security) ======================================================================== MPL-1.1 @@ -915,7 +961,7 @@ MPL-2.0 The following software have components provided under the terms of this license: - Javassist (from http://www.javassist.org/) -- OkHttp (from ) +- okhttp (from https://square.github.io/okhttp/) ======================================================================== PHP-3.01 @@ -930,10 +976,6 @@ Public-Domain ======================================================================== The following software have components provided under the terms of this license: -- HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) -- Joda-Time (from http://www.joda.org/joda-time/) -- Joda-Time (from http://www.joda.org/joda-time/) -- LatencyUtils (from http://latencyutils.github.io/LatencyUtils/) - Spongy Castle (from http://rtyley.github.io/spongycastle/) ======================================================================== @@ -949,7 +991,13 @@ SPL-1.0 The following software have components provided under the terms of this license: - Checker Qual (from https://checkerframework.org) -- Checker Qual (from https://checkerframework.org) + +======================================================================== +SunPro +======================================================================== +The following software have components provided under the terms of this license: + +- Lucene Core (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-core) ======================================================================== WTFPL @@ -958,6 +1006,13 @@ The following software have components provided under the terms of this license: - Reflections (from http://github.com/ronmamo/reflections) +======================================================================== +X11 +======================================================================== +The following software have components provided under the terms of this license: + +- Lucene Core (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-core) + ======================================================================== public-domain ======================================================================== @@ -966,13 +1021,14 @@ The following software have components provided under the terms of this license: - AOP alliance (from http://aopalliance.sourceforge.net) - AWS Java SDK :: SDK Core (from https://aws.amazon.com/sdkforjava) - AWS SDK for Java - Models (from https://aws.amazon.com/sdkforjava) -- Asynchronous Http Client (from ) -- Guava: Google Core Libraries for Java (from https://github.com/google/guava.git) -- Guava: Google Core Libraries for Java (from https://github.com/google/guava.git) -- Guava: Google Core Libraries for Java (from https://github.com/google/guava.git) +- Asynchronous Http Client (from https://repo1.maven.org/maven2/org/asynchttpclient/async-http-client) +- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) +- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) - HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) - HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) -- Joda-Time (from http://www.joda.org/joda-time/) +- Joda-Time (from https://www.joda.org/joda-time/) +- Joda-Time (from https://www.joda.org/joda-time/) +- Joda-Time (from https://www.joda.org/joda-time/) - LatencyUtils (from http://latencyutils.github.io/LatencyUtils/) - Microsoft Application Insights Java SDK Core (from https://github.com/Microsoft/ApplicationInsights-Java) - Microsoft Azure SDK for EventGrid Management (from https://github.com/Azure/azure-sdk-for-java) @@ -981,7 +1037,7 @@ The following software have components provided under the terms of this license: - Project Lombok (from https://projectlombok.org) - Project Lombok (from https://projectlombok.org) - Spring Web (from https://github.com/spring-projects/spring-framework) -- StAX API (from http://stax.codehaus.org/) +- Spring Web (from https://github.com/spring-projects/spring-framework) - azure-documentdb (from https://azure.microsoft.com/en-us/services/cosmos-db/) - botocore (from https://github.com/boto/botocore) - msal4j (from https://github.com/AzureAD/microsoft-authentication-library-for-java) @@ -992,20 +1048,25 @@ unknown ======================================================================== The following software have components provided under the terms of this license: -- Byte Buddy (without dependencies) (from ) +- Byte Buddy (without dependencies) (from https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy) - Checker Qual (from https://checkerframework.org) - JSON in Java (from https://github.com/douglascrockford/JSON-java) - JUnit (from http://junit.org) - JUnit (from http://junit.org) - JUnit Jupiter (Aggregator) (from https://junit.org/junit5/) +- JUnit Jupiter (Aggregator) (from https://junit.org/junit5/) +- JUnit Jupiter API (from https://junit.org/junit5/) +- JUnit Jupiter API (from https://junit.org/junit5/) +- JUnit Jupiter Engine (from https://junit.org/junit5/) +- JUnit Jupiter Engine (from https://junit.org/junit5/) +- JUnit Jupiter Params (from https://junit.org/junit5/) +- JUnit Jupiter Params (from https://junit.org/junit5/) - JavaBeans Activation Framework API jar (from ) -- JavaMail API (from ) - Spongy Castle (from http://rtyley.github.io/spongycastle/) - jakarta.xml.bind-api (from ) -- org.junit.jupiter:junit-jupiter-api (from http://junit.org/junit5/) -- org.junit.jupiter:junit-jupiter-engine (from http://junit.org/junit5/) -- org.junit.jupiter:junit-jupiter-params (from http://junit.org/junit5/) - org.junit.platform:junit-platform-commons (from http://junit.org/junit5/) +- org.junit.platform:junit-platform-commons (from http://junit.org/junit5/) +- org.junit.platform:junit-platform-engine (from http://junit.org/junit5/) - org.junit.platform:junit-platform-engine (from http://junit.org/junit5/) - org.junit.vintage:junit-vintage-engine (from http://junit.org/junit5/) diff --git a/deployments/scripts/ibm/bootstrap.sh b/deployments/scripts/ibm/bootstrap.sh index 0d67ebd4e9eb0ff5f9b815a21b1a6776f0affc8d..2cfc69688da950879336f9d925368fb9712def72 100644 --- a/deployments/scripts/ibm/bootstrap.sh +++ b/deployments/scripts/ibm/bootstrap.sh @@ -1,6 +1,6 @@ +curl -X DELETE -u $IBM_QA_DB_USER:$IBM_QA_DB_PASSWORD $IBM_QA_DB_URL/oc-cpd-dataecosystem-opendes-schema2 export IBM_SCHEMA_URL=$IBM_SCHEMA_HOST/api/schema-service/v1/schema BEARER_TOKEN=`python $IBM_DEPLOYMENTS_SUBDIR/Token.py` export BEARER_TOKEN=$BEARER_TOKEN echo $BEARER_TOKEN python $IBM_DEPLOYMENTS_SCRIPTS_SUBDIR/DeploySharedSchemas.py -u $IBM_SCHEMA_URL - diff --git a/deployments/shared-schemas/README.md b/deployments/shared-schemas/README.md index f05715b50f97dd4f6d83be4bc21060ca94a5071d..4057d5b4ac64ab352e1b99a29b25ee9d0c3aed00 100644 --- a/deployments/shared-schemas/README.md +++ b/deployments/shared-schemas/README.md @@ -47,7 +47,9 @@ load sequence per schema version. An example can be found ## Upload schema definitions Once the loading instructions are completed, the schema registration can be launched. this is -done via the [DeploySharedSchemas.py](../scripts/DeploySharedSchemas.py): +done via the [DeploySharedSchemas.py](../scripts/DeploySharedSchemas.py). Important parameters, i.e. +the target schema authority and the path to the load-sequence file are in code in `DEFAULT_BOOTSTRAP_OPTIONS` +[Utility.py](../scripts/Utility.py#L18). The DeploySharedSchemas.py options are as follows: ```shell script python deployments\scripts\DeploySharedSchemas.py -h @@ -58,14 +60,11 @@ load sequence file. optional arguments: -h, --help show this help message and exit - -a A The schema authority or partition-id to replace (default via - Env) - -l L The path to the load sequence file, e.g. load_sequence.?.?.? -u U The complete URL to the Schema Service. example: -python deployments\scripts\DeploySharedSchemas.py -l load_sequence.1.0.0.json -a osdu -u https://opengroup.test.org/api/schema-service/v1/schema +python deployments\scripts\DeploySharedSchemas.py -u https://opengroup.test.org/api/schema-service/v1/schema ``` diff --git a/deployments/shared-schemas/osdu/abstract/AbstractActivityParameter.1.0.0.json b/deployments/shared-schemas/osdu/abstract/AbstractActivityParameter.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..44fcff51813696420636f7dfaab39ff078804507 --- /dev/null +++ b/deployments/shared-schemas/osdu/abstract/AbstractActivityParameter.1.0.0.json @@ -0,0 +1,142 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "AbstractActivityParameter", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:AbstractActivityParameter:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "x-osdu-review-status": "Accepted", + "$id": "https://schema.osdu.opengroup.org/json/abstract/AbstractActivityParameter.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:AbstractActivityParameter:1.0.0", + "title": "AbstractActivityParameter", + "description": "General parameter value used in one instance of activity.\n[Without inheritance, combined specializations.]", + "type": "object", + "properties": { + "Title": { + "type": "string", + "title": "Title", + "description": "Name of the parameter, used to identify it in the activity. It must have an equivalent in the ActivityTemplate parameters." + }, + "Index": { + "type": "integer", + "title": "Index", + "description": "When parameter is an array, used to indicate the index in the array." + }, + "Selection": { + "type": "string", + "title": "Selection", + "description": "Textual description about how this parameter was selected." + }, + "Keys": { + "type": "array", + "title": "Keys", + "description": "A nested array describing keys used to identify a parameter value. When multiple values are provided for a given parameter, the key provides a way to identify the parameter through its association with an object, a time index or a parameter array member via ParameterKey value.", + "items": { + "type": "object", + "title": "Parameter Key", + "description": "Abstract class describing a key used to identify a parameter value. When multiple values are provided for a given parameter, provides a way to identify the parameter through its association with an object, a time index... \n[Without inheritance, combined specializations.]", + "properties": { + "ObjectParameterKey": { + "type": "string", + "title": "Object Parameter Key", + "description": "Relationship to an object ID, which acts as the parameter.", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [] + }, + "TimeIndexParameterKey": { + "type": "string", + "title": "Time Index Parameter Key", + "format": "time" + }, + "ParameterKey": { + "type": "string", + "title": "Internal Parameter Key", + "description": "The key name, which establishes an association between parameters." + } + } + } + }, + "DataObjectParameter": { + "type": "string", + "title": "Data Object Parameter", + "description": "Parameter referencing to a top level object.", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [] + }, + "DataQuantityParameter": { + "type": "number", + "title": "Data Quantity Parameter", + "description": "Parameter containing a double value.", + "x-osdu-frame-of-reference": "UOM_via_property:DataQuantityParameterUOMID" + }, + "IntegerQuantityParameter": { + "type": "integer", + "title": "Integer Quantity Parameter", + "description": "Parameter containing an integer value." + }, + "StringParameter": { + "type": "string", + "title": "String Parameter", + "description": "Parameter containing a string value." + }, + "TimeIndexParameter": { + "type": "string", + "title": "Time Index Parameter", + "description": "Parameter containing a time index value. It is assumed that all TimeIndexParameters within an Activity have the same date-time format, which is then described by the FrameOfReference mechanism.", + "format": "date-time", + "x-osdu-frame-of-reference": "DateTime" + }, + "ParameterKindID": { + "type": "string", + "description": "[Added to cover lack of inheritance]", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-ParameterKind:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "ParameterKind" + } + ] + }, + "ParameterRoleID": { + "type": "string", + "title": "Parameter Role", + "description": "Reference data describing how the parameter was used by the activity, such as input, output, control, constraint, agent, predecessor activity, successor activity.", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-ParameterRole:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "ParameterRole" + } + ] + }, + "DataQuantityParameterUOMID": { + "type": "string", + "title": "Data Quantity Parameter UoM ID", + "description": "Identifies unit of measure for floating point value.", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-UnitOfMeasure:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "UnitOfMeasure" + } + ] + } + }, + "required": [ + "Title", + "ParameterKindID" + ], + "x-osdu-inheriting-from-kind": [] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/abstract/AbstractDataset.1.0.0.json b/deployments/shared-schemas/osdu/abstract/AbstractDataset.1.0.0.json index 5b749597abd0ba11022bebf91824d323377b49d1..71066ab24925e944957a68a415327e7355910515 100644 --- a/deployments/shared-schemas/osdu/abstract/AbstractDataset.1.0.0.json +++ b/deployments/shared-schemas/osdu/abstract/AbstractDataset.1.0.0.json @@ -46,7 +46,7 @@ "EncodingFormatTypeID": { "type": "string", "title": "Encoding Format Type ID", - "description": "EncodingFormatType ID reference value relationship. It can me a mime-type or media-type.", + "description": "EncodingFormatType ID reference value relationship. It can be a mime-type or media-type.", "example": "namespace:reference-data--EncodingFormatType:text%2Fcsv:", "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-EncodingFormatType:[\\w\\-\\.\\:\\%]+:[0-9]*$", "x-osdu-relationship": [ diff --git a/deployments/shared-schemas/osdu/abstract/AbstractFacility.1.0.0.json b/deployments/shared-schemas/osdu/abstract/AbstractFacility.1.0.0.json index 75cc409dfcd93979365f44c6bcc07d7b92c32e73..364787c19b12180894eacb092d34eb17f6f537ef 100644 --- a/deployments/shared-schemas/osdu/abstract/AbstractFacility.1.0.0.json +++ b/deployments/shared-schemas/osdu/abstract/AbstractFacility.1.0.0.json @@ -23,7 +23,8 @@ "type": "object", "properties": { "FacilityID": { - "description": "A system-specified unique identifier of a Facility.", + "title": "External Facility Identifier", + "description": "Native identifier from a Master Data Management System or other trusted source external to OSDU - stored here in order to allow for multi-system connection and synchronization. If used, the \"Source\" property should identify that source system.", "type": "string" }, "FacilityTypeID": { diff --git a/deployments/shared-schemas/osdu/abstract/AbstractProject.1.0.0.json b/deployments/shared-schemas/osdu/abstract/AbstractProject.1.0.0.json index afe4ffd2a8a6876cdac7a2d0d618203da219c5e8..fcfcfd4ba384917de1add9e21ebb2355dc51c9b9 100644 --- a/deployments/shared-schemas/osdu/abstract/AbstractProject.1.0.0.json +++ b/deployments/shared-schemas/osdu/abstract/AbstractProject.1.0.0.json @@ -23,7 +23,8 @@ "type": "object", "properties": { "ProjectID": { - "description": "A system-specified unique identifier of a Project.", + "title": "External Project Identifier", + "description": "Native identifier from a Master Data Management System or other trusted source external to OSDU - stored here in order to allow for multi-system connection and synchronization. If used, the \"Source\" property should identify that source system.", "type": "string" }, "ProjectName": { diff --git a/deployments/shared-schemas/osdu/abstract/AbstractProjectActivity.1.0.0.json b/deployments/shared-schemas/osdu/abstract/AbstractProjectActivity.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..c4b36658dd008f4b9f2185f393a48eb92734aca4 --- /dev/null +++ b/deployments/shared-schemas/osdu/abstract/AbstractProjectActivity.1.0.0.json @@ -0,0 +1,68 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "AbstractProjectActivity", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:AbstractProjectActivity:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "x-osdu-review-status": "Accepted", + "$id": "https://schema.osdu.opengroup.org/json/abstract/AbstractProjectActivity.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:AbstractProjectActivity:1.0.0", + "title": "AbstractProjectActivity", + "description": "The activity abstraction for projects and surveys (master-data).", + "type": "object", + "properties": { + "ActivityTemplateID": { + "type": "string", + "title": "Activity Template ID", + "description": "The relation to the ActivityTemplate carrying expected parameter definitions and default values.", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-ActivityTemplate:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "ActivityTemplate" + } + ] + }, + "ParentProjectID": { + "type": "string", + "title": "Parent Project ID", + "description": "The relationship to a parent project acting as a parent activity.", + "pattern": "^[\\w\\-\\.]+:(master-data\\-\\-[\\w\\-\\.]*Project[\\w\\-\\.]*|master-data\\-\\-[\\w\\-\\.]*Survey[\\w\\-\\.]*):[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "*Project*" + }, + { + "GroupType": "master-data", + "EntityType": "*Survey*" + } + ] + }, + "Parameters": { + "type": "array", + "title": "Parameters", + "description": "General parameter value used in one instance of activity. Includes reference to data objects which are inputs and outputs of the activity.", + "x-osdu-indexing": { + "type": "nested" + }, + "items": { + "$ref": "{{schema-authority}}:wks:AbstractActivityParameter:1.0.0" + } + } + }, + "x-osdu-inheriting-from-kind": [] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/abstract/AbstractPropertyType.1.0.0.json b/deployments/shared-schemas/osdu/abstract/AbstractPropertyType.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..989c4107006dc8b70b5610c56a7a4a46f11a7389 --- /dev/null +++ b/deployments/shared-schemas/osdu/abstract/AbstractPropertyType.1.0.0.json @@ -0,0 +1,54 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "AbstractPropertyType", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:AbstractPropertyType:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "x-osdu-review-status": "Accepted", + "$id": "https://schema.osdu.opengroup.org/json/abstract/AbstractPropertyType.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:AbstractPropertyType:1.0.0", + "title": "AbstractPropertyType", + "description": "A nested object holding the relationship to a PropertyType by id (uuid) and a derived, human-readable name.", + "type": "object", + "properties": { + "PropertyTypeID": { + "type": "string", + "title": "Property Type ID", + "description": "The relationship to the PropertyType reference data item, typically containing an Energistics PWLS 3 uuid. For better traceability and usability the property name is to be populated in the Name property.", + "example": "namespace:reference-data--PropertyType:ace68d4c-7400-431d-9a33-0541b8bfc4b4:", + "x-osdu-existing-standard": "Energistics PWLS 3", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-PropertyType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "PropertyType" + } + ] + }, + "Name": { + "type": "string", + "title": "Name", + "description": "The name of the PropertyType, de-normalized, derived from the record referenced in PropertyTypeID.", + "example": "dip azimuth", + "x-osdu-is-derived": { + "RelationshipPropertyName": "PropertyTypeID", + "TargetPropertyName": "Name" + }, + "x-osdu-existing-standard": "Energistics PWLS 3" + } + }, + "x-osdu-inheriting-from-kind": [] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/abstract/AbstractReferencePropertyType.1.0.0.json b/deployments/shared-schemas/osdu/abstract/AbstractReferencePropertyType.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..ce68c883afa57fd925a52bcf45bfed3235de2881 --- /dev/null +++ b/deployments/shared-schemas/osdu/abstract/AbstractReferencePropertyType.1.0.0.json @@ -0,0 +1,75 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "AbstractReferencePropertyType", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:AbstractReferencePropertyType:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "x-osdu-review-status": "Accepted", + "x-osdu-governance-authorities": [ + "OSDU" + ], + "$id": "https://schema.osdu.opengroup.org/json/abstract/AbstractReferencePropertyType.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:AbstractReferencePropertyType:1.0.0", + "title": "AbstractReferencePropertyType", + "description": "The purpose of this schema is best understood in the context of a columnar dataset: the AbstractReferencePropertyType describes a column in a columnar dataset by declaring its value type (number, string), a UnitQuantity if the value type is a number, a kind if the string value is actually a relationship to a e.g. reference-data type.", + "type": "object", + "properties": { + "ValueType": { + "type": "string", + "title": "Value Type", + "description": "The type of value to expect for this reference property, either \"number\" (floating point number), \"integer\", \"string\", or \"boolean\".", + "example": "string" + }, + "ValueCount": { + "type": "integer", + "title": "Value Count", + "description": "The number of values in a tuple, e.g. For coordinates. The default is 1.", + "example": 1, + "default": 1 + }, + "UnitQuantityID": { + "type": "string", + "title": "Unit Quantity ID", + "description": "Only populated of the ValueType is \"number\". It holds the UnitQuantity associated with this reference property type. It is a relationship to UnitQuantity record.", + "example": "namespace:reference-data--UnitQuantity:plane%20angle:", + "x-osdu-existing-standard": "Energistics Unit of Measure V1.0", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-UnitQuantity:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "UnitQuantity" + } + ] + }, + "PropertyType": { + "$ref": "{{schema-authority}}:wks:AbstractPropertyType:1.0.0", + "title": "Property Type", + "description": "It holds the PropertyType associated with this reference property type, further defining the semantics of the value. It contains a relationship to PropertyType record and its (de-normalized) name. String or number values can represent e.g. A date or a time by referring to the respective PropertyType record id.", + "example": { + "PropertyTypeID": "namespace:reference-data--PropertyType:ace68d4c-7400-431d-9a33-0541b8bfc4b4:", + "Name": "dip azimuth" + } + }, + "RelationshipTargetKind": { + "type": "string", + "title": "Relationship Target Kind", + "description": "Only populated if ValueType==\"string\" and the values are expected to represent record ids, e.g. to a reference-data type, then this value holds the kind (optionally without the semantic version number).", + "example": "osdu:wks:reference-data--UnitOfMeasure:", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:([0-9]+)?(\\.)?([0-9]+)?(\\.)?([0-9]+)?$" + } + }, + "x-osdu-inheriting-from-kind": [] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/abstract/AbstractReferenceType.1.0.0.json b/deployments/shared-schemas/osdu/abstract/AbstractReferenceType.1.0.0.json index 6ae725dc8c0ed56c91d3c8ddebebb40844399e4b..56d6a491beec0e8039d6ed81f98ed7695cf2c1c6 100644 --- a/deployments/shared-schemas/osdu/abstract/AbstractReferenceType.1.0.0.json +++ b/deployments/shared-schemas/osdu/abstract/AbstractReferenceType.1.0.0.json @@ -38,7 +38,8 @@ } }, "ID": { - "description": "Surrogate key to uniquely identify an instance in a domain list.", + "title": "External Identifier", + "description": "Native identifier from a Master Data Management System or other trusted source external to OSDU - stored here in order to allow for multi-system connection and synchronization. If used, the \"Source\" property should identify that source system.", "type": "string" }, "InactiveIndicator": { diff --git a/deployments/shared-schemas/osdu/abstract/AbstractWPCActivity.1.0.0.json b/deployments/shared-schemas/osdu/abstract/AbstractWPCActivity.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..ab8c61efdea4a7b68ecb5fc799cf8e0a6730e4b1 --- /dev/null +++ b/deployments/shared-schemas/osdu/abstract/AbstractWPCActivity.1.0.0.json @@ -0,0 +1,123 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "AbstractWPCActivity", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:AbstractWPCActivity:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "x-osdu-review-status": "Accepted", + "$id": "https://schema.osdu.opengroup.org/json/abstract/AbstractWPCActivity.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:AbstractWPCActivity:1.0.0", + "title": "AbstractWPCActivity", + "description": "The activity abstraction included by projects (master-data) and work-product-component group-type specialisations.", + "type": "object", + "properties": { + "ActivityTemplateID": { + "type": "string", + "title": "Activity Template ID", + "description": "The relation to the ActivityTemplate carrying expected parameter definitions and default values.", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-ActivityTemplate:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "ActivityTemplate" + } + ] + }, + "ParentProjectID": { + "type": "string", + "title": "Parent Project ID", + "description": "The relationship to a parent project acting as a parent activity.", + "pattern": "^[\\w\\-\\.]+:(master-data\\-\\-[\\w\\-\\.]*Project[\\w\\-\\.]*|master-data\\-\\-[\\w\\-\\.]*Survey[\\w\\-\\.]*):[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "*Project*" + }, + { + "GroupType": "master-data", + "EntityType": "*Survey*" + } + ] + }, + "ParentActivityID": { + "type": "string", + "title": "Parent Activity ID", + "description": "The relationship to a parent activity.", + "pattern": "^[\\w\\-\\.]+:work-product-component\\-\\-[\\w\\-\\.]*Activity[\\w\\-\\.]*:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "work-product-component", + "EntityType": "*Activity*" + } + ] + }, + "Parameters": { + "type": "array", + "title": "Parameters", + "description": "General parameter value used in one instance of activity. Includes reference to data objects which are inputs and outputs of the activity.", + "x-osdu-indexing": { + "type": "nested" + }, + "items": { + "$ref": "{{schema-authority}}:wks:AbstractActivityParameter:1.0.0" + } + }, + "PriorActivityIDs": { + "type": "array", + "title": "Prior Activity IDs", + "description": "The activity or activities feeding results into this activity instance.", + "items": { + "type": "string", + "pattern": "^[\\w\\-\\.]+:work-product-component\\-\\-[\\w\\-\\.]*Activity[\\w\\-\\.]*:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "work-product-component", + "EntityType": "*Activity*" + } + ] + } + }, + "SoftwareSpecifications": { + "type": "array", + "title": "Software Specifications", + "description": "Software names and versions used.", + "x-osdu-indexing": { + "type": "flattened" + }, + "items": { + "type": "object", + "title": "Software", + "description": "The name and version of the software being executed in the context of this activity", + "properties": { + "SoftwareName": { + "type": "string", + "title": "Software Name", + "description": "The name of the software, application or plug-in used while performing this activity." + }, + "Version": { + "type": "string", + "title": "Software Version", + "description": "The version of the software, application or plug-in used while performing this activity." + } + } + } + } + }, + "required": [ + "Parameters" + ], + "x-osdu-inheriting-from-kind": [] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/load_sequence.1.0.0.json b/deployments/shared-schemas/osdu/load_sequence.1.0.0.json index 82eba9e3932278976f6b3ea02da4824108870bd7..ff95100805d2a85ac515b3ead7e8cf1f297e860b 100644 --- a/deployments/shared-schemas/osdu/load_sequence.1.0.0.json +++ b/deployments/shared-schemas/osdu/load_sequence.1.0.0.json @@ -3,6 +3,10 @@ "kind": "{{schema-authority}}:wks:AbstractAccessControlList:1.0.0", "relativePath": "shared-schemas/osdu/abstract/AbstractAccessControlList.1.0.0.json" }, + { + "kind": "{{schema-authority}}:wks:AbstractActivityParameter:1.0.0", + "relativePath": "shared-schemas/osdu/abstract/AbstractActivityParameter.1.0.0.json" + }, { "kind": "{{schema-authority}}:wks:AbstractAliasNames:1.0.0", "relativePath": "shared-schemas/osdu/abstract/AbstractAliasNames.1.0.0.json" @@ -127,10 +131,22 @@ "kind": "{{schema-authority}}:wks:AbstractProject:1.0.0", "relativePath": "shared-schemas/osdu/abstract/AbstractProject.1.0.0.json" }, + { + "kind": "{{schema-authority}}:wks:AbstractProjectActivity:1.0.0", + "relativePath": "shared-schemas/osdu/abstract/AbstractProjectActivity.1.0.0.json" + }, + { + "kind": "{{schema-authority}}:wks:AbstractPropertyType:1.0.0", + "relativePath": "shared-schemas/osdu/abstract/AbstractPropertyType.1.0.0.json" + }, { "kind": "{{schema-authority}}:wks:AbstractQualityMetric:1.0.0", "relativePath": "shared-schemas/osdu/abstract/AbstractQualityMetric.1.0.0.json" }, + { + "kind": "{{schema-authority}}:wks:AbstractReferencePropertyType:1.0.0", + "relativePath": "shared-schemas/osdu/abstract/AbstractReferencePropertyType.1.0.0.json" + }, { "kind": "{{schema-authority}}:wks:AbstractReferenceType:1.0.0", "relativePath": "shared-schemas/osdu/abstract/AbstractReferenceType.1.0.0.json" @@ -139,6 +155,10 @@ "kind": "{{schema-authority}}:wks:AbstractVectorHeaderMapping:1.0.0", "relativePath": "shared-schemas/osdu/abstract/AbstractVectorHeaderMapping.1.0.0.json" }, + { + "kind": "{{schema-authority}}:wks:AbstractWPCActivity:1.0.0", + "relativePath": "shared-schemas/osdu/abstract/AbstractWPCActivity.1.0.0.json" + }, { "kind": "{{schema-authority}}:wks:AbstractWPCGroupType:1.0.0", "relativePath": "shared-schemas/osdu/abstract/AbstractWPCGroupType.1.0.0.json" @@ -151,6 +171,18 @@ "kind": "{{schema-authority}}:wks:AbstractWorkProductComponent:1.0.0", "relativePath": "shared-schemas/osdu/abstract/AbstractWorkProductComponent.1.0.0.json" }, + { + "kind": "{{schema-authority}}:wks:work-product-component--Activity:1.0.0", + "relativePath": "shared-schemas/osdu/work-product-component/Activity.1.0.0.json" + }, + { + "kind": "{{schema-authority}}:wks:master-data--ActivityTemplate:1.0.0", + "relativePath": "shared-schemas/osdu/master-data/ActivityTemplate.1.0.0.json" + }, + { + "kind": "{{schema-authority}}:wks:master-data--ActivityTemplateArc:1.0.0", + "relativePath": "shared-schemas/osdu/master-data/ActivityTemplateArc.1.0.0.json" + }, { "kind": "{{schema-authority}}:wks:reference-data--ActivityType:1.0.0", "relativePath": "shared-schemas/osdu/reference-data/ActivityType.1.0.0.json" @@ -207,6 +239,14 @@ "kind": "{{schema-authority}}:wks:reference-data--CalculationMethodType:1.0.0", "relativePath": "shared-schemas/osdu/reference-data/CalculationMethodType.1.0.0.json" }, + { + "kind": "{{schema-authority}}:wks:master-data--Collection:1.0.0", + "relativePath": "shared-schemas/osdu/master-data/Collection.1.0.0.json" + }, + { + "kind": "{{schema-authority}}:wks:reference-data--CollectionPurpose:1.0.0", + "relativePath": "shared-schemas/osdu/reference-data/CollectionPurpose.1.0.0.json" + }, { "kind": "{{schema-authority}}:wks:reference-data--CompressionMethodType:1.0.0", "relativePath": "shared-schemas/osdu/reference-data/CompressionMethodType.1.0.0.json" @@ -479,6 +519,14 @@ "kind": "{{schema-authority}}:wks:work-product-component--PPFGDataset:1.0.0", "relativePath": "shared-schemas/osdu/work-product-component/PPFGDataset.1.0.0.json" }, + { + "kind": "{{schema-authority}}:wks:reference-data--ParameterKind:1.0.0", + "relativePath": "shared-schemas/osdu/reference-data/ParameterKind.1.0.0.json" + }, + { + "kind": "{{schema-authority}}:wks:reference-data--ParameterRole:1.0.0", + "relativePath": "shared-schemas/osdu/reference-data/ParameterRole.1.0.0.json" + }, { "kind": "{{schema-authority}}:wks:reference-data--ParameterType:1.0.0", "relativePath": "shared-schemas/osdu/reference-data/ParameterType.1.0.0.json" @@ -515,6 +563,10 @@ "kind": "{{schema-authority}}:wks:reference-data--PropertyNameType:1.0.0", "relativePath": "shared-schemas/osdu/reference-data/PropertyNameType.1.0.0.json" }, + { + "kind": "{{schema-authority}}:wks:reference-data--PropertyType:1.0.0", + "relativePath": "shared-schemas/osdu/reference-data/PropertyType.1.0.0.json" + }, { "kind": "{{schema-authority}}:wks:master-data--Prospect:1.0.0", "relativePath": "shared-schemas/osdu/master-data/Prospect.1.0.0.json" @@ -663,10 +715,18 @@ "kind": "{{schema-authority}}:wks:reference-data--StringClass:1.0.0", "relativePath": "shared-schemas/osdu/reference-data/StringClass.1.0.0.json" }, + { + "kind": "{{schema-authority}}:wks:reference-data--SurveyToolType:1.0.0", + "relativePath": "shared-schemas/osdu/reference-data/SurveyToolType.1.0.0.json" + }, { "kind": "{{schema-authority}}:wks:reference-data--TectonicSettingType:1.0.0", "relativePath": "shared-schemas/osdu/reference-data/TectonicSettingType.1.0.0.json" }, + { + "kind": "{{schema-authority}}:wks:reference-data--TrajectoryStationPropertyType:1.0.0", + "relativePath": "shared-schemas/osdu/reference-data/TrajectoryStationPropertyType.1.0.0.json" + }, { "kind": "{{schema-authority}}:wks:work-product-component--TubularAssembly:1.0.0", "relativePath": "shared-schemas/osdu/work-product-component/TubularAssembly.1.0.0.json" @@ -719,6 +779,10 @@ "kind": "{{schema-authority}}:wks:reference-data--UnitOfMeasure:1.0.0", "relativePath": "shared-schemas/osdu/reference-data/UnitOfMeasure.1.0.0.json" }, + { + "kind": "{{schema-authority}}:wks:reference-data--UnitOfMeasureConfiguration:1.0.0", + "relativePath": "shared-schemas/osdu/reference-data/UnitOfMeasureConfiguration.1.0.0.json" + }, { "kind": "{{schema-authority}}:wks:reference-data--UnitQuantity:1.0.0", "relativePath": "shared-schemas/osdu/reference-data/UnitQuantity.1.0.0.json" @@ -763,6 +827,14 @@ "kind": "{{schema-authority}}:wks:work-product-component--WellLog:1.0.0", "relativePath": "shared-schemas/osdu/work-product-component/WellLog.1.0.0.json" }, + { + "kind": "{{schema-authority}}:wks:work-product-component--WellLog:1.1.0", + "relativePath": "shared-schemas/osdu/work-product-component/WellLog.1.1.0.json" + }, + { + "kind": "{{schema-authority}}:wks:reference-data--WellLogSamplingDomainType:1.0.0", + "relativePath": "shared-schemas/osdu/reference-data/WellLogSamplingDomainType.1.0.0.json" + }, { "kind": "{{schema-authority}}:wks:master-data--Wellbore:1.0.0", "relativePath": "shared-schemas/osdu/master-data/Wellbore.1.0.0.json" @@ -775,6 +847,10 @@ "kind": "{{schema-authority}}:wks:work-product-component--WellboreTrajectory:1.0.0", "relativePath": "shared-schemas/osdu/work-product-component/WellboreTrajectory.1.0.0.json" }, + { + "kind": "{{schema-authority}}:wks:work-product-component--WellboreTrajectory:1.1.0", + "relativePath": "shared-schemas/osdu/work-product-component/WellboreTrajectory.1.1.0.json" + }, { "kind": "{{schema-authority}}:wks:reference-data--WellboreTrajectoryType:1.0.0", "relativePath": "shared-schemas/osdu/reference-data/WellboreTrajectoryType.1.0.0.json" diff --git a/deployments/shared-schemas/osdu/manifest/GenericDataset.1.0.0.json b/deployments/shared-schemas/osdu/manifest/GenericDataset.1.0.0.json index b01589f087ab3f7d6c2390c619b40e1aadbd30e4..4d8990b320b7adfed0aa68740d3d263e25b7f0d7 100644 --- a/deployments/shared-schemas/osdu/manifest/GenericDataset.1.0.0.json +++ b/deployments/shared-schemas/osdu/manifest/GenericDataset.1.0.0.json @@ -136,7 +136,7 @@ "EncodingFormatTypeID": { "type": "string", "title": "Encoding Format Type ID", - "description": "EncodingFormatType ID reference value relationship. It can me a mime-type or media-type.", + "description": "EncodingFormatType ID reference value relationship. It can be a mime-type or media-type.", "example": "namespace:reference-data--EncodingFormatType:text%2Fcsv:", "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-EncodingFormatType:[\\w\\-\\.\\:\\%]+:[0-9]*$", "x-osdu-relationship": [ diff --git a/deployments/shared-schemas/osdu/master-data/ActivityTemplate.1.0.0.json b/deployments/shared-schemas/osdu/master-data/ActivityTemplate.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..38630ff7b66bb554415bed6e7b52bc0fa95b5c8b --- /dev/null +++ b/deployments/shared-schemas/osdu/master-data/ActivityTemplate.1.0.0.json @@ -0,0 +1,244 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "master-data--ActivityTemplate", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:master-data--ActivityTemplate:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/master-data/ActivityTemplate.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:master-data--ActivityTemplate:1.0.0", + "title": "ActivityTemplate", + "description": "Description of one type of activity.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-ActivityTemplate:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:master-data--ActivityTemplate:44d649a3-8d8b-532c-8b77-b10f589a876b" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:master-data--ActivityTemplate:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "{{schema-authority}}:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "{{schema-authority}}:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "{{schema-authority}}:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "{{schema-authority}}:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "{{schema-authority}}:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractMaster:1.0.0" + }, + { + "type": "object", + "properties": { + "Parameters": { + "type": "array", + "title": "Parameters", + "description": "Description of one parameter that participate in one type of activity.", + "x-osdu-indexing": { + "type": "nested" + }, + "items": { + "type": "object", + "title": "Parameter Template", + "description": "Description of one parameter that participates in one type of activity.\n[Without inheritance, combined specializations.]", + "properties": { + "AllowedParameterKind": { + "type": "string", + "title": "Allowed Parameter Kind", + "description": "If no allowed kind is given, then all kind of data types are allowed.", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-ParameterKind:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "ParameterKind" + } + ] + }, + "IsInput": { + "type": "boolean", + "title": "Is Input", + "description": "Indicates if the parameter is an input of the activity. If the parameter is a data object and is also an output of the activity, it is strongly advised to use two parameters : one for input and one for output. The reason is to be able to give two different versions strings for the input and output data object which has got obviously the same UUID." + }, + "KeyConstraints": { + "type": "array", + "title": "Key Constraints", + "description": "Allows to indicate that, in the same activity, this parameter template must be associated to another parameter template identified by its title. The associated parameter value constrains this parameter.", + "items": { + "type": "string" + } + }, + "IsOutput": { + "type": "boolean", + "title": "Is Output", + "description": "Indicates if the parameter is an output of the activity. If the parameter is a data object and is also an input of the activity, it is strongly advised to use two parameters : one for input and one for output. The reason is to be able to give two different versions strings for the input and output data object which has got obviously the same UUID." + }, + "Title": { + "type": "string", + "title": "Title", + "description": "Name of the parameter in the activity. Key to identify parameter." + }, + "DataObjectContentType": { + "type": "array", + "title": "Data Object Content Type", + "description": "When parameter is limited to data object of given types, describe the allowed types. Used only when ParameterType is dataObject. String is an OSDU kind of work product component.", + "items": { + "type": "string" + } + }, + "MaxOccurs": { + "type": "integer", + "title": "Max Occurs", + "description": "Maximum number of parameters of this type allowed in the activity. If the maximum number of parameters is infinite, use -1 value." + }, + "MinOccurs": { + "type": "integer", + "title": "Min Occurs", + "description": "Minimum number of parameter of this type required by the activity. If the minimum number of parameters is infinite, use -1 value." + }, + "Constraint": { + "type": "string", + "title": "Constraint", + "description": "Textual description of additional constraint associated with the parameter. (note that it will be better to have a formal description of the constraint)" + }, + "DefaultValue": { + "$ref": "{{schema-authority}}:wks:AbstractActivityParameter:1.0.0", + "title": "Default Value", + "description": "Activity Parameter value to use if one not supplied." + }, + "PropertyType": { + "$ref": "{{schema-authority}}:wks:AbstractPropertyType:1.0.0", + "title": "Property Type", + "description": "The property type ID and Name, which determines eventually the UnitQuantity of the parameter value. Used to provide a more scoped context than UnitQuantityID. If PropertyType is provided, UnitQuantityID is expected to be omitted." + }, + "UnitQuantityID": { + "type": "string", + "title": "Unit Quantity ID", + "description": "The expected UnitQuantity for the parameter value. A more precise context can be provided by PropertyType. If UnitQuantityID is provided, PropertyType is expected to be omitted.", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-UnitQuantity:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "UnitQuantity" + } + ] + } + }, + "required": [ + "IsInput", + "IsOutput", + "Title", + "MaxOccurs", + "MinOccurs" + ] + } + } + }, + "required": [ + "Parameters" + ] + }, + { + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-review-status": "Accepted", + "x-osdu-inheriting-from-kind": [] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/master-data/ActivityTemplateArc.1.0.0.json b/deployments/shared-schemas/osdu/master-data/ActivityTemplateArc.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..654dae6f8dca0dbcba67d91e4cf7d449302e3d38 --- /dev/null +++ b/deployments/shared-schemas/osdu/master-data/ActivityTemplateArc.1.0.0.json @@ -0,0 +1,236 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "master-data--ActivityTemplateArc", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:master-data--ActivityTemplateArc:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/master-data/ActivityTemplateArc.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:master-data--ActivityTemplateArc:1.0.0", + "title": "ActivityTemplateArc", + "description": "An 'arc' establishing a link between ActivityTemplate input and output parameters.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-ActivityTemplateArc:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:master-data--ActivityTemplateArc:908c2239-bea8-59ec-a918-24b5994f6fa8" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:master-data--ActivityTemplateArc:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "{{schema-authority}}:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "{{schema-authority}}:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "{{schema-authority}}:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "{{schema-authority}}:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "{{schema-authority}}:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractMaster:1.0.0" + }, + { + "type": "object", + "properties": { + "Name": { + "type": "string", + "title": "Name", + "description": "The name of this input/output parameter definition set." + }, + "OutputInputArcs": { + "type": "array", + "title": "Output Input Arcs", + "description": "The array of arcs, which associate ActivityTemplate outputs to ActivityTemplate inputs.", + "items": { + "type": "object", + "title": "Arc", + "description": "An 'arc' establishing a link between a single pair of ActivityTemplate input and output parameters.", + "properties": { + "ProducingActivityTemplateID": { + "type": "string", + "title": "Producing Activity Template ID", + "description": "The relationship to the producing ActivityTemplate.", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-ActivityTemplate:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "ActivityTemplate" + } + ] + }, + "ProducingParameterTitle": { + "type": "string", + "title": "Producing Parameter Title", + "description": "The Title of the producing ActivityTemplate Parameter array element." + }, + "ConsumingActivityTemplateID": { + "type": "string", + "title": "Consuming Activity Template ID", + "description": "The relationship to the consuming ActivityTemplate.", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-ActivityTemplate:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "ActivityTemplate" + } + ] + }, + "ConsumingParameterTitle": { + "type": "string", + "title": "Consuming Parameter Title", + "description": "The Title of the consuming ActivityTemplate Parameter array element." + } + }, + "required": [ + "ProducingActivityTemplateID", + "ProducingParameterTitle", + "ConsumingActivityTemplateID", + "ConsumingParameterTitle" + ] + } + }, + "ActivityArcs": { + "type": "array", + "title": "Activity Arcs", + "description": "The array of arcs, which link pairs of ActivityTemplate as predecessor and successor.", + "items": { + "type": "object", + "title": "Arc", + "description": "An 'arc' establishing a link between a single pair of ActivityTemplate input and output parameters.", + "properties": { + "PrecedingActivityTemplateID": { + "type": "string", + "title": "Preceding Activity Template ID", + "description": "The relationship to the ActivityTemplate first in a pair of ActivityTemplates in the context of a workflow.", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-ActivityTemplate:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "ActivityTemplate" + } + ] + }, + "SucceedingActivityTemplateID": { + "type": "string", + "title": "Succeeding Activity Template ID", + "description": "The relationship to the ActivityTemplate succeeding the first ActivityTemplate in the workflow.", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-ActivityTemplate:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "ActivityTemplate" + } + ] + } + }, + "required": [ + "PrecedingActivityTemplateID", + "SucceedingActivityTemplateID" + ] + } + } + } + }, + { + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-review-status": "Accepted", + "x-osdu-inheriting-from-kind": [] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/master-data/Basin.1.0.0.json b/deployments/shared-schemas/osdu/master-data/Basin.1.0.0.json index 1a452232fc24633d24f6749216d9b65992b22329..a3488c3dcabec793297f9487083c6e9cedb8b24f 100644 --- a/deployments/shared-schemas/osdu/master-data/Basin.1.0.0.json +++ b/deployments/shared-schemas/osdu/master-data/Basin.1.0.0.json @@ -115,7 +115,8 @@ "type": "object", "properties": { "BasinID": { - "description": "A system generated unique identifier.", + "title": "External Basin Identifier", + "description": "Native identifier from a Master Data Management System or other trusted source external to OSDU - stored here in order to allow for multi-system connection and synchronization. If used, the \"Source\" property should identify that source system.", "type": "string" }, "BasinName": { diff --git a/deployments/shared-schemas/osdu/master-data/Collection.1.0.0.json b/deployments/shared-schemas/osdu/master-data/Collection.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..edbb3bab0382bcf126c9268e56be87b2d141d493 --- /dev/null +++ b/deployments/shared-schemas/osdu/master-data/Collection.1.0.0.json @@ -0,0 +1,206 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "master-data--Collection", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:master-data--Collection:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/master-data/Collection.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:master-data--Collection:1.0.0", + "title": "Collection", + "description": "Collection of objects ingested in the data platform. The collection is persisted and can group objects of different nature, including master data, work-product-components and reference data. A Collection can also contain Collection(s).", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Collection:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:master-data--Collection:2a40d3ce-52cd-59de-b037-ff320b2d4569" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:master-data--Collection:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "{{schema-authority}}:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "{{schema-authority}}:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "{{schema-authority}}:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "{{schema-authority}}:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "{{schema-authority}}:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractMaster:1.0.0" + }, + { + "type": "object", + "properties": { + "MemberIDs": { + "type": "array", + "title": "MemberIDs", + "description": "List of objects part of the Collection, defined as an array of the member IDs", + "example": [ + "namespace:work-product-component--SeismicHorizon:a7a81843-9bea-5ce4-913c-f67e4ea154ff:", + "namespace:work-product-component--SeismicHorizon:aff9a086-3da6-53c0-baef-222c2273a040:" + ], + "items": { + "type": "string", + "pattern": "^[\\w\\-\\.]+:(master-data\\-\\-[\\w\\-\\.]+|reference-data\\-\\-[\\w\\-\\.]+|work-product-component\\-\\-[\\w\\-\\.]+|work-product\\-\\-[\\w\\-\\.]+):[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data" + }, + { + "GroupType": "reference-data" + }, + { + "GroupType": "work-product-component" + }, + { + "GroupType": "work-product" + } + ] + } + }, + "Description": { + "type": "string", + "title": "Description", + "description": "Describes the Collection (free string)" + }, + "PurposeID": { + "type": "string", + "title": "PurposeID", + "description": "Purpose of the Collection", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-CollectionPurpose:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "CollectionPurpose" + } + ] + }, + "ParentCollectionID": { + "type": "string", + "title": "ParentCollectionID", + "description": "If this Collection is nested within another Collection, this property points to the Parent Collection ID. Otherwise, leave empty.", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Collection:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "Collection" + } + ] + }, + "HomogeneousMemberKind": { + "type": "string", + "title": "HomogeneousMemberKind", + "description": "If the Collection is homogeneous, this indicates the single data schema Kind within the collection (without the semantic version number). If the collection is heterogeneous (collecting multiple data types) leave this property empty.", + "example": "osdu:wks:work-product-component--SeismicHorizon" + }, + "Author": { + "type": "string", + "title": "Author", + "description": "The author responsible to the collection content." + } + } + }, + { + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-review-status": "Accepted", + "x-osdu-inheriting-from-kind": [] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/master-data/Field.1.0.0.json b/deployments/shared-schemas/osdu/master-data/Field.1.0.0.json index 552bb84105d49a22397b7509b2a579a42ff30750..9a718b14417bfe74d9d08bc80e1032ae6edca144 100644 --- a/deployments/shared-schemas/osdu/master-data/Field.1.0.0.json +++ b/deployments/shared-schemas/osdu/master-data/Field.1.0.0.json @@ -115,7 +115,8 @@ "type": "object", "properties": { "FieldID": { - "description": "A system generated unique identifier.", + "title": "External Field Identifier", + "description": "Native identifier from a Master Data Management System or other trusted source external to OSDU - stored here in order to allow for multi-system connection and synchronization. If used, the \"Source\" property should identify that source system.", "type": "string" }, "FieldName": { diff --git a/deployments/shared-schemas/osdu/master-data/GeoPoliticalEntity.1.0.0.json b/deployments/shared-schemas/osdu/master-data/GeoPoliticalEntity.1.0.0.json index e55319f580fdccc2b2e577369f8a05a494959de5..c7ecb4a5bffefccf21e2d343617ceec574730e53 100644 --- a/deployments/shared-schemas/osdu/master-data/GeoPoliticalEntity.1.0.0.json +++ b/deployments/shared-schemas/osdu/master-data/GeoPoliticalEntity.1.0.0.json @@ -115,7 +115,8 @@ "type": "object", "properties": { "GeoPoliticalEntityID": { - "description": "A system generated unique identifier.", + "title": "External GeoPoliticalEntity Identifier", + "description": "Native identifier from a Master Data Management System or other trusted source external to OSDU - stored here in order to allow for multi-system connection and synchronization. If used, the \"Source\" property should identify that source system.", "type": "string" }, "TerminationDate": { diff --git a/deployments/shared-schemas/osdu/master-data/Organisation.1.0.0.json b/deployments/shared-schemas/osdu/master-data/Organisation.1.0.0.json index 5bf3d51eb17f153bb1d199cfd64b135c949899c1..9246fa56b9908e56075d0dd3309e1a1918291baf 100644 --- a/deployments/shared-schemas/osdu/master-data/Organisation.1.0.0.json +++ b/deployments/shared-schemas/osdu/master-data/Organisation.1.0.0.json @@ -115,7 +115,8 @@ "type": "object", "properties": { "OrganisationID": { - "description": "A system generated unique identifier.", + "title": "External Organisation Identifier", + "description": "Native identifier from a Master Data Management System or other trusted source external to OSDU - stored here in order to allow for multi-system connection and synchronization. If used, the \"Source\" property should identify that source system.", "type": "string" }, "OrganisationName": { diff --git a/deployments/shared-schemas/osdu/master-data/Play.1.0.0.json b/deployments/shared-schemas/osdu/master-data/Play.1.0.0.json index 2b7eef54d4163ffbce513f3bcd076c2d3af0ac0f..925043d353433841a522a8f282ff1df2f65f8cfc 100644 --- a/deployments/shared-schemas/osdu/master-data/Play.1.0.0.json +++ b/deployments/shared-schemas/osdu/master-data/Play.1.0.0.json @@ -116,8 +116,8 @@ "properties": { "PlayID": { "type": "string", - "title": "Play ID", - "description": "System generated unique identifier for a Play." + "title": "External Play Identifier", + "description": "Native identifier from a Master Data Management System or other trusted source external to OSDU - stored here in order to allow for multi-system connection and synchronization. If used, the \"Source\" property should identify that source system." }, "PlayName": { "type": "string", diff --git a/deployments/shared-schemas/osdu/master-data/Prospect.1.0.0.json b/deployments/shared-schemas/osdu/master-data/Prospect.1.0.0.json index 6b48244f799dd2c49ecaa0a77bc5800855388276..ea77c557457b49610db95b65c511c179004d28ec 100644 --- a/deployments/shared-schemas/osdu/master-data/Prospect.1.0.0.json +++ b/deployments/shared-schemas/osdu/master-data/Prospect.1.0.0.json @@ -116,8 +116,8 @@ "properties": { "ProspectID": { "type": "string", - "title": "Prospect ID", - "description": "System generated unique identifier for a Prospect." + "title": "External Prospect Identifier", + "description": "Native identifier from a Master Data Management System or other trusted source external to OSDU - stored here in order to allow for multi-system connection and synchronization. If used, the \"Source\" property should identify that source system." }, "ProspectName": { "type": "string", diff --git a/deployments/shared-schemas/osdu/reference-data/CollectionPurpose.1.0.0.json b/deployments/shared-schemas/osdu/reference-data/CollectionPurpose.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..b91d1763b29c2f8e0451c5aea9b1afab391bca48 --- /dev/null +++ b/deployments/shared-schemas/osdu/reference-data/CollectionPurpose.1.0.0.json @@ -0,0 +1,147 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "reference-data--CollectionPurpose", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:reference-data--CollectionPurpose:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/reference-data/CollectionPurpose.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:reference-data--CollectionPurpose:1.0.0", + "title": "CollectionPurpose", + "description": "A governed purpose code for collections, e.g. 'Flow simulation output properties', 'Study', or similar.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-CollectionPurpose:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:reference-data--CollectionPurpose:f8e39086-88f6-51e9-a659-f13eef0e1505" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:reference-data--CollectionPurpose:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "{{schema-authority}}:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "{{schema-authority}}:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "{{schema-authority}}:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "{{schema-authority}}:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "{{schema-authority}}:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractReferenceType:1.0.0" + }, + { + "type": "object", + "properties": {} + }, + { + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-review-status": "Pending", + "x-osdu-governance-model": "OPEN", + "x-osdu-governance-authorities": [ + "OSDU" + ], + "x-osdu-inheriting-from-kind": [ + { + "name": "ReferenceType", + "kind": "osdu:wks:AbstractReferenceType:1.0.0" + } + ] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/reference-data/ParameterKind.1.0.0.json b/deployments/shared-schemas/osdu/reference-data/ParameterKind.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..0500dba5401e872399bf3745fd489aa18d069bf3 --- /dev/null +++ b/deployments/shared-schemas/osdu/reference-data/ParameterKind.1.0.0.json @@ -0,0 +1,147 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "reference-data--ParameterKind", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:reference-data--ParameterKind:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/reference-data/ParameterKind.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:reference-data--ParameterKind:1.0.0", + "title": "ParameterKind", + "description": "ParameterKind describes the value type of the parameter. Known values are integer, double, string, timestamp, subActivity, dataObject.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-ParameterKind:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:reference-data--ParameterKind:93950274-2767-5942-87a7-bad3cc8a4949" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:reference-data--ParameterKind:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "{{schema-authority}}:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "{{schema-authority}}:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "{{schema-authority}}:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "{{schema-authority}}:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "{{schema-authority}}:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractReferenceType:1.0.0" + }, + { + "type": "object", + "properties": {} + }, + { + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-review-status": "Accepted", + "x-osdu-governance-model": "OPEN", + "x-osdu-governance-authorities": [ + "Energistics" + ], + "x-osdu-inheriting-from-kind": [ + { + "name": "ReferenceType", + "kind": "osdu:wks:AbstractReferenceType:1.0.0" + } + ] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/reference-data/ParameterRole.1.0.0.json b/deployments/shared-schemas/osdu/reference-data/ParameterRole.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..79f4b6a16799202812e54a48b2db7439ab066417 --- /dev/null +++ b/deployments/shared-schemas/osdu/reference-data/ParameterRole.1.0.0.json @@ -0,0 +1,147 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "reference-data--ParameterRole", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:reference-data--ParameterRole:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/reference-data/ParameterRole.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:reference-data--ParameterRole:1.0.0", + "title": "ParameterRole", + "description": "Reference value type describing how an activity parameter was used by an activity, such as input, output, control, constraint, agent, predecessor activity, successor activity.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-ParameterRole:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:reference-data--ParameterRole:575b6f15-e3d4-5055-a803-0d35c45a6d8e" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:reference-data--ParameterRole:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "{{schema-authority}}:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "{{schema-authority}}:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "{{schema-authority}}:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "{{schema-authority}}:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "{{schema-authority}}:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractReferenceType:1.0.0" + }, + { + "type": "object", + "properties": {} + }, + { + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-review-status": "Accepted", + "x-osdu-governance-model": "OPEN", + "x-osdu-governance-authorities": [ + "OSDU" + ], + "x-osdu-inheriting-from-kind": [ + { + "name": "ReferenceType", + "kind": "osdu:wks:AbstractReferenceType:1.0.0" + } + ] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/reference-data/PropertyType.1.0.0.json b/deployments/shared-schemas/osdu/reference-data/PropertyType.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..5fd2794215a1de3b47bac019133fe79d1f7c905e --- /dev/null +++ b/deployments/shared-schemas/osdu/reference-data/PropertyType.1.0.0.json @@ -0,0 +1,200 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "reference-data--PropertyType", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:reference-data--PropertyType:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/reference-data/PropertyType.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:reference-data--PropertyType:1.0.0", + "title": "PropertyType", + "description": "PropertyType is part of Energistics PWLS 3, which defines a detailed hierarchy of properties linked to the Energistics UnitQuantity/UnitOfMeasure.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-PropertyType:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:reference-data--PropertyType:9da1d25c-0b31-53b9-8f02-32c9d75067d8" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:reference-data--PropertyType:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "{{schema-authority}}:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "{{schema-authority}}:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "{{schema-authority}}:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "{{schema-authority}}:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "{{schema-authority}}:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractReferenceType:1.0.0" + }, + { + "type": "object", + "properties": { + "ParentPropertyTypeID": { + "type": "string", + "title": "Parent Property Type", + "description": "Relationship to the parent PropertyType. The root PropertyType is called 'property' and refers to itself as parent.", + "example": "namespace:reference-data--PropertyType:46943a75-5fa3-4acf-8d9f-d9c4c748b1c9:", + "x-osdu-attribution-authority": "Energistics", + "x-osdu-attribution-publication": "PWLS 3", + "x-osdu-attribution-revision": 3, + "x-osdu-existing-standard": "Energistics PWLS 3", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-PropertyType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "PropertyType" + } + ] + }, + "ParentName": { + "type": "string", + "title": "Parent Name", + "description": "The name of the parent PropertyType.", + "example": "azimuth", + "x-osdu-is-derived": { + "RelationshipPropertyName": "ParentPropertyTypeID", + "TargetPropertyName": "Name" + }, + "x-osdu-attribution-authority": "Energistics", + "x-osdu-attribution-publication": "PWLS 3", + "x-osdu-attribution-revision": 3, + "x-osdu-existing-standard": "Energistics PWLS 3" + }, + "UnitQuantityID": { + "type": "string", + "title": "Unit Quantity ID", + "description": "The relationship to a UnitQuantity, which connects to frame of reference conversion.", + "example": "namespace:reference-data--UnitQuantity:plane%20angle:", + "x-osdu-attribution-authority": "Energistics", + "x-osdu-attribution-publication": "PWLS 3", + "x-osdu-attribution-revision": 3, + "x-osdu-existing-standard": "Energistics PWLS 3", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-UnitQuantity:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "UnitQuantity" + } + ] + } + }, + "required": [ + "ParentPropertyTypeID", + "UnitQuantityID" + ] + }, + { + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-review-status": "Accepted", + "x-osdu-governance-model": "OPEN", + "x-osdu-governance-authorities": [ + "Energistics" + ], + "x-osdu-inheriting-from-kind": [ + { + "name": "ReferenceType", + "kind": "osdu:wks:AbstractReferenceType:1.0.0" + } + ] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/reference-data/SurveyToolType.1.0.0.json b/deployments/shared-schemas/osdu/reference-data/SurveyToolType.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..d1c678f0d9b5258a56ff1095f002b3277a4d3b5d --- /dev/null +++ b/deployments/shared-schemas/osdu/reference-data/SurveyToolType.1.0.0.json @@ -0,0 +1,142 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "reference-data--SurveyToolType", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:reference-data--SurveyToolType:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/reference-data/SurveyToolType.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:reference-data--SurveyToolType:1.0.0", + "title": "SurveyToolType", + "description": "Used to describe The type of tool or equipment used to acquire this Directional Survey. For example, gyroscopic, magnetic, MWD, TOTCO, acid bottle, etc. Follow OWSG reference data and support the ISCWSA survey tool definitions.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-SurveyToolType:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:reference-data--SurveyToolType:9a9a3e1d-563a-5c64-9efa-c74f136941a7" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:reference-data--SurveyToolType:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "{{schema-authority}}:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "{{schema-authority}}:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "{{schema-authority}}:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "{{schema-authority}}:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "{{schema-authority}}:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractReferenceType:1.0.0" + }, + { + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-governance-authorities": [ + "None" + ], + "x-osdu-governance-model": "OPEN", + "x-osdu-inheriting-from-kind": [ + { + "name": "ReferenceType", + "kind": "osdu:wks:AbstractReferenceType:1.0.0" + } + ] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/reference-data/TrajectoryStationPropertyType.1.0.0.json b/deployments/shared-schemas/osdu/reference-data/TrajectoryStationPropertyType.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..6629e0370d1515177feae2c0944a8e385d8edeb9 --- /dev/null +++ b/deployments/shared-schemas/osdu/reference-data/TrajectoryStationPropertyType.1.0.0.json @@ -0,0 +1,150 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "reference-data--TrajectoryStationPropertyType", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:reference-data--TrajectoryStationPropertyType:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/reference-data/TrajectoryStationPropertyType.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:reference-data--TrajectoryStationPropertyType:1.0.0", + "title": "TrajectoryStationPropertyType", + "description": "The trajectory station property catalog for e.g. WellboreTrajectory AvailableTrajectoryStationProperties. Similar to LogCurveType the TrajectoryStationPropertyType describes well-known properties (or curves or channels in an array view), which can be accessed via the Wellbore Domain Data Management Services.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-TrajectoryStationPropertyType:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:reference-data--TrajectoryStationPropertyType:9359ff0b-553b-599a-9677-b47d7f3b84de" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:reference-data--TrajectoryStationPropertyType:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "{{schema-authority}}:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "{{schema-authority}}:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "{{schema-authority}}:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "{{schema-authority}}:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "{{schema-authority}}:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractReferenceType:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractReferencePropertyType:1.0.0" + }, + { + "type": "object", + "properties": {} + }, + { + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-review-status": "Accepted", + "x-osdu-governance-model": "OPEN", + "x-osdu-governance-authorities": [ + "OSDU" + ], + "x-osdu-inheriting-from-kind": [ + { + "name": "ReferenceType", + "kind": "osdu:wks:AbstractReferenceType:1.0.0" + } + ] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/reference-data/UnitOfMeasureConfiguration.1.0.0.json b/deployments/shared-schemas/osdu/reference-data/UnitOfMeasureConfiguration.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..7b69d96d029e8dbb3ef3f74f2be0094693c8011c --- /dev/null +++ b/deployments/shared-schemas/osdu/reference-data/UnitOfMeasureConfiguration.1.0.0.json @@ -0,0 +1,272 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "reference-data--UnitOfMeasureConfiguration", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:reference-data--UnitOfMeasureConfiguration:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/reference-data/UnitOfMeasureConfiguration.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:reference-data--UnitOfMeasureConfiguration:1.0.0", + "title": "UnitOfMeasureConfiguration", + "description": "A UnitOfMeasure configuration allowing to associate preferred units and default units to specific UnitQuantity values. UnitQuantity provides the full list of units, UnitOfMeasureConfiguration scopes the lists to a domain's/app's/user's requirements.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-UnitOfMeasureConfiguration:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:reference-data--UnitOfMeasureConfiguration:87c5069b-9cbd-5ccf-b839-47f646216d14" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:reference-data--UnitOfMeasureConfiguration:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "{{schema-authority}}:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "{{schema-authority}}:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "{{schema-authority}}:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "{{schema-authority}}:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "{{schema-authority}}:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractReferenceType:1.0.0" + }, + { + "type": "object", + "properties": { + "ParentConfigurationID": { + "type": "string", + "title": "Parent Configuration ID", + "description": "Optional reference to a UnitOfMeasureConfiguration, from which the majority of definitions are derived.", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-UnitOfMeasureConfiguration:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "UnitOfMeasureConfiguration" + } + ] + }, + "Configurations": { + "type": "array", + "title": "Configurations", + "description": "The list of configurations associating measurements or properties with preferred and default units.", + "items": { + "type": "object", + "title": "Configuration", + "description": "A configuration for a UnitQuantity offering a sub-set of units and a default unit.", + "properties": { + "Name": { + "type": "string", + "title": "Name", + "description": "The name of the measurement.", + "example": "Diameter" + }, + "UnitQuantityID": { + "type": "string", + "title": "Unit Quantity ID", + "description": "The relationship to the UnitQuantity for this configuration. At least one of the fields UnitQuantityID, PropertyType and or PropertyNames must be populated. Scope narrows from UnitQuantityID, PropertyType to PropertyNames.", + "example": "namespace:reference-data--UnitQuantity:length:", + "x-osdu-existing-standard": "Energistics UoM V 1.0", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-UnitQuantity:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "UnitQuantity" + } + ] + }, + "PropertyType": { + "$ref": "{{schema-authority}}:wks:AbstractPropertyType:1.0.0", + "title": "Property Type", + "description": "If specified,Energistics PWLS 3 PropertyType implies a UnitQuantityID and offers a much finer scoping. PropertyType refers to a pair PropertyTypeID (typically a UUID) and a PropertyName. At least one of the fields UnitQuantityID, PropertyType and or PropertyNames must be populated. Scope narrows from UnitQuantityID, PropertyType to PropertyNames.", + "example": { + "PropertyTypeID": "namespace:reference-data--PropertyType:a391d150-5f9d-43ec-be44-b3e020e8e0b9:", + "Name": "inside diameter" + }, + "x-osdu-existing-standard": "Energistics PWLS 3" + }, + "PropertyNames": { + "type": "array", + "title": "Property Names", + "description": "The list of property names, to which this configuration should apply. At least one of the fields UnitQuantityID, PropertyType and or PropertyNames must be populated. Scope narrows from UnitQuantityID, PropertyType to PropertyNames.", + "example": [ + "TubularComponentNominalSize", + "DriftDiameter", + "InnerDiameter" + ], + "items": { + "type": "string" + } + }, + "DefaultUnitID": { + "type": "string", + "title": "Default Unit ID", + "description": "The default UnitOfMeasure to be used for this measurement name. If empty, the first element of the mandatory PreferredUnitIDs array should be taken. The DefaultUnitID should be member of the PreferredUnitIDs array.", + "example": "namespace:reference-data--UnitOfMeasure:in:", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-UnitOfMeasure:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "UnitOfMeasure" + } + ] + }, + "PreferredUnitIDs": { + "type": "array", + "title": "Preferred Unit IDs", + "description": "The preferred sub-set of units, which are meaningful for the domain, app or user. This property is mandatory and must contain at least one element.", + "example": [ + "namespace:reference-data--UnitOfMeasure:in:", + "namespace:reference-data--UnitOfMeasure:cm:", + "namespace:reference-data--UnitOfMeasure:mm:" + ], + "items": { + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-UnitOfMeasure:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "UnitOfMeasure" + } + ] + } + }, + "NumericFormatType": { + "type": "string", + "title": "Numeric Format Type", + "description": "A hint how the number is expected to be presented, e.g., d or D for decimal, f or F for fixed point, e or E for exponential (scientific), or g or G for general (default). Not all languages support all codes in all cases - in principle the case means that the resulting case is transformed to upper case or lower case depending on the case of the NumericFormatType.", + "enum": [ + "f", + "F", + "g", + "G", + "d", + "D", + "e", + "E" + ] + }, + "NumericPrecision": { + "type": "integer", + "title": "Numeric Precision", + "description": "The number of decimal digits for NumericFormatType f or F or e or E, or the number of significant digits in g or G. If populated in conjunction with NumericFormatType d or D, NumericPrecision defines the minimum number of digits. If the number has less digits than given by NumericPrecision, it is padded with leading zeroes.", + "example": 2 + } + }, + "required": [ + "PreferredUnitIDs" + ] + } + } + } + }, + { + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-review-status": "Accepted", + "x-osdu-governance-model": "LOCAL", + "x-osdu-governance-authorities": [ + "OSDU" + ], + "x-osdu-inheriting-from-kind": [ + { + "name": "ReferenceType", + "kind": "osdu:wks:AbstractReferenceType:1.0.0" + } + ] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/reference-data/WellLogSamplingDomainType.1.0.0.json b/deployments/shared-schemas/osdu/reference-data/WellLogSamplingDomainType.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..c8d70786392046dcbe3408d7f6c9c27e1ef78735 --- /dev/null +++ b/deployments/shared-schemas/osdu/reference-data/WellLogSamplingDomainType.1.0.0.json @@ -0,0 +1,147 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "reference-data--WellLogSamplingDomainType", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:reference-data--WellLogSamplingDomainType:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/reference-data/WellLogSamplingDomainType.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:reference-data--WellLogSamplingDomainType:1.0.0", + "title": "WellLogSamplingDomainType", + "description": "The reference type for the well log, e.g. the domain of the reference curve. The most common value is Depth but it can also be calendar time, e.g. TimePast-1970-01-01 or SeismicTwoWayTravelTime.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-WellLogSamplingDomainType:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:reference-data--WellLogSamplingDomainType:b51aa4f2-9f2b-5352-9461-f61c1cd430d5" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:reference-data--WellLogSamplingDomainType:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "{{schema-authority}}:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "{{schema-authority}}:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "{{schema-authority}}:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "{{schema-authority}}:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "{{schema-authority}}:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractReferenceType:1.0.0" + }, + { + "type": "object", + "properties": {} + }, + { + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-review-status": "Accepted", + "x-osdu-governance-model": "OPEN", + "x-osdu-governance-authorities": [ + "OSDU" + ], + "x-osdu-inheriting-from-kind": [ + { + "name": "ReferenceType", + "kind": "osdu:wks:AbstractReferenceType:1.0.0" + } + ] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/work-product-component/Activity.1.0.0.json b/deployments/shared-schemas/osdu/work-product-component/Activity.1.0.0.json new file mode 100644 index 0000000000000000000000000000000000000000..19a5e5a50287d8ffb533feba483adb217e9cfd14 --- /dev/null +++ b/deployments/shared-schemas/osdu/work-product-component/Activity.1.0.0.json @@ -0,0 +1,153 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "work-product-component--Activity", + "schemaVersionMajor": 1, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:work-product-component--Activity:1.0.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/work-product-component/Activity.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:work-product-component--Activity:1.0.0", + "title": "Activity", + "description": "Instance of a given activity", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:work-product-component\\-\\-Activity:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:work-product-component--Activity:d3ff5ea3-3070-51ec-aba2-d67370b1ed2b" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:work-product-component--Activity:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "{{schema-authority}}:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "{{schema-authority}}:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "{{schema-authority}}:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "{{schema-authority}}:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "{{schema-authority}}:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractWPCGroupType:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractWorkProductComponent:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractWPCActivity:1.0.0" + }, + { + "type": "object", + "properties": {} + }, + { + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-review-status": "Accepted", + "x-osdu-inheriting-from-kind": [ + { + "name": "WorkProductComponent", + "kind": "osdu:wks:AbstractWPCGroupType:1.0.0" + }, + { + "name": "Activity", + "kind": "osdu:wks:AbstractWPCActivity:1.0.0" + } + ] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/work-product-component/TubularUmbilical.1.0.0.json b/deployments/shared-schemas/osdu/work-product-component/TubularUmbilical.1.0.0.json index 7bb39a829f9766f043dc943b05c9c90ddd774f86..b07c5522226d6995c8bc5491df35a29a260619dc 100644 --- a/deployments/shared-schemas/osdu/work-product-component/TubularUmbilical.1.0.0.json +++ b/deployments/shared-schemas/osdu/work-product-component/TubularUmbilical.1.0.0.json @@ -224,7 +224,7 @@ "legal" ], "additionalProperties": false, - "x-osdu-review-status": "NOT APPROVED!", + "x-osdu-review-status": "Accepted", "x-osdu-supported-file-formats": [ "WITSML", "csv" diff --git a/deployments/shared-schemas/osdu/work-product-component/WellLog.1.1.0.json b/deployments/shared-schemas/osdu/work-product-component/WellLog.1.1.0.json new file mode 100644 index 0000000000000000000000000000000000000000..11fac5a745eb4d9b1f2ccce2bad6701eabee89aa --- /dev/null +++ b/deployments/shared-schemas/osdu/work-product-component/WellLog.1.1.0.json @@ -0,0 +1,483 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "work-product-component--WellLog", + "schemaVersionMajor": 1, + "schemaVersionMinor": 1, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:work-product-component--WellLog:1.1.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/work-product-component/WellLog.1.1.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:work-product-component--WellLog:1.1.0", + "title": "WellLog", + "description": "A well log is a data type that correlates a particular measurement or multiple measurements in a wellbore against depth and/or time within that wellbore. When plotted visually, well logs are typically long line graphs (called \"curves\") but may sometimes be discrete points or intervals. This schema object is intended for digital well logs, not raster log files or raster calibration files, but may be used for the latter in the absence of a defined OSDU schema for these use cases.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:work-product-component\\-\\-WellLog:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:work-product-component--WellLog:c2c79f1c-90ca-5c92-b8df-04dbe438f414" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:work-product-component--WellLog:1.1.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "{{schema-authority}}:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "{{schema-authority}}:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "{{schema-authority}}:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "{{schema-authority}}:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "{{schema-authority}}:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractWPCGroupType:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractWorkProductComponent:1.0.0" + }, + { + "type": "object", + "properties": { + "WellboreID": { + "type": "string", + "description": "The Wellbore where the Well Log Work Product Component was recorded", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Wellbore:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "Wellbore" + } + ] + }, + "WellLogTypeID": { + "type": "string", + "description": "Well Log Type short Description such as Raw; Evaluated; Composite;....", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-LogType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "LogType" + } + ] + }, + "TopMeasuredDepth": { + "type": "number", + "title": "Top Measured Depth", + "description": "Informational Top Measured Depth of the Well Log. Always populate SamplingStart and SamplingStop, which represents the real sampling of the WellLog, including non-depth sampling.", + "x-osdu-frame-of-reference": "UOM:length" + }, + "BottomMeasuredDepth": { + "type": "number", + "title": "Bottom Measured Depth", + "description": "Informational Bottom Measured Depth of the Well Log. Always populate SamplingStart and SamplingStop, which represents the real sampling of the WellLog, including non-depth sampling.", + "x-osdu-frame-of-reference": "UOM:length" + }, + "ServiceCompanyID": { + "type": "string", + "description": "The relationship to a Service Company, typically the producer or logging contractor.", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Organisation:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "Organisation" + } + ] + }, + "LogSource": { + "type": "string", + "description": "OSDU Native Log Source - will be updated for later releases - not to be used yet" + }, + "LogActivity": { + "type": "string", + "description": "Log Activity, used to describe the type of pass such as Calibration Pass - Main Pass - Repeated Pass" + }, + "LogRun": { + "type": "string", + "description": "Log Run - describe the run of the log - can be a number, but may be also a alphanumeric description such as a version name" + }, + "LogVersion": { + "type": "string", + "description": "Log Version" + }, + "LoggingService": { + "type": "string", + "description": "Logging Service - mainly a short concatenation of the names of the tools" + }, + "LogServiceDateInterval": { + "type": "object", + "description": "An interval built from two nested values : StartDate and EndDate. It applies to the whole log services and may apply to composite logs as [start of the first run job] and [end of the last run job]Log Service Date", + "properties": { + "StartDate": { + "type": "string", + "format": "date-time" + }, + "EndDate": { + "type": "string", + "format": "date-time" + } + } + }, + "ToolStringDescription": { + "type": "string", + "description": "Tool String Description - a long concatenation of the tools used for logging services such as GammaRay+NeutronPorosity" + }, + "LoggingDirection": { + "type": "string", + "description": "Specifies whether curves were collected downward or upward" + }, + "PassNumber": { + "type": "integer", + "description": "Indicates if the Pass is the Main one (1) or a repeated one - and it's level repetition" + }, + "ActivityType": { + "type": "string", + "description": "General method or circumstance of logging - MWD, completion, ..." + }, + "DrillingFluidProperty": { + "type": "string", + "description": "Type of mud at time of logging (oil, water based,...)" + }, + "HoleTypeLogging": { + "type": "string", + "description": "Description of the hole related type of logging - POSSIBLE VALUE : OpenHole / CasedHole / CementedHole", + "pattern": "^OPENHOLE|CASEDHOLE|CEMENTEDHOLE$" + }, + "VerticalMeasurementID": { + "type": "string", + "description": "DEPRECATED: Use data.VerticalMeasurement.VerticalReferenceID instead. References an entry in the Vertical Measurement array for the Wellbore identified by WellboreID, which defines the vertical reference datum for all curve measured depths. Either VerticalMeasurementID or VerticalMeasurement are populated." + }, + "VerticalMeasurement": { + "$ref": "{{schema-authority}}:wks:AbstractFacilityVerticalMeasurement:1.0.0", + "description": "The vertical measurement reference for the log curves, which defines the vertical reference datum for the logged depths. Either VerticalMeasurement or VerticalMeasurementID are populated." + }, + "Curves": { + "type": "array", + "x-osdu-indexing": { + "type": "nested" + }, + "items": { + "type": "object", + "properties": { + "CurveID": { + "type": "string", + "description": "The ID of the Well Log Curve" + }, + "DateStamp": { + "type": "string", + "description": "Date curve was created in the database", + "format": "date-time", + "x-osdu-frame-of-reference": "DateTime" + }, + "CurveVersion": { + "type": "string", + "description": "The Version of the Log Curve." + }, + "CurveQuality": { + "type": "string", + "description": "The Quality of the Log Curve." + }, + "InterpreterName": { + "type": "string", + "description": "The name of person who interpreted this Log Curve." + }, + "IsProcessed": { + "type": "boolean", + "description": "Indicates if the curve has been (pre)processed or if it is a raw recording" + }, + "NullValue": { + "type": "boolean", + "description": "Indicates that there is no measurement within the curve" + }, + "DepthCoding": { + "type": "string", + "description": "DEPRECATED: Replaced by boolean data.IsRegular. The Coding of the depth.", + "pattern": "^REGULAR|DISCRETE$" + }, + "Interpolate": { + "type": "boolean", + "description": "Whether curve can be interpolated or not" + }, + "TopDepth": { + "type": "number", + "description": "DEPRECATED: populate data.SamplingStart or data.SamplingStop instead, for informational purposes data.TopMeasuredDepth. SamplingStart and SamplingStop support other domains than depth.", + "x-osdu-frame-of-reference": "UOM_via_property:DepthUnit" + }, + "BaseDepth": { + "type": "number", + "description": "DEPRECATED: populate data.SamplingStart or data.SamplingStop instead, for informational purposes data.BottomMeasuredDepth. SamplingStart and SamplingStop support other domains than depth.", + "x-osdu-frame-of-reference": "UOM_via_property:DepthUnit" + }, + "DepthUnit": { + "type": "string", + "description": "DEPRECATED: use the meta[] to specify the sampling UnitOfMeasure (AbstractMetaItem of kind \"Unit\"; propertyNames[\"TopMeasuredDepth\", \"BottomMeasuredDepth\"]). Originally: Unit of Measure for Top and Base depth.", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-UnitOfMeasure:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "UnitOfMeasure" + } + ] + }, + "CurveUnit": { + "type": "string", + "description": "Unit of Measure for the Log Curve", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-UnitOfMeasure:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "UnitOfMeasure" + } + ] + }, + "Mnemonic": { + "type": "string", + "description": "The Mnemonic of the Log Curve is the value as received either from Raw Providers or from Internal Processing team" + }, + "LogCurveTypeID": { + "type": "string", + "description": "The related record id of the Log Curve Type - which is the standard mnemonic chosen by the company - OSDU provides an initial list", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-LogCurveType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "LogCurveType" + } + ] + }, + "LogCurveBusinessValueID": { + "type": "string", + "description": "The related record id of the Log Curve Business Value Type.", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-LogCurveBusinessValue:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "LogCurveBusinessValue" + } + ] + }, + "LogCurveMainFamilyID": { + "type": "string", + "description": "The related record id of the Log Curve Main Family Type - which is the Geological Physical Quantity measured - such as porosity.", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-LogCurveMainFamily:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "LogCurveMainFamily" + } + ] + }, + "LogCurveFamilyID": { + "type": "string", + "description": "The related record id of the Log Curve Family - which is the detailed Geological Physical Quantity Measured - such as neutron porosity", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-LogCurveFamily:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "LogCurveFamily" + } + ] + }, + "NumberOfColumns": { + "type": "integer", + "title": "Number Of Columns", + "description": "The number of columns present in this Curve for a single reference value. For simple logs this is typically 1; for image logs this holds the number of image traces or property series. Further information about the columns can be obtained via the respective log or curve APIs of the Domain Data Management Service.", + "example": 192 + } + } + } + }, + "FrameIdentifier": { + "type": "string", + "title": "Frame Identifier", + "description": "For multi-frame or multi-section files, this identifier defines the source frame in the file. If the identifier is an index number the index starts with zero and is converted to a string for this property.", + "example": 0 + }, + "SamplingInterval": { + "type": "number", + "title": "Sampling Interval", + "description": "For regularly sampled curves this property holds the sampling interval. For non regular sampling rate this property is not set. The IsRegular flag indicates whether SamplingInterval is required.", + "example": 0.0254, + "x-osdu-frame-of-reference": "UOM" + }, + "ReferenceCurveID": { + "type": "string", + "title": "Reference Curve ID", + "description": "The data.Curves[].CurveID, which holds the primary index (reference) values.", + "example": "MD" + }, + "SamplingStart": { + "type": "number", + "title": "Sampling Start", + "description": "The start value/first value of the ReferenceCurveID, typically the start depth of the logging.", + "example": 2500.0, + "x-osdu-frame-of-reference": "UOM" + }, + "SamplingStop": { + "type": "number", + "title": "Sampling Stop", + "description": "The stop value/last value of the ReferenceCurveID, typically the end depth of the logging.", + "example": 7500.0, + "x-osdu-frame-of-reference": "UOM" + }, + "SamplingDomainTypeID": { + "type": "string", + "title": "Sampling Domain Type ID", + "description": "The sampling domain, e.g. measured depth, true vertical, travel-time, calendar-time.", + "example": "namespace:reference-data--WellLogSamplingDomainType:Depth:", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-WellLogSamplingDomainType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "WellLogSamplingDomainType" + } + ] + }, + "CompanyID": { + "type": "string", + "title": "Company ID", + "description": "The relationship to company who engaged the service company (ServiceCompanyID) to perform the logging.", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Organisation:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "Organisation" + } + ] + }, + "CandidateReferenceCurveIDs": { + "type": "array", + "description": "Secondary index curves, which are alternative candidates to act as ReferenceCurveID. Generally not populated, except in the cases where multiple reference curves are present, e.g. measured depth and time.", + "items": { + "type": "string" + } + }, + "ZeroTime": { + "type": "string", + "description": "Optional time reference for (calender) time logs. The ISO date time string representing zero time. Not to be confused with seismic travel time zero. The latter is defined by SeismicReferenceDatum.", + "format": "date-time", + "x-osdu-frame-of-reference": "DateTime" + }, + "SeismicReferenceElevation": { + "$ref": "{{schema-authority}}:wks:AbstractFacilityVerticalMeasurement:1.0.0", + "description": "Populated only if the WellLog represents time-depth relationships or checkshots. It is expressed via the standard AbstractFacilityVerticalMeasurement. The following properties are expected to be present: VerticalMeasurementPathID (typically elevation), VerticalMeasurementTypeID as SeismicReferenceDatum, VerticalMeasurement holding the offset to either the VerticalCRSID or the chained VerticalReferenceID in the parent Wellbore." + }, + "IsRegular": { + "type": "boolean", + "title": "Is Regular Flag", + "description": "Boolean property indicating the sampling mode of the ReferenceCurveID. True means all reference curve values are regularly spaced (see SamplingInterval); false means irregular or discrete sample spacing." + } + } + }, + { + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-review-status": "Accepted", + "x-osdu-supported-file-formats": [ + "WITSML", + "DLIS", + "LIS", + "LAS2", + "LAS3", + "csv" + ], + "x-osdu-inheriting-from-kind": [ + { + "name": "WorkProductComponent", + "kind": "osdu:wks:AbstractWPCGroupType:1.0.0" + } + ] + } +} \ No newline at end of file diff --git a/deployments/shared-schemas/osdu/work-product-component/WellboreTrajectory.1.1.0.json b/deployments/shared-schemas/osdu/work-product-component/WellboreTrajectory.1.1.0.json new file mode 100644 index 0000000000000000000000000000000000000000..931570e89c874edd963c20fd780b8c22e2f705a2 --- /dev/null +++ b/deployments/shared-schemas/osdu/work-product-component/WellboreTrajectory.1.1.0.json @@ -0,0 +1,373 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "{{schema-authority}}", + "source": "wks", + "entityType": "work-product-component--WellboreTrajectory", + "schemaVersionMajor": 1, + "schemaVersionMinor": 1, + "schemaVersionPatch": 0, + "id": "{{schema-authority}}:wks:work-product-component--WellboreTrajectory:1.1.0" + }, + "createdBy": "OSDU Data Definition Group", + "scope": "SHARED", + "status": "DEVELOPMENT" + }, + "schema": { + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/work-product-component/WellboreTrajectory.1.1.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:work-product-component--WellboreTrajectory:1.1.0", + "title": "WellboreTrajectory", + "description": "Work Product Component describing an individual instance of a wellbore trajectory data object. Also called a deviation survey, wellbore trajectory is data that is used to calculate the position and spatial uncertainty of a planned or actual wellbore in 2-dimensional and 3-dimensional space.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:work-product-component\\-\\-WellboreTrajectory:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:work-product-component--WellboreTrajectory:606f224a-ef1f-5690-9843-d26cd7e33e10" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:work-product-component--WellboreTrajectory:1.1.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "{{schema-authority}}:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "{{schema-authority}}:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "{{schema-authority}}:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "{{schema-authority}}:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "{{schema-authority}}:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractWPCGroupType:1.0.0" + }, + { + "$ref": "{{schema-authority}}:wks:AbstractWorkProductComponent:1.0.0" + }, + { + "type": "object", + "properties": { + "ServiceCompanyID": { + "type": "string", + "title": "Service Company", + "description": "Name of the Survey Company.", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Organisation:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "Organisation" + } + ] + }, + "WellboreID": { + "type": "string", + "title": "Wellbore", + "description": "A unique name, code or number designated to the Wellbore.", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Wellbore:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "Wellbore" + } + ] + }, + "TopDepthMeasuredDepth": { + "type": "number", + "title": "Survey Top Measured Depth", + "description": "Measured depth in wellbore where the directional survey starts. This should equal the minimum station measured depth for this directional survey, regardless of whether the surveyed station represents an actual surveyed MD or not.", + "x-osdu-frame-of-reference": "UOM:length" + }, + "AzimuthReferenceType": { + "type": "string", + "title": "Azimuth Reference Type", + "description": "The North reference of the trajectory used to define the azimuth angular measurement values. For example, True North, Grid North, Magnetic North.", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-AzimuthReferenceType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "AzimuthReferenceType" + } + ] + }, + "CalculationMethodType": { + "type": "string", + "title": "Calculation Method Type", + "description": "Calculation Method Type used to compute the TVD, X OFFSET, Y OFFSET and DOG LEG SEVERITY values for this Directional Survey. For example, Radius of Curvature, Minimum Curvature, Balanced Tangential, etc.", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-CalculationMethodType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "CalculationMethodType" + } + ] + }, + "ProjectedCRSID": { + "type": "string", + "title": "Projected Coordinate Reference System ID", + "description": "Coordinate Reference System defining the Projection of the station EASTING and NORTHING values. If type is \"Grid North\" and EASTING and NORTHING attributes are stored, clearly identifying their projection is required.", + "example": "namespace:reference-data--CoordinateReferenceSystem:ProjectedCRS.EPSG.32615:", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-CoordinateReferenceSystem:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "CoordinateReferenceSystem" + } + ] + }, + "ActiveIndicator": { + "type": "boolean", + "title": "Active Survey Indicator", + "description": "A flag indicating if the survey is currently active or valid within his lifecycle stage, not necessarily the definitive survey." + }, + "SurveyType": { + "type": "string", + "title": "Directional Survey Type", + "description": "The type of this directional survey. For example a \"Directional Survey\" where MD, Inclination and Azimuth are all measured or a \"Position Log\" where Inclination and Azimuth are both null and only MD, TVD and X/Y Offsets are available) - or \"Full Survey\" where everything is fully filled-up, depth-inclination-azimuth." + }, + "AcquisitionDate": { + "type": "string", + "title": "Effective Date", + "description": "The date that the survey data was acquired on the field.", + "format": "date-time" + }, + "GeographicCRSID": { + "type": "string", + "title": "Geographic Coordinate Reference System", + "description": "Coordinate Reference System defining the Geodetic Datum of the station LATITUDE and LONGITUDE values. If LATITUDE and LONGITUDE attributes are stored, clearly identifying their Datum is required.", + "example": "namespace:reference-data--CoordinateReferenceSystem:GeodeticCRS.EPSG.4326:", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-CoordinateReferenceSystem:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "CoordinateReferenceSystem" + } + ] + }, + "AcquisitionRemark": { + "type": "string", + "title": "Survey Remark", + "description": "Remarks related to acquisition context which is not the same as Description which is a summary of the work-product-component." + }, + "SurveyReferenceIdentifier": { + "type": "string", + "title": "Survey Reference Identifier", + "description": "Unique or Distinctive Survey Reference Number, Job Number, File Number, Identifier, Label, Name, etc. as indicated on a directional survey report, file, etc. Use this attribute to allow correlation of the data in this Directional Survey back to the original source document, file, etc." + }, + "SurveyToolTypeID": { + "type": "string", + "title": "Type of the Survey Tool", + "description": "The type of tool or equipment used to acquire this Directional Survey. For example, gyroscopic, magnetic, MWD, TOTCO, acid bottle, etc. Follow OWSG reference data and support the ISCWSA survey tool definitions.", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-SurveyToolType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "SurveyToolType" + } + ] + }, + "SurveyVersion": { + "type": "string", + "title": "Survey Version", + "description": "The version of the wellbore survey deliverable received from the service provider - as given by this provider" + }, + "ExtrapolatedMeasuredDepth": { + "type": "number", + "title": "Extrapolated Measured Depth", + "description": "The measured depth to which the survey segment was extrapolated.", + "x-osdu-frame-of-reference": "UOM:length" + }, + "BaseDepthMeasuredDepth": { + "type": "number", + "title": "Survey Base Measured Depth", + "description": "Measured depth within the wellbore of the LAST surveyed station with recorded data. If a stored survey has been extrapolated to a deeper depth than the last surveyed station then that is the extrapolated measured depth and not the survey base depth.", + "x-osdu-frame-of-reference": "UOM:length" + }, + "TieMeasuredDepth": { + "type": "number", + "title": "Tie Measured Depth", + "description": "Tie-point depth measured along the wellbore from the measurement reference datum to the survey station - where tie point is the place on the originating survey where the current survey intersect it.", + "x-osdu-frame-of-reference": "UOM:length" + }, + "VerticalMeasurement": { + "$ref": "{{schema-authority}}:wks:AbstractFacilityVerticalMeasurement:1.0.0", + "description": "References an entry in the Vertical Measurement array for the Wellbore identified by WellboreID, which defines the vertical reference datum for all survey station measured depths." + }, + "AvailableTrajectoryStationProperties": { + "type": "array", + "title": "Available Trajectory Station Properties", + "description": "The array of TrajectoryStationProperty definitions describing the available properties for this instance of WellboreTrajectory.", + "x-osdu-indexing": { + "type": "flattened" + }, + "items": { + "type": "object", + "title": "Curve", + "description": "A set of properties describing a trajectory station property which is available for this instance of a WellboreTrajectory.", + "properties": { + "TrajectoryStationPropertyTypeID": { + "type": "string", + "title": "Trajectory Station Property Type ID", + "description": "The reference to a trajectory station property type - of if interpreted as channels, the curve or channel name type, identifying e.g. MD, Inclination, Azimuth. This is a relationship to a reference-data--TrajectoryStationPropertyType record id.", + "example": "partition-id:reference-data--TrajectoryStationPropertyType:AzimuthTN:", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-TrajectoryStationPropertyType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "TrajectoryStationPropertyType" + } + ] + }, + "StationPropertyUnitID": { + "type": "string", + "title": "Station Property Unit ID", + "description": "Unit of Measure for the station properties of type TrajectoryStationPropertyType.", + "example": "partition-id:reference-data--UnitOfMeasure:dega:", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-UnitOfMeasure:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "UnitOfMeasure" + } + ] + }, + "Name": { + "type": "string", + "title": "Name", + "description": "The name of the curve (e.g. column in a CSV document) as originally found. If absent The name of the TrajectoryCurveType is intended to be used.", + "example": "AzimuthTN" + } + } + } + }, + "AppliedOperations": { + "type": "array", + "title": "Applied Operations", + "description": "The audit trail of operations applied to the station coordinates from the original state to the current state. The list may contain operations applied prior to ingestion as well as the operations applied to produce the Wgs84Coordinates. The text elements refer to ESRI style CRS and Transformation names, which may have to be translated to EPSG standard names.", + "items": { + "type": "string" + } + }, + "CompanyID": { + "type": "string", + "title": "Company ID", + "description": "The relationship to company who engaged the service company (ServiceCompanyID) to perform the surveying.", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Organisation:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "Organisation" + } + ] + } + }, + "required": [ + "WellboreID", + "TopDepthMeasuredDepth", + "BaseDepthMeasuredDepth", + "VerticalMeasurement" + ] + }, + { + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-review-status": "Accepted", + "x-osdu-supported-file-formats": [ + "WITSML", + "P7/17", + "P7/2000", + "LAS2", + "LAS3", + "csv" + ], + "x-osdu-inheriting-from-kind": [ + { + "name": "WorkProductComponent", + "kind": "osdu:wks:AbstractWPCGroupType:1.0.0" + } + ] + } +} \ No newline at end of file diff --git a/devops/gcp/bootstrap.yaml b/devops/gcp/bootstrap.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9141ad962a258ee99be8b9eb47a27e9241030359 --- /dev/null +++ b/devops/gcp/bootstrap.yaml @@ -0,0 +1,24 @@ +osdu_gcp_bootstrap: + stage: bootstrap + image: python:3.8 + needs: ["osdu-gcp-deploy"] + extends: + - .osdu-gcp-variables + variables: + JSON_KEY: $OSDU_GCP_INTEGRATION_TESTER + AUDIENCE: $GOOGLE_AUDIENCE + DATA_PARTITION: $OSDU_TENANT + script: + - pip install -r $OSDU_GCP_DEPLOYMENTS_SUBDIR/requirements.txt + - export BEARER_TOKEN=$(python $OSDU_GCP_DEPLOYMENTS_SUBDIR/Token.py) + - python $OSDU_GCP_DEPLOYMENTS_SCRIPTS_SUBDIR/DeploySharedSchemas.py -u $OSDU_GCP_SCHEMA_URL/api/schema-service/v1/schema + + only: + variables: + - $OSDU_GCP == 'true' + +osdu-gcp-test: + needs: ["osdu_gcp_bootstrap"] + only: + variables: + - $OSDU_GCP == 'true' diff --git a/devops/gcp/configmap/.helmignore b/devops/gcp/configmap/.helmignore new file mode 100644 index 0000000000000000000000000000000000000000..0e8a0eb36f4ca2c939201c0d54b5d82a1ea34778 --- /dev/null +++ b/devops/gcp/configmap/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/devops/gcp/configmap/Chart.yaml b/devops/gcp/configmap/Chart.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a5adcc32aadf8ed61195097124591edaed1289d4 --- /dev/null +++ b/devops/gcp/configmap/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: gcp-schema-configmap +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/devops/gcp/configmap/templates/_helpers.tpl b/devops/gcp/configmap/templates/_helpers.tpl new file mode 100644 index 0000000000000000000000000000000000000000..fa972f28258c93aadbb4cc035ff78c549e61cc1a --- /dev/null +++ b/devops/gcp/configmap/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "configmap.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "configmap.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "configmap.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "configmap.labels" -}} +helm.sh/chart: {{ include "configmap.chart" . }} +{{ include "configmap.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "configmap.selectorLabels" -}} +app.kubernetes.io/name: {{ include "configmap.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "configmap.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "configmap.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/devops/gcp/configmap/templates/configmap.yml b/devops/gcp/configmap/templates/configmap.yml new file mode 100644 index 0000000000000000000000000000000000000000..426fca03f506d9c88eb4ec5ac82566a5082027d8 --- /dev/null +++ b/devops/gcp/configmap/templates/configmap.yml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + app: "{{ .Values.conf.app_name }}" + name: "{{ .Values.conf.configmap }}" + namespace: "{{ .Release.Namespace }}" +data: + LOG_LEVEL: "{{ .Values.data.log_level }}" + LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_WEB: "{{ .Values.data.log_level }}" + PARTITION_API: "{{ .Values.data.partition_api }}" + GOOGLE_AUDIENCES: "{{ .Values.data.google_audiences }}" + AUTHORIZE_API: "{{ .Values.data.authorize_api }}" + AUTHORIZE_API_KEY: "{{ .Values.data.authorize_api_key }}" + SHARED_TENANT_NAME: "{{ .Values.data.shared_tenant_name }}" diff --git a/devops/gcp/configmap/values.yaml b/devops/gcp/configmap/values.yaml new file mode 100644 index 0000000000000000000000000000000000000000..36b9e88027ccfbaf6272b661f080073f9f3220eb --- /dev/null +++ b/devops/gcp/configmap/values.yaml @@ -0,0 +1,15 @@ +# Default values for schema-configmap. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +data: + log_level: "" + authorize_api: "" + authorize_api_key: "Null" + partition_api: "" + google_audiences: "" + shared_tenant_name: "" + +conf: + configmap: "schema-config" + app_name: "schema" diff --git a/devops/gcp/deploy/.helmignore b/devops/gcp/deploy/.helmignore new file mode 100644 index 0000000000000000000000000000000000000000..0e8a0eb36f4ca2c939201c0d54b5d82a1ea34778 --- /dev/null +++ b/devops/gcp/deploy/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/devops/gcp/deploy/Chart.yaml b/devops/gcp/deploy/Chart.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0cde2760cd01e6474f7f98d64bf6d639dd60403f --- /dev/null +++ b/devops/gcp/deploy/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: gcp-schema-deploy +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/devops/gcp/deploy/templates/_helpers.tpl b/devops/gcp/deploy/templates/_helpers.tpl new file mode 100644 index 0000000000000000000000000000000000000000..7292128acbcaf2b7750af87569464aa1306ba407 --- /dev/null +++ b/devops/gcp/deploy/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "deploy.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "deploy.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "deploy.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "deploy.labels" -}} +helm.sh/chart: {{ include "deploy.chart" . }} +{{ include "deploy.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "deploy.selectorLabels" -}} +app.kubernetes.io/name: {{ include "deploy.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "deploy.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "deploy.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/devops/gcp/deploy/templates/deployment.yaml b/devops/gcp/deploy/templates/deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b3d3b4cc336c616f9d904da01f2a45dd99bf6105 --- /dev/null +++ b/devops/gcp/deploy/templates/deployment.yaml @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: "{{ .Values.conf.app_name }}" + name: "{{ .Values.conf.app_name }}" + namespace: "{{ .Release.Namespace }}" +spec: + selector: + matchLabels: + app: "{{ .Values.conf.app_name }}" + replicas: 1 + template: + metadata: + labels: + app: "{{ .Values.conf.app_name }}" + annotations: + rollme: {{ randAlphaNum 5 | quote }} + spec: + containers: + - name: "{{ .Values.conf.app_name }}" + image: "{{ .Values.data.image }}" + envFrom: + - configMapRef: + name: "{{ .Values.conf.configmap }}" + securityContext: + allowPrivilegeEscalation: false + runAsUser: 0 + ports: + - containerPort: 8080 + resources: + requests: + cpu: "{{ .Values.data.requests_cpu }}" + memory: "{{ .Values.data.requests_memory }}" + limits: + cpu: "{{ .Values.data.limits_cpu }}" + memory: "{{ .Values.data.limits_memory }}" + serviceAccountName: "{{ .Values.data.serviceAccountName }}" diff --git a/devops/gcp/deploy/templates/service.yaml b/devops/gcp/deploy/templates/service.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d92e1b6fb4b7890067aaf4d6b46c8310162d4d6e --- /dev/null +++ b/devops/gcp/deploy/templates/service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: "{{ .Values.conf.app_name }}" + annotations: + cloud.google.com/neg: '{"ingress": true}' + namespace: "{{ .Release.Namespace }}" + labels: + app: "{{ .Values.conf.app_name }}" + service: "{{ .Values.conf.app_name }}" +spec: + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + name: http + selector: + app: "{{ .Values.conf.app_name }}" diff --git a/devops/gcp/deploy/templates/virtual-service.yml b/devops/gcp/deploy/templates/virtual-service.yml new file mode 100644 index 0000000000000000000000000000000000000000..56fa8894a079e3ff1e5b366234d5e1e6e66045dc --- /dev/null +++ b/devops/gcp/deploy/templates/virtual-service.yml @@ -0,0 +1,19 @@ +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: "{{ .Values.conf.app_name }}" + namespace: "{{ .Release.Namespace }}" +spec: + hosts: + - "*" + gateways: + - service-gateway + http: + - match: + - uri: + prefix: "/api/schema-service" + route: + - destination: + port: + number: 80 + host: "{{ .Values.conf.app_name }}.{{ .Release.Namespace }}.svc.cluster.local" diff --git a/devops/gcp/deploy/values.yaml b/devops/gcp/deploy/values.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1e593dd6e89dba655fcfab1a019bd77183e3d8c3 --- /dev/null +++ b/devops/gcp/deploy/values.yaml @@ -0,0 +1,15 @@ +# Default values for schema-deploy. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +data: + requests_cpu: "0.25" + requests_memory: "256M" + limits_cpu: "1" + limits_memory: "1G" + serviceAccountName: "" + image: "" + +conf: + configmap: "schema-config" + app_name: "schema" diff --git a/docs/SchemaService-OSDU.md b/docs/SchemaService-OSDU.md index 131d9fdf21b2db4116d725843db3f7629b1fabdb..2f6d3e39e38a81a70c4721a9af054631cfd00806 100644 --- a/docs/SchemaService-OSDU.md +++ b/docs/SchemaService-OSDU.md @@ -4,6 +4,7 @@ - [Concepts](#concepts) - [How to use this service?](#using_this_service) - [Current limitation](#limitation) +- [Schema Validation](#schema-validation) ## Introduction @@ -245,4 +246,69 @@ The following parameters are required to create a schema: | schema | Schema definition | JSON object. Please refer example above. | Object | No | +## Schema Validation + +Schema service does multiple checks on different levels to make sure the inserted schema fits into validations on major, minor and patch version levels. +Following is the list of all validations that is performed while creating/updating any schema into the system. + +Schema version constitutes three parts, MAJOR, MINOR, and PATCH. Depending upon the nature of changes done to the structure of schema, the application may force the user to update the version number. At a high level, the upgrading versions would be required when: + * PATCH version when you make backwards compatible bug fixes or documentation/decoration changes + * MINOR version when you add functionality or contents in a backwards compatible manner, and + * MAJOR version when you make incompatible schema changes. e.g.Whenever an attribute is removed or `type` of an attribute is updated + +##### Permitted Changes for PATCH Version Increments: + +Changes in the values of following attributes is permitted at patch version increment. They are non-mandatory attributes so addition or removal of any of these attributes is permitted. + * title + * description + * example/examples + * pattern + * $id + * $comment + * any JSON extension tag starting with x-osdu + +##### Permitted Changes for MINOR Version Increments: + +In addition to all permitted changes in PATCH versions, the following actions are permitted: +1. Adding properties to existing data and nested structures +2. Adding object structures to below arrays: + * [allOf](https://json-schema.org/understanding-json-schema/reference/combining.html#allof) : To validate against allOf, the given data must be valid against all of the given subschemas + * [oneOf](https://json-schema.org/understanding-json-schema/reference/combining.html#oneof) : To validate against oneOf, the given data must be valid against exactly one of the given subschemas + * [anyOf](https://json-schema.org/understanding-json-schema/reference/combining.html#anyof) : To validate against anyOf, the given data must be valid against any (one or more) of the given subschemas +3. Changing the indices of objects containing title inside oneof or allof arrays +4. Changing indices of ref attributes keeping same text values +5. Changing the order of required attribute + +Explicitly not permitted is changing +1. The list of [required](https://json-schema.org/understanding-json-schema/reference/object.html#required-properties) properties +2. The state of [additionalProperties](https://json-schema.org/understanding-json-schema/reference/object.html#additional-properties) + * If `additionalProperties` is not present in original schema then it cannot be added with value as false + * If `additionalProperties` is present with value equal to false then cannot be removed/altered + * Value of `additionalProperties` cannot be changed from true to false +3. Changing type of any attribute + +It is permitted to declare existing properties as deprecated, preferable with instructions how to migrate from the previous to the next version. The documentation will automatically mark properties with strike-through if the description starts with "DEPRECATED: " . + +##### Permitted Changes for MAJOR Version Increments: + +Any changes are permitted, specifically +1. Removal of properties +2. Removal of structures in allOf, oneOf, anyOf +3. Changing the list of required properties +4. Changing the state of additionalProperties +5. Changing the indices of attributes without title in oneof and allof arrays +6. Changing type of any attribute +7. Breaking change introduced in external schema of `ref` attribute + +Following table gives you error message when breaking change is introduced at any level: + +##### Error codes along with message + +| Error Code | Condition | Error Message | +|------------|----------------|---------------| +| 400 | When breaking change not allowed at patch versionlevel |Patch version validation failed. Changes requiring a minor or major version increment were found; analysed version: 2.2.15 and 2.2.14. Updating the schema version to a higher minor or major version is required.| +| 400 | When breaking change not allowed at minor version level | Minor version validation failed. Breaking changes were found; analysed versions 1013.2.0 and 1013.1.0. Updating the schema version to a higher major version is required.| + +Note: The above array message would contain given schema version and existing schema in the system + diff --git a/provider/schema-aws/maven/settings.xml b/provider/schema-aws/maven/settings.xml index 72f847e1ed9a0b34d272fef93e0ee4ba39467b9c..1bfc43ac96aafb6790498c6f0acef3ca0818a98f 100644 --- a/provider/schema-aws/maven/settings.xml +++ b/provider/schema-aws/maven/settings.xml @@ -1,80 +1,80 @@ - - - aws-osdu-dev-maven - - true - - - - aws-osdu-dev-maven - ${env.AWS_OSDU_DEV_MAVEN_URL} - - - gitlab-os-core-common-maven - https://community.opengroup.org/api/v4/projects/67/packages/maven - - + + + aws-osdu-dev-maven + + true + + + + aws-osdu-dev-maven + ${env.AWS_OSDU_DEV_MAVEN_URL} + + + gitlab-os-core-common-maven + https://community.opengroup.org/api/v4/projects/67/packages/maven + + gitlab-os-core-lib-aws-maven https://community.opengroup.org/api/v4/projects/68/packages/maven - - - - credentialsConfiguration - - true - - - dev - no-default - no-default - Another-Access-Token-2021 - no-default - - - + + + + credentialsConfiguration + + true + + + dev + no-default + no-default + Another-Access-Token-2021 + no-default + + + - - - aws-osdu-dev-maven - aws - ${env.AWS_OSDU_DEV_MAVEN_AUTH_TOKEN} - - + + + aws-osdu-dev-maven + aws + ${env.AWS_OSDU_DEV_MAVEN_AUTH_TOKEN} + + - - - - - - - - - + + + aws-osdu-dev-maven + aws-osdu-dev-maven + https://osdu-dev-${AWS_ACCOUNT_ID}.d.codeartifact.us-east-1.amazonaws.com/maven/osdu-maven/ + central,!gitlab-os-core-common-maven,!gitlab-os-core-lib-aws-maven + + - - credentialsConfiguration - + + credentialsConfiguration + \ No newline at end of file diff --git a/provider/schema-aws/pom.xml b/provider/schema-aws/pom.xml index d0285959d675082b43967198afb479a458bb3c5a..79da5f24c2d4aaf05c8e7fe334c0c165e7741ed3 100644 --- a/provider/schema-aws/pom.xml +++ b/provider/schema-aws/pom.xml @@ -67,7 +67,7 @@ org.opengroup.osdu.core.aws os-core-lib-aws - 0.9.0 + 0.10.0 diff --git a/provider/schema-aws/src/main/resources/application.properties b/provider/schema-aws/src/main/resources/application.properties index 247373bf6f828963e7718181dbbc6d80a9cb4916..d05efcacb49b6dbd9a2d6e879568b697e160465e 100644 --- a/provider/schema-aws/src/main/resources/application.properties +++ b/provider/schema-aws/src/main/resources/application.properties @@ -19,7 +19,7 @@ aws.resource.prefix=${ENVIRONMENT} AUTHORIZE_API=${ENTITLEMENTS_BASE_URL}/api/entitlements/v2 AUTHORIZE_API_KEY= -PARTITION_API=${ENTITLEMENTS_BASE_URL}/api/partition/v1 +PARTITION_API=${PARTITION_BASE_URL}/api/partition/v1 LOG_PREFIX=schema @@ -55,4 +55,6 @@ server.ssl.key-store-type=PKCS12 server.ssl.key-store=${SSL_KEY_STORE_PATH:/certs/osduonaws.p12} server.ssl.key-alias=${SSL_KEY_ALIAS:osduonaws} server.ssl.key-password=${SSL_KEY_PASSWORD:} -server.ssl.key-store-password=${SSL_KEY_STORE_PASSWORD:} \ No newline at end of file +server.ssl.key-store-password=${SSL_KEY_STORE_PASSWORD:} + +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration \ No newline at end of file diff --git a/provider/schema-azure/pom.xml b/provider/schema-azure/pom.xml index 3f782a53bc353905b8a27a6c2b406a999715c63d..1cf04dada723c482cba6e5c6f95dba9b1d1753cf 100644 --- a/provider/schema-azure/pom.xml +++ b/provider/schema-azure/pom.xml @@ -29,15 +29,22 @@ jar - 0.6.1 - 0.6.9 + 2.1.7 + 0.10.1 + 0.10.0 0.10.0-SNAPSHOT 1.10.19 5.4.0 + 8.20.2 + + com.nimbusds + nimbus-jose-jwt + ${nimbus-jose-jwt-azure.version} + org.opengroup.osdu @@ -56,16 +63,6 @@ - - com.microsoft.azure - azure-active-directory-spring-boot-starter - - - org.springframework.boot - spring-boot-starter-logging - - - org.opengroup.osdu @@ -117,7 +114,6 @@ ${cucumber.version} test - io.cucumber cucumber-guice @@ -147,6 +143,17 @@ jackson-dataformat-cbor 2.12.3 + + com.azure.spring + azure-spring-boot-starter-active-directory + 3.4.0 + + + com.azure.spring + azure-spring-boot + 3.5.0 + + diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/api/AzureSchemaApi.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/api/AzureSchemaApi.java new file mode 100644 index 0000000000000000000000000000000000000000..d1af034d5f5ed9ce54f2b08a6c637b1fdf5a98cc --- /dev/null +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/api/AzureSchemaApi.java @@ -0,0 +1,47 @@ +// Copyright © Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.opengroup.osdu.schema.azure.api; + +import org.opengroup.osdu.schema.azure.interfaces.ISchemaServiceAzure; +import org.opengroup.osdu.schema.exceptions.ApplicationException; +import org.opengroup.osdu.schema.exceptions.BadRequestException; +import org.opengroup.osdu.schema.model.SchemaInfo; +import org.opengroup.osdu.schema.model.SchemaRequest; +import org.opengroup.osdu.schema.model.SchemaUpsertResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + + +@RestController +@RequestMapping("/schemas/system") +public class AzureSchemaApi { + + @Autowired + ISchemaServiceAzure schemaService; + + @PutMapping() + @PreAuthorize("@authorizationFilterSP.hasPermissions()") + public ResponseEntity upsertSystemSchema(@Valid @RequestBody SchemaRequest schemaRequest) + throws ApplicationException, BadRequestException { + SchemaUpsertResponse upsertResp = schemaService.upsertSystemSchema(schemaRequest); + ResponseEntity response = new ResponseEntity<>(upsertResp.getSchemaInfo(), upsertResp.getHttpCode()); + return response; + } + +} diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/auth/AuthorizationFilterSP.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/auth/AuthorizationFilterSP.java new file mode 100644 index 0000000000000000000000000000000000000000..0441565a6081a034fa5026d270a6f142a0902ffa --- /dev/null +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/auth/AuthorizationFilterSP.java @@ -0,0 +1,23 @@ +package org.opengroup.osdu.schema.azure.auth; + +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.schema.azure.interfaces.IAuthorizationServiceForServicePrincipal; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.context.annotation.RequestScope; + +@Component("authorizationFilterSP") +@RequestScope +public class AuthorizationFilterSP { + + @Autowired + private DpsHeaders headers; + + @Autowired + private IAuthorizationServiceForServicePrincipal authorizationService; + + public boolean hasPermissions() { + headers.put(DpsHeaders.USER_EMAIL, "ServicePrincipalUser"); + return authorizationService.isDomainAdminServiceAccount(); + } +} diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/di/SystemResourceConfig.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/di/SystemResourceConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..095a551ed6754db6a0479059c06d8163150bc8cd --- /dev/null +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/di/SystemResourceConfig.java @@ -0,0 +1,16 @@ +package org.opengroup.osdu.schema.azure.di; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@Getter +@Setter +@ConfigurationProperties("azure.system") +public class SystemResourceConfig { + private String storageContainerName; + private String cosmosDatabase; + private String sharedTenant; +} diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureAuthorityStore.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureAuthorityStore.java index 157c6961d4777edc936aaf5f13bfa1cef3c0e10a..494fb5909c851c8eaff532c26318307c1128f8d9 100644 --- a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureAuthorityStore.java +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureAuthorityStore.java @@ -21,6 +21,7 @@ import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.schema.azure.definitions.AuthorityDoc; +import org.opengroup.osdu.schema.azure.di.SystemResourceConfig; import org.opengroup.osdu.schema.constants.SchemaConstants; import org.opengroup.osdu.azure.cosmosdb.CosmosStore; @@ -31,6 +32,7 @@ import org.opengroup.osdu.schema.exceptions.NotFoundException; import org.opengroup.osdu.schema.model.Authority; import org.opengroup.osdu.schema.provider.interfaces.schemainfostore.IAuthorityStore; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Repository; import java.text.MessageFormat; @@ -58,6 +60,9 @@ public class AzureAuthorityStore implements IAuthorityStore { @Autowired JaxRsDpsLog log; + @Autowired + SystemResourceConfig systemResourceConfig; + /** * Method to get Authority from Azure store * @param authorityId @@ -69,9 +74,15 @@ public class AzureAuthorityStore implements IAuthorityStore { public Authority get(String authorityId) throws NotFoundException, ApplicationException { String id = headers.getPartitionId() + ":" + authorityId; - - AuthorityDoc authorityDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, authorityContainer, id, authorityId, AuthorityDoc.class) - .orElseThrow(() -> new NotFoundException("bad input parameter")); + AuthorityDoc authorityDoc; + + if (systemResourceConfig.getSharedTenant().equalsIgnoreCase(headers.getPartitionId())) { + authorityDoc = cosmosStore.findItem(systemResourceConfig.getCosmosDatabase(), authorityContainer, id, authorityId, AuthorityDoc.class) + .orElseThrow(() -> new NotFoundException("bad input parameter")); + } else { + authorityDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, authorityContainer, id, authorityId, AuthorityDoc.class) + .orElseThrow(() -> new NotFoundException("bad input parameter")); + } return authorityDoc.getAuthority(); } @@ -89,7 +100,11 @@ public class AzureAuthorityStore implements IAuthorityStore { try { AuthorityDoc authorityDoc = new AuthorityDoc(id, authority); - cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, authorityContainer, id, authorityDoc); + if (systemResourceConfig.getSharedTenant().equalsIgnoreCase(headers.getPartitionId())) { + cosmosStore.createItem(systemResourceConfig.getCosmosDatabase(), authorityContainer, id, authorityDoc); + } else { + cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, authorityContainer, id, authorityDoc); + } } catch (AppException ex) { if (ex.getError().getCode() == 409) { log.warning(SchemaConstants.AUTHORITY_EXISTS_ALREADY_REGISTERED); diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureEntityTypeStore.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureEntityTypeStore.java index f4371947efac89872ff5de0681b58fb43367429f..7a88a69053fff9aa8d4144588edc657a4988cbcc 100644 --- a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureEntityTypeStore.java +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureEntityTypeStore.java @@ -20,6 +20,7 @@ import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.schema.azure.definitions.EntityTypeDoc; +import org.opengroup.osdu.schema.azure.di.SystemResourceConfig; import org.opengroup.osdu.schema.constants.SchemaConstants; import org.opengroup.osdu.schema.exceptions.ApplicationException; import org.opengroup.osdu.schema.exceptions.BadRequestException; @@ -27,6 +28,7 @@ import org.opengroup.osdu.schema.exceptions.NotFoundException; import org.opengroup.osdu.schema.model.EntityType; import org.opengroup.osdu.schema.provider.interfaces.schemainfostore.IEntityTypeStore; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Repository; import lombok.extern.java.Log; @@ -55,6 +57,9 @@ public class AzureEntityTypeStore implements IEntityTypeStore { @Autowired JaxRsDpsLog log; + @Autowired + SystemResourceConfig systemResourceConfig; + /** * Method to get entity type from azure store * @param entityTypeId @@ -66,9 +71,15 @@ public class AzureEntityTypeStore implements IEntityTypeStore { public EntityType get(String entityTypeId) throws NotFoundException, ApplicationException { String id = headers.getPartitionId() + ":" + entityTypeId; - - EntityTypeDoc entityTypeDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, entityTypeContainer, id, entityTypeId, EntityTypeDoc.class) - .orElseThrow(() -> new NotFoundException("bad input parameter")); + EntityTypeDoc entityTypeDoc; + + if (systemResourceConfig.getSharedTenant().equalsIgnoreCase(headers.getPartitionId())) { + entityTypeDoc = cosmosStore.findItem(systemResourceConfig.getCosmosDatabase(), entityTypeContainer, id, entityTypeId, EntityTypeDoc.class) + .orElseThrow(() -> new NotFoundException("bad input parameter")); + } else { + entityTypeDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, entityTypeContainer, id, entityTypeId, EntityTypeDoc.class) + .orElseThrow(() -> new NotFoundException("bad input parameter")); + } return entityTypeDoc.getEntityType(); } @@ -86,7 +97,11 @@ public class AzureEntityTypeStore implements IEntityTypeStore { try { EntityTypeDoc entityTypeDoc = new EntityTypeDoc(id, entityType); - cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, entityTypeContainer, id, entityTypeDoc); + if (systemResourceConfig.getSharedTenant().equalsIgnoreCase(headers.getPartitionId())) { + cosmosStore.createItem(systemResourceConfig.getCosmosDatabase(), entityTypeContainer, id, entityTypeDoc); + } else { + cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, entityTypeContainer, id, entityTypeDoc); + } } catch (AppException ex) { if (ex.getError().getCode() == 409) { log.warning(SchemaConstants.ENTITY_TYPE_EXISTS); diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureSchemaInfoStore.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureSchemaInfoStore.java index 26a16ea8b9a3320a7d2d00f1c31f6c93abc75822..ecb9611db8e80b0cd09edcdd01536ba601686c80 100644 --- a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureSchemaInfoStore.java +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureSchemaInfoStore.java @@ -31,6 +31,7 @@ import org.opengroup.osdu.core.common.model.tenant.TenantInfo; import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory; import org.opengroup.osdu.schema.azure.definitions.FlattenedSchemaInfo; import org.opengroup.osdu.schema.azure.definitions.SchemaInfoDoc; +import org.opengroup.osdu.schema.azure.di.SystemResourceConfig; import org.opengroup.osdu.schema.constants.SchemaConstants; import org.opengroup.osdu.schema.enums.SchemaScope; import org.opengroup.osdu.schema.enums.SchemaStatus; @@ -80,6 +81,9 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { @Value("${shared.tenant.name:common}") private String sharedTenant; + @Autowired + SystemResourceConfig systemResourceConfig; + @Autowired JaxRsDpsLog log; @@ -99,10 +103,10 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { SchemaIdentity schemaIdentity = schemaKindToSchemaIdentity(schemaId); String partitioningKey = createSchemaInfoPartitionKey(schemaIdentity); - SchemaInfoDoc schemaInfoDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, partitioningKey, SchemaInfoDoc.class) - .orElseThrow(() -> new NotFoundException(SchemaConstants.SCHEMA_NOT_PRESENT)); + SchemaInfoDoc schemaInfoDoc = findItemInCosmosStore(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, partitioningKey, SchemaInfoDoc.class) + .orElseThrow(() -> new NotFoundException(SchemaConstants.SCHEMA_NOT_PRESENT)); - return getSchemaInfoObject(schemaInfoDoc.getFlattenedSchemaInfo()); + return getSchemaInfoObject(schemaInfoDoc.getFlattenedSchemaInfo(), headers.getPartitionId()); } /** @@ -120,7 +124,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { String partitionKey = createSchemaInfoPartitionKey(schema.getSchemaInfo().getSchemaIdentity()); SchemaInfoDoc schemaInfoDoc = new SchemaInfoDoc(id, partitionKey, flattenedSchemaInfo); try { - cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, partitionKey, schemaInfoDoc); + crateItemInCosmos(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, partitionKey, schemaInfoDoc); } catch (AppException ex) { if (ex.getError().getCode() == 409) { log.warning(SchemaConstants.SCHEMA_ID_EXISTS); @@ -132,7 +136,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { } log.info(SchemaConstants.SCHEMA_INFO_CREATED); - return getSchemaInfoObject(flattenedSchemaInfo); + return getSchemaInfoObject(flattenedSchemaInfo, headers.getPartitionId()); } /** @@ -150,14 +154,14 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { String partitionKey = createSchemaInfoPartitionKey(schema.getSchemaInfo().getSchemaIdentity()); SchemaInfoDoc schemaInfoDoc = new SchemaInfoDoc(id, partitionKey, flattenedSchemaInfo); try { - cosmosStore.upsertItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, partitionKey,schemaInfoDoc); + upsertItemInCosmos(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, partitionKey,schemaInfoDoc); } catch (Exception ex) { log.error(MessageFormat.format(SchemaConstants.OBJECT_INVALID, ex.getMessage())); throw new ApplicationException(SchemaConstants.SCHEMA_CREATION_FAILED_INVALID_OBJECT); } log.info(SchemaConstants.SCHEMA_INFO_UPDATED); - return getSchemaInfoObject(flattenedSchemaInfo); + return getSchemaInfoObject(flattenedSchemaInfo, headers.getPartitionId()); } /** @@ -175,13 +179,13 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { String partitionKey = createSchemaInfoPartitionKey(schemaIdentity); // Check whether SchemaInfo already exists - Boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, partitionKey, SchemaInfoDoc.class).isPresent(); + Boolean exists = findItemInCosmosStore(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, partitionKey, SchemaInfoDoc.class).isPresent(); if (!exists) { return false; } // Delete the item. - cosmosStore.deleteItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, headers.getPartitionId()); + deleteItemInCosmos(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, headers.getPartitionId()); return true; } @@ -209,7 +213,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { pars.add(new SqlParameter("@entityType", schemaInfo.getSchemaIdentity().getEntityType())); pars.add(new SqlParameter("@majorVersion", schemaInfo.getSchemaIdentity().getSchemaVersionMajor())); - List schemaInfoList = cosmosStore.queryItems(headers.getPartitionId(), cosmosDBName,schemaInfoContainer, query, options, SchemaInfoDoc.class); + List schemaInfoList = queryItemsInCosmos(headers.getPartitionId(), cosmosDBName,schemaInfoContainer, query, options, SchemaInfoDoc.class); TreeMap sortedMap = new TreeMap<>(Collections.reverseOrder()); for (SchemaInfoDoc info : schemaInfoList) @@ -244,7 +248,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { SchemaIdentity schemaIdentity = schemaKindToSchemaIdentity(schemaInfo.getSupersededBy().getId()); String partitionKey = createSchemaInfoPartitionKey(schemaIdentity); - if ( !cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, partitionKey, FlattenedSchemaInfo.class).isPresent()) { + if ( !findItemInCosmosStore(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, partitionKey, FlattenedSchemaInfo.class).isPresent()) { log.error(SchemaConstants.INVALID_SUPERSEDEDBY_ID); throw new BadRequestException(SchemaConstants.INVALID_SUPERSEDEDBY_ID); } @@ -268,13 +272,13 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { .build(); } - private SchemaInfo getSchemaInfoObject(FlattenedSchemaInfo flattenedSchemaInfo) { + private SchemaInfo getSchemaInfoObject(FlattenedSchemaInfo flattenedSchemaInfo, String dataPartitionId) { SchemaIdentity superSededBy = null; if (!flattenedSchemaInfo.getSupersededBy().isEmpty()) { - String id = headers.getPartitionId() + ":" + flattenedSchemaInfo.getSupersededBy(); + String id = dataPartitionId + ":" + flattenedSchemaInfo.getSupersededBy(); SchemaIdentity schemaIdentity = schemaKindToSchemaIdentity(flattenedSchemaInfo.getSupersededBy()); String partitionKey = createSchemaInfoPartitionKey(schemaIdentity); - SchemaInfoDoc doc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, partitionKey, SchemaInfoDoc.class).get(); + SchemaInfoDoc doc = findItemInCosmosStore(dataPartitionId, cosmosDBName, schemaInfoContainer, id, partitionKey, SchemaInfoDoc.class).get(); superSededBy = getSchemaIdentity(doc.getFlattenedSchemaInfo()); } @@ -352,12 +356,12 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { query.getParameters().add(new SqlParameter(param, parameterMap.get(param))); } - List schemaInfoList = cosmosStore.queryItems(tenantId, cosmosDBName,schemaInfoContainer, query, options, SchemaInfoDoc.class); + List schemaInfoList = queryItemsInCosmos(tenantId, cosmosDBName,schemaInfoContainer, query, options, SchemaInfoDoc.class); List schemaList = new LinkedList<>(); for (SchemaInfoDoc info: schemaInfoList) { - schemaList.add(getSchemaInfoObject(info.getFlattenedSchemaInfo())); + schemaList.add(getSchemaInfoObject(info.getFlattenedSchemaInfo(), tenantId)); } if (queryParams.getLatestVersion() != null && queryParams.getLatestVersion()) { @@ -386,7 +390,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { String id = tenant + ":" + schemaId; String partitionKey = createSchemaInfoPartitionKey(schemaKindToSchemaIdentity(schemaId)); try { - Boolean exists = cosmosStore.findItem(tenant, cosmosDBName, schemaInfoContainer, id, partitionKey, SchemaInfoDoc.class).isPresent(); + Boolean exists = findItemInCosmosStore(tenant, cosmosDBName, schemaInfoContainer, id, partitionKey, SchemaInfoDoc.class).isPresent(); if (exists) { return false; } @@ -468,5 +472,72 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { ":"+schemaIdentity.getEntityType()+ ":"+schemaIdentity.getSchemaVersionMajor().toString(); } + + private Optional findItemInCosmosStore( + String dataPartitionId, + String dataBaseName, + String containerName, + String id, + String partitionKey, + Class clazz) { + if (systemResourceConfig.getSharedTenant().equalsIgnoreCase(dataPartitionId)) { + return cosmosStore.findItem(systemResourceConfig.getCosmosDatabase(), containerName, id, partitionKey, clazz); + } else { + return cosmosStore.findItem(dataPartitionId, dataBaseName, containerName, id, partitionKey, clazz); + } + } + + private void crateItemInCosmos( + String dataPartitionId, + String dataBaseName, + String containerName, + String partitionKey, + T item) { + if (systemResourceConfig.getSharedTenant().equalsIgnoreCase(dataPartitionId)) { + cosmosStore.createItem(systemResourceConfig.getCosmosDatabase(), containerName, partitionKey, item); + } else { + cosmosStore.createItem(dataPartitionId, dataBaseName, containerName, partitionKey, item); + } + } + + private void upsertItemInCosmos( + String dataPartitionId, + String dataBaseName, + String containerName, + String partitionKey, + T item) { + if (systemResourceConfig.getSharedTenant().equalsIgnoreCase(dataPartitionId)) { + cosmosStore.upsertItem(systemResourceConfig.getCosmosDatabase(), containerName, partitionKey, item); + } else { + cosmosStore.upsertItem(dataPartitionId, dataBaseName, containerName, partitionKey, item); + } + } + + private void deleteItemInCosmos( + String dataPartitionId, + String dataBaseName, + String containerName, + String id, + String partitionKey) { + if (systemResourceConfig.getSharedTenant().equalsIgnoreCase(dataPartitionId)) { + cosmosStore.deleteItem(systemResourceConfig.getCosmosDatabase(), containerName, id, partitionKey); + } else { + cosmosStore.deleteItem(dataPartitionId, dataBaseName, containerName, id, partitionKey); + } + } + + private List queryItemsInCosmos( + String dataPartitionId, + String cosmosDBName, + String collection, + SqlQuerySpec query, + CosmosQueryRequestOptions options, + Class clazz) { + if (systemResourceConfig.getSharedTenant().equalsIgnoreCase(dataPartitionId)) { + return cosmosStore.queryItems(systemResourceConfig.getCosmosDatabase(), collection, query, options, clazz); + } else { + return cosmosStore.queryItems(dataPartitionId, cosmosDBName, collection, query, options, clazz); + } + } } diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureSourceStore.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureSourceStore.java index d1515c5310fa37f2516d2adabfc1b0f71e0d4b69..2b6be77855f912db41ab3df642af534c3f346782 100644 --- a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureSourceStore.java +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureSourceStore.java @@ -21,6 +21,7 @@ import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.schema.azure.definitions.SourceDoc; +import org.opengroup.osdu.schema.azure.di.SystemResourceConfig; import org.opengroup.osdu.schema.constants.SchemaConstants; import org.opengroup.osdu.schema.exceptions.ApplicationException; import org.opengroup.osdu.schema.exceptions.BadRequestException; @@ -28,6 +29,7 @@ import org.opengroup.osdu.schema.exceptions.NotFoundException; import org.opengroup.osdu.schema.model.Source; import org.opengroup.osdu.schema.provider.interfaces.schemainfostore.ISourceStore; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Repository; /** @@ -53,6 +55,9 @@ public class AzureSourceStore implements ISourceStore { @Autowired JaxRsDpsLog log; + @Autowired + SystemResourceConfig systemResourceConfig; + /** * Method to create Source in azure store * @param sourceId @@ -64,8 +69,15 @@ public class AzureSourceStore implements ISourceStore { public Source get(String sourceId) throws NotFoundException, ApplicationException { String id = headers.getPartitionId().toString() + ":" + sourceId; - SourceDoc sourceDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, sourceContainer, id, sourceId, SourceDoc.class) - .orElseThrow(() -> new NotFoundException("bad input parameter")); + SourceDoc sourceDoc; + + if (systemResourceConfig.getSharedTenant().equalsIgnoreCase(headers.getPartitionId())) { + sourceDoc = cosmosStore.findItem(systemResourceConfig.getCosmosDatabase(), sourceContainer, id, sourceId, SourceDoc.class) + .orElseThrow(() -> new NotFoundException("bad input parameter")); + } else { + sourceDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, sourceContainer, id, sourceId, SourceDoc.class) + .orElseThrow(() -> new NotFoundException("bad input parameter")); + } return sourceDoc.getSource(); } @@ -83,7 +95,11 @@ public class AzureSourceStore implements ISourceStore { try { SourceDoc sourceDoc = new SourceDoc(id, source); - cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, sourceContainer, id, sourceDoc); + if (systemResourceConfig.getSharedTenant().equalsIgnoreCase(headers.getPartitionId())) { + cosmosStore.createItem(systemResourceConfig.getCosmosDatabase(), sourceContainer, id, sourceDoc); + } else { + cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, sourceContainer, id, sourceDoc); + } } catch (AppException ex) { if (ex.getError().getCode() == 409) { log.warning(SchemaConstants.SOURCE_EXISTS); diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemastore/AzureSchemaStore.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemastore/AzureSchemaStore.java index dc758a4b7897f36cfa62dd263a3a13e2ff906e76..3462747d50781cd98c47114aec302ee181e8d7de 100644 --- a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemastore/AzureSchemaStore.java +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemastore/AzureSchemaStore.java @@ -18,11 +18,13 @@ import org.opengroup.osdu.azure.blobstorage.BlobStore; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.schema.azure.di.CosmosContainerConfig; +import org.opengroup.osdu.schema.azure.di.SystemResourceConfig; import org.opengroup.osdu.schema.constants.SchemaConstants; import org.opengroup.osdu.schema.exceptions.ApplicationException; import org.opengroup.osdu.schema.exceptions.NotFoundException; import org.opengroup.osdu.schema.provider.interfaces.schemastore.ISchemaStore; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Repository; /** @@ -45,6 +47,9 @@ public class AzureSchemaStore implements ISchemaStore { @Autowired JaxRsDpsLog log; + @Autowired + SystemResourceConfig systemResourceConfig; + /** * Method to get schema from azure Storage given Tenant ProjectInfo * @@ -59,7 +64,12 @@ public class AzureSchemaStore implements ISchemaStore { public String getSchema(String dataPartitionId, String filePath) throws ApplicationException, NotFoundException { filePath = dataPartitionId + ":" + filePath + SchemaConstants.JSON_EXTENSION; try { - String content = blobStore.readFromStorageContainer(dataPartitionId, filePath, config.containerName()); + String content = null; + if (systemResourceConfig.getSharedTenant().equalsIgnoreCase(dataPartitionId)) { + content = blobStore.readFromStorageContainer(filePath, systemResourceConfig.getStorageContainerName()); + } else { + content = blobStore.readFromStorageContainer(dataPartitionId, filePath, config.containerName()); + } if (content != null) return content; else @@ -84,7 +94,11 @@ public class AzureSchemaStore implements ISchemaStore { filePath = dataPartitionId + ":" + filePath + SchemaConstants.JSON_EXTENSION; try { - blobStore.writeToStorageContainer(dataPartitionId, filePath, content, config.containerName()); + if (systemResourceConfig.getSharedTenant().equalsIgnoreCase(headers.getPartitionId())) { + blobStore.writeToStorageContainer(filePath, content, systemResourceConfig.getStorageContainerName()); + } else { + blobStore.writeToStorageContainer(dataPartitionId, filePath, content, config.containerName()); + } log.info(SchemaConstants.SCHEMA_CREATED); return filePath; } catch (Exception ex) { @@ -105,7 +119,11 @@ public class AzureSchemaStore implements ISchemaStore { try { - return blobStore.deleteFromStorageContainer(dataPartitionId, filePath, config.containerName()); + if (systemResourceConfig.getSharedTenant().equalsIgnoreCase(headers.getPartitionId())) { + return blobStore.deleteFromStorageContainer(filePath, systemResourceConfig.getStorageContainerName()); + } else { + return blobStore.deleteFromStorageContainer(dataPartitionId, filePath, config.containerName()); + } } catch (Exception e) { diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/interfaces/IAuthorizationServiceForServicePrincipal.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/interfaces/IAuthorizationServiceForServicePrincipal.java new file mode 100644 index 0000000000000000000000000000000000000000..2c84ab64018f7cfadb79d075ec5d8398a5080fed --- /dev/null +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/interfaces/IAuthorizationServiceForServicePrincipal.java @@ -0,0 +1,5 @@ +package org.opengroup.osdu.schema.azure.interfaces; + +public interface IAuthorizationServiceForServicePrincipal { + boolean isDomainAdminServiceAccount(); +} diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/interfaces/ISchemaServiceAzure.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/interfaces/ISchemaServiceAzure.java new file mode 100644 index 0000000000000000000000000000000000000000..e99616179b6faadf041cce869fda458a48d28782 --- /dev/null +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/interfaces/ISchemaServiceAzure.java @@ -0,0 +1,43 @@ +// Copyright © Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.opengroup.osdu.schema.azure.interfaces; + +import org.opengroup.osdu.schema.exceptions.ApplicationException; +import org.opengroup.osdu.schema.exceptions.BadRequestException; +import org.opengroup.osdu.schema.model.SchemaInfo; +import org.opengroup.osdu.schema.model.SchemaRequest; +import org.opengroup.osdu.schema.model.SchemaUpsertResponse; + +public interface ISchemaServiceAzure { + + /** + * This method creates a shared schema + * @param schemaRequest schema request + * @return Schema info of created schema + * @throws ApplicationException + * @throws BadRequestException + */ + SchemaInfo createSystemSchema(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException; + + /** + * This method first tries to update the schema with the given schema-id. If there is no schema found, + * it tries to create the new shared schema. + * @param schemaRequest schema request + * @return schema upsert response + * @throws ApplicationException + * @throws BadRequestException + */ + SchemaUpsertResponse upsertSystemSchema(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException; +} diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/service/serviceimpl/AuthorizationServiceForServicePrincipalImpl.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/service/serviceimpl/AuthorizationServiceForServicePrincipalImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..c396094c7a08446271b63a5fc3008588ec22989a --- /dev/null +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/service/serviceimpl/AuthorizationServiceForServicePrincipalImpl.java @@ -0,0 +1,65 @@ +package org.opengroup.osdu.schema.azure.service.serviceimpl; + + +import org.opengroup.osdu.schema.azure.interfaces.IAuthorizationServiceForServicePrincipal; +import com.azure.spring.autoconfigure.aad.UserPrincipal; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Component; + +import java.util.Map; + +@Component +public class AuthorizationServiceForServicePrincipalImpl implements IAuthorizationServiceForServicePrincipal { + enum UserType { + REGULAR_USER, + GUEST_USER, + SERVICE_PRINCIPAL + } + + @Override + public boolean isDomainAdminServiceAccount() { + final Object principal = getUserPrincipal(); + + if (!(principal instanceof UserPrincipal)) { + return false; + } + + final UserPrincipal userPrincipal = (UserPrincipal) principal; + + UserType type = getType(userPrincipal); + if (type == UserType.SERVICE_PRINCIPAL) { + return true; + } + return false; + } + + /** + * The internal method to get the user principal. + * + * @return user principal + */ + private Object getUserPrincipal() { + final Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + return auth.getPrincipal(); + } + + /** + * Convenience method returning the type of user + * + * @param u user principal to check + * @return the user type + */ + private UserType getType(UserPrincipal u) { + UserType type; + Map claims = u.getClaims(); + if (claims != null && claims.get("upn") != null) { + type = UserType.REGULAR_USER; + } else if (claims != null && claims.get("unique_name") != null) { + type = UserType.GUEST_USER; + } else { + type = UserType.SERVICE_PRINCIPAL; + } + return type; + } +} diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/service/serviceimpl/SchemaServiceAzure.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/service/serviceimpl/SchemaServiceAzure.java new file mode 100644 index 0000000000000000000000000000000000000000..ab9b22617d9aaaf998944c7b4f768555a4be9cde --- /dev/null +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/service/serviceimpl/SchemaServiceAzure.java @@ -0,0 +1,55 @@ +// Copyright © Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.opengroup.osdu.schema.azure.service.serviceimpl; + +import lombok.RequiredArgsConstructor; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.schema.azure.di.SystemResourceConfig; +import org.opengroup.osdu.schema.azure.interfaces.ISchemaServiceAzure; +import org.opengroup.osdu.schema.constants.SchemaConstants; +import org.opengroup.osdu.schema.exceptions.ApplicationException; +import org.opengroup.osdu.schema.exceptions.BadRequestException; +import org.opengroup.osdu.schema.model.SchemaInfo; +import org.opengroup.osdu.schema.model.SchemaRequest; +import org.opengroup.osdu.schema.model.SchemaUpsertResponse; +import org.opengroup.osdu.schema.service.ISchemaService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class SchemaServiceAzure implements ISchemaServiceAzure { + + private final ISchemaService schemaServiceCore; + + final DpsHeaders headers; + + private final SystemResourceConfig systemResourceConfig; + + public SchemaInfo createSystemSchema(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException { + updateDataPartitionId(); + return schemaServiceCore.createSchema(schemaRequest); + } + + public SchemaUpsertResponse upsertSystemSchema(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException { + updateDataPartitionId(); + return schemaServiceCore.upsertSchema(schemaRequest); + } + + private void updateDataPartitionId() { + headers.put(SchemaConstants.DATA_PARTITION_ID, systemResourceConfig.getSharedTenant()); + } +} diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/security/AADSecurityConfig.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/security/AADSecurityConfig.java index 09d57f1b5a87c7ecaf5d841fab7f3ec9fd2e1528..2e6751282dabbc083013f3d61c0e49ce6e602669 100644 --- a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/security/AADSecurityConfig.java +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/security/AADSecurityConfig.java @@ -14,7 +14,7 @@ package org.opengroup.osdu.schema.security; -import com.microsoft.azure.spring.autoconfigure.aad.AADAppRoleStatelessAuthenticationFilter; +import com.azure.spring.autoconfigure.aad.AADAppRoleStatelessAuthenticationFilter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/security/AADSecurityConfigWithIstioEnabled.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/security/AADSecurityConfigWithIstioEnabled.java new file mode 100644 index 0000000000000000000000000000000000000000..de0d18f4a8b98ee224c2d7d900df157215a81022 --- /dev/null +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/security/AADSecurityConfigWithIstioEnabled.java @@ -0,0 +1,41 @@ +package org.opengroup.osdu.schema.security; + +import com.azure.spring.autoconfigure.aad.AADAppRoleStatelessAuthenticationFilter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; + +@EnableWebSecurity +@EnableGlobalMethodSecurity(prePostEnabled = true) +@ConditionalOnProperty(value = "azure.istio.auth.enabled", havingValue = "true", matchIfMissing = true) +public class AADSecurityConfigWithIstioEnabled extends WebSecurityConfigurerAdapter { + @Autowired + private AADAppRoleStatelessAuthenticationFilter appRoleAuthFilter; + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .csrf().disable() + .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER) + .and() + .authorizeRequests() + .antMatchers("/", "/index.html", + "/v2/api-docs", + "/configuration/ui", + "/swagger-resources/**", + "/configuration/security", + "/swagger", + "/swagger-ui.html", + "/schema", + "/schema/**", + "/webjars/**").permitAll() + .anyRequest().authenticated() + .and() + .addFilterBefore(appRoleAuthFilter, UsernamePasswordAuthenticationFilter.class); + } +} diff --git a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/security/AzureIstioSecurityConfig.java b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/security/AzureIstioSecurityConfig.java deleted file mode 100644 index 398092dc0a708fd7947111ba524daca9ac3d80ba..0000000000000000000000000000000000000000 --- a/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/security/AzureIstioSecurityConfig.java +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright © Microsoft Corporation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.opengroup.osdu.schema.security; - - -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; - - -@EnableWebSecurity -@EnableGlobalMethodSecurity(prePostEnabled = true) -@ConditionalOnProperty(value = "azure.istio.auth.enabled", havingValue = "true", matchIfMissing = true) -public class AzureIstioSecurityConfig extends WebSecurityConfigurerAdapter { - - @Override - protected void configure(HttpSecurity http) throws Exception { - http.httpBasic().disable() - .csrf().disable(); //AuthN is disabled. AuthN is handled by sidecar proxy - } -} diff --git a/provider/schema-azure/src/main/resources/application.properties b/provider/schema-azure/src/main/resources/application.properties index b01f3c39804e1cb3de490064dbebeb39c988eb17..3324cb780b126837a1a72f3103680e9c74986b2b 100644 --- a/provider/schema-azure/src/main/resources/application.properties +++ b/provider/schema-azure/src/main/resources/application.properties @@ -21,9 +21,9 @@ AUTHORIZE_API_KEY=${entitlements_service_api_key} # Azure AD configuration, commented below settings to disable AAD AuthN, # Uncomment it In the Istio AUTHN disabled Scenario -#azure.activedirectory.client-id=${aad_client_id} -#azure.activedirectory.AppIdUri=api://${azure.activedirectory.client-id} -#azure.activedirectory.session-stateless=true +azure.activedirectory.client-id=${aad_client_id} +azure.activedirectory.AppIdUri=api://${azure.activedirectory.client-id} +azure.activedirectory.session-stateless=true # Azure CosmosDB configuration azure.cosmosdb.database=${cosmosdb_database} @@ -65,8 +65,24 @@ azure.activedirectory.app-resource-id=${aad_client_id} # Use this property to name your shared tenant name # shared.tenant.name=${shared_partition} + shared.tenant.name=opendes # Azure Event Grid Configuration azure.eventGrid.enabled=${event_grid_enabled} azure.eventGrid.topicName=${event_grid_topic} + +# Configuration for system schemas +azure.system.sharedTenant=${shared.tenant.name} +azure.system.cosmosDatabase=osdu-system-db +azure.system.storageContainerName=opendes + +#Name of keys in key-vault for system resources/cosmos db +osdu.azure.system.cosmosDBAccountKeyName=system-cosmos-endpoint +osdu.azure.system.cosmosPrimaryKeyName=system-cosmos-primary-key +osdu.azure.system.cosmosConnectionStringKeyName=system-cosmos-connection +osdu.azure.system.storageAccountNameKeyName=system-storage +osdu.azure.system.storageKeyKeyName=system-storage-key + + + diff --git a/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/api/AzureSchemaApiTest.java b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/api/AzureSchemaApiTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5fe4b7961436358eb35a24483e5bfd5f4377202b --- /dev/null +++ b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/api/AzureSchemaApiTest.java @@ -0,0 +1,102 @@ +package org.opengroup.osdu.schema.provider.azure.api; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.opengroup.osdu.schema.azure.api.AzureSchemaApi; +import org.opengroup.osdu.schema.azure.interfaces.ISchemaServiceAzure; +import org.opengroup.osdu.schema.enums.SchemaScope; +import org.opengroup.osdu.schema.enums.SchemaStatus; +import org.opengroup.osdu.schema.exceptions.ApplicationException; +import org.opengroup.osdu.schema.exceptions.BadRequestException; +import org.opengroup.osdu.schema.exceptions.NotFoundException; +import org.opengroup.osdu.schema.model.SchemaIdentity; +import org.opengroup.osdu.schema.model.SchemaInfo; +import org.opengroup.osdu.schema.model.SchemaRequest; +import org.opengroup.osdu.schema.model.SchemaUpsertResponse; +import org.springframework.http.HttpStatus; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.Date; + +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.when; + +@RunWith(SpringJUnit4ClassRunner.class) +public class AzureSchemaApiTest { + + @Mock + ISchemaServiceAzure schemaServiceAzure; + + @InjectMocks + AzureSchemaApi azureSchemaApi; + + private SchemaRequest schemaRequest; + + @Test + public void testCreateSchema() + throws ApplicationException, NotFoundException, BadRequestException, JsonProcessingException { + schemaRequest = getSchemaRequestObject(); + + when(schemaServiceAzure.createSystemSchema(schemaRequest)).thenReturn(getSchemaInfoObject()); + assertNotNull(schemaServiceAzure.createSystemSchema(schemaRequest)); + + } + + @Test + public void testUpsertSchema_update() throws ApplicationException, BadRequestException { + schemaRequest = getSchemaRequestObject(); + + when(schemaServiceAzure.upsertSystemSchema(schemaRequest)).thenReturn(getSchemaUpsertResponse_Updated()); + assertNotNull(azureSchemaApi.upsertSystemSchema(schemaRequest)); + + } + + @Test + public void testUpsertSchema_create() throws ApplicationException, BadRequestException { + schemaRequest = getSchemaRequestObject(); + + when(schemaServiceAzure.upsertSystemSchema(schemaRequest)).thenReturn(getSchemaUpsertResponse_Created()); + assertNotNull(azureSchemaApi.upsertSystemSchema(schemaRequest)); + + } + + @Test(expected = BadRequestException.class) + public void testUpsertSchema_Failed() throws ApplicationException, BadRequestException { + schemaRequest = getSchemaRequestObject(); + + when(schemaServiceAzure.upsertSystemSchema(schemaRequest)).thenThrow(BadRequestException.class); + azureSchemaApi.upsertSystemSchema(schemaRequest); + } + + private SchemaRequest getSchemaRequestObject() { + return SchemaRequest.builder().schema(null).schemaInfo(SchemaInfo.builder().createdBy("creator") + .dateCreated(new Date(System.currentTimeMillis())) + .schemaIdentity(SchemaIdentity.builder().authority("os").entityType("well").id("os..wks.well.1.1") + .schemaVersionMajor(1L).schemaVersionMinor(1L).source("wks").build()) + .scope(SchemaScope.INTERNAL).status(SchemaStatus.DEVELOPMENT) + .supersededBy(SchemaIdentity.builder().authority("os").entityType("well").id("os..wks.well.1.4") + .schemaVersionMajor(1L).schemaVersionMinor(1L).source("wks").build()) + .build()).build(); + } + + private SchemaInfo getSchemaInfoObject() { + return SchemaInfo.builder().createdBy("creator").dateCreated(new Date(System.currentTimeMillis())) + .schemaIdentity(SchemaIdentity.builder().authority("os").entityType("well").id("os..wks.well.1.1") + .schemaVersionMajor(1L).schemaVersionMinor(1L).source("wks").build()) + .scope(SchemaScope.INTERNAL).status(SchemaStatus.DEVELOPMENT) + .supersededBy(SchemaIdentity.builder().authority("os").entityType("well").id("os..wks.well.1.4") + .schemaVersionMajor(1L).schemaVersionMinor(1L).source("wks").build()) + .build(); + } + + private SchemaUpsertResponse getSchemaUpsertResponse_Created() { + return SchemaUpsertResponse.builder().schemaInfo(getSchemaInfoObject()).httpCode(HttpStatus.CREATED).build(); + } + + private SchemaUpsertResponse getSchemaUpsertResponse_Updated() { + return SchemaUpsertResponse.builder().schemaInfo(getSchemaInfoObject()).httpCode(HttpStatus.OK).build(); + } +} diff --git a/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureAuthorityStoreTest.java b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureAuthorityStoreTest.java index d5c11356cee518813e0afa5a0b4acb71ad88d9f6..7010741d565bd98fe6cbaa65a51ca581d344056c 100644 --- a/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureAuthorityStoreTest.java +++ b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureAuthorityStoreTest.java @@ -26,12 +26,15 @@ import org.opengroup.osdu.core.common.model.http.AppError; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.schema.azure.definitions.AuthorityDoc; +import org.opengroup.osdu.schema.azure.di.SystemResourceConfig; import org.opengroup.osdu.schema.azure.impl.schemainfostore.AzureAuthorityStore; import org.opengroup.osdu.schema.constants.SchemaConstants; import org.opengroup.osdu.schema.exceptions.ApplicationException; import org.opengroup.osdu.schema.exceptions.BadRequestException; import org.opengroup.osdu.schema.exceptions.NotFoundException; import org.opengroup.osdu.schema.model.Authority; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.test.util.ReflectionTestUtils; import java.io.IOException; import java.util.Optional; @@ -59,15 +62,22 @@ public class AzureAuthorityStoreTest { @Mock JaxRsDpsLog log; + @Mock + SystemResourceConfig systemResourceConfig; + private static final String dataPartitionId = "testPartitionId"; + private static final String sharedTenantId = "common"; private static final String authorityId = "testAuthorityId"; private static final String partitionKey = "testAuthorityId"; + private static final String systemCosmosDBName = "osdu-system-db"; @Before public void init() { initMocks(this); Mockito.when(headers.getPartitionId()).thenReturn(dataPartitionId); Mockito.when(mockAuthority.getAuthorityId()).thenReturn(authorityId); + Mockito.when(systemResourceConfig.getCosmosDatabase()).thenReturn(systemCosmosDBName); + Mockito.when(systemResourceConfig.getSharedTenant()).thenReturn(sharedTenantId); } @Test @@ -88,6 +98,24 @@ public class AzureAuthorityStoreTest { assertEquals(authorityId, store.get(authorityId).getAuthorityId()); } + @Test + public void testGetAuthority_PublicSchemas() throws NotFoundException, ApplicationException, IOException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + AuthorityDoc authorityDoc = getAuthorityDoc(dataPartitionId, authorityId); + Optional cosmosItem = Optional.of(authorityDoc); + doReturn(cosmosItem) + .when(cosmosStore) + .findItem( + eq(systemCosmosDBName), + any(), + eq(sharedTenantId + ":" + authorityId), + eq(partitionKey), + any()); + + assertNotNull(store.get(authorityId)); + assertEquals(authorityId, store.get(authorityId).getAuthorityId()); + } + @Test public void testGetAuthority_NotFoundException() throws IOException { Optional cosmosItem = Optional.empty(); @@ -111,12 +139,42 @@ public class AzureAuthorityStoreTest { } } + @Test + public void testGetAuthority_NotFoundException_PublicSchemas() throws IOException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + Optional cosmosItem = Optional.empty(); + doReturn(cosmosItem) + .when(cosmosStore) + .findItem( + eq(systemCosmosDBName), + any(), + eq(sharedTenantId + ":" + ""), + eq(dataPartitionId), + any()); + try { + store.get(""); + fail("Should not succeed"); + } catch (NotFoundException e) { + assertEquals("bad input parameter", e.getMessage()); + + } catch (Exception e) { + fail("Should not get different exception"); + } + } + @Test public void testCreateAuthority() throws ApplicationException, BadRequestException { doNothing().when(cosmosStore).createItem(eq(dataPartitionId), any(), any(), any(), any()); assertNotNull(store.create(mockAuthority)); } + @Test + public void testCreateAuthority_PublicSchemas() throws ApplicationException, BadRequestException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + doNothing().when(cosmosStore).createItem(eq(systemCosmosDBName), any(), eq(partitionKey), any()); + assertNotNull(store.create(mockAuthority)); + } + @Test public void testCreateAuthority_BadRequestException() throws NotFoundException, ApplicationException, BadRequestException, IOException { @@ -134,6 +192,24 @@ public class AzureAuthorityStoreTest { } } + @Test + public void testCreateAuthority_BadRequestException_PublicSchemas() + throws NotFoundException, ApplicationException, BadRequestException, IOException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + AppException exception = getMockAppException(409); + doThrow(exception).when(cosmosStore).createItem(eq(systemCosmosDBName), any(), eq("common:testAuthorityId"), any()); + + try { + store.create(mockAuthority); + fail("Should not succeed"); + } catch (BadRequestException e) { + assertEquals("Authority already registered with Id: testAuthorityId", e.getMessage()); + + } catch (Exception e) { + fail("Should not get different exception"); + } + } + @Test public void testCreateAuthority_ApplicationException() throws NotFoundException, ApplicationException, BadRequestException, CosmosException { @@ -149,6 +225,21 @@ public class AzureAuthorityStoreTest { } } + public void testCreateAuthority_ApplicationException_PublicSchemas() + throws NotFoundException, ApplicationException, BadRequestException, CosmosException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + AppException exception = getMockAppException(500); + doThrow(exception).when(cosmosStore).createItem(systemCosmosDBName, any(), eq(partitionKey), any()); + try { + store.create(mockAuthority); + fail("Should not succeed"); + } catch (ApplicationException e) { + assertEquals(SchemaConstants.INVALID_INPUT, e.getMessage()); + } catch (Exception e) { + fail("Should not get different exception"); + } + } + private AuthorityDoc getAuthorityDoc(String partitionId, String authorityName) { String id = partitionId + ":" + authorityName; diff --git a/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureEntityTypeStoreTest.java b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureEntityTypeStoreTest.java index d9814285801b9d77453741e594fe255db3526199..e5cb7138296df61fde0569086241d2b37394bf50 100644 --- a/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureEntityTypeStoreTest.java +++ b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureEntityTypeStoreTest.java @@ -25,6 +25,7 @@ import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.model.http.AppError; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.schema.azure.di.SystemResourceConfig; import org.opengroup.osdu.schema.azure.impl.schemainfostore.AzureEntityTypeStore; import org.opengroup.osdu.schema.azure.definitions.EntityTypeDoc; import org.opengroup.osdu.schema.constants.SchemaConstants; @@ -32,6 +33,8 @@ import org.opengroup.osdu.schema.exceptions.ApplicationException; import org.opengroup.osdu.schema.exceptions.BadRequestException; import org.opengroup.osdu.schema.exceptions.NotFoundException; import org.opengroup.osdu.schema.model.EntityType; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.test.util.ReflectionTestUtils; import java.io.IOException; import java.util.Optional; @@ -60,15 +63,22 @@ public class AzureEntityTypeStoreTest { @Mock JaxRsDpsLog log; + @Mock + SystemResourceConfig systemResourceConfig; + private static final String dataPartitionId = "testPartitionId"; + private static final String sharedTenantId = "common"; private static final String entityTypeId = "testEntityId"; private static final String partitionKey = "testEntityId"; + private static final String systemCosmosDBName = "osdu-system-db"; @Before public void init() { initMocks(this); Mockito.when(headers.getPartitionId()).thenReturn(dataPartitionId); Mockito.when(mockEntityType.getEntityTypeId()).thenReturn(entityTypeId); + Mockito.when(systemResourceConfig.getCosmosDatabase()).thenReturn(systemCosmosDBName); + Mockito.when(systemResourceConfig.getSharedTenant()).thenReturn(sharedTenantId); } @Test @@ -89,6 +99,24 @@ public class AzureEntityTypeStoreTest { assertEquals(entityTypeId, store.get(entityTypeId).getEntityTypeId()); } + @Test + public void testGetEntityType_PublicSchemas() throws NotFoundException, ApplicationException, IOException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + EntityTypeDoc entityTypeDoc = getEntityTypeDoc(dataPartitionId, entityTypeId); + Optional cosmosItem = Optional.of(entityTypeDoc); + doReturn(cosmosItem) + .when(cosmosStore) + .findItem( + eq(systemCosmosDBName), + any(), + eq(sharedTenantId + ":" + entityTypeId), + eq(partitionKey), + any()); + + assertNotNull(store.get(entityTypeId)); + assertEquals(entityTypeId, store.get(entityTypeId).getEntityTypeId()); + } + @Test public void testGetEntityType_NotFoundException() throws IOException { Optional cosmosItem = Optional.empty(); @@ -113,6 +141,30 @@ public class AzureEntityTypeStoreTest { } } + @Test + public void testGetEntityType_NotFoundException_PublicSchemas() throws IOException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + Optional cosmosItem = Optional.empty(); + doReturn(cosmosItem) + .when(cosmosStore) + .findItem( + eq(systemCosmosDBName), + any(), + eq(sharedTenantId + ":" + ""), + eq(partitionKey), + any()); + + try { + store.get(""); + fail("Should not succeed"); + } catch (NotFoundException e) { + assertEquals("bad input parameter", e.getMessage()); + + } catch (Exception e) { + fail("Should not get different exception"); + } + } + @Test public void testCreateEntityType() throws ApplicationException, BadRequestException { Mockito.when(mockEntityType.getEntityTypeId()).thenReturn(entityTypeId); @@ -120,6 +172,14 @@ public class AzureEntityTypeStoreTest { assertNotNull(store.create(mockEntityType)); } + @Test + public void testCreateEntityType_PublicSchemas() throws ApplicationException, BadRequestException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + Mockito.when(mockEntityType.getEntityTypeId()).thenReturn(entityTypeId); + doNothing().when(cosmosStore).createItem(eq(systemCosmosDBName), any(), eq(partitionKey), any()); + assertNotNull(store.create(mockEntityType)); + } + @Test public void testCreateEntityType_BadRequestException() throws NotFoundException, ApplicationException, BadRequestException, IOException { @@ -137,6 +197,24 @@ public class AzureEntityTypeStoreTest { } } + @Test + public void testCreateEntityType_BadRequestException_PublicSchemas() + throws NotFoundException, ApplicationException, BadRequestException, IOException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + AppException exception = getMockAppException(409); + doThrow(exception).when(cosmosStore).createItem(eq(systemCosmosDBName), any(), eq("common:testEntityId"), any()); + + try { + store.create(mockEntityType); + fail("Should not succeed"); + } catch (BadRequestException e) { + assertEquals("EntityType already registered with Id: testEntityId", e.getMessage()); + + } catch (Exception e) { + fail("Should not get different exception"); + } + } + @Test public void testCreateEntityType_ApplicationException() throws NotFoundException, ApplicationException, BadRequestException, CosmosException { @@ -153,6 +231,23 @@ public class AzureEntityTypeStoreTest { } } + @Test + public void testCreateEntityType_ApplicationException_PublicSchemas() + throws NotFoundException, ApplicationException, BadRequestException, CosmosException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + AppException exception = getMockAppException(500); + doThrow(exception).when(cosmosStore).createItem(eq(systemCosmosDBName), any(), eq("common:testEntityId"), any()); + + try { + store.create(mockEntityType); + fail("Should not succeed"); + } catch (ApplicationException e) { + assertEquals(SchemaConstants.INVALID_INPUT, e.getMessage()); + } catch (Exception e) { + fail("Should not get different exception"); + } + } + private EntityTypeDoc getEntityTypeDoc(String partitionId, String EntityTypeName) { String id = partitionId + ":" + EntityTypeName; diff --git a/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureSchemaInfoStoreTest.java b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureSchemaInfoStoreTest.java index ef80a0f222a42256a2922629357006ecf0126f44..080fd22dc615c4ff940cd36b3a331139b73742e1 100644 --- a/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureSchemaInfoStoreTest.java +++ b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureSchemaInfoStoreTest.java @@ -22,11 +22,7 @@ import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.lenient; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; import static org.mockito.MockitoAnnotations.initMocks; import java.io.IOException; @@ -35,6 +31,7 @@ import java.util.Collection; import java.util.Date; import java.util.LinkedList; import java.util.List; +import java.util.NoSuchElementException; import java.util.Optional; import org.junit.Before; @@ -43,6 +40,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Mockito; import org.opengroup.osdu.azure.cosmosdb.CosmosStore; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.model.http.AppError; @@ -52,6 +50,7 @@ import org.opengroup.osdu.core.common.model.tenant.TenantInfo; import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory; import org.opengroup.osdu.schema.azure.definitions.FlattenedSchemaInfo; import org.opengroup.osdu.schema.azure.definitions.SchemaInfoDoc; +import org.opengroup.osdu.schema.azure.di.SystemResourceConfig; import org.opengroup.osdu.schema.azure.impl.schemainfostore.AzureSchemaInfoStore; import org.opengroup.osdu.schema.constants.SchemaConstants; import org.opengroup.osdu.schema.enums.SchemaScope; @@ -95,12 +94,16 @@ public class AzureSchemaInfoStoreTest { @Mock FlattenedSchemaInfo flattenedSchemaInfo; + @Mock + SystemResourceConfig systemResourceConfig; + private static final String dataPartitionId = "testPartitionId"; private static final String partitionKey = "os:wks:well:1"; private static final String CONTENT = "Hello World"; private static final String schemaId = "os:wks:well:1.1.1"; private static final String supersedingSchemaId = "os:wks:well:1.2.1"; private static final String commonTenantId = "common"; + private static final String systemCosmosDBName = "osdu-system-db"; @Rule public ExpectedException expectedException = ExpectedException.none(); @@ -108,8 +111,10 @@ public class AzureSchemaInfoStoreTest { @Before public void init() { initMocks(this); - ReflectionTestUtils.setField(schemaInfoStore, "sharedTenant", "common"); + ReflectionTestUtils.setField(schemaInfoStore, "sharedTenant", commonTenantId); doReturn(dataPartitionId).when(headers).getPartitionId(); + Mockito.when(systemResourceConfig.getCosmosDatabase()).thenReturn(systemCosmosDBName); + Mockito.when(systemResourceConfig.getSharedTenant()).thenReturn(commonTenantId); } @Test @@ -157,6 +162,26 @@ public class AzureSchemaInfoStoreTest { assertNotNull(schemaInfo); } + @Test + public void testGetSchemaInfo_NotEmpty_PublicSchemas() throws NotFoundException, ApplicationException { + Mockito.when(headers.getPartitionId()).thenReturn(commonTenantId); + Optional cosmosItem = Optional.of(schemaInfoDoc); + doReturn(cosmosItem) + .when(cosmosStore) + .findItem( + eq(systemCosmosDBName), + any(), + eq(commonTenantId + ":" + schemaId), + eq(partitionKey), + any()); + + doReturn(getFlattenedSchemaInfo()).when(schemaInfoDoc).getFlattenedSchemaInfo(); + SchemaInfo schemaInfo = schemaInfoStore.getSchemaInfo(schemaId); + assertNotNull(schemaInfo); + verify(this.cosmosStore, times(1)).findItem(any(), any(), eq("common:os:wks:well:1.1.1"), eq("os:wks:well:1"), eq(SchemaInfoDoc.class)); + verify(this.cosmosStore, times(0)).findItem(anyString(), anyString(), anyString(), anyString(), anyString(), any()); + } + @Test public void testGetSchemaInfo_Empty() throws NotFoundException, ApplicationException { expectedException.expect(NotFoundException.class); @@ -192,6 +217,25 @@ public class AzureSchemaInfoStoreTest { assertNotNull(schemaInfoStore.createSchemaInfo(getMockSchemaObject_Published())); } + @Test + public void testCreateSchemaInfo_Positive_PublicSchemas() throws ApplicationException, BadRequestException { + Mockito.when(headers.getPartitionId()).thenReturn(commonTenantId); + // the schema is not present in schemaInfoStore + doReturn(Optional.empty()) + .when(cosmosStore) + .findItem( + eq(systemCosmosDBName), + any(), + eq(commonTenantId + ":" + schemaId), + anyString(), + any()); + doReturn(getFlattenedSchemaInfo()).when(schemaInfoDoc).getFlattenedSchemaInfo(); + + assertNotNull(schemaInfoStore.createSchemaInfo(getMockSchemaObject_Published())); + verify(this.cosmosStore, times(1)).createItem(any(), any(), eq("os:wks:well:1"), any()); + verify(this.cosmosStore, times(0)).createItem(anyString(), anyString(), anyString(), anyString(), any()); + } + @Test public void testCreateSchemaInfo_WithSupersededBy() throws NotFoundException, ApplicationException, BadRequestException { @@ -311,6 +355,23 @@ public class AzureSchemaInfoStoreTest { assertFalse(schemaInfoStore.isUnique(schemaId, dataPartitionId)); } + @Test + public void testIsUnique_False_PublicSchemas() throws ApplicationException { + Mockito.when(headers.getPartitionId()).thenReturn(commonTenantId); + Optional cosmosItem = Optional.of(schemaInfoDoc); + doReturn(cosmosItem) + .when(cosmosStore) + .findItem( + eq(systemCosmosDBName), + any(), + eq(commonTenantId + ":" + schemaId), + eq(partitionKey), + any()); + assertFalse(schemaInfoStore.isUnique(schemaId, commonTenantId)); + verify(this.cosmosStore, times(1)).findItem(any(), any(), anyString(), anyString(), any()); + verify(this.cosmosStore, times(0)).findItem(anyString(), anyString(), anyString(), anyString(), anyString(), any()); + } + @Test public void testIsUnique_False_CommomTenant() throws ApplicationException { TenantInfo tenant1 = new TenantInfo(); @@ -351,6 +412,25 @@ public class AzureSchemaInfoStoreTest { assertNotNull(schemaInfoStore.updateSchemaInfo(getMockSchemaObject_Published())); } + @Test + public void testUpdateSchemaInfo_PublicSchemas() throws NotFoundException, ApplicationException, BadRequestException { + Mockito.when(headers.getPartitionId()).thenReturn(commonTenantId); + Optional cosmosItem = Optional.of(schemaInfoDoc); + doReturn(cosmosItem) + .when(cosmosStore) + .findItem( + eq(systemCosmosDBName), + any(), + eq(commonTenantId + ":" + supersedingSchemaId), + eq(partitionKey), + any()); + + doReturn(getFlattenedSchemaInfo()).when(schemaInfoDoc).getFlattenedSchemaInfo(); + assertNotNull(schemaInfoStore.updateSchemaInfo(getMockSchemaObject_Published())); + verify(this.cosmosStore, times(1)).upsertItem(any(), any(), any(), any()); + verify(this.cosmosStore, times(0)).upsertItem(any(), any(), any(), any(), any()); + } + @Test public void testUpdateSchemaInfo_SupersededBy() throws NotFoundException, ApplicationException, BadRequestException { @@ -466,6 +546,18 @@ public class AzureSchemaInfoStoreTest { assertEquals(1, schemaInfoStore.getSchemaInfoList(QueryParams.builder().limit(100).offset(0).build(), dataPartitionId).size()); } + + @Test + public void testGetSchemaInfoList_Withoutqueryparam_FailedWhenSearchedIntoSharedPartition() + throws NotFoundException, ApplicationException, BadRequestException { + List schemaInfoDocsList = new LinkedList<>(); + schemaInfoDocsList.add(getMockSchemaInfoDocWithSupersededBy()); + doReturn(schemaInfoDocsList).when(cosmosStore).queryItems(eq(dataPartitionId), any(), any(), any(), any(), any()); + doThrow(new NoSuchElementException()).when(cosmosStore).findItem(eq("common"), any(), any(), any(), any(), any()); + doReturn(Optional.of(getMockSchemaInfoDoc())).when(cosmosStore).findItem(eq(dataPartitionId), any(), any(), any(), any(), any()); + schemaInfoStore.getSchemaInfoList(QueryParams.builder().limit(100).offset(0).build(), dataPartitionId); + expectedException.none(); + } @Test public void testGetSchemaInfoList_withqueryparam() @@ -505,6 +597,22 @@ public class AzureSchemaInfoStoreTest { assertEquals(true, schemaInfoStore.cleanSchema(schemaId)); } + @Test + public void testCleanSchema_Success_PublicSchemas() throws ApplicationException { + doReturn(commonTenantId).when(headers).getPartitionId(); + doReturn(Optional.of(schemaInfoDoc)) + .when(cosmosStore) + .findItem( + eq(systemCosmosDBName), + any(), + eq(commonTenantId + ":" + schemaId), + eq(partitionKey), + any()); + assertEquals(true, schemaInfoStore.cleanSchema(schemaId)); + verify(cosmosStore, times(1)).deleteItem(any(), any(), any(), any()); + verify(cosmosStore, times(0)).deleteItem(any(), any(), any(), any(), any()); + } + @Test public void testCleanSchema_Failure() throws ApplicationException { doReturn(Optional.empty()) @@ -531,6 +639,12 @@ public class AzureSchemaInfoStoreTest { return new SchemaInfoDoc(id, headers.getPartitionId(), getFlattenedSchemaInfo()); } + + private SchemaInfoDoc getMockSchemaInfoDocWithSupersededBy() { + String id = headers.getPartitionId() + ":" + schemaId; + + return new SchemaInfoDoc(id, headers.getPartitionId(), getFlattenedSchemaInfo_SupersededBy()); + } private FlattenedSchemaInfo getFlattenedSchemaInfo() { return FlattenedSchemaInfo.builder() diff --git a/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureSourceStoreTest.java b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureSourceStoreTest.java index 0babb38035ba096c28f8a8bd96868b43bf55d9ed..7580c6b3afc273f927c5da52eb69b4342dd34182 100644 --- a/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureSourceStoreTest.java +++ b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureSourceStoreTest.java @@ -26,12 +26,15 @@ import org.opengroup.osdu.core.common.model.http.AppError; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.schema.azure.definitions.SourceDoc; +import org.opengroup.osdu.schema.azure.di.SystemResourceConfig; import org.opengroup.osdu.schema.azure.impl.schemainfostore.AzureSourceStore; import org.opengroup.osdu.schema.constants.SchemaConstants; import org.opengroup.osdu.schema.exceptions.ApplicationException; import org.opengroup.osdu.schema.exceptions.BadRequestException; import org.opengroup.osdu.schema.exceptions.NotFoundException; import org.opengroup.osdu.schema.model.Source; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.test.util.ReflectionTestUtils; import java.io.IOException; import java.util.Optional; @@ -60,14 +63,22 @@ public class AzureSourceStoreTest { @Mock JaxRsDpsLog log; + @Mock + SystemResourceConfig systemResourceConfig; + private static final String dataPartitionId = "testPartitionId"; private static final String sourceId = "testSourceId"; + private static final String partitionKey = "testSourceId"; + private static final String sharedTenantId = "common"; + private static final String systemCosmosDBName = "osdu-system-db"; @Before public void init() { initMocks(this); Mockito.when(headers.getPartitionId()).thenReturn(dataPartitionId); Mockito.when(mockSource.getSourceId()).thenReturn(sourceId); + Mockito.when(systemResourceConfig.getSharedTenant()).thenReturn(sharedTenantId); + Mockito.when(systemResourceConfig.getCosmosDatabase()).thenReturn(systemCosmosDBName); } @Test @@ -87,6 +98,23 @@ public class AzureSourceStoreTest { assertEquals(sourceId, store.get(sourceId).getSourceId()); } + @Test + public void testGetSource_PublicSchemas() throws NotFoundException, ApplicationException, IOException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + SourceDoc sourceDoc = getSourceDoc(dataPartitionId, sourceId); + Optional cosmosItem = Optional.of(sourceDoc); + doReturn(cosmosItem) + .when(cosmosStore) + .findItem( + eq(systemCosmosDBName), + any(), + eq(sharedTenantId + ":" + sourceId), + eq(partitionKey), + any()); + assertNotNull(store.get(sourceId)); + assertEquals(sourceId, store.get(sourceId).getSourceId()); + } + @Test public void testGetSource_NotFoundException() throws IOException { String sourceId = ""; @@ -111,6 +139,30 @@ public class AzureSourceStoreTest { } } + @Test + public void testGetSource_NotFoundException_PublicSchemas() throws IOException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + String sourceId = ""; + Optional cosmosItem = Optional.empty(); + doReturn(cosmosItem) + .when(cosmosStore) + .findItem( + eq(systemCosmosDBName), + any(), + eq(sharedTenantId + ":" + ""), + eq(sourceId), + any()); + try { + store.get(sourceId); + fail("Should not succeed"); + } catch (NotFoundException e) { + assertEquals("bad input parameter", e.getMessage()); + + } catch (Exception e) { + fail("Should not get different exception"); + } + } + @Test public void testCreateSource() throws ApplicationException, BadRequestException { doNothing().when(cosmosStore).createItem(anyString(), any(), any(),any(), any()); @@ -118,6 +170,13 @@ public class AzureSourceStoreTest { assertNotNull(store.create(mockSource)); } + @Test + public void testCreateSource_PublicSchemas() throws ApplicationException, BadRequestException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + doNothing().when(cosmosStore).createItem(eq(systemCosmosDBName), any(), eq("common:testSourceId"), any()); + assertNotNull(store.create(mockSource)); + } + @Test public void testCreateSource_BadRequestException() throws NotFoundException, ApplicationException, BadRequestException, IOException { @@ -134,6 +193,23 @@ public class AzureSourceStoreTest { } } + @Test + public void testCreateSource_BadRequestException_PublicSchemas() + throws NotFoundException, ApplicationException, BadRequestException, IOException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + AppException exception = getMockAppException(409); + doThrow(exception).when(cosmosStore).createItem(eq(systemCosmosDBName), any(), eq("common:testSourceId"), any()); + try { + store.create(mockSource); + fail("Should not succeed"); + } catch (BadRequestException e) { + assertEquals("Source already registered with Id: testSourceId", e.getMessage()); + + } catch (Exception e) { + fail("Should not get different exception"); + } + } + @Test public void testCreateSource_ApplicationException() throws NotFoundException, ApplicationException, BadRequestException, CosmosException { @@ -150,6 +226,23 @@ public class AzureSourceStoreTest { } } + @Test + public void testCreateSource_ApplicationException_PublicSchemas() + throws NotFoundException, ApplicationException, BadRequestException, CosmosException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + AppException exception = getMockAppException(500); + doThrow(exception).when(cosmosStore).createItem(eq(systemCosmosDBName), any(), eq("common:testSourceId"), any()); + + try { + store.create(mockSource); + fail("Should not succeed"); + } catch (ApplicationException e) { + assertEquals(SchemaConstants.INVALID_INPUT, e.getMessage()); + } catch (Exception e) { + fail("Should not get different exception"); + } + } + private SourceDoc getSourceDoc(String partitionId, String sourceName) { String id = partitionId + ":" + sourceName; diff --git a/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemastore/AzureSchemaStoreTest.java b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemastore/AzureSchemaStoreTest.java index 93da8c5f2d03fa151fd5f1df0b12a0741e3afb12..f05614c3749888f1051da9f0c3c5ec090fa90995 100644 --- a/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemastore/AzureSchemaStoreTest.java +++ b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemastore/AzureSchemaStoreTest.java @@ -21,16 +21,19 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Mockito; import org.opengroup.osdu.azure.blobstorage.BlobStore; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.schema.azure.di.AzureBootstrapConfig; import org.opengroup.osdu.schema.azure.di.CosmosContainerConfig; +import org.opengroup.osdu.schema.azure.di.SystemResourceConfig; import org.opengroup.osdu.schema.azure.impl.schemastore.AzureSchemaStore; import org.opengroup.osdu.schema.constants.SchemaConstants; import org.opengroup.osdu.schema.exceptions.ApplicationException; import org.opengroup.osdu.schema.exceptions.NotFoundException; +import org.springframework.test.util.ReflectionTestUtils; import static org.mockito.Mockito.*; import static org.mockito.MockitoAnnotations.initMocks; @@ -51,20 +54,28 @@ public class AzureSchemaStoreTest { @Mock JaxRsDpsLog log; + @Mock + SystemResourceConfig systemResourceConfig; + @Rule public ExpectedException expectedException = ExpectedException.none(); private static final String dataPartitionId = "dataPartitionId"; + private static final String sharedTenantId = "common"; private static final String FILE_PATH = "/test-folder/test-file"; private static final String CONTENT = "Hello World"; private static final String containerName = "opendes"; + private static final String systemContainerName = "systemContainer"; private static final String filePath = dataPartitionId + ":" + FILE_PATH + SchemaConstants.JSON_EXTENSION; + private static final String filePathPublic = sharedTenantId + ":" + FILE_PATH + SchemaConstants.JSON_EXTENSION; @Before public void init(){ initMocks(this); doReturn(dataPartitionId).when(headers).getPartitionId(); when(config.containerName()).thenReturn(containerName); + Mockito.when(systemResourceConfig.getStorageContainerName()).thenReturn(systemContainerName); + Mockito.when(systemResourceConfig.getSharedTenant()).thenReturn(sharedTenantId); } @Test @@ -73,6 +84,13 @@ public class AzureSchemaStoreTest { Assert.assertEquals(CONTENT, schemaStore.getSchema(dataPartitionId, FILE_PATH)); } + @Test + public void testGetSchema_PublicSchemas() throws ApplicationException, NotFoundException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + doReturn(CONTENT).when(blobStore).readFromStorageContainer(filePathPublic, systemContainerName); + Assert.assertEquals(CONTENT, schemaStore.getSchema(sharedTenantId, FILE_PATH)); + } + @Test public void testGetSchema_NotFound() throws ApplicationException, NotFoundException { expectedException.expect(NotFoundException.class); @@ -81,6 +99,15 @@ public class AzureSchemaStoreTest { schemaStore.getSchema(dataPartitionId, FILE_PATH); } + @Test + public void testGetSchema_NotFound_PublicSchemas() throws ApplicationException, NotFoundException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + expectedException.expect(NotFoundException.class); + expectedException.expectMessage(SchemaConstants.SCHEMA_NOT_PRESENT); + doReturn(null).when(blobStore).readFromStorageContainer(filePathPublic, systemContainerName); + schemaStore.getSchema(sharedTenantId, FILE_PATH); + } + @Test public void testGetSchema_Failure() throws ApplicationException, NotFoundException { expectedException.expect(NotFoundException.class); @@ -90,6 +117,16 @@ public class AzureSchemaStoreTest { schemaStore.getSchema(dataPartitionId, FILE_PATH); } + @Test + public void testGetSchema_Failure_PublicSchemas() throws ApplicationException, NotFoundException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + expectedException.expect(NotFoundException.class); + expectedException.expectMessage(SchemaConstants.SCHEMA_NOT_PRESENT); + + doThrow(AppException.class).when(blobStore).readFromStorageContainer(filePathPublic, systemContainerName); + schemaStore.getSchema(sharedTenantId, FILE_PATH); + } + @Test public void testDeleteSchema() throws ApplicationException { doReturn(true).when(blobStore).deleteFromStorageContainer(dataPartitionId, filePath, containerName); @@ -98,6 +135,15 @@ public class AzureSchemaStoreTest { Assert.assertEquals(true, result); } + @Test + public void testDeleteSchema_PublicSchemas() throws ApplicationException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + doReturn(true).when(blobStore).deleteFromStorageContainer(filePathPublic, systemContainerName); + + Boolean result = schemaStore.cleanSchemaProject(FILE_PATH); + Assert.assertEquals(true, result); + } + @Test public void testDeleteSchema_Failure() throws ApplicationException { expectedException.expect(ApplicationException.class); @@ -107,6 +153,16 @@ public class AzureSchemaStoreTest { schemaStore.cleanSchemaProject(FILE_PATH); } + @Test + public void testDeleteSchema_Failure_PublicSchemas() throws ApplicationException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + expectedException.expect(ApplicationException.class); + expectedException.expectMessage(SchemaConstants.INTERNAL_SERVER_ERROR); + + doThrow(AppException.class).when(blobStore).deleteFromStorageContainer(filePathPublic, systemContainerName); + schemaStore.cleanSchemaProject(FILE_PATH); + } + @Test public void testCreateSchema() throws ApplicationException { @@ -114,6 +170,14 @@ public class AzureSchemaStoreTest { Assert.assertEquals(filePath, schemaStore.createSchema(FILE_PATH, CONTENT)); } + @Test + public void testCreateSchema_PublicSchemas() throws ApplicationException { + + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + doNothing().when(blobStore).writeToStorageContainer(filePathPublic, CONTENT, systemContainerName); + Assert.assertEquals(filePathPublic, schemaStore.createSchema(FILE_PATH, CONTENT)); + } + @Test public void testCreateSchema_Failure() throws ApplicationException { expectedException.expect(ApplicationException.class); @@ -122,4 +186,14 @@ public class AzureSchemaStoreTest { doThrow(AppException.class).when(blobStore).writeToStorageContainer(dataPartitionId, filePath, CONTENT, containerName); schemaStore.createSchema(FILE_PATH, CONTENT); } + + @Test + public void testCreateSchema_Failure_PublicSchemas() throws ApplicationException { + Mockito.when(headers.getPartitionId()).thenReturn(sharedTenantId); + expectedException.expect(ApplicationException.class); + expectedException.expectMessage(SchemaConstants.INTERNAL_SERVER_ERROR); + + doThrow(AppException.class).when(blobStore).writeToStorageContainer(filePathPublic, CONTENT, systemContainerName); + schemaStore.createSchema(FILE_PATH, CONTENT); + } } diff --git a/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/service/serviceimpl/SchemaServiceAzureTest.java b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/service/serviceimpl/SchemaServiceAzureTest.java new file mode 100644 index 0000000000000000000000000000000000000000..32ab6a0806d6e8618a6f5caa83716b9a963965fb --- /dev/null +++ b/provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/service/serviceimpl/SchemaServiceAzureTest.java @@ -0,0 +1,138 @@ +package org.opengroup.osdu.schema.provider.azure.service.serviceimpl; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.schema.azure.di.SystemResourceConfig; +import org.opengroup.osdu.schema.azure.service.serviceimpl.SchemaServiceAzure; +import org.opengroup.osdu.schema.constants.SchemaConstants; +import org.opengroup.osdu.schema.enums.SchemaScope; +import org.opengroup.osdu.schema.enums.SchemaStatus; +import org.opengroup.osdu.schema.exceptions.ApplicationException; +import org.opengroup.osdu.schema.exceptions.BadRequestException; +import org.opengroup.osdu.schema.exceptions.NotFoundException; +import org.opengroup.osdu.schema.model.SchemaIdentity; +import org.opengroup.osdu.schema.model.SchemaInfo; +import org.opengroup.osdu.schema.model.SchemaRequest; +import org.opengroup.osdu.schema.model.SchemaUpsertResponse; +import org.opengroup.osdu.schema.service.ISchemaService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.util.ReflectionTestUtils; + +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import java.util.Date; + +import static org.junit.Assert.assertEquals; +import static org.mockito.MockitoAnnotations.initMocks; + +public class SchemaServiceAzureTest { + @InjectMocks + SchemaServiceAzure schemaServiceAzure; + + @Mock + ISchemaService schemaServiceCore; + + @Mock + DpsHeaders headers; + + @Mock + SchemaUpsertResponse upsertResponse; + + @Mock + SystemResourceConfig systemResourceConfig; + + private Date currDate = new Date(); + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private static final String SHARED_TENANT = "common"; + private static final String PRIVATE_TENANT = "opendes"; + + @Before + public void setUp() { + initMocks(this); + Mockito.when(systemResourceConfig.getSharedTenant()).thenReturn(SHARED_TENANT); + } + + @Test + public void testCreateSharedSchema() throws BadRequestException, ApplicationException { + SchemaRequest schemaRequest = getMockSchemaObject_published_SharedScope(); + SchemaInfo schemaInfo = getMockSchemaInfo_Published_SharedScope(); + Mockito.when(schemaServiceCore.createSchema(schemaRequest)).thenReturn(schemaInfo); + + assertEquals(schemaInfo, schemaServiceAzure.createSystemSchema(schemaRequest)); + verify(this.headers, times(1)).put(SchemaConstants.DATA_PARTITION_ID, SHARED_TENANT); + } + + @Test + public void testCreateSharedSchema_SchemaAlreadyPresent() throws BadRequestException, ApplicationException { + expectedException.expect(BadRequestException.class); + expectedException.expectMessage(SchemaConstants.SCHEMA_ID_EXISTS); + SchemaRequest schemaRequest = getMockSchemaObject_published_SharedScope(); + Mockito.when(schemaServiceCore.createSchema(schemaRequest)).thenThrow(new BadRequestException(SchemaConstants.SCHEMA_ID_EXISTS)); + schemaServiceAzure.createSystemSchema(schemaRequest); + } + + @Test + public void testUpsertSharedSchema_SuccessfulUpdate() throws BadRequestException, ApplicationException { + SchemaRequest schemaRequest = getMockSchemaObject_published_SharedScope(); + SchemaInfo schemaInfo = getMockSchemaInfo_Published_SharedScope(); + Mockito.when(upsertResponse.getHttpCode()).thenReturn(HttpStatus.OK); + Mockito.when(schemaServiceCore.upsertSchema(schemaRequest)).thenReturn(upsertResponse); + + assertEquals(HttpStatus.OK, schemaServiceAzure.upsertSystemSchema(schemaRequest).getHttpCode()); + verify(this.headers, times(1)).put(SchemaConstants.DATA_PARTITION_ID, SHARED_TENANT); + verify(this.schemaServiceCore, times(1)).upsertSchema(schemaRequest); + } + + @Test + public void testUpsertSharedSchema_SuccessfulCreate () throws BadRequestException, ApplicationException { + SchemaRequest schemaRequest = getMockSchemaObject_published_SharedScope(); + SchemaInfo schemaInfo = getMockSchemaInfo_Published_SharedScope(); + Mockito.when(upsertResponse.getHttpCode()).thenReturn(HttpStatus.CREATED); + Mockito.when(schemaServiceCore.upsertSchema(schemaRequest)).thenReturn(upsertResponse); + + assertEquals(HttpStatus.CREATED, schemaServiceAzure.upsertSystemSchema(schemaRequest).getHttpCode()); + verify(this.headers, times(1)).put(SchemaConstants.DATA_PARTITION_ID, SHARED_TENANT); + verify(this.schemaServiceCore, times(1)).upsertSchema(schemaRequest); + } + + @Test(expected = BadRequestException.class) + public void testUpsertSharedSchema_WhenSchemaExistInOtherTenant() + throws ApplicationException, NotFoundException, BadRequestException { + SchemaRequest schemaRequest = getMockSchemaObject_published_SharedScope(); + Mockito.when(schemaServiceCore.upsertSchema(schemaRequest)).thenThrow(new BadRequestException()); + schemaServiceAzure.upsertSystemSchema(schemaRequest).getHttpCode(); + } + + + private SchemaRequest getMockSchemaObject_published_SharedScope() { + return SchemaRequest.builder().schema("{}") + .schemaInfo(SchemaInfo.builder() + .schemaIdentity(SchemaIdentity.builder().authority("os").source("wks").entityType("well") + .schemaVersionMajor(1L).schemaVersionMinor(1L).schemaVersionPatch(1L) + .id("os:wks:well:1.1.1").build()) + .dateCreated(currDate).scope(SchemaScope.SHARED).status(SchemaStatus.PUBLISHED).build()) + .build(); + + } + + private SchemaInfo getMockSchemaInfo_Published_SharedScope() { + return SchemaInfo.builder() + .schemaIdentity( + SchemaIdentity.builder().authority("os").source("wks").entityType("well").schemaVersionMajor(1L) + .schemaVersionMinor(1L).schemaVersionPatch(1L).id("os:wks:well:1.1.1").build()) + .dateCreated(currDate).scope(SchemaScope.SHARED).status(SchemaStatus.PUBLISHED).build(); + } +} diff --git a/provider/schema-gcp/README.md b/provider/schema-gcp/README.md index bf1c200ab8c46da0346a29d1687925bc29a297da..90a1fa3c0e4aa226a9f0040d680fdd3082eb3b52 100644 --- a/provider/schema-gcp/README.md +++ b/provider/schema-gcp/README.md @@ -42,6 +42,7 @@ In order to run the service locally or remotely, you will need to have the follo | `PARTITION_API` | ex `http://localhost:8081/api/partition/v1` | Partition service endpoint | no | - | | `GOOGLE_APPLICATION_CREDENTIALS` | ex `/path/to/directory/service-key.json` | Service account credentials, you only need this if running locally | yes | https://console.cloud.google.com/iam-admin/serviceaccounts | | `GCLOUD_PROJECT` | `******` | Cloud project id, you only need this if running locally | no | https://console.cloud.google.com | +| `gcp.schema-changed.messagingEnabled` | `true` OR `false` | Allows to configure message publishing about schemas changes to Pub/Sub | no | - | ### Run Locally Check that maven is installed: diff --git a/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/GcpSchemaApplication.java b/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/GcpSchemaApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..6504d62ab5d1d3319096ffb94f131218b89dc788 --- /dev/null +++ b/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/GcpSchemaApplication.java @@ -0,0 +1,33 @@ +/* + Copyright 2021 Google LLC + Copyright 2021 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +package org.opengroup.osdu.schema; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.ConfigurationPropertiesScan; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan({"org.opengroup.osdu"}) +@ConfigurationPropertiesScan +public class GcpSchemaApplication { + + public static void main(String[] args) { + SpringApplication.run(GcpSchemaApplication.class, args); + } +} \ No newline at end of file diff --git a/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/configuration/EventMessagingPropertiesConfig.java b/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/configuration/EventMessagingPropertiesConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..b566889a66b1b277f4c69934dc0a0c917dc36735 --- /dev/null +++ b/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/configuration/EventMessagingPropertiesConfig.java @@ -0,0 +1,42 @@ +/* + Copyright 2021 Google LLC + Copyright 2021 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +package org.opengroup.osdu.schema.configuration; + +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.ConstructorBinding; + +@ConfigurationProperties(prefix = "gcp.schema-changed") +@Getter +@ConstructorBinding +public class EventMessagingPropertiesConfig { + + private final boolean messagingEnabled; + private final String topicName; + + public EventMessagingPropertiesConfig(boolean messagingEnabled, String topicName) { + if (messagingEnabled && StringUtils.isEmpty(topicName)) { + throw new RuntimeException("Missing event messaging configuration."); + } + + this.messagingEnabled = messagingEnabled; + this.topicName = topicName; + } + +} diff --git a/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/exception/AppExceptionHandler.java b/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/exception/AppExceptionHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..daf32930b84bc9f4ec5b2667f208d8081800b9fb --- /dev/null +++ b/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/exception/AppExceptionHandler.java @@ -0,0 +1,39 @@ +package org.opengroup.osdu.schema.exception; + +import java.util.Objects; +import lombok.extern.slf4j.Slf4j; +import org.opengroup.osdu.core.common.model.http.AppException; +import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; + +@ControllerAdvice +@Order(Ordered.HIGHEST_PRECEDENCE) +@Slf4j +public class AppExceptionHandler { + + @ExceptionHandler(AppException.class) + public ResponseEntity handleAppExceptions(AppException e) { + return this.getErrorResponse(e); + } + + private ResponseEntity getErrorResponse(AppException e) { + + String exceptionMsg = Objects.nonNull(e.getOriginalException()) + ? e.getOriginalException().getMessage() + : e.getError().getMessage(); + + Integer errorCode = e.getError().getCode(); + + if (errorCode > 499) { + log.error(exceptionMsg, e.getOriginalException()); + } else { + log.warn(exceptionMsg, e.getOriginalException()); + } + + return new ResponseEntity<>(e.getError(), HttpStatus.resolve(errorCode)); + } +} diff --git a/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/messagebus/MessageBusImpl.java b/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/messagebus/MessageBusImpl.java index 0648ec2d46877525199c578c0d0c93ab0aa51cc4..fc4e5d0c9f6662c07ffcbe4b03db5471853242c0 100644 --- a/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/messagebus/MessageBusImpl.java +++ b/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/messagebus/MessageBusImpl.java @@ -1,21 +1,120 @@ +/* + Copyright 2021 Google LLC + Copyright 2021 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.schema.impl.messagebus; +import com.google.api.gax.retrying.RetrySettings; +import com.google.cloud.pubsub.v1.Publisher; +import com.google.gson.Gson; +import com.google.protobuf.ByteString; +import com.google.pubsub.v1.ProjectTopicName; +import com.google.pubsub.v1.PubsubMessage; +import com.google.pubsub.v1.PubsubMessage.Builder; +import java.io.IOException; +import java.util.Collections; +import java.util.Objects; +import org.apache.http.HttpStatus; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.http.AppException; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.core.common.model.tenant.TenantInfo; +import org.opengroup.osdu.schema.configuration.EventMessagingPropertiesConfig; +import org.opengroup.osdu.schema.constants.SchemaConstants; +import org.opengroup.osdu.schema.impl.messagebus.model.SchemaPubSubInfo; +import org.opengroup.osdu.schema.logging.AuditLogger; import org.opengroup.osdu.schema.provider.interfaces.messagebus.IMessageBus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.threeten.bp.Duration; @Component -public class MessageBusImpl implements IMessageBus{ +public class MessageBusImpl implements IMessageBus { + + private static final RetrySettings RETRY_SETTINGS = RetrySettings.newBuilder() + .setTotalTimeout(Duration.ofSeconds(10)) + .setInitialRetryDelay(Duration.ofMillis(5)) + .setRetryDelayMultiplier(2) + .setMaxRetryDelay(Duration.ofSeconds(3)) + .setInitialRpcTimeout(Duration.ofSeconds(10)) + .setRpcTimeoutMultiplier(2) + .setMaxRpcTimeout(Duration.ofSeconds(10)) + .build(); + + + private Publisher publisher; + + @Autowired + private TenantInfo tenantInfo; + + @Autowired + private DpsHeaders headers; + + @Autowired + private EventMessagingPropertiesConfig eventMessagingPropertiesConfig; + + @Autowired + private JaxRsDpsLog logger; + + @Autowired + private AuditLogger auditLogger; + + @Override + public void publishMessage(String schemaId, String eventType) { + if (this.eventMessagingPropertiesConfig.isMessagingEnabled()) { + this.logger.info(String.format("Generating event of type %s", eventType)); + + if (Objects.isNull(this.publisher)) { + try { + this.publisher = Publisher.newBuilder( + ProjectTopicName.newBuilder() + .setProject(this.tenantInfo.getProjectId()) + .setTopic(this.eventMessagingPropertiesConfig.getTopicName()).build()) + .setRetrySettings(RETRY_SETTINGS).build(); + } catch (IOException e) { + this.logger.info(SchemaConstants.SCHEMA_NOTIFICATION_FAILED); + this.auditLogger.schemaNotificationFailure(Collections.singletonList(schemaId)); + throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Internal error", + "A fatal internal error has occurred.", e); + } + } + + PubsubMessage message = createMessage(schemaId, eventType); + this.publisher.publish(message); + this.auditLogger.schemaNotificationSuccess(Collections.singletonList(schemaId)); + } else { + this.logger.info(SchemaConstants.SCHEMA_NOTIFICATION_IS_DISABLED); + } + } + + private PubsubMessage createMessage(String schemaId, String eventType) { + SchemaPubSubInfo schemaPubSubMsg = new SchemaPubSubInfo(schemaId, eventType); - @Autowired - private JaxRsDpsLog logger; + String json = new Gson().toJson(schemaPubSubMsg); + ByteString data = ByteString.copyFromUtf8(json); - @Override - public void publishMessage(String schemaId, String eventType) { - // TODO Auto-generated method stub - logger.warning("publish message not implemented yet"); + Builder messageBuilder = PubsubMessage.newBuilder(); + messageBuilder.putAttributes(DpsHeaders.ACCOUNT_ID, this.tenantInfo.getName()); + messageBuilder.putAttributes(DpsHeaders.DATA_PARTITION_ID, + this.headers.getPartitionIdWithFallbackToAccountId()); + this.headers.addCorrelationIdIfMissing(); + messageBuilder.putAttributes(DpsHeaders.CORRELATION_ID, this.headers.getCorrelationId()); + messageBuilder.setData(data); - } + return messageBuilder.build(); + } -} \ No newline at end of file +} diff --git a/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/messagebus/model/SchemaPubSubInfo.java b/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/messagebus/model/SchemaPubSubInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..31742683775b7b3858b7f0ffbb120cd1448dc410 --- /dev/null +++ b/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/messagebus/model/SchemaPubSubInfo.java @@ -0,0 +1,33 @@ +/* + Copyright 2021 Google LLC + Copyright 2021 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +package org.opengroup.osdu.schema.impl.messagebus.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SchemaPubSubInfo { + + private String kind; + + private String op; + +} diff --git a/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleSchemaInfoStore.java b/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleSchemaInfoStore.java index b90cd72391857da506d023bedf0ce5d2218f916c..8775030c70270435898310cef130625bd6b67f56 100644 --- a/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleSchemaInfoStore.java +++ b/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleSchemaInfoStore.java @@ -17,6 +17,21 @@ package org.opengroup.osdu.schema.impl.schemainfostore; +import com.google.cloud.Timestamp; +import com.google.cloud.datastore.Blob; +import com.google.cloud.datastore.BlobValue; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreException; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.KeyFactory; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.StructuredQuery.CompositeFilter; +import com.google.cloud.datastore.StructuredQuery.Filter; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +import com.google.gson.Gson; import java.util.Collections; import java.util.HashSet; import java.util.LinkedList; @@ -25,8 +40,9 @@ import java.util.Map.Entry; import java.util.Set; import java.util.TreeMap; import java.util.stream.Collectors; - +import org.apache.http.HttpStatus; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.model.tenant.TenantInfo; import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory; @@ -46,22 +62,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Repository; -import com.google.cloud.Timestamp; -import com.google.cloud.datastore.Blob; -import com.google.cloud.datastore.BlobValue; -import com.google.cloud.datastore.Datastore; -import com.google.cloud.datastore.DatastoreException; -import com.google.cloud.datastore.Entity; -import com.google.cloud.datastore.EntityQuery; -import com.google.cloud.datastore.Key; -import com.google.cloud.datastore.KeyFactory; -import com.google.cloud.datastore.Query; -import com.google.cloud.datastore.QueryResults; -import com.google.cloud.datastore.StructuredQuery.CompositeFilter; -import com.google.cloud.datastore.StructuredQuery.Filter; -import com.google.cloud.datastore.StructuredQuery.PropertyFilter; -import com.google.gson.Gson; - /** * Repository class to to register Schema in Google store. * @@ -340,9 +340,15 @@ public class GoogleSchemaInfoStore implements ISchemaInfoStore { Query query = Query.newKeyQueryBuilder().setNamespace(SchemaConstants.NAMESPACE) .setKind(SchemaConstants.SCHEMA_KIND).setFilter(PropertyFilter.eq("__key__", schemaKey)).build(); - QueryResults keys = datastore.run(query); - if (keys.hasNext()) - return false; + try { + QueryResults keys = datastore.run(query); + if (keys.hasNext()) { + return false; + } + } catch (DatastoreException e) { + throw new AppException(HttpStatus.SC_BAD_REQUEST, "Schema uniqueness check failed", + String.format("Misconfigured tenant-info for %s, not possible to check schema uniqueness", tenant)); + } } return true; } diff --git a/provider/schema-gcp/src/main/resources/application.properties b/provider/schema-gcp/src/main/resources/application.properties index 218dae13712a418e280bfe1703edf37b85a3ff51..3527ebb64408d5c6e4cb5d1ceacc8dd40185e274 100644 --- a/provider/schema-gcp/src/main/resources/application.properties +++ b/provider/schema-gcp/src/main/resources/application.properties @@ -13,3 +13,6 @@ shared.tenant.name=common google.audiences=123.apps.googleusercontent.com partition.api=http://localhost:8081/api/partition/v1 + +gcp.schema-changed.messagingEnabled=false +gcp.schema-changed.topicName=topicName \ No newline at end of file diff --git a/provider/schema-gcp/src/test/java/org/opengroup/osdu/schema/impl/messagebus/MessageBusImplTest.java b/provider/schema-gcp/src/test/java/org/opengroup/osdu/schema/impl/messagebus/MessageBusImplTest.java new file mode 100644 index 0000000000000000000000000000000000000000..951c1c65303c2b5188395881266691e28f5e570d --- /dev/null +++ b/provider/schema-gcp/src/test/java/org/opengroup/osdu/schema/impl/messagebus/MessageBusImplTest.java @@ -0,0 +1,88 @@ +/* + Copyright 2021 Google LLC + Copyright 2021 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +package org.opengroup.osdu.schema.impl.messagebus; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import com.google.cloud.pubsub.v1.Publisher; +import com.google.pubsub.v1.PubsubMessage; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.core.common.model.tenant.TenantInfo; +import org.opengroup.osdu.schema.configuration.EventMessagingPropertiesConfig; +import org.opengroup.osdu.schema.logging.AuditLogger; + +@RunWith(MockitoJUnitRunner.class) +public class MessageBusImplTest { + + private static final String SCHEMA_ID = "schemaId"; + private static final String EVENT_TYPE = "eventType"; + private static final String TENANT_NAME = "tenantName"; + private static final String DATA_PARTITION_ID = "partitionId"; + private static final String CORRELATION_ID = "correlationId"; + + @Mock + private Publisher publisher; + + @Mock + private TenantInfo tenantInfo; + + @Mock + private DpsHeaders headers; + + @Mock + private EventMessagingPropertiesConfig eventMessagingPropertiesConfig; + + @Mock + private JaxRsDpsLog logger; + + @Mock + private AuditLogger auditLogger; + + @InjectMocks + private MessageBusImpl messageBusImpl; + + @Test + public void shouldNot_publishEventMessage_WhenFlagIsFalse() { + when(this.eventMessagingPropertiesConfig.isMessagingEnabled()).thenReturn(false); + this.messageBusImpl.publishMessage(SCHEMA_ID, EVENT_TYPE); + verify(this.publisher, times(0)).publish(any()); + } + + @Test + public void should_publishEventMessage_WhenFlagIsTrue() { + when(this.eventMessagingPropertiesConfig.isMessagingEnabled()).thenReturn(true); + when(this.tenantInfo.getName()).thenReturn(TENANT_NAME); + when(this.headers.getPartitionIdWithFallbackToAccountId()).thenReturn(DATA_PARTITION_ID); + doNothing().when(this.headers).addCorrelationIdIfMissing(); + when(this.headers.getCorrelationId()).thenReturn(CORRELATION_ID); + + this.messageBusImpl.publishMessage(SCHEMA_ID, EVENT_TYPE); + + verify(this.publisher, times(1)).publish(any(PubsubMessage.class)); + } +} diff --git a/provider/schema-gcp/src/test/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleSchemaInfoStoreTest.java b/provider/schema-gcp/src/test/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleSchemaInfoStoreTest.java index 57f4b5a2d2080e5aeec3036f72dbfd44c80ff497..524d15a68625c82735b0fa355c41cfeff590a899 100644 --- a/provider/schema-gcp/src/test/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleSchemaInfoStoreTest.java +++ b/provider/schema-gcp/src/test/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleSchemaInfoStoreTest.java @@ -14,10 +14,12 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; +import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.model.tenant.TenantInfo; import org.opengroup.osdu.core.gcp.multitenancy.DatastoreFactory; @@ -478,6 +480,26 @@ public class GoogleSchemaInfoStoreTest { assertEquals(false, schemaInfoStore.cleanSchema(schemaId)); } + @Test + public void testMisconfiguredTenantInfoShouldThrowException() throws ApplicationException { + Key storageKey = mock(Key.class); + KeyFactory storageKeyFactory = mock(KeyFactory.class); + String schemaId = "schemaId"; + String tenantId = "common"; + Mockito.when(tenantFactory.getTenantInfo("common")).thenReturn(tenantInfoCommon); + Mockito.when(tenantInfoCommon.getName()).thenReturn("common"); + Mockito.when(dataStoreFactory.getDatastore(tenantInfoCommon)).thenReturn(dataStore); + Mockito.when(dataStore.newKeyFactory()).thenReturn(keyFactory); + Mockito.when(keyFactory.setKind(SchemaConstants.SCHEMA_KIND)).thenReturn(keyFactory); + Mockito.when(keyFactory.setNamespace(SchemaConstants.NAMESPACE)).thenReturn(keyFactory); + when(keyFactory.newKey(schemaId)).thenReturn(key); + when(storageKeyFactory.newKey(schemaId)).thenReturn(storageKey); + when(dataStore.run(ArgumentMatchers.any())).thenThrow(new DatastoreException(401,"","")); + expectedException.expect(AppException.class); + expectedException.expectMessage("Misconfigured tenant-info for common, not possible to check schema uniqueness"); + schemaInfoStore.isUnique(schemaId, tenantId); + } + private SchemaRequest getMockSchemaObject_Published() { return SchemaRequest.builder().schema("{}") .schemaInfo(SchemaInfo.builder() diff --git a/provider/schema-ibm/pom.xml b/provider/schema-ibm/pom.xml index 81942e246dad95be05e32ac4a8658daed7e6b2c7..e946eb678f5ffce7592e93891d51443ee82966f7 100644 --- a/provider/schema-ibm/pom.xml +++ b/provider/schema-ibm/pom.xml @@ -12,7 +12,7 @@ org.opengroup.osdu.schema.provider.ibm.app.SchemaIBMApplication - 0.7.0 + 0.9.0 diff --git a/provider/schema-ibm/src/main/java/org/opengroup/osdu/schema/impl/schemainfostore/IbmSchemaInfoStore.java b/provider/schema-ibm/src/main/java/org/opengroup/osdu/schema/impl/schemainfostore/IbmSchemaInfoStore.java index 97c25fbcdb9d67dd419a758b37c07fd138f61785..0d0d2792aa6c272db33022e6c098de64d4563585 100644 --- a/provider/schema-ibm/src/main/java/org/opengroup/osdu/schema/impl/schemainfostore/IbmSchemaInfoStore.java +++ b/provider/schema-ibm/src/main/java/org/opengroup/osdu/schema/impl/schemainfostore/IbmSchemaInfoStore.java @@ -283,7 +283,7 @@ public class IbmSchemaInfoStore extends IbmDocumentStore implements ISchemaInfoS } long numRecords = LIMIT_SIZE; - if (Long.valueOf(queryParams.getLimit()) != null) { + if (Long.valueOf(queryParams.getLimit()) != null && Long.valueOf(queryParams.getLimit()) != 0) { numRecords = Long.valueOf(queryParams.getLimit()); } diff --git a/schema-core/pom.xml b/schema-core/pom.xml index 7bf3b4637369023d67fd42d9ab623eec1b0b7801..36520bdd578dd4b7be8b8eef55283fc2cb84111c 100644 --- a/schema-core/pom.xml +++ b/schema-core/pom.xml @@ -13,7 +13,7 @@ 2.7.0 - 0.9.0 + 0.10.0 @@ -121,7 +121,16 @@ org.springframework.boot spring-boot-starter-actuator - + + javax.json + javax.json-api + 1.1.2 + + + org.glassfish + javax.json + 1.1.2 + diff --git a/schema-core/src/main/java/org/opengroup/osdu/schema/constants/SchemaConstants.java b/schema-core/src/main/java/org/opengroup/osdu/schema/constants/SchemaConstants.java index c39fe857d3af597291962579b5006ae0d981f458..3a76a61e8e9725f73fae23c39cfab9aba147f2f9 100644 --- a/schema-core/src/main/java/org/opengroup/osdu/schema/constants/SchemaConstants.java +++ b/schema-core/src/main/java/org/opengroup/osdu/schema/constants/SchemaConstants.java @@ -16,6 +16,10 @@ public class SchemaConstants { // authority public static final String AUTHORITY_KIND = "authority"; + + //Delimeters + public static final String SCHEMA_KIND_DELIMITER = ":"; + public static final String SCHEMA_Version_DELIMITER = "."; // schema public static final String SCHEMA_KIND = "schema"; @@ -31,6 +35,8 @@ public class SchemaConstants { public static final String SCHEMA = "schema"; public static final String SCOPE = "scope"; public static final String STATUS = "status"; + public static final String XOSDU_TAG = "x-osdu"; + public static final String TITLE_TAG = "title"; // general public static final String ALREADY_EXISTS = "ALREADY_EXISTS"; @@ -103,6 +109,8 @@ public class SchemaConstants { public static final String SCHEMA_ID_EXISTS = "Schema Id is already present"; public static final String INVALID_UPDATE_OPERATION = "Update/Create failed because schema id is present in another tenant"; public static final String UNAUTHORIZED_EXCEPTION = "User is unauthorized to perform this action"; + public static final String BREAKING_CHANGES_PATCH = "Patch version validation failed. Changes requiring a minor or major version increment were found; analysed version: {0} and {1}. Updating the schema version to a higher minor or major version is required."; + public static final String BREAKING_CHANGES_MINOR = "Minor version validation failed. Breaking changes were found; analysed versions {0} and {1}. Updating the schema version to a higher major version is required."; // OSDU public static final String DATA_PARTITION_ID = "data-partition-id"; @@ -110,9 +118,50 @@ public class SchemaConstants { public static final String APPLICATION_NAME = "Schema Service"; - //pub-sub message + //pub-sub message public final static String EVENT_SUBJECT = "schemachanged"; public final static String SCHEMA_CREATE_EVENT_TYPE = "create"; public final static String SCHEMA_UPDATE_EVENT_TYPE = "update"; public final static String KIND = "kind"; + + //Schema Validation Constants + public static enum SkipTags + { + TITLE("title"), + DESCRIPTION("description"), + EXAMPLES("examples"), + EXAMPLE("example"), + PATTERN("pattern"), + ID("$id"), + COMMENT("$comment"); + private final String value; + private SkipTags(String value) + { + this.value = value; + } + public String getValue() + { + return this.value; + } + } + + //Schema Composition Tags + public static enum CompositionTags + { + ALL_OF("allOf"), + ONE_OF("oneOf"), + ANY_OF("anyOf"); + + private final String value; + + private CompositionTags(String value) + { + this.value = value; + } + + public String getValue() + { + return this.value; + } + } } diff --git a/schema-core/src/main/java/org/opengroup/osdu/schema/exceptions/SchemaVersionException.java b/schema-core/src/main/java/org/opengroup/osdu/schema/exceptions/SchemaVersionException.java new file mode 100644 index 0000000000000000000000000000000000000000..64fdf58f4a2fee7cf00c11847d65fa2bbb426e8e --- /dev/null +++ b/schema-core/src/main/java/org/opengroup/osdu/schema/exceptions/SchemaVersionException.java @@ -0,0 +1,36 @@ +package org.opengroup.osdu.schema.exceptions; + +import org.springframework.http.HttpStatus; + +public class SchemaVersionException extends BadRequestException{ + + private final HttpStatus status; + private final String errorMsg; + private static final long serialVersionUID = 5234324334634627L; + + public SchemaVersionException(HttpStatus status, String errorMsg, Throwable throwable) { + super(errorMsg, throwable); + this.errorMsg = errorMsg; + this.status = status; + } + + public SchemaVersionException(HttpStatus status, String errorMsg) { + this(status, errorMsg, null); + } + + public SchemaVersionException(String errorMsg, Throwable throwable) { + this(HttpStatus.BAD_REQUEST, errorMsg, throwable); + } + + public SchemaVersionException(String errorMsg) { + this(HttpStatus.BAD_REQUEST, errorMsg, null); + } + + public SchemaVersionException(Throwable throwable) { + this(HttpStatus.BAD_REQUEST.toString(), throwable); + } + + public SchemaVersionException() { + this(HttpStatus.BAD_REQUEST.toString()); + } +} diff --git a/schema-core/src/main/java/org/opengroup/osdu/schema/model/SchemaRequest.java b/schema-core/src/main/java/org/opengroup/osdu/schema/model/SchemaRequest.java index 049a4d953efd37921cf515da1ab819e849414cd0..b048fab2c8752c093a341911b0945b63215de863 100644 --- a/schema-core/src/main/java/org/opengroup/osdu/schema/model/SchemaRequest.java +++ b/schema-core/src/main/java/org/opengroup/osdu/schema/model/SchemaRequest.java @@ -3,7 +3,7 @@ package org.opengroup.osdu.schema.model; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import org.opengroup.osdu.schema.validation.SchemaConstraint; +import org.opengroup.osdu.schema.validation.SchemaRequestConstraint; import lombok.AllArgsConstructor; import lombok.Builder; @@ -21,7 +21,7 @@ public class SchemaRequest { private SchemaInfo schemaInfo; @NotNull(message = "schema must not be null") - @SchemaConstraint + @SchemaRequestConstraint private Object schema; } diff --git a/schema-core/src/main/java/org/opengroup/osdu/schema/service/serviceimpl/SchemaService.java b/schema-core/src/main/java/org/opengroup/osdu/schema/service/serviceimpl/SchemaService.java index 3ba008e3e21680580e6ad2360c06f4933f2f43bb..55b79a1dea336416d6c2588387fcc7575e22d3e0 100644 --- a/schema-core/src/main/java/org/opengroup/osdu/schema/service/serviceimpl/SchemaService.java +++ b/schema-core/src/main/java/org/opengroup/osdu/schema/service/serviceimpl/SchemaService.java @@ -21,6 +21,7 @@ import org.opengroup.osdu.schema.exceptions.ApplicationException; import org.opengroup.osdu.schema.exceptions.BadRequestException; import org.opengroup.osdu.schema.exceptions.NoSchemaFoundException; import org.opengroup.osdu.schema.exceptions.NotFoundException; +import org.opengroup.osdu.schema.exceptions.SchemaVersionException; import org.opengroup.osdu.schema.logging.AuditLogger; import org.opengroup.osdu.schema.model.QueryParams; import org.opengroup.osdu.schema.model.SchemaIdentity; @@ -35,12 +36,16 @@ import org.opengroup.osdu.schema.service.IAuthorityService; import org.opengroup.osdu.schema.service.IEntityTypeService; import org.opengroup.osdu.schema.service.ISchemaService; import org.opengroup.osdu.schema.service.ISourceService; +import org.opengroup.osdu.schema.util.SchemaComparatorByVersion; import org.opengroup.osdu.schema.util.SchemaResolver; import org.opengroup.osdu.schema.util.SchemaUtil; +import org.opengroup.osdu.schema.validation.SchemaVersionValidatorFactory; +import org.opengroup.osdu.schema.validation.SchemaVersionValidatorType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; + import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; @@ -68,9 +73,11 @@ public class SchemaService implements ISchemaService { private final IEntityTypeService entityTypeService; private final SchemaUtil schemaUtil; - + private SchemaResolver schemaResolver; + private final SchemaVersionValidatorFactory versionValidatorFactory; + @Value("${shared.tenant.name:common}") private String sharedTenant; @@ -131,13 +138,7 @@ public class SchemaService implements ISchemaService { if (schemaInfoStore.isUnique(schemaId, dataPartitionId)) { setScope(schemaRequest, dataPartitionId); - String latestMinorSchema = schemaInfoStore.getLatestMinorVerSchema(schemaRequest.getSchemaInfo()); - - Gson gson = new Gson(); - if (StringUtils.isNotEmpty(latestMinorSchema)) { - schemaUtil.checkBreakingChange(gson.toJson(schemaRequest.getSchema()), latestMinorSchema); - } - String schema = schemaResolver.resolveSchema(gson.toJson(schemaRequest.getSchema())); + String schema = resolveAndCheckBreakingChanges(schemaRequest); Boolean authority = authorityService.checkAndRegisterAuthorityIfNotPresent( schemaRequest.getSchemaInfo().getSchemaIdentity().getAuthority()); @@ -205,8 +206,7 @@ public class SchemaService implements ISchemaService { if (SchemaStatus.DEVELOPMENT.equals(schemaInfo.getStatus())) { log.info(MessageFormat.format(SchemaConstants.SCHEMA_UPDATION_STARTED, createdSchemaId)); setScope(schemaRequest, dataPartitionId); - Gson gson = new Gson(); - String schema = schemaResolver.resolveSchema(gson.toJson(schemaRequest.getSchema())); + String schema = resolveAndCheckBreakingChanges(schemaRequest); SchemaInfo schInfo = schemaInfoStore.updateSchemaInfo(schemaRequest); auditLogger.schemaUpdatedSuccess(Collections.singletonList(schemaRequest.toString())); schemaStore.createSchema(schemaRequest.getSchemaInfo().getSchemaIdentity().getId(), schema); @@ -235,6 +235,15 @@ public class SchemaService implements ISchemaService { schemaRequest.getSchemaInfo().getSchemaIdentity().setId(schemaId); return schemaId; } + + private String resolveAndCheckBreakingChanges(SchemaRequest schemaRequest) throws ApplicationException, BadRequestException { + + Gson gson = new Gson(); + String schemaInRequestPayload = gson.toJson(schemaRequest.getSchema()); + String fullyResolvedInputSchema = schemaResolver.resolveSchema(schemaInRequestPayload); + compareFullyResolvedSchema(schemaRequest.getSchemaInfo(), fullyResolvedInputSchema); + return fullyResolvedInputSchema; + } @Override public SchemaInfoResponse getSchemaInfoList(QueryParams queryParams) @@ -343,6 +352,7 @@ public class SchemaService implements ISchemaService { List latestSchemaList = new ArrayList<>(); Map latestSchemaMap = new HashMap<>(); + SchemaComparatorByVersion schemaComparatorByVersion = new SchemaComparatorByVersion(); for(SchemaInfo schemaInfo :filteredSchemaList) { @@ -351,7 +361,7 @@ public class SchemaService implements ISchemaService { SchemaInfo value = latestSchemaMap.get(key); - if(compareSchemaVersion(schemaInfo, value) >= 0) + if(schemaComparatorByVersion.compare(schemaInfo, value) >= 0) latestSchemaMap.put(key, schemaInfo); } @@ -373,28 +383,45 @@ public class SchemaService implements ISchemaService { schemaInfo.getSchemaIdentity().getEntityType()); } - /**** - * This method compares the schema versions of two SchemaInfo attribute. The comparison is done based on the following order
- * 1. Major Version
- * 2. Minor Version
- * 3. Patch Version
- * - * @param scInfo1 SchemaInfo version - * @param scInfo2 SchemaInfo - * @return Returns positive integer if version of scInfo1 is greater than version of scInfo2 - */ - private int compareSchemaVersion(SchemaInfo scInfo1, SchemaInfo scInfo2){ + private void compareFullyResolvedSchema(SchemaInfo inputSchemaInfo, String resolvedInputSchema) throws BadRequestException, ApplicationException { + try { + SchemaInfo[] schemaInfoToCompareWith = schemaUtil.findSchemaToCompare(inputSchemaInfo); + + for(SchemaInfo existingSchemaInfo : schemaInfoToCompareWith) { + if(null == existingSchemaInfo) + continue; + + String existingSchemaInStore = getSchema(existingSchemaInfo.getSchemaIdentity().getId()).toString(); + + try { + //Compare Major version of the schemas are different + if(inputSchemaInfo.getSchemaIdentity().getSchemaVersionMajor().compareTo(existingSchemaInfo.getSchemaIdentity().getSchemaVersionMajor()) != 0) { + continue; + //Compare Minor version is greater or smaller + }else if(inputSchemaInfo.getSchemaIdentity().getSchemaVersionMinor().compareTo(existingSchemaInfo.getSchemaIdentity().getSchemaVersionMinor()) < 0){ + versionValidatorFactory.getSchemaVersionValidator(SchemaVersionValidatorType.MINOR).validate(resolvedInputSchema, existingSchemaInStore); + }else if(inputSchemaInfo.getSchemaIdentity().getSchemaVersionMinor().compareTo(existingSchemaInfo.getSchemaIdentity().getSchemaVersionMinor()) > 0) { + versionValidatorFactory.getSchemaVersionValidator(SchemaVersionValidatorType.MINOR).validate(existingSchemaInStore, resolvedInputSchema); + }else { + versionValidatorFactory.getSchemaVersionValidator(SchemaVersionValidatorType.PATCH).validate(existingSchemaInStore, resolvedInputSchema); + } + }catch (SchemaVersionException exc) { + log.error("Failed to resolve the schema and find breaking changes. Reason :" + exc.getMessage()); + + String message = MessageFormat.format(exc.getMessage(), StringUtils.substringAfterLast(inputSchemaInfo.getSchemaIdentity().getId(), SchemaConstants.SCHEMA_KIND_DELIMITER), + StringUtils.substringAfterLast(existingSchemaInfo.getSchemaIdentity().getId(), SchemaConstants.SCHEMA_KIND_DELIMITER)); + throw new BadRequestException(message); + } + } - Comparator compareByMajor = - (s1,s2) -> s1.getSchemaIdentity().getSchemaVersionMajor().compareTo(s2.getSchemaIdentity().getSchemaVersionMajor()); - Comparator compareByMinor = - (s1,s2) -> s1.getSchemaIdentity().getSchemaVersionMinor().compareTo(s2.getSchemaIdentity().getSchemaVersionMinor()); - - Comparator compareByPatch = - (s1,s2) -> s1.getSchemaIdentity().getSchemaVersionPatch().compareTo(s2.getSchemaIdentity().getSchemaVersionPatch()); + } catch ( NotFoundException e) { + throw new ApplicationException("Schema not found to evaluate breaking changes."); + }catch (JSONException exc) { + log.error("Failed to resolve the schema and find breaking changes. Reason :"+exc.getMessage()); + throw new BadRequestException("Bad Input, invalid json"); + } - - return compareByMajor.thenComparing(compareByMinor).thenComparing(compareByPatch).compare(scInfo1, scInfo2); } + } \ No newline at end of file diff --git a/schema-core/src/main/java/org/opengroup/osdu/schema/util/JSONUtil.java b/schema-core/src/main/java/org/opengroup/osdu/schema/util/JSONUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..490e8de6b2ca380cabfc4ea239841f325b8cd5bb --- /dev/null +++ b/schema-core/src/main/java/org/opengroup/osdu/schema/util/JSONUtil.java @@ -0,0 +1,100 @@ +package org.opengroup.osdu.schema.util; + +import java.io.StringReader; +import java.util.EnumSet; +import java.util.Iterator; +import java.util.Map.Entry; +import java.util.concurrent.atomic.AtomicInteger; + +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonPatch; +import javax.json.JsonPointer; +import javax.json.JsonReader; +import javax.json.JsonStructure; +import javax.json.JsonValue; + +import org.opengroup.osdu.schema.constants.SchemaConstants; +import org.opengroup.osdu.schema.constants.SchemaConstants.CompositionTags; +import org.opengroup.osdu.schema.constants.SchemaConstants.SkipTags; +import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import lombok.RequiredArgsConstructor; + +@Component +@RequiredArgsConstructor +public class JSONUtil { + + private EnumSet skipTags = EnumSet.allOf(SkipTags.class); + private EnumSet compositionTags = EnumSet.allOf(CompositionTags.class); + + public String getCleanJSON(String inputJSON) throws JsonMappingException, JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + JsonNode root = mapper.readTree(inputJSON); + clean(root, ""); + + return root.toString(); + } + private boolean checkIfParentIsCompositionTag(String path) { + String [] tags = path.split("/"); + if(tags.length < 3) + return false; + boolean isCompositionTag = compositionTags.stream().anyMatch(tag -> tag.getValue().equals(tags[tags.length-2])); + return isCompositionTag; + } + + public JsonPatch findJSONDiff(JsonValue source, JsonValue target) { + JsonPatch diff = Json.createDiff(source.asJsonObject(), target.asJsonObject()); + return diff; + + } + + public JsonArray getJsonArrayFromGivenPath(String jsonString, String rootPath) { + JsonReader reader = Json.createReader(new StringReader(jsonString)); + JsonStructure jsonStruct = reader.read(); + JsonPointer jp = Json.createPointer(rootPath); + JsonValue oldJsonVal = jp.getValue(jsonStruct); + return oldJsonVal.asJsonArray(); + } + + private void clean(JsonNode node, String path) { + if (node.isObject()) { + ObjectNode object = (ObjectNode) node; + Iterator> itr = object.fields(); + while(itr.hasNext()) { + + Entry entry = itr.next(); + String key = entry.getKey(); + if(skipTags.stream().anyMatch(tag -> tag.getValue().equals(key)) + || entry.getKey().startsWith(SchemaConstants.XOSDU_TAG)) { + //Don't delete the title tag of elements inside composition tag + //This will be utilized later for comparision + if(SchemaConstants.TITLE_TAG.equals(key) + && checkIfParentIsCompositionTag(path)){ + continue; + } + itr.remove(); + } + clean(entry.getValue(), path + "/" + entry.getKey()); + } + } else if (node.isArray()) { + ArrayNode array = (ArrayNode) node; + Iterator itr = array.elements(); + AtomicInteger counter = new AtomicInteger(); + while(itr.hasNext()) { + JsonNode entry = itr.next(); + if(skipTags.stream().anyMatch(tag -> tag.getValue().equals(entry)) + || entry.asText().startsWith(SchemaConstants.XOSDU_TAG)) { + itr.remove(); + } + clean(entry, path + "/" + counter.getAndIncrement()); + } + } + } +} diff --git a/schema-core/src/main/java/org/opengroup/osdu/schema/util/SchemaComparatorByVersion.java b/schema-core/src/main/java/org/opengroup/osdu/schema/util/SchemaComparatorByVersion.java new file mode 100644 index 0000000000000000000000000000000000000000..8ff9b0e2226ab7f7431952b750c8c3e5be75c95c --- /dev/null +++ b/schema-core/src/main/java/org/opengroup/osdu/schema/util/SchemaComparatorByVersion.java @@ -0,0 +1,25 @@ +package org.opengroup.osdu.schema.util; + +import java.util.Comparator; + +import org.opengroup.osdu.schema.model.SchemaIdentity; +import org.opengroup.osdu.schema.model.SchemaInfo; + +public class SchemaComparatorByVersion implements Comparator { + + @Override + public int compare(SchemaInfo sch1, SchemaInfo sch2) { + SchemaIdentity schemaIdentity1 = sch1.getSchemaIdentity(); + SchemaIdentity schemaIdentity2 = sch2.getSchemaIdentity(); + + Comparator compareByMajor = (s1,s2) -> s1.getSchemaVersionMajor().compareTo(s2.getSchemaVersionMajor()); + + Comparator compareByMinor = (s1,s2) -> s1.getSchemaVersionMinor().compareTo(s2.getSchemaVersionMinor()); + + Comparator compareByPatch = (s1,s2) -> s1.getSchemaVersionPatch().compareTo(s2.getSchemaVersionPatch()); + + return compareByMajor.thenComparing(compareByMinor).thenComparing(compareByPatch).compare(schemaIdentity1, schemaIdentity2); + } + + +} \ No newline at end of file diff --git a/schema-core/src/main/java/org/opengroup/osdu/schema/util/SchemaUtil.java b/schema-core/src/main/java/org/opengroup/osdu/schema/util/SchemaUtil.java index b18b981e28f7705e6b3f013467e934dfada867bd..4a54b75aff94836da18798931efccb3eb7cf7f99 100644 --- a/schema-core/src/main/java/org/opengroup/osdu/schema/util/SchemaUtil.java +++ b/schema-core/src/main/java/org/opengroup/osdu/schema/util/SchemaUtil.java @@ -1,23 +1,84 @@ package org.opengroup.osdu.schema.util; -import org.json.JSONException; -import org.opengroup.osdu.schema.exceptions.BadRequestException; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; +import java.util.Collections; +import java.util.List; +import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.schema.exceptions.ApplicationException; +import org.opengroup.osdu.schema.model.QueryParams; +import org.opengroup.osdu.schema.model.SchemaIdentity; +import org.opengroup.osdu.schema.model.SchemaInfo; +import org.opengroup.osdu.schema.provider.interfaces.schemainfostore.ISchemaInfoStore; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import lombok.RequiredArgsConstructor; + @Component +@RequiredArgsConstructor public class SchemaUtil { - public void checkBreakingChange(String newSchema, String originalSchema) throws BadRequestException { + private final ISchemaInfoStore schemaInfoStore; + + private final JaxRsDpsLog log; + + private final DpsHeaders headers; + + @Value("${shared.tenant.name:common}") + private String sharedTenant; + + public SchemaInfo[] findSchemaToCompare(SchemaInfo schemaInfo) throws ApplicationException { + + SchemaInfo[] matchingSchemaInfo = findClosestSchemas(schemaInfo, true); + + if(null == matchingSchemaInfo[0] && null == matchingSchemaInfo[1]) { + log.info("Latest patch version is not found so trying to find the nearest matching major version"); + matchingSchemaInfo = findClosestSchemas(schemaInfo, false); + } + + return matchingSchemaInfo; + } + + public SchemaInfo[] findClosestSchemas(SchemaInfo schemaInfo, boolean atPatchlevel) throws ApplicationException { + SchemaIdentity schemaIdentity = schemaInfo.getSchemaIdentity(); + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + QueryParams.QueryParamsBuilder queryParamBuilder = QueryParams.builder().authority(schemaIdentity.getAuthority()) + .source(schemaIdentity.getSource()) + .entityType(schemaIdentity.getEntityType()) + .schemaVersionMajor(schemaIdentity.getSchemaVersionMajor()); + + if(atPatchlevel) + queryParamBuilder.schemaVersionMinor(schemaIdentity.getSchemaVersionMinor()); + + QueryParams queryParams = queryParamBuilder.build(); + + List schemaInfoList = schemaInfoStore.getSchemaInfoList(queryParams, headers.getPartitionId()); + + if(null == schemaInfoList || schemaInfoList.isEmpty()) + return schemaInfoArr; + + SchemaComparatorByVersion schemaComparatorByVersion = new SchemaComparatorByVersion(); + Collections.sort(schemaInfoList, schemaComparatorByVersion); + + SchemaInfo smaller = null,bigger =null; + + for(SchemaInfo element : schemaInfoList) { + + if(schemaComparatorByVersion.compare(element, schemaInfo) < 0) { + smaller = element; + }else if (schemaComparatorByVersion.compare(element, schemaInfo) > 0) { + bigger = element; + break; + } + } + + schemaInfoArr[0]=smaller; + schemaInfoArr[1]=bigger; + + return schemaInfoArr; + } + + - try { - JSONAssert.assertEquals(originalSchema, newSchema, JSONCompareMode.LENIENT); - } catch (AssertionError e) { - throw new BadRequestException("Breaking changes found, please change schema major version"); - } catch (JSONException e) { - throw new BadRequestException("Bad Input, invalid json"); - } - } } diff --git a/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaMinorVersionValidator.java b/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaMinorVersionValidator.java new file mode 100644 index 0000000000000000000000000000000000000000..a29dd520e6690054ddd8c28fe1d9b4f1512f3046 --- /dev/null +++ b/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaMinorVersionValidator.java @@ -0,0 +1,213 @@ +package org.opengroup.osdu.schema.validation; + + +import java.io.StringReader; +import java.util.Arrays; +import java.util.HashSet; +import java.util.ListIterator; +import java.util.Optional; +import java.util.Set; +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonObject; +import javax.json.JsonPatch; +import javax.json.JsonPointer; +import javax.json.JsonValue; +import org.apache.commons.lang3.StringUtils; +import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.schema.constants.SchemaConstants; +import org.opengroup.osdu.schema.exceptions.ApplicationException; +import org.opengroup.osdu.schema.exceptions.SchemaVersionException; +import org.opengroup.osdu.schema.util.JSONUtil; +import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonProcessingException; +import lombok.RequiredArgsConstructor; + +@Component +@RequiredArgsConstructor +public class SchemaMinorVersionValidator implements SchemaVersionValidator{ + + private final JaxRsDpsLog log; + + private final JSONUtil jsonUtil; + + @Override + public void validate(String oldSchema, String newSchema) throws SchemaVersionException, ApplicationException{ + + String cleanSource; + String cleanTarget; + try { + cleanSource = jsonUtil.getCleanJSON(oldSchema); + cleanTarget = jsonUtil.getCleanJSON(newSchema); + } catch (JsonProcessingException e) { + throw new ApplicationException("Failed to vaildate schemas."); + } + + JsonValue source = Json.createReader(new StringReader(cleanSource)).readValue(); + JsonValue target = Json.createReader(new StringReader(cleanTarget)).readValue(); + + JsonPatch diff = jsonUtil.findJSONDiff(source, target); + Set processedArrayPath = new HashSet<>(); + + log.info("Difference between two schemas found :"+diff); + + for(JsonValue jsonValue : diff.toJsonArray()) { + + JsonObject jsonObject = jsonValue.asJsonObject(); + String operation = jsonObject.getString("op"); + String path = jsonObject.getString("path"); + String attributeName = StringUtils.substringAfterLast(path, "/"); + + log.info("Processing the path :"+path); + log.info("Processing the Operation :"+operation); + + //Changing state of "additionalProperties" is only permitted when it was not present and added as true + //or it is present as true but removed now + if("additionalProperties".equals(attributeName)) { + if("add".equals(operation) && "true".equals(jsonObject.get("value").toString())) { + continue; + }else if("remove".equals(operation)) { + JsonPointer pointer = Json.createPointer(path); + JsonValue originalValue = pointer.getValue(source.asJsonObject()); + if("true".equals(originalValue.toString())) + continue; + } + + log.error("Changing state of \"additionalProperties\" is not permitted. Path :"+path); + throw new SchemaVersionException(SchemaConstants.BREAKING_CHANGES_MINOR); + } + //Removing anything is not permitted + if(path.contains("/allOf") || path.contains("/oneOf") || path.contains("/anyOf")) { + String [] attributes = path.split("/"); + + Optional xxxOfAttrOpt = Arrays.stream(attributes) + .filter(attr -> ("allOf".equals(attr) || "oneOf".equals(attr) || "anyOf".equals(attr))) + .findFirst(); + + if(operation.equals("remove") && attributeName.equals(xxxOfAttrOpt.get())) + throw new SchemaVersionException(SchemaConstants.BREAKING_CHANGES_MINOR); + + int lastIdx = path.indexOf(xxxOfAttrOpt.get()); + String rootPath = path.substring(0, lastIdx+5); + + //Array is already validated + if (processedArrayPath.contains(rootPath)) + continue; + + validateCompositionAttributesForMinorVersion(cleanSource, cleanTarget, rootPath); + processedArrayPath.add(rootPath); + } + + //Changing list of "required" is not permitted + else if(path.contains("/required")) { + int lastIdx = path.indexOf("required"); + String rootPath = path.substring(0, lastIdx+8); + + //Array is already validated + if (processedArrayPath.contains(rootPath)) + continue; + + validateRequiredAttribute(cleanSource, cleanTarget, rootPath); + processedArrayPath.add(rootPath); + } + else if("type".endsWith(attributeName)) { + //Remove operation is not permitted + if(operation.equals("remove") || operation.equals("replace")) { + log.error("Removing or changing type attribute is not permitted. Path :"+path); + throw new SchemaVersionException(SchemaConstants.BREAKING_CHANGES_MINOR); + } + } + + //Remove operation is not permitted + else if(operation.equals("remove")) { + log.error("Removing elements from a schema at Minor level not permitted. Path :"+path); + throw new SchemaVersionException(SchemaConstants.BREAKING_CHANGES_MINOR); + } + } + } + + + @Override + public SchemaVersionValidatorType getType() { + return SchemaVersionValidatorType.MINOR; + } + + private void validateCompositionAttributesForMinorVersion(String oldSchema, String newSchema, String path) throws SchemaVersionException, ApplicationException { + JsonArray oldJsonArray = jsonUtil.getJsonArrayFromGivenPath(oldSchema, path); + JsonArray newJsonArray = jsonUtil.getJsonArrayFromGivenPath(newSchema, path); + + + try { + if(oldJsonArray.size() > newJsonArray.size()) { + throw new SchemaVersionException(SchemaConstants.BREAKING_CHANGES_MINOR); + } + + for(int i=0;i newItr = newJsonArray.listIterator(); + int count=0; + String newTitle=null; + while(newItr.hasNext()) { + JsonValue newValue = newItr.next(); + if(newValue.asJsonObject().containsKey("title")) { + newTitle = newValue.asJsonObject().get("title").toString(); + } + + //Skip if title block is not present + if(StringUtils.isNoneBlank(oldTitle) && oldTitle.equals(newTitle) == false) { + count++; + continue; + } + validate(oldValue.toString(), newValue.toString()); + break; + } + + //Element is not found in the entire Array + if(count == newJsonArray.size()) { + throw new SchemaVersionException(SchemaConstants.BREAKING_CHANGES_MINOR); + } + } + } + }catch (AssertionError exc) { + throw new SchemaVersionException(SchemaConstants.BREAKING_CHANGES_MINOR); + } + + } + + private void validateRequiredAttribute(String oldSchema, String newSchema, String path) throws SchemaVersionException { + + JsonArray oldJsonArray = jsonUtil.getJsonArrayFromGivenPath(oldSchema, path); + JsonArray newJsonArray = jsonUtil.getJsonArrayFromGivenPath(newSchema, path); + + if(false == compareRequiredArrays(oldJsonArray, newJsonArray)) { + log.error("Changing list of \"required\" is not permitted. Path :"+path); + throw new SchemaVersionException(SchemaConstants.BREAKING_CHANGES_MINOR); + } + + } + + private boolean compareRequiredArrays(JsonArray arr1, JsonArray arr2) { + + if(arr1.size() != arr2.size()) { + log.error("Array length is not same."); + return false; + } + + return arr1.containsAll(arr1); + } +} diff --git a/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaPatchVersionValidator.java b/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaPatchVersionValidator.java new file mode 100644 index 0000000000000000000000000000000000000000..acd25fba8d3588805b7e1dddbda181de89b3a448 --- /dev/null +++ b/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaPatchVersionValidator.java @@ -0,0 +1,82 @@ +package org.opengroup.osdu.schema.validation; + +import java.io.StringReader; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; + +import javax.json.Json; +import javax.json.JsonObject; +import javax.json.JsonPatch; +import javax.json.JsonValue; + +import org.apache.commons.lang3.StringUtils; +import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.schema.constants.SchemaConstants; +import org.opengroup.osdu.schema.exceptions.ApplicationException; +import org.opengroup.osdu.schema.exceptions.SchemaVersionException; +import org.opengroup.osdu.schema.provider.interfaces.schemainfostore.ISchemaInfoStore; +import org.opengroup.osdu.schema.util.JSONUtil; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.core.JsonProcessingException; + +import org.opengroup.osdu.schema.constants.SchemaConstants.SkipTags; +import lombok.RequiredArgsConstructor; + +@Component +@RequiredArgsConstructor +public class SchemaPatchVersionValidator implements SchemaVersionValidator{ + + private List breakingChanges = new ArrayList(); + + private final ISchemaInfoStore schemaInfoStore; + + private final JaxRsDpsLog log; + + private final DpsHeaders headers; + + private final JSONUtil jsonUtil; + + private EnumSet skipTags = EnumSet.allOf(SkipTags.class); + + @Override + public SchemaVersionValidatorType getType() { + return SchemaVersionValidatorType.PATCH; + } + + @Override + public void validate(String oldSchema, String newSchema) throws SchemaVersionException, ApplicationException { + + String cleanSource; + String cleanTarget; + try { + cleanSource = jsonUtil.getCleanJSON(oldSchema); + cleanTarget = jsonUtil.getCleanJSON(newSchema); + } catch (JsonProcessingException e) { + throw new ApplicationException("Failed to vaildate schemas."); + } + + + JsonValue source = Json.createReader(new StringReader(cleanSource)).readValue(); + JsonValue target = Json.createReader(new StringReader(cleanTarget)).readValue(); + + JsonPatch diff = jsonUtil.findJSONDiff(source, target); + + for(JsonValue value: diff.toJsonArray()) { + JsonObject jsonObject = value.asJsonObject(); + String path = jsonObject.getString("path"); + String attributeName = StringUtils.substringAfterLast(path, "/"); + + if(skipTags.stream().anyMatch(tag -> tag.getValue().equals(attributeName)) + || attributeName.startsWith(SchemaConstants.XOSDU_TAG)) + continue; + + log.error("Failed patch level validation for the attribute: "+attributeName); + + throw new SchemaVersionException(SchemaConstants.BREAKING_CHANGES_PATCH); + } + } + +} diff --git a/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaConstraint.java b/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaRequestConstraint.java similarity index 85% rename from schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaConstraint.java rename to schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaRequestConstraint.java index 3100c0a78cc97b221c648734e7754fa73bcb398b..d1962d9ccf47fdf0294846587a6540e24fd4854f 100644 --- a/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaConstraint.java +++ b/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaRequestConstraint.java @@ -12,10 +12,10 @@ import javax.validation.Payload; import org.opengroup.osdu.schema.constants.SchemaConstants; @Documented -@Constraint(validatedBy = SchemaValidator.class) +@Constraint(validatedBy = SchemaRequestValidator.class) @Target({ ElementType.FIELD }) @Retention(RetentionPolicy.RUNTIME) -public @interface SchemaConstraint { +public @interface SchemaRequestConstraint { String message() default SchemaConstants.INVALID_SCHEMA_INPUT; Class[] groups() default {}; diff --git a/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaValidator.java b/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaRequestValidator.java similarity index 89% rename from schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaValidator.java rename to schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaRequestValidator.java index 03a90b50422ca13dd5d5496f1a13ae174838f7ed..e66eb67737519583d8d626270da002bd73734e8a 100644 --- a/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaValidator.java +++ b/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaRequestValidator.java @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; * Method to validate if field with SchemaConstraint annotation is in form of * Json Object */ -public class SchemaValidator implements ConstraintValidator { +public class SchemaRequestValidator implements ConstraintValidator { @Override public boolean isValid(Object value, ConstraintValidatorContext context) { diff --git a/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaVersionValidator.java b/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaVersionValidator.java new file mode 100644 index 0000000000000000000000000000000000000000..d68b0da864df39deb25195386f82b221edce6664 --- /dev/null +++ b/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaVersionValidator.java @@ -0,0 +1,13 @@ +package org.opengroup.osdu.schema.validation; + +import org.opengroup.osdu.schema.exceptions.ApplicationException; +import org.opengroup.osdu.schema.exceptions.SchemaVersionException; + +public interface SchemaVersionValidator { + + public SchemaVersionValidatorType getType(); + + public void validate(String oldSchema, String newSchema) throws SchemaVersionException, ApplicationException; + + +} diff --git a/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaVersionValidatorFactory.java b/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaVersionValidatorFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..32654b16fb3667f307a775bad809d1df181f22f0 --- /dev/null +++ b/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaVersionValidatorFactory.java @@ -0,0 +1,21 @@ +package org.opengroup.osdu.schema.validation; + +import java.util.List; +import java.util.Optional; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class SchemaVersionValidatorFactory { + + @Autowired + private List schemaVersionValidator; + + public SchemaVersionValidator getSchemaVersionValidator(SchemaVersionValidatorType validatorType) { + Optional schemaValidator = schemaVersionValidator.stream().filter(validator -> validator.getType().equals(validatorType)) + .findAny(); + + return schemaValidator.orElseThrow(() -> new RuntimeException("Unknown validator type: " + validatorType)); + } +} diff --git a/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaVersionValidatorType.java b/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaVersionValidatorType.java new file mode 100644 index 0000000000000000000000000000000000000000..5e26377d262e4e99c1889cebf5d78bd8ed5d168d --- /dev/null +++ b/schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaVersionValidatorType.java @@ -0,0 +1,6 @@ +package org.opengroup.osdu.schema.validation; + +public enum SchemaVersionValidatorType { + PATCH, + MINOR; +} diff --git a/schema-core/src/test/java/org/opengroup/osdu/schema/service/serviceimpl/SchemaServiceTest.java b/schema-core/src/test/java/org/opengroup/osdu/schema/service/serviceimpl/SchemaServiceTest.java index 1b452d754746cdcde3585483d7ec514e96cf28f7..d47be2c9f21410447a8b988d2d4650cf28cd2040 100644 --- a/schema-core/src/test/java/org/opengroup/osdu/schema/service/serviceimpl/SchemaServiceTest.java +++ b/schema-core/src/test/java/org/opengroup/osdu/schema/service/serviceimpl/SchemaServiceTest.java @@ -4,10 +4,17 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.IOException; import java.util.Date; import java.util.LinkedList; import java.util.List; -import static org.mockito.Mockito.*; + import org.json.JSONException; import org.junit.Assert; import org.junit.Before; @@ -16,6 +23,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.InjectMocks; +import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.Mockito; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; @@ -27,6 +35,7 @@ import org.opengroup.osdu.schema.exceptions.ApplicationException; import org.opengroup.osdu.schema.exceptions.BadRequestException; import org.opengroup.osdu.schema.exceptions.NoSchemaFoundException; import org.opengroup.osdu.schema.exceptions.NotFoundException; +import org.opengroup.osdu.schema.exceptions.SchemaVersionException; import org.opengroup.osdu.schema.logging.AuditLogger; import org.opengroup.osdu.schema.model.QueryParams; import org.opengroup.osdu.schema.model.SchemaIdentity; @@ -38,820 +47,885 @@ import org.opengroup.osdu.schema.provider.interfaces.schemastore.ISchemaStore; import org.opengroup.osdu.schema.service.IAuthorityService; import org.opengroup.osdu.schema.service.IEntityTypeService; import org.opengroup.osdu.schema.service.ISourceService; +import org.opengroup.osdu.schema.util.FileUtils; import org.opengroup.osdu.schema.util.SchemaResolver; import org.opengroup.osdu.schema.util.SchemaUtil; +import org.opengroup.osdu.schema.validation.SchemaMinorVersionValidator; +import org.opengroup.osdu.schema.validation.SchemaPatchVersionValidator; +import org.opengroup.osdu.schema.validation.SchemaVersionValidator; +import org.opengroup.osdu.schema.validation.SchemaVersionValidatorFactory; +import org.opengroup.osdu.schema.validation.SchemaVersionValidatorType; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.util.ReflectionTestUtils; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; @RunWith(SpringJUnit4ClassRunner.class) public class SchemaServiceTest { - @InjectMocks - SchemaService schemaService; + @InjectMocks + SchemaService schemaService; - @Mock - ISchemaInfoStore schemaInfoStore; + @Mock + ISchemaInfoStore schemaInfoStore; - @Mock - ISchemaStore schemaStore; + @Mock + ISchemaStore schemaStore; - @Mock - IAuthorityService authorityService; + @Mock + IAuthorityService authorityService; - @Mock - ISourceService sourceService; + @Mock + ISourceService sourceService; - @Mock - IEntityTypeService entityTypeService; + @Mock + IEntityTypeService entityTypeService; - @Mock - SchemaUtil SchemaUtil; + @Mock + SchemaUtil schemaUtil; - @Mock - SchemaResolver schemaResolver; + @Mock + SchemaResolver schemaResolver; - @Mock - DpsHeaders headers; + @Mock + DpsHeaders headers; - @Mock - JaxRsDpsLog log; + @Mock + JaxRsDpsLog log; - @Mock - AuditLogger auditLogger; - - @Value("${shared.tenant.name:common}") + @Mock + AuditLogger auditLogger; + + @Mock + SchemaVersionValidatorFactory schemaVersionValidatorFactory; + + @Value("${shared.tenant.name:common}") private String sharedTenant; - + @Mock IMessageBus messageBus; - private Date currDate = new Date(); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); + @Mock + SchemaMinorVersionValidator minorVersionValidator; - @Before - public void setUp() { - schemaService.setSchemaResolver(schemaResolver); - ReflectionTestUtils.setField(schemaService, "sharedTenant", "common"); - } + @Mock + SchemaPatchVersionValidator patchVersionValidator; - @Test - public void testGetSchema_EmptySchemaId() throws BadRequestException, NotFoundException, ApplicationException { - String schemaId = ""; - expectedException.expect(BadRequestException.class); - expectedException.expectMessage(SchemaConstants.EMPTY_ID); - schemaService.getSchema(schemaId); - } - - @Test - public void testGetSchema_FetchPrivateProjectTest() - throws BadRequestException, NotFoundException, ApplicationException { - String dataPartitionId = "private"; - Mockito.when(headers.getPartitionId()).thenReturn(dataPartitionId); - String schemaId = "os..wks..well.1.1"; - Mockito.when(schemaStore.getSchema(dataPartitionId, schemaId)).thenReturn("{}"); - assertNotNull(schemaService.getSchema(schemaId)); - } - - @Test - public void testGetSchema_FetchCommonProjectTest() - throws BadRequestException, NotFoundException, ApplicationException { - ReflectionTestUtils.setField(schemaService, "sharedTenant", sharedTenant); - String dataPartitionId = "private"; - Mockito.when(headers.getPartitionId()).thenReturn(dataPartitionId); - String schemaId = "os..wks..well.1.1"; - Mockito.when(schemaStore.getSchema(dataPartitionId, schemaId)).thenThrow(NotFoundException.class); - Mockito.when(schemaStore.getSchema(sharedTenant, schemaId)).thenReturn("{}"); - assertNotNull(schemaService.getSchema(schemaId)); - } - - @Test - public void testGetSchema_NotFoundException() throws BadRequestException, NotFoundException, ApplicationException { - ReflectionTestUtils.setField(schemaService, "sharedTenant", sharedTenant); - expectedException.expect(NotFoundException.class); - expectedException.expectMessage(SchemaConstants.SCHEMA_NOT_PRESENT); - String dataPartitionId = "private"; - Mockito.when(headers.getPartitionId()).thenReturn(dataPartitionId); - String schemaId = "os..wks..well.1.1"; - Mockito.when(schemaStore.getSchema(dataPartitionId, schemaId)).thenThrow(NotFoundException.class); - Mockito.when(schemaStore.getSchema(sharedTenant, schemaId)) - .thenThrow(new NotFoundException(SchemaConstants.SCHEMA_NOT_PRESENT)); - schemaService.getSchema(schemaId); - } - - @Test - public void testCreateSchema_withPrivateSchema() - throws ApplicationException, NotFoundException, BadRequestException, JsonProcessingException { - String dataPartitionId = "tenant"; - String schemaId = "os:wks:well:1.1.1"; - - SchemaRequest schReqPubInt = getMockSchemaObject_published_InternalScope(); - SchemaInfo schInfo = getMockSchemaInfo_Published_InternalScope(); - - when(schemaInfoStore.isUnique(schemaId, "common")).thenReturn(true); - when(schemaInfoStore.isUnique(schemaId, "tenant")).thenReturn(true); - when(headers.getPartitionId()).thenReturn(dataPartitionId); - Mockito.when(schemaStore.getSchema(sharedTenant, schemaId)) - .thenThrow(NotFoundException.class); - Mockito.when(schemaStore.getSchema(dataPartitionId, schemaId)).thenThrow(NotFoundException.class); - Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( - schReqPubInt.getSchemaInfo().getSchemaIdentity().getAuthority())) - .thenReturn(true); - Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( - schReqPubInt.getSchemaInfo().getSchemaIdentity().getSource())) - .thenReturn(true); - Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( - schReqPubInt.getSchemaInfo().getSchemaIdentity().getEntityType())) - .thenReturn(true); - Mockito.when(schemaResolver.resolveSchema(Mockito.anyString())).thenReturn("{}"); - Mockito.when(schemaStore.createSchema(Mockito.anyString(), Mockito.anyString())).thenReturn("{}"); - Mockito.when(schemaInfoStore.createSchemaInfo(schReqPubInt)).thenReturn(schInfo); - - assertEquals(SchemaStatus.PUBLISHED, - schemaService.createSchema(schReqPubInt).getStatus()); + private Date currDate = new Date(); + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void setUp() { + schemaService.setSchemaResolver(schemaResolver); + ReflectionTestUtils.setField(schemaService, "sharedTenant", "common"); + } + + @Test + public void testGetSchema_EmptySchemaId() throws BadRequestException, NotFoundException, ApplicationException { + String schemaId = ""; + expectedException.expect(BadRequestException.class); + expectedException.expectMessage(SchemaConstants.EMPTY_ID); + schemaService.getSchema(schemaId); + } + + @Test + public void testGetSchema_FetchPrivateProjectTest() + throws BadRequestException, NotFoundException, ApplicationException { + String dataPartitionId = "private"; + Mockito.when(headers.getPartitionId()).thenReturn(dataPartitionId); + String schemaId = "os..wks..well.1.1"; + Mockito.when(schemaStore.getSchema(dataPartitionId, schemaId)).thenReturn("{}"); + assertNotNull(schemaService.getSchema(schemaId)); + } + + @Test + public void testGetSchema_FetchCommonProjectTest() + throws BadRequestException, NotFoundException, ApplicationException { + ReflectionTestUtils.setField(schemaService, "sharedTenant", sharedTenant); + String dataPartitionId = "private"; + Mockito.when(headers.getPartitionId()).thenReturn(dataPartitionId); + String schemaId = "os..wks..well.1.1"; + Mockito.when(schemaStore.getSchema(dataPartitionId, schemaId)).thenThrow(NotFoundException.class); + Mockito.when(schemaStore.getSchema(sharedTenant, schemaId)).thenReturn("{}"); + assertNotNull(schemaService.getSchema(schemaId)); + } + + @Test + public void testGetSchema_NotFoundException() throws BadRequestException, NotFoundException, ApplicationException { + ReflectionTestUtils.setField(schemaService, "sharedTenant", sharedTenant); + expectedException.expect(NotFoundException.class); + expectedException.expectMessage(SchemaConstants.SCHEMA_NOT_PRESENT); + String dataPartitionId = "private"; + Mockito.when(headers.getPartitionId()).thenReturn(dataPartitionId); + String schemaId = "os..wks..well.1.1"; + Mockito.when(schemaStore.getSchema(dataPartitionId, schemaId)).thenThrow(NotFoundException.class); + Mockito.when(schemaStore.getSchema(sharedTenant, schemaId)) + .thenThrow(new NotFoundException(SchemaConstants.SCHEMA_NOT_PRESENT)); + schemaService.getSchema(schemaId); + } + + @Test + public void testCreateSchema_withPrivateSchema() + throws ApplicationException, NotFoundException, BadRequestException, JsonProcessingException { + String dataPartitionId = "tenant"; + String schemaId = "os:wks:well:1.1.1"; + + SchemaRequest schReqPubInt = getMockSchemaObject_published_InternalScope(); + SchemaInfo schInfo = getMockSchemaInfo_Published_InternalScope(); + + when(schemaInfoStore.isUnique(schemaId, "common")).thenReturn(true); + when(schemaInfoStore.isUnique(schemaId, "tenant")).thenReturn(true); + when(headers.getPartitionId()).thenReturn(dataPartitionId); + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + schemaInfoArr[1]=schInfo; + Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( + schReqPubInt.getSchemaInfo().getSchemaIdentity().getAuthority())) + .thenReturn(true); + Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( + schReqPubInt.getSchemaInfo().getSchemaIdentity().getSource())) + .thenReturn(true); + Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( + schReqPubInt.getSchemaInfo().getSchemaIdentity().getEntityType())) + .thenReturn(true); + Mockito.when(schemaResolver.resolveSchema(Mockito.anyString())).thenReturn("{}"); + Mockito.when(schemaStore.createSchema(Mockito.anyString(), Mockito.anyString())).thenReturn("{}"); + Mockito.when(schemaInfoStore.createSchemaInfo(schReqPubInt)).thenReturn(schInfo); + Mockito.when(schemaStore.getSchema(anyString(), anyString())).thenReturn(schReqPubInt.getSchema().toString()); + + Mockito.when(schemaUtil.findSchemaToCompare(schReqPubInt.getSchemaInfo())).thenReturn(schemaInfoArr); + Mockito.when(schemaVersionValidatorFactory.getSchemaVersionValidator(Matchers.any(SchemaVersionValidatorType.class))).thenReturn(mock(SchemaVersionValidator.class)); + assertEquals(SchemaStatus.PUBLISHED, schemaService.createSchema(schReqPubInt).getStatus()); verify(messageBus, times(1)).publishMessage( anyString(), anyString()); - } - - @Test - public void testCreateSchema_SuccessScenario() - throws ApplicationException, NotFoundException, BadRequestException, JsonProcessingException { - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - String schemaId = "os:wks:well:1.1.1"; - - SchemaRequest schReq = getMockSchemaObject_published_InternalScope(); - SchemaInfo schInfo = getMockSchemaInfo_Published_InternalScope(); - - when(schemaInfoStore.isUnique(schemaId, "common")).thenReturn(true); - when(schemaInfoStore.isUnique(schemaId, "tenant")).thenReturn(true); - Mockito.when(schemaStore.getSchema(Mockito.anyString(), Mockito.anyString())) - .thenThrow(NotFoundException.class); - Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( - schReq.getSchemaInfo().getSchemaIdentity().getAuthority())) - .thenReturn(true); - Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( - schReq.getSchemaInfo().getSchemaIdentity().getSource())) - .thenReturn(true); - Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( - schReq.getSchemaInfo().getSchemaIdentity().getEntityType())) - .thenReturn(true); - Mockito.when(schemaResolver.resolveSchema(Mockito.anyString())).thenReturn("{}"); - Mockito.when(schemaStore.createSchema(Mockito.anyString(), Mockito.anyString())).thenReturn("{}"); - Mockito.when(schemaInfoStore.createSchemaInfo(schReq)) - .thenReturn(schInfo); - assertEquals(schInfo, schemaService.createSchema(schReq)); + } + + @Test + public void testCreateSchema_SuccessScenario() + throws ApplicationException, NotFoundException, BadRequestException, JsonProcessingException { + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + String schemaId = "os:wks:well:1.1.1"; + + SchemaRequest schReq = getMockSchemaObject_published_InternalScope(); + SchemaInfo schInfo = getMockSchemaInfo_Published_InternalScope(); + + when(schemaInfoStore.isUnique(schemaId, "common")).thenReturn(true); + when(schemaInfoStore.isUnique(schemaId, "tenant")).thenReturn(true); + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + schemaInfoArr[1]=schInfo; + Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( + schReq.getSchemaInfo().getSchemaIdentity().getAuthority())) + .thenReturn(true); + Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( + schReq.getSchemaInfo().getSchemaIdentity().getSource())) + .thenReturn(true); + Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( + schReq.getSchemaInfo().getSchemaIdentity().getEntityType())) + .thenReturn(true); + Mockito.when(schemaResolver.resolveSchema(Mockito.anyString())).thenReturn("{}"); + Mockito.when(schemaStore.createSchema(Mockito.anyString(), Mockito.anyString())).thenReturn("{}"); + Mockito.when(schemaInfoStore.createSchemaInfo(schReq)) + .thenReturn(schInfo); + Mockito.when(schemaStore.getSchema(anyString(), anyString())).thenReturn(schReq.getSchema().toString()); + + Mockito.when(schemaUtil.findSchemaToCompare(schReq.getSchemaInfo())).thenReturn(schemaInfoArr); + Mockito.when(schemaVersionValidatorFactory.getSchemaVersionValidator(Matchers.any(SchemaVersionValidatorType.class))) + .thenReturn(mock(SchemaVersionValidator.class)); + assertEquals(schInfo, schemaService.createSchema(schReq)); verify(messageBus, times(1)).publishMessage( anyString(), anyString()); - } - - @Test - public void testCreateSchema_FailScenario_CleanUpScenario() - throws ApplicationException, NotFoundException, BadRequestException, JsonProcessingException { - expectedException.expect(ApplicationException.class); - - SchemaRequest schReq = getMockSchemaObject_published_InternalScope(); - - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - String schemaId = "os:wks:well:1.1.1"; - when(schemaInfoStore.isUnique(schemaId, "common")).thenReturn(true); - when(schemaInfoStore.isUnique(schemaId, "tenant")).thenReturn(true); - Mockito.when(schemaStore.getSchema(Mockito.anyString(), Mockito.anyString())) - .thenThrow(NotFoundException.class); - Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( - schReq.getSchemaInfo().getSchemaIdentity().getAuthority())) - .thenReturn(true); - Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( - schReq.getSchemaInfo().getSchemaIdentity().getSource())) - .thenReturn(true); - Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( - schReq.getSchemaInfo().getSchemaIdentity().getEntityType())) - .thenReturn(true); - Mockito.when(schemaResolver.resolveSchema(Mockito.anyString())).thenReturn("{}"); - Mockito.when(schemaStore.createSchema(Mockito.anyString(), Mockito.anyString())) - .thenThrow(ApplicationException.class); - schemaService.createSchema(schReq); + } + + @Test + public void testCreateSchema_FailScenario_CleanUpScenario() + throws ApplicationException, NotFoundException, BadRequestException, JsonProcessingException { + expectedException.expect(ApplicationException.class); + + SchemaRequest schReq = getMockSchemaObject_published_InternalScope(); + + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + String schemaId = "os:wks:well:1.1.1"; + when(schemaInfoStore.isUnique(schemaId, "common")).thenReturn(true); + when(schemaInfoStore.isUnique(schemaId, "tenant")).thenReturn(true); + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + schemaInfoArr[1]=schReq.getSchemaInfo(); + Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( + schReq.getSchemaInfo().getSchemaIdentity().getAuthority())) + .thenReturn(true); + Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( + schReq.getSchemaInfo().getSchemaIdentity().getSource())) + .thenReturn(true); + Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( + schReq.getSchemaInfo().getSchemaIdentity().getEntityType())) + .thenReturn(true); + Mockito.when(schemaResolver.resolveSchema(Mockito.anyString())).thenReturn("{}"); + Mockito.when(schemaStore.createSchema(Mockito.anyString(), Mockito.anyString())).thenThrow(ApplicationException.class); + + + Mockito.when(schemaStore.getSchema(anyString(), anyString())).thenReturn(schReq.getSchema().toString()); + + Mockito.when(schemaUtil.findSchemaToCompare(schReq.getSchemaInfo())).thenReturn(schemaInfoArr); + Mockito.when(schemaVersionValidatorFactory.getSchemaVersionValidator(Matchers.any(SchemaVersionValidatorType.class))) + .thenReturn(mock(SchemaVersionValidator.class)); + schemaService.createSchema(schReq); verify(messageBus, times(0)).publishMessage(anyString(), anyString()); - } - - @Test - public void testCreateSchema_SharedSchema() - throws JsonProcessingException, ApplicationException, BadRequestException, NotFoundException { - String dataPartitionId = "common"; - String schemaId = "os:wks:well:1.1.1"; - - SchemaRequest schReqInt = getMockSchemaObject_published_InternalScope(); - SchemaRequest schReqPub = getMockSchemaObject_published(); - SchemaInfo schInfoPub = getMockSchemaInfo_Published_SharedScope(); - - Mockito.when(headers.getPartitionId()).thenReturn(dataPartitionId); - when(schemaInfoStore.isUnique(Mockito.anyString(), Mockito.anyString())).thenReturn(true); - Mockito.when(schemaStore.getSchema(sharedTenant, schemaId)) - .thenThrow(NotFoundException.class); - Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( - schReqInt.getSchemaInfo().getSchemaIdentity().getAuthority())) - .thenReturn(true); - Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( - schReqInt.getSchemaInfo().getSchemaIdentity().getSource())) - .thenReturn(true); - Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( - schReqInt.getSchemaInfo().getSchemaIdentity().getEntityType())) - .thenReturn(true); - Mockito.when(schemaResolver.resolveSchema(Mockito.anyString())).thenReturn("{}"); - Mockito.when(schemaStore.createSchema(Mockito.anyString(), Mockito.anyString())).thenReturn("{}"); - Mockito.when(schemaInfoStore.createSchemaInfo(schReqPub)).thenReturn(schInfoPub); - assertEquals(SchemaStatus.PUBLISHED, schemaService.createSchema(schReqPub).getStatus()); + } + + @Test + public void testCreateSchema_SharedSchema() + throws JsonProcessingException, ApplicationException, BadRequestException, NotFoundException { + String dataPartitionId = "common"; + String schemaId = "os:wks:well:1.1.1"; + + SchemaRequest schReqInt = getMockSchemaObject_published_InternalScope(); + SchemaRequest schReqPub = getMockSchemaObject_published(); + SchemaInfo schInfoPub = getMockSchemaInfo_Published_SharedScope(); + + Mockito.when(headers.getPartitionId()).thenReturn(dataPartitionId); + when(schemaInfoStore.isUnique(Mockito.anyString(), Mockito.anyString())).thenReturn(true); + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + schemaInfoArr[1]=schInfoPub; + Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( + schReqInt.getSchemaInfo().getSchemaIdentity().getAuthority())) + .thenReturn(true); + Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( + schReqInt.getSchemaInfo().getSchemaIdentity().getSource())) + .thenReturn(true); + Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( + schReqInt.getSchemaInfo().getSchemaIdentity().getEntityType())) + .thenReturn(true); + Mockito.when(schemaResolver.resolveSchema(Mockito.anyString())).thenReturn("{}"); + Mockito.when(schemaStore.createSchema(Mockito.anyString(), Mockito.anyString())).thenReturn("{}"); + Mockito.when(schemaInfoStore.createSchemaInfo(schReqPub)).thenReturn(schInfoPub); + Mockito.when(schemaStore.getSchema(anyString(), anyString())).thenReturn(schReqPub.getSchema().toString()); + + Mockito.when(schemaUtil.findSchemaToCompare(schReqPub.getSchemaInfo())).thenReturn(schemaInfoArr); + Mockito.when(schemaVersionValidatorFactory.getSchemaVersionValidator(Matchers.any(SchemaVersionValidatorType.class))) + .thenReturn(mock(SchemaVersionValidator.class)); + assertEquals(SchemaStatus.PUBLISHED, schemaService.createSchema(schReqPub).getStatus()); verify(messageBus, times(1)).publishMessage( anyString(), anyString()); - } - - @Test - public void testCreateSchema_Private_SchemaAlreadyRegistered() - throws JsonProcessingException, ApplicationException, BadRequestException, NotFoundException { - expectedException.expect(BadRequestException.class); - expectedException.expectMessage(SchemaConstants.SCHEMA_ID_EXISTS); - String schemaId = getMockSchemaObject_published().getSchemaInfo().getSchemaIdentity().getId(); - String tenantId = "testing"; - Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( - getMockSchemaObject_published_InternalScope().getSchemaInfo().getSchemaIdentity().getAuthority())) - .thenReturn(true); - Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( - getMockSchemaObject_published_InternalScope().getSchemaInfo().getSchemaIdentity().getSource())) - .thenReturn(true); - Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( - getMockSchemaObject_published_InternalScope().getSchemaInfo().getSchemaIdentity().getEntityType())) - .thenReturn(true); - Mockito.when(schemaInfoStore.isUnique(schemaId, tenantId)).thenReturn(false); - schemaService.createSchema(getMockSchemaObject_published()); + } + + @Test + public void testCreateSchema_Private_SchemaAlreadyRegistered() + throws JsonProcessingException, ApplicationException, BadRequestException, NotFoundException { + expectedException.expect(BadRequestException.class); + expectedException.expectMessage(SchemaConstants.SCHEMA_ID_EXISTS); + String schemaId = getMockSchemaObject_published().getSchemaInfo().getSchemaIdentity().getId(); + String tenantId = "testing"; + Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( + getMockSchemaObject_published_InternalScope().getSchemaInfo().getSchemaIdentity().getAuthority())) + .thenReturn(true); + Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( + getMockSchemaObject_published_InternalScope().getSchemaInfo().getSchemaIdentity().getSource())) + .thenReturn(true); + Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( + getMockSchemaObject_published_InternalScope().getSchemaInfo().getSchemaIdentity().getEntityType())) + .thenReturn(true); + Mockito.when(schemaInfoStore.isUnique(schemaId, tenantId)).thenReturn(false); + schemaService.createSchema(getMockSchemaObject_published()); verify(messageBus, times(0)).publishMessage( anyString(), anyString()); - } - - @Test - public void testCreateSchema_withBreakingChanges_FoundScenario() - throws ApplicationException, NotFoundException, BadRequestException, JsonProcessingException { - expectedException.expect(BadRequestException.class); - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - Mockito.when(schemaStore.getSchema(Mockito.anyString(), Mockito.anyString())) - .thenThrow(NotFoundException.class); - ObjectMapper mapper = new ObjectMapper(); - SchemaRequest schReqBreakingChange = getMockSchemaObject_BreakingChanges(); - String inputSchema = mapper.writeValueAsString(schReqBreakingChange.getSchema()); - String latestSchema = "{\"key\":\"value\"}"; - Mockito.doThrow(BadRequestException.class).when(SchemaUtil).checkBreakingChange(inputSchema, latestSchema); - Mockito.when(schemaInfoStore.getLatestMinorVerSchema(getMockSchemaInfo_Published_InternalScope())) - .thenReturn(latestSchema); - schemaService.createSchema(schReqBreakingChange); + } + + @Test + public void testCreateSchema_withBreakingChanges_FoundScenario() + throws ApplicationException, NotFoundException, BadRequestException, IOException { + expectedException.expect(BadRequestException.class); + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + ObjectMapper mapper = new ObjectMapper(); + SchemaRequest schReqBreakingChange = getMockSchemaObject_BreakingChanges(); + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + schemaInfoArr[1]=schReqBreakingChange.getSchemaInfo(); + String inputSchema = mapper.writeValueAsString(schReqBreakingChange.getSchema()); + String latestSchema = getMockLatestSchema_BreakingChanges(); + Mockito.when(schemaStore.getSchema(anyString(), anyString())).thenReturn(latestSchema); + Mockito.when(schemaResolver.resolveSchema(Mockito.anyString())).thenReturn(inputSchema); + Mockito.when(schemaUtil.findSchemaToCompare(schReqBreakingChange.getSchemaInfo())).thenReturn(schemaInfoArr); + + Mockito.when(schemaVersionValidatorFactory.getSchemaVersionValidator(SchemaVersionValidatorType.PATCH)) + .thenReturn(patchVersionValidator); + Mockito.doThrow(SchemaVersionException.class).when(patchVersionValidator).validate(anyString(), anyString()); + Mockito.when(schemaInfoStore.getLatestMinorVerSchema(getMockSchemaInfo_Published_InternalScope())) + .thenReturn(latestSchema); + schemaService.createSchema(schReqBreakingChange); verify(messageBus, times(0)).publishMessage( anyString(), anyString()); - } - - @Test - public void testCreateSchema_withBreakingChanges_NotFoundScenario() - throws ApplicationException, NotFoundException, BadRequestException, JsonProcessingException { - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - Mockito.when(schemaStore.getSchema(Mockito.anyString(), Mockito.anyString())) - .thenThrow(NotFoundException.class); - - SchemaRequest mockSchReqPubInt = getMockSchemaObject_published_InternalScope(); - SchemaInfo mockSchInfoPubInt = getMockSchemaInfo_Published_InternalScope(); - SchemaRequest schReqBreakingChange = getMockSchemaObject_BreakingChanges(); - ObjectMapper mapper = new ObjectMapper(); - String inputSchema = mapper.writeValueAsString(schReqBreakingChange.getSchema()); - String latestSchema = "{\"key\":\"value1\"}"; - when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "common")).thenReturn(true); - when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "tenant")).thenReturn(true); - Mockito.doNothing().when(SchemaUtil).checkBreakingChange(inputSchema, latestSchema); - Mockito.when(schemaInfoStore.getLatestMinorVerSchema(mockSchInfoPubInt)) - .thenReturn(latestSchema); - Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( - mockSchReqPubInt.getSchemaInfo().getSchemaIdentity().getAuthority())) - .thenReturn(true); - Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( - mockSchReqPubInt.getSchemaInfo().getSchemaIdentity().getSource())) - .thenReturn(true); - Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( - mockSchReqPubInt.getSchemaInfo().getSchemaIdentity().getEntityType())) - .thenReturn(true); - Mockito.when(schemaResolver.resolveSchema(Mockito.anyString())).thenReturn(latestSchema); - Mockito.when(schemaStore.createSchema(Mockito.anyString(), Mockito.anyString())).thenReturn(latestSchema); - Mockito.when(schemaInfoStore.createSchemaInfo(mockSchReqPubInt)) - .thenReturn(mockSchInfoPubInt); - assertEquals(mockSchInfoPubInt, schemaService.createSchema(mockSchReqPubInt)); + } + + @Test + public void testCreateSchema_withBreakingChanges_NotFoundScenario() + throws ApplicationException, NotFoundException, BadRequestException, IOException { + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + SchemaRequest mockSchReqPubInt = getMockSchemaObject_published_InternalScope(); + SchemaInfo mockSchInfoPubInt = getMockSchemaInfo_Published_InternalScope(); + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + schemaInfoArr[1]=mockSchInfoPubInt; + SchemaRequest schReqBreakingChange = getMockSchemaObject_BreakingChanges(); + ObjectMapper mapper = new ObjectMapper(); + String inputSchema = mapper.writeValueAsString(schReqBreakingChange.getSchema()); + String latestSchema = "{\"key\":\"value1\"}"; + when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "common")).thenReturn(true); + when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "tenant")).thenReturn(true); + Mockito.when(schemaInfoStore.getLatestMinorVerSchema(mockSchInfoPubInt)) + .thenReturn(latestSchema); + Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( + mockSchReqPubInt.getSchemaInfo().getSchemaIdentity().getAuthority())) + .thenReturn(true); + Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( + mockSchReqPubInt.getSchemaInfo().getSchemaIdentity().getSource())) + .thenReturn(true); + Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( + mockSchReqPubInt.getSchemaInfo().getSchemaIdentity().getEntityType())) + .thenReturn(true); + Mockito.when(schemaStore.getSchema(anyString(), anyString())).thenReturn(latestSchema); + Mockito.when(schemaResolver.resolveSchema(Mockito.anyString())).thenReturn(inputSchema); + Mockito.when(schemaStore.createSchema(Mockito.anyString(), Mockito.anyString())).thenReturn(latestSchema); + Mockito.when(schemaInfoStore.createSchemaInfo(mockSchReqPubInt)) + .thenReturn(mockSchInfoPubInt); + Mockito.when(schemaUtil.findSchemaToCompare(mockSchReqPubInt.getSchemaInfo())).thenReturn(schemaInfoArr); + Mockito.when(schemaVersionValidatorFactory.getSchemaVersionValidator(Matchers.any(SchemaVersionValidatorType.class))).thenReturn(mock(SchemaVersionValidator.class)); + assertEquals(mockSchInfoPubInt, schemaService.createSchema(mockSchReqPubInt)); + verify(messageBus, times(1)).publishMessage(anyString(), anyString()); - } - - @Test - public void testCreateSchema_ApplicationException_Entity_PrivateSchema() - throws JsonProcessingException, ApplicationException, BadRequestException, NotFoundException { - expectedException.expect(ApplicationException.class); - expectedException.expectMessage("Internal server error"); - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "common")).thenReturn(true); - when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "tenant")).thenReturn(true); - SchemaRequest schReqPub = getMockSchemaObject_published(); - - Mockito.when(schemaStore.getSchema(Mockito.anyString(), Mockito.anyString())) - .thenThrow(NotFoundException.class); - Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getAuthority())).thenReturn(true); - Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getSource())).thenReturn(true); - Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getEntityType())).thenReturn(false); - schemaService.createSchema(schReqPub); + } + + @Test + public void testCreateSchema_ApplicationException_Entity_PrivateSchema() + throws JsonProcessingException, ApplicationException, BadRequestException, NotFoundException { + expectedException.expect(ApplicationException.class); + expectedException.expectMessage("Internal server error"); + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "common")).thenReturn(true); + when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "tenant")).thenReturn(true); + SchemaRequest schReqPub = getMockSchemaObject_published(); + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + schemaInfoArr[1]=schReqPub.getSchemaInfo(); + Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getAuthority())).thenReturn(true); + Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getSource())).thenReturn(true); + Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getEntityType())).thenReturn(false); + Mockito.when(schemaInfoStore.createSchemaInfo(schReqPub)).thenReturn(schReqPub.getSchemaInfo()); + Mockito.when(schemaStore.getSchema(anyString(), anyString())).thenReturn(""); + Mockito.when(schemaUtil.findSchemaToCompare(schReqPub.getSchemaInfo())).thenReturn(schemaInfoArr); + Mockito.when(schemaVersionValidatorFactory.getSchemaVersionValidator(Matchers.any(SchemaVersionValidatorType.class))) + .thenReturn(mock(SchemaVersionValidator.class)); + schemaService.createSchema(schReqPub); verify(messageBus, times(0)).publishMessage( anyString(), anyString()); - } - - @Test - public void testCreateSchema_ApplicationException_Authority_PrivateSchema() - throws NotFoundException, BadRequestException, ApplicationException, JsonProcessingException { - expectedException.expect(ApplicationException.class); - expectedException.expectMessage(SchemaConstants.INTERNAL_SERVER_ERROR); - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "common")).thenReturn(true); - when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "tenant")).thenReturn(true); - SchemaRequest schReqPub = getMockSchemaObject_published(); - Mockito.when(schemaStore.getSchema(Mockito.anyString(), Mockito.anyString())) - .thenThrow(NotFoundException.class); - Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getAuthority())).thenReturn(false); - Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getSource())).thenReturn(true); - Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getEntityType())).thenReturn(true); - schemaService.createSchema(schReqPub); + } + + @Test + public void testCreateSchema_ApplicationException_Authority_PrivateSchema() + throws NotFoundException, BadRequestException, ApplicationException, JsonProcessingException { + expectedException.expect(ApplicationException.class); + expectedException.expectMessage(SchemaConstants.INTERNAL_SERVER_ERROR); + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "common")).thenReturn(true); + when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "tenant")).thenReturn(true); + SchemaRequest schReqPub = getMockSchemaObject_published(); + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + schemaInfoArr[1]=schReqPub.getSchemaInfo(); + Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getAuthority())).thenReturn(false); + Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getSource())).thenReturn(true); + Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getEntityType())).thenReturn(true); + Mockito.when(schemaStore.getSchema(anyString(), anyString())).thenReturn(""); + Mockito.when(schemaUtil.findSchemaToCompare(schReqPub.getSchemaInfo())).thenReturn(schemaInfoArr); + Mockito.when(schemaVersionValidatorFactory.getSchemaVersionValidator(Matchers.any(SchemaVersionValidatorType.class))) + .thenReturn(mock(SchemaVersionValidator.class)); + schemaService.createSchema(schReqPub); verify(messageBus, times(0)).publishMessage( anyString(), anyString()); - } - - @Test - public void testCreateSchema_ApplicationException_Source_PrivateSchema() - throws JsonProcessingException, ApplicationException, BadRequestException, NotFoundException { - expectedException.expect(ApplicationException.class); - expectedException.expectMessage("Internal server error"); - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "common")).thenReturn(true); - when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "tenant")).thenReturn(true); - Mockito.when(schemaStore.getSchema(Mockito.anyString(), Mockito.anyString())) - .thenThrow(NotFoundException.class); - SchemaRequest schReqPub = getMockSchemaObject_published(); - Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getAuthority())).thenReturn(true); - Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getSource())).thenReturn(false); - Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getEntityType())).thenReturn(true); - schemaService.createSchema(schReqPub); + } + + @Test + public void testCreateSchema_ApplicationException_Source_PrivateSchema() + throws JsonProcessingException, ApplicationException, BadRequestException, NotFoundException { + expectedException.expect(ApplicationException.class); + expectedException.expectMessage("Internal server error"); + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "common")).thenReturn(true); + when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "tenant")).thenReturn(true); + SchemaRequest schReqPub = getMockSchemaObject_published(); + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + schemaInfoArr[1]=schReqPub.getSchemaInfo(); + Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getAuthority())).thenReturn(true); + Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getSource())).thenReturn(false); + Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getEntityType())).thenReturn(true); + Mockito.when(schemaStore.getSchema(anyString(), anyString())).thenReturn(""); + Mockito.when(schemaUtil.findSchemaToCompare(schReqPub.getSchemaInfo())).thenReturn(schemaInfoArr); + Mockito.when(schemaVersionValidatorFactory.getSchemaVersionValidator(Matchers.any(SchemaVersionValidatorType.class))) + .thenReturn(mock(SchemaVersionValidator.class)); + schemaService.createSchema(schReqPub); verify(messageBus, times(0)).publishMessage( anyString(), anyString()); - } - - @Test - public void testCreateSchema_schemaExists() - throws ApplicationException, NotFoundException, BadRequestException, JsonProcessingException { - expectedException.expect(BadRequestException.class); - expectedException.expectMessage(SchemaConstants.SCHEMA_ID_EXISTS); - String dataPartitionId = "common"; - String schemaId = "os:wks:well:1.1.1"; - Mockito.when(headers.getPartitionId()).thenReturn(dataPartitionId); - when(schemaInfoStore.isUnique(schemaId, "common")).thenReturn(false); - when(schemaInfoStore.isUnique(schemaId, "tenant")).thenReturn(false); - schemaService.createSchema(getMockSchemaObject_published()); + } + + @Test + public void testCreateSchema_schemaExists() + throws ApplicationException, NotFoundException, BadRequestException, JsonProcessingException { + expectedException.expect(BadRequestException.class); + expectedException.expectMessage(SchemaConstants.SCHEMA_ID_EXISTS); + String dataPartitionId = "common"; + String schemaId = "os:wks:well:1.1.1"; + Mockito.when(headers.getPartitionId()).thenReturn(dataPartitionId); + when(schemaInfoStore.isUnique(schemaId, "common")).thenReturn(false); + when(schemaInfoStore.isUnique(schemaId, "tenant")).thenReturn(false); + schemaService.createSchema(getMockSchemaObject_published()); verify(messageBus, times(0)).publishMessage( anyString(), anyString()); - } - - @Test - public void testUpdateSchema_WithPublishedState() { - try { - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - SchemaRequest schReqPub = getMockSchemaObject_published(); - - Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getAuthority())) - .thenReturn(true); - Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getSource())).thenReturn(true); - Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getEntityType())) - .thenReturn(true); - Mockito.when(schemaInfoStore.getSchemaInfo("os:wks:well:1.1.1")).thenReturn(getMockSchemaInfo()); - schemaService.updateSchema(schReqPub); - fail("Should not succeed"); - - } catch (BadRequestException e) { + } + + @Test + public void testUpdateSchema_WithPublishedState() { + try { + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + SchemaRequest schReqPub = getMockSchemaObject_published(); + + Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getAuthority())) + .thenReturn(true); + Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getSource())).thenReturn(true); + Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getEntityType())) + .thenReturn(true); + Mockito.when(schemaInfoStore.getSchemaInfo("os:wks:well:1.1.1")).thenReturn(getMockSchemaInfo()); + schemaService.updateSchema(schReqPub); + fail("Should not succeed"); + + } catch (BadRequestException e) { verify(messageBus, times(0)).publishMessage( anyString(), anyString()); - assertEquals(SchemaConstants.SCHEMA_UPDATE_EXCEPTION, e.getMessage()); - } catch (Exception e) { - fail("Should not get different exception"); - } - } - - @Test - public void testUpdateSchema_NotFoundException_Published() throws NotFoundException, ApplicationException { - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "common")).thenReturn(true); - when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "tenant")).thenReturn(true); - SchemaRequest schReqPub = getMockSchemaObject_published(); - Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getAuthority())).thenReturn(true); - Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getSource())).thenReturn(true); - Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getEntityType())).thenReturn(true); - Mockito.when(schemaInfoStore.getSchemaInfo("os:wks:well:1.1.1")).thenThrow(NotFoundException.class); - try { - schemaService.updateSchema(schReqPub); - fail("Should not succeed"); - - } catch (BadRequestException e) { + assertEquals(SchemaConstants.SCHEMA_UPDATE_EXCEPTION, e.getMessage()); + } catch (Exception e) { + fail("Should not get different exception"); + } + } + + @Test + public void testUpdateSchema_NotFoundException_Published() throws NotFoundException, ApplicationException { + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "common")).thenReturn(true); + when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "tenant")).thenReturn(true); + SchemaRequest schReqPub = getMockSchemaObject_published(); + Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getAuthority())).thenReturn(true); + Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getSource())).thenReturn(true); + Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getEntityType())).thenReturn(true); + Mockito.when(schemaInfoStore.getSchemaInfo("os:wks:well:1.1.1")).thenThrow(NotFoundException.class); + try { + schemaService.updateSchema(schReqPub); + fail("Should not succeed"); + + } catch (BadRequestException e) { verify(messageBus, times(0)).publishMessage( anyString(), anyString()); - assertEquals(SchemaConstants.SCHEMA_PUT_CREATE_EXCEPTION, e.getMessage()); - } catch (Exception e) { - fail("Should not get different exception"); - } - } - - @Test - public void testUpdateSchema_NotFoundException_Development() throws NotFoundException, ApplicationException { - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "common")).thenReturn(true); - when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "tenant")).thenReturn(true); - SchemaRequest schReqPub = getMockSchemaObject_published(); - Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getAuthority())).thenReturn(true); - Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getSource())).thenReturn(true); - Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getEntityType())).thenReturn(true); - Mockito.when(schemaInfoStore.getSchemaInfo("os:wks:well:1.1.1")).thenThrow(NotFoundException.class); - try { - schemaService.updateSchema(getMockSchemaObject_Development()); - fail("Should not succeed"); - - } catch (NoSchemaFoundException e) { + assertEquals(SchemaConstants.SCHEMA_PUT_CREATE_EXCEPTION, e.getMessage()); + } catch (Exception e) { + fail("Should not get different exception"); + } + } + + @Test + public void testUpdateSchema_NotFoundException_Development() throws NotFoundException, ApplicationException { + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "common")).thenReturn(true); + when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "tenant")).thenReturn(true); + SchemaRequest schReqPub = getMockSchemaObject_published(); + Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getAuthority())).thenReturn(true); + Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getSource())).thenReturn(true); + Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getEntityType())).thenReturn(true); + Mockito.when(schemaInfoStore.getSchemaInfo("os:wks:well:1.1.1")).thenThrow(NotFoundException.class); + try { + schemaService.updateSchema(getMockSchemaObject_Development()); + fail("Should not succeed"); + + } catch (NoSchemaFoundException e) { verify(messageBus, times(0)).publishMessage( anyString(), anyString()); - assertEquals(SchemaConstants.INVALID_SCHEMA_UPDATE, e.getMessage()); - } catch (Exception e) { - fail("Should not get different exception"); - } - } - - @Test - public void testUpdateSchema_withUnregisteredSchema() { - try { - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "common")).thenReturn(true); - when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "tenant")).thenReturn(true); - SchemaRequest schReqPub = getMockSchemaObject_published(); - Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getAuthority())) - .thenReturn(true); - Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getSource())).thenReturn(true); - Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( - schReqPub.getSchemaInfo().getSchemaIdentity().getEntityType())) - .thenReturn(true); - Mockito.when(schemaInfoStore.getSchemaInfo("os:wks:well:1.1.1")).thenThrow(NotFoundException.class); - schemaService.updateSchema(schReqPub); - fail("Should not succeed"); - - } catch (BadRequestException e) { + assertEquals(SchemaConstants.INVALID_SCHEMA_UPDATE, e.getMessage()); + } catch (Exception e) { + fail("Should not get different exception"); + } + } + + @Test + public void testUpdateSchema_withUnregisteredSchema() { + try { + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "common")).thenReturn(true); + when(schemaInfoStore.isUnique("os:wks:well:1.1.1", "tenant")).thenReturn(true); + SchemaRequest schReqPub = getMockSchemaObject_published(); + Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getAuthority())) + .thenReturn(true); + Mockito.when(sourceService.checkAndRegisterSourceIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getSource())).thenReturn(true); + Mockito.when(entityTypeService.checkAndRegisterEntityTypeIfNotPresent( + schReqPub.getSchemaInfo().getSchemaIdentity().getEntityType())) + .thenReturn(true); + Mockito.when(schemaInfoStore.getSchemaInfo("os:wks:well:1.1.1")).thenThrow(NotFoundException.class); + schemaService.updateSchema(schReqPub); + fail("Should not succeed"); + + } catch (BadRequestException e) { verify(messageBus, times(0)).publishMessage( anyString(), anyString()); - assertEquals(SchemaConstants.SCHEMA_PUT_CREATE_EXCEPTION, e.getMessage()); - } catch (Exception e) { - fail("Should not get different exception"); - } - } - - @Test - public void testUpdateSchema_DevelopmentState() throws ApplicationException, NotFoundException, BadRequestException, - JSONException, JsonProcessingException { - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - Mockito.when(schemaInfoStore.getSchemaInfo("os:wks:well:1.1.1")) - .thenReturn(getMockSchemaInfo_development_status()); - Mockito.when(schemaInfoStore.updateSchemaInfo(getMockSchemaObject_Development())) - .thenReturn(getMockSchemaInfo_development_status()); - assertNotNull(schemaService.updateSchema(getMockSchemaObject_Development())); + assertEquals(SchemaConstants.SCHEMA_PUT_CREATE_EXCEPTION, e.getMessage()); + } catch (Exception e) { + fail("Should not get different exception"); + } + } + + @Test + public void testUpdateSchema_DevelopmentState() throws ApplicationException, NotFoundException, BadRequestException, + JSONException, JsonProcessingException { + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + SchemaInfo input = getMockSchemaInfo_development_status(); + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + schemaInfoArr[1]=input; + Mockito.when(schemaInfoStore.getSchemaInfo("os:wks:well:1.1.1")).thenReturn(input); + Mockito.when(schemaInfoStore.updateSchemaInfo(getMockSchemaObject_Development())).thenReturn(input); + + Mockito.when(schemaStore.getSchema(anyString(), anyString())).thenReturn(""); + Mockito.when(schemaUtil.findSchemaToCompare(input)).thenReturn(schemaInfoArr); + Mockito.when(schemaVersionValidatorFactory.getSchemaVersionValidator(Matchers.any(SchemaVersionValidatorType.class))) + .thenReturn(mock(SchemaVersionValidator.class)); + assertNotNull(schemaService.updateSchema(getMockSchemaObject_Development())); verify(messageBus, times(1)).publishMessage( anyString(), anyString()); - } - - @Test - public void testGetSchemaInfoList() throws ApplicationException, NotFoundException, BadRequestException { - List schemaInfos = new LinkedList(); - schemaInfos.add(getMockSchemaInfo()); - QueryParams queryParams = QueryParams.builder().authority("test").limit(10).build(); - Mockito.when(headers.getPartitionId()).thenReturn("test"); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "test")).thenReturn(schemaInfos); - Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); - } - - @Test - public void testGetSchemaInfoList_SharedScope() - throws ApplicationException, NotFoundException, BadRequestException { - List schemaInfos = new LinkedList(); - schemaInfos.add(getMockSchemaInfo()); - QueryParams queryParams = QueryParams.builder().scope("SHARED").authority("test").limit(10).build(); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaInfos); - Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); - } - - @Test - public void testGetSchemaInfoList_InvalidScope() - throws ApplicationException, NotFoundException, BadRequestException { - List schemaInfos = new LinkedList(); - schemaInfos.add(getMockSchemaInfo()); - QueryParams queryParams = QueryParams.builder().scope("random").authority("test").limit(10).build(); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaInfos); - Assert.assertEquals(0, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); - } - - @Test - public void testGetSchemaInfoList_PrivateScope() - throws ApplicationException, NotFoundException, BadRequestException { - List schemaInfos = new LinkedList(); - schemaInfos.add(getMockSchemaInfo()); - QueryParams queryParams = QueryParams.builder().scope("INTERNAL").authority("test").limit(10).build(); - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); - Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); - } - - @Test - public void testGetSchemaInfoList_LatestVersion_MajorMinorConflict_NoLatestVersion() - throws ApplicationException, NotFoundException, BadRequestException { - - List schemaInt = new LinkedList(); - List schemaPub = new LinkedList(); - List schemaComb = new LinkedList(); - - schemaInt.add(getMockSchemaInfo_Published_InternalScope()); - schemaPub.add(getMockSchemaInfo()); - schemaComb.addAll(schemaPub); - schemaComb.addAll(schemaInt); - - QueryParams queryParams = QueryParams.builder().authority("test").latestVersion(true).limit(10).build(); - - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaPub); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInt); - - Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); - } - - @Test - public void testGetSchemaInfoList_MatchingVersion_MajorGiven() - throws ApplicationException, NotFoundException, BadRequestException { - List schemaInfos = new LinkedList(); - QueryParams queryParams = QueryParams.builder().authority("test").schemaVersionMajor(1L).limit(10).build(); - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - schemaInfos.add(getMockSchemaInfo()); - schemaInfos.add(getMockSchemaInfo()); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); - Assert.assertEquals(2, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); - } - - @Test - public void testGetSchemaInfoList_MatchingVersion_MinorGiven() - throws ApplicationException, NotFoundException, BadRequestException { - List schemaInfos = new LinkedList(); - QueryParams queryParams = QueryParams.builder().authority("test").schemaVersionMinor(1L).limit(10).build(); - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - schemaInfos.add(getMockSchemaInfo()); - schemaInfos.add(getMockSchemaInfo()); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); - Assert.assertEquals(2, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); - } - - @Test - public void testGetSchemaInfoList_MatchingVersion_MajorMinorGiven() - throws ApplicationException, NotFoundException, BadRequestException { - List schemaInfos = new LinkedList(); - QueryParams queryParams = QueryParams.builder().authority("test").schemaVersionMajor(1L).schemaVersionMinor(1L) - .limit(10).build(); - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - schemaInfos.add(getMockSchemaInfo()); - schemaInfos.add(getMockSchemaInfo()); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); - Assert.assertEquals(2, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); - } - - @Test - public void testGetSchemaInfoList_MatchingVersion_PatchGiven() - throws ApplicationException, NotFoundException, BadRequestException { - List schemaInfos = new LinkedList(); - QueryParams queryParams = QueryParams.builder().authority("test").schemaVersionMinor(1L).limit(10).build(); - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - schemaInfos.add(getMockSchemaInfo()); - schemaInfos.add(getMockSchemaInfo()); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); - Assert.assertEquals(2, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); - } - - @Test - public void testGetSchemaInfoList_LatestVersion_MajorMinorConflict_MajorVersionWithoutMinorAndPatch() - throws ApplicationException, NotFoundException, BadRequestException { - QueryParams queryParams = QueryParams.builder().authority("os").latestVersion(true).schemaVersionMajor(1l) - .limit(10).build(); - - List schemaInt = new LinkedList(); - List schemaPub = new LinkedList(); - List schemaComb = new LinkedList(); - - schemaInt.add(getMockSchemaInfo_Published_InternalScope()); - schemaPub.add(getMockSchemaInfo()); - schemaComb.addAll(schemaPub); - schemaComb.addAll(schemaInt); - - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaPub); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInt); - - Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); - } - - @Test - public void testGetSchemaInfoList_LatestVersion_MajorMinorConflict_MinorVersionWithoutMajor() - throws ApplicationException, NotFoundException, BadRequestException { - QueryParams queryParams = QueryParams.builder().latestVersion(true).schemaVersionMinor(1l).limit(10).build(); - expectedException.expect(BadRequestException.class); - expectedException.expectMessage(SchemaConstants.LATESTVERSION_MINORFILTER_WITHOUT_MAJOR); - schemaService.getSchemaInfoList(queryParams); - } - - @Test - public void testGetSchemaInfoList_LatestVersion_MajorMinorPatch_NoLatestVersion() - throws ApplicationException, NotFoundException, BadRequestException { - List schemaInfos = new LinkedList(); - QueryParams queryParams = QueryParams.builder().authority("test").latestVersion(true).schemaVersionMajor(1L) - .schemaVersionMinor(1L).limit(10).build(); - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); - Assert.assertEquals(0, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); - } - - @Test - public void testGetSchemaInfoList_LatestVersion_WithoutScope() - throws ApplicationException, NotFoundException, BadRequestException { - - List schemaInt = new LinkedList(); - List schemaPub = new LinkedList(); - List schemaComb = new LinkedList(); - + } + + @Test + public void testGetSchemaInfoList() throws ApplicationException, NotFoundException, BadRequestException { + List schemaInfos = new LinkedList(); + schemaInfos.add(getMockSchemaInfo()); + QueryParams queryParams = QueryParams.builder().authority("test").limit(10).build(); + Mockito.when(headers.getPartitionId()).thenReturn("test"); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "test")).thenReturn(schemaInfos); + Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); + } + + @Test + public void testGetSchemaInfoList_SharedScope() + throws ApplicationException, NotFoundException, BadRequestException { + List schemaInfos = new LinkedList(); + schemaInfos.add(getMockSchemaInfo()); + QueryParams queryParams = QueryParams.builder().scope("SHARED").authority("test").limit(10).build(); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaInfos); + Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); + } + + @Test + public void testGetSchemaInfoList_InvalidScope() + throws ApplicationException, NotFoundException, BadRequestException { + List schemaInfos = new LinkedList(); + schemaInfos.add(getMockSchemaInfo()); + QueryParams queryParams = QueryParams.builder().scope("random").authority("test").limit(10).build(); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaInfos); + Assert.assertEquals(0, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); + } + + @Test + public void testGetSchemaInfoList_PrivateScope() + throws ApplicationException, NotFoundException, BadRequestException { + List schemaInfos = new LinkedList(); + schemaInfos.add(getMockSchemaInfo()); + QueryParams queryParams = QueryParams.builder().scope("INTERNAL").authority("test").limit(10).build(); + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); + Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); + } + + @Test + public void testGetSchemaInfoList_LatestVersion_MajorMinorConflict_NoLatestVersion() + throws ApplicationException, NotFoundException, BadRequestException { + + List schemaInt = new LinkedList(); + List schemaPub = new LinkedList(); + List schemaComb = new LinkedList(); + schemaInt.add(getMockSchemaInfo_Published_InternalScope()); - schemaPub.add(getMockSchemaInfo()); - schemaComb.addAll(schemaPub); - schemaComb.addAll(schemaInt); - - QueryParams queryParams = QueryParams.builder().latestVersion(true).limit(10).build(); - - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaPub); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInt); - - Assert.assertEquals(1, schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size()); - } - - @Test - public void testGetSchemaInfoList_LatestVersion_WithoutScope_ForOneAuthority() - throws ApplicationException, NotFoundException, BadRequestException { - List schemaInt = new LinkedList(); - List schemaPub = new LinkedList(); - List schemaComb = new LinkedList(); - + schemaPub.add(getMockSchemaInfo()); + schemaComb.addAll(schemaPub); + schemaComb.addAll(schemaInt); + + QueryParams queryParams = QueryParams.builder().authority("test").latestVersion(true).limit(10).build(); + + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaPub); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInt); + + Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); + } + + @Test + public void testGetSchemaInfoList_MatchingVersion_MajorGiven() + throws ApplicationException, NotFoundException, BadRequestException { + List schemaInfos = new LinkedList(); + QueryParams queryParams = QueryParams.builder().authority("test").schemaVersionMajor(1L).limit(10).build(); + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + schemaInfos.add(getMockSchemaInfo()); + schemaInfos.add(getMockSchemaInfo()); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); + Assert.assertEquals(2, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); + } + + @Test + public void testGetSchemaInfoList_MatchingVersion_MinorGiven() + throws ApplicationException, NotFoundException, BadRequestException { + List schemaInfos = new LinkedList(); + QueryParams queryParams = QueryParams.builder().authority("test").schemaVersionMinor(1L).limit(10).build(); + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + schemaInfos.add(getMockSchemaInfo()); + schemaInfos.add(getMockSchemaInfo()); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); + Assert.assertEquals(2, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); + } + + @Test + public void testGetSchemaInfoList_MatchingVersion_MajorMinorGiven() + throws ApplicationException, NotFoundException, BadRequestException { + List schemaInfos = new LinkedList(); + QueryParams queryParams = QueryParams.builder().authority("test").schemaVersionMajor(1L).schemaVersionMinor(1L) + .limit(10).build(); + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + schemaInfos.add(getMockSchemaInfo()); + schemaInfos.add(getMockSchemaInfo()); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); + Assert.assertEquals(2, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); + } + + @Test + public void testGetSchemaInfoList_MatchingVersion_PatchGiven() + throws ApplicationException, NotFoundException, BadRequestException { + List schemaInfos = new LinkedList(); + QueryParams queryParams = QueryParams.builder().authority("test").schemaVersionMinor(1L).limit(10).build(); + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + schemaInfos.add(getMockSchemaInfo()); + schemaInfos.add(getMockSchemaInfo()); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); + Assert.assertEquals(2, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); + } + + @Test + public void testGetSchemaInfoList_LatestVersion_MajorMinorConflict_MajorVersionWithoutMinorAndPatch() + throws ApplicationException, NotFoundException, BadRequestException { + QueryParams queryParams = QueryParams.builder().authority("os").latestVersion(true).schemaVersionMajor(1l) + .limit(10).build(); + + List schemaInt = new LinkedList(); + List schemaPub = new LinkedList(); + List schemaComb = new LinkedList(); + schemaInt.add(getMockSchemaInfo_Published_InternalScope()); - schemaPub.add(getMockSchemaInfo()); - schemaComb.addAll(schemaPub); - schemaComb.addAll(schemaInt); - - QueryParams queryParams = QueryParams.builder().authority("os").latestVersion(true).limit(10).build(); - - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaPub); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInt); - - Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); - } - - @Test - public void testGetSchemaInfoList_LatestVersion_WithScopeInternal_WithoutAuthority() - throws ApplicationException, NotFoundException, BadRequestException { - List schemaInfos = new LinkedList(); - QueryParams queryParams = QueryParams.builder().latestVersion(true).scope("INTERNAL").limit(10).build(); - - schemaInfos.add(getMockSchemaInfo_INTERNAL_EntityWellBore()); - schemaInfos.add(getMockSchemaInfo_Published_InternalScope()); - - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos.subList(0, 1)); - - Assert.assertTrue(schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size() > 0); - - for(SchemaInfo outputSchemaInfo : schemaService.getSchemaInfoList(queryParams).getSchemaInfos()) { - Assert.assertTrue("INTERNAL".equals(outputSchemaInfo.getScope().toString())); - } - - } - - @Test - public void testGetSchemaInfoList_LatestVersion_WithScopeInternal_WithOneAuthority() - throws ApplicationException, NotFoundException, BadRequestException { - List schemaInfos = new LinkedList(); - QueryParams queryParams = QueryParams.builder().authority("os").latestVersion(true).scope("INTERNAL").limit(10).build(); - schemaInfos.add(getMockSchemaInfo_Published_InternalScope()); - - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); - - Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); - Assert.assertTrue("INTERNAL".equals(schemaService.getSchemaInfoList(queryParams).getSchemaInfos().get(0).getScope().toString())); - } - - @Test - public void testGetSchemaInfoList_LatestVersion_WithScopeShared_WithoutAuthority() - throws ApplicationException, NotFoundException, BadRequestException { - List schemaInfos = new LinkedList(); - QueryParams queryParams = QueryParams.builder().latestVersion(true).scope("SHARED").limit(10).build(); - schemaInfos.add(getMockSchemaInfo_Published_SharedScope()); - schemaInfos.add(getMockSchemaInfo_SHARED_EntityWellBore()); - - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaInfos); - - List finalList = schemaService.getSchemaInfoList(queryParams).getSchemaInfos(); - - Assert.assertTrue(finalList.size() == 2); - - for(SchemaInfo outputSchemaInfo : finalList) { - Assert.assertTrue("SHARED".equals(outputSchemaInfo.getScope().toString())); - } - - } - - @Test - public void testGetSchemaInfoList_LatestVersion_WithScopeShared_WithOneAuthority() - throws ApplicationException, NotFoundException, BadRequestException { - - List schemaInfos = new LinkedList(); - QueryParams queryParams = QueryParams.builder().authority("os").latestVersion(true).scope("SHARED").limit(10).build(); - schemaInfos.add(getMockSchemaInfo_Published_SharedScope()); - - Mockito.when(headers.getPartitionId()).thenReturn("tenant"); - Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaInfos); - - Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); - Assert.assertTrue("SHARED".equals(schemaService.getSchemaInfoList(queryParams).getSchemaInfos().get(0).getScope().toString())); - Assert.assertTrue("os".equals(schemaService.getSchemaInfoList(queryParams).getSchemaInfos().get(0).getSchemaIdentity().getAuthority())); - - - } - - @Test - public void testGetSchemaInfoList_LatestVersion_MajorMinorPatchConflict_PatchVersionWithoutMinor() - throws ApplicationException, NotFoundException, BadRequestException { - QueryParams queryParams = QueryParams.builder().authority("test").latestVersion(true).schemaVersionMajor(1L) - .schemaVersionPatch(1L).limit(10).build(); - expectedException.expect(BadRequestException.class); - expectedException.expectMessage(SchemaConstants.LATESTVERSION_PATCHFILTER_WITHOUT_MINOR); - schemaService.getSchemaInfoList(queryParams); - } - - @Test - public void testGetSchemaInfoList_LatestVersion_MajorMinorConflict_PatchVersionWithoutMajor() - throws ApplicationException, NotFoundException, BadRequestException { - QueryParams queryParams = QueryParams.builder().latestVersion(true).schemaVersionMinor(1l) - .schemaVersionPatch(1L).limit(10).build(); - expectedException.expect(BadRequestException.class); - expectedException.expectMessage(SchemaConstants.LATESTVERSION_MINORFILTER_WITHOUT_MAJOR); - schemaService.getSchemaInfoList(queryParams); - } - - @Test - public void testUpsertSchema_SuccessfullUpdate() + schemaPub.add(getMockSchemaInfo()); + schemaComb.addAll(schemaPub); + schemaComb.addAll(schemaInt); + + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaPub); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInt); + + Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); + } + + @Test + public void testGetSchemaInfoList_LatestVersion_MajorMinorConflict_MinorVersionWithoutMajor() + throws ApplicationException, NotFoundException, BadRequestException { + QueryParams queryParams = QueryParams.builder().latestVersion(true).schemaVersionMinor(1l).limit(10).build(); + expectedException.expect(BadRequestException.class); + expectedException.expectMessage(SchemaConstants.LATESTVERSION_MINORFILTER_WITHOUT_MAJOR); + schemaService.getSchemaInfoList(queryParams); + } + + @Test + public void testGetSchemaInfoList_LatestVersion_MajorMinorPatch_NoLatestVersion() + throws ApplicationException, NotFoundException, BadRequestException { + List schemaInfos = new LinkedList(); + QueryParams queryParams = QueryParams.builder().authority("test").latestVersion(true).schemaVersionMajor(1L) + .schemaVersionMinor(1L).limit(10).build(); + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); + Assert.assertEquals(0, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); + } + + @Test + public void testGetSchemaInfoList_LatestVersion_WithoutScope() throws ApplicationException, NotFoundException, BadRequestException { + List schemaInt = new LinkedList(); + List schemaPub = new LinkedList(); + List schemaComb = new LinkedList(); + + schemaInt.add(getMockSchemaInfo_Published_InternalScope()); + schemaPub.add(getMockSchemaInfo()); + schemaComb.addAll(schemaPub); + schemaComb.addAll(schemaInt); + + QueryParams queryParams = QueryParams.builder().latestVersion(true).limit(10).build(); + + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaPub); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInt); + + Assert.assertEquals(1, schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size()); + } + + @Test + public void testGetSchemaInfoList_LatestVersion_WithoutScope_ForOneAuthority() + throws ApplicationException, NotFoundException, BadRequestException { + List schemaInt = new LinkedList(); + List schemaPub = new LinkedList(); + List schemaComb = new LinkedList(); + + schemaInt.add(getMockSchemaInfo_Published_InternalScope()); + schemaPub.add(getMockSchemaInfo()); + schemaComb.addAll(schemaPub); + schemaComb.addAll(schemaInt); + + QueryParams queryParams = QueryParams.builder().authority("os").latestVersion(true).limit(10).build(); + + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaPub); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInt); + + Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); + } + + @Test + public void testGetSchemaInfoList_LatestVersion_WithScopeInternal_WithoutAuthority() + throws ApplicationException, NotFoundException, BadRequestException { + List schemaInfos = new LinkedList(); + QueryParams queryParams = QueryParams.builder().latestVersion(true).scope("INTERNAL").limit(10).build(); + + schemaInfos.add(getMockSchemaInfo_INTERNAL_EntityWellBore()); + schemaInfos.add(getMockSchemaInfo_Published_InternalScope()); + + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos.subList(0, 1)); + + Assert.assertTrue(schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size() > 0); + + for(SchemaInfo outputSchemaInfo : schemaService.getSchemaInfoList(queryParams).getSchemaInfos()) { + Assert.assertTrue("INTERNAL".equals(outputSchemaInfo.getScope().toString())); + } + + } + + @Test + public void testGetSchemaInfoList_LatestVersion_WithScopeInternal_WithOneAuthority() + throws ApplicationException, NotFoundException, BadRequestException { + List schemaInfos = new LinkedList(); + QueryParams queryParams = QueryParams.builder().authority("os").latestVersion(true).scope("INTERNAL").limit(10).build(); + schemaInfos.add(getMockSchemaInfo_Published_InternalScope()); + + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "tenant")).thenReturn(schemaInfos); + + Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); + Assert.assertTrue("INTERNAL".equals(schemaService.getSchemaInfoList(queryParams).getSchemaInfos().get(0).getScope().toString())); + } + + @Test + public void testGetSchemaInfoList_LatestVersion_WithScopeShared_WithoutAuthority() + throws ApplicationException, NotFoundException, BadRequestException { + List schemaInfos = new LinkedList(); + QueryParams queryParams = QueryParams.builder().latestVersion(true).scope("SHARED").limit(10).build(); + schemaInfos.add(getMockSchemaInfo_Published_SharedScope()); + schemaInfos.add(getMockSchemaInfo_SHARED_EntityWellBore()); + + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaInfos); + + List finalList = schemaService.getSchemaInfoList(queryParams).getSchemaInfos(); + + Assert.assertTrue(finalList.size() == 2); + + for(SchemaInfo outputSchemaInfo : finalList) { + Assert.assertTrue("SHARED".equals(outputSchemaInfo.getScope().toString())); + } + + } + + @Test + public void testGetSchemaInfoList_LatestVersion_WithScopeShared_WithOneAuthority() + throws ApplicationException, NotFoundException, BadRequestException { + + List schemaInfos = new LinkedList(); + QueryParams queryParams = QueryParams.builder().authority("os").latestVersion(true).scope("SHARED").limit(10).build(); + schemaInfos.add(getMockSchemaInfo_Published_SharedScope()); + + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + Mockito.when(schemaInfoStore.getSchemaInfoList(queryParams, "common")).thenReturn(schemaInfos); + + Assert.assertEquals(1, (schemaService.getSchemaInfoList(queryParams).getSchemaInfos().size())); + Assert.assertTrue("SHARED".equals(schemaService.getSchemaInfoList(queryParams).getSchemaInfos().get(0).getScope().toString())); + Assert.assertTrue("os".equals(schemaService.getSchemaInfoList(queryParams).getSchemaInfos().get(0).getSchemaIdentity().getAuthority())); + + + } + + @Test + public void testGetSchemaInfoList_LatestVersion_MajorMinorPatchConflict_PatchVersionWithoutMinor() + throws ApplicationException, NotFoundException, BadRequestException { + QueryParams queryParams = QueryParams.builder().authority("test").latestVersion(true).schemaVersionMajor(1L) + .schemaVersionPatch(1L).limit(10).build(); + expectedException.expect(BadRequestException.class); + expectedException.expectMessage(SchemaConstants.LATESTVERSION_PATCHFILTER_WITHOUT_MINOR); + schemaService.getSchemaInfoList(queryParams); + } + + @Test + public void testGetSchemaInfoList_LatestVersion_MajorMinorConflict_PatchVersionWithoutMajor() + throws ApplicationException, NotFoundException, BadRequestException { + QueryParams queryParams = QueryParams.builder().latestVersion(true).schemaVersionMinor(1l) + .schemaVersionPatch(1L).limit(10).build(); + expectedException.expect(BadRequestException.class); + expectedException.expectMessage(SchemaConstants.LATESTVERSION_MINORFILTER_WITHOUT_MAJOR); + schemaService.getSchemaInfoList(queryParams); + } + + @Test + public void testUpsertSchema_SuccessfullUpdate() + throws ApplicationException, NotFoundException, BadRequestException, JsonMappingException, JsonProcessingException { + SchemaInfo schInfo = getMockSchemaInfo_development_status(); SchemaRequest schReq = getMockSchemaObject_Development(); - + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + schemaInfoArr[1]=schInfo; Mockito.when(headers.getPartitionId()).thenReturn("tenant"); Mockito.when(schemaInfoStore.getSchemaInfo("os:wks:well:1.1.1")).thenReturn(schInfo); Mockito.when(schemaInfoStore.updateSchemaInfo(schReq)).thenReturn(schInfo); Mockito.when(schemaStore.createSchema(Mockito.anyString(), Mockito.anyString())).thenReturn("{}"); + Mockito.when(schemaStore.getSchema(anyString(), anyString())).thenReturn(""); + Mockito.when(schemaUtil.findSchemaToCompare(schInfo)).thenReturn(schemaInfoArr); + Mockito.when(schemaVersionValidatorFactory.getSchemaVersionValidator(Matchers.any(SchemaVersionValidatorType.class))) + .thenReturn(mock(SchemaVersionValidator.class)); assertEquals(HttpStatus.OK, schemaService.upsertSchema(schReq).getHttpCode()); } @Test public void testUpsertSchema_SuccessfullCreate() - throws ApplicationException, NotFoundException, BadRequestException { + throws ApplicationException, NotFoundException, BadRequestException, JsonMappingException, JsonProcessingException { //throw exception while updating the schema SchemaRequest schReq = getMockSchemaObject_Development(); SchemaInfo schInfoCr = getMockSchemaInfo_development_status(); - + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + schemaInfoArr[1]=schReq.getSchemaInfo(); Mockito.when(headers.getPartitionId()).thenReturn("tenant"); Mockito.when(schemaInfoStore.getSchemaInfo("os:wks:well:1.1.1")).thenThrow(new NotFoundException()); @@ -863,8 +937,6 @@ public class SchemaServiceTest { when(schemaInfoStore.isUnique(schemaId, "common")).thenReturn(true); when(schemaInfoStore.isUnique(schemaId, "tenant")).thenReturn(true); - Mockito.when(schemaStore.getSchema(Mockito.anyString(), Mockito.anyString())) - .thenThrow(NotFoundException.class); Mockito.when(authorityService.checkAndRegisterAuthorityIfNotPresent( schReq.getSchemaInfo().getSchemaIdentity().getAuthority())) .thenReturn(true); @@ -878,7 +950,10 @@ public class SchemaServiceTest { Mockito.when(schemaStore.createSchema(Mockito.anyString(), Mockito.anyString())).thenReturn("{}"); Mockito.when(schemaInfoStore.createSchemaInfo(schReq)) .thenReturn(schInfoCr); - + Mockito.when(schemaStore.getSchema(anyString(), anyString())).thenReturn(""); + Mockito.when(schemaUtil.findSchemaToCompare(schReq.getSchemaInfo())).thenReturn(schemaInfoArr); + Mockito.when(schemaVersionValidatorFactory.getSchemaVersionValidator(Matchers.any(SchemaVersionValidatorType.class))) + .thenReturn(mock(SchemaVersionValidator.class)); assertEquals(HttpStatus.CREATED, schemaService.upsertSchema(schReq).getHttpCode()); } @@ -901,7 +976,117 @@ public class SchemaServiceTest { when(schemaInfoStore.isUnique(schemaId, "tenant")).thenReturn(false); schemaService.upsertSchema(schReq).getHttpCode(); } - + + @Test + public void testSchemaCreate_Patch_BreakingChanges() + throws ApplicationException, NotFoundException, BadRequestException, JsonMappingException, JsonProcessingException { + + //Exception is expected when comparing patch version fails + expectedException.expect(BadRequestException.class); + + SchemaRequest schReq = getMockSchemaObject_Development(); + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + schemaInfoArr[1]=schReq.getSchemaInfo(); + //Schema is unique + when(schemaInfoStore.isUnique(anyString(), anyString())).thenReturn(true); + //Find nearest Schema version to compare with + when(schemaUtil.findSchemaToCompare(schReq.getSchemaInfo())).thenReturn(schemaInfoArr); + //Schema is successfully resolved + Mockito.when(schemaResolver.resolveSchema(Mockito.anyString())).thenReturn("{}"); + //Nothing is returned + Mockito.when(schemaStore.getSchema(anyString(), anyString())).thenReturn("{}"); + Mockito.when(schemaVersionValidatorFactory.getSchemaVersionValidator(SchemaVersionValidatorType.PATCH)) + .thenReturn(patchVersionValidator); + Mockito.doThrow(new SchemaVersionException(SchemaConstants.BREAKING_CHANGES_PATCH)).when(patchVersionValidator).validate(anyString(), anyString()); + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + schemaService.createSchema(schReq); + //Assert that createSchema is not called even once + verify(schemaStore, times(0)).createSchema(anyString(), anyString()); + } + + @Test + public void testSchemaCreate_WhenMajorVersionIsGreater_BreakingChanges() + throws ApplicationException, NotFoundException, BadRequestException, JsonMappingException, JsonProcessingException { + + //Exception is expected when comparing patch version fails + expectedException.expect(BadRequestException.class); + + SchemaRequest schReq = getMockSchemaObject_Development(); + + SchemaInfo latestFoundInSystem = SchemaInfo.builder() + .schemaIdentity(SchemaIdentity.builder().authority("os").source("wks").entityType("well") + .schemaVersionMajor(1L).schemaVersionMinor(2L).schemaVersionPatch(1L) + .id("os:wks:well:1.2.1").build()) + .dateCreated(currDate).scope(SchemaScope.INTERNAL).status(SchemaStatus.DEVELOPMENT).build(); + + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + schemaInfoArr[1]=latestFoundInSystem; + + //Schema is unique + when(schemaInfoStore.isUnique(anyString(), anyString())).thenReturn(true); + + //Find nearest Schema version to compare with + when(schemaUtil.findSchemaToCompare(schReq.getSchemaInfo())).thenReturn(schemaInfoArr); + + //Schema is successfully resolved + Mockito.when(schemaResolver.resolveSchema(Mockito.anyString())).thenReturn("{}"); + + //Nothing is returned + Mockito.when(schemaStore.getSchema(anyString(), anyString())).thenReturn("{}"); + + Mockito.when(schemaVersionValidatorFactory.getSchemaVersionValidator(SchemaVersionValidatorType.MINOR)) + .thenReturn(minorVersionValidator); + Mockito.doThrow(new SchemaVersionException(SchemaConstants.BREAKING_CHANGES_MINOR)).when(minorVersionValidator).validate(anyString(), anyString()); + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + + schemaService.createSchema(schReq); + //Assert that createSchema is not called even once + verify(schemaStore, times(0)).createSchema(anyString(), anyString()); + } + + @Test + public void testSchemaCreate_WhenMajorVersionIsLesser_BreakingChanges() + throws ApplicationException, NotFoundException, BadRequestException, JsonMappingException, JsonProcessingException { + + //Exception is expected when comparing patch version fails + expectedException.expect(BadRequestException.class); + + SchemaRequest schReq = getMockSchemaObject_Development(); + + SchemaInfo latestFoundInSystem = SchemaInfo.builder() + .schemaIdentity(SchemaIdentity.builder().authority("os").source("wks").entityType("well") + .schemaVersionMajor(1L).schemaVersionMinor(0L).schemaVersionPatch(1L) + .id("os:wks:well:1.0.1").build()) + .dateCreated(currDate).scope(SchemaScope.INTERNAL).status(SchemaStatus.DEVELOPMENT).build(); + + SchemaInfo[] schemaInfoArr = new SchemaInfo [2]; + schemaInfoArr[1]=latestFoundInSystem; + + //Schema is unique + when(schemaInfoStore.isUnique(anyString(), anyString())).thenReturn(true); + + //Find nearest Schema version to compare with + when(schemaUtil.findSchemaToCompare(schReq.getSchemaInfo())).thenReturn(schemaInfoArr); + + //Schema is successfully resolved + Mockito.when(schemaResolver.resolveSchema(Mockito.anyString())).thenReturn("{}"); + + //Nothing is returned + Mockito.when(schemaStore.getSchema(anyString(), anyString())).thenReturn("{}"); + + //Do nothing when minor level changes are compared + Mockito.when(schemaVersionValidatorFactory.getSchemaVersionValidator(SchemaVersionValidatorType.MINOR)) + .thenReturn(minorVersionValidator); + Mockito.doThrow(new SchemaVersionException(SchemaConstants.BREAKING_CHANGES_MINOR)).when(minorVersionValidator).validate(anyString(), anyString()); + + Mockito.when(headers.getPartitionId()).thenReturn("tenant"); + + schemaService.createSchema(schReq); + + //Assert that createSchema is not called even once + verify(schemaStore, times(0)).createSchema(anyString(), anyString()); + } + @Test public void testUpsertSchema_Badrequest() throws ApplicationException, NotFoundException, BadRequestException { @@ -919,119 +1104,127 @@ public class SchemaServiceTest { String schemaId = "os:wks:well:1.1.1"; when(schemaInfoStore.isUnique(schemaId, "tenant")).thenReturn(false); - + try { schemaService.upsertSchema(schReq).getHttpCode(); }catch (BadRequestException badreqEx) { assertTrue(SchemaConstants.INVALID_UPDATE_OPERATION.equals(badreqEx.getMessage())); } - + + } + + private SchemaRequest getMockSchemaObject_published() { + return SchemaRequest.builder().schema("{}") + .schemaInfo(SchemaInfo.builder() + .schemaIdentity(SchemaIdentity.builder().authority("os").source("wks").entityType("well") + .schemaVersionMajor(1L).schemaVersionMinor(1L).schemaVersionPatch(1L) + .id("os:wks:well:1.1.1").build()) + .dateCreated(currDate).scope(SchemaScope.SHARED).status(SchemaStatus.PUBLISHED).build()) + .build(); + + } + + private SchemaRequest getMockSchemaObject_published_InternalScope() { + return SchemaRequest.builder().schema("{}") + .schemaInfo(SchemaInfo.builder() + .schemaIdentity(SchemaIdentity.builder().authority("os").source("wks").entityType("well") + .schemaVersionMajor(1L).schemaVersionMinor(1L).schemaVersionPatch(1L) + .id("os:wks:well:1.1.1").build()) + .dateCreated(currDate).scope(SchemaScope.INTERNAL).status(SchemaStatus.PUBLISHED).build()) + .build(); + + } + + private SchemaRequest getMockSchemaObject_published_SharedScope() { + return SchemaRequest.builder().schema("{}") + .schemaInfo(SchemaInfo.builder() + .schemaIdentity(SchemaIdentity.builder().authority("os").source("wks").entityType("well") + .schemaVersionMajor(1L).schemaVersionMinor(1L).schemaVersionPatch(1L) + .id("os:wks:well:1.1.1").build()) + .dateCreated(currDate).scope(SchemaScope.SHARED).status(SchemaStatus.PUBLISHED).build()) + .build(); + + } + + private SchemaRequest getMockSchemaObject_BreakingChanges() throws IOException { + + String schema = new FileUtils().read("/schema_compare/original-schema.json"); + return SchemaRequest.builder().schema(schema) + .schemaInfo(SchemaInfo.builder() + .schemaIdentity(SchemaIdentity.builder().authority("os").source("wks").entityType("well") + .schemaVersionMajor(1L).schemaVersionMinor(1L).schemaVersionPatch(1L) + .id("os:wks:well:1.1.1").build()) + .dateCreated(currDate).scope(SchemaScope.INTERNAL).status(SchemaStatus.PUBLISHED).build()) + .build(); + + } + + private String getMockLatestSchema_BreakingChanges() throws IOException { + + String schema = new FileUtils().read("/schema_compare/minor_level_changes/fail/schema-with-reqprop-extraelement.json"); + return schema; + } + + private SchemaRequest getMockSchemaObject_Development() { + return SchemaRequest.builder().schema("{}") + .schemaInfo(SchemaInfo.builder() + .schemaIdentity(SchemaIdentity.builder().authority("os").source("wks").entityType("well") + .schemaVersionMajor(1L).schemaVersionMinor(1L).schemaVersionPatch(1L) + .id("os:wks:well:1.1.1").build()) + .dateCreated(currDate).scope(SchemaScope.INTERNAL).status(SchemaStatus.DEVELOPMENT).build()) + .build(); + + } + + private SchemaInfo getMockSchemaInfo() { + return SchemaInfo.builder() + .schemaIdentity( + SchemaIdentity.builder().authority("os").source("wks").entityType("well").schemaVersionMajor(1L) + .schemaVersionMinor(1L).schemaVersionPatch(1L).id("os:wks:well:1.1.1").build()) + .dateCreated(currDate).scope(SchemaScope.SHARED).status(SchemaStatus.PUBLISHED).build(); + + } + + private SchemaInfo getMockSchemaInfo_SHARED_EntityWellBore() { + return SchemaInfo.builder() + .schemaIdentity( + SchemaIdentity.builder().authority("os").source("abc").entityType("wellbore").schemaVersionMajor(1L) + .schemaVersionMinor(1L).schemaVersionPatch(1L).id("os:wks:well:1.1.1").build()) + .dateCreated(currDate).scope(SchemaScope.SHARED).status(SchemaStatus.PUBLISHED).build(); + + } + + private SchemaInfo getMockSchemaInfo_INTERNAL_EntityWellBore() { + return SchemaInfo.builder() + .schemaIdentity( + SchemaIdentity.builder().authority("os").source("abc").entityType("wellbore").schemaVersionMajor(1L) + .schemaVersionMinor(1L).schemaVersionPatch(1L).id("os:wks:well:1.1.1").build()) + .dateCreated(currDate).scope(SchemaScope.INTERNAL).status(SchemaStatus.PUBLISHED).build(); + + } + + private SchemaInfo getMockSchemaInfo_Published_InternalScope() { + return SchemaInfo.builder() + .schemaIdentity( + SchemaIdentity.builder().authority("os").source("wks").entityType("well").schemaVersionMajor(1L) + .schemaVersionMinor(1L).schemaVersionPatch(1L).id("os:wks:well:1.1.1").build()) + .dateCreated(currDate).scope(SchemaScope.INTERNAL).status(SchemaStatus.PUBLISHED).build(); + } + + private SchemaInfo getMockSchemaInfo_Published_SharedScope() { + return SchemaInfo.builder() + .schemaIdentity( + SchemaIdentity.builder().authority("os").source("wks").entityType("well").schemaVersionMajor(1L) + .schemaVersionMinor(1L).schemaVersionPatch(1L).id("os:wks:well:1.1.1").build()) + .dateCreated(currDate).scope(SchemaScope.SHARED).status(SchemaStatus.PUBLISHED).build(); + } + + private SchemaInfo getMockSchemaInfo_development_status() { + return SchemaInfo.builder() + .schemaIdentity( + SchemaIdentity.builder().authority("os").source("wks").entityType("well").schemaVersionMajor(1L) + .schemaVersionMinor(1L).schemaVersionPatch(1L).id("os:wks:well:1.1.1").build()) + .dateCreated(currDate).scope(SchemaScope.INTERNAL).status(SchemaStatus.DEVELOPMENT).build(); + } - - private SchemaRequest getMockSchemaObject_published() { - return SchemaRequest.builder().schema("{}") - .schemaInfo(SchemaInfo.builder() - .schemaIdentity(SchemaIdentity.builder().authority("os").source("wks").entityType("well") - .schemaVersionMajor(1L).schemaVersionMinor(1L).schemaVersionPatch(1L) - .id("os:wks:well:1.1.1").build()) - .dateCreated(currDate).scope(SchemaScope.SHARED).status(SchemaStatus.PUBLISHED).build()) - .build(); - - } - - private SchemaRequest getMockSchemaObject_published_InternalScope() { - return SchemaRequest.builder().schema("{}") - .schemaInfo(SchemaInfo.builder() - .schemaIdentity(SchemaIdentity.builder().authority("os").source("wks").entityType("well") - .schemaVersionMajor(1L).schemaVersionMinor(1L).schemaVersionPatch(1L) - .id("os:wks:well:1.1.1").build()) - .dateCreated(currDate).scope(SchemaScope.INTERNAL).status(SchemaStatus.PUBLISHED).build()) - .build(); - - } - - private SchemaRequest getMockSchemaObject_published_SharedScope() { - return SchemaRequest.builder().schema("{}") - .schemaInfo(SchemaInfo.builder() - .schemaIdentity(SchemaIdentity.builder().authority("os").source("wks").entityType("well") - .schemaVersionMajor(1L).schemaVersionMinor(1L).schemaVersionPatch(1L) - .id("os:wks:well:1.1.1").build()) - .dateCreated(currDate).scope(SchemaScope.SHARED).status(SchemaStatus.PUBLISHED).build()) - .build(); - - } - - private SchemaRequest getMockSchemaObject_BreakingChanges() { - return SchemaRequest.builder().schema("{\"key\":\"value1\"}") - .schemaInfo(SchemaInfo.builder() - .schemaIdentity(SchemaIdentity.builder().authority("os").source("wks").entityType("well") - .schemaVersionMajor(1L).schemaVersionMinor(1L).schemaVersionPatch(1L) - .id("os:wks:well:1.1.1").build()) - .dateCreated(currDate).scope(SchemaScope.INTERNAL).status(SchemaStatus.PUBLISHED).build()) - .build(); - - } - - private SchemaRequest getMockSchemaObject_Development() { - return SchemaRequest.builder().schema("{}") - .schemaInfo(SchemaInfo.builder() - .schemaIdentity(SchemaIdentity.builder().authority("os").source("wks").entityType("well") - .schemaVersionMajor(1L).schemaVersionMinor(1L).schemaVersionPatch(1L) - .id("os:wks:well:1.1.1").build()) - .dateCreated(currDate).scope(SchemaScope.INTERNAL).status(SchemaStatus.DEVELOPMENT).build()) - .build(); - - } - - private SchemaInfo getMockSchemaInfo() { - return SchemaInfo.builder() - .schemaIdentity( - SchemaIdentity.builder().authority("os").source("wks").entityType("well").schemaVersionMajor(1L) - .schemaVersionMinor(1L).schemaVersionPatch(1L).id("os:wks:well:1.1.1").build()) - .dateCreated(currDate).scope(SchemaScope.SHARED).status(SchemaStatus.PUBLISHED).build(); - - } - - private SchemaInfo getMockSchemaInfo_SHARED_EntityWellBore() { - return SchemaInfo.builder() - .schemaIdentity( - SchemaIdentity.builder().authority("os").source("abc").entityType("wellbore").schemaVersionMajor(1L) - .schemaVersionMinor(1L).schemaVersionPatch(1L).id("os:wks:well:1.1.1").build()) - .dateCreated(currDate).scope(SchemaScope.SHARED).status(SchemaStatus.PUBLISHED).build(); - - } - - private SchemaInfo getMockSchemaInfo_INTERNAL_EntityWellBore() { - return SchemaInfo.builder() - .schemaIdentity( - SchemaIdentity.builder().authority("os").source("abc").entityType("wellbore").schemaVersionMajor(1L) - .schemaVersionMinor(1L).schemaVersionPatch(1L).id("os:wks:well:1.1.1").build()) - .dateCreated(currDate).scope(SchemaScope.INTERNAL).status(SchemaStatus.PUBLISHED).build(); - - } - - private SchemaInfo getMockSchemaInfo_Published_InternalScope() { - return SchemaInfo.builder() - .schemaIdentity( - SchemaIdentity.builder().authority("os").source("wks").entityType("well").schemaVersionMajor(1L) - .schemaVersionMinor(1L).schemaVersionPatch(1L).id("os:wks:well:1.1.1").build()) - .dateCreated(currDate).scope(SchemaScope.INTERNAL).status(SchemaStatus.PUBLISHED).build(); - } - - private SchemaInfo getMockSchemaInfo_Published_SharedScope() { - return SchemaInfo.builder() - .schemaIdentity( - SchemaIdentity.builder().authority("os").source("wks").entityType("well").schemaVersionMajor(1L) - .schemaVersionMinor(1L).schemaVersionPatch(1L).id("os:wks:well:1.1.1").build()) - .dateCreated(currDate).scope(SchemaScope.SHARED).status(SchemaStatus.PUBLISHED).build(); - } - - private SchemaInfo getMockSchemaInfo_development_status() { - return SchemaInfo.builder() - .schemaIdentity( - SchemaIdentity.builder().authority("os").source("wks").entityType("well").schemaVersionMajor(1L) - .schemaVersionMinor(1L).schemaVersionPatch(1L).id("os:wks:well:1.1.1").build()) - .dateCreated(currDate).scope(SchemaScope.INTERNAL).status(SchemaStatus.DEVELOPMENT).build(); - - } } \ No newline at end of file diff --git a/schema-core/src/test/java/org/opengroup/osdu/schema/util/FileUtils.java b/schema-core/src/test/java/org/opengroup/osdu/schema/util/FileUtils.java index 4da7d9b2e57f9993b400c4f22173b3c65c28c228..8e40d97a3335fffe02c71236e85c5f086425d8aa 100644 --- a/schema-core/src/test/java/org/opengroup/osdu/schema/util/FileUtils.java +++ b/schema-core/src/test/java/org/opengroup/osdu/schema/util/FileUtils.java @@ -1,6 +1,8 @@ package org.opengroup.osdu.schema.util; import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -22,6 +24,19 @@ public class FileUtils { return stringBuilder.toString(); } + public String read(File file) throws IOException { + + BufferedReader br = new BufferedReader(new FileReader(file)); + 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/schema-core/src/test/java/org/opengroup/osdu/schema/util/JSONUtilTest.java b/schema-core/src/test/java/org/opengroup/osdu/schema/util/JSONUtilTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b6991476619663e12f58288ed66c181d6bb6c6d6 --- /dev/null +++ b/schema-core/src/test/java/org/opengroup/osdu/schema/util/JSONUtilTest.java @@ -0,0 +1,113 @@ +package org.opengroup.osdu.schema.util; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.util.EnumSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicInteger; +import org.apache.commons.lang3.StringUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.opengroup.osdu.schema.constants.SchemaConstants.CompositionTags; +import org.opengroup.osdu.schema.constants.SchemaConstants.SkipTags; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +@RunWith(SpringJUnit4ClassRunner.class) +public class JSONUtilTest { + + @InjectMocks + JSONUtil jsonUtil; + + private EnumSet compositionTags = EnumSet.allOf(CompositionTags.class); + + @Test + public void testGetCleanJSON() throws IOException { + String testJSON = new FileUtils().read("/schema_compare/patch_level_changes/schema-with-all-permissible-changes.json"); + String cleanJSON = jsonUtil.getCleanJSON(testJSON); + assertTrue(verifyCleanJSON(cleanJSON)); + } + + public boolean verifyCleanJSON(String inputJSON) throws JsonMappingException, JsonProcessingException { + EnumSet skipTags = EnumSet.allOf(SkipTags.class); + ObjectMapper mapper = new ObjectMapper(); + JsonNode root = mapper.readTree(inputJSON); + Map flattenedJSON = new JSONFlattener(root).flatten(); + + for(String key : flattenedJSON.keySet()) { + System.out.println("key "+key); + boolean isTitleTag =StringUtils.substringAfterLast(key, "/").equals("title"); + if(isTitleTag) { + String[] tags = key.split("/"); + boolean compositionTagContainsTitleTag = compositionTags.stream().anyMatch(tag -> tag.getValue().equals(tags[tags.length-3])); + if(compositionTagContainsTitleTag) + continue; + } + + if(skipTags.stream().anyMatch(element -> + + element.getValue().equals(StringUtils.substringAfterLast(key, "/")))) { + return false; + } + } + + return true; + } + + class JSONFlattener { + + private final Map json = new LinkedHashMap<>(64); + private final JsonNode root; + JSONFlattener(JsonNode node) { + this.root = Objects.requireNonNull(node); + } + + public Map flatten() { + process(root, ""); + return json; + } + + private void process(JsonNode node, String prefix) { + if (node.isObject()) { + ObjectNode object = (ObjectNode) node; + object + .fields() + .forEachRemaining( + entry -> { + process(entry.getValue(), prefix + "/" + entry.getKey()); + }); + } else if (node.isArray()) { + ArrayNode array = (ArrayNode) node; + AtomicInteger counter = new AtomicInteger(); + array + .elements() + .forEachRemaining( + item -> { + process(item, prefix + "/" + counter.getAndIncrement()); + }); + } else { + json.put(prefix, node); + } + } + + + } + + public static void main(String[] args) { + String key = "/A/B/oneOf/0/title"; + boolean isTitleTag =StringUtils.substringAfterLast(key, "/").equals("title"); + if(isTitleTag) { + String[] tags = key.split("/"); + System.out.println(tags[tags.length-3]); + } + } +} diff --git a/schema-core/src/test/java/org/opengroup/osdu/schema/util/SchemaUtilTest.java b/schema-core/src/test/java/org/opengroup/osdu/schema/util/SchemaUtilTest.java index 744a5b67295e70ddb7a971974d28598ebaecd753..1517e69fad064dab63101a2662b800671837eeb7 100644 --- a/schema-core/src/test/java/org/opengroup/osdu/schema/util/SchemaUtilTest.java +++ b/schema-core/src/test/java/org/opengroup/osdu/schema/util/SchemaUtilTest.java @@ -1,50 +1,234 @@ package org.opengroup.osdu.schema.util; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - +import static org.junit.Assert.assertNull; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.schema.exceptions.ApplicationException; import org.opengroup.osdu.schema.exceptions.BadRequestException; +import org.opengroup.osdu.schema.model.QueryParams; +import org.opengroup.osdu.schema.model.SchemaIdentity; +import org.opengroup.osdu.schema.model.SchemaInfo; +import org.opengroup.osdu.schema.provider.interfaces.schemainfostore.ISchemaInfoStore; +import org.springframework.beans.factory.annotation.Value; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.util.ReflectionTestUtils; @RunWith(SpringJUnit4ClassRunner.class) public class SchemaUtilTest { - @InjectMocks - SchemaUtil SchemaUtil; - - @Test - public void testSchemaBreakingChanges_positive() throws BadRequestException { - SchemaUtil.checkBreakingChange("{\"key1\":\"value1\"}", "{\"key1\":\"value1\"}"); - } - - @Test - public void testSchemaBreakingChanges_WithNonBreakingChanges() throws BadRequestException { - SchemaUtil.checkBreakingChange("{\"key1\":\"value1\",\"key2\":\"value2\"}", "{\"key1\":\"value1\"}"); - } - - @Test - public void testSchemaBreakingChanges_WithBreakingChanges() throws BadRequestException { - try { - SchemaUtil.checkBreakingChange("{\"key1\":\"value3\",\"key2\":\"value2\"}", "{\"key1\":\"value1\"}"); - fail("Should not succeed"); - } catch (BadRequestException e) { - assertEquals("Breaking changes found, please change schema major version", e.getMessage()); - } catch (Exception e) { - fail("Should not get different exception"); - } - } - - @Test - public void testSchemaBreakingChanges_WithInCorrectJson() throws BadRequestException { - try { - SchemaUtil.checkBreakingChange("{\"key1\":{value3},\"key2\":\"value2\"}", "{\"key1\":\"value1\"}"); - fail("Should not succeed"); - } catch (BadRequestException e) { - assertEquals("Bad Input, invalid json", e.getMessage()); - } catch (Exception e) { - fail("Should not get different exception"); - } - } + @InjectMocks + SchemaUtil schemaUtil; + + @Mock + ISchemaInfoStore schemaInfoStore; + + @Mock + DpsHeaders headers; + + @Mock + JaxRsDpsLog log; + + @Spy + JSONUtil jsonUtil; + + @Value("${shared.tenant.name:common}") + private String sharedTenant; + + @Before + public void setUp() { + ReflectionTestUtils.setField(schemaUtil, "sharedTenant", "common"); + } + + /*** + * Mock SchemaInfoList with versions: [1.1.0], [1.4.7],[1.6.6],[1.27.5] + */ + private List getMockedList(){ + List schemaInfoList = new ArrayList(); + SchemaInfo schInf = SchemaInfo.builder().schemaIdentity(SchemaIdentity.builder() + .schemaVersionMajor(1l) + .schemaVersionMinor(1l) + .schemaVersionPatch(0l).build()).build(); + schemaInfoList.add(schInf); + + schInf = SchemaInfo.builder().schemaIdentity(SchemaIdentity.builder() + .schemaVersionMajor(1l) + .schemaVersionMinor(27l) + .schemaVersionPatch(5l).build()).build(); + schemaInfoList.add(schInf); + + schInf = SchemaInfo.builder().schemaIdentity(SchemaIdentity.builder() + .schemaVersionMajor(1l) + .schemaVersionMinor(6l) + .schemaVersionPatch(6l).build()).build(); + schemaInfoList.add(schInf); + + schInf = SchemaInfo.builder().schemaIdentity(SchemaIdentity.builder() + .schemaVersionMajor(1l) + .schemaVersionMinor(4l) + .schemaVersionPatch(7l).build()).build(); + schemaInfoList.add(schInf); + + return schemaInfoList; + } + + @Test + public void testFindSchemaWithClosestAndLatestPatchVersion_ReturnNull() throws BadRequestException, ApplicationException { + + SchemaIdentity schemaIdentity = SchemaIdentity.builder().schemaVersionMajor(1l).schemaVersionMinor(1l) + .schemaVersionPatch(0l).build(); + SchemaInfo schInf = SchemaInfo.builder().schemaIdentity(schemaIdentity).build(); + + Mockito.when(schemaInfoStore.getSchemaInfoList( Mockito.any(QueryParams.class), Mockito.anyString())) + .thenReturn(new LinkedList<>()); + Mockito.when(headers.getPartitionId()).thenReturn("opendes"); + SchemaInfo[] schemaInfoArr = schemaUtil.findSchemaToCompare(schInf); + assertNull(schemaInfoArr[0]); + assertNull(schemaInfoArr[1]); + + + } + + @Test + public void testFindSchemaWithClosestAndLatestPatchVersion_ReturnsLatestPatch() throws BadRequestException, ApplicationException { + List schemaInfoList = new ArrayList<>(); + SchemaInfo inputSchemaInfo = SchemaInfo.builder().schemaIdentity(SchemaIdentity.builder() + .schemaVersionMajor(1l) + .schemaVersionMinor(1l) + .schemaVersionPatch(0l).build()).build(); + + SchemaInfo schInfLatest = SchemaInfo.builder().schemaIdentity(SchemaIdentity.builder() + .schemaVersionMajor(1l) + .schemaVersionMinor(0l) + .schemaVersionPatch(0l).build()).build(); + + schemaInfoList.add(schInfLatest); + Mockito.when(schemaInfoStore.getSchemaInfoList( Mockito.any(QueryParams.class), Mockito.anyString())) + .thenReturn(schemaInfoList); + Mockito.when(headers.getPartitionId()).thenReturn("opendes"); + SchemaInfo[] schemaInfoArr = schemaUtil.findSchemaToCompare(inputSchemaInfo); + assertEquals(schemaInfoArr[0], schInfLatest); + assertNull(schemaInfoArr[1]); + + + + } + + /**** + * Example1: + * Existing version in the system: [1.1.0], [1.4.7],[1.6.6],[1.27.5] + * Incoming version: 1.4.0 + * Records fetched to compare: [1.1.0], [1.4.7],[1.6.6],[1.27.5] + * Comparison happens with: [1.1.0 Vs 1.4.0] & [1.4.0 Vs 1.4.7] + * + */ + @Test + public void testFindSchemaWithClosestMinorVersion_ReturnsLatestMinor() throws BadRequestException, ApplicationException { + + + SchemaIdentity schId = SchemaIdentity.builder() + .authority("test") + .source("test") + .entityType("test") + .schemaVersionMajor(1l) + .schemaVersionMinor(4l) + .schemaVersionPatch(0l).build(); + SchemaInfo inputSchemaInfo = SchemaInfo.builder().schemaIdentity(schId).build(); + + SchemaInfo smaller = SchemaInfo.builder().schemaIdentity(SchemaIdentity.builder() + .schemaVersionMajor(1l) + .schemaVersionMinor(1l) + .schemaVersionPatch(0l).build()).build(); + + SchemaInfo bigger = SchemaInfo.builder().schemaIdentity(SchemaIdentity.builder() + .schemaVersionMajor(1l) + .schemaVersionMinor(4l) + .schemaVersionPatch(7l).build()).build(); + + QueryParams latestPatchQueryParams = QueryParams.builder().authority(schId.getAuthority()) + .source(schId.getSource()) + .entityType(schId.getEntityType()) + .schemaVersionMajor(schId.getSchemaVersionMajor()) + .schemaVersionMinor(schId.getSchemaVersionMinor()) + .latestVersion(true).build(); + + QueryParams queryParamsForAllMajorVersion = QueryParams.builder().authority(schId.getAuthority()) + .source(schId.getSource()) + .entityType(schId.getEntityType()) + .schemaVersionMajor(schId.getSchemaVersionMajor()).build(); + + Mockito.when(schemaInfoStore.getSchemaInfoList( latestPatchQueryParams, "opendes")) + .thenReturn(new LinkedList<>()); + + Mockito.when(schemaInfoStore.getSchemaInfoList( latestPatchQueryParams, "common")) + .thenReturn(new LinkedList<>()); + + Mockito.when(schemaInfoStore.getSchemaInfoList( queryParamsForAllMajorVersion, "opendes")) + .thenReturn(getMockedList()); + + Mockito.when(headers.getPartitionId()).thenReturn("opendes"); + SchemaInfo[] schemaInfoArr = schemaUtil.findSchemaToCompare(inputSchemaInfo); + assertEquals(schemaInfoArr[0], smaller); + assertEquals(schemaInfoArr[1], bigger); + + + } + + /**** + * Existing version in the system: [1.1.0], [1.4.7],[1.6.6],[1.27.5] + * Incoming version: 1.30.0 + * Records fetched to compare: [1.1.0], [1.4.7],[1.6.6],[1.27.5] + * Comparison happens with: 1.27.5 Vs 1.30.0 + * + */ + @Test + public void testFindSchemaWithClosestMinorVersion_ReturnsClosesGreaterMinor() throws BadRequestException, ApplicationException { + + + SchemaIdentity schId = SchemaIdentity.builder() + .authority("test") + .source("test") + .entityType("test") + .schemaVersionMajor(1l) + .schemaVersionMinor(30l) + .schemaVersionPatch(0l).build(); + SchemaInfo inputSchemaInfo = SchemaInfo.builder().schemaIdentity(schId).build(); + + SchemaInfo schInfLatest = SchemaInfo.builder().schemaIdentity(SchemaIdentity.builder() + .schemaVersionMajor(1l) + .schemaVersionMinor(27l) + .schemaVersionPatch(5l).build()).build(); + + QueryParams latestPatchqueryParams = QueryParams.builder().authority(schId.getAuthority()) + .source(schId.getSource()) + .entityType(schId.getEntityType()) + .schemaVersionMajor(schId.getSchemaVersionMajor()) + .schemaVersionMinor(schId.getSchemaVersionMinor()) + .latestVersion(true).build(); + + QueryParams queryParamsForAllMajorVersion = QueryParams.builder().authority(schId.getAuthority()) + .source(schId.getSource()) + .entityType(schId.getEntityType()) + .schemaVersionMajor(schId.getSchemaVersionMajor()).build(); + + Mockito.when(schemaInfoStore.getSchemaInfoList( latestPatchqueryParams, "opendes")) + .thenReturn(new LinkedList<>()); + + Mockito.when(schemaInfoStore.getSchemaInfoList( queryParamsForAllMajorVersion, "opendes")) + .thenReturn(getMockedList()); + Mockito.when(headers.getPartitionId()).thenReturn("opendes"); + SchemaInfo[] schemaInfoArr = schemaUtil.findSchemaToCompare(inputSchemaInfo); + assertEquals(schemaInfoArr[0], schInfLatest); + assertNull(schemaInfoArr[1]); + } + } \ No newline at end of file diff --git a/schema-core/src/test/java/org/opengroup/osdu/schema/validation/SchemaMinorVersionValidatorTest.java b/schema-core/src/test/java/org/opengroup/osdu/schema/validation/SchemaMinorVersionValidatorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c7e07b4f34559240bca0a01ac4f1b709ec796acb --- /dev/null +++ b/schema-core/src/test/java/org/opengroup/osdu/schema/validation/SchemaMinorVersionValidatorTest.java @@ -0,0 +1,143 @@ +package org.opengroup.osdu.schema.validation; + +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.schema.exceptions.ApplicationException; +import org.opengroup.osdu.schema.exceptions.BadRequestException; +import org.opengroup.osdu.schema.provider.interfaces.schemainfostore.ISchemaInfoStore; +import org.opengroup.osdu.schema.util.FileUtils; +import org.opengroup.osdu.schema.util.JSONUtil; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +public class SchemaMinorVersionValidatorTest { + + @InjectMocks + SchemaMinorVersionValidator minorVersionValidator; + + @Mock + ISchemaInfoStore schemaInfoStore; + + @Mock + DpsHeaders headers; + + @Mock + JaxRsDpsLog log; + + @Spy + JSONUtil jsonUtil; + + @Test + public void testVerifyMinorLevelChanges_WithAllPermissibleChanges() throws IOException, BadRequestException, ApplicationException { + String sourceSchema = new FileUtils().read("/schema_compare/minor_level_changes/original.json"); + + File folder = new File("src/test/resources/schema_compare/minor_level_changes/pass"); + + for (final File fileEntry : folder.listFiles()) { + System.out.println(fileEntry.getPath()); + String newSchemaSchema = new FileUtils().read(fileEntry); + minorVersionValidator.validate(sourceSchema, newSchemaSchema); + assertTrue(true); + } + } + + @Test + public void testVerifyMinorLevelChanges_WithOneOfAttr_WithTitle_OrderChanged() throws IOException, BadRequestException, ApplicationException { + String sourceSchema = new FileUtils().read("/schema_compare/minor_level_changes/original-schema-with-oneOf-Title.json"); + String newSchemaSchema = new FileUtils().read("/schema_compare/minor_level_changes/pass-with-title/schema-with-oneOf-Orderchanged-Title.json"); + minorVersionValidator.validate(sourceSchema, newSchemaSchema); + assertTrue(true); + } + + @Test + public void testVerifyMinorLevelChanges_WithOneOfAttr_WithTitle_OrderChanged_AdditionalRefAttr() throws IOException, BadRequestException, ApplicationException { + String sourceSchema = new FileUtils().read("/schema_compare/minor_level_changes/original-schema-with-oneOf-Title.json"); + String newSchemaSchema = new FileUtils().read("/schema_compare/minor_level_changes/pass-with-title/schema-with-oneOf-Orderchanged-Title-WithRefAttr.json"); + minorVersionValidator.validate(sourceSchema, newSchemaSchema); + assertTrue(true); + } + + @Test + public void testVerifyMinorLevelChanges_ComplexSchema_NestedAllOf() throws IOException, BadRequestException, ApplicationException { + String sourceSchema = new FileUtils().read("/schema_compare/minor_level_changes/original-complex-oneOf-With-Title.json"); + File folder = new File("src/test/resources/schema_compare/minor_level_changes/pass-complex"); + + for (final File fileEntry : folder.listFiles()) { + System.out.println(fileEntry.getPath()); + String newSchemaSchema = new FileUtils().read(fileEntry); + minorVersionValidator.validate(sourceSchema, newSchemaSchema); + assertTrue(true); + } + } + + @Test + public void testVerifyMinorLevelChanges_WhenTitleBlockIsMissing() throws IOException, ApplicationException { + String sourceSchema = new FileUtils().read("/schema_compare/minor_level_changes/original-schema-with-oneOf-Title.json"); + + File folder = new File("src/test/resources/schema_compare/minor_level_changes/fail-with-title"); + + for (final File fileEntry : folder.listFiles()) { + System.out.println(fileEntry.getPath()); + String existingSchema = new FileUtils().read(fileEntry); + try { + minorVersionValidator.validate(sourceSchema, existingSchema); + assertTrue(false); + } catch (BadRequestException e) { + System.out.println(e.getErrorMsg()); + assertTrue(true); + } + + } + } + + @Test + public void testVerifyMinorLevelChanges_WithAllNonPermissibleChanges() throws IOException, ApplicationException { + String sourceSchema = new FileUtils().read("/schema_compare/minor_level_changes/original.json"); + + File folder = new File("src/test/resources/schema_compare/minor_level_changes/fail"); + + for (final File fileEntry : folder.listFiles()) { + System.out.println(fileEntry.getPath()); + String existingSchema = new FileUtils().read(fileEntry); + try { + minorVersionValidator.validate(sourceSchema, existingSchema); + assertTrue(false); + } catch (BadRequestException e) { + System.out.println(e.getErrorMsg()); + assertTrue(true); + } + + } + } + + + + @Test(expected = BadRequestException.class) + public void testVerifyMinorLevelChanges_WhenAdditionalAttribute_Changed_FromTrueToFalse() throws IOException, BadRequestException, ApplicationException { + String sourceSchema = new FileUtils().read("/schema_compare/minor_level_changes/fail/schema-wth-addprop-add-false.json"); + + String existingSchema = new FileUtils().read("/schema_compare/minor_level_changes/pass/schema-with-addprop-add-true.json"); + + minorVersionValidator.validate(sourceSchema, existingSchema); + } + + @Test + public void testVerifyMinorLevelChanges_WhenAdditionalAttributeExistAsTrue_ButRemoved() throws IOException, BadRequestException, ApplicationException { + + String existingSchema = new FileUtils().read("/schema_compare/minor_level_changes/pass/schema-with-addprop-add-true.json"); + + String sourceSchema = new FileUtils().read("/schema_compare/minor_level_changes/original.json"); + + minorVersionValidator.validate(sourceSchema, existingSchema); + } +} diff --git a/schema-core/src/test/java/org/opengroup/osdu/schema/validation/SchemaPatchVersionValidatorTest.java b/schema-core/src/test/java/org/opengroup/osdu/schema/validation/SchemaPatchVersionValidatorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7635c6a9fe6d01928b3bcacb45e045bc9046362f --- /dev/null +++ b/schema-core/src/test/java/org/opengroup/osdu/schema/validation/SchemaPatchVersionValidatorTest.java @@ -0,0 +1,74 @@ +package org.opengroup.osdu.schema.validation; + +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.schema.exceptions.ApplicationException; +import org.opengroup.osdu.schema.exceptions.BadRequestException; +import org.opengroup.osdu.schema.provider.interfaces.schemainfostore.ISchemaInfoStore; +import org.opengroup.osdu.schema.util.FileUtils; +import org.opengroup.osdu.schema.util.JSONUtil; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +public class SchemaPatchVersionValidatorTest { + + @InjectMocks + SchemaPatchVersionValidator patchVersionValidator; + + @Mock + ISchemaInfoStore schemaInfoStore; + + @Mock + DpsHeaders headers; + + @Mock + JaxRsDpsLog log; + + @Spy + JSONUtil jsonUtil; + + @Test + public void testVerifyPatchLevelChanges_WithAllPermissibleChanges() throws IOException, BadRequestException, ApplicationException { + String sourceSchema = new FileUtils().read("/schema_compare/original-schema.json"); + + File folder = new File("src/test/resources/schema_compare/patch_level_changes"); + + for (final File fileEntry : folder.listFiles()) { + System.out.println(fileEntry.getPath()); + String existingSchema = new FileUtils().read(fileEntry); + patchVersionValidator.validate(sourceSchema, existingSchema); + assertTrue(true); + } + } + + @Test + public void testVerifyMinorLevelChanges_WithAllNonPermissibleChanges() throws IOException, ApplicationException { + String sourceSchema = new FileUtils().read("/schema_compare/original-schema.json"); + + File folder = new File("src/test/resources/schema_compare/minor_level_changes/fail"); + + for (final File fileEntry : folder.listFiles()) { + System.out.println(fileEntry.getPath()); + String existingSchema = new FileUtils().read(fileEntry); + try { + patchVersionValidator.validate(sourceSchema, existingSchema); + assertTrue(false); + } catch (BadRequestException e) { + System.out.println(e.getErrorMsg()); + assertTrue(true); + } + + } + } + +} diff --git a/schema-core/src/test/java/org/opengroup/osdu/schema/validation/SchemaValidatorTest.java b/schema-core/src/test/java/org/opengroup/osdu/schema/validation/SchemaRequestValidatorTest.java similarity index 93% rename from schema-core/src/test/java/org/opengroup/osdu/schema/validation/SchemaValidatorTest.java rename to schema-core/src/test/java/org/opengroup/osdu/schema/validation/SchemaRequestValidatorTest.java index 9c278190917d3ae9feb27adbe436656a89417c87..3a472e0bcdb60f9ec4880499b66495256fc18155 100644 --- a/schema-core/src/test/java/org/opengroup/osdu/schema/validation/SchemaValidatorTest.java +++ b/schema-core/src/test/java/org/opengroup/osdu/schema/validation/SchemaRequestValidatorTest.java @@ -15,10 +15,10 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; @RunWith(SpringJUnit4ClassRunner.class) -public class SchemaValidatorTest { +public class SchemaRequestValidatorTest { @InjectMocks - SchemaValidator schemaValidator; + SchemaRequestValidator schemaValidator; @Mock ConstraintValidatorContext constraintValidatorContext; diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/fail-with-title/schema-with-allOf-Title-Missing.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail-with-title/schema-with-allOf-Title-Missing.json new file mode 100644 index 0000000000000000000000000000000000000000..06831c845aee7b3c3cbbd5de2ac8cf35942c8874 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail-with-title/schema-with-allOf-Title-Missing.json @@ -0,0 +1,32 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string" }, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1" ], + "oneOf": [ + { + "title": "title-1", + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + }, + { + "title": "title-3", + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-existing-attr-removed.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-existing-attr-removed.json new file mode 100644 index 0000000000000000000000000000000000000000..0fb347fdd0d6485b716fd65014a909f82fbbaf3a --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-existing-attr-removed.json @@ -0,0 +1,58 @@ +{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "additionalProperties": true, + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-oneOf-Orderchanged-Title-WithNonRefAttr.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-oneOf-Orderchanged-Title-WithNonRefAttr.json new file mode 100644 index 0000000000000000000000000000000000000000..9a0d694d56270b639ca790a2d272dcfa1abd7e32 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-oneOf-Orderchanged-Title-WithNonRefAttr.json @@ -0,0 +1,41 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + + }, + "properties": { + "AddressLine1": { "type": "string" }, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1" ], + "oneOf": [ + { + "title": "title-2", + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + }, + { + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "integer" } + } + }, + { + "title": "title-1", + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-oneOf-changeinorder-withoutitle.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-oneOf-changeinorder-withoutitle.json new file mode 100644 index 0000000000000000000000000000000000000000..836ff02412c1266abca1cd15552df0ce393304e5 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-oneOf-changeinorder-withoutitle.json @@ -0,0 +1,61 @@ +{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "additionalProperties":true, + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + }, + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-oneOf-removedelement.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-oneOf-removedelement.json new file mode 100644 index 0000000000000000000000000000000000000000..6b5df8ae1bd694982f813c6c0198793824f0ce1e --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-oneOf-removedelement.json @@ -0,0 +1,43 @@ +{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "additionalProperties":true, + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-removed-oneof.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-removed-oneof.json new file mode 100644 index 0000000000000000000000000000000000000000..1f7d9f0b21518f9c1194d9fabe699c8df5e8f907 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-removed-oneof.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string" }, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1", "AddressLine2" ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-reqprop-changeelement.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-reqprop-changeelement.json new file mode 100644 index 0000000000000000000000000000000000000000..ba9608f0a5e448fda928b4070d392d6cfc05b1d9 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-reqprop-changeelement.json @@ -0,0 +1,61 @@ +{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "additionalProperties":true, + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + }, + { + "type":"object", + "properties":{ + "state":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-reqprop-extraelement.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-reqprop-extraelement.json new file mode 100644 index 0000000000000000000000000000000000000000..eabb5aaa0c05f85a83ba9d84773a7048642d14fa --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-reqprop-extraelement.json @@ -0,0 +1,62 @@ +{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "additionalProperties": true, + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2", + "City" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-reqprop-removingelement.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-reqprop-removingelement.json new file mode 100644 index 0000000000000000000000000000000000000000..6b5df8ae1bd694982f813c6c0198793824f0ce1e --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-reqprop-removingelement.json @@ -0,0 +1,43 @@ +{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "additionalProperties":true, + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-type-attribute-change.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-type-attribute-change.json new file mode 100644 index 0000000000000000000000000000000000000000..387addffefa79b61511734e69bd9c266607fab01 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-type-attribute-change.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string" }, + "AddressLine2": { "type": "int" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1", "AddressLine2" ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + }, + { + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-wth-addprop-add-false.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-wth-addprop-add-false.json new file mode 100644 index 0000000000000000000000000000000000000000..15fff6a651ff3865892876cefcd7fb4583ea8215 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-wth-addprop-add-false.json @@ -0,0 +1,61 @@ +{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "additionalProperties": false, + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/original-complex-oneOf-With-Title.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/original-complex-oneOf-With-Title.json new file mode 100644 index 0000000000000000000000000000000000000000..eaf50ae75ed2bd4b29b29f3cf3ad9abf6f610cc4 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/original-complex-oneOf-With-Title.json @@ -0,0 +1,239 @@ +{ + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/master-data/Wellbore.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:master-data--Wellbore:1.0.0", + "title": "Wellbore", + "description": "A hole in the ground extending from a point at the earth's surface to the maximum point of penetration.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Wellbore:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:master-data--Wellbore:c7c421a7-f496-5aef-8093-298c32bfdea9" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:master-data--Wellbore:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "osdu:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "osdu:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "osdu:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "osdu:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "osdu:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "osdu:wks:AbstractMaster:1.0.0" + }, + { + "$ref": "osdu:wks:AbstractFacility:1.0.0" + }, + { + "title": "title-1", + "type": "object", + "properties": { + "WellID": { + "type": "string", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Well:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "Well" + } + ] + }, + "SequenceNumber": { + "description": "A number that indicates the order in which wellbores were drilled.", + "type": "integer" + }, + "VerticalMeasurements": { + "description": "List of all depths and elevations pertaining to the wellbore, like, plug back measured depth, total measured depth, KB elevation", + "type": "array", + "x-osdu-indexing": { + "type": "nested" + }, + "items": { + "allOf": [ + { + "title": "title-3", + "type": "object", + "properties": { + "VerticalMeasurementID": { + "description": "The ID for a distinct vertical measurement within the Wellbore VerticalMeasurements array so that it may be referenced by other vertical measurements if necessary.", + "type": "string" + } + } + }, + { + "$ref": "osdu:wks:AbstractFacilityVerticalMeasurement:1.0.0" + } + ] + } + }, + "DrillingReasons": { + "description": "The history of drilling reasons of the wellbore.", + "type": "array", + "items": { + "$ref": "osdu:wks:AbstractWellboreDrillingReason:1.0.0" + } + }, + "KickOffWellbore": { + "description": "This is a pointer to the parent wellbore. The wellbore that starts from top has no parent.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Wellbore:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "Wellbore" + } + ] + }, + "TrajectoryTypeID": { + "description": "Describes the predominant shapes the wellbore path can follow if deviated from vertical. Sample Values: Horizontal, Vertical, Directional.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-WellboreTrajectoryType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "WellboreTrajectoryType" + } + ] + }, + "DefinitiveTrajectoryID": { + "description": "SRN of Wellbore Trajectory which is considered the authoritative or preferred version.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:work-product-component\\-\\-WellboreTrajectory:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "work-product-component", + "EntityType": "WellboreTrajectory" + } + ] + }, + "TargetFormation": { + "description": "The Formation of interest for which the Wellbore is drilled to interact with. The Wellbore may terminate in a lower formation if the requirement is to drill through the entirety of the target formation, therefore this is not necessarily the Formation at TD.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-GeologicalFormation:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "GeologicalFormation" + } + ] + }, + "PrimaryMaterialID": { + "description": "The primary material injected/produced from the wellbore.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-MaterialType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "MaterialType" + } + ] + }, + "DefaultVerticalMeasurementID": { + "description": "The default datum reference point, or zero depth point, used to determine other points vertically in a wellbore. References an entry in the Vertical Measurements array of this wellbore.", + "type": "string" + }, + "ProjectedBottomHoleLocation": { + "description": "The bottom hole location of the wellbore denoted by a projected horizontal coordinate reference system (Horizontal CRS), such a UTM zone. 'Projected' in this property does not mean 'planned' or 'projected-to-bit'. If both GeographicBottomHoleLocation and ProjectedBottomHoleLocation properties are populated on this wellbore, they must identify the same point, just in different CRSs.", + "$ref": "osdu:wks:AbstractSpatialLocation:1.0.0" + }, + "GeographicBottomHoleLocation": { + "description": "The bottom hole location of the wellbore denoted by a specified geographic horizontal coordinate reference system (Horizontal CRS), such as WGS84, NAD27, or ED50. If both GeographicBottomHoleLocation and ProjectedBottomHoleLocation properties are populated on this wellbore, they must identify the same point, just in different CRSs.", + "$ref": "osdu:wks:AbstractSpatialLocation:1.0.0" + } + } + }, + { + "title": "title-2", + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-inheriting-from-kind": [] + } diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/original-schema-with-oneOf-Title.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/original-schema-with-oneOf-Title.json new file mode 100644 index 0000000000000000000000000000000000000000..e3d07fca140f39206fb5ebf661e376e694f7c8f4 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/original-schema-with-oneOf-Title.json @@ -0,0 +1,32 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string" }, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1" ], + "oneOf": [ + { + "title": "title-1", + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + }, + { + "title": "title-2", + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/original.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/original.json new file mode 100644 index 0000000000000000000000000000000000000000..87046daa3876fd5e11ea1545fc8d53cc1dc76acd --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/original.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string" }, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1", "AddressLine2" ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + }, + { + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/pass-complex/new-complex-NestedAllOf-ElementJumbled-NewAttributeAdded.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass-complex/new-complex-NestedAllOf-ElementJumbled-NewAttributeAdded.json new file mode 100644 index 0000000000000000000000000000000000000000..631f34b93253589c4193504e25c17e0e747453d5 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass-complex/new-complex-NestedAllOf-ElementJumbled-NewAttributeAdded.json @@ -0,0 +1,243 @@ +{ + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/master-data/Wellbore.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:master-data--Wellbore:1.0.0", + "title": "Wellbore", + "description": "A hole in the ground extending from a point at the earth's surface to the maximum point of penetration.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Wellbore:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:master-data--Wellbore:c7c421a7-f496-5aef-8093-298c32bfdea9" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:master-data--Wellbore:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "osdu:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "osdu:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "osdu:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "osdu:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "osdu:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "osdu:wks:AbstractMaster:1.0.0" + }, + { + "title": "title-1", + "type": "object", + "properties": { + "WellID": { + "type": "string", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Well:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "Well" + } + ] + }, + "SequenceNumber": { + "description": "A number that indicates the order in which wellbores were drilled.", + "type": "integer" + }, + "VerticalMeasurements": { + "description": "List of all depths and elevations pertaining to the wellbore, like, plug back measured depth, total measured depth, KB elevation", + "type": "array", + "x-osdu-indexing": { + "type": "nested" + }, + "items": { + "allOf": [ + { + "$ref": "osdu:wks:AbstractFacilityVerticalMeasurement:1.0.0" + }, + { + "title": "title-3", + "type": "object", + "properties": { + "VerticalMeasurementID": { + "description": "The ID for a distinct vertical measurement within the Wellbore VerticalMeasurements array so that it may be referenced by other vertical measurements if necessary.", + "type": "string" + }, + "SequenceNumber": { + "description": "A number that indicates the order in which wellbores were drilled.", + "type": "integer" + } + } + } + ] + } + }, + "DrillingReasons": { + "description": "The history of drilling reasons of the wellbore.", + "type": "array", + "items": { + "$ref": "osdu:wks:AbstractWellboreDrillingReason:1.0.0" + } + }, + "KickOffWellbore": { + "description": "This is a pointer to the parent wellbore. The wellbore that starts from top has no parent.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Wellbore:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "Wellbore" + } + ] + }, + "TrajectoryTypeID": { + "description": "Describes the predominant shapes the wellbore path can follow if deviated from vertical. Sample Values: Horizontal, Vertical, Directional.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-WellboreTrajectoryType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "WellboreTrajectoryType" + } + ] + }, + "DefinitiveTrajectoryID": { + "description": "SRN of Wellbore Trajectory which is considered the authoritative or preferred version.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:work-product-component\\-\\-WellboreTrajectory:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "work-product-component", + "EntityType": "WellboreTrajectory" + } + ] + }, + "TargetFormation": { + "description": "The Formation of interest for which the Wellbore is drilled to interact with. The Wellbore may terminate in a lower formation if the requirement is to drill through the entirety of the target formation, therefore this is not necessarily the Formation at TD.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-GeologicalFormation:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "GeologicalFormation" + } + ] + }, + "PrimaryMaterialID": { + "description": "The primary material injected/produced from the wellbore.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-MaterialType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "MaterialType" + } + ] + }, + "DefaultVerticalMeasurementID": { + "description": "The default datum reference point, or zero depth point, used to determine other points vertically in a wellbore. References an entry in the Vertical Measurements array of this wellbore.", + "type": "string" + }, + "ProjectedBottomHoleLocation": { + "description": "The bottom hole location of the wellbore denoted by a projected horizontal coordinate reference system (Horizontal CRS), such a UTM zone. 'Projected' in this property does not mean 'planned' or 'projected-to-bit'. If both GeographicBottomHoleLocation and ProjectedBottomHoleLocation properties are populated on this wellbore, they must identify the same point, just in different CRSs.", + "$ref": "osdu:wks:AbstractSpatialLocation:1.0.0" + }, + "GeographicBottomHoleLocation": { + "description": "The bottom hole location of the wellbore denoted by a specified geographic horizontal coordinate reference system (Horizontal CRS), such as WGS84, NAD27, or ED50. If both GeographicBottomHoleLocation and ProjectedBottomHoleLocation properties are populated on this wellbore, they must identify the same point, just in different CRSs.", + "$ref": "osdu:wks:AbstractSpatialLocation:1.0.0" + } + } + }, + { + "$ref": "osdu:wks:AbstractFacility:1.0.0" + }, + { + "title": "title-2", + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-inheriting-from-kind": [] + } diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/pass-complex/new-complex-NestedoneOf-ElementJumbled-With-Title.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass-complex/new-complex-NestedoneOf-ElementJumbled-With-Title.json new file mode 100644 index 0000000000000000000000000000000000000000..bfa435a05bd16821fdc4f64b171b4c458aef0c42 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass-complex/new-complex-NestedoneOf-ElementJumbled-With-Title.json @@ -0,0 +1,239 @@ +{ + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/master-data/Wellbore.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:master-data--Wellbore:1.0.0", + "title": "Wellbore", + "description": "A hole in the ground extending from a point at the earth's surface to the maximum point of penetration.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Wellbore:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:master-data--Wellbore:c7c421a7-f496-5aef-8093-298c32bfdea9" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:master-data--Wellbore:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "osdu:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "osdu:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "osdu:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "osdu:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "osdu:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "osdu:wks:AbstractMaster:1.0.0" + }, + { + "title": "title-1", + "type": "object", + "properties": { + "WellID": { + "type": "string", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Well:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "Well" + } + ] + }, + "SequenceNumber": { + "description": "A number that indicates the order in which wellbores were drilled.", + "type": "integer" + }, + "VerticalMeasurements": { + "description": "List of all depths and elevations pertaining to the wellbore, like, plug back measured depth, total measured depth, KB elevation", + "type": "array", + "x-osdu-indexing": { + "type": "nested" + }, + "items": { + "allOf": [ + { + "$ref": "osdu:wks:AbstractFacilityVerticalMeasurement:1.0.0" + }, + { + "title": "title-3", + "type": "object", + "properties": { + "VerticalMeasurementID": { + "description": "The ID for a distinct vertical measurement within the Wellbore VerticalMeasurements array so that it may be referenced by other vertical measurements if necessary.", + "type": "string" + } + } + } + ] + } + }, + "DrillingReasons": { + "description": "The history of drilling reasons of the wellbore.", + "type": "array", + "items": { + "$ref": "osdu:wks:AbstractWellboreDrillingReason:1.0.0" + } + }, + "KickOffWellbore": { + "description": "This is a pointer to the parent wellbore. The wellbore that starts from top has no parent.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Wellbore:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "Wellbore" + } + ] + }, + "TrajectoryTypeID": { + "description": "Describes the predominant shapes the wellbore path can follow if deviated from vertical. Sample Values: Horizontal, Vertical, Directional.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-WellboreTrajectoryType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "WellboreTrajectoryType" + } + ] + }, + "DefinitiveTrajectoryID": { + "description": "SRN of Wellbore Trajectory which is considered the authoritative or preferred version.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:work-product-component\\-\\-WellboreTrajectory:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "work-product-component", + "EntityType": "WellboreTrajectory" + } + ] + }, + "TargetFormation": { + "description": "The Formation of interest for which the Wellbore is drilled to interact with. The Wellbore may terminate in a lower formation if the requirement is to drill through the entirety of the target formation, therefore this is not necessarily the Formation at TD.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-GeologicalFormation:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "GeologicalFormation" + } + ] + }, + "PrimaryMaterialID": { + "description": "The primary material injected/produced from the wellbore.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-MaterialType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "MaterialType" + } + ] + }, + "DefaultVerticalMeasurementID": { + "description": "The default datum reference point, or zero depth point, used to determine other points vertically in a wellbore. References an entry in the Vertical Measurements array of this wellbore.", + "type": "string" + }, + "ProjectedBottomHoleLocation": { + "description": "The bottom hole location of the wellbore denoted by a projected horizontal coordinate reference system (Horizontal CRS), such a UTM zone. 'Projected' in this property does not mean 'planned' or 'projected-to-bit'. If both GeographicBottomHoleLocation and ProjectedBottomHoleLocation properties are populated on this wellbore, they must identify the same point, just in different CRSs.", + "$ref": "osdu:wks:AbstractSpatialLocation:1.0.0" + }, + "GeographicBottomHoleLocation": { + "description": "The bottom hole location of the wellbore denoted by a specified geographic horizontal coordinate reference system (Horizontal CRS), such as WGS84, NAD27, or ED50. If both GeographicBottomHoleLocation and ProjectedBottomHoleLocation properties are populated on this wellbore, they must identify the same point, just in different CRSs.", + "$ref": "osdu:wks:AbstractSpatialLocation:1.0.0" + } + } + }, + { + "$ref": "osdu:wks:AbstractFacility:1.0.0" + }, + { + "title": "title-2", + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-inheriting-from-kind": [] + } diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/pass-complex/new-complex-oneOf-ElementJumbled-With-Title.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass-complex/new-complex-oneOf-ElementJumbled-With-Title.json new file mode 100644 index 0000000000000000000000000000000000000000..833d433a8463c646610eaf42bc784662ae21adef --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass-complex/new-complex-oneOf-ElementJumbled-With-Title.json @@ -0,0 +1,239 @@ +{ + "x-osdu-license": "Copyright 2021, The Open Group \\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", + "$id": "https://schema.osdu.opengroup.org/json/master-data/Wellbore.1.0.0.json", + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-schema-source": "osdu:wks:master-data--Wellbore:1.0.0", + "title": "Wellbore", + "description": "A hole in the ground extending from a point at the earth's surface to the maximum point of penetration.", + "type": "object", + "properties": { + "id": { + "description": "Previously called ResourceID or SRN which identifies this OSDU resource object without version.", + "title": "Entity ID", + "type": "string", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Wellbore:[\\w\\-\\.\\:\\%]+$", + "example": "namespace:master-data--Wellbore:c7c421a7-f496-5aef-8093-298c32bfdea9" + }, + "kind": { + "description": "The schema identification for the OSDU resource object following the pattern {Namespace}:{Source}:{Type}:{VersionMajor}.{VersionMinor}.{VersionPatch}. The versioning scheme follows the semantic versioning, https://semver.org/.", + "title": "Entity Kind", + "type": "string", + "pattern": "^[\\w\\-\\.]+:[\\w\\-\\.]+:[\\w\\-\\.]+:[0-9]+.[0-9]+.[0-9]+$", + "example": "osdu:wks:master-data--Wellbore:1.0.0" + }, + "version": { + "description": "The version number of this OSDU resource; set by the framework.", + "title": "Version Number", + "type": "integer", + "format": "int64", + "example": 1562066009929332 + }, + "acl": { + "description": "The access control tags associated with this entity.", + "title": "Access Control List", + "$ref": "osdu:wks:AbstractAccessControlList:1.0.0" + }, + "legal": { + "description": "The entity's legal tags and compliance status. The actual contents associated with the legal tags is managed by the Compliance Service.", + "title": "Legal Tags", + "$ref": "osdu:wks:AbstractLegalTags:1.0.0" + }, + "tags": { + "title": "Tag Dictionary", + "description": "A generic dictionary of string keys mapping to string value. Only strings are permitted as keys and values.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "example": { + "NameOfKey": "String value" + } + }, + "createTime": { + "description": "Timestamp of the time at which initial version of this OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:46:20.163Z" + }, + "createUser": { + "title": "Resource Object Creation User Reference", + "description": "The user reference, which created the first version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "modifyTime": { + "description": "Timestamp of the time at which this version of the OSDU resource object was created. Set by the System. The value is a combined date-time string in ISO-8601 given in UTC.", + "title": "Resource Object Version Creation DateTime", + "type": "string", + "format": "date-time", + "example": "2020-12-16T11:52:24.477Z" + }, + "modifyUser": { + "title": "Resource Object Version Creation User Reference", + "description": "The user reference, which created this version of this resource object. Set by the System.", + "type": "string", + "example": "some-user@some-company-cloud.com" + }, + "ancestry": { + "description": "The links to data, which constitute the inputs.", + "title": "Ancestry", + "$ref": "osdu:wks:AbstractLegalParentList:1.0.0" + }, + "meta": { + "description": "The Frame of Reference meta data section linking the named properties to self-contained definitions.", + "title": "Frame of Reference Meta Data", + "type": "array", + "items": { + "$ref": "osdu:wks:AbstractMetaItem:1.0.0" + } + }, + "data": { + "allOf": [ + { + "$ref": "osdu:wks:AbstractCommonResources:1.0.0" + }, + { + "$ref": "osdu:wks:AbstractMaster:1.0.0" + }, + { + "title": "title-1", + "type": "object", + "properties": { + "WellID": { + "type": "string", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Well:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "Well" + } + ] + }, + "SequenceNumber": { + "description": "A number that indicates the order in which wellbores were drilled.", + "type": "integer" + }, + "VerticalMeasurements": { + "description": "List of all depths and elevations pertaining to the wellbore, like, plug back measured depth, total measured depth, KB elevation", + "type": "array", + "x-osdu-indexing": { + "type": "nested" + }, + "items": { + "allOf": [ + { + "title": "title-3", + "type": "object", + "properties": { + "VerticalMeasurementID": { + "description": "The ID for a distinct vertical measurement within the Wellbore VerticalMeasurements array so that it may be referenced by other vertical measurements if necessary.", + "type": "string" + } + } + }, + { + "$ref": "osdu:wks:AbstractFacilityVerticalMeasurement:1.0.0" + } + ] + } + }, + "DrillingReasons": { + "description": "The history of drilling reasons of the wellbore.", + "type": "array", + "items": { + "$ref": "osdu:wks:AbstractWellboreDrillingReason:1.0.0" + } + }, + "KickOffWellbore": { + "description": "This is a pointer to the parent wellbore. The wellbore that starts from top has no parent.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:master-data\\-\\-Wellbore:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "master-data", + "EntityType": "Wellbore" + } + ] + }, + "TrajectoryTypeID": { + "description": "Describes the predominant shapes the wellbore path can follow if deviated from vertical. Sample Values: Horizontal, Vertical, Directional.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-WellboreTrajectoryType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "WellboreTrajectoryType" + } + ] + }, + "DefinitiveTrajectoryID": { + "description": "SRN of Wellbore Trajectory which is considered the authoritative or preferred version.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:work-product-component\\-\\-WellboreTrajectory:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "work-product-component", + "EntityType": "WellboreTrajectory" + } + ] + }, + "TargetFormation": { + "description": "The Formation of interest for which the Wellbore is drilled to interact with. The Wellbore may terminate in a lower formation if the requirement is to drill through the entirety of the target formation, therefore this is not necessarily the Formation at TD.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-GeologicalFormation:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "GeologicalFormation" + } + ] + }, + "PrimaryMaterialID": { + "description": "The primary material injected/produced from the wellbore.", + "type": "string", + "pattern": "^[\\w\\-\\.]+:reference-data\\-\\-MaterialType:[\\w\\-\\.\\:\\%]+:[0-9]*$", + "x-osdu-relationship": [ + { + "GroupType": "reference-data", + "EntityType": "MaterialType" + } + ] + }, + "DefaultVerticalMeasurementID": { + "description": "The default datum reference point, or zero depth point, used to determine other points vertically in a wellbore. References an entry in the Vertical Measurements array of this wellbore.", + "type": "string" + }, + "ProjectedBottomHoleLocation": { + "description": "The bottom hole location of the wellbore denoted by a projected horizontal coordinate reference system (Horizontal CRS), such a UTM zone. 'Projected' in this property does not mean 'planned' or 'projected-to-bit'. If both GeographicBottomHoleLocation and ProjectedBottomHoleLocation properties are populated on this wellbore, they must identify the same point, just in different CRSs.", + "$ref": "osdu:wks:AbstractSpatialLocation:1.0.0" + }, + "GeographicBottomHoleLocation": { + "description": "The bottom hole location of the wellbore denoted by a specified geographic horizontal coordinate reference system (Horizontal CRS), such as WGS84, NAD27, or ED50. If both GeographicBottomHoleLocation and ProjectedBottomHoleLocation properties are populated on this wellbore, they must identify the same point, just in different CRSs.", + "$ref": "osdu:wks:AbstractSpatialLocation:1.0.0" + } + } + }, + { + "$ref": "osdu:wks:AbstractFacility:1.0.0" + }, + { + "title": "title-2", + "type": "object", + "properties": { + "ExtensionProperties": { + "type": "object" + } + } + } + ] + } + }, + "required": [ + "kind", + "acl", + "legal" + ], + "additionalProperties": false, + "x-osdu-inheriting-from-kind": [] + } diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/pass-with-title/schema-with-oneOf-Orderchanged-Title-WithRefAttr.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass-with-title/schema-with-oneOf-Orderchanged-Title-WithRefAttr.json new file mode 100644 index 0000000000000000000000000000000000000000..f393ed8667894064c9e64132b8521a2e8e21a637 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass-with-title/schema-with-oneOf-Orderchanged-Title-WithRefAttr.json @@ -0,0 +1,39 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + "test":{ + "type": "string" + } + }, + "properties": { + "AddressLine1": { "type": "string" }, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1" ], + "oneOf": [ + { + "title": "title-2", + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + }, + { + "$ref": "#definitions/test" + }, + { + "title": "title-1", + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/pass-with-title/schema-with-oneOf-Orderchanged-Title.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass-with-title/schema-with-oneOf-Orderchanged-Title.json new file mode 100644 index 0000000000000000000000000000000000000000..c0f321a46308e5dbd695b936ff52a296920ff069 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass-with-title/schema-with-oneOf-Orderchanged-Title.json @@ -0,0 +1,32 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string" }, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1" ], + "oneOf": [ + { + "title": "title-2", + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + }, + { + "title": "title-1", + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-additional-attribute.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-additional-attribute.json new file mode 100644 index 0000000000000000000000000000000000000000..9e71b01c71b9fe85c705e7dd3ea66363248dc3ee --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-additional-attribute.json @@ -0,0 +1,64 @@ +{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "additionalProperties": true, + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + }, + "Phone":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-addprop-add-true.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-addprop-add-true.json new file mode 100644 index 0000000000000000000000000000000000000000..1e3446ee7b445e0d54716a7aff62fac594a919fd --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-addprop-add-true.json @@ -0,0 +1,61 @@ +{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "additionalProperties": true, + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-oneOf-addelement-without-title.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-oneOf-addelement-without-title.json new file mode 100644 index 0000000000000000000000000000000000000000..d30fc0ced83079f30825d16c2387ce4b9aed0742 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-oneOf-addelement-without-title.json @@ -0,0 +1,75 @@ +{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "additionalProperties":true, + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + }, + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "Pincode":{ + "type":"string" + } + }, + "required":[ + "Pincode" + ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-reqprop-changeinorder.json b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-reqprop-changeinorder.json new file mode 100644 index 0000000000000000000000000000000000000000..1e3446ee7b445e0d54716a7aff62fac594a919fd --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-reqprop-changeinorder.json @@ -0,0 +1,61 @@ +{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "additionalProperties": true, + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/original-schema.json b/schema-core/src/test/resources/schema_compare/original-schema.json new file mode 100644 index 0000000000000000000000000000000000000000..127e3f3de6ffe9da90eee95a96809052c895d96e --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/original-schema.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string" }, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1" ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + }, + { + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-all-permissible-changes.json b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-all-permissible-changes.json new file mode 100644 index 0000000000000000000000000000000000000000..f3dba875beb05fd00cfa0f3dd417bd0ab66c114d --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-all-permissible-changes.json @@ -0,0 +1,60 @@ +{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1" + ], + "oneOf":[ + { + "title":"title-1", + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-comment-added.json b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-comment-added.json new file mode 100644 index 0000000000000000000000000000000000000000..b66a36f16221cc7c7ac6a30069617b57065b9e11 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-comment-added.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "$comment": "This is a test schema", + "type": "object", + "title": "My schema", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string", + "$comment": "This is a mandatory attribute"}, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1" ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + }, + { + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-examples-added.json b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-examples-added.json new file mode 100644 index 0000000000000000000000000000000000000000..1b5484489639fd09115d197cd943e53244068b78 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-examples-added.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string" }, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1" ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string", + "examples": [ + "98052-7329" + ] } + }, + "required": [ "ZipCode" ] + }, + { + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-id-added.json b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-id-added.json new file mode 100644 index 0000000000000000000000000000000000000000..a8f93e3e267d8b25e7168e02e1b88369c3f12bba --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-id-added.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type": "object", + "title": "My schema", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string" }, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1" ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + }, + { + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-title-changed.json b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-title-changed.json new file mode 100644 index 0000000000000000000000000000000000000000..fa16975d2d507373d7c78677effa383622d16fce --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-title-changed.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "$comment": "This is a test schema", + "type": "object", + "title": "My schema - Changed", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string", + "$comment": "This is a mandatory attribute"}, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1" ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + }, + { + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-xosdu-added.json b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-xosdu-added.json new file mode 100644 index 0000000000000000000000000000000000000000..bcee7be6c7032b87d482fc60f070f765501229b4 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-xosdu-added.json @@ -0,0 +1,33 @@ +{ + "x-osdu-license":"Landmark copyright placeholder", + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "$comment": "This is a test schema", + "type": "object", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string", + "$comment": "This is a mandatory attribute"}, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1" ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + }, + { + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-wtih-description-added.json b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-wtih-description-added.json new file mode 100644 index 0000000000000000000000000000000000000000..04ecdd63aaa5fe1202ea29966ee9aeaf546e6700 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-wtih-description-added.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string", + "description": "This should be the apartment number and building name"}, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1" ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + }, + { + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} \ No newline at end of file diff --git a/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-wtih-pattern-added.json b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-wtih-pattern-added.json new file mode 100644 index 0000000000000000000000000000000000000000..92c2576c6de81d2a7a74e8a854659a0258a4f8e0 --- /dev/null +++ b/schema-core/src/test/resources/schema_compare/patch_level_changes/schema-wtih-pattern-added.json @@ -0,0 +1,53 @@ +{ + "$schema":"http://json-schema.org/draft-07/schema#", + "type":"object", + "title":"My schema", + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$" + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} \ No newline at end of file diff --git a/testing/schema-test-azure/pom.xml b/testing/schema-test-azure/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..ee3d55f5631c107392be858baff742d62c7abce6 --- /dev/null +++ b/testing/schema-test-azure/pom.xml @@ -0,0 +1,168 @@ + + 4.0.0 + + + org.opengroup.osdu + os-schema-test + 0.10.0-SNAPSHOT + ../pom.xml + + + schema-test-azure + + 0.7.0 + 0.6.1 + 1.8 + 1.8 + UTF-8 + + + + + + org.opengroup.osdu + os-schema-core + + + ch.qos.logback + logback-classic + + + org.apache.logging.log4j + log4j-to-slf4j + + + 0.0.1 + + + + + io.rest-assured + rest-assured + 3.2.0 + + + + io.cucumber + cucumber-java8 + 5.4.0 + test + + + + io.cucumber + cucumber-junit + 5.4.0 + test + + + + io.cucumber + cucumber-guice + 5.4.0 + test + + + + com.google.inject + guice + 4.2.0 + test + + + + com.google.cloud + google-cloud-storage + 1.76.0 + + + + org.opengroup.osdu + core-lib-azure + ${os-core-lib-azure.version} + + + + org.opengroup.osdu.core.aws + os-core-lib-aws + 0.3.16 + + + + org.opengroup.osdu + os-core-lib-ibm + ${os-core-lib-ibm.version} + + + + + + + + org.opengroup.osdu + core-lib-azure + ${os-core-lib-azure.version} + pom + import + + + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.0.0-M3 + + + pre-integration-test + + integration-test + + + ${skipItTests} + + org.opengroup.osdu.schema.runner.PreIntegrationTestsRunner + + + + + integration-test + + integration-test + + + ${skipItTests} + + none + + + org.opengroup.osdu.schema.runner.SchemaServiceTestsRunner + + + + + post-integration-test + + integration-test + + + ${skipItTests} + + org.opengroup.osdu.schema.runner.TearDownTestsRunner + + + + + verify + + verify + + + + + + + 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 new file mode 100644 index 0000000000000000000000000000000000000000..c3fba017791efc4b1e3bee23a118a7d49b682d63 --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/constants/HttpConnection.java @@ -0,0 +1,10 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..4b4946a3f9d7c7a81ddcf69adf59fbe28afab833 --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/constants/TestConstants.java @@ -0,0 +1,57 @@ +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 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 new file mode 100644 index 0000000000000000000000000000000000000000..f0cdd4e8480919496e141e78551bab90c7853ba0 --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/runner/PreIntegrationTestsRunner.java @@ -0,0 +1,13 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..385545c2d2ae888156ee6c1ce23a00f6f095c045 --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/runner/SchemaServiceTestsRunner.java @@ -0,0 +1,13 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..71de8088ebc7ab9797fb7eafe267764df965288d --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/runner/TearDownTestsRunner.java @@ -0,0 +1,13 @@ +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/LocalSetupStepDef.java b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/LocalSetupStepDef.java new file mode 100644 index 0000000000000000000000000000000000000000..c85be6bcba82f1307ed6a89aa3bce80899635162 --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/LocalSetupStepDef.java @@ -0,0 +1,12 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..a043eee8bd028866525de30b8dc04aa2659d0e23 --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_GET.java @@ -0,0 +1,182 @@ +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 LIST_OF_AVAILABLE_SCHEMAS = new TreeSet(); + + private final static Logger LOGGER = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); + List> list_schemaParameterMap = new ArrayList>(); + + 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 authHeaders = new HashMap(); + 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 authHeaders = new HashMap(); + 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 queryParams = new HashMap(); + 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 schemaIdentityMap = new HashMap(); + + 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) schemaIdentityMap); + } + LOGGER.log(Level.INFO, "SchemaParameterMapList - " + this.list_schemaParameterMap.toString()); + } + } + + private void verifySchemaInfoResponse(String parameterName, String parameterVal) { + for (HashMap 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 new file mode 100644 index 0000000000000000000000000000000000000000..5935d0247e21fe62a5721f31291365b2b7efd306 --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_PUT.java @@ -0,0 +1,437 @@ +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> list_schemaParameterMap = new ArrayList>(); + + 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 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 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 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 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 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 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 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 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 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 new file mode 100644 index 0000000000000000000000000000000000000000..cd2d0bbf1b101187957e1f8954f6bedc7e14fa31 --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/TearDownStepDefs.java @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..b29857a31a213ae7a7c5d02ad0cd92d615d3fd77 --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/model/HttpRequest.java @@ -0,0 +1,37 @@ +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 requestHeaders = new HashMap<>(); + + @Builder.Default + Map queryParams = new HashMap<>(); + + @Builder.Default + Map 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 new file mode 100644 index 0000000000000000000000000000000000000000..a162b40f1254708ec9df50db3d61df9eb4c1ba8f --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/model/HttpResponse.java @@ -0,0 +1,17 @@ +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> 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 new file mode 100644 index 0000000000000000000000000000000000000000..471f34a7421dcc4fe4e01832f6aac01b966c7dae --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/model/SchemaServiceScope.java @@ -0,0 +1,106 @@ +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 authHeaders; + private Map 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 new file mode 100644 index 0000000000000000000000000000000000000000..72ecdb9a486b63b3d9ebdb5e0ea4953a58dd215a --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/AuthUtil.java @@ -0,0 +1,22 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..4da7d9b2e57f9993b400c4f22173b3c65c28c228 --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/FileUtils.java @@ -0,0 +1,28 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..aaeb18eab394e6e3bdace99fbd20b74f469ee1ee --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/HttpClient.java @@ -0,0 +1,10 @@ +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 send(HttpRequest httpRequest, Class 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 new file mode 100644 index 0000000000000000000000000000000000000000..8b5a8d6f1dcc0081ff82a3ed59684a00376b3934 --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/HttpClientFactory.java @@ -0,0 +1,12 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..5e29093f0de01f0cc22ac3d205cc28220768f446 --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/JsonUtils.java @@ -0,0 +1,19 @@ +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 fromJson(String json, Class 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 new file mode 100644 index 0000000000000000000000000000000000000000..6d5b96a1c6d05a704a40b9d0348642a47be12d2d --- /dev/null +++ b/testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/RestAssuredClient.java @@ -0,0 +1,73 @@ +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> 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 send(HttpRequest httpRequest, Class classOfT) { + HttpResponse httpResponse = send(httpRequest); + return JsonUtils.fromJson(httpResponse.getBody(), classOfT); + } +} diff --git a/testing/schema-test-azure/src/test/resources/features/IntegrationTest_SchemaService_PUT.feature b/testing/schema-test-azure/src/test/resources/features/IntegrationTest_SchemaService_PUT.feature new file mode 100644 index 0000000000000000000000000000000000000000..01c911a9b55e48adadc0d8935b85716a13dac5bc --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/features/IntegrationTest_SchemaService_PUT.feature @@ -0,0 +1,163 @@ +Feature: To verify functionality of PUT schema Service + + ### Commons test steps are accomplished here + Background: Common steps for all tests are executed + Given I generate user token and set request headers for "TENANT1" + Given I get latest schema with authority, source, entityType as "OSDUTest", "testSource", "testEntity" respectively + Given I generate user token and set request headers for system API + Given I hit schema service PUT API with "/input_payloads/postInPrivateScope_positiveScenario.json" only if status is not development + + @SchemaServiceAzure + Scenario Outline: Verify that Schema Service's PUT API works correctly without scope field + Given I hit schema service PUT API with + Then put schema service should respond back with + And schema service should respond back with and + + Examples: + | InputPayload | ReponseStatusCodeForPUT | ReponseStatusCodeForGET | ResponseMessageforGET | + | "/input_payloads/postInPrivateScope_positiveScenario.json" | "200" | "200" | "/output_payloads/ResolvedSchema.json" | + + @SchemaServiceAzure + Scenario Outline: Verify that Schema Service's PUT API works correctly and update schema properly + Given I hit schema service PUT API with + And put schema service should respond back with + When I hit schema service PUT API with + Then put schema service should respond back with + And schema service should respond back with and + + Examples: + | InputPayload | ReponseStatusCodeForPUT | ReponseStatusCodeForGET | ResponseMessageforGET | UpdatedInputPayload | + | "/input_payloads/postInPrivateScope_positiveScenario.json" | "200" | "200" | "/output_payloads/UpdatedResolvedSchema.json" | "/input_payloads/putUpdatedSchema_positiveScenario.json" | + + @SchemaServiceAzure + Scenario Outline: Verify that Schema Service's PUT API throws error if put request tries to create new record without development status + Given I hit schema service PUT API with and mark schema as for next major version + Then service should respond back with error and + + Examples: + | InputPayload | ReponseStatusCode | ResponseMessage | status | + | "/input_payloads/postInPrivateScope_positiveScenario.json" | "400" | "/output_payloads/SchemaPut_InvalidStatusMessage.json" | "OBSOLETE" | + | "/input_payloads/postInPrivateScope_positiveScenario.json" | "400" | "/output_payloads/SchemaPut_InvalidStatusMessage.json" | "PUBLISHED" | + + @SchemaServiceAzure + Scenario Outline: Verify that Schema Service's PUT API throws error if modification in schemaInfo is requested + Given I hit schema service PUT API with with different entityType + Then put schema service should respond back with + And schema service should respond back with and + + Examples: + | InputPayload | ReponseStatusCodeForPUT | ReponseStatusCodeForGET | ResponseMessageforGET | + | "/input_payloads/PUT_ModifySchemaInfo.json" | "201" | "200" | "/output_payloads/UpdatedSchema_EntityTypeUpdate.json" | + + @SchemaServiceAzure + Scenario Outline: Verify that Schema Service's PUT API validates input payload + Given I hit schema service PUT API with + Then service should respond back with error and + + Examples: + | InputPayload | ReponseStatusCode | ResponseMessage | + | "/input_payloads/inputPayloadWithIncorrectJSON.json" | "400" | "/output_payloads/SchemaPost_IncorrectJsonError.json" | + + @SchemaServiceAzure + Scenario Outline: Verify that Schema Service's PUT API responds as bad request for wrong value of $ref attribute in schema input + Given I hit schema service PUT API with + Then service should respond back with error and + + Examples: + | InputPayload | ReponseStatusCode | ResponseMessage | + | "/input_payloads/postSchema_InvalidRefSchemaObject.json" | "400" | "/output_payloads/PostSchema_InvalidRefSchemaObject.json" | + | "/input_payloads/postSchema_RefNotResolvable.json" | "400" | "/output_payloads/PostSchema_RefNotResolvable.json" | + + @SchemaServiceAzure + Scenario Outline: Verify that Schema Service's PUT API responds as bad request for wrong value of $ref attribute in schema input + Given I hit schema service PUT API with with next major version + Then service should respond back with error and + + Examples: + | InputPayload | ReponseStatusCode | ResponseMessage | + | "/input_payloads/postSchema_InvalidRefSchemaObject.json" | "400" | "/output_payloads/PostSchema_InvalidRefSchemaObject.json" | + | "/input_payloads/postSchema_RefNotResolvable.json" | "400" | "/output_payloads/PostSchema_RefNotResolvable.json" | + + @SchemaServiceAzure + Scenario Outline: Verify that Schema Service's PUT API validates input payload for JSON correctness + Given I hit schema service PUT API with + Then service should respond back with error and + + Examples: + | InputPayload | ReponseStatusCode | ResponseMessage | + | "/input_payloads/inputPayloadWithIncorrectJSON.json" | "400" | "/output_payloads/SchemaPost_IncorrectJsonError.json" | + + @SchemaServiceAzure + Scenario Outline: Verify that Schema Service's PUT API validates input payload for JSON correctness + Given I hit schema service PUT API with with next major version + Then service should respond back with error and + + Examples: + | InputPayload | ReponseStatusCode | ResponseMessage | + | "/input_payloads/inputPayloadWithIncorrectJSON.json" | "400" | "/output_payloads/SchemaPost_IncorrectJsonError.json" | + + #@SchemaServiceAzure Commenting this tag for now since this scenario for "common" is failing + Scenario Outline: Verify that Schema Service's PUT API registers authority, source, entity and creates a private schema correctly with $ref attribute + Given I hit schema service PUT API with + Then service should respond back with and and scope whould be + + Examples: + | InputPayload | ReponseStatusCode | ResponseMessage | responceScope | + | "/input_payloads/postSchemaServiceWithRef_positiveScenario.json" | "200" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "INTERNAL" | + + @SchemaServiceAzure + Scenario Outline: Verify that Schema Service's PUT API registers authority, source, entity and creates a private schema correctly with $ref attribute + Given I hit schema service PUT API with with next major version + Then service should respond back with and and scope whould be + + Examples: + | parameter | value | latestVersion | InputPayload | otherTenant | ReponseStatusCode | ResponseMessage | responceScope | + | "authority" | "OSDUTest" | "true" | "/input_payloads/postSchemaServiceWithRef_positiveScenario.json" | "COMMON" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "INTERNAL" | + + @SchemaServiceAzure + Scenario Outline: Verify that create Schema Service supersededBy functionality work correctly + Given I hit schema service PUT API for supersededBy with + Then the put service for supersededBy should respond back with + + Examples: + | InputPayload | ReponseStatusCode | + | "/input_payloads/supercededInputPayload_positive.json" | "201" | + + @SchemaServiceAzure + Scenario Outline: Verify that update Schema Service supersededBy functionality work correctly + Given I hit schema service PUT API with for superceded input + Then the put service for supersededBy should respond back with + + Examples: + | InputPayload | ReponseStatusCode | + | "/input_payloads/postSchemaService_EmptySchema.json" | "200" | + + @SchemaServiceAzure + Scenario Outline: Verify that Schema Service's PUT API throws correct error if input payload is not valid + Given I hit schema service PUT API with + Then service should respond back with error and + + Examples: + | InputPayload | ReponseStatusCode | ResponseMessage | + | "/input_payloads/postSchema_withEntityAttributeInPayload.json" | "400" | "/output_payloads/PostSchema_EntityNotAllowedError.json" | + | "/input_payloads/postSchema_flattenedSchemaAsInput.json" | "400" | "/output_payloads/PostSchema_InvalidInputSchemaError.json" | + + @SchemaServiceAzure + Scenario Outline: Verify that Schema Service's PUT API throws correct error if input payload is not valid + Given I hit schema service PUT API with + Then service should respond back with error and + + Examples: + | InputPayload | ReponseStatusCode | ResponseMessage | + | "/input_payloads/postSchema_withEntityAttributeInPayload.json" | "400" | "/output_payloads/PostSchema_EntityNotAllowedError.json" | + | "/input_payloads/postSchema_flattenedSchemaAsInput.json" | "400" | "/output_payloads/PostSchema_InvalidInputSchemaError.json" | + + @SchemaServiceAzure + Scenario Outline: Verify whether schema can not be registered with already existing major, but increased minor version + Given I hit schema service PUT API with + Given I hit schema service PUT API with with increased minor version only + Then service should respond back with error and + + Examples: + | EmptyInputPayload | InputPayload | ReponseStatusCode | ResponseMessage | + | "/input_payloads/postSchemaService_EmptySchema.json" | "/input_payloads/inputPayloadWithExistingVersion.json" | "400" | "/output_payloads/SchemaPost_BreakingChangeError.json" | diff --git a/testing/schema-test-azure/src/test/resources/features/post_integration.feature b/testing/schema-test-azure/src/test/resources/features/post_integration.feature new file mode 100644 index 0000000000000000000000000000000000000000..518edfd1b714099bb02a679bf8633f7a57981a15 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/features/post_integration.feature @@ -0,0 +1,2 @@ +Feature: Delete files generated during integration testing. + diff --git a/testing/schema-test-azure/src/test/resources/features/pre_integration.feature b/testing/schema-test-azure/src/test/resources/features/pre_integration.feature new file mode 100644 index 0000000000000000000000000000000000000000..ba3581bc8fac76fe749177c6929d026acda4b6c5 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/features/pre_integration.feature @@ -0,0 +1 @@ +Feature: Setup required for schema service dev sanity is done here. diff --git a/testing/schema-test-azure/src/test/resources/input_payloads/PUT_ModifySchemaInfo.json b/testing/schema-test-azure/src/test/resources/input_payloads/PUT_ModifySchemaInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..ca6e95f4efded812604dc1d012d6361e8e728a5a --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/input_payloads/PUT_ModifySchemaInfo.json @@ -0,0 +1,21 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "OSDUTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 5, + "schemaVersionMinor": 6, + "schemaVersionPatch": 0, + "id": "OSDUTest:testSource:testEntity:5.5.0" + }, + "status": "DEVELOPMENT", + "scope": "INTERNAL", + "createdBy": "John Smith", + "dateCreated": "2019-05-27T11:16:03Z" + }, + "schema": { + "ValidationString": "Schema modified by PUT operation", + "definitions": {} + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/input_payloads/inputPayloadWithExistingVersion.json b/testing/schema-test-azure/src/test/resources/input_payloads/inputPayloadWithExistingVersion.json new file mode 100644 index 0000000000000000000000000000000000000000..460f89ef9d5a2de5694cca705843360e0a6a3b1e --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/input_payloads/inputPayloadWithExistingVersion.json @@ -0,0 +1,17 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "OSDUTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 291, + "schemaVersionMinor": 257, + "schemaVersionPatch": 0, + "id": "OSDUTest:testSource:testEntity:1.1.0" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "test" : "test" + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/input_payloads/inputPayloadWithIncorrectJSON.json b/testing/schema-test-azure/src/test/resources/input_payloads/inputPayloadWithIncorrectJSON.json new file mode 100644 index 0000000000000000000000000000000000000000..501c270459c4d9d0b4f68f7f528d0a6f608e6eb1 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/input_payloads/inputPayloadWithIncorrectJSON.json @@ -0,0 +1,18 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "OSDUTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 5, + "schemaVersionMinor": 5, + "schemaVersionPatch": 5, + "id": "DevSanity:testSource:testEntity:5.5.5" + }, + "status": "OBSOLETE", + "scope": "DEVELOPMENT", + "createdBy": "John Smith", + "dateCreated": "2019-05-27T11:16:03Z" + } + +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/input_payloads/postInPrivateScope_positiveScenario.json b/testing/schema-test-azure/src/test/resources/input_payloads/postInPrivateScope_positiveScenario.json new file mode 100644 index 0000000000000000000000000000000000000000..a25d2ca7b0f95ef958215741cd677e6dc470271d --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/input_payloads/postInPrivateScope_positiveScenario.json @@ -0,0 +1,544 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "OSDUTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 1, + "schemaVersionMinor": 1, + "schemaVersionPatch": 0, + "id": "OSDUTest:testSource:testEntity:1.1.0" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "The entity well.", + "title": "Well", + "type": "object", + "x-slb-lifecycle-state": "published", + "definitions": { + "FeatureCollection": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "GeoJSON FeatureCollection", + "type": "object", + "required": [ + "type", + "features" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "FeatureCollection" + ] + }, + "features": { + "type": "array", + "items": { + "title": "GeoJSON Feature", + "type": "object", + "required": [ + "type", + "properties", + "geometry" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "geometry": { + "oneOf": [ + { + "type": "null" + }, + { + "title": "GeoJSON Point", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + }, + "type": { + "type": "string", + "enum": [ + "Point" + ] + } + } + }, + { + "title": "GeoJSON LineString", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "minItems": 2, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + }, + "type": { + "type": "string", + "enum": [ + "LineString" + ] + } + } + }, + { + "title": "GeoJSON Polygon", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "minItems": 4, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "Polygon" + ] + } + } + }, + { + "title": "GeoJSON MultiPoint", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiPoint" + ] + } + } + }, + { + "title": "GeoJSON MultiLineString", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiLineString" + ] + } + } + }, + { + "title": "GeoJSON MultiPolygon", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "type": "array", + "items": { + "minItems": 4, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiPolygon" + ] + } + } + }, + { + "title": "GeoJSON GeometryCollection", + "type": "object", + "required": [ + "type", + "geometries" + ], + "properties": { + "geometries": { + "type": "array", + "items": { + "oneOf": [ + { + "title": "GeoJSON Point", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + }, + "type": { + "type": "string", + "enum": [ + "Point" + ] + } + } + }, + { + "title": "GeoJSON LineString", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "minItems": 2, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + }, + "type": { + "type": "string", + "enum": [ + "LineString" + ] + } + } + }, + { + "title": "GeoJSON Polygon", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "minItems": 4, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "Polygon" + ] + } + } + }, + { + "title": "GeoJSON MultiPoint", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiPoint" + ] + } + } + }, + { + "title": "GeoJSON MultiLineString", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiLineString" + ] + } + } + }, + { + "title": "GeoJSON MultiPolygon", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "type": "array", + "items": { + "minItems": 4, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiPolygon" + ] + } + } + } + ] + } + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "type": { + "type": "string", + "enum": [ + "GeometryCollection" + ] + } + } + } + ] + }, + "type": { + "type": "string", + "enum": [ + "Feature" + ] + }, + "properties": { + "oneOf": [ + { + "type": "null" + }, + { + "type": "object" + } + ] + } + } + } + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + }, + "$id": "https://geojson.org/schema/FeatureCollection.json" + } + } + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/input_payloads/postSchemaServiceWithRef_positiveScenario.json b/testing/schema-test-azure/src/test/resources/input_payloads/postSchemaServiceWithRef_positiveScenario.json new file mode 100644 index 0000000000000000000000000000000000000000..e434331fcf2c76e6252d814f5a12935d24f06f5e --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/input_payloads/postSchemaServiceWithRef_positiveScenario.json @@ -0,0 +1,67 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "OSDUTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 1, + "schemaVersionMinor": 1, + "schemaVersionPatch": 0, + "id": "OSDUTest:testSource:testEntity:1.1.0" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema":"http://json-schema.org/draft-07/schema#", + "x-slb-lifecycle-state":"published", + "description":"Theentitywell.", + "title":"Well", + "type":"object", + "definitions":{ + "anyCrsFeatureCollection.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "anyCrsFeatureCollection", + "type": "object" + }, + "testSource..wks..well.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "testSource..wks..well", + "type": "object" + } + }, + "properties":{ + "locationOriginalCRS":{ + "description":"Thewell'soriginallocationasAnyCrsFeatureCollection-astructuresimilartobutdistinctfromGeoJSON.", + "title":"OriginalCRSLocation", + "$ref":"#/definition/anyCrsFeatureCollection.1.0" + }, + "allOf":{ + "$ref":"#/definition/testSource..wks..well.1.0" + }, + "locationWGS84":{ + "description":"Thewell'slocationasGeoJSONFeatureCollection.", + "title":"WGS84Location", + "$ref":"https://geojson.org/schema/FeatureCollection.json", + "example":{ + "features":[ + { + "geometry":{ + "coordinates":[ + -92.11569999999999, + 29.8823, + 153.4779442519685 + ], + "type":"Point" + }, + "type":"Feature", + "properties":{ + "name":"Newton2-31" + } + } + ], + "type":"FeatureCollection" + } + } + } +} +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/input_payloads/postSchemaService_EmptySchema.json b/testing/schema-test-azure/src/test/resources/input_payloads/postSchemaService_EmptySchema.json new file mode 100644 index 0000000000000000000000000000000000000000..23d3443754e5260874b6308ee4b0d6283c4c1154 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/input_payloads/postSchemaService_EmptySchema.json @@ -0,0 +1,16 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "OSDUTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 1, + "schemaVersionMinor": 1, + "schemaVersionPatch": 0, + "id": "OSDUTest:testSource:testEntity:1.1.0" + }, + "status": "DEVELOPMENT" + }, + "schema": { + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/input_payloads/postSchema_InvalidRefSchemaObject.json b/testing/schema-test-azure/src/test/resources/input_payloads/postSchema_InvalidRefSchemaObject.json new file mode 100644 index 0000000000000000000000000000000000000000..eb4220da85a15c59d7d36f79663f72cc315add59 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/input_payloads/postSchema_InvalidRefSchemaObject.json @@ -0,0 +1,49 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "OSDUTest", + "source": "testSource", + "schemaVersionMajor": 1, + "schemaVersionMinor": 1, + "schemaVersionPatch": 0, + "entityType": "wellbore" + }, + "status": "DEVELOPMENT", + "scope": "SHARED" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Wellbore", + "description": "The entity wellbore.", + "type": "object", + "definitions": {}, + "properties": { + "uwi": { + "description": "The unique wellbore identifier, aka. API number, US well number or UBHI. Codes can have 10, 12 or 14 digits depending on the availability of directional sidetrack (2 digits) and event sequence codes (2 digits).", + "example": [ + "42-501-20130", + "42-501-20130-01-02" + ], + "title": "Unique Well Identifier", + "type": "string", + "x-slb-aliasProperties": [ + "petrel:UWI", + "witsml:SuffixAPI", + "drillplan:uwi" + ] + }, + "allOf": { + "$ref": "https://abc.com/" + }, + "wellboreName": { + "description": "The wellbore name", + "title": "Wellbore Name", + "type": "string", + "x-slb-aliasProperties": [ + "ocean:BoreholeName", + "witsml:NameLegal" + ] + } + } + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/input_payloads/postSchema_RefNotResolvable.json b/testing/schema-test-azure/src/test/resources/input_payloads/postSchema_RefNotResolvable.json new file mode 100644 index 0000000000000000000000000000000000000000..e6ad482a4ed13d43ba1d15b7624ddaaae764ee20 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/input_payloads/postSchema_RefNotResolvable.json @@ -0,0 +1,49 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "slb", + "source": "testSource", + "schemaVersionMajor": 1, + "schemaVersionMinor": 1, + "schemaVersionPatch": 0, + "entityType": "wellbore" + }, + "status": "DEVELOPMENT", + "scope": "SHARED" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Wellbore", + "description": "The entity wellbore.", + "type": "object", + "definitions": {}, + "properties": { + "uwi": { + "description": "The unique wellbore identifier, aka. API number, US well number or UBHI. Codes can have 10, 12 or 14 digits depending on the availability of directional sidetrack (2 digits) and event sequence codes (2 digits).", + "example": [ + "42-501-20130", + "42-501-20130-01-02" + ], + "title": "Unique Well Identifier", + "type": "string", + "x-slb-aliasProperties": [ + "petrel:UWI", + "witsml:SuffixAPI", + "drillplan:uwi" + ] + }, + "allOf": { + "$ref": "https://notexistingref" + }, + "wellboreName": { + "description": "The wellbore name", + "title": "Wellbore Name", + "type": "string", + "x-slb-aliasProperties": [ + "ocean:BoreholeName", + "witsml:NameLegal" + ] + } + } + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/input_payloads/postSchema_flattenedSchemaAsInput.json b/testing/schema-test-azure/src/test/resources/input_payloads/postSchema_flattenedSchemaAsInput.json new file mode 100644 index 0000000000000000000000000000000000000000..82b55eff83a2899f222c41a75dd42ebc2536385a --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/input_payloads/postSchema_flattenedSchemaAsInput.json @@ -0,0 +1,123 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "OSDUTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 11, + "schemaVersionMinor": 0, + "schemaVersionPatch": 0 + }, + "status": "DEVELOPMENT" + }, + "schema": [ + { + "path": "Original CRS", + "kind": "string" + }, + { + "path": "Original CRS Name", + "kind": "string" + }, + { + "path": "Top Y", + "kind": "double" + }, + { + "path": "Field", + "kind": "string" + }, + { + "path": "Project Coordinate System", + "kind": "string" + }, + { + "path": "Permanent Elevation [m]", + "kind": "double" + }, + { + "path": "Spud Date", + "kind": "string" + }, + { + "path": "Current Status", + "kind": "string" + }, + { + "path": "Original Coord System Name", + "kind": "string" + }, + { + "path": "Remarks", + "kind": "string" + }, + { + "path": "Original Top X", + "kind": "string" + }, + { + "path": "Permanent Elevation Ref", + "kind": "string" + }, + { + "path": "Project Elevation Ref", + "kind": "string" + }, + { + "path": "Class", + "kind": "string" + }, + { + "path": "Primary Source", + "kind": "string" + }, + { + "path": "Country", + "kind": "string" + }, + { + "path": "Well Name", + "kind": "string" + }, + { + "path": "Row Status", + "kind": "string" + }, + { + "path": "Original Top Y", + "kind": "string" + }, + { + "path": "Top X", + "kind": "double" + }, + { + "path": "Short Name", + "kind": "string" + }, + { + "path": "UWI", + "kind": "string" + }, + { + "path": "Original Coord System Id", + "kind": "long" + }, + { + "path": "Operator", + "kind": "string" + }, + { + "path": "_crc", + "kind": "int" + }, + { + "path": "_dataset_descriptor", + "kind": "link" + }, + { + "path": "dlLatLongWGS84", + "kind": "core:dl:geopoint:1.0.0" + } + ] +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/input_payloads/postSchema_withEntityAttributeInPayload.json b/testing/schema-test-azure/src/test/resources/input_payloads/postSchema_withEntityAttributeInPayload.json new file mode 100644 index 0000000000000000000000000000000000000000..f1e380f39e0a024e85846268e98f1cc68b56c418 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/input_payloads/postSchema_withEntityAttributeInPayload.json @@ -0,0 +1,544 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "OSDUTest", + "source": "testSource", + "entity": "testEntity", + "schemaVersionMajor": 1, + "schemaVersionMinor": 1, + "schemaVersionPatch": 0, + "id": "OSDUTest:testSource:testEntity:1.1.0" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "The entity well.", + "title": "Well", + "type": "object", + "x-slb-lifecycle-state": "published", + "definitions": { + "FeatureCollection": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "GeoJSON FeatureCollection", + "type": "object", + "required": [ + "type", + "features" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "FeatureCollection" + ] + }, + "features": { + "type": "array", + "items": { + "title": "GeoJSON Feature", + "type": "object", + "required": [ + "type", + "properties", + "geometry" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "geometry": { + "oneOf": [ + { + "type": "null" + }, + { + "title": "GeoJSON Point", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + }, + "type": { + "type": "string", + "enum": [ + "Point" + ] + } + } + }, + { + "title": "GeoJSON LineString", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "minItems": 2, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + }, + "type": { + "type": "string", + "enum": [ + "LineString" + ] + } + } + }, + { + "title": "GeoJSON Polygon", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "minItems": 4, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "Polygon" + ] + } + } + }, + { + "title": "GeoJSON MultiPoint", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiPoint" + ] + } + } + }, + { + "title": "GeoJSON MultiLineString", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiLineString" + ] + } + } + }, + { + "title": "GeoJSON MultiPolygon", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "type": "array", + "items": { + "minItems": 4, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiPolygon" + ] + } + } + }, + { + "title": "GeoJSON GeometryCollection", + "type": "object", + "required": [ + "type", + "geometries" + ], + "properties": { + "geometries": { + "type": "array", + "items": { + "oneOf": [ + { + "title": "GeoJSON Point", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + }, + "type": { + "type": "string", + "enum": [ + "Point" + ] + } + } + }, + { + "title": "GeoJSON LineString", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "minItems": 2, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + }, + "type": { + "type": "string", + "enum": [ + "LineString" + ] + } + } + }, + { + "title": "GeoJSON Polygon", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "minItems": 4, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "Polygon" + ] + } + } + }, + { + "title": "GeoJSON MultiPoint", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiPoint" + ] + } + } + }, + { + "title": "GeoJSON MultiLineString", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiLineString" + ] + } + } + }, + { + "title": "GeoJSON MultiPolygon", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "coordinates": { + "type": "array", + "items": { + "type": "array", + "items": { + "minItems": 4, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiPolygon" + ] + } + } + } + ] + } + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + }, + "type": { + "type": "string", + "enum": [ + "GeometryCollection" + ] + } + } + } + ] + }, + "type": { + "type": "string", + "enum": [ + "Feature" + ] + }, + "properties": { + "oneOf": [ + { + "type": "null" + }, + { + "type": "object" + } + ] + } + } + } + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + }, + "$id": "https://geojson.org/schema/FeatureCollection.json" + } + } + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/input_payloads/putUpdatedSchema_positiveScenario.json b/testing/schema-test-azure/src/test/resources/input_payloads/putUpdatedSchema_positiveScenario.json new file mode 100644 index 0000000000000000000000000000000000000000..68b25824a7d3ad275f9ef9fa27bf8ad78c16c474 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/input_payloads/putUpdatedSchema_positiveScenario.json @@ -0,0 +1,28 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "OSDUTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 248, + "schemaVersionMinor": 215, + "schemaVersionPatch": 0, + "id": "OSDUTest:testSource:testEntity:248.215.0" + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "The entity well.", + "title": "Well", + "type": "object", + "x-slb-lifecycle-state": "published", + "definitions": { + "FeatureCollection": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "GeoJSON FeatureCollection", + "type": "object" + } + } + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/input_payloads/supercededInputPayload_positive.json b/testing/schema-test-azure/src/test/resources/input_payloads/supercededInputPayload_positive.json new file mode 100644 index 0000000000000000000000000000000000000000..75050c432ea8dbb32a3613dc832d81e8ecb72822 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/input_payloads/supercededInputPayload_positive.json @@ -0,0 +1,26 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "OSDUTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 651, + "schemaVersionMinor": 657, + "schemaVersionPatch": 0, + "id": "OSDUTest:testSource:testEntity1:551.552.5" + }, + "supersededBy": { + "authority": "OSDUTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 551, + "schemaVersionMinor": 552, + "schemaVersionPatch": 5, + "id": "OSDUTest:testSource:testEntity1:551.552.5" + + }, + "status": "DEVELOPMENT", + "scope": "INTERNAL" + }, + "schema": {"name": "Test"} +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_EntityNotAllowedError.json b/testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_EntityNotAllowedError.json new file mode 100644 index 0000000000000000000000000000000000000000..dc0bc73e14052e7f9b448f26aa58f4256be63ab9 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_EntityNotAllowedError.json @@ -0,0 +1,13 @@ +{ + "error": { + "code": 400, + "message": "Validation Error", + "errors": [ + { + "domain": "global", + "reason": "badRequest", + "message": "entityType must not be null" + } + ] + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_InvalidInputSchemaError.json b/testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_InvalidInputSchemaError.json new file mode 100644 index 0000000000000000000000000000000000000000..b331dfe170f714df8274afad88916aba3e5fb618 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_InvalidInputSchemaError.json @@ -0,0 +1,13 @@ +{ + "error": { + "code": 400, + "message": "Validation Error", + "errors": [ + { + "domain": "global", + "reason": "badRequest", + "message": "The input is invalid. Schema is not a valid JSON Object" + } + ] + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_InvalidRefSchemaObject.json b/testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_InvalidRefSchemaObject.json new file mode 100644 index 0000000000000000000000000000000000000000..3dcfb578c85b34633d189a31b5440df737b66500 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_InvalidRefSchemaObject.json @@ -0,0 +1,13 @@ +{ + "error": { + "code": 400, + "message": "Invalid Request, https://abc.com/ not a valid Json schema object", + "errors": [ + { + "domain": "global", + "reason": "badRequest", + "message": "Invalid Request, https://abc.com/ not a valid Json schema object" + } + ] + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_RefNotResolvable.json b/testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_RefNotResolvable.json new file mode 100644 index 0000000000000000000000000000000000000000..fda2ccc3c28d475f40145b0c6dd80163a15b46a1 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_RefNotResolvable.json @@ -0,0 +1,13 @@ +{ + "error": { + "code": 400, + "message": "Invalid Request, https://notexistingref not resolvable", + "errors": [ + { + "domain": "global", + "reason": "badRequest", + "message": "Invalid Request, https://notexistingref not resolvable" + } + ] + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/output_payloads/ResolvedSchema.json b/testing/schema-test-azure/src/test/resources/output_payloads/ResolvedSchema.json new file mode 100644 index 0000000000000000000000000000000000000000..39c757e5b19412d955fee09ca2304197fefb333b --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/output_payloads/ResolvedSchema.json @@ -0,0 +1,530 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "x-slb-lifecycle-state": "published", + "description": "The entity well.", + "title": "Well", + "type": "object", + "definitions": { + "FeatureCollection": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "GeoJSON FeatureCollection", + "type": "object", + "required": [ + "type", + "features" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "FeatureCollection" + ] + }, + "features": { + "type": "array", + "items": { + "title": "GeoJSON Feature", + "type": "object", + "required": [ + "type", + "properties", + "geometry" + ], + "properties": { + "geometry": { + "oneOf": [ + { + "type": "null" + }, + { + "title": "GeoJSON Point", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "coordinates": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + }, + "type": { + "type": "string", + "enum": [ + "Point" + ] + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + { + "title": "GeoJSON LineString", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "coordinates": { + "minItems": 2, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + }, + "type": { + "type": "string", + "enum": [ + "LineString" + ] + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + { + "title": "GeoJSON Polygon", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "coordinates": { + "type": "array", + "items": { + "minItems": 4, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "Polygon" + ] + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + { + "title": "GeoJSON MultiPoint", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "coordinates": { + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiPoint" + ] + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + { + "title": "GeoJSON MultiLineString", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "coordinates": { + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiLineString" + ] + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + { + "title": "GeoJSON MultiPolygon", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "coordinates": { + "type": "array", + "items": { + "type": "array", + "items": { + "minItems": 4, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiPolygon" + ] + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + { + "title": "GeoJSON GeometryCollection", + "type": "object", + "required": [ + "type", + "geometries" + ], + "properties": { + "type": { + "type": "string", + "enum": [ + "GeometryCollection" + ] + }, + "geometries": { + "type": "array", + "items": { + "oneOf": [ + { + "title": "GeoJSON Point", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "coordinates": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + }, + "type": { + "type": "string", + "enum": [ + "Point" + ] + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + { + "title": "GeoJSON LineString", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "coordinates": { + "minItems": 2, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + }, + "type": { + "type": "string", + "enum": [ + "LineString" + ] + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + { + "title": "GeoJSON Polygon", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "coordinates": { + "type": "array", + "items": { + "minItems": 4, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "Polygon" + ] + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + { + "title": "GeoJSON MultiPoint", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "coordinates": { + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiPoint" + ] + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + { + "title": "GeoJSON MultiLineString", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "coordinates": { + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiLineString" + ] + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + } + }, + { + "title": "GeoJSON MultiPolygon", + "type": "object", + "required": [ + "type", + "coordinates" + ], + "properties": { + "coordinates": { + "type": "array", + "items": { + "type": "array", + "items": { + "minItems": 4, + "type": "array", + "items": { + "minItems": 2, + "type": "array", + "items": { + "type": "number" + } + } + } + } + }, + "type": { + "type": "string", + "enum": [ + "MultiPolygon" + ] + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + } + } + ] + } + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + } + } + ] + }, + "type": { + "type": "string", + "enum": [ + "Feature" + ] + }, + "properties": { + "oneOf": [ + { + "type": "null" + }, + { + "type": "object" + } + ] + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + } + } + }, + "bbox": { + "minItems": 4, + "type": "array", + "items": { + "type": "number" + } + } + }, + "$id": "https://geojson.org/schema/FeatureCollection.json" + } + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/output_payloads/SchemaPost_BreakingChangeError.json b/testing/schema-test-azure/src/test/resources/output_payloads/SchemaPost_BreakingChangeError.json new file mode 100644 index 0000000000000000000000000000000000000000..0fd462e6c041b9dd0db6feeff13d4dd559bdd6f6 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/output_payloads/SchemaPost_BreakingChangeError.json @@ -0,0 +1,13 @@ +{ + "error": { + "code": 400, + "message": "Breaking changes found, please change schema major version", + "errors": [ + { + "domain": "global", + "reason": "badRequest", + "message": "Breaking changes found, please change schema major version" + } + ] + } +} diff --git a/testing/schema-test-azure/src/test/resources/output_payloads/SchemaPost_IncorrectJsonError.json b/testing/schema-test-azure/src/test/resources/output_payloads/SchemaPost_IncorrectJsonError.json new file mode 100644 index 0000000000000000000000000000000000000000..770a0f94923a6e725cf25c5df9213467a1898db6 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/output_payloads/SchemaPost_IncorrectJsonError.json @@ -0,0 +1,13 @@ +{ + "error": { + "code": 400, + "message": "Bad Request. Invalid Input.", + "errors": [ + { + "domain": "global", + "reason": "badRequest", + "message": "Bad Request. Invalid Input." + } + ] + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json b/testing/schema-test-azure/src/test/resources/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json new file mode 100644 index 0000000000000000000000000000000000000000..9f63648f182d84d5aba6a21f5782549fa1cad0fb --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json @@ -0,0 +1,15 @@ +{ + "schemaIdentity": { + "authority": "OSDUTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 1, + "schemaVersionMinor": 1, + "schemaVersionPatch": 0, + "id": "OSDUTest:testSource:testEntity:1.1.0" + }, + "createdBy": "hmadhani-slb-com-350e08c6@desid.delfi.slb.com", + "dateCreated": "2019-12-24T09:53:02.285+0000", + "status": "DEVELOPMENT", + "scope": "INTERNAL" +} diff --git a/testing/schema-test-azure/src/test/resources/output_payloads/SchemaPut_InvalidStatusMessage.json b/testing/schema-test-azure/src/test/resources/output_payloads/SchemaPut_InvalidStatusMessage.json new file mode 100644 index 0000000000000000000000000000000000000000..2031eea6a39b273de4b838f5d57bea8ce3716ebe --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/output_payloads/SchemaPut_InvalidStatusMessage.json @@ -0,0 +1,13 @@ +{ + "error": { + "code": 400, + "message": "Only schema in developement stage can be created through put", + "errors": [ + { + "domain": "global", + "reason": "badRequest", + "message": "Only schema in developement stage can be created through put" + } + ] + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/output_payloads/UpdatedResolvedSchema.json b/testing/schema-test-azure/src/test/resources/output_payloads/UpdatedResolvedSchema.json new file mode 100644 index 0000000000000000000000000000000000000000..174496c062255c933f63271c2c9a531fb1c0c549 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/output_payloads/UpdatedResolvedSchema.json @@ -0,0 +1,14 @@ +{ + "$schema":"http://json-schema.org/draft-07/schema#", + "x-slb-lifecycle-state":"published", + "description":"The entity well.", + "title":"Well", + "type":"object", + "definitions":{ + "FeatureCollection":{ + "$schema":"http://json-schema.org/draft-07/schema#", + "title":"GeoJSON FeatureCollection", + "type":"object" + } + } +} \ No newline at end of file diff --git a/testing/schema-test-azure/src/test/resources/output_payloads/UpdatedSchema_EntityTypeUpdate.json b/testing/schema-test-azure/src/test/resources/output_payloads/UpdatedSchema_EntityTypeUpdate.json new file mode 100644 index 0000000000000000000000000000000000000000..02305590cad6ed8aede33018212060a073e6fc95 --- /dev/null +++ b/testing/schema-test-azure/src/test/resources/output_payloads/UpdatedSchema_EntityTypeUpdate.json @@ -0,0 +1,4 @@ +{ + "ValidationString": "Schema modified by PUT operation", + "definitions": {} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_GET.java b/testing/schema-test-core/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_GET.java index ca47c96a1e25e78064217ccfefe87ccb76de33d6..02d125a4e6549cb516caf42c640a968b9f9bd426 100644 --- a/testing/schema-test-core/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_GET.java +++ b/testing/schema-test-core/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_GET.java @@ -304,7 +304,7 @@ public class SchemaServiceStepDef_GET implements En { } }); - Then("Then service should respond back with status code {string} or {string}", + Then("service should respond back with status code {string} or {string}", (String ResponseStatusCode, String AlternateStatusCode) -> { HttpResponse response = this.context.getHttpResponse(); if (response != null) { diff --git a/testing/schema-test-core/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_POST.java b/testing/schema-test-core/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_POST.java index bf62b8608ffb058384d666b0f995adcb2580fcca..975f93948e9832c3e464af94b371f81a6e5cdb8f 100644 --- a/testing/schema-test-core/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_POST.java +++ b/testing/schema-test-core/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_POST.java @@ -1,6 +1,7 @@ package org.opengroup.osdu.schema.stepdefs; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.ArrayList; @@ -33,7 +34,7 @@ public class SchemaServiceStepDef_POST implements En { static String[] GetListBaseFilterArray; static String[] GetListVersionFilterArray; String queryParameter; - + private final static Logger LOGGER = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); List> list_schemaParameterMap = new ArrayList>(); @@ -73,6 +74,27 @@ public class SchemaServiceStepDef_POST implements En { } }); + Given("I hit schema service POST API with {string} and data-partition-id as {string} and update versions", + (String inputPayload, String tenant) -> { + tenant = selectTenant(tenant); + 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()); + int nextPatchVersion = currentPatchVersion + 1; + int nextMinorVersion = currentMinorVersion + 1; + int nextMajorVersion = currentMajorVersion + 1; + String schemaId = "SchemaSanityTest:testSource:testEntity:" + nextMajorVersion + "." + + nextMinorVersion + "." + nextPatchVersion; + this.context.setSchemaIdFromInputPayload(schemaId); + updatePatchVersionInJsonBody(jsonBody, nextMinorVersion, nextMajorVersion, nextPatchVersion, schemaId); + HttpResponse response = postRequest(jsonBody, schemaId, tenant); + this.context.setHttpResponse(response); + prepareSchemaParameterMapList(); + + }); + Given("I hit schema service POST API with {string} and data-partition-id as {string}", (String inputPayload, String tenant) -> { tenant = selectTenant(tenant); @@ -80,17 +102,53 @@ public class SchemaServiceStepDef_POST implements En { 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()); + int nextPatchVersion = currentPatchVersion + 1; int nextMinorVersion = currentMinorVersion + 1; int nextMajorVersion = currentMajorVersion + 1; String schemaId = "SchemaSanityTest:testSource:testEntity:" + nextMajorVersion + "." - + nextMinorVersion + ".0"; + + nextMinorVersion + "." + nextPatchVersion; this.context.setSchemaIdFromInputPayload(schemaId); - updateVersionInJsonBody(jsonBody, nextMinorVersion, nextMajorVersion, schemaId); + updatePatchVersionInJsonBody(jsonBody, nextMinorVersion, nextMajorVersion, nextPatchVersion, schemaId); + HttpResponse response = postRequest(jsonBody, schemaId, tenant); + this.context.setHttpResponse(response); + + }); + + Given("I hit schema service POST API with {string} and data-partition-id as {string} with no version increase", + (String inputPayload, String tenant) -> { + tenant = selectTenant(tenant); + 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 schemaId = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." + + currentMinorVersion + ".0"; + this.context.setSchemaIdFromInputPayload(schemaId); + updateVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, schemaId); HttpResponse response = postRequest(jsonBody, schemaId, tenant); this.context.setHttpResponse(response); }); - Given("I hit schema service POST API with {string} and data-partition-id as {string} with increased minor version only", + Given("I hit schema service POST API with {string} and data-partition-id as {string} with increased patch version only", + (String inputPayload, String tenant) -> { + tenant = selectTenant(tenant); + 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()); + int nextPatchVersion = currentPatchVersion + 1; + String schemaId = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." + + currentMinorVersion + "." + nextPatchVersion; + this.context.setSchemaIdFromInputPayload(schemaId); + updatePatchVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, nextPatchVersion, + schemaId); + HttpResponse response = postRequest(jsonBody, schemaId, tenant); + this.context.setHttpResponse(response); + }); + + Given("I hit schema service POST API with {string} and data-partition-id as {string} with increased minor version", (String inputPayload, String tenant) -> { tenant = selectTenant(tenant); String body = this.context.getFileUtils().read(inputPayload); @@ -98,7 +156,79 @@ public class SchemaServiceStepDef_POST implements En { int currentMinorVersion = Integer.parseInt(this.context.getSchemaVersionMinor()); int currentMajorVersion = Integer.parseInt(this.context.getSchemaVersionMajor()); int nextMinorVersion = currentMinorVersion + 1; - int nextMajorVersion = currentMajorVersion; + String schemaId = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." + + nextMinorVersion + ".0"; + this.context.setSchemaIdFromInputPayload(schemaId); + updateVersionInJsonBody(jsonBody, nextMinorVersion, currentMajorVersion, + schemaId); + HttpResponse response = postRequest(jsonBody, schemaId, tenant); + this.context.setHttpResponse(response); + }); + + Given("I hit schema service POST API with {string} and data-partition-id as {string} with increased minor version with 2 count", + (String inputPayload, String tenant) -> { + tenant = selectTenant(tenant); + 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()); + int nextMinorVersion = currentMinorVersion + 2; + String schemaId = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." + + nextMinorVersion + "."+currentPatchVersion; + this.context.setSchemaIdFromInputPayload(schemaId); + updatePatchVersionInJsonBody(jsonBody, nextMinorVersion, currentMajorVersion,currentPatchVersion, + schemaId); + HttpResponse response = postRequest(jsonBody, schemaId, tenant); + this.context.setHttpResponse(response); + prepareSchemaParameterMapList(); + }); + + Given("I hit schema service POST API with {string} and data-partition-id as {string} with less minor version by 1 count than earlier", + (String inputPayload, String tenant) -> { + tenant = selectTenant(tenant); + 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 previousMinorVersion = currentMinorVersion - 1 ; + String schemaId = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." + + previousMinorVersion + ".0"; + this.context.setSchemaIdFromInputPayload(schemaId); + updateVersionInJsonBody(jsonBody, previousMinorVersion, currentMajorVersion, + schemaId); + HttpResponse response = postRequest(jsonBody, schemaId, tenant); + this.context.setHttpResponse(response); + }); + + Given("I hit schema service POST API with {string} and data-partition-id as {string} with increased minor version and patch version", + (String inputPayload, String tenant) -> { + tenant = selectTenant(tenant); + 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()); + int nextMinorVersion = currentMinorVersion + 1; + int nextPatchVersion = currentPatchVersion + 1; + String schemaId = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." + + nextMinorVersion + "." + nextPatchVersion; + this.context.setSchemaIdFromInputPayload(schemaId); + updatePatchVersionInJsonBody(jsonBody, nextMinorVersion, currentMajorVersion, nextPatchVersion, + schemaId); + HttpResponse response = postRequest(jsonBody, schemaId, tenant); + this.context.setHttpResponse(response); + }); + + Given("I hit schema service POST API with {string} and data-partition-id as {string} with increased minor version only", + (String inputPayload, String tenant) -> { + tenant = selectTenant(tenant); + 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 nextMinorVersion = currentMinorVersion + 2; + int nextMajorVersion = currentMajorVersion + 1; String id = "SchemaSanityTest:testSource:testEntity:" + nextMajorVersion + "." + nextMinorVersion + ".0"; updateVersionInJsonBody(jsonBody, nextMinorVersion, nextMajorVersion, id); @@ -124,11 +254,10 @@ public class SchemaServiceStepDef_POST implements En { JsonElement jsonBody = new Gson().fromJson(body, JsonElement.class); int currentMinorVersion = Integer.parseInt(this.context.getSchemaVersionMinor()); int currentMajorVersion = Integer.parseInt(this.context.getSchemaVersionMajor()); - int nextMinorVersion = currentMinorVersion; - int nextMajorVersion = currentMajorVersion; - String id = "SchemaSanityTest:testSource:testEntity:" + nextMajorVersion + "." + nextMinorVersion - + ".0"; - updateVersionInJsonBody(jsonBody, nextMinorVersion, nextMajorVersion, id); + int currentPatchVersion = Integer.parseInt(this.context.getSchemaVersionPatch()); + String id = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." + currentMinorVersion + + "." + currentPatchVersion; + updatePatchVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, currentPatchVersion, id); body = new Gson().toJson(jsonBody); this.context.setSchemaIdFromInputPayload(id); this.context @@ -157,6 +286,18 @@ public class SchemaServiceStepDef_POST implements En { } }); + Then("user gets response as {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())); + otherAssertion(response, jsonBody); + Assert.assertNotNull(jsonBody.get(TestConstants.DATE_CREATED)); + Assert.assertNotNull(jsonBody.get(TestConstants.CREATED_BY)); + } + }); + 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); @@ -180,11 +321,47 @@ public class SchemaServiceStepDef_POST implements En { Gson gsn = new Gson(); JsonObject expectedData = gsn.fromJson(body, JsonObject.class); JsonObject responseMsg = gsn.fromJson(response.getBody().toString(), JsonObject.class); - if(!response.getBody().isEmpty()) + if (!response.getBody().isEmpty()) assertEquals(expectedData.toString(), responseMsg.toString()); }); + Then("user gets patch version error response as {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 responseMsg = gsn.fromJson(response.getBody().toString(), JsonObject.class); + if (!response.getBody().isEmpty()) + assertTrue(responseMsg.toString().contains("Patch version validation failed.")); + + }); + + Then("user gets minor version error response as {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 responseMsg = gsn.fromJson(response.getBody().toString(), JsonObject.class); + if (!response.getBody().isEmpty()) + assertTrue(responseMsg.toString().contains("Minor version validation failed")); + + }); + + Then("user gets oneOf attribute error response as {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 responseMsg = gsn.fromJson(response.getBody().toString(), JsonObject.class); + if (!response.getBody().isEmpty()) + assertTrue(responseMsg.toString().contains("Changing list of \\\"oneOf\\\",\\\"allOf\\\" or \\\"anyOf\\\" is not permitted,")); + + }); + Given("I hit schema service POST API with {string} and auth token invalid", (String inputPayload) -> { String body = this.context.getFileUtils().read(inputPayload); JsonObject jsonBody = new Gson().fromJson(body, JsonObject.class); @@ -203,7 +380,7 @@ public class SchemaServiceStepDef_POST implements En { .body(body).httpMethod(HttpRequest.POST).requestHeaders(this.context.getAuthHeaders()).build(); HttpResponse response = HttpClientFactory.getInstance().send(httpRequest); this.context.setHttpResponse(response); - }); + }); Given("I hit schema service POST API with {string}", (String inputPayload) -> { String body = this.context.getFileUtils().read(inputPayload); @@ -230,7 +407,7 @@ public class SchemaServiceStepDef_POST implements En { String supersededById = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." + currentMinorVersion + ".0"; updateSupersededByInJsonBody(jsonBody, supersededById); - this.context.setSupersededById(supersededById); + this.context.setSupersededById(supersededById); int nextMinorVersion = currentMinorVersion + 1; int nextMajorVersion = currentMajorVersion + 1; @@ -244,7 +421,7 @@ public class SchemaServiceStepDef_POST implements En { this.context.setHttpResponse(response); }); - Then("the post service for supersededBy should respond back with {string} and {string}", + Then("post service for supersededBy 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); @@ -296,6 +473,21 @@ public class SchemaServiceStepDef_POST implements En { Assert.assertNotNull(jsonBody.get(TestConstants.CREATED_BY)); } + private void otherAssertion(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 void updateVersionInJsonBody(JsonElement jsonBody, int nextMinorVersion, int nextMajorVersion, String id) { jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject() .remove("schemaVersionMinor"); @@ -310,6 +502,25 @@ public class SchemaServiceStepDef_POST implements En { .addProperty("id", id); } + private void updatePatchVersionInJsonBody(JsonElement jsonBody, int nextMinorVersion, int nextMajorVersion, + int nextPatchVersion, 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("schemaVersionPatch"); + jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject() + .addProperty("schemaVersionPatch", nextPatchVersion); + jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject().remove("id"); + jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject() + .addProperty("id", id); + } + private String getExpectedValue(JsonObject jsonBody, String parentAttributeValue, String valueToBeRetrieved) { String value; if (parentAttributeValue == null) { @@ -338,7 +549,7 @@ public class SchemaServiceStepDef_POST implements En { jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject(TestConstants.SUPERSEDED_BY) .remove(TestConstants.ID); jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject(TestConstants.SUPERSEDED_BY) - .addProperty(TestConstants.ID, id); + .addProperty(TestConstants.ID, id); } public void prepareSchemaParameterMapList() throws IOException { @@ -350,6 +561,8 @@ public class SchemaServiceStepDef_POST implements En { .setSchemaVersionMajor(schemaIdentity_ForEachSchemaIdentity.get("schemaVersionMajor").getAsString()); this.context .setSchemaVersionMinor(schemaIdentity_ForEachSchemaIdentity.get("schemaVersionMinor").getAsString()); + this.context + .setSchemaVersionPatch(schemaIdentity_ForEachSchemaIdentity.get("schemaVersionPatch").getAsString()); } private String selectTenant(String tenant) { diff --git a/testing/schema-test-core/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_PUT.java b/testing/schema-test-core/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_PUT.java index ddf15bba4debb51fecd8c57c3c2c4e0e73cb1fe2..ccc6183dd2d33e49dd1bee321be6eae22c8c44a8 100644 --- a/testing/schema-test-core/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_PUT.java +++ b/testing/schema-test-core/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_PUT.java @@ -41,16 +41,17 @@ public class SchemaServiceStepDef_PUT implements En { public SchemaServiceStepDef_PUT() { - Given("I hit schema service PUT API with {string}, data-partition-id as {string} and mark schema as {string}.", - (String inputPayload, String tenant, String status) -> { + Given("I hit schema service PUT API with {string}, data-partition-id as {string} and mark schema as {string}", + (String inputPayload, String tenant, String status) -> { tenant = selectTenant(tenant); 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 = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." - + currentMinorVersion + ".0"; - updateVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, id); + + currentMinorVersion + "." + currentPatchVersion; + updatePatchVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, currentPatchVersion, id); this.context.setSchemaIdFromInputPayload(id); jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject().remove("status"); jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").getAsJsonObject().addProperty("status", @@ -97,9 +98,10 @@ public class SchemaServiceStepDef_PUT implements En { 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 = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." - + currentMinorVersion + ".0"; - updateVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, id); + + currentMinorVersion + "." + currentPatchVersion; + updatePatchVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, currentPatchVersion, id); this.context.setSchemaIdFromInputPayload(id); body = new Gson().toJson(jsonBody); Map headers = this.context.getAuthHeaders(); @@ -112,55 +114,148 @@ public class SchemaServiceStepDef_PUT implements En { }); Given("I hit schema service PUT API with {string}, data-partition-id as {string} for superceded input", - (String inputPayload, String tenant) -> { + (String inputPayload, String tenant) -> { tenant = selectTenant(tenant); 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); + 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 = "SchemaSanityTest:testSource:testEntity:" + (currentMajorVersion+1) + "." - + currentMinorVersion + "."+patchMajorVersion; - String supersededById = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." - + currentMinorVersion + "."+patchMajorVersion; - updateVersionInJsonBody(newSchemaJsonBody, currentMinorVersion, currentMajorVersion+1, newID); + String newID = "SchemaSanityTest:testSource:testEntity:" + (currentMajorVersion + 1) + "." + + currentMinorVersion + "." + patchMajorVersion; + String supersededById = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." + + currentMinorVersion + "." + patchMajorVersion; + updateVersionInJsonBody(newSchemaJsonBody, currentMinorVersion, currentMajorVersion + 1, newID); newSchemaStr = new Gson().toJson(newSchemaJsonBody); Map headers = this.context.getAuthHeaders(); headers.put(TestConstants.DATA_PARTITION_ID, tenant); - //Create new Schema - HttpRequest httpPostRequest = HttpRequest.builder().url(TestConstants.HOST + TestConstants.POST_ENDPOINT) - .body(newSchemaStr).httpMethod(HttpRequest.POST).requestHeaders(this.context.getAuthHeaders()) - .build(); + // 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 + + // 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(); + .body(putRequest.toString()).httpMethod(HttpRequest.PUT) + .requestHeaders(this.context.getAuthHeaders()).build(); HttpResponse response = HttpClientFactory.getInstance().send(httpRequest); - this.context.setHttpResponse(response); + this.context.setHttpResponse(response); + }); + + Given("I hit schema service PUT API with {string}, data-partition-id as {string} with increased patch version only", + (String inputPayload, String tenant) -> { + tenant = selectTenant(tenant); + 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()); + int nextPatchVersion = currentPatchVersion + 1; + String schemaId = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." + + currentMinorVersion + "." + nextPatchVersion; + this.context.setSchemaIdFromInputPayload(schemaId); + updatePatchVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, nextPatchVersion, + schemaId); + HttpResponse response = putRequest(jsonBody, schemaId, tenant); + this.context.setHttpResponse(response); + }); + + Given("I hit schema service PUT API with {string} and data-partition-id as {string} with increased minor version with 2 count", + (String inputPayload, String tenant) -> { + tenant = selectTenant(tenant); + 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()); + int nextMinorVersion = currentMinorVersion + 2; + String schemaId = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." + + nextMinorVersion + "."+currentPatchVersion; + this.context.setSchemaIdFromInputPayload(schemaId); + updatePatchVersionInJsonBody(jsonBody, nextMinorVersion, currentMajorVersion,currentPatchVersion, + schemaId); + HttpResponse response = putRequest(jsonBody, schemaId, tenant); + this.context.setHttpResponse(response); + prepareSchemaParameterMapList(); + }); + + Given("I hit schema service PUT API with {string} and data-partition-id as {string} with less minor version by 1 count than earlier", + (String inputPayload, String tenant) -> { + tenant = selectTenant(tenant); + 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 previousMinorVersion = currentMinorVersion - 1 ; + String schemaId = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." + + previousMinorVersion + ".0"; + this.context.setSchemaIdFromInputPayload(schemaId); + updateVersionInJsonBody(jsonBody, previousMinorVersion, currentMajorVersion, + schemaId); + HttpResponse response = putRequest(jsonBody, schemaId, tenant); + this.context.setHttpResponse(response); + }); + + Given("I hit schema service PUT API with {string}, data-partition-id as {string} with increased minor version and patch version", + (String inputPayload, String tenant) -> { + tenant = selectTenant(tenant); + 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()); + int nextMinorVersion = currentMinorVersion + 1; + int nextPatchVersion = currentPatchVersion + 1; + String schemaId = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." + + nextMinorVersion + "." + nextPatchVersion; + this.context.setSchemaIdFromInputPayload(schemaId); + updatePatchVersionInJsonBody(jsonBody, nextMinorVersion, currentMajorVersion, nextPatchVersion, + schemaId); + HttpResponse response = putRequest(jsonBody, schemaId, tenant); + this.context.setHttpResponse(response); + }); + + Given("I hit schema service PUT API with {string}, data-partition-id as {string} with increased minor version", + (String inputPayload, String tenant) -> { + tenant = selectTenant(tenant); + 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()); + int nextMinorVersion = currentMinorVersion + 1; + String schemaId = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." + + nextMinorVersion + "." + currentPatchVersion; + this.context.setSchemaIdFromInputPayload(schemaId); + updateVersionInJsonBody(jsonBody, nextMinorVersion, currentMajorVersion, + schemaId); + HttpResponse response = putRequest(jsonBody, schemaId, tenant); + this.context.setHttpResponse(response); }); Given("I hit schema service PUT API with {string}, data-partition-id as {string} with increased minor version only", @@ -170,9 +265,10 @@ public class SchemaServiceStepDef_PUT implements En { 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()); currentMinorVersion = currentMinorVersion + 1; String id = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." - + currentMinorVersion + ".0"; + + currentMinorVersion + "." + currentPatchVersion; updateVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, id); this.context.setSchemaIdFromInputPayload(id); body = new Gson().toJson(jsonBody); @@ -192,8 +288,9 @@ public class SchemaServiceStepDef_PUT implements En { 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 = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." - + currentMinorVersion + ".0"; + + currentMinorVersion + "." + currentPatchVersion; updateVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, id); this.context.setSchemaIdFromInputPayload(id); int randomNum = (int) (Math.random() * 10000); @@ -219,9 +316,10 @@ public class SchemaServiceStepDef_PUT implements En { 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()); currentMajorVersion = currentMajorVersion + 1; String id = "SchemaSanityTest:testSource:testEntity:" + currentMajorVersion + "." - + currentMinorVersion + ".0"; + + currentMinorVersion + "." + currentPatchVersion; updateVersionInJsonBody(jsonBody, currentMinorVersion, currentMajorVersion, id); this.context.setSchemaIdFromInputPayload(id); body = new Gson().toJson(jsonBody); @@ -239,20 +337,17 @@ public class SchemaServiceStepDef_PUT implements En { assertEquals(ReponseStatusCode, String.valueOf(response.getCode())); }); - 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()); - } - }); + 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} and data-partition-id as {string}", (String inputPayload, String tenant) -> { @@ -298,6 +393,39 @@ public class SchemaServiceStepDef_PUT implements En { jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject() .addProperty("id", id); } + + private void updatePatchVersionInJsonBody(JsonElement jsonBody, int nextMinorVersion, int nextMajorVersion, + int nextPatchVersion, 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("schemaVersionPatch"); + jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject() + .addProperty("schemaVersionPatch", nextPatchVersion); + jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject().remove("id"); + jsonBody.getAsJsonObject().getAsJsonObject("schemaInfo").get("schemaIdentity").getAsJsonObject() + .addProperty("id", id); + } + + private HttpResponse putRequest(JsonElement jsonBody, String schemaId, String tenant) { + this.context.setSchemaIdFromInputPayload(schemaId); + this.context.setSchemaFromInputPayload(jsonBody.getAsJsonObject().get(TestConstants.SCHEMA).toString()); + this.context.setJsonPayloadForPostPUT(jsonBody.toString()); + Map headers = this.context.getAuthHeaders(); + headers.put(TestConstants.DATA_PARTITION_ID, tenant); + this.context.setAuthHeaders(headers); + HttpRequest httpRequest = HttpRequest.builder().url(TestConstants.HOST + TestConstants.PUT_ENDPOINT) + .body(jsonBody.toString()).httpMethod(HttpRequest.PUT).requestHeaders(headers).build(); + HttpResponse response = HttpClientFactory.getInstance().send(httpRequest); + return response; + } + public void prepareSchemaParameterMapList() throws IOException { String response = this.context.getHttpResponse().getBody(); diff --git a/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_Nested_POST.feature b/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_Nested_POST.feature new file mode 100644 index 0000000000000000000000000000000000000000..03aab5132328511b6d1bb13d4a8d75ae19870969 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_Nested_POST.feature @@ -0,0 +1,199 @@ +Feature: To verify functionality of nested POST schema Service + + ### Common test steps are accomplished here + Background: Common steps for all tests are executed + Given I generate user token and set request headers for "TENANT1" + Given I get latest schema with authority, source, entityType as "SchemaSanityTest", "testSource", "testEntity" respectively + Given I hit schema service POST API with "/input_payloads/Base_Schema.json" and data-partition-id as "TENANT1" only if status is not development + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds successfully even if ID, Title, x-osdu and few other optional attributes are added + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service POST API with and data-partition-id as with increased patch version only + Then user gets response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | ResponseMessage1 | + | "/input_payloads/Nested_Base_Schema.json" | "/input_payloads/Nested_Base_Schema_ID.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_SuccessfulCreation.json" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + | "/input_payloads/Nested_Base_Schema.json" | "/input_payloads/Nested_Base_Schema_Title.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_SuccessfulCreation.json" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + | "/input_payloads/Nested_Base_Schema.json" | "/input_payloads/Nested_Base_Schema_MultipleChanges.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_SuccessfulCreation.json" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + | "/input_payloads/Nested_Base_Schema.json" | "/input_payloads/Nested_Base_Schema_x-osdu-added.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_SuccessfulCreation.json" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds as bad request when only patch version is increased and Additional properties attribute has false value + When I hit schema service POST API with and data-partition-id as with increased patch version only + Then user gets patch version error response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_AdditionalPropIsF.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_Patch_BreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds as bad request when minor and patch versions are increased and Additional properties attribute has false value + When I hit schema service POST API with and data-partition-id as with increased minor version and patch version + Then user gets minor version error response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_AdditionalPropIsF.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds as bad request when only minor version is increased and Additional properties attribute has false value + When I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_AdditionalPropIsF.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds successfully when only minor version is increased and Additional properties attribute having true(Earlier AP=NA) value + When I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_AdditionalPropIsT.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds as bad request when only minor version is increased and Additional properties attribute having true(Earlier AP=False) value + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + When I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode1 | ReponseStatusCode | ResponseMessage1 | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_WithFalseAP.json" | "/input_payloads/Nested_Base_Schema_AdditionalPropIsT.json" | "TENANT1" | "201" | "400" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds as bad request when only patch version is increased and Additional properties attribute having true(Earlier AP=False) value + When I hit schema service POST API with and data-partition-id as with increased patch version only + Then user gets patch version error response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_AdditionalPropIsT.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_Patch_BreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds as bad request when only minor version is increased and Additional properties attribute having false(Earlier AP=NA) value + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode1 | ReponseStatusCode | ResponseMessage1 | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_WithoutAP.json" | "/input_payloads/Nested_Base_Schema_AdditionalPropIsF.json" | "TENANT1" | "201" | "400" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds as bad request when only patch version is increased and Additional properties attribute having false(Earlier AP=NA) value + When I hit schema service POST API with and data-partition-id as with increased patch version only + Then user gets patch version error response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_AdditionalPropIsF.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_Patch_BreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds successfully when only minor version is increased and Additional properties attribute having true(Earlier AP=NA) value + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_AdditionalPropIsT.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds successfully when only patch version is increased and Additional properties attribute having true(Earlier AP=NA) value + When I hit schema service POST API with and data-partition-id as with increased patch version only + Then user gets response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_AdditionalPropIsT.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds as bad request when only minor version is increased and Additional properties attribute is absent(Earlier AP=false) + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode1 | ReponseStatusCode | ResponseMessage1 | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_AdditionalPropIsF.json" | "/input_payloads/Nested_Base_Schema_WithoutAP.json" | "TENANT1" | "201" | "400" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds as bad request when only patch version is increased and Additional properties attribute is absent(Earlier AP=false) + Given I hit schema service POST API with and data-partition-id as with increased patch version only + Then user gets patch version error response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_WithoutAP.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_Patch_BreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds as bad request for adding/replacing any attribute which is not present in the immediate next schema record + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service POST API with and data-partition-id as with increased minor version with 2 count + Then user gets response as and + Given I hit schema service POST API with and data-partition-id as with less minor version by 1 count than earlier + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithAddedChanges | InputPayloadWithReplacedChanges | tenant | ReponseStatusCode | ReponseStatusCode1 | ResponseMessage | ResponseMessage1 | + | "/input_payloads/Nested_Base_Schema_New.json" | "/input_payloads/Nested_Base_Schema_AddedAttribute.json" | "/input_payloads/Nested_Base_Schema_ReplacedAttribute.json" | "TENANT1" | "400" | "201" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds as bad request for removing/replacing any attribute from previous schema record + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithRemovedChanges | tenant | ReponseStatusCode | ReponseStatusCode1 | ResponseMessage1 | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_New.json" | "/input_payloads/Nested_Base_Schema_RemovedAttribute.json" | "TENANT1" | "400" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds as bad request for removing/replacing any element of OneOf from previous schema record + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | InputPayloadWithRemovedChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_RemovedAttributeFromOneOfElement.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds as bad request when only minor version is increased with jumbled oneOf elements and position change of elements on index basis + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage1 | ReponseStatusCode1 | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_NestedoneOf.json" | "/input_payloads/Nested_Base_Schema_JumbledOneOfWithFalseAP.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "201" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds successfully when only minor version is increased and added one element in oneOf elements + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Nested_Base_Schema_NestedoneOf_AddedExtraElement.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that nested Schema Service's POST API responds successfully when only minor version is increased with jumbled ref elements in oneOf + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | | ResponseMessage1 | ReponseStatusCode1 | + | "/input_payloads/Nested_Base_Schema_NestedoneOf_RemoveElement.json" | "/input_payloads/Nested_Base_Schema_NestedoneOf_JumbeledRef.json" | "TENANT1" | | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "201" | diff --git a/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_POST.feature b/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_POST.feature index 7116e62fd16c778326ad3517a96bde94645ee09b..f98965d188629733024e39ab154f9d03f1178eeb 100644 --- a/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_POST.feature +++ b/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_POST.feature @@ -8,7 +8,7 @@ Feature: To verify functionality of POST schema Service @SchemaService Scenario Outline: Verify that Schema Service's POST API creates a empty private schema correctly. - Given I hit schema service POST API with and data-partition-id as + Given I hit schema service POST API with and data-partition-id as and update versions Then service should respond back with and And schema service should respond back with and @@ -63,10 +63,10 @@ Feature: To verify functionality of POST schema Service | "/input_payloads/postSchema_withEntityAttributeInPayload.json" | "TENANT1" | "400" | "/output_payloads/PostSchema_EntityNotAllowedError.json" | | "/input_payloads/postSchema_flattenedSchemaAsInput.json" | "TENANT1" | "400" | "/output_payloads/PostSchema_InvalidInputSchemaError.json" | - @SchemaService + @Not_Running Scenario Outline: Verify that Schema Service supersededBy functionality work correctly Given I hit schema service POST API for supersededBy with and data-partition-id as - Then the post service for supersededBy should respond back with and + Then post service for supersededBy should respond back with and Examples: | InputPayload | tenant | ReponseStatusCode | ResponseMessage | @@ -76,8 +76,8 @@ Feature: To verify functionality of POST schema Service Scenario Outline: Verify whether schema can not be registered with already existing major, but increased minor version Given I hit schema service POST API with and data-partition-id as Given I hit schema service POST API with and data-partition-id as with increased minor version only - Then service should respond back with error and + Then user gets minor version error response as and Examples: - | EmptyInputPayload | InputPayload | ReponseStatusCode | ResponseMessage | tenant | - | "/input_payloads/postSchemaService_EmptySchema.json" | "/input_payloads/inputPayloadWithExistingVersion.json" | "400" | "/output_payloads/SchemaPost_BreakingChangeError.json" | "TENANT1" | + | EmptyInputPayload | InputPayload | ReponseStatusCode | ResponseMessage | tenant | + | "/input_payloads/postSchemaService_EmptySchema.json" | "/input_payloads/inputPayloadWithExistingVersion.json" | "400" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | "TENANT1" | diff --git a/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_POST_SchemaValidations.feature b/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_POST_SchemaValidations.feature new file mode 100644 index 0000000000000000000000000000000000000000..9ca339d218fa942b9f788da8d69b6d376c4d2189 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_POST_SchemaValidations.feature @@ -0,0 +1,212 @@ +Feature: To verify functionality of POST schema Service + + ### Common test steps are accomplished here + Background: Common steps for all tests are executed + Given I generate user token and set request headers for "TENANT1" + Given I get latest schema with authority, source, entityType as "SchemaSanityTest", "testSource", "testEntity" respectively + Given I hit schema service POST API with "/input_payloads/Base_Schema.json" and data-partition-id as "TENANT1" only if status is not development + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds successfully even if ID, Title, x-osdu and few other optional attributes are added + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service POST API with and data-partition-id as with increased patch version only + Then user gets response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | ResponseMessage1 | + | "/input_payloads/Base_Schema.json" | "/input_payloads/Base_Schema_ID.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_SuccessfulCreation.json" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + | "/input_payloads/Base_Schema.json" | "/input_payloads/Base_Schema_Title.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_SuccessfulCreation.json" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + | "/input_payloads/Base_Schema.json" | "/input_payloads/Base_Schema_MultipleChanges.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_SuccessfulCreation.json" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + | "/input_payloads/Base_Schema.json" | "/input_payloads/Base_Schema_x-osdu-added.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_SuccessfulCreation.json" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds as bad request when only patch version is increased and Additional properties attribute has false value + When I hit schema service POST API with and data-partition-id as with increased patch version only + Then user gets patch version error response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsF.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_Patch_BreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds as bad request when minor and patch versions are increased and Additional properties attribute has false value + When I hit schema service POST API with and data-partition-id as with increased minor version and patch version + Then user gets minor version error response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsF.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds as bad request when only minor version is increased and Additional properties attribute has false value + When I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsF.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds successfully when only minor version is increased and Additional properties attribute having true(Earlier AP=NA) value + When I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsT.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds as bad request when only minor version is increased and Additional properties attribute having true(Earlier AP=False) value + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + When I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode1 | ReponseStatusCode | ResponseMessage1 | ResponseMessage | + | "/input_payloads/Base_Schema_WithFalseAP.json" | "/input_payloads/Base_Schema_AdditionalPropIsT.json" | "TENANT1" | "201" | "400" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds as bad request when only patch version is increased and Additional properties attribute having true(Earlier AP=False) value + When I hit schema service POST API with and data-partition-id as with increased patch version only + Then user gets patch version error response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsT.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_Patch_BreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds as bad request when only minor version is increased and Additional properties attribute having false(Earlier AP=NA) value + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode1 | ReponseStatusCode | ResponseMessage1 | ResponseMessage | + | "/input_payloads/Base_Schema_WithoutAP.json" | "/input_payloads/Base_Schema_AdditionalPropIsF.json" | "TENANT1" | "201" | "400" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds as bad request when only patch version is increased and Additional properties attribute having false(Earlier AP=NA) value + When I hit schema service POST API with and data-partition-id as with increased patch version only + Then user gets patch version error response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsF.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_Patch_BreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds successfully when only minor version is increased and Additional properties attribute having true(Earlier AP=NA) value + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsT.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds successfully when only patch version is increased and Additional properties attribute having true(Earlier AP=NA) value + When I hit schema service POST API with and data-partition-id as with increased patch version only + Then user gets response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsT.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds as bad request when only minor version is increased and Additional properties attribute is absent(Earlier AP=false) + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode1 | ReponseStatusCode | ResponseMessage1 | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsF.json" | "/input_payloads/Base_Schema_WithoutAP.json" | "TENANT1" | "201" | "400" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds as bad request when only patch version is increased and Additional properties attribute is absent(Earlier AP=false) + Given I hit schema service POST API with and data-partition-id as with increased patch version only + Then user gets patch version error response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_WithoutAP.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_Patch_BreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds as bad request for adding/replacing any attribute which is not present in the immediate next schema record + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service POST API with and data-partition-id as with increased minor version with 2 count + Then user gets response as and + Given I hit schema service POST API with and data-partition-id as with less minor version by 1 count than earlier + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithAddedChanges | InputPayloadWithReplacedChanges | tenant | ReponseStatusCode | ReponseStatusCode1 | ResponseMessage | ResponseMessage1 | + | "/input_payloads/Base_Schema_New.json" | "/input_payloads/Base_Schema_AddedAttribute.json" | "/input_payloads/Base_Schema_ReplacedAttribute.json" | "TENANT1" | "400" | "201" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds as bad request for removing/replacing any attribute from previous schema record + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithRemovedChanges | tenant | ReponseStatusCode | ReponseStatusCode1 | ResponseMessage1 | ResponseMessage | + | "/input_payloads/Base_Schema_New.json" | "/input_payloads/Base_Schema_RemovedAttribute.json" | "TENANT1" | "400" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds as bad request for removing/replacing any element of OneOf from previous schema record + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | InputPayloadWithRemovedChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_RemovedAttributeFromOneOfElement.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds as bad request when only minor version is increased with jumbled oneOf elements and position change of elements on index basis + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage1 | ReponseStatusCode1 | ResponseMessage | + | "/input_payloads/Base_Schema_NestedoneOf.json" | "/input_payloads/Base_Schema_JumbledOneOfWithFalseAP.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "201" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds successfully when only minor version is increased and added one element in oneOf elements + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_NestedoneOf_AddedExtraElement.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds successfully when only minor version is increased with jumbled ref elements in oneOf + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ResponseMessage1 | ReponseStatusCode1 | + | "/input_payloads/Base_Schema_NestedoneOf_RemoveElement.json" | "/input_payloads/Base_Schema_NestedoneOf_JumbeledRef.json" | "TENANT1" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "201" | + + @SchemaService + Scenario Outline: Verify that Schema Service's POST API responds as bad request when type of any element is changed + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage1 | ReponseStatusCode1 | ResponseMessage | + | "/input_payloads/Base_Schema.json" | "/input_payloads/Base_Schema_TypeChanged.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "201" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_PUT.feature b/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_PUT.feature index 05a407884db604f095393c29b0adbeaff26c737e..52776df377675b7593893b3395e701b1fba98c42 100644 --- a/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_PUT.feature +++ b/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_PUT.feature @@ -30,7 +30,7 @@ Feature: To verify functionality of PUT schema Service @SchemaService Scenario Outline: Verify that Schema Service's PUT API throws error if update is requested for schema which is not in development status. - Given I hit schema service PUT API with , data-partition-id as and mark schema as . + Given I hit schema service PUT API with , data-partition-id as and mark schema as When I hit schema service PUT API with , data-partition-id as Then service should respond back with error and @@ -196,8 +196,8 @@ Feature: To verify functionality of PUT schema Service Scenario Outline: Verify whether schema can not be registered with already existing major, but increased minor version Given I hit schema service PUT API with , data-partition-id as Given I hit schema service PUT API with , data-partition-id as with increased minor version only - Then service should respond back with error and + Then user gets minor version error response as and Examples: - | EmptyInputPayload | InputPayload | ReponseStatusCode | tenant | ResponseMessage | - | "/input_payloads/postSchemaService_EmptySchema.json" | "/input_payloads/inputPayloadWithExistingVersion.json" | "400" | "TENANT1" | "/output_payloads/SchemaPost_BreakingChangeError.json" | + | EmptyInputPayload | InputPayload | ReponseStatusCode | tenant | ResponseMessage | + | "/input_payloads/postSchemaService_EmptySchema.json" | "/input_payloads/inputPayloadWithExistingVersion.json" | "400" | "TENANT1" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | diff --git a/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_PUT_SchemaValidations.feature b/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_PUT_SchemaValidations.feature new file mode 100644 index 0000000000000000000000000000000000000000..17a7055115e14a7a564e673aa43ba00420662e75 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_PUT_SchemaValidations.feature @@ -0,0 +1,219 @@ +Feature: To verify functionality of PUT schema Service + + ### Commons test steps are accomplished here + Background: Common steps for all tests are executed + Given I generate user token and set request headers for "TENANT1" + Given I get latest schema with authority, source, entityType as "SchemaSanityTest", "testSource", "testEntity" respectively + Given I hit schema service POST API with "/input_payloads/Base_Schema.json" and data-partition-id as "TENANT1" only if status is not development + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds successfully even if ID, Title, x-osdu and few other optional attributes are added + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service PUT API with , data-partition-id as with increased patch version only + Then user gets response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | ResponseMessage1 | + | "/input_payloads/Base_Schema.json" | "/input_payloads/Base_Schema_ID.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_SuccessfulCreation.json" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + | "/input_payloads/Base_Schema.json" | "/input_payloads/Base_Schema_Title.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_SuccessfulCreation.json" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + | "/input_payloads/Base_Schema.json" | "/input_payloads/Base_Schema_MultipleChanges.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_SuccessfulCreation.json" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + | "/input_payloads/Base_Schema.json" | "/input_payloads/Base_Schema_x-osdu-added.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_SuccessfulCreation.json" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds as bad request when only patch version is increased and Additional properties attribute has false value + When I hit schema service PUT API with , data-partition-id as with increased patch version only + Then user gets patch version error response as and + + Examples: #NegativeScenario + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsF.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_Patch_BreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds as bad request when minor and patch versions are increased and Additional properties attribute has false value + When I hit schema service PUT API with , data-partition-id as with increased minor version and patch version + Then user gets minor version error response as and + + Examples: #NegativeScenario + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsF.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds as bad request when only minor version is increased and Additional properties attribute has false value + When I hit schema service PUT API with , data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: #NegativeScenario + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsF.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds successfully when only minor version is increased and Additional properties attribute having true(Earlier AP=NA) value + When I hit schema service PUT API with , data-partition-id as with increased minor version + Then user gets response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsT.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds as bad request when only minor version is increased and Additional properties attribute having true(Earlier AP=False) value + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + When I hit schema service PUT API with , data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode1 | ReponseStatusCode | ResponseMessage1 | ResponseMessage | + | "/input_payloads/Base_Schema_WithFalseAP.json" | "/input_payloads/Base_Schema_AdditionalPropIsT.json" | "TENANT1" | "201" | "400" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds as bad request when only patch version is increased and Additional properties attribute having true(Earlier AP=False) value + When I hit schema service PUT API with , data-partition-id as with increased patch version only + Then user gets patch version error response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsT.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_Patch_BreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds as bad request when only minor version is increased and Additional properties attribute having false(Earlier AP=NA) value + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service PUT API with , data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode1 | ReponseStatusCode | ResponseMessage1 | ResponseMessage | + | "/input_payloads/Base_Schema_WithoutAP.json" | "/input_payloads/Base_Schema_AdditionalPropIsF.json" | "TENANT1" | "201" | "400" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds as bad request when only patch version is increased and Additional properties attribute having false(Earlier AP=NA) value + When I hit schema service PUT API with , data-partition-id as with increased patch version only + Then user gets patch version error response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsF.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_Patch_BreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds successfully when only minor version is increased and Additional properties attribute having true(Earlier AP=NA) value + Given I hit schema service PUT API with , data-partition-id as with increased minor version + Then user gets response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsT.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds successfully when only patch version is increased and Additional properties attribute having true(Earlier AP=NA) value + When I hit schema service PUT API with , data-partition-id as with increased patch version only + Then user gets response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsT.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds as bad request when only minor version is increased and Additional properties attribute is absent(Earlier AP=false) + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service PUT API with , data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode1 | ReponseStatusCode | ResponseMessage1 | ResponseMessage | + | "/input_payloads/Base_Schema_AdditionalPropIsF.json" | "/input_payloads/Base_Schema_WithoutAP.json" | "TENANT1" | "201" | "400" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds as bad request when only patch version is increased and Additional properties attribute is absent(Earlier AP=false) + Given I hit schema service PUT API with , data-partition-id as with increased patch version only + Then user gets patch version error response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_WithoutAP.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_Patch_BreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds as bad request for adding/replacing any attribute which is not present in the immediate next schema record + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service PUT API with and data-partition-id as with increased minor version with 2 count + Then user gets response as and + Given I hit schema service PUT API with and data-partition-id as with less minor version by 1 count than earlier + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithAddedChanges | InputPayloadWithReplacedChanges | tenant | ReponseStatusCode | ReponseStatusCode1 | ResponseMessage | ResponseMessage1 | + | "/input_payloads/Base_Schema_New.json" | "/input_payloads/Base_Schema_AddedAttribute.json" | "/input_payloads/Base_Schema_ReplacedAttribute.json" | "TENANT1" | "400" | "201" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds as bad request for removing/replacing any attribute from previous schema record + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service PUT API with , data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithRemovedChanges | tenant | ReponseStatusCode | ReponseStatusCode1 | ResponseMessage1 | ResponseMessage | + | "/input_payloads/Base_Schema_New.json" | "/input_payloads/Base_Schema_RemovedAttribute.json" | "TENANT1" | "400" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds as bad request for removing/replacing any element of OneOf from previous schema record + Given I hit schema service POST API with and data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | InputPayloadWithRemovedChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_RemovedAttributeFromOneOfElement.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds as bad request when only minor version is increased with jumbled oneOf elements and position change of elements on index basis + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service PUT API with , data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage1 | ReponseStatusCode1 | ResponseMessage | + | "/input_payloads/Base_Schema_NestedoneOf.json" | "/input_payloads/Base_Schema_JumbledOneOfWithFalseAP.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "201" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds successfully when only minor version is increased and added one element in oneOf elements + Given I hit schema service PUT API with , data-partition-id as with increased minor version + Then user gets response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_NestedoneOf_AddedExtraElement.json" | "TENANT1" | "201" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds successfully when only minor version is increased with jumbled ref elements in oneOf + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service PUT API with , data-partition-id as with increased minor version + Then user gets response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ResponseMessage1 | ReponseStatusCode1 | + | "/input_payloads/Base_Schema_NestedoneOf_RemoveElement.json" | "/input_payloads/Base_Schema_NestedoneOf_JumbeledRef.json" | "TENANT1" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "201" | + + @SchemaService + Scenario Outline: Verify that Schema Service's PUT API responds successfully when no version is increased with jumbled oneOf elements + Given I hit schema service PUT API with , data-partition-id as + Then user gets response as and + + Examples: + | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage | + | "/input_payloads/Base_Schema_NestedoneOf_RemoveElement.json" | "TENANT1" | "200" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | + + @Failed + Scenario Outline: Verify that Schema Service's POST API responds as bad request when type of any element is changed + Given I hit schema service POST API with and data-partition-id as and update versions + Then service should respond back with and + Given I hit schema service PUT API with , data-partition-id as with increased minor version + Then user gets minor version error response as and + + Examples: + | BaseInputPayload | InputPayloadWithChanges | tenant | ReponseStatusCode | ResponseMessage1 | ReponseStatusCode1 | ResponseMessage | + | "/input_payloads/Base_Schema.json" | "/input_payloads/Base_Schema_TypeChanged.json" | "TENANT1" | "400" | "/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json" | "201" | "/output_payloads/SchemaPost_MinorBreakingChangeError.json" | diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema.json new file mode 100644 index 0000000000000000000000000000000000000000..6ee973ff9033e1c7542cbe131871e1d53d5fd2d0 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema.json @@ -0,0 +1,43 @@ +{ + "schemaInfo":{ + "schemaIdentity":{ + "authority":"SchemaSanityTest", + "source":"testSource", + "entityType":"testEntity", + "schemaVersionMajor":0, + "schemaVersionMinor":0, + "schemaVersionPatch":2 + }, + "status":"DEVELOPMENT" + }, + "schema":{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string" }, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1", "AddressLine2" ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + }, + { + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_AddedAttribute.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_AddedAttribute.json new file mode 100644 index 0000000000000000000000000000000000000000..421eec6aeb67d604c12870271891baf50060fcd0 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_AddedAttribute.json @@ -0,0 +1,75 @@ +{ + "schemaInfo":{ + "schemaIdentity":{ + "authority":"SchemaSanityTest", + "source":"testSource", + "entityType":"testEntity", + "schemaVersionMajor":4, + "schemaVersionMinor":2, + "schemaVersionPatch":0 + }, + "status":"DEVELOPMENT" + }, + "schema":{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + }, + "state":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_AdditionalPropIsF.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_AdditionalPropIsF.json new file mode 100644 index 0000000000000000000000000000000000000000..b55756c4a31ea97c9e68e2e0420dbd5c9ac1bd70 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_AdditionalPropIsF.json @@ -0,0 +1,74 @@ +{ + "schemaInfo":{ + "schemaIdentity":{ + "authority":"SchemaSanityTest", + "source":"testSource", + "entityType":"testEntity", + "schemaVersionMajor":0, + "schemaVersionMinor":0, + "schemaVersionPatch":8 + }, + "status":"DEVELOPMENT" + }, + "schema": { + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "additionalProperties": false, + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_AdditionalPropIsT.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_AdditionalPropIsT.json new file mode 100644 index 0000000000000000000000000000000000000000..610613fe1985cd04912bccdfb2dc457169beb144 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_AdditionalPropIsT.json @@ -0,0 +1,74 @@ +{ + "schemaInfo":{ + "schemaIdentity":{ + "authority":"SchemaSanityTest", + "source":"testSource", + "entityType":"testEntity", + "schemaVersionMajor":0, + "schemaVersionMinor":1, + "schemaVersionPatch":0 + }, + "status":"DEVELOPMENT" + }, + "schema": { + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "additionalProperties": true, + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_ID.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_ID.json new file mode 100644 index 0000000000000000000000000000000000000000..55c254297917ecbaefe0fd4541050f9d0227e511 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_ID.json @@ -0,0 +1,44 @@ +{ + "schemaInfo":{ + "schemaIdentity":{ + "authority":"SchemaSanityTest", + "source":"testSource", + "entityType":"testEntity", + "schemaVersionMajor":0, + "schemaVersionMinor":0, + "schemaVersionPatch":2 + }, + "status":"DEVELOPMENT" + }, + "schema":{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type": "object", + "title": "My schema", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string" }, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1", "AddressLine2" ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + }, + { + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_JumbledOneOfWithFalseAP.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_JumbledOneOfWithFalseAP.json new file mode 100644 index 0000000000000000000000000000000000000000..81edcf305d09d68bfdfd0ac1f84062b8d975c9de --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_JumbledOneOfWithFalseAP.json @@ -0,0 +1,101 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 1, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type": "object", + "title": "My schema - Changed", + "definitions": { + "osdu..wks..well.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..well", + "type": "object" + }, + "osdu..wks..wellabc.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..wellabc", + "type": "object" + } + }, + "properties": { + "AddressLine1": { + "type": "string", + "$comment": "This is a mandatory attribute", + "description": "This should be the apartment number and building name" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "$ref": "#/definition/osdu..wks..well.1.0" + }, + { + "$ref": "#/definition/osdu..wks..wellabc.1.0" + }, + { + "title": "Local Address", + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "title": "Address", + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + }, + { + "type": "object", + "properties": { + "email": { + "type": "string" + } + }, + "required": [ + "email" + ] + } + ] + } +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_MultipleChanges.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_MultipleChanges.json new file mode 100644 index 0000000000000000000000000000000000000000..9c6a0e238bd794d4f1922b2490aaa414c8937ef0 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_MultipleChanges.json @@ -0,0 +1,72 @@ +{ + "schemaInfo":{ + "schemaIdentity":{ + "authority":"SchemaSanityTest", + "source":"testSource", + "entityType":"testEntity", + "schemaVersionMajor":0, + "schemaVersionMinor":0, + "schemaVersionPatch":7 + }, + "status":"DEVELOPMENT" + }, + "schema":{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf.json new file mode 100644 index 0000000000000000000000000000000000000000..c63a6d52a8f56421132411ff4cd228f201c3c401 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf.json @@ -0,0 +1,101 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type": "object", + "title": "My schema - Changed", + "definitions": { + "osdu..wks..well.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..well", + "type": "object" + }, + "osdu..wks..wellabc.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..wellabc", + "type": "object" + } + }, + "properties": { + "AddressLine1": { + "type": "string", + "$comment": "This is a mandatory attribute", + "description": "This should be the apartment number and building name" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "$ref": "#/definition/osdu..wks..well.1.0" + }, + { + "$ref": "#/definition/osdu..wks..wellabc.1.0" + }, + { + "title": "Local Address", + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "email": { + "type": "string" + } + }, + "required": [ + "email" + ] + }, + { + "title": "Address", + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf_AddedExtraElement.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf_AddedExtraElement.json new file mode 100644 index 0000000000000000000000000000000000000000..8feeaa223950056a4848ccdb87ab01f838dc1959 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf_AddedExtraElement.json @@ -0,0 +1,113 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 2, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type": "object", + "title": "My schema - Changed", + "definitions": { + "osdu..wks..well.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..well", + "type": "object" + }, + "osdu..wks..wellabc.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..wellabc", + "type": "object" + } + }, + "properties": { + "AddressLine1": { + "type": "string", + "$comment": "This is a mandatory attribute", + "description": "This should be the apartment number and building name" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "$ref": "#/definition/osdu..wks..well.1.0" + }, + { + "$ref": "#/definition/osdu..wks..wellabc.1.0" + }, + { + "title": "Local Address", + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "email": { + "type": "string" + } + }, + "required": [ + "email" + ] + }, + { + "title": "Address", + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + }, + { + "title": "Contact", + "type": "object", + "properties": { + "phone": { + "type": "string" + } + }, + "required": [ + "phone" + ] + } + ] + } +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf_JumbeledRef.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf_JumbeledRef.json new file mode 100644 index 0000000000000000000000000000000000000000..4af181413a2d0938bb8944420e55322f39e4a4ca --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf_JumbeledRef.json @@ -0,0 +1,101 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 2, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type": "object", + "title": "My schema - Changed", + "definitions": { + "osdu..wks..well.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..well", + "type": "object" + }, + "osdu..wks..wellabc.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..wellabc", + "type": "object" + } + }, + "properties": { + "AddressLine1": { + "type": "string", + "$comment": "This is a mandatory attribute", + "description": "This should be the apartment number and building name" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "$ref": "#/definition/osdu..wks..wellabc.1.0" + }, + { + "$ref": "#/definition/osdu..wks..well.1.0" + }, + { + "title": "Local Address", + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "email": { + "type": "string" + } + }, + "required": [ + "email" + ] + }, + { + "title": "Address", + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf_RemoveElement.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf_RemoveElement.json new file mode 100644 index 0000000000000000000000000000000000000000..ed3d52ea923b77704f38dda0baafa866b350ba6e --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf_RemoveElement.json @@ -0,0 +1,101 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 2, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type": "object", + "title": "My schema - Changed", + "definitions": { + "osdu..wks..well.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..well", + "type": "object" + }, + "osdu..wks..wellabc.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..wellabc", + "type": "object" + } + }, + "properties": { + "AddressLine1": { + "type": "string", + "$comment": "This is a mandatory attribute", + "description": "This should be the apartment number and building name" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "$ref": "#/definition/osdu..wks..well.1.0" + }, + { + "$ref": "#/definition/osdu..wks..wellabc.1.0" + }, + { + "title": "Local Address", + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "email": { + "type": "string" + } + }, + "required": [ + "email" + ] + }, + { + "title": "Address", + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_New.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_New.json new file mode 100644 index 0000000000000000000000000000000000000000..f40ec96b87e2970c098d25cabf64b224414376f7 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_New.json @@ -0,0 +1,72 @@ +{ + "schemaInfo":{ + "schemaIdentity":{ + "authority":"SchemaSanityTest", + "source":"testSource", + "entityType":"testEntity", + "schemaVersionMajor":4, + "schemaVersionMinor":0, + "schemaVersionPatch":0 + }, + "status":"DEVELOPMENT" + }, + "schema":{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_RemovedAttribute.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_RemovedAttribute.json new file mode 100644 index 0000000000000000000000000000000000000000..03dbc93018cf6bf4238a0f3e30d94584102cc361 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_RemovedAttribute.json @@ -0,0 +1,69 @@ +{ + "schemaInfo":{ + "schemaIdentity":{ + "authority":"SchemaSanityTest", + "source":"testSource", + "entityType":"testEntity", + "schemaVersionMajor":4, + "schemaVersionMinor":0, + "schemaVersionPatch":0 + }, + "status":"DEVELOPMENT" + }, + "schema":{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_RemovedAttributeFromOneOfElement.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_RemovedAttributeFromOneOfElement.json new file mode 100644 index 0000000000000000000000000000000000000000..03dbc93018cf6bf4238a0f3e30d94584102cc361 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_RemovedAttributeFromOneOfElement.json @@ -0,0 +1,69 @@ +{ + "schemaInfo":{ + "schemaIdentity":{ + "authority":"SchemaSanityTest", + "source":"testSource", + "entityType":"testEntity", + "schemaVersionMajor":4, + "schemaVersionMinor":0, + "schemaVersionPatch":0 + }, + "status":"DEVELOPMENT" + }, + "schema":{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_ReplacedAttribute.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_ReplacedAttribute.json new file mode 100644 index 0000000000000000000000000000000000000000..64649c4ae64e49938b844621b028fbd2bf9f2024 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_ReplacedAttribute.json @@ -0,0 +1,75 @@ +{ + "schemaInfo":{ + "schemaIdentity":{ + "authority":"SchemaSanityTest", + "source":"testSource", + "entityType":"testEntity", + "schemaVersionMajor":4, + "schemaVersionMinor":1, + "schemaVersionPatch":0 + }, + "status":"DEVELOPMENT" + }, + "schema":{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + }, + "district":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_Title.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_Title.json new file mode 100644 index 0000000000000000000000000000000000000000..ef78f224d23413581c11c2663da6bf9c0d3928c3 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_Title.json @@ -0,0 +1,44 @@ +{ + "schemaInfo":{ + "schemaIdentity":{ + "authority":"SchemaSanityTest", + "source":"testSource", + "entityType":"testEntity", + "schemaVersionMajor":0, + "schemaVersionMinor":0, + "schemaVersionPatch":2 + }, + "status":"DEVELOPMENT" + }, + "schema":{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type": "object", + "title": "My schema - Changed", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string" }, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1", "AddressLine2" ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + }, + { + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_TypeChanged.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_TypeChanged.json new file mode 100644 index 0000000000000000000000000000000000000000..d5320cd5b93d7b7c23b1f63579edf62f774395cc --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_TypeChanged.json @@ -0,0 +1,43 @@ +{ + "schemaInfo":{ + "schemaIdentity":{ + "authority":"SchemaSanityTest", + "source":"testSource", + "entityType":"testEntity", + "schemaVersionMajor":0, + "schemaVersionMinor":0, + "schemaVersionPatch":2 + }, + "status":"DEVELOPMENT" + }, + "schema":{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "number" }, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1", "AddressLine2" ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + }, + { + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_WithFalseAP.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_WithFalseAP.json new file mode 100644 index 0000000000000000000000000000000000000000..808f4e8b1ae4e821fb95e704675649c78660ea47 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_WithFalseAP.json @@ -0,0 +1,74 @@ +{ + "schemaInfo":{ + "schemaIdentity":{ + "authority":"SchemaSanityTest", + "source":"testSource", + "entityType":"testEntity", + "schemaVersionMajor":0, + "schemaVersionMinor":1, + "schemaVersionPatch":0 + }, + "status":"DEVELOPMENT" + }, + "schema": { + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "additionalProperties": false, + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_WithoutAP.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_WithoutAP.json new file mode 100644 index 0000000000000000000000000000000000000000..196c1b4f0fd40330b16ff65cda437df1c20de8a0 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_WithoutAP.json @@ -0,0 +1,73 @@ +{ + "schemaInfo":{ + "schemaIdentity":{ + "authority":"SchemaSanityTest", + "source":"testSource", + "entityType":"testEntity", + "schemaVersionMajor":0, + "schemaVersionMinor":1, + "schemaVersionPatch":0 + }, + "status":"DEVELOPMENT" + }, + "schema": { + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] +} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_x-osdu-added.json b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_x-osdu-added.json new file mode 100644 index 0000000000000000000000000000000000000000..99968514266342f09009e5a7f8430cd2d15861cd --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_x-osdu-added.json @@ -0,0 +1,46 @@ +{ + "schemaInfo":{ + "schemaIdentity":{ + "authority":"SchemaSanityTest", + "source":"testSource", + "entityType":"testEntity", + "schemaVersionMajor":0, + "schemaVersionMinor":0, + "schemaVersionPatch":4 + }, + "status":"DEVELOPMENT" + }, + "schema": { + "x-osdu-license":"Landmark copyright placeholder", + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "$comment": "This is a test schema", + "type": "object", + "definitions": {}, + "properties": { + "AddressLine1": { "type": "string", + "$comment": "This is a mandatory attribute"}, + "AddressLine2": { "type": "string" }, + "City": { "type": "string" } + }, + "required": [ "AddressLine1", "AddressLine2" ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { "type": "string" }, + "ZipCode": { "type": "string" } + }, + "required": [ "ZipCode" ] + }, + { + "type": "object", + "properties": { + "County": { "type": "string" }, + "PostCode": { "type": "string" } + }, + "required": [ "PostCode" ] + } + ] +} +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema.json new file mode 100644 index 0000000000000000000000000000000000000000..44634c688d62409a27cd0b3f9622fd003f45ec4e --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema.json @@ -0,0 +1,115 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + "test1": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } + } + }, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_AddedAttribute.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_AddedAttribute.json new file mode 100644 index 0000000000000000000000000000000000000000..f71b7962f90174d45188d849f2b0da80d79963bd --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_AddedAttribute.json @@ -0,0 +1,127 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 2 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + "test1": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type": "object", + "title": "My schema - Changed", + "definitions": { + }, + "properties": { + "AddressLine1": { + "type": "string", + "$comment": "This is a mandatory attribute", + "description": "This should be the apartment number and building name" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + }, + "state": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } + }, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_AdditionalPropIsF.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_AdditionalPropIsF.json new file mode 100644 index 0000000000000000000000000000000000000000..9dbfb477138a92392d6f9cf29c3634f057530090 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_AdditionalPropIsF.json @@ -0,0 +1,122 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + "test1": { + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-license": "Landmark copyright placeholder", + "type": "object", + "title": "My schema - changed", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "additionalProperties": false, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } + } + }, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_AdditionalPropIsT.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_AdditionalPropIsT.json new file mode 100644 index 0000000000000000000000000000000000000000..37ae66b285d64c054cefe0e389f2364cc15918ee --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_AdditionalPropIsT.json @@ -0,0 +1,122 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + "test1": { + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-license": "Landmark copyright placeholder", + "type": "object", + "title": "My schema - changed", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "additionalProperties": true, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } + } + }, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_ID.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_ID.json new file mode 100644 index 0000000000000000000000000000000000000000..d7bc33656c5b385acae18578106f07f906959e4d --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_ID.json @@ -0,0 +1,116 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + "test1": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } + } + }, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_JumbledOneOfWithFalseAP.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_JumbledOneOfWithFalseAP.json new file mode 100644 index 0000000000000000000000000000000000000000..d2d1038dca2195f1ead324d9e004010d4c336348 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_JumbledOneOfWithFalseAP.json @@ -0,0 +1,137 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 2 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + "schemaInfo":{ + "schemaIdentity":{ + "authority":"testAuthority1", + "source":"local", + "entityType":"schema-validation1", + "schemaVersionMajor":5, + "schemaVersionMinor":2, + "schemaVersionPatch":0 + }, + "status":"DEVELOPMENT" + }, + "schema": { + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "additionalProperties": false, + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", + "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + }, + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + } + ] + } + }, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_MultipleChanges.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_MultipleChanges.json new file mode 100644 index 0000000000000000000000000000000000000000..1a0c6663707f335f4d30689e18ee41ecd4474826 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_MultipleChanges.json @@ -0,0 +1,120 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + "test1": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema - changed", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } + } + }, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf.json new file mode 100644 index 0000000000000000000000000000000000000000..c63a6d52a8f56421132411ff4cd228f201c3c401 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf.json @@ -0,0 +1,101 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type": "object", + "title": "My schema - Changed", + "definitions": { + "osdu..wks..well.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..well", + "type": "object" + }, + "osdu..wks..wellabc.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..wellabc", + "type": "object" + } + }, + "properties": { + "AddressLine1": { + "type": "string", + "$comment": "This is a mandatory attribute", + "description": "This should be the apartment number and building name" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "$ref": "#/definition/osdu..wks..well.1.0" + }, + { + "$ref": "#/definition/osdu..wks..wellabc.1.0" + }, + { + "title": "Local Address", + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "email": { + "type": "string" + } + }, + "required": [ + "email" + ] + }, + { + "title": "Address", + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf_AddedExtraElement.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf_AddedExtraElement.json new file mode 100644 index 0000000000000000000000000000000000000000..8feeaa223950056a4848ccdb87ab01f838dc1959 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf_AddedExtraElement.json @@ -0,0 +1,113 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 2, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type": "object", + "title": "My schema - Changed", + "definitions": { + "osdu..wks..well.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..well", + "type": "object" + }, + "osdu..wks..wellabc.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..wellabc", + "type": "object" + } + }, + "properties": { + "AddressLine1": { + "type": "string", + "$comment": "This is a mandatory attribute", + "description": "This should be the apartment number and building name" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "$ref": "#/definition/osdu..wks..well.1.0" + }, + { + "$ref": "#/definition/osdu..wks..wellabc.1.0" + }, + { + "title": "Local Address", + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "email": { + "type": "string" + } + }, + "required": [ + "email" + ] + }, + { + "title": "Address", + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + }, + { + "title": "Contact", + "type": "object", + "properties": { + "phone": { + "type": "string" + } + }, + "required": [ + "phone" + ] + } + ] + } +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf_JumbeledRef.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf_JumbeledRef.json new file mode 100644 index 0000000000000000000000000000000000000000..4af181413a2d0938bb8944420e55322f39e4a4ca --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf_JumbeledRef.json @@ -0,0 +1,101 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 2, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type": "object", + "title": "My schema - Changed", + "definitions": { + "osdu..wks..well.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..well", + "type": "object" + }, + "osdu..wks..wellabc.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..wellabc", + "type": "object" + } + }, + "properties": { + "AddressLine1": { + "type": "string", + "$comment": "This is a mandatory attribute", + "description": "This should be the apartment number and building name" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "$ref": "#/definition/osdu..wks..wellabc.1.0" + }, + { + "$ref": "#/definition/osdu..wks..well.1.0" + }, + { + "title": "Local Address", + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "email": { + "type": "string" + } + }, + "required": [ + "email" + ] + }, + { + "title": "Address", + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf_RemoveElement.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf_RemoveElement.json new file mode 100644 index 0000000000000000000000000000000000000000..ed3d52ea923b77704f38dda0baafa866b350ba6e --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf_RemoveElement.json @@ -0,0 +1,101 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 2, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type": "object", + "title": "My schema - Changed", + "definitions": { + "osdu..wks..well.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..well", + "type": "object" + }, + "osdu..wks..wellabc.1.0": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "osdu..wks..wellabc", + "type": "object" + } + }, + "properties": { + "AddressLine1": { + "type": "string", + "$comment": "This is a mandatory attribute", + "description": "This should be the apartment number and building name" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "$ref": "#/definition/osdu..wks..well.1.0" + }, + { + "$ref": "#/definition/osdu..wks..wellabc.1.0" + }, + { + "title": "Local Address", + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "email": { + "type": "string" + } + }, + "required": [ + "email" + ] + }, + { + "title": "Address", + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_New.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_New.json new file mode 100644 index 0000000000000000000000000000000000000000..1f46c1fd9bd23300f0268b3f7789f80958e3255c --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_New.json @@ -0,0 +1,124 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 2 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + "test1": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type": "object", + "title": "My schema - Changed", + "definitions": { + }, + "properties": { + "AddressLine1": { + "type": "string", + "$comment": "This is a mandatory attribute", + "description": "This should be the apartment number and building name" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } + }, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_RemovedAttribute.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_RemovedAttribute.json new file mode 100644 index 0000000000000000000000000000000000000000..2bae634512bf669096d3533b58501a19b3eb7397 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_RemovedAttribute.json @@ -0,0 +1,132 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 2 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + "schemaInfo":{ + "schemaIdentity":{ + "authority":"testAuthority1", + "source":"local", + "entityType":"schema-validation1", + "schemaVersionMajor":4, + "schemaVersionMinor":0, + "schemaVersionPatch":0 + }, + "status":"DEVELOPMENT" + }, + "schema":{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] + } + }, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_RemovedAttributeFromOneOfElement.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_RemovedAttributeFromOneOfElement.json new file mode 100644 index 0000000000000000000000000000000000000000..c4f83816999f98a4422c1b5778272c084be770a5 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_RemovedAttributeFromOneOfElement.json @@ -0,0 +1,121 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 2 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + "test1": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type": "object", + "title": "My schema - Changed", + "definitions": { + }, + "properties": { + "AddressLine1": { + "type": "string", + "$comment": "This is a mandatory attribute", + "description": "This should be the apartment number and building name" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } + }, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_ReplacedAttribute.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_ReplacedAttribute.json new file mode 100644 index 0000000000000000000000000000000000000000..28700eedd871fbceba9196b78b8c30c178335936 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_ReplacedAttribute.json @@ -0,0 +1,138 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 2 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + "schemaInfo":{ + "schemaIdentity":{ + "authority":"testAuthority1", + "source":"local", + "entityType":"schema-validation1", + "schemaVersionMajor":4, + "schemaVersionMinor":1, + "schemaVersionPatch":0 + }, + "status":"DEVELOPMENT" + }, + "schema":{ + "$schema":"http://json-schema.org/draft-07/schema#", + "$id":"https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "type":"object", + "title":"My schema - Changed", + "definitions":{ + + }, + "properties":{ + "AddressLine1":{ + "type":"string", + "$comment":"This is a mandatory attribute", + "description":"This should be the apartment number and building name" + }, + "AddressLine2":{ + "type":"string" + }, + "City":{ + "type":"string" + }, + "district":{ + "type":"string" + } + }, + "required":[ + "AddressLine1", "AddressLine2" + ], + "oneOf":[ + { + "type":"object", + "properties":{ + "State":{ + "type":"string" + }, + "ZipCode":{ + "type":"string", + "pattern":"^\\d{5}(?:[-\\s]\\d{4})?$", + "examples":[ + "98052-7329" + ] + } + }, + "required":[ + "ZipCode" + ] + }, + { + "type":"object", + "properties":{ + "County":{ + "type":"string" + }, + "PostCode":{ + "type":"string" + } + }, + "required":[ + "PostCode" + ] + } + ] + } + }, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_Title.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_Title.json new file mode 100644 index 0000000000000000000000000000000000000000..8b87bf9b5ea08c3c68c92d18982d975b303ffe19 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_Title.json @@ -0,0 +1,116 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + "test1": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema - changed", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } + } + }, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_WithFalseAP.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_WithFalseAP.json new file mode 100644 index 0000000000000000000000000000000000000000..9dbfb477138a92392d6f9cf29c3634f057530090 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_WithFalseAP.json @@ -0,0 +1,122 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + "test1": { + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-license": "Landmark copyright placeholder", + "type": "object", + "title": "My schema - changed", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "additionalProperties": false, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } + } + }, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_WithoutAP.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_WithoutAP.json new file mode 100644 index 0000000000000000000000000000000000000000..75a5cc6cf58b99a6457f9fff763c0cb8eba95e8c --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_WithoutAP.json @@ -0,0 +1,121 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "My schema", + "definitions": { + "test1": { + "$schema": "http://json-schema.org/draft-07/schema#", + "x-osdu-license": "Landmark copyright placeholder", + "type": "object", + "title": "My schema - changed", + "$id": "https://schema.osdu.opengroup.org/json/dataset/schema-with-id-added.json", + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string", + "pattern": "^\\d{5}(?:[-\\s]\\d{4})?$", + "examples": [ + "98052-7329" + ] + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] + } + } + }, + "properties": { + "AddressLine1": { + "type": "string" + }, + "AddressLine2": { + "type": "string" + }, + "City": { + "type": "string" + } + }, + "required": [ + "AddressLine1", + "AddressLine2" + ], + "oneOf": [ + { + "type": "object", + "properties": { + "State": { + "type": "string" + }, + "ZipCode": { + "type": "string" + } + }, + "required": [ + "ZipCode" + ] + }, + { + "type": "object", + "properties": { + "County": { + "type": "string" + }, + "PostCode": { + "type": "string" + } + }, + "required": [ + "PostCode" + ] + } + ] +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_x-osdu-added.json b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_x-osdu-added.json new file mode 100644 index 0000000000000000000000000000000000000000..f17963f6cbbe1402e4675caaccfdd73be5880f5e --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_x-osdu-added.json @@ -0,0 +1,121 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 0, + "schemaVersionMinor": 0, + "schemaVersionPatch": 1 + }, + "status": "DEVELOPMENT" + }, + "schema": { + "$schema": "http://json-