From b1119b1b46b8071c05f84e0acf97c09880d607bf Mon Sep 17 00:00:00 2001 From: Spencer Sutton Date: Thu, 27 May 2021 16:03:27 +0000 Subject: [PATCH 01/30] Locking down maven central commit f7b32ee6 Author: Spencer Sutton Date: Thu May 27 2021 10:15:59 GMT-0500 (Central Daylight Time) "Excluding springs default security, locking down mvn central" --- provider/schema-aws/maven/settings.xml | 122 +++++++++--------- .../src/main/resources/application.properties | 4 +- 2 files changed, 64 insertions(+), 62 deletions(-) diff --git a/provider/schema-aws/maven/settings.xml b/provider/schema-aws/maven/settings.xml index 72f847e1..1bfc43ac 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/src/main/resources/application.properties b/provider/schema-aws/src/main/resources/application.properties index 247373bf..1265c63a 100644 --- a/provider/schema-aws/src/main/resources/application.properties +++ b/provider/schema-aws/src/main/resources/application.properties @@ -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 -- GitLab From 5c9a512588d2f2f74a5cdb3ca3acae5c4ab6fccc Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 3 Jun 2021 19:48:15 +0530 Subject: [PATCH 02/30] Fixing supersededBy issue for SHARED partition --- .../impl/schemainfostore/AzureSchemaInfoStore.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 26a16ea8..857fe46b 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 @@ -102,7 +102,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { SchemaInfoDoc schemaInfoDoc = cosmosStore.findItem(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()); } /** @@ -132,7 +132,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { } log.info(SchemaConstants.SCHEMA_INFO_CREATED); - return getSchemaInfoObject(flattenedSchemaInfo); + return getSchemaInfoObject(flattenedSchemaInfo, headers.getPartitionId()); } /** @@ -157,7 +157,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { } log.info(SchemaConstants.SCHEMA_INFO_UPDATED); - return getSchemaInfoObject(flattenedSchemaInfo); + return getSchemaInfoObject(flattenedSchemaInfo, headers.getPartitionId()); } /** @@ -268,13 +268,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 = cosmosStore.findItem(dataPartitionId, cosmosDBName, schemaInfoContainer, id, partitionKey, SchemaInfoDoc.class).get(); superSededBy = getSchemaIdentity(doc.getFlattenedSchemaInfo()); } @@ -357,7 +357,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { 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()) { -- GitLab From e70a00b51d74319490439c891d6ec4e26b7fbab8 Mon Sep 17 00:00:00 2001 From: Matt Wise Date: Thu, 3 Jun 2021 13:07:30 -0500 Subject: [PATCH 03/30] use proper partition env var --- provider/schema-aws/src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provider/schema-aws/src/main/resources/application.properties b/provider/schema-aws/src/main/resources/application.properties index 1265c63a..d05efcac 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 -- GitLab From 741a9322f4eeca65b23f1079cc7d80331005be5d Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 9 Jun 2021 13:24:55 +0530 Subject: [PATCH 04/30] Adding unit testcase --- .../schemainfostore/AzureSchemaInfoStoreTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 ef80a0f2..4d2247fb 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 @@ -466,6 +466,17 @@ 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(getMockSchemaInfoDoc()); + doReturn(new ArrayList<>()).when(cosmosStore).queryItems(eq("common"), any(), any(), any(), any(), any()); + + assertEquals(0, + schemaInfoStore.getSchemaInfoList(QueryParams.builder().limit(100).offset(0).build(), dataPartitionId).size()); + } @Test public void testGetSchemaInfoList_withqueryparam() -- GitLab From 6d88b3b08f0655e79aa34c8550f5be7caf7b8a56 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 9 Jun 2021 13:47:59 +0530 Subject: [PATCH 05/30] Modifying testcase --- .../AzureSchemaInfoStoreTest.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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 4d2247fb..9f14e1ad 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 @@ -35,6 +35,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; @@ -471,11 +472,12 @@ public class AzureSchemaInfoStoreTest { public void testGetSchemaInfoList_Withoutqueryparam_FailedWhenSearchedIntoSharedPartition() throws NotFoundException, ApplicationException, BadRequestException { List schemaInfoDocsList = new LinkedList<>(); - schemaInfoDocsList.add(getMockSchemaInfoDoc()); - doReturn(new ArrayList<>()).when(cosmosStore).queryItems(eq("common"), any(), any(), any(), any(), any()); - - assertEquals(0, - schemaInfoStore.getSchemaInfoList(QueryParams.builder().limit(100).offset(0).build(), dataPartitionId).size()); + 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 @@ -542,6 +544,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() -- GitLab From 3d82e912dd26edc4ce300f50e860a4be97fdfacd Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 9 Jun 2021 16:04:45 +0530 Subject: [PATCH 06/30] Update fossa-check-notice --- NOTICE | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NOTICE b/NOTICE index 4465e330..8637930e 100644 --- a/NOTICE +++ b/NOTICE @@ -692,6 +692,8 @@ 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) 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) - tomcat-embed-core (from http://tomcat.apache.org/) @@ -749,6 +751,8 @@ 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) 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) @@ -768,6 +772,8 @@ 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) 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) -- GitLab From 5342e3fc0accfe6fbeec0cb13c5fad533b42abfc Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 9 Jun 2021 19:17:31 +0530 Subject: [PATCH 07/30] Update fossa-check-notice --- NOTICE | 6 ------ 1 file changed, 6 deletions(-) diff --git a/NOTICE b/NOTICE index 8637930e..4465e330 100644 --- a/NOTICE +++ b/NOTICE @@ -692,8 +692,6 @@ 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) 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) - tomcat-embed-core (from http://tomcat.apache.org/) @@ -751,8 +749,6 @@ 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) 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) @@ -772,8 +768,6 @@ 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) 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) -- GitLab From bd79176d038f84f854815dce797ec6d3b2133a0c Mon Sep 17 00:00:00 2001 From: "Rustam Lotsmanenko (EPAM)" Date: Thu, 17 Jun 2021 10:52:08 +0000 Subject: [PATCH 08/30] Gcp fix schema uniqueness check --- .../schema/exception/AppExceptionHandler.java | 39 ++++++++++++++++ .../GoogleSchemaInfoStore.java | 46 +++++++++++-------- .../GoogleSchemaInfoStoreTest.java | 22 +++++++++ 3 files changed, 87 insertions(+), 20 deletions(-) create mode 100644 provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/exception/AppExceptionHandler.java 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 00000000..daf32930 --- /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/schemainfostore/GoogleSchemaInfoStore.java b/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleSchemaInfoStore.java index b90cd723..8775030c 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/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 57f4b5a2..524d15a6 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() -- GitLab From 6df62ed997653a092ed96fe941c58890268c6669 Mon Sep 17 00:00:00 2001 From: Spencer Sutton Date: Tue, 22 Jun 2021 13:04:30 -0500 Subject: [PATCH 09/30] Using version 0.9.2 for core lib aws --- provider/schema-aws/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provider/schema-aws/pom.xml b/provider/schema-aws/pom.xml index d0285959..e4d7da3b 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.9.2-SNAPSHOT -- GitLab From ea9cbda0d44c47ab469a5961fd5c7668ca25925e Mon Sep 17 00:00:00 2001 From: Anastasiia Gelmut Date: Tue, 29 Jun 2021 10:11:59 +0000 Subject: [PATCH 10/30] Schema: Implement Event Publishing for GCP (GONRG-2378) --- NOTICE | 145 ++++++------------ provider/schema-gcp/README.md | 1 + .../osdu/schema/GcpSchemaApplication.java | 33 ++++ .../EventMessagingPropertiesConfig.java | 42 +++++ .../impl/messagebus/MessageBusImpl.java | 117 ++++++++++++-- .../messagebus/model/SchemaPubSubInfo.java | 33 ++++ .../src/main/resources/application.properties | 3 + .../impl/messagebus/MessageBusImplTest.java | 88 +++++++++++ 8 files changed, 359 insertions(+), 103 deletions(-) create mode 100644 provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/GcpSchemaApplication.java create mode 100644 provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/configuration/EventMessagingPropertiesConfig.java create mode 100644 provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/messagebus/model/SchemaPubSubInfo.java create mode 100644 provider/schema-gcp/src/test/java/org/opengroup/osdu/schema/impl/messagebus/MessageBusImplTest.java diff --git a/NOTICE b/NOTICE index 4465e330..abd79655 100644 --- a/NOTICE +++ b/NOTICE @@ -350,7 +350,6 @@ The following software have components provided under the terms of this license: - Google OAuth Client Library for Java (from ) - 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) @@ -554,6 +553,7 @@ The following software have components provided under the terms of this license: - 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) +- jakarta.xml.bind-api (from ) - java-cloudant (from https://cloudant.com) - java-cloudant (from https://cloudant.com) - javatuples (from http://www.javatuples.org) @@ -611,7 +611,7 @@ The following software have components provided under the terms of this license: - Hamcrest Core (from http://hamcrest.org/) - HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) - Lucene Common Analyzers (from ) -- StAX (from http://stax.codehaus.org/) +- Reflections (from http://github.com/ronmamo/reflections) - Stax2 API (from http://github.com/FasterXML/stax2-api) - ThreeTen backport (from https://www.threeten.org/threetenbp) @@ -623,16 +623,13 @@ The following software have components provided under the terms of this license: - API Common (from https://github.com/googleapis) - ASM Core (from ) - ASM Core (from ) -- Apache Commons Codec (from http://commons.apache.org/proper/commons-codec/) +- Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) - 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 ) -- 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 ) @@ -647,12 +644,10 @@ The following software have components provided under the terms of this license: - Netty/Codec/HTTP (from ) - Protocol Buffer Java API (from https://developers.google.com/protocol-buffers/) - Protocol Buffers [Util] (from ) -- Reflections (from http://github.com/ronmamo/reflections) -- SnakeYAML (from http://www.snakeyaml.org) - 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.annotation-api (from https://projects.eclipse.org/projects/ee4j.ca) - jakarta.xml.bind-api (from ) ======================================================================== @@ -677,6 +672,14 @@ CC0-1.0 ======================================================================== The following software have components provided under the terms of this license: +- 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) +- HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) +- HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) +- LatencyUtils (from http://latencyutils.github.io/LatencyUtils/) +- Netty/Common (from ) +- Netty/Common (from ) - reactive-streams (from http://www.reactive-streams.org/) ======================================================================== @@ -684,15 +687,17 @@ CDDL-1.0 ======================================================================== The following software have components provided under the terms of this license: +- Apache Log4j Core (from ) +- JavaBeans(TM) Activation Framework (from http://java.sun.com/javase/technologies/desktop/javabeans/jaf/index.jsp) - 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: -- JavaBeans Activation Framework (from ) +- JSR 353 (JSON Processing) API (from http://json-processing-spec.java.net) +- JSR 353 (JSON Processing) Default Provider (from http://jsonp.java.net) - JavaBeans(TM) Activation Framework (from http://java.sun.com/javase/technologies/desktop/javabeans/jaf/index.jsp) - tomcat-embed-core (from http://tomcat.apache.org/) @@ -704,6 +709,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: + +- Woodstox (from https://github.com/FasterXML/woodstox) +- aalto-xml (from ) + ======================================================================== EPL-1.0 ======================================================================== @@ -711,16 +724,13 @@ 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 ) - Logback Contrib :: JSON :: Classic (from ) - Logback Contrib :: JSON :: Core (from ) - Logback Contrib :: Jackson (from ) -- Logback Core Module (from ) - 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) - 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/) @@ -749,18 +759,14 @@ GPL-2.0-only ======================================================================== The following software have components provided under the terms of this license: -- JavaBeans Activation Framework (from ) +- 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) Default Provider (from http://jsonp.java.net) - 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/) -======================================================================== -GPL-2.0-or-later -======================================================================== -The following software have components provided under the terms of this license: - -- SnakeYAML (from http://www.snakeyaml.org) - ======================================================================== GPL-2.0-with-classpath-exception ======================================================================== @@ -768,10 +774,11 @@ 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) -- JavaBeans Activation Framework (from ) +- Google Guice - Core Library (from ) +- JSR 353 (JSON Processing) API (from http://json-processing-spec.java.net) +- JSR 353 (JSON Processing) Default Provider (from http://jsonp.java.net) - 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/) ======================================================================== @@ -780,10 +787,17 @@ GPL-3.0-only The following software have components provided under the terms of this license: - Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) -- Project Lombok (from https://projectlombok.org) -- 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) +- aalto-xml (from ) + ======================================================================== JSON ======================================================================== @@ -800,31 +814,14 @@ 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 Contrib :: JSON :: Classic (from ) - Logback Contrib :: JSON :: Core (from ) - Logback Contrib :: Jackson (from ) -- Logback Core Module (from ) - 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) -======================================================================== -LGPL-2.1-or-later -======================================================================== -The following software have components provided under the terms of this license: - -- SnakeYAML (from http://www.snakeyaml.org) - -======================================================================== -LGPL-3.0-only -======================================================================== -The following software have components provided under the terms of this license: - -- Apache Log4j API (from ) -- Apache Log4j Core (from ) - ======================================================================== MIT ======================================================================== @@ -834,6 +831,8 @@ The following software have components provided under the terms of this license: - 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 ) +- Apache Log4j SLF4J Binding (from ) +- Apache Log4j to SLF4J Adapter (from ) - Azure AD Spring Security Integration Spring Boot Starter (from https://github.com/Microsoft/azure-spring-boot) - 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) @@ -855,6 +854,7 @@ The following software have components provided under the terms of this license: - Cucumber-JVM: Plugin (from https://repo1.maven.org/maven2/io/cucumber/cucumber-plugin) - DataTable (from ) - Extensions on Apache Proton-J library (from https://github.com/Azure/qpid-proton-j-extensions) +- Google Guice - Core Library (from ) - 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) @@ -878,8 +878,8 @@ 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) +- Mockito (from http://mockito.org) - Netty/Codec/HTTP (from ) - Netty/Codec/HTTP (from ) - Netty/Common (from ) @@ -894,6 +894,7 @@ 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/) +- jakarta.xml.bind-api (from ) - micrometer-core (from https://github.com/micrometer-metrics/micrometer) - mockito-inline (from https://github.com/mockito/mockito) - mockito-junit-jupiter (from https://github.com/mockito/mockito) @@ -902,61 +903,35 @@ The following software have components provided under the terms of this license: - msal4j-persistence-extension (from https://github.com/AzureAD/microsoft-authentication-extensions-for-java) - spring-security-core (from http://spring.io/spring-security) -======================================================================== -MPL-1.1 -======================================================================== -The following software have components provided under the terms of this license: - -- Javassist (from http://www.javassist.org/) - ======================================================================== MPL-2.0 ======================================================================== The following software have components provided under the terms of this license: - Javassist (from http://www.javassist.org/) -- OkHttp (from ) - -======================================================================== -PHP-3.01 -======================================================================== -The following software have components provided under the terms of this license: - -- JavaBeans Activation Framework API jar (from ) -- jakarta.xml.bind-api (from ) ======================================================================== 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/) ======================================================================== -Python-2.0 -======================================================================== -The following software have components provided under the terms of this license: - -- google-auth (from https://github.com/GoogleCloudPlatform/google-auth-library-python) - -======================================================================== -SPL-1.0 +WTFPL ======================================================================== The following software have components provided under the terms of this license: -- Checker Qual (from https://checkerframework.org) -- Checker Qual (from https://checkerframework.org) +- Reflections (from http://github.com/ronmamo/reflections) ======================================================================== -WTFPL +X11 ======================================================================== The following software have components provided under the terms of this license: -- Reflections (from http://github.com/ronmamo/reflections) +- 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) ======================================================================== public-domain @@ -967,9 +942,6 @@ The following software have components provided under the terms of this license: - 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) - HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) - HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) - Joda-Time (from http://www.joda.org/joda-time/) @@ -978,14 +950,9 @@ The following software have components provided under the terms of this license: - Microsoft Azure SDK for EventGrid Management (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) - Microsoft Azure client library for Blob Storage (from https://github.com/Azure/azure-sdk-for-java) -- 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/) - 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) -- reactive-streams (from http://www.reactive-streams.org/) ======================================================================== unknown @@ -993,20 +960,10 @@ unknown The following software have components provided under the terms of this license: - Byte Buddy (without dependencies) (from ) -- 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/) -- 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-engine (from http://junit.org/junit5/) -- org.junit.vintage:junit-vintage-engine (from http://junit.org/junit5/) diff --git a/provider/schema-gcp/README.md b/provider/schema-gcp/README.md index bf1c200a..90a1fa3c 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 00000000..6504d62a --- /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 00000000..b566889a --- /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/impl/messagebus/MessageBusImpl.java b/provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/messagebus/MessageBusImpl.java index 0648ec2d..fc4e5d0c 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 00000000..31742683 --- /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/resources/application.properties b/provider/schema-gcp/src/main/resources/application.properties index 218dae13..3527ebb6 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 00000000..951c1c65 --- /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)); + } +} -- GitLab From 547ce1c29f605569e461626b9dec4eab5a5bf7ed Mon Sep 17 00:00:00 2001 From: Aman Verma Date: Wed, 30 Jun 2021 11:52:53 +0000 Subject: [PATCH 11/30] [azure] Adding new API to create public schemas in azure --- NOTICE | 122 +++++++++------- provider/schema-azure/pom.xml | 33 +++-- .../osdu/schema/azure/api/AzureSchemaApi.java | 47 ++++++ .../azure/auth/AuthorizationFilterSP.java | 18 +++ .../schema/azure/di/SystemResourceConfig.java | 16 ++ .../schemainfostore/AzureAuthorityStore.java | 23 ++- .../schemainfostore/AzureEntityTypeStore.java | 23 ++- .../schemainfostore/AzureSchemaInfoStore.java | 93 ++++++++++-- .../schemainfostore/AzureSourceStore.java | 22 ++- .../impl/schemastore/AzureSchemaStore.java | 24 ++- ...thorizationServiceForServicePrincipal.java | 5 + .../azure/interfaces/ISchemaServiceAzure.java | 43 ++++++ ...izationServiceForServicePrincipalImpl.java | 65 +++++++++ .../serviceimpl/SchemaServiceAzure.java | 55 +++++++ .../schema/security/AADSecurityConfig.java | 2 +- .../AADSecurityConfigWithIstioEnabled.java | 41 ++++++ .../security/AzureIstioSecurityConfig.java | 35 ----- .../src/main/resources/application.properties | 22 ++- .../azure/api/AzureSchemaApiTest.java | 102 +++++++++++++ .../AzureAuthorityStoreTest.java | 91 ++++++++++++ .../AzureEntityTypeStoreTest.java | 95 ++++++++++++ .../AzureSchemaInfoStoreTest.java | 107 +++++++++++++- .../schemainfostore/AzureSourceStoreTest.java | 93 ++++++++++++ .../schemastore/AzureSchemaStoreTest.java | 74 ++++++++++ .../serviceimpl/SchemaServiceAzureTest.java | 138 ++++++++++++++++++ 25 files changed, 1255 insertions(+), 134 deletions(-) create mode 100644 provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/api/AzureSchemaApi.java create mode 100644 provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/auth/AuthorizationFilterSP.java create mode 100644 provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/di/SystemResourceConfig.java create mode 100644 provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/interfaces/IAuthorizationServiceForServicePrincipal.java create mode 100644 provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/interfaces/ISchemaServiceAzure.java create mode 100644 provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/service/serviceimpl/AuthorizationServiceForServicePrincipalImpl.java create mode 100644 provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/service/serviceimpl/SchemaServiceAzure.java create mode 100644 provider/schema-azure/src/main/java/org/opengroup/osdu/schema/security/AADSecurityConfigWithIstioEnabled.java delete mode 100644 provider/schema-azure/src/main/java/org/opengroup/osdu/schema/security/AzureIstioSecurityConfig.java create mode 100644 provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/api/AzureSchemaApiTest.java create mode 100644 provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/service/serviceimpl/SchemaServiceAzureTest.java diff --git a/NOTICE b/NOTICE index abd79655..ed6d296c 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 ======================================================================== @@ -303,6 +296,7 @@ The following software have components provided under the terms of this license: - 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/) +- Apache Commons Lang (from http://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}) @@ -317,12 +311,14 @@ The following software have components provided under the terms of this license: - Apache Log4j SLF4J Binding (from ) - Apache Log4j to SLF4J Adapter (from ) - AssertJ fluent assertions (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) +- 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) +- Brave Instrumentation: Http Adapters (from ) +- Brave instrumentation for Reactor Netty HTTP (from https://github.com/reactor/reactor-netty) - Byte Buddy (without dependencies) (from ) - Byte Buddy Java agent (from ) - ClassMate (from http://github.com/cowtowncoder/java-classmate) @@ -330,6 +326,7 @@ The following software have components provided under the terms of this license: - CloudWatch Metrics for AWS Java SDK (from https://aws.amazon.com/sdkforjava) - Commons IO (from http://commons.apache.org/io/) - Converter: Jackson (from ) +- 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) @@ -352,8 +349,8 @@ The following software have components provided under the terms of this license: - Guava InternalFutureFailureAccess and InternalFutures (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) +- HTTP functionality for the Reactor Netty library (from https://github.com/reactor/reactor-netty) - Hibernate Validator Engine (from ) - Hibernate Validator Engine (from ) - IBM COS Java SDK for Amazon S3 (from https://github.com/ibm/ibm-cos-sdk-java) @@ -375,22 +372,16 @@ The following software have components provided under the terms of this license: - 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-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) - Java Libraries for Amazon Simple WorkFlow (from https://aws.amazon.com/sdkforjava) - Java Native Access (from https://github.com/java-native-access/jna) @@ -421,7 +412,6 @@ The following software have components provided under the terms of this license: - Lucene Queries (from ) - Lucene QueryParsers (from ) - Lucene Sandbox (from ) -- Lucene Spatial (from ) - Lucene Spatial 3D (from ) - Lucene Spatial Extras (from ) - Lucene Suggest (from ) @@ -435,35 +425,33 @@ The following software have components provided under the terms of this license: - 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://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/DNS (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/Resolver/DNS (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 ) - 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) - 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) - Objenesis (from http://objenesis.org) - OkHttp (from ) - OkHttp Logging Interceptor (from ) @@ -480,51 +468,79 @@ The following software have components provided under the terms of this license: - 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) - 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 Beans (from https://github.com/spring-projects/spring-framework) +- Spring Boot (from http://projects.spring.io/spring-boot/) - Spring Boot (from http://projects.spring.io/spring-boot/) - Spring Boot Actuator (from http://projects.spring.io/spring-boot/) +- Spring Boot Actuator (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 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 Actuator Starter (from http://projects.spring.io/spring-boot/) - Spring Boot AutoConfigure (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 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 Reactor Netty Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-reactor-netty) +- Spring Boot Security 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 Starter (from http://projects.spring.io/spring-boot/) +- Spring Boot Test (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 Auto-Configure (from http://projects.spring.io/spring-boot/) - Spring Boot Test Starter (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 Tomcat Starter (from http://projects.spring.io/spring-boot/) - Spring Boot Validation 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 Web Starter (from http://projects.spring.io/spring-boot/) +- Spring Boot WebFlux Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-webflux) +- 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 Core (from https://github.com/spring-projects/spring-framework) - Spring Data Core (from ) - 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 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 Reporter Brave (from https://repo1.maven.org/maven2/io/zipkin/reporter2/zipkin-reporter-brave) +- Zipkin Reporter: Core (from ) +- Zipkin v2 (from ) - 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) +- brave (from ) - 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) @@ -552,7 +568,6 @@ 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) - jakarta.xml.bind-api (from ) - java-cloudant (from https://cloudant.com) - java-cloudant (from https://cloudant.com) @@ -564,6 +579,7 @@ The following software have components provided under the terms of this license: - 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) - org.apiguardian:apiguardian-api (from https://github.com/apiguardian-team/apiguardian) - org.jetbrains.kotlin:kotlin-stdlib-common (from https://kotlinlang.org/) @@ -575,15 +591,19 @@ The following software have components provided under the terms of this license: - 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) - 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) @@ -611,6 +631,7 @@ The following software have components provided under the terms of this license: - Hamcrest Core (from http://hamcrest.org/) - HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) - Lucene Common Analyzers (from ) +- Lucene Core (from ) - Reflections (from http://github.com/ronmamo/reflections) - Stax2 API (from http://github.com/FasterXML/stax2-api) - ThreeTen backport (from https://www.threeten.org/threetenbp) @@ -639,12 +660,11 @@ The following software have components provided under the terms of this license: - 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 ) - Spring Core (from https://github.com/spring-projects/spring-framework) +- Spring Core (from https://github.com/spring-projects/spring-framework) - ThreeTen backport (from https://www.threeten.org/threetenbp) - google (from http://breakingcode.wordpress.com/) - jakarta.annotation-api (from https://projects.eclipse.org/projects/ee4j.ca) @@ -672,14 +692,12 @@ CC0-1.0 ======================================================================== The following software have components provided under the terms of this license: -- 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) - HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) - HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) - LatencyUtils (from http://latencyutils.github.io/LatencyUtils/) - Netty/Common (from ) -- Netty/Common (from ) - reactive-streams (from http://www.reactive-streams.org/) ======================================================================== @@ -696,8 +714,6 @@ 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) Default Provider (from http://jsonp.java.net) - JavaBeans(TM) Activation Framework (from http://java.sun.com/javase/technologies/desktop/javabeans/jaf/index.jsp) - tomcat-embed-core (from http://tomcat.apache.org/) @@ -714,7 +730,6 @@ DOC ======================================================================== The following software have components provided under the terms of this license: -- Woodstox (from https://github.com/FasterXML/woodstox) - aalto-xml (from ) ======================================================================== @@ -724,6 +739,7 @@ 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/) - Logback Contrib :: JSON :: Classic (from ) - Logback Contrib :: JSON :: Core (from ) - Logback Contrib :: Jackson (from ) @@ -733,10 +749,15 @@ The following software have components provided under the terms of this license: - Microsoft Application Insights Log4j 2 Appender (from https://github.com/Microsoft/ApplicationInsights-Java) - 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-api (from http://junit.org/junit5/) +- org.junit.jupiter:junit-jupiter-engine (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.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/) ======================================================================== @@ -746,12 +767,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/) - 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-api (from http://junit.org/junit5/) +- org.junit.jupiter:junit-jupiter-engine (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.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/) ======================================================================== @@ -760,8 +787,6 @@ GPL-2.0-only The following software have components provided under the terms of this license: - 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) Default Provider (from http://jsonp.java.net) - 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) @@ -775,8 +800,6 @@ 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) - Google Guice - Core Library (from ) -- JSR 353 (JSON Processing) API (from http://json-processing-spec.java.net) -- JSR 353 (JSON Processing) Default Provider (from http://jsonp.java.net) - JavaMail API (from ) - jakarta.annotation-api (from https://projects.eclipse.org/projects/ee4j.ca) - tomcat-embed-core (from http://tomcat.apache.org/) @@ -795,7 +818,6 @@ 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) - aalto-xml (from ) ======================================================================== @@ -833,13 +855,10 @@ The following software have components provided under the terms of this license: - Animal Sniffer Annotations (from ) - Apache Log4j SLF4J Binding (from ) - Apache Log4j to SLF4J Adapter (from ) -- Azure AD Spring Security Integration Spring Boot Starter (from https://github.com/Microsoft/azure-spring-boot) - 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) @@ -860,7 +879,6 @@ The following software have components provided under the terms of this license: - 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 ) - 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,11 +896,10 @@ 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://www.mockito.org) - Mockito (from http://mockito.org) +- 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 ) - Project Lombok (from https://projectlombok.org) - Project Lombok (from https://projectlombok.org) @@ -896,12 +913,15 @@ The following software have components provided under the terms of this license: - documentdb-bulkexecutor (from http://azure.microsoft.com/en-us/services/documentdb/) - jakarta.xml.bind-api (from ) - micrometer-core (from https://github.com/micrometer-metrics/micrometer) +- micrometer-core (from https://github.com/micrometer-metrics/micrometer) - 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-2.0 @@ -929,7 +949,6 @@ X11 ======================================================================== The following software have components provided under the terms of this license: -- 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) @@ -950,6 +969,7 @@ The following software have components provided under the terms of this license: - Microsoft Azure SDK for EventGrid Management (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) - Microsoft Azure client library for Blob Storage (from https://github.com/Azure/azure-sdk-for-java) +- 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) diff --git a/provider/schema-azure/pom.xml b/provider/schema-azure/pom.xml index 3f782a53..b7660bc1 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.11.0-SNAPSHOT + 0.10.0-SNAPSHOT 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 00000000..d1af034d --- /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 00000000..b95b6d04 --- /dev/null +++ b/provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/auth/AuthorizationFilterSP.java @@ -0,0 +1,18 @@ +package org.opengroup.osdu.schema.azure.auth; + +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 IAuthorizationServiceForServicePrincipal authorizationService; + + public boolean hasPermissions() { + 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 00000000..095a551e --- /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 157c6961..494fb590 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 f4371947..7a88a690 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 857fe46b..ecb9611d 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,8 +103,8 @@ 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(), 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); @@ -150,7 +154,7 @@ 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); @@ -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); } @@ -274,7 +278,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore { String id = dataPartitionId + ":" + flattenedSchemaInfo.getSupersededBy(); SchemaIdentity schemaIdentity = schemaKindToSchemaIdentity(flattenedSchemaInfo.getSupersededBy()); String partitionKey = createSchemaInfoPartitionKey(schemaIdentity); - SchemaInfoDoc doc = cosmosStore.findItem(dataPartitionId, cosmosDBName, schemaInfoContainer, id, partitionKey, SchemaInfoDoc.class).get(); + SchemaInfoDoc doc = findItemInCosmosStore(dataPartitionId, cosmosDBName, schemaInfoContainer, id, partitionKey, SchemaInfoDoc.class).get(); superSededBy = getSchemaIdentity(doc.getFlattenedSchemaInfo()); } @@ -352,7 +356,7 @@ 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) @@ -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 d1515c53..2b6be778 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 dc758a4b..3462747d 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 00000000..2c84ab64 --- /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 00000000..e9961617 --- /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 00000000..c396094c --- /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 00000000..ab9b2261 --- /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 09d57f1b..2e675128 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 00000000..de0d18f4 --- /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 398092dc..00000000 --- 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 b01f3c39..3324cb78 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 00000000..5fe4b796 --- /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 d5c11356..7010741d 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 d9814285..e5cb7138 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 9f14e1ad..080fd22d 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; @@ -44,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; @@ -53,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; @@ -96,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(); @@ -109,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 @@ -158,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); @@ -193,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 { @@ -312,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(); @@ -352,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 { @@ -518,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()) 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 0babb380..7580c6b3 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 93da8c5f..f05614c3 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 00000000..32ab6a08 --- /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(); + } +} -- GitLab From 81cec12758dad2ecc718bdd97ad6f19ac21fdb21 Mon Sep 17 00:00:00 2001 From: Aman Verma Date: Wed, 30 Jun 2021 19:26:39 +0000 Subject: [PATCH 12/30] Adding integration tests schemas/system endpoint --- .gitlab-ci.yml | 1 + NOTICE | 3 + .../azure/auth/AuthorizationFilterSP.java | 5 + testing/schema-test-azure/pom.xml | 168 ++++++ .../osdu/schema/constants/HttpConnection.java | 10 + .../osdu/schema/constants/TestConstants.java | 57 ++ .../runner/PreIntegrationTestsRunner.java | 13 + .../runner/SchemaServiceTestsRunner.java | 13 + .../schema/runner/TearDownTestsRunner.java | 13 + .../schema/stepdefs/LocalSetupStepDef.java | 12 + .../stepdefs/SchemaServiceStepDef_GET.java | 182 ++++++ .../stepdefs/SchemaServiceStepDef_PUT.java | 437 ++++++++++++++ .../schema/stepdefs/TearDownStepDefs.java | 5 + .../schema/stepdefs/model/HttpRequest.java | 37 ++ .../schema/stepdefs/model/HttpResponse.java | 17 + .../stepdefs/model/SchemaServiceScope.java | 106 ++++ .../opengroup/osdu/schema/util/AuthUtil.java | 22 + .../opengroup/osdu/schema/util/FileUtils.java | 28 + .../osdu/schema/util/HttpClient.java | 10 + .../osdu/schema/util/HttpClientFactory.java | 12 + .../opengroup/osdu/schema/util/JsonUtils.java | 19 + .../osdu/schema/util/RestAssuredClient.java | 73 +++ .../IntegrationTest_SchemaService_PUT.feature | 163 ++++++ .../features/post_integration.feature | 2 + .../features/pre_integration.feature | 1 + .../input_payloads/PUT_ModifySchemaInfo.json | 21 + .../inputPayloadWithExistingVersion.json | 17 + .../inputPayloadWithIncorrectJSON.json | 18 + .../postInPrivateScope_positiveScenario.json | 544 ++++++++++++++++++ ...SchemaServiceWithRef_positiveScenario.json | 67 +++ .../postSchemaService_EmptySchema.json | 16 + .../postSchema_InvalidRefSchemaObject.json | 49 ++ .../postSchema_RefNotResolvable.json | 49 ++ .../postSchema_flattenedSchemaAsInput.json | 123 ++++ ...stSchema_withEntityAttributeInPayload.json | 544 ++++++++++++++++++ .../putUpdatedSchema_positiveScenario.json | 28 + .../supercededInputPayload_positive.json | 26 + .../PostSchema_EntityNotAllowedError.json | 13 + .../PostSchema_InvalidInputSchemaError.json | 13 + .../PostSchema_InvalidRefSchemaObject.json | 13 + .../PostSchema_RefNotResolvable.json | 13 + .../output_payloads/ResolvedSchema.json | 530 +++++++++++++++++ .../SchemaPost_BreakingChangeError.json | 13 + .../SchemaPost_IncorrectJsonError.json | 13 + ...aPost_PrivateScope_SuccessfulCreation.json | 15 + .../SchemaPut_InvalidStatusMessage.json | 13 + .../UpdatedResolvedSchema.json | 14 + .../UpdatedSchema_EntityTypeUpdate.json | 4 + 48 files changed, 3565 insertions(+) create mode 100644 testing/schema-test-azure/pom.xml create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/constants/HttpConnection.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/constants/TestConstants.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/runner/PreIntegrationTestsRunner.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/runner/SchemaServiceTestsRunner.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/runner/TearDownTestsRunner.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/LocalSetupStepDef.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_GET.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/SchemaServiceStepDef_PUT.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/TearDownStepDefs.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/model/HttpRequest.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/model/HttpResponse.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/stepdefs/model/SchemaServiceScope.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/AuthUtil.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/FileUtils.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/HttpClient.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/HttpClientFactory.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/JsonUtils.java create mode 100644 testing/schema-test-azure/src/test/java/org/opengroup/osdu/schema/util/RestAssuredClient.java create mode 100644 testing/schema-test-azure/src/test/resources/features/IntegrationTest_SchemaService_PUT.feature create mode 100644 testing/schema-test-azure/src/test/resources/features/post_integration.feature create mode 100644 testing/schema-test-azure/src/test/resources/features/pre_integration.feature create mode 100644 testing/schema-test-azure/src/test/resources/input_payloads/PUT_ModifySchemaInfo.json create mode 100644 testing/schema-test-azure/src/test/resources/input_payloads/inputPayloadWithExistingVersion.json create mode 100644 testing/schema-test-azure/src/test/resources/input_payloads/inputPayloadWithIncorrectJSON.json create mode 100644 testing/schema-test-azure/src/test/resources/input_payloads/postInPrivateScope_positiveScenario.json create mode 100644 testing/schema-test-azure/src/test/resources/input_payloads/postSchemaServiceWithRef_positiveScenario.json create mode 100644 testing/schema-test-azure/src/test/resources/input_payloads/postSchemaService_EmptySchema.json create mode 100644 testing/schema-test-azure/src/test/resources/input_payloads/postSchema_InvalidRefSchemaObject.json create mode 100644 testing/schema-test-azure/src/test/resources/input_payloads/postSchema_RefNotResolvable.json create mode 100644 testing/schema-test-azure/src/test/resources/input_payloads/postSchema_flattenedSchemaAsInput.json create mode 100644 testing/schema-test-azure/src/test/resources/input_payloads/postSchema_withEntityAttributeInPayload.json create mode 100644 testing/schema-test-azure/src/test/resources/input_payloads/putUpdatedSchema_positiveScenario.json create mode 100644 testing/schema-test-azure/src/test/resources/input_payloads/supercededInputPayload_positive.json create mode 100644 testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_EntityNotAllowedError.json create mode 100644 testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_InvalidInputSchemaError.json create mode 100644 testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_InvalidRefSchemaObject.json create mode 100644 testing/schema-test-azure/src/test/resources/output_payloads/PostSchema_RefNotResolvable.json create mode 100644 testing/schema-test-azure/src/test/resources/output_payloads/ResolvedSchema.json create mode 100644 testing/schema-test-azure/src/test/resources/output_payloads/SchemaPost_BreakingChangeError.json create mode 100644 testing/schema-test-azure/src/test/resources/output_payloads/SchemaPost_IncorrectJsonError.json create mode 100644 testing/schema-test-azure/src/test/resources/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation.json create mode 100644 testing/schema-test-azure/src/test/resources/output_payloads/SchemaPut_InvalidStatusMessage.json create mode 100644 testing/schema-test-azure/src/test/resources/output_payloads/UpdatedResolvedSchema.json create mode 100644 testing/schema-test-azure/src/test/resources/output_payloads/UpdatedSchema_EntityTypeUpdate.json diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 45339b7b..e3bda258 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 diff --git a/NOTICE b/NOTICE index ed6d296c..daa585f1 100644 --- a/NOTICE +++ b/NOTICE @@ -714,6 +714,7 @@ CDDL-1.1 ======================================================================== The following software have components provided under the terms of this license: +- JavaBeans Activation Framework (from ) - JavaBeans(TM) Activation Framework (from http://java.sun.com/javase/technologies/desktop/javabeans/jaf/index.jsp) - tomcat-embed-core (from http://tomcat.apache.org/) @@ -787,6 +788,7 @@ GPL-2.0-only The following software have components provided under the terms of this license: - Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) +- 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) @@ -800,6 +802,7 @@ 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) - Google Guice - Core Library (from ) +- JavaBeans Activation Framework (from ) - JavaMail API (from ) - jakarta.annotation-api (from https://projects.eclipse.org/projects/ee4j.ca) - tomcat-embed-core (from http://tomcat.apache.org/) 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 index b95b6d04..0441565a 100644 --- 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 @@ -1,5 +1,6 @@ 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; @@ -9,10 +10,14 @@ import org.springframework.web.context.annotation.RequestScope; @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/testing/schema-test-azure/pom.xml b/testing/schema-test-azure/pom.xml new file mode 100644 index 00000000..ee3d55f5 --- /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 00000000..c3fba017 --- /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 00000000..4b4946a3 --- /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 00000000..f0cdd4e8 --- /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 00000000..385545c2 --- /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 00000000..71de8088 --- /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 00000000..c85be6bc --- /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 00000000..a043eee8 --- /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 00000000..5935d024 --- /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 00000000..cd2d0bbf --- /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 00000000..b29857a3 --- /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 00000000..a162b40f --- /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 00000000..471f34a7 --- /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 00000000..72ecdb9a --- /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 00000000..4da7d9b2 --- /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 00000000..aaeb18ea --- /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 00000000..8b5a8d6f --- /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 00000000..5e29093f --- /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 00000000..6d5b96a1 --- /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 00000000..01c911a9 --- /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 00000000..518edfd1 --- /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 00000000..ba3581bc --- /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 00000000..ca6e95f4 --- /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 00000000..460f89ef --- /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 00000000..501c2704 --- /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 00000000..a25d2ca7 --- /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 00000000..e434331f --- /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 00000000..23d34437 --- /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 00000000..eb4220da --- /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 00000000..e6ad482a --- /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 00000000..82b55eff --- /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 00000000..f1e380f3 --- /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 00000000..68b25824 --- /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 00000000..75050c43 --- /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 00000000..dc0bc73e --- /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 00000000..b331dfe1 --- /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 00000000..3dcfb578 --- /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 00000000..fda2ccc3 --- /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 00000000..39c757e5 --- /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 00000000..0fd462e6 --- /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 00000000..770a0f94 --- /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 00000000..9f63648f --- /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 00000000..2031eea6 --- /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 00000000..174496c0 --- /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 00000000..02305590 --- /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 -- GitLab From 612b6bb25c5fe7485c2f6028fd42489e5e5363df Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 1 Jul 2021 12:32:16 +0000 Subject: [PATCH 13/30] Schema validation changes --- NOTICE | 7 +- docs/SchemaService-OSDU.md | 66 + schema-core/pom.xml | 11 +- .../schema/constants/SchemaConstants.java | 51 +- .../exceptions/SchemaVersionException.java | 36 + .../osdu/schema/model/SchemaRequest.java | 4 +- .../service/serviceimpl/SchemaService.java | 89 +- .../opengroup/osdu/schema/util/JSONUtil.java | 100 + .../util/SchemaComparatorByVersion.java | 25 + .../osdu/schema/util/SchemaUtil.java | 87 +- .../SchemaMinorVersionValidator.java | 213 ++ .../SchemaPatchVersionValidator.java | 82 + ...aint.java => SchemaRequestConstraint.java} | 4 +- ...dator.java => SchemaRequestValidator.java} | 2 +- .../validation/SchemaVersionValidator.java | 13 + .../SchemaVersionValidatorFactory.java | 21 + .../SchemaVersionValidatorType.java | 6 + .../serviceimpl/SchemaServiceTest.java | 1919 +++++++++-------- .../opengroup/osdu/schema/util/FileUtils.java | 15 + .../osdu/schema/util/JSONUtilTest.java | 113 + .../osdu/schema/util/SchemaUtilTest.java | 260 ++- .../SchemaMinorVersionValidatorTest.java | 143 ++ .../SchemaPatchVersionValidatorTest.java | 74 + ...t.java => SchemaRequestValidatorTest.java} | 4 +- .../schema-with-allOf-Title-Missing.json | 32 + .../schema-with-existing-attr-removed.json | 58 + ...eOf-Orderchanged-Title-WithNonRefAttr.json | 41 + ...-with-oneOf-changeinorder-withoutitle.json | 61 + .../schema-with-oneOf-removedelement.json | 43 + .../fail/schema-with-removed-oneof.json | 12 + .../schema-with-reqprop-changeelement.json | 61 + .../schema-with-reqprop-extraelement.json | 62 + .../schema-with-reqprop-removingelement.json | 43 + .../schema-with-type-attribute-change.json | 30 + .../fail/schema-wth-addprop-add-false.json | 61 + .../original-complex-oneOf-With-Title.json | 239 ++ .../original-schema-with-oneOf-Title.json | 32 + .../minor_level_changes/original.json | 30 + ...llOf-ElementJumbled-NewAttributeAdded.json | 243 +++ ...NestedoneOf-ElementJumbled-With-Title.json | 239 ++ ...mplex-oneOf-ElementJumbled-With-Title.json | 239 ++ ...-oneOf-Orderchanged-Title-WithRefAttr.json | 39 + .../schema-with-oneOf-Orderchanged-Title.json | 32 + .../schema-with-additional-attribute.json | 64 + .../pass/schema-with-addprop-add-true.json | 61 + ...a-with-oneOf-addelement-without-title.json | 75 + .../schema-with-reqprop-changeinorder.json | 61 + .../schema_compare/original-schema.json | 30 + .../schema-with-all-permissible-changes.json | 60 + .../schema-with-comment-added.json | 33 + .../schema-with-examples-added.json | 33 + .../schema-with-id-added.json | 31 + .../schema-with-title-changed.json | 33 + .../schema-with-xosdu-added.json | 33 + .../schema-wtih-description-added.json | 31 + .../schema-wtih-pattern-added.json | 53 + .../stepdefs/SchemaServiceStepDef_GET.java | 2 +- .../stepdefs/SchemaServiceStepDef_POST.java | 243 ++- .../stepdefs/SchemaServiceStepDef_PUT.java | 216 +- ...tionTest_SchemaService_Nested_POST.feature | 199 ++ ...IntegrationTest_SchemaService_POST.feature | 12 +- ...hemaService_POST_SchemaValidations.feature | 212 ++ .../IntegrationTest_SchemaService_PUT.feature | 8 +- ...chemaService_PUT_SchemaValidations.feature | 219 ++ .../resources/input_payloads/Base_Schema.json | 43 + .../Base_Schema_AddedAttribute.json | 75 + .../Base_Schema_AdditionalPropIsF.json | 74 + .../Base_Schema_AdditionalPropIsT.json | 74 + .../input_payloads/Base_Schema_ID.json | 44 + .../Base_Schema_JumbledOneOfWithFalseAP.json | 101 + .../Base_Schema_MultipleChanges.json | 72 + .../Base_Schema_NestedoneOf.json | 101 + ..._Schema_NestedoneOf_AddedExtraElement.json | 113 + .../Base_Schema_NestedoneOf_JumbeledRef.json | 101 + ...Base_Schema_NestedoneOf_RemoveElement.json | 101 + .../input_payloads/Base_Schema_New.json | 72 + .../Base_Schema_RemovedAttribute.json | 69 + ...hema_RemovedAttributeFromOneOfElement.json | 69 + .../Base_Schema_ReplacedAttribute.json | 75 + .../input_payloads/Base_Schema_Title.json | 44 + .../Base_Schema_TypeChanged.json | 43 + .../Base_Schema_WithFalseAP.json | 74 + .../input_payloads/Base_Schema_WithoutAP.json | 73 + .../Base_Schema_x-osdu-added.json | 46 + .../input_payloads/Nested_Base_Schema.json | 115 + .../Nested_Base_Schema_AddedAttribute.json | 127 ++ .../Nested_Base_Schema_AdditionalPropIsF.json | 122 ++ .../Nested_Base_Schema_AdditionalPropIsT.json | 122 ++ .../input_payloads/Nested_Base_Schema_ID.json | 116 + ...d_Base_Schema_JumbledOneOfWithFalseAP.json | 137 ++ .../Nested_Base_Schema_MultipleChanges.json | 120 ++ .../Nested_Base_Schema_NestedoneOf.json | 101 + ..._Schema_NestedoneOf_AddedExtraElement.json | 113 + ...d_Base_Schema_NestedoneOf_JumbeledRef.json | 101 + ...Base_Schema_NestedoneOf_RemoveElement.json | 101 + .../Nested_Base_Schema_New.json | 124 ++ .../Nested_Base_Schema_RemovedAttribute.json | 132 ++ ...hema_RemovedAttributeFromOneOfElement.json | 121 ++ .../Nested_Base_Schema_ReplacedAttribute.json | 138 ++ .../Nested_Base_Schema_Title.json | 116 + .../Nested_Base_Schema_WithFalseAP.json | 122 ++ .../Nested_Base_Schema_WithoutAP.json | 121 ++ .../Nested_Base_Schema_x-osdu-added.json | 121 ++ ...hemaServiceWithAbsentRefInDefinitions.json | 58 + ...SchemaServiceWithRef_positiveScenario.json | 2 +- .../SchemaPost_MinorBreakingChangeError.json | 13 + .../SchemaPost_OneOfBreakingChangeError.json | 13 + .../SchemaPost_Patch_BreakingChangeError.json | 13 + ...Post_PrivateScope_SuccessfulCreation2.json | 15 + .../SchemaPost_SuccessfulCreation.json | 15 + 110 files changed, 9488 insertions(+), 1026 deletions(-) create mode 100644 schema-core/src/main/java/org/opengroup/osdu/schema/exceptions/SchemaVersionException.java create mode 100644 schema-core/src/main/java/org/opengroup/osdu/schema/util/JSONUtil.java create mode 100644 schema-core/src/main/java/org/opengroup/osdu/schema/util/SchemaComparatorByVersion.java create mode 100644 schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaMinorVersionValidator.java create mode 100644 schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaPatchVersionValidator.java rename schema-core/src/main/java/org/opengroup/osdu/schema/validation/{SchemaConstraint.java => SchemaRequestConstraint.java} (85%) rename schema-core/src/main/java/org/opengroup/osdu/schema/validation/{SchemaValidator.java => SchemaRequestValidator.java} (89%) create mode 100644 schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaVersionValidator.java create mode 100644 schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaVersionValidatorFactory.java create mode 100644 schema-core/src/main/java/org/opengroup/osdu/schema/validation/SchemaVersionValidatorType.java create mode 100644 schema-core/src/test/java/org/opengroup/osdu/schema/util/JSONUtilTest.java create mode 100644 schema-core/src/test/java/org/opengroup/osdu/schema/validation/SchemaMinorVersionValidatorTest.java create mode 100644 schema-core/src/test/java/org/opengroup/osdu/schema/validation/SchemaPatchVersionValidatorTest.java rename schema-core/src/test/java/org/opengroup/osdu/schema/validation/{SchemaValidatorTest.java => SchemaRequestValidatorTest.java} (93%) create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/fail-with-title/schema-with-allOf-Title-Missing.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-existing-attr-removed.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-oneOf-Orderchanged-Title-WithNonRefAttr.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-oneOf-changeinorder-withoutitle.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-oneOf-removedelement.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-removed-oneof.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-reqprop-changeelement.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-reqprop-extraelement.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-reqprop-removingelement.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-with-type-attribute-change.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/fail/schema-wth-addprop-add-false.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/original-complex-oneOf-With-Title.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/original-schema-with-oneOf-Title.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/original.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/pass-complex/new-complex-NestedAllOf-ElementJumbled-NewAttributeAdded.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/pass-complex/new-complex-NestedoneOf-ElementJumbled-With-Title.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/pass-complex/new-complex-oneOf-ElementJumbled-With-Title.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/pass-with-title/schema-with-oneOf-Orderchanged-Title-WithRefAttr.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/pass-with-title/schema-with-oneOf-Orderchanged-Title.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-additional-attribute.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-addprop-add-true.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-oneOf-addelement-without-title.json create mode 100644 schema-core/src/test/resources/schema_compare/minor_level_changes/pass/schema-with-reqprop-changeinorder.json create mode 100644 schema-core/src/test/resources/schema_compare/original-schema.json create mode 100644 schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-all-permissible-changes.json create mode 100644 schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-comment-added.json create mode 100644 schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-examples-added.json create mode 100644 schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-id-added.json create mode 100644 schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-title-changed.json create mode 100644 schema-core/src/test/resources/schema_compare/patch_level_changes/schema-with-xosdu-added.json create mode 100644 schema-core/src/test/resources/schema_compare/patch_level_changes/schema-wtih-description-added.json create mode 100644 schema-core/src/test/resources/schema_compare/patch_level_changes/schema-wtih-pattern-added.json create mode 100644 testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_Nested_POST.feature create mode 100644 testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_POST_SchemaValidations.feature create mode 100644 testing/schema-test-core/src/test/resources/features/IntegrationTest_SchemaService_PUT_SchemaValidations.feature create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_AddedAttribute.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_AdditionalPropIsF.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_AdditionalPropIsT.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_ID.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_JumbledOneOfWithFalseAP.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_MultipleChanges.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf_AddedExtraElement.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf_JumbeledRef.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_NestedoneOf_RemoveElement.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_New.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_RemovedAttribute.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_RemovedAttributeFromOneOfElement.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_ReplacedAttribute.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_Title.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_TypeChanged.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_WithFalseAP.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_WithoutAP.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Base_Schema_x-osdu-added.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_AddedAttribute.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_AdditionalPropIsF.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_AdditionalPropIsT.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_ID.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_JumbledOneOfWithFalseAP.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_MultipleChanges.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf_AddedExtraElement.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf_JumbeledRef.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_NestedoneOf_RemoveElement.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_New.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_RemovedAttribute.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_RemovedAttributeFromOneOfElement.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_ReplacedAttribute.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_Title.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_WithFalseAP.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_WithoutAP.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/Nested_Base_Schema_x-osdu-added.json create mode 100644 testing/schema-test-core/src/test/resources/input_payloads/postSchemaServiceWithAbsentRefInDefinitions.json create mode 100644 testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_MinorBreakingChangeError.json create mode 100644 testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_OneOfBreakingChangeError.json create mode 100644 testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_Patch_BreakingChangeError.json create mode 100644 testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation2.json create mode 100644 testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_SuccessfulCreation.json diff --git a/NOTICE b/NOTICE index daa585f1..9b0572d5 100644 --- a/NOTICE +++ b/NOTICE @@ -714,6 +714,8 @@ 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) 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) - tomcat-embed-core (from http://tomcat.apache.org/) @@ -788,6 +790,8 @@ GPL-2.0-only The following software have components provided under the terms of this license: - 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) 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) @@ -802,6 +806,8 @@ 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) - Google Guice - Core Library (from ) +- 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) @@ -989,4 +995,3 @@ The following software have components provided under the terms of this license: - JavaMail API (from ) - Spongy Castle (from http://rtyley.github.io/spongycastle/) - diff --git a/docs/SchemaService-OSDU.md b/docs/SchemaService-OSDU.md index 131d9fdf..2f6d3e39 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/schema-core/pom.xml b/schema-core/pom.xml index 7bf3b463..94baf99a 100644 --- a/schema-core/pom.xml +++ b/schema-core/pom.xml @@ -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 c39fe857..3a76a61e 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 00000000..64fdf58f --- /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 049a4d95..b048fab2 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 3ba008e3..55b79a1d 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 00000000..490e8de6 --- /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 00000000..8ff9b0e2 --- /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 b18b981e..4a54b75a 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 00000000..a29dd520 --- /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 00000000..acd25fba --- /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 3100c0a7..d1962d9c 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 03a90b50..e66eb677 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 00000000..d68b0da8 --- /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 00000000..32654b16 --- /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 00000000..5e26377d --- /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 1b452d75..d47be2c9 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 4da7d9b2..8e40d97a 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 00000000..b6991476 --- /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 744a5b67..1517e69f 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 00000000..c7e07b4f --- /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 00000000..7635c6a9 --- /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 9c278190..3a472e0b 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 00000000..06831c84 --- /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 00000000..0fb347fd --- /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 00000000..9a0d694d --- /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 00000000..836ff024 --- /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 00000000..6b5df8ae --- /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 00000000..1f7d9f0b --- /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 00000000..ba9608f0 --- /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 00000000..eabb5aaa --- /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 00000000..6b5df8ae --- /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 00000000..387addff --- /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 00000000..15fff6a6 --- /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 00000000..eaf50ae7 --- /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 00000000..e3d07fca --- /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 00000000..87046daa --- /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 00000000..631f34b9 --- /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 00000000..bfa435a0 --- /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 00000000..833d433a --- /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 00000000..f393ed86 --- /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 00000000..c0f321a4 --- /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 00000000..9e71b01c --- /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 00000000..1e3446ee --- /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 00000000..d30fc0ce --- /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 00000000..1e3446ee --- /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 00000000..127e3f3d --- /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 00000000..f3dba875 --- /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 00000000..b66a36f1 --- /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 00000000..1b548448 --- /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 00000000..a8f93e3e --- /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 00000000..fa16975d --- /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 00000000..bcee7be6 --- /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 00000000..04ecdd63 --- /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 00000000..92c2576c --- /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-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 ca47c96a..02d125a4 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 bf62b860..975f9394 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 ddf15bba..ccc6183d 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 00000000..03aab513 --- /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 7116e62f..f98965d1 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 00000000..9ca339d2 --- /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 05a40788..52776df3 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 00000000..17a70551 --- /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 00000000..6ee973ff --- /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 00000000..421eec6a --- /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 00000000..b55756c4 --- /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 00000000..610613fe --- /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 00000000..55c25429 --- /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 00000000..81edcf30 --- /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 00000000..9c6a0e23 --- /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 00000000..c63a6d52 --- /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 00000000..8feeaa22 --- /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 00000000..4af18141 --- /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 00000000..ed3d52ea --- /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 00000000..f40ec96b --- /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 00000000..03dbc930 --- /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 00000000..03dbc930 --- /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 00000000..64649c4a --- /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 00000000..ef78f224 --- /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 00000000..d5320cd5 --- /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 00000000..808f4e8b --- /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 00000000..196c1b4f --- /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 00000000..99968514 --- /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 00000000..44634c68 --- /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 00000000..f71b7962 --- /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 00000000..9dbfb477 --- /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 00000000..37ae66b2 --- /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 00000000..d7bc3365 --- /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 00000000..d2d1038d --- /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 00000000..1a0c6663 --- /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 00000000..c63a6d52 --- /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 00000000..8feeaa22 --- /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 00000000..4af18141 --- /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 00000000..ed3d52ea --- /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 00000000..1f46c1fd --- /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 00000000..2bae6345 --- /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 00000000..c4f83816 --- /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 00000000..28700eed --- /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 00000000..8b87bf9b --- /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 00000000..9dbfb477 --- /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 00000000..75a5cc6c --- /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 00000000..f17963f6 --- /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-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" + ] + } + ] +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/input_payloads/postSchemaServiceWithAbsentRefInDefinitions.json b/testing/schema-test-core/src/test/resources/input_payloads/postSchemaServiceWithAbsentRefInDefinitions.json new file mode 100644 index 00000000..7b02214a --- /dev/null +++ b/testing/schema-test-core/src/test/resources/input_payloads/postSchemaServiceWithAbsentRefInDefinitions.json @@ -0,0 +1,58 @@ +{ + "schemaInfo": { + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 1, + "schemaVersionMinor": 1, + "schemaVersionPatch": 0, + "id": "SchemaSanityTest: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":{ + + }, + "properties":{ + "locationOriginalCRS":{ + "description":"Thewell'soriginallocationasAnyCrsFeatureCollection-astructuresimilartobutdistinctfromGeoJSON.", + "title":"OriginalCRSLocation", + "$ref":"#/definition/anyCrsFeatureCollection.1.0" + }, + "allOf":{ + "$ref":"#/definition/osdu..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" + } + } + } +} +} diff --git a/testing/schema-test-core/src/test/resources/input_payloads/postSchemaServiceWithRef_positiveScenario.json b/testing/schema-test-core/src/test/resources/input_payloads/postSchemaServiceWithRef_positiveScenario.json index 87c09729..c565db1b 100644 --- a/testing/schema-test-core/src/test/resources/input_payloads/postSchemaServiceWithRef_positiveScenario.json +++ b/testing/schema-test-core/src/test/resources/input_payloads/postSchemaServiceWithRef_positiveScenario.json @@ -64,4 +64,4 @@ } } } -} \ No newline at end of file +} diff --git a/testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_MinorBreakingChangeError.json b/testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_MinorBreakingChangeError.json new file mode 100644 index 00000000..fc09a4a1 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_MinorBreakingChangeError.json @@ -0,0 +1,13 @@ +{ + "error": { + "code": 400, + "message": "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.", + "errors": [ + { + "domain": "global", + "reason": "badRequest", + "message": "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." + } + ] + } +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_OneOfBreakingChangeError.json b/testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_OneOfBreakingChangeError.json new file mode 100644 index 00000000..d45f1e12 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_OneOfBreakingChangeError.json @@ -0,0 +1,13 @@ +{ + "error": { + "code": 400, + "message": "Changing list of \"oneOf\",\"allOf\" or \"anyOf\" is not permitted, please change schema major version", + "errors": [ + { + "domain": "global", + "reason": "badRequest", + "message": "Changing list of \"oneOf\",\"allOf\" or \"anyOf\" is not permitted, please change schema major version" + } + ] + } +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_Patch_BreakingChangeError.json b/testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_Patch_BreakingChangeError.json new file mode 100644 index 00000000..9cdf51f1 --- /dev/null +++ b/testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_Patch_BreakingChangeError.json @@ -0,0 +1,13 @@ +{ + "error": { + "code": 400, + "message": "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.", + "errors": [ + { + "domain": "global", + "reason": "badRequest", + "message": "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." + } + ] + } +} \ No newline at end of file diff --git a/testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation2.json b/testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation2.json new file mode 100644 index 00000000..9d20871a --- /dev/null +++ b/testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_PrivateScope_SuccessfulCreation2.json @@ -0,0 +1,15 @@ +{ + "schemaIdentity": { + "authority": "testAuthority1", + "source": "local", + "entityType": "schema-validation1", + "schemaVersionMajor": 1, + "schemaVersionMinor": 1, + "schemaVersionPatch": 0, + "id": "SchemaSanityTest: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-core/src/test/resources/output_payloads/SchemaPost_SuccessfulCreation.json b/testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_SuccessfulCreation.json new file mode 100644 index 00000000..b367feac --- /dev/null +++ b/testing/schema-test-core/src/test/resources/output_payloads/SchemaPost_SuccessfulCreation.json @@ -0,0 +1,15 @@ +{ + "schemaIdentity": { + "authority": "SchemaSanityTest", + "source": "testSource", + "entityType": "testEntity", + "schemaVersionMajor": 1, + "schemaVersionMinor": 1, + "schemaVersionPatch": 0, + "id": "SchemaSanityTest: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" +} -- GitLab From e968ae337bf12182d54319966bd6961c1c6225b2 Mon Sep 17 00:00:00 2001 From: Gokul Nagare Date: Fri, 2 Jul 2021 05:58:00 +0000 Subject: [PATCH 14/30] non zero check added on limit --- .../osdu/schema/impl/schemainfostore/IbmSchemaInfoStore.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 97c25fbc..0d0d2792 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()); } -- GitLab From 476d35388b673a19356408623a575c00abf1d4a3 Mon Sep 17 00:00:00 2001 From: "Mikhail Piatliou (EPAM)" Date: Mon, 5 Jul 2021 09:38:13 +0000 Subject: [PATCH 15/30] Add helms for schema service [GONRG-2682] --- devops/gcp/configmap/.helmignore | 23 +++++++ devops/gcp/configmap/Chart.yaml | 24 +++++++ devops/gcp/configmap/templates/configmap.yml | 15 +++++ devops/gcp/configmap/values.yaml | 15 +++++ devops/gcp/deploy/.helmignore | 23 +++++++ devops/gcp/deploy/Chart.yaml | 24 +++++++ devops/gcp/deploy/templates/_helpers.tpl | 62 +++++++++++++++++++ devops/gcp/deploy/templates/deployment.yaml | 36 +++++++++++ devops/gcp/deploy/templates/service.yaml | 18 ++++++ .../gcp/deploy/templates/virtual-service.yml | 19 ++++++ devops/gcp/deploy/values.yaml | 15 +++++ 11 files changed, 274 insertions(+) create mode 100644 devops/gcp/configmap/.helmignore create mode 100644 devops/gcp/configmap/Chart.yaml create mode 100644 devops/gcp/configmap/templates/configmap.yml create mode 100644 devops/gcp/configmap/values.yaml create mode 100644 devops/gcp/deploy/.helmignore create mode 100644 devops/gcp/deploy/Chart.yaml create mode 100644 devops/gcp/deploy/templates/_helpers.tpl create mode 100644 devops/gcp/deploy/templates/deployment.yaml create mode 100644 devops/gcp/deploy/templates/service.yaml create mode 100644 devops/gcp/deploy/templates/virtual-service.yml create mode 100644 devops/gcp/deploy/values.yaml diff --git a/devops/gcp/configmap/.helmignore b/devops/gcp/configmap/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /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 00000000..a5adcc32 --- /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/configmap.yml b/devops/gcp/configmap/templates/configmap.yml new file mode 100644 index 00000000..426fca03 --- /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 00000000..ad37e58e --- /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: "" + 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 00000000..0e8a0eb3 --- /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 00000000..0cde2760 --- /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 00000000..7292128a --- /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 00000000..0244bc0d --- /dev/null +++ b/devops/gcp/deploy/templates/deployment.yaml @@ -0,0 +1,36 @@ +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 }}" + 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 00000000..d92e1b6f --- /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 00000000..56fa8894 --- /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 00000000..2b9bf3c0 --- /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: "128M" + limits_cpu: "1" + limits_memory: "1G" + serviceAccountName: "" + image: "" + +conf: + configmap: "schema-config" + app_name: "schema" -- GitLab From 3204e5ab225fb05dbaed8879a4d79837203a887e Mon Sep 17 00:00:00 2001 From: "Mikhail Piatliou (EPAM)" Date: Mon, 5 Jul 2021 11:34:34 +0000 Subject: [PATCH 16/30] Added path to GCP helms [GONRG-2682] --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e3bda258..25cce3de 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -39,6 +39,7 @@ variables: 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_HELM_PACKAGE_CHARTS: "devops/gcp/deploy devops/gcp/configmap" include: - project: "osdu/platform/ci-cd-pipelines" -- GitLab From d604f9eb3c7f91b77a1258f7317e46caa88f816b Mon Sep 17 00:00:00 2001 From: "Mikhail Piatliou (EPAM)" Date: Tue, 6 Jul 2021 08:33:04 +0000 Subject: [PATCH 17/30] Update GCP helms for schema [GONRG-2682] --- devops/gcp/configmap/templates/_helpers.tpl | 62 +++++++++++++++++++++ devops/gcp/configmap/values.yaml | 2 +- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 devops/gcp/configmap/templates/_helpers.tpl diff --git a/devops/gcp/configmap/templates/_helpers.tpl b/devops/gcp/configmap/templates/_helpers.tpl new file mode 100644 index 00000000..fa972f28 --- /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/values.yaml b/devops/gcp/configmap/values.yaml index ad37e58e..36b9e880 100644 --- a/devops/gcp/configmap/values.yaml +++ b/devops/gcp/configmap/values.yaml @@ -5,7 +5,7 @@ data: log_level: "" authorize_api: "" - authorize_api_key: "" + authorize_api_key: "Null" partition_api: "" google_audiences: "" shared_tenant_name: "" -- GitLab From 1043099a23e760b44c641fd7f5314b4a13167752 Mon Sep 17 00:00:00 2001 From: Aman Verma Date: Tue, 13 Jul 2021 10:58:35 +0000 Subject: [PATCH 18/30] updating the core-lib-azure version in azure related pom.xml --- NOTICE | 142 ++++++++++++++++++++++++++-------- provider/schema-azure/pom.xml | 2 +- 2 files changed, 110 insertions(+), 34 deletions(-) diff --git a/NOTICE b/NOTICE index 9b0572d5..a8dd5f3b 100644 --- a/NOTICE +++ b/NOTICE @@ -425,8 +425,8 @@ The following software have components provided under the terms of this license: - 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://mockito.org) - Mockito (from http://www.mockito.org) +- Mockito (from http://mockito.org) - Netty Reactive Streams HTTP support (from ) - Netty Reactive Streams Implementation (from ) - Netty/Buffer (from http://netty.io/) @@ -568,7 +568,6 @@ 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) -- jakarta.xml.bind-api (from ) - java-cloudant (from https://cloudant.com) - java-cloudant (from https://cloudant.com) - javatuples (from http://www.javatuples.org) @@ -644,13 +643,16 @@ The following software have components provided under the terms of this license: - API Common (from https://github.com/googleapis) - ASM Core (from ) - ASM Core (from ) -- Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) +- 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 ) +- 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 ) @@ -663,11 +665,12 @@ The following software have components provided under the terms of this license: - Netty/Codec/HTTP (from ) - Protocol Buffer Java API (from https://developers.google.com/protocol-buffers/) - Protocol Buffers [Util] (from ) +- Reflections (from http://github.com/ronmamo/reflections) +- SnakeYAML (from http://www.snakeyaml.org) - Spring Core (from https://github.com/spring-projects/spring-framework) - Spring Core (from https://github.com/spring-projects/spring-framework) - ThreeTen backport (from https://www.threeten.org/threetenbp) - google (from http://breakingcode.wordpress.com/) -- jakarta.annotation-api (from https://projects.eclipse.org/projects/ee4j.ca) - jakarta.xml.bind-api (from ) ======================================================================== @@ -692,32 +695,20 @@ CC0-1.0 ======================================================================== The following software have components provided under the terms of this license: -- 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) -- HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) -- HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) -- LatencyUtils (from http://latencyutils.github.io/LatencyUtils/) -- Netty/Common (from ) - reactive-streams (from http://www.reactive-streams.org/) -======================================================================== -CDDL-1.0 -======================================================================== -The following software have components provided under the terms of this license: - -- Apache Log4j Core (from ) -- JavaBeans(TM) Activation Framework (from http://java.sun.com/javase/technologies/desktop/javabeans/jaf/index.jsp) -- JavaMail API (from ) - ======================================================================== 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 ) +- javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250) - tomcat-embed-core (from http://tomcat.apache.org/) ======================================================================== @@ -733,7 +724,8 @@ DOC ======================================================================== The following software have components provided under the terms of this license: -- aalto-xml (from ) +- Lucene Core (from ) +- Woodstox (from https://github.com/FasterXML/woodstox) ======================================================================== EPL-1.0 @@ -743,13 +735,16 @@ 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/) +- Logback Classic Module (from ) - Logback Contrib :: JSON :: Classic (from ) - Logback Contrib :: JSON :: Core (from ) - Logback Contrib :: Jackson (from ) +- Logback Core Module (from ) - 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) - 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-api (from http://junit.org/junit5/) @@ -789,15 +784,20 @@ GPL-2.0-only ======================================================================== The following software have components provided under the terms of this license: -- 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/) +======================================================================== +GPL-2.0-or-later +======================================================================== +The following software have components provided under the terms of this license: + +- SnakeYAML (from http://www.snakeyaml.org) + ======================================================================== GPL-2.0-with-classpath-exception ======================================================================== @@ -805,12 +805,12 @@ 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) -- Google Guice - Core Library (from ) +- 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/) ======================================================================== @@ -819,6 +819,8 @@ GPL-3.0-only The following software have components provided under the terms of this license: - Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) +- Project Lombok (from https://projectlombok.org) +- Project Lombok (from https://projectlombok.org) - jakarta.annotation-api (from https://projects.eclipse.org/projects/ee4j.ca) ======================================================================== @@ -827,7 +829,7 @@ ImageMagick The following software have components provided under the terms of this license: - Stax2 API (from http://github.com/FasterXML/stax2-api) -- aalto-xml (from ) +- Woodstox (from https://github.com/FasterXML/woodstox) ======================================================================== JSON @@ -845,14 +847,32 @@ 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 Contrib :: JSON :: Classic (from ) - Logback Contrib :: JSON :: Core (from ) - Logback Contrib :: Jackson (from ) +- Logback Core Module (from ) - 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) +======================================================================== +LGPL-2.1-or-later +======================================================================== +The following software have components provided under the terms of this license: + +- Javassist (from http://www.javassist.org/) +- SnakeYAML (from http://www.snakeyaml.org) + +======================================================================== +LGPL-3.0-only +======================================================================== +The following software have components provided under the terms of this license: + +- Apache Log4j API (from ) +- Apache Log4j Core (from ) + ======================================================================== MIT ======================================================================== @@ -862,8 +882,6 @@ The following software have components provided under the terms of this license: - 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 ) -- Apache Log4j SLF4J Binding (from ) -- Apache Log4j to SLF4J Adapter (from ) - 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) @@ -882,7 +900,6 @@ The following software have components provided under the terms of this license: - Cucumber-JVM: Plugin (from https://repo1.maven.org/maven2/io/cucumber/cucumber-plugin) - DataTable (from ) - Extensions on Apache Proton-J library (from https://github.com/Azure/qpid-proton-j-extensions) -- Google Guice - Core Library (from ) - 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) @@ -920,7 +937,6 @@ 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/) -- jakarta.xml.bind-api (from ) - micrometer-core (from https://github.com/micrometer-metrics/micrometer) - micrometer-core (from https://github.com/micrometer-metrics/micrometer) - mockito-inline (from https://github.com/mockito/mockito) @@ -932,12 +948,28 @@ The following software have components provided under the terms of this license: - spring-security-core (from http://spring.io/spring-security) - spring-security-core (from http://spring.io/spring-security) +======================================================================== +MPL-1.1 +======================================================================== +The following software have components provided under the terms of this license: + +- Javassist (from http://www.javassist.org/) + ======================================================================== MPL-2.0 ======================================================================== The following software have components provided under the terms of this license: - Javassist (from http://www.javassist.org/) +- OkHttp (from ) + +======================================================================== +PHP-3.01 +======================================================================== +The following software have components provided under the terms of this license: + +- JavaBeans Activation Framework API jar (from ) +- jakarta.xml.bind-api (from ) ======================================================================== Public-Domain @@ -946,6 +978,27 @@ The following software have components provided under the terms of this license: - Spongy Castle (from http://rtyley.github.io/spongycastle/) +======================================================================== +Python-2.0 +======================================================================== +The following software have components provided under the terms of this license: + +- google-auth (from https://github.com/GoogleCloudPlatform/google-auth-library-python) + +======================================================================== +SPL-1.0 +======================================================================== +The following software have components provided under the terms of this license: + +- Checker Qual (from https://checkerframework.org) + +======================================================================== +SunPro +======================================================================== +The following software have components provided under the terms of this license: + +- Lucene Core (from ) + ======================================================================== WTFPL ======================================================================== @@ -958,8 +1011,7 @@ X11 ======================================================================== The following software have components provided under the terms of this license: -- 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) +- Lucene Core (from ) ======================================================================== public-domain @@ -970,18 +1022,26 @@ The following software have components provided under the terms of this license: - 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) - 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 http://www.joda.org/joda-time/) +- Joda-Time (from http://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) - Microsoft Azure SDK for SQL API of Azure Cosmos DB Service (from https://github.com/Azure/azure-sdk-for-java) - Microsoft Azure client library for Blob Storage (from https://github.com/Azure/azure-sdk-for-java) +- Project Lombok (from https://projectlombok.org) +- Project Lombok (from https://projectlombok.org) +- Spring Web (from https://github.com/spring-projects/spring-framework) - 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) +- reactive-streams (from http://www.reactive-streams.org/) ======================================================================== unknown @@ -989,9 +1049,25 @@ unknown The following software have components provided under the terms of this license: - Byte Buddy (without dependencies) (from ) +- 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) -- JavaMail API (from ) +- JUnit Jupiter (Aggregator) (from https://junit.org/junit5/) +- JUnit Jupiter (Aggregator) (from https://junit.org/junit5/) +- JavaBeans Activation Framework API jar (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-api (from http://junit.org/junit5/) +- org.junit.jupiter:junit-jupiter-engine (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.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/provider/schema-azure/pom.xml b/provider/schema-azure/pom.xml index b7660bc1..34940a15 100644 --- a/provider/schema-azure/pom.xml +++ b/provider/schema-azure/pom.xml @@ -30,7 +30,7 @@ 2.1.7 - 0.11.0-SNAPSHOT + 0.10.0-rc10 0.10.0-SNAPSHOT 0.10.0-SNAPSHOT 1.10.19 -- GitLab From a8f3ce3a2d250de05bbd3c2555f4e47492bde85d Mon Sep 17 00:00:00 2001 From: Spencer Sutton Date: Tue, 13 Jul 2021 10:34:16 -0500 Subject: [PATCH 19/30] Updating core lib aws version --- provider/schema-aws/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provider/schema-aws/pom.xml b/provider/schema-aws/pom.xml index e4d7da3b..f660bde5 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.2-SNAPSHOT + 0.10.0-SNAPSHOT -- GitLab From 982f7b5c83270c3ae3a2cb7f59e2fcfc11cfcf6e Mon Sep 17 00:00:00 2001 From: Oleksii Tsyganov Date: Wed, 14 Jul 2021 07:36:14 +0200 Subject: [PATCH 20/30] Changed authorize_api to v2 --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 25cce3de..3533ba61 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,7 +38,7 @@ 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" include: -- GitLab From 9118f8a7a7e1a4361335fbdf96c8c1744ed951a5 Mon Sep 17 00:00:00 2001 From: "Thomas Gehrmann [SLB]" Date: Fri, 16 Jul 2021 19:28:24 +0000 Subject: [PATCH 21/30] Resolve "Revised WellLog" --- NOTICE | 44 +- deployments/shared-schemas/README.md | 9 +- .../AbstractActivityParameter.1.0.0.json | 142 +++++ .../osdu/abstract/AbstractDataset.1.0.0.json | 2 +- .../osdu/abstract/AbstractFacility.1.0.0.json | 3 +- .../osdu/abstract/AbstractProject.1.0.0.json | 3 +- .../AbstractProjectActivity.1.0.0.json | 68 +++ .../abstract/AbstractPropertyType.1.0.0.json | 54 ++ .../AbstractReferencePropertyType.1.0.0.json | 75 +++ .../abstract/AbstractReferenceType.1.0.0.json | 3 +- .../abstract/AbstractWPCActivity.1.0.0.json | 123 +++++ .../osdu/load_sequence.1.0.0.json | 76 +++ .../osdu/manifest/GenericDataset.1.0.0.json | 2 +- .../master-data/ActivityTemplate.1.0.0.json | 244 +++++++++ .../ActivityTemplateArc.1.0.0.json | 236 +++++++++ .../osdu/master-data/Basin.1.0.0.json | 3 +- .../osdu/master-data/Collection.1.0.0.json | 206 ++++++++ .../osdu/master-data/Field.1.0.0.json | 3 +- .../master-data/GeoPoliticalEntity.1.0.0.json | 3 +- .../osdu/master-data/Organisation.1.0.0.json | 3 +- .../osdu/master-data/Play.1.0.0.json | 4 +- .../osdu/master-data/Prospect.1.0.0.json | 4 +- .../CollectionPurpose.1.0.0.json | 147 ++++++ .../reference-data/ParameterKind.1.0.0.json | 147 ++++++ .../reference-data/ParameterRole.1.0.0.json | 147 ++++++ .../reference-data/PropertyType.1.0.0.json | 200 ++++++++ .../reference-data/SurveyToolType.1.0.0.json | 142 +++++ .../TrajectoryStationPropertyType.1.0.0.json | 150 ++++++ .../UnitOfMeasureConfiguration.1.0.0.json | 272 ++++++++++ .../WellLogSamplingDomainType.1.0.0.json | 147 ++++++ .../Activity.1.0.0.json | 153 ++++++ .../TubularUmbilical.1.0.0.json | 2 +- .../work-product-component/WellLog.1.1.0.json | 483 ++++++++++++++++++ .../WellboreTrajectory.1.1.0.json | 373 ++++++++++++++ 34 files changed, 3632 insertions(+), 41 deletions(-) create mode 100644 deployments/shared-schemas/osdu/abstract/AbstractActivityParameter.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/abstract/AbstractProjectActivity.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/abstract/AbstractPropertyType.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/abstract/AbstractReferencePropertyType.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/abstract/AbstractWPCActivity.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/master-data/ActivityTemplate.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/master-data/ActivityTemplateArc.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/master-data/Collection.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/reference-data/CollectionPurpose.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/reference-data/ParameterKind.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/reference-data/ParameterRole.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/reference-data/PropertyType.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/reference-data/SurveyToolType.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/reference-data/TrajectoryStationPropertyType.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/reference-data/UnitOfMeasureConfiguration.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/reference-data/WellLogSamplingDomainType.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/work-product-component/Activity.1.0.0.json create mode 100644 deployments/shared-schemas/osdu/work-product-component/WellLog.1.1.0.json create mode 100644 deployments/shared-schemas/osdu/work-product-component/WellboreTrajectory.1.1.0.json diff --git a/NOTICE b/NOTICE index a8dd5f3b..b23e0f8e 100644 --- a/NOTICE +++ b/NOTICE @@ -22,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) @@ -319,8 +319,8 @@ The following software have components provided under the terms of this license: - Bean Validation API (from http://beanvalidation.org) - Brave Instrumentation: Http Adapters (from ) - Brave instrumentation for Reactor Netty HTTP (from https://github.com/reactor/reactor-netty) -- Byte Buddy (without dependencies) (from ) -- Byte Buddy Java agent (from ) +- Byte Buddy (without dependencies) (from https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy) +- Byte Buddy 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 ) - CloudWatch Metrics for AWS Java SDK (from https://aws.amazon.com/sdkforjava) @@ -328,7 +328,6 @@ The following software have components provided under the terms of this license: - Converter: Jackson (from ) - 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 ) @@ -349,10 +348,10 @@ The following software have components provided under the terms of this license: - Guava InternalFutureFailureAccess and InternalFutures (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) -- HPPC Collections (from http://labs.carrotsearch.com) - HTTP functionality for the Reactor Netty library (from https://github.com/reactor/reactor-netty) - Hibernate Validator Engine (from ) - Hibernate Validator Engine (from ) +- High Performance Primitive Collections (from https://github.com/carrotsearch/hppc) - 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) @@ -371,15 +370,15 @@ The following software have components provided under the terms of this license: - 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 dataformat: CBOR (from http://github.com/FasterXML/jackson-dataformats-binary) - Jackson dataformat: CBOR (from http://github.com/FasterXML/jackson-dataformats-binary) +- Jackson dataformat: Smile (from http://github.com/FasterXML/jackson-dataformats-binary) - Jackson datatype: JSR310 (from http://wiki.fasterxml.com/JacksonModuleJSR310) +- 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-annotations (from http://github.com/FasterXML/jackson) - 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-dataformats-text) - Jackson-datatype-Joda (from http://wiki.fasterxml.com/JacksonModuleJoda) -- 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 ) - Jakarta Bean Validation API (from https://beanvalidation.org) @@ -414,7 +413,7 @@ The following software have components provided under the terms of this license: - Lucene Sandbox (from ) - Lucene Spatial 3D (from ) - Lucene Spatial Extras (from ) -- Lucene Suggest (from ) +- Lucene Suggest (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-suggest) - MapStruct Core (from ) - Metrics Core (from https://github.com/dropwizard/metrics) - Microsoft Application Insights Java SDK Core (from https://github.com/Microsoft/ApplicationInsights-Java) @@ -424,9 +423,9 @@ 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) - Mockito (from http://mockito.org) +- Mockito (from http://mockito.org) - Netty Reactive Streams HTTP support (from ) - Netty Reactive Streams Implementation (from ) - Netty/Buffer (from http://netty.io/) @@ -448,7 +447,7 @@ The following software have components provided under the terms of this license: - 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) @@ -466,7 +465,7 @@ The following software have components provided under the terms of this license: - PWDB :: Database (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/database) - Protocol Buffer extensions to the Google HTTP Client Library for Java. (from ) - QpidJMS Client (from ) -- Reactive Streams Netty driver (from https://github.com/reactor/reactor-netty) +- Reactor Netty with all modules (from https://github.com/reactor/reactor-netty) - Retrofit (from ) - SnakeYAML (from http://www.snakeyaml.org) - Spring AOP (from https://github.com/spring-projects/spring-framework) @@ -551,8 +550,8 @@ The following software have components provided under the terms of this license: - datastore-v1-proto-client (from ) - elasticsearch-core (from https://github.com/elastic/elasticsearch) - elasticsearch-geo (from https://github.com/elastic/elasticsearch) -- error-prone annotations (from ) -- error-prone annotations (from ) +- 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) @@ -594,6 +593,7 @@ The following software have components provided under the terms of this license: - 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-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) @@ -656,7 +656,7 @@ The following software have components provided under the terms of this license: - JavaBeans Activation Framework API jar (from ) - Lucene Common Analyzers (from ) - Lucene Core (from ) -- Lucene Suggest (from ) +- 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) @@ -1048,7 +1048,7 @@ 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) diff --git a/deployments/shared-schemas/README.md b/deployments/shared-schemas/README.md index f05715b5..4057d5b4 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 00000000..44fcff51 --- /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 5b749597..71066ab2 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 75cc409d..364787c1 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 afe4ffd2..fcfcfd4b 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 00000000..c4b36658 --- /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 00000000..989c4107 --- /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 00000000..ce68c883 --- /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 6ae725dc..56d6a491 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 00000000..ab8c61ef --- /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 82eba9e3..ff951008 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 b01589f0..4d8990b3 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 00000000..38630ff7 --- /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 00000000..654dae6f --- /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 1a452232..a3488c3d 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 00000000..edbb3bab --- /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 552bb841..9a718b14 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 e55319f5..c7ecb4a5 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 5bf3d51e..9246fa56 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 2b7eef54..925043d3 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 6b48244f..ea77c557 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 00000000..b91d1763 --- /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 00000000..0500dba5 --- /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 00000000..79f4b6a1 --- /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 00000000..5fd27942 --- /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 00000000..d1c678f0 --- /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 00000000..6629e037 --- /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 00000000..7b69d96d --- /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-go