Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Schema
Commits
f6a74310
Commit
f6a74310
authored
Jan 25, 2021
by
Rustam Lotsmanenko (EPAM)
Browse files
GONRG-1634 update core-lib gcp, fix related methods & unit tests
parent
2698cf19
Pipeline
#23578
failed with stages
in 15 seconds
Changes
12
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/configuration/DatastoreFactoryBean.java
deleted
100644 → 0
View file @
2698cf19
/*
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
;
}
}
provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleAuthorityStore.java
View file @
f6a74310
...
...
@@ -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
);
...
...
provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleEntityTypeStore.java
View file @
f6a74310
...
...
@@ -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
);
...
...
provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleSchemaInfoStore.java
View file @
f6a74310
...
...
@@ -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
(
tenant
Id
,
SchemaConstants
.
NAMESPACE
);
Datastore
datastore
=
dataStoreFactory
.
getDatastore
(
tenant
Factory
.
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
(
tenant
Factory
.
getTenantInfo
(
tenant
)
);
Key
schemaKey
=
datastore
.
newKeyFactory
().
setNamespace
(
SchemaConstants
.
NAMESPACE
)
.
setKind
(
SchemaConstants
.
SCHEMA_KIND
).
newKey
(
schemaId
);
...
...
provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleSourceStore.java
View file @
f6a74310
...
...
@@ -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
);
...
...
provider/schema-gcp/src/main/java/org/opengroup/osdu/schema/impl/schemastore/GoogleSchemaStore.java
View file @
f6a74310
...
...
@@ -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
...
...
provider/schema-gcp/src/test/java/org/opengroup/osdu/schema/configuration/DatastoreFactoryBeanTest.java
deleted
100644 → 0
View file @
2698cf19
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
());
}
}
provider/schema-gcp/src/test/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleAuthorityStoreTest.java
View file @
f6a74310
...
...
@@ -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
);
...
...
provider/schema-gcp/src/test/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleEntityTypeStoreTest.java
View file @
f6a74310
...
...
@@ -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
);
...
...
provider/schema-gcp/src/test/java/org/opengroup/osdu/schema/impl/schemainfostore/GoogleSchemaInfoStoreTest.java
View file @
f6a74310
...
...
@@ -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"
);
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
);
...
...
@@ -432,8 +414,7 @@ public class GoogleSchemaInfoStoreTest {
Mockito
.
when
(
headers
.
getPartitionId
()).
thenReturn
(
"test"
);
Mockito
.
when
(
tenantFactory
.
getTenantInfo
(
"test"
)).
thenReturn
(
tenantInfo
);
Mockito
.
when
(
tenantInfo
.
getName
()).
thenReturn
(
"test"
);
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
);