Commit 8f778707 authored by SGupta79's avatar SGupta79
Browse files

Merge branch 'master' of

https://community.opengroup.org/osdu/platform/system/schema-service.git
into slb-logs-audit-request-app

Conflicts:
	schema-core/src/main/java/org/opengroup/osdu/schema/logging/AuditEvents.java
	schema-core/src/main/java/org/opengroup/osdu/schema/logging/AuditLogger.java
	schema-core/src/main/java/org/opengroup/osdu/schema/service/serviceimpl/SchemaService.java
parents 85b01bdb eaab30cb
Pipeline #24570 failed with stages
in 2 minutes and 19 seconds
......@@ -246,6 +246,7 @@ The following software have components provided under the terms of this license:
- Google Cloud Core HTTP (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-core-http)
- Google Cloud Core gRPC (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-core-grpc)
- Google Cloud Datastore (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-datastore)
- Google Cloud Key Management Service (KMS) API v1-rev22-1.23.0 (from )
- Google Cloud Logging (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-logging)
- Google Cloud Pub/Sub (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-pubsub)
- Google Cloud Storage (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-storage)
......
......@@ -57,7 +57,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-gcp</artifactId>
<version>0.1.15</version>
<version>0.3.25</version>
</dependency>
<dependency>
......
/*
Copyright 2020 Google LLC
Copyright 2020 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 org.opengroup.osdu.core.gcp.multitenancy.DatastoreFactory;
import org.opengroup.osdu.core.gcp.multitenancy.TenantFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.stereotype.Component;
@Component
public class DatastoreFactoryBean extends AbstractFactoryBean<DatastoreFactory> {
@Autowired
TenantFactory tenantFactory;
@Override
protected DatastoreFactory createInstance() throws Exception {
return new DatastoreFactory(tenantFactory);
}
@Override
public Class<?> getObjectType() {
return DatastoreFactory.class;
}
}
......@@ -22,6 +22,7 @@ import java.text.MessageFormat;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.gcp.multitenancy.DatastoreFactory;
import org.opengroup.osdu.core.gcp.multitenancy.TenantFactory;
import org.opengroup.osdu.schema.constants.SchemaConstants;
import org.opengroup.osdu.schema.exceptions.ApplicationException;
import org.opengroup.osdu.schema.exceptions.BadRequestException;
......@@ -51,6 +52,9 @@ public class GoogleAuthorityStore implements IAuthorityStore {
@Autowired
private DatastoreFactory dataStoreFactory;
@Autowired
private TenantFactory tenantFactory;
@Autowired
JaxRsDpsLog log;
......@@ -64,7 +68,7 @@ public class GoogleAuthorityStore implements IAuthorityStore {
*/
@Override
public Authority get(String authorityId) throws NotFoundException, ApplicationException {
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(tenantFactory.getTenantInfo(headers.getPartitionId()));
Key key = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE)
.setKind(SchemaConstants.AUTHORITY_KIND).newKey(authorityId);
......@@ -81,14 +85,13 @@ public class GoogleAuthorityStore implements IAuthorityStore {
* Method to create authority in google store of dataPartitionId project
*
* @param authority
* @param dataPartitionId
* @return Authority object
* @throws ApplicationException
* @throws BadRequestException
*/
@Override
public Authority create(Authority authority) throws ApplicationException, BadRequestException {
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(tenantFactory.getTenantInfo(headers.getPartitionId()));
Key key = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE)
.setKind(SchemaConstants.AUTHORITY_KIND).newKey(authority.getAuthorityId());
Entity entity = getEntityObject(key);
......
......@@ -69,7 +69,7 @@ public class GoogleEntityTypeStore implements IEntityTypeStore {
*/
@Override
public EntityType get(String entityTypeId) throws NotFoundException, ApplicationException {
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(tenantFactory.getTenantInfo(headers.getPartitionId()));
Key key = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE)
.setKind(SchemaConstants.ENTITYTYPE_KIND).newKey(entityTypeId);
Entity entity = datastore.get(key);
......@@ -85,14 +85,13 @@ public class GoogleEntityTypeStore implements IEntityTypeStore {
* Method to create entityType in google store of dataPartitionId GCP
*
* @param entityType
* @param dataPartitionId
* @return entityType object
* @throws ApplicationException
* @throws BadRequestException
*/
@Override
public EntityType create(EntityType entityType) throws BadRequestException, ApplicationException {
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(tenantFactory.getTenantInfo(headers.getPartitionId()));
Key key = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE)
.setKind(SchemaConstants.ENTITYTYPE_KIND).newKey(entityType.getEntityTypeId());
Entity entity = getEntityObject(key);
......
......@@ -95,7 +95,7 @@ public class GoogleSchemaInfoStore implements ISchemaInfoStore {
*/
@Override
public SchemaInfo getSchemaInfo(String schemaId) throws ApplicationException, NotFoundException {
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(tenantFactory.getTenantInfo(headers.getPartitionId()));
Key key = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE).setKind(SchemaConstants.SCHEMA_KIND)
.newKey(schemaId);
Entity entity = datastore.get(key);
......@@ -110,14 +110,13 @@ public class GoogleSchemaInfoStore implements ISchemaInfoStore {
* Method to Create schema in google store of tenantId GCP
*
* @param schema
* @param tenantId
* @return schemaInfo object
* @throws ApplicationException
* @throws BadRequestException
*/
@Override
public SchemaInfo createSchemaInfo(SchemaRequest schema) throws ApplicationException, BadRequestException {
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(tenantFactory.getTenantInfo(headers.getPartitionId()));
KeyFactory keyFactory = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE)
.setKind(SchemaConstants.SCHEMA_KIND);
Entity entity = getEntityObject(schema, datastore, keyFactory);
......@@ -140,14 +139,13 @@ public class GoogleSchemaInfoStore implements ISchemaInfoStore {
* Method to update schema in google store of tenantId GCP
*
* @param schema
* @param tenantId
* @return schemaInfo object
* @throws ApplicationException
* @throws BadRequestException
*/
@Override
public SchemaInfo updateSchemaInfo(SchemaRequest schema) throws ApplicationException, BadRequestException {
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(tenantFactory.getTenantInfo(headers.getPartitionId()));
KeyFactory keyFactory = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE)
.setKind(SchemaConstants.SCHEMA_KIND);
Entity entity = getEntityObject(schema, datastore, keyFactory);
......@@ -170,7 +168,7 @@ public class GoogleSchemaInfoStore implements ISchemaInfoStore {
*/
@Override
public boolean cleanSchema(String schemaId) throws ApplicationException {
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(tenantFactory.getTenantInfo(headers.getPartitionId()));
KeyFactory keyFactory = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE)
.setKind(SchemaConstants.SCHEMA_KIND);
Key key = keyFactory.newKey(schemaId);
......@@ -184,7 +182,7 @@ public class GoogleSchemaInfoStore implements ISchemaInfoStore {
@Override
public String getLatestMinorVerSchema(SchemaInfo schemaInfo) throws ApplicationException {
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(tenantFactory.getTenantInfo(headers.getPartitionId()));
Query<Entity> query = Query.newEntityQueryBuilder().setNamespace(SchemaConstants.NAMESPACE)
.setKind(SchemaConstants.SCHEMA_KIND)
.setFilter(CompositeFilter.and(
......@@ -275,7 +273,7 @@ public class GoogleSchemaInfoStore implements ISchemaInfoStore {
@Override
public List<SchemaInfo> getSchemaInfoList(QueryParams queryParams, String tenantId) throws ApplicationException {
List<SchemaInfo> schemaList = new LinkedList<>();
Datastore datastore = dataStoreFactory.getDatastore(tenantId, SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(tenantFactory.getTenantInfo(tenantId));
List<Filter> filterList = getFilters(queryParams);
EntityQuery.Builder queryBuilder = Query.newEntityQueryBuilder().setNamespace(SchemaConstants.NAMESPACE)
......@@ -336,7 +334,7 @@ public class GoogleSchemaInfoStore implements ISchemaInfoStore {
}
for (String tenant : tenantList) {
Datastore datastore = dataStoreFactory.getDatastore(tenant, SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(tenantFactory.getTenantInfo(tenant));
Key schemaKey = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE)
.setKind(SchemaConstants.SCHEMA_KIND).newKey(schemaId);
......
......@@ -68,7 +68,7 @@ public class GoogleSourceStore implements ISourceStore {
*/
@Override
public Source get(String sourceId) throws NotFoundException, ApplicationException {
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(tenantFactory.getTenantInfo(headers.getPartitionId()));
Key key = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE).setKind(SchemaConstants.SOURCE_KIND)
.newKey(sourceId);
Entity entity = datastore.get(key);
......@@ -83,13 +83,11 @@ public class GoogleSourceStore implements ISourceStore {
/**
* Method to create Source in google store of dataPartitionId GCP
*
* @param Source
* @param dataPartitionId
* @return Source object
*/
@Override
public Source create(Source source) throws BadRequestException, ApplicationException {
Datastore datastore = dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE);
Datastore datastore = dataStoreFactory.getDatastore(tenantFactory.getTenantInfo(headers.getPartitionId()));
Key key = datastore.newKeyFactory().setNamespace(SchemaConstants.NAMESPACE).setKind(SchemaConstants.SOURCE_KIND)
.newKey(source.getSourceId());
Entity entity = getEntityObject(key);
......
......@@ -83,7 +83,6 @@ public class GoogleSchemaStore implements ISchemaStore {
/**
* Method to write schema to google Storage given Tenant ProjectInfo
*
* @param dataPartitionId
* @param filePath
* @param content
* @return schema object
......
package org.opengroup.osdu.schema.configuration;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.opengroup.osdu.core.gcp.multitenancy.TenantFactory;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
public class DatastoreFactoryBeanTest {
@InjectMocks
DatastoreFactoryBean datastoreFactoryBean;
@Mock
TenantFactory tenantFactory;
@Test
public void test_createInstance() throws Exception {
assertNotNull(datastoreFactoryBean.createInstance());
}
@Test
public void test_getObjectType() throws Exception {
assertNotNull(datastoreFactoryBean.getObjectType());
}
}
......@@ -69,8 +69,7 @@ public class GoogleAuthorityStoreTest {
String authorityId = "testAuthorityId";
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).thenReturn(dataStore);
Mockito.when(dataStore.newKeyFactory()).thenReturn(keyFactory);
Mockito.when(keyFactory.setKind(SchemaConstants.AUTHORITY_KIND)).thenReturn(keyFactory);
Mockito.when(keyFactory.setNamespace(SchemaConstants.NAMESPACE)).thenReturn(keyFactory);
......@@ -86,8 +85,7 @@ public class GoogleAuthorityStoreTest {
try {
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).thenReturn(dataStore);
Mockito.when(dataStore.newKeyFactory()).thenReturn(keyFactory);
Mockito.when(keyFactory.setKind(SchemaConstants.AUTHORITY_KIND)).thenReturn(keyFactory);
Mockito.when(keyFactory.setNamespace(SchemaConstants.NAMESPACE)).thenReturn(keyFactory);
......@@ -107,8 +105,7 @@ public class GoogleAuthorityStoreTest {
public void testCreateAuthority() throws NotFoundException, ApplicationException, BadRequestException {
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).thenReturn(dataStore);
Mockito.when(dataStore.newKeyFactory()).thenReturn(keyFactory);
Mockito.when(keyFactory.setKind(SchemaConstants.AUTHORITY_KIND)).thenReturn(keyFactory);
Mockito.when(keyFactory.setNamespace(SchemaConstants.NAMESPACE)).thenReturn(keyFactory);
......@@ -126,8 +123,7 @@ public class GoogleAuthorityStoreTest {
Mockito.when(headers.getPartitionId()).thenReturn("test");
mockGoogleAuthorityStore = Mockito.spy(mockGoogleAuthorityStore);
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).thenReturn(dataStore);
Mockito.when(dataStore.newKeyFactory()).thenReturn(keyFactory);
Mockito.when(keyFactory.setKind(SchemaConstants.AUTHORITY_KIND)).thenReturn(keyFactory);
Mockito.when(keyFactory.setNamespace(SchemaConstants.NAMESPACE)).thenReturn(keyFactory);
......@@ -152,8 +148,7 @@ public class GoogleAuthorityStoreTest {
Mockito.when(headers.getPartitionId()).thenReturn("test");
mockGoogleAuthorityStore = Mockito.spy(mockGoogleAuthorityStore);
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).thenReturn(dataStore);
Mockito.when(dataStore.newKeyFactory()).thenReturn(keyFactory);
Mockito.when(keyFactory.setKind(SchemaConstants.AUTHORITY_KIND)).thenReturn(keyFactory);
Mockito.when(keyFactory.setNamespace(SchemaConstants.NAMESPACE)).thenReturn(keyFactory);
......
......@@ -70,8 +70,7 @@ public class GoogleEntityTypeStoreTest {
String entityId = "testEntityId";
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).thenReturn(dataStore);
Mockito.when(dataStore.newKeyFactory()).thenReturn(keyFactory);
Mockito.when(keyFactory.setKind(SchemaConstants.ENTITY_TYPE)).thenReturn(keyFactory);
Mockito.when(keyFactory.setNamespace(SchemaConstants.NAMESPACE)).thenReturn(keyFactory);
......@@ -88,8 +87,7 @@ public class GoogleEntityTypeStoreTest {
try {
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).thenReturn(dataStore);
Mockito.when(dataStore.newKeyFactory()).thenReturn(keyFactory);
Mockito.when(keyFactory.setKind(SchemaConstants.ENTITY_TYPE)).thenReturn(keyFactory);
Mockito.when(keyFactory.setNamespace(SchemaConstants.NAMESPACE)).thenReturn(keyFactory);
......@@ -110,8 +108,7 @@ public class GoogleEntityTypeStoreTest {
System.out.println("testCreate");
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).thenReturn(dataStore);
Mockito.when(dataStore.newKeyFactory()).thenReturn(keyFactory);
Mockito.when(keyFactory.setKind(SchemaConstants.ENTITY_TYPE)).thenReturn(keyFactory);
Mockito.when(keyFactory.setNamespace(SchemaConstants.NAMESPACE)).thenReturn(keyFactory);
......@@ -127,8 +124,7 @@ public class GoogleEntityTypeStoreTest {
System.out.println("testCreate_BadRequestException");
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).thenReturn(dataStore);
Mockito.when(mockEntityType.getEntityTypeId()).thenReturn("wks");
Mockito.when(dataStore.newKeyFactory()).thenReturn(keyFactory);
Mockito.when(keyFactory.setKind(SchemaConstants.ENTITYTYPE_KIND)).thenReturn(keyFactory);
......@@ -153,8 +149,7 @@ public class GoogleEntityTypeStoreTest {
System.out.println("testCreate_ApplicationException");
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).thenReturn(dataStore);
Mockito.when(dataStore.newKeyFactory()).thenReturn(keyFactory);
Mockito.when(keyFactory.setKind(SchemaConstants.ENTITYTYPE_KIND)).thenReturn(keyFactory);
Mockito.when(keyFactory.setNamespace(SchemaConstants.NAMESPACE)).thenReturn(keyFactory);
......
......@@ -106,7 +106,7 @@ public class GoogleSchemaInfoStoreTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Before
public void setUp() {
ReflectionTestUtils.setField(schemaInfoStore, "sharedTenant", "common");
......@@ -116,8 +116,7 @@ public class GoogleSchemaInfoStoreTest {
public void testGetLatestMinorVersion_ReturnNull() throws NotFoundException, ApplicationException {
when(headers.getPartitionId()).thenReturn("tenant");
Mockito.when(tenantFactory.getTenantInfo("tenant")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).thenReturn(dataStore);
Mockito.when(dataStore.run(Mockito.any())).thenReturn(queryResult);
Mockito.when(entity.getBlob(SchemaConstants.SCHEMA)).thenReturn(blob);
Mockito.when(blob.toByteArray()).thenReturn("{}".getBytes());
......@@ -129,8 +128,7 @@ public class GoogleSchemaInfoStoreTest {
String schemaId = "schemaId";
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).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);
......@@ -148,8 +146,7 @@ public class GoogleSchemaInfoStoreTest {
String schemaId = "schemaId";
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).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);
......@@ -162,8 +159,7 @@ public class GoogleSchemaInfoStoreTest {
public void testCreateSchemaInfo_Positive() throws ApplicationException, BadRequestException {
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).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);
......@@ -184,10 +180,8 @@ public class GoogleSchemaInfoStoreTest {
Mockito.when(tenantFactory.getTenantInfo("common")).thenReturn(tenantInfoCommon);
Mockito.when(tenantInfo.getName()).thenReturn("tenant");
Mockito.when(tenantInfoCommon.getName()).thenReturn("common");
Mockito.when(dataStoreFactory.getDatastore(tenantInfo.getName(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfoCommon.getName(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).thenReturn(dataStore);
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);
......@@ -209,10 +203,8 @@ public class GoogleSchemaInfoStoreTest {
Mockito.when(tenantFactory.getTenantInfo("common")).thenReturn(tenantInfoCommon);
Mockito.when(tenantInfo.getName()).thenReturn("test");
Mockito.when(tenantInfoCommon.getName()).thenReturn("common");
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfoCommon.getName(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).thenReturn(dataStore);
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);
......@@ -234,10 +226,8 @@ public class GoogleSchemaInfoStoreTest {
Mockito.when(tenantFactory.getTenantInfo("common")).thenReturn(tenantInfoCommon);
Mockito.when(tenantInfo.getName()).thenReturn("test");
Mockito.when(tenantInfoCommon.getName()).thenReturn("common");
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfoCommon.getName(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).thenReturn(dataStore);
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);
......@@ -254,8 +244,7 @@ public class GoogleSchemaInfoStoreTest {
String tenantId = "test";
Mockito.when(headers.getPartitionId()).thenReturn(tenantId);
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).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);
......@@ -270,8 +259,7 @@ public class GoogleSchemaInfoStoreTest {
throws NotFoundException, ApplicationException, BadRequestException {
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).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);
......@@ -291,8 +279,7 @@ public class GoogleSchemaInfoStoreTest {
try {
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).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);
......@@ -317,8 +304,7 @@ public class GoogleSchemaInfoStoreTest {
throws NotFoundException, ApplicationException, BadRequestException {
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).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);
......@@ -336,8 +322,7 @@ public class GoogleSchemaInfoStoreTest {
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(headers.getUserEmail()).thenReturn("dummy-user");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).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);
......@@ -362,8 +347,7 @@ public class GoogleSchemaInfoStoreTest {
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(headers.getUserEmail()).thenReturn("dummy-user");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).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);
......@@ -387,8 +371,7 @@ public class GoogleSchemaInfoStoreTest {
Mockito.when(headers.getPartitionId()).thenReturn("test");
Mockito.when(headers.getUserEmail()).thenReturn("dummy-user");
Mockito.when(tenantFactory.getTenantInfo("test")).thenReturn(tenantInfo);
Mockito.when(dataStoreFactory.getDatastore(headers.getPartitionId(), SchemaConstants.NAMESPACE))
.thenReturn(dataStore);
Mockito.when(dataStoreFactory.getDatastore(tenantInfo)).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);
......@@ -410,8 +393,7 @@ public class GoogleSchemaInfoStoreTest {
when(headers.getPartitionId()).thenReturn("tenant");