Commit 04971a14 authored by Aman Verma's avatar Aman Verma Committed by Kishore Battula
Browse files

miscellaneous changes

parent c7270fe0
......@@ -46,6 +46,10 @@ Once the above Prerequisite are done, we can follow the below steps to run the s
You can access the service APIs by following the service contract in [schema.yaml](https://dev.azure.com/slb-des-ext-collaboration/open-data-ecosystem/_git/os-schema?path=%2Fdocs%2Fapi%2Fschema.yaml)
### 2. Azure deployment
Instructions for running the Azure implementation in the cloud can be found [here](https://community.opengroup.org/osdu/platform/system/schema-service/-/blob/master/provider/schema-azure/README.md).
## Running Automated Integration Test
DevSanity tests are located in a schema-core project in testing directory under the project root directory.
......
import os
import msal
class AzureToken(object):
def get_azure_id_token(self):
tenant_id = os.getenv('AZURE_AD_TENANT_ID')
resource_id = os.getenv('AZURE_AD_APP_RESOURCE_ID')
client_id = os.getenv('INTEGRATION_TESTER')
client_secret = os.getenv('TESTER_SERVICEPRINCIPAL_SECRET')
authority_host_uri = 'https://login.microsoftonline.com'
authority_uri = authority_host_uri + '/' + tenant_id
scopes = [resource_id + '/.default']
if tenant_id is None:
print('Please pass tenant Id to generate token')
exit(1)
if resource_id is None:
print('Please pass resource Id to generate token')
exit(1)
if client_id is None:
print('Please pass client Id to generate token')
exit(1)
if client_secret is None:
print('Please pass client secret to generate token')
exit(1)
try:
app = msal.ConfidentialClientApplication(client_id=client_id, authority=authority_uri, client_credential=client_secret)
result = app.acquire_token_for_client(scopes=scopes)
token = 'Bearer ' + result.get('access_token')
print(token)
return token
except Exception as e:
print(e)
if __name__ == '__main__':
AzureToken().get_azure_id_token()
\ No newline at end of file
os
msal
\ No newline at end of file
......@@ -52,6 +52,19 @@ az keyvault secret show --vault-name $KEY_VAULT_NAME --name $KEY_VAULT_SECRET_NA
| `AZURE_CLIENT_SECRET` | `********` | Secret for `$AZURE_CLIENT_ID` | yes | keyvault secret: `$KEYVAULT_URI/secrets/app-dev-sp-password` |
**Required to run integration tests**
| name | value | description | sensitive? | source |
| --- | --- | --- | --- | --- |
| `AZURE_AD_APP_RESOURCE_ID` | `********` | AAD client application ID | yes | output of infrastructure deployment |
| `AZURE_AD_TENANT_ID` | `********` | AD tenant to authenticate users from | yes | -- |
| `INTEGRATION_TESTER` | `********` | System identity to assume for API calls. Note: this user must have entitlements configured already | no | -- |
| `PRIVATE_TENANT1` | `opendes` | OSDU tenant used for testing | no | -- |
| `PRIVATE_TENANT2` | `tenant2` | OSDU tenant used for testing | no | -- |
| `SHARED_TENANT` | `common` | OSDU tenant used for testing | no | -- |
| `VENDOR` | `azure` | cloud provider name | no | -- |
| `HOST` | ex: `http://localhost:8080` | OSDU tenant used for testing | no | -- |
| `TESTER_SERVICEPRINCIPAL_SECRET` | `********` | Secret for `$INTEGRATION_TESTER` | yes | -- |
### Configure Maven
......@@ -109,6 +122,19 @@ After configuring your environment as specified above, you can follow these step
After the service has started it should be accessible via a web browser by visiting [http://localhost:8080/swagger-ui.html](http://localhost:8080/swagger-ui.html). If the request does not fail, you can then run the integration tests.
### Running automated integration tests:
These tests validate functionality of schema service.
They can then be run/debugged directly in your IDE of choice using the GUI or via the commandline using below command from schema-core project.
Below command has to be run post building complete project.
cd testing/schema-test-core
mvn verify -DVENDOR=azure -DHOST=http://localhost:8080 -DPRIVATE_TENANT1=opendes -DPRIVATE_TENANT2=tenant2 -DSHARED_TENANT=common -Dcucumber.options="--tags @SchemaService"
Below command can be run through azure-pipeline.yml after setting environment variables in the pipeline.
verify "-Dcucumber.options=--tags @SchemaService"
## Debugging
......
......@@ -15,6 +15,7 @@
package org.opengroup.osdu.schema.azure.impl.schemainfostore;
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.constants.SchemaConstants;
import org.opengroup.osdu.azure.CosmosStore;
......@@ -79,21 +80,20 @@ public class AzureAuthorityStore implements IAuthorityStore {
*/
@Override
public Authority create(Authority authority) throws ApplicationException, BadRequestException {
String id = headers.getPartitionId() + ":" + authority.getAuthorityId();
Boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, authorityContainer, id, headers.getPartitionId(), AuthorityDoc.class).isPresent();
if (exists) {
log.warning(SchemaConstants.AUTHORITY_EXISTS_ALREADY_REGISTERED);
throw new BadRequestException(MessageFormat.format(SchemaConstants.AUTHORITY_EXISTS_EXCEPTION,
authority.getAuthorityId()));
}
try {
AuthorityDoc authorityDoc = new AuthorityDoc(id, headers.getPartitionId(), authority);
cosmosStore.upsertItem(headers.getPartitionId(), cosmosDBName, authorityContainer, authorityDoc);
} catch (Exception ex) {
log.error(MessageFormat.format(SchemaConstants.OBJECT_INVALID, ex.getMessage()));
throw new ApplicationException(SchemaConstants.INVALID_INPUT);
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, authorityContainer, authorityDoc);
} catch (AppException ex) {
if (ex.getError().getCode() == 409) {
log.warning(SchemaConstants.AUTHORITY_EXISTS_ALREADY_REGISTERED);
throw new BadRequestException(MessageFormat.format(SchemaConstants.AUTHORITY_EXISTS_EXCEPTION,
authority.getAuthorityId()));
} else {
log.error(MessageFormat.format(SchemaConstants.OBJECT_INVALID, ex.getMessage()));
throw new ApplicationException(SchemaConstants.INVALID_INPUT);
}
}
log.info(SchemaConstants.AUTHORITY_CREATED);
......
......@@ -17,6 +17,7 @@ package org.opengroup.osdu.schema.azure.impl.schemainfostore;
import java.text.MessageFormat;
import org.opengroup.osdu.azure.CosmosStore;
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.constants.SchemaConstants;
......@@ -81,22 +82,20 @@ public class AzureEntityTypeStore implements IEntityTypeStore {
*/
@Override
public EntityType create(EntityType entityType) throws BadRequestException, ApplicationException {
String id = headers.getPartitionId() + ":" + entityType.getEntityTypeId();
// Check whether EntityType already exists and throw required exception.
Boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, entityTypeContainer, id, headers.getPartitionId(), EntityTypeDoc.class).isPresent();
if (exists) {
log.warning(SchemaConstants.ENTITY_TYPE_EXISTS);
throw new BadRequestException(MessageFormat.format(SchemaConstants.ENTITY_TYPE_EXISTS_EXCEPTION,
entityType.getEntityTypeId()));
}
try {
EntityTypeDoc entityTypeDoc = new EntityTypeDoc(id, headers.getPartitionId(), entityType);
cosmosStore.upsertItem(headers.getPartitionId(), cosmosDBName, entityTypeContainer, entityTypeDoc);
} catch (Exception ex) {
log.error(MessageFormat.format(SchemaConstants.OBJECT_INVALID, ex.getMessage()));
throw new ApplicationException(SchemaConstants.INVALID_INPUT);
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, entityTypeContainer, entityTypeDoc);
} catch (AppException ex) {
if (ex.getError().getCode() == 409) {
log.warning(SchemaConstants.ENTITY_TYPE_EXISTS);
throw new BadRequestException(MessageFormat.format(SchemaConstants.ENTITY_TYPE_EXISTS_EXCEPTION,
entityType.getEntityTypeId()));
} else {
log.error(MessageFormat.format(SchemaConstants.OBJECT_INVALID, ex.getMessage()));
throw new ApplicationException(SchemaConstants.INVALID_INPUT);
}
}
log.info(SchemaConstants.ENTITY_TYPE_CREATED);
......
......@@ -22,6 +22,7 @@ import java.util.stream.Collectors;
import com.azure.cosmos.*;
import org.opengroup.osdu.azure.CosmosStore;
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;
......@@ -104,21 +105,18 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
@Override
public SchemaInfo createSchemaInfo(SchemaRequest schema) throws ApplicationException, BadRequestException {
String id = headers.getPartitionId() + ":" + schema.getSchemaInfo().getSchemaIdentity().getId();
// Check whether SchemaInfo already exists and throw required exception.
Boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, headers.getPartitionId(), SchemaInfoDoc.class).isPresent();
if (exists) {
log.warning(SchemaConstants.SCHEMA_ID_EXISTS);
throw new BadRequestException(SchemaConstants.SCHEMA_ID_EXISTS);
}
FlattenedSchemaInfo flattenedSchemaInfo = populateSchemaInfo(schema.getSchemaInfo());
SchemaInfoDoc schemaInfoDoc = new SchemaInfoDoc(id, headers.getPartitionId(), flattenedSchemaInfo);
try {
cosmosStore.upsertItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, schemaInfoDoc);
} catch (Exception ex) {
log.error(MessageFormat.format(SchemaConstants.OBJECT_INVALID, ex.getMessage()));
throw new ApplicationException(SchemaConstants.SCHEMA_CREATION_FAILED_INVALID_OBJECT);
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, schemaInfoDoc);
} catch (AppException ex) {
if (ex.getError().getCode() == 409) {
log.warning(SchemaConstants.SCHEMA_ID_EXISTS);
throw new BadRequestException(SchemaConstants.SCHEMA_ID_EXISTS);
} else {
log.error(MessageFormat.format(SchemaConstants.OBJECT_INVALID, ex.getMessage()));
throw new ApplicationException(SchemaConstants.SCHEMA_CREATION_FAILED_INVALID_OBJECT);
}
}
log.info(SchemaConstants.SCHEMA_CREATED);
......
......@@ -18,6 +18,7 @@ import java.text.MessageFormat;
import org.opengroup.osdu.azure.CosmosStore;
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.constants.SchemaConstants;
......@@ -78,23 +79,20 @@ public class AzureSourceStore implements ISourceStore {
*/
@Override
public Source create(Source source) throws BadRequestException, ApplicationException {
String id = headers.getPartitionId() + ":" + source.getSourceId();
// Check whether Source already exists and throw required exception.
Boolean exists = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, sourceContainer, id, headers.getPartitionId(), SourceDoc.class).isPresent();
if (exists) {
log.warning(SchemaConstants.SOURCE_EXISTS);
throw new BadRequestException(MessageFormat.format(SchemaConstants.SOURCE_EXISTS_EXCEPTION,
source.getSourceId()));
}
try {
SourceDoc sourceDoc = new SourceDoc(id, headers.getPartitionId(), source);
cosmosStore.upsertItem(headers.getPartitionId(), cosmosDBName, sourceContainer, sourceDoc);
} catch (Exception ex) {
log.error(MessageFormat.format(SchemaConstants.OBJECT_INVALID, ex.getMessage()));
throw new ApplicationException(SchemaConstants.INVALID_INPUT);
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, sourceContainer, sourceDoc);
} catch (AppException ex) {
if (ex.getError().getCode() == 409) {
log.warning(SchemaConstants.SOURCE_EXISTS);
throw new BadRequestException(MessageFormat.format(SchemaConstants.SOURCE_EXISTS_EXCEPTION,
source.getSourceId()));
} else {
log.error(MessageFormat.format(SchemaConstants.OBJECT_INVALID, ex.getMessage()));
throw new ApplicationException(SchemaConstants.INVALID_INPUT);
}
}
log.info(SchemaConstants.SOURCE_CREATED);
......
......@@ -14,10 +14,9 @@
package org.opengroup.osdu.schema.azure.impl.schemastore;
import com.azure.storage.blob.BlobContainerClient;
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.utils.OSDUAzureBlobStorageImpl;
import org.opengroup.osdu.schema.constants.SchemaConstants;
import org.opengroup.osdu.schema.exceptions.ApplicationException;
import org.opengroup.osdu.schema.exceptions.NotFoundException;
......@@ -37,10 +36,7 @@ public class AzureSchemaStore implements ISchemaStore {
private DpsHeaders headers;
@Autowired
private BlobContainerClient blobContainerClient;
@Autowired
private OSDUAzureBlobStorageImpl blobStorage;
private BlobStore blobStore;
@Autowired
JaxRsDpsLog log;
......@@ -59,7 +55,7 @@ public class AzureSchemaStore implements ISchemaStore {
public String getSchema(String dataPartitionId, String filePath) throws ApplicationException, NotFoundException {
filePath = dataPartitionId + ":" + filePath + SchemaConstants.JSON_EXTENSION;
try {
String content = blobStorage.readFromBlob(filePath);
String content = blobStore.readFromBlob(dataPartitionId, filePath);
if (content != null)
return content;
else
......@@ -85,7 +81,8 @@ public class AzureSchemaStore implements ISchemaStore {
filePath = dataPartitionId + ":" + filePath + SchemaConstants.JSON_EXTENSION;
try {
return blobStorage.writeToBlob(filePath, content);
blobStore.writeToBlob(dataPartitionId, filePath, content);
return filePath;
} catch (Exception ex) {
throw new ApplicationException(SchemaConstants.INTERNAL_SERVER_ERROR);
}
......@@ -104,7 +101,7 @@ public class AzureSchemaStore implements ISchemaStore {
try
{
return blobStorage.deleteFromBlob(filePath);
return blobStore.deleteFromBlob(dataPartitionId, filePath);
}
catch (Exception e)
{
......
// 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.utils;
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.specialized.BlockBlobClient;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.io.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
@Repository
public class OSDUAzureBlobStorageImpl {
@Autowired
private DpsHeaders headers;
@Autowired
private BlobContainerClient blobContainerClient;
@Autowired
JaxRsDpsLog log;
public String readFromBlob(String filePath) throws ApplicationException {
String content = "";
BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(filePath).getBlockBlobClient();
try (ByteArrayOutputStream downloadStream = new ByteArrayOutputStream()) {
blockBlobClient.download(downloadStream);
content = downloadStream.toString(StandardCharsets.UTF_8.name());
return content;
} catch (Exception ex) {
log.warning(ex.getMessage());
throw new ApplicationException(ex.getMessage());
}
}
public boolean deleteFromBlob(String filePath) throws ApplicationException {
BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(filePath).getBlockBlobClient();
try
{
blockBlobClient.delete();
return true;
}
catch (Exception ex)
{
log.warning(ex.getMessage());
throw new ApplicationException("Error deleting file.");
}
}
public String writeToBlob(String filePath, String content) throws ApplicationException {
byte[] bytes = content.getBytes(StandardCharsets.UTF_8);
int bytesSize = bytes.length;
BlockBlobClient blockBlobClient = blobContainerClient.getBlobClient(filePath).getBlockBlobClient();
try (ByteArrayInputStream dataStream = new ByteArrayInputStream(bytes)) {
blockBlobClient.upload(dataStream, bytesSize, true);
} catch (Exception ex) {
log.warning(ex.getMessage());
throw new ApplicationException("Write to blob failed");
}
// Get the blobname
return blockBlobClient.getBlobName();
}
}
......@@ -21,6 +21,7 @@ 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.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.impl.schemainfostore.AzureAuthorityStore;
......@@ -35,7 +36,6 @@ import org.opengroup.osdu.azure.CosmosStore;
import java.io.IOException;
import java.util.Optional;
import static org.mockito.ArgumentMatchers.anyString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
......@@ -112,24 +112,15 @@ public class AzureAuthorityStoreTest {
@Test
public void testCreateAuthority() throws ApplicationException, BadRequestException {
doNothing().when(cosmosStore).upsertItem(eq(dataPartitionId), any(), any(), any());
doNothing().when(cosmosStore).createItem(eq(dataPartitionId), any(), any(), any());
assertNotNull(store.create(mockAuthority));
}
@Test
public void testCreateAuthority_BadRequestException()
throws NotFoundException, ApplicationException, BadRequestException, IOException {
AuthorityDoc authorityDoc = getAuthorityDoc(dataPartitionId, authorityId);
Optional<AuthorityDoc> cosmosItem = Optional.of(authorityDoc);
doReturn(cosmosItem)
.when(cosmosStore)
.findItem(
eq(dataPartitionId),
any(),
any(),
eq(dataPartitionId + ":" + authorityId),
eq(dataPartitionId),
any());
AppException exception = getMockAppException(409);
doThrow(exception).when(cosmosStore).createItem(eq(dataPartitionId), any(), any(), any());
try {
store.create(mockAuthority);
......@@ -145,17 +136,8 @@ public class AzureAuthorityStoreTest {
@Test
public void testCreateAuthority_ApplicationException()
throws NotFoundException, ApplicationException, BadRequestException, CosmosClientException {
Optional<AuthorityDoc> cosmosItem = Optional.empty();
doReturn(cosmosItem)
.when(cosmosStore)
.findItem(
eq(dataPartitionId),
any(),
any(),
eq(dataPartitionId + ":" + authorityId),
eq(dataPartitionId),
any());
doThrow(AppException.class).when(cosmosStore).upsertItem(eq(dataPartitionId), any(), any(), any());
AppException exception = getMockAppException(500);
doThrow(exception).when(cosmosStore).createItem(eq(dataPartitionId), any(), any(), any());
try {
store.create(mockAuthority);
fail("Should not succeed");
......@@ -173,4 +155,12 @@ public class AzureAuthorityStoreTest {
authority.setAuthorityId(authorityName);
return new AuthorityDoc(id, partitionId, authority);
}
private AppException getMockAppException(int errorCode) {
AppException mockException = mock(AppException.class);
AppError mockError = mock(AppError.class);
lenient().when(mockException.getError()).thenReturn(mockError);
lenient().when(mockError.getCode()).thenReturn(errorCode);
return mockException;
}
}
......@@ -22,6 +22,7 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.opengroup.osdu.azure.CosmosStore;
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.impl.schemainfostore.AzureEntityTypeStore;
......@@ -114,16 +115,15 @@ public class AzureEntityTypeStoreTest {
@Test
public void testCreateEntityType() throws ApplicationException, BadRequestException {
Mockito.when(mockEntityType.getEntityTypeId()).thenReturn(entityTypeId);
doNothing().when(cosmosStore).upsertItem(anyString(), any(), any(), any());
doNothing().when(cosmosStore).createItem(anyString(), any(), any(), any());
assertNotNull(store.create(mockEntityType));
}
@Test
public void testCreateEntityType_BadRequestException()
throws NotFoundException, ApplicationException, BadRequestException, IOException {
EntityTypeDoc entityTypeDoc = getEntityTypeDoc(dataPartitionId, entityTypeId);
Optional<EntityTypeDoc> cosmosItem = Optional.of(entityTypeDoc);
doReturn(cosmosItem).when(cosmosStore).findItem(anyString(), any(), any(), anyString(), anyString(), any());
AppException exception = getMockAppException(409);
doThrow(exception).when(cosmosStore).createItem(eq(dataPartitionId), any(), any(), any());
try {
store.create(mockEntityType);
......@@ -139,17 +139,8 @@ public class AzureEntityTypeStoreTest {
@Test
public void testCreateEntityType_ApplicationException()
throws NotFoundException, ApplicationException, BadRequestException, CosmosClientException {
Optional<EntityTypeDoc> cosmosItem = Optional.empty();
doReturn(cosmosItem)
.when(cosmosStore)
.findItem(
eq(dataPartitionId),
any(),
any(),
eq(dataPartitionId + ":" + entityTypeId),
eq(dataPartitionId),
any());
doThrow(AppException.class).when(cosmosStore).upsertItem(anyString(), any(), any(), any());
AppException exception = getMockAppException(500);
doThrow(exception).when(cosmosStore).createItem(eq(dataPartitionId), any(), any(), any());
try {
store.create(mockEntityType);
......@@ -168,4 +159,12 @@ public class AzureEntityTypeStoreTest {
EntityType.setEntityTypeId(EntityTypeName);
return new EntityTypeDoc(id, partitionId, EntityType);
}
private AppException getMockAppException(int errorCode) {
AppException mockException = mock(AppException.class);
AppError mockError = mock(AppError.class);
lenient().when(mockException.getError()).thenReturn(mockError);
lenient().when(mockError.getCode()).thenReturn(errorCode);
return mockException;
}
}
......@@ -26,6 +26,7 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.opengroup.osdu.azure.CosmosStore;
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.core.common.model.tenant.TenantInfo;
......@@ -214,16 +215,8 @@ public class AzureSchemaInfoStoreTest {
public void testCreateSchemaInfo_BadRequestException()
throws NotFoundException, ApplicationException, BadRequestException {
Optional<SchemaInfoDoc> cosmosItem = Optional.of(schemaInfoDoc);
doReturn(cosmosItem)
.when(cosmosStore)
.findItem(
eq(dataPartitionId),
any(),
any(),
eq(dataPartitionId + ":" + schemaId),