Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Schema
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSDU
OSDU Data Platform
System
Schema
Commits
5d290b62
Commit
5d290b62
authored
1 year ago
by
Solomon Ayalew
Browse files
Options
Downloads
Patches
Plain Diff
Increase test coverage
parent
465b0de0
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!539
AWS Merge Dev Into Master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
provider/schema-aws/src/test/java/org/opengroup/osdu/schema/provider/aws/impl/schemainfostore/AwsEntityTypeStoreTest.java
+91
-71
91 additions, 71 deletions
...ider/aws/impl/schemainfostore/AwsEntityTypeStoreTest.java
with
91 additions
and
71 deletions
provider/schema-aws/src/test/java/org/opengroup/osdu/schema/provider/aws/impl/schemainfostore/AwsEntityTypeStoreTest.java
+
91
−
71
View file @
5d290b62
...
...
@@ -39,12 +39,11 @@ import static org.junit.Assert.assertEquals;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
AwsEntityTypeStoreTest
{
@InjectMocks
private
AwsEntityTypeStore
entityTypeStore
;
@InjectMocks
private
AwsEntityTypeStore
entityTypeStore
;
@Mock
private
DpsHeaders
headers
;
@Mock
private
DpsHeaders
headers
;
@Mock
private
DynamoDBQueryHelperFactory
queryHelperFactory
;
...
...
@@ -52,70 +51,91 @@ public class AwsEntityTypeStoreTest {
@Mock
private
DynamoDBQueryHelperV2
queryHelper
;
@Mock
private
JaxRsDpsLog
logger
;
private
static
final
String
COMMON_TENANT_ID
=
"common"
;
@Before
public
void
setUp
()
throws
Exception
{
Mockito
.
when
(
queryHelperFactory
.
getQueryHelperForPartition
(
Mockito
.
any
(
DpsHeaders
.
class
),
Mockito
.
any
()))
.
thenReturn
(
queryHelper
);
ReflectionTestUtils
.
setField
(
entityTypeStore
,
"sharedTenant"
,
COMMON_TENANT_ID
);
}
@Rule
public
ExpectedException
expectedException
=
ExpectedException
.
none
();
@Test
public
void
get
()
throws
NotFoundException
,
ApplicationException
{
String
entityTypeId
=
"id"
;
String
partitionId
=
"partitionId"
;
EntityType
expected
=
new
EntityType
();
EntityTypeDoc
entityTypeDoc
=
new
EntityTypeDoc
(
"id"
,
partitionId
,
expected
);
Mockito
.
when
(
queryHelper
.
loadByPrimaryKey
(
Mockito
.
any
(),
Mockito
.
any
())).
thenReturn
(
entityTypeDoc
);
Mockito
.
when
(
headers
.
getPartitionId
()).
thenReturn
(
partitionId
);
EntityType
actual
=
entityTypeStore
.
get
(
entityTypeId
);
Assert
.
assertEquals
(
expected
,
actual
);
}
@Test
public
void
get_SystemSchemas
()
throws
NotFoundException
,
ApplicationException
{
String
entityTypeId
=
"id"
;
EntityType
expected
=
new
EntityType
();
EntityTypeDoc
entityTypeDoc
=
new
EntityTypeDoc
(
"id"
,
COMMON_TENANT_ID
,
expected
);
Mockito
.
when
(
queryHelper
.
loadByPrimaryKey
(
Mockito
.
any
(),
Mockito
.
any
())).
thenReturn
(
entityTypeDoc
);
Mockito
.
when
(
headers
.
getPartitionId
()).
thenReturn
(
COMMON_TENANT_ID
);
EntityType
actual
=
entityTypeStore
.
get
(
entityTypeId
);
Assert
.
assertEquals
(
expected
,
actual
);
}
@Test
public
void
create
()
throws
BadRequestException
,
ApplicationException
{
String
partitionId
=
"partitionId"
;
EntityType
expected
=
new
EntityType
();
Mockito
.
when
(
queryHelper
.
keyExistsInTable
(
Mockito
.
any
(),
Mockito
.
any
())).
thenReturn
(
false
);
Mockito
.
doNothing
().
when
(
queryHelper
).
save
(
Mockito
.
any
());
Mockito
.
when
(
headers
.
getPartitionId
()).
thenReturn
(
partitionId
);
EntityType
actual
=
entityTypeStore
.
create
(
expected
);
assertEquals
(
expected
,
actual
);
}
@Test
public
void
create_SystemSchemas
()
throws
BadRequestException
,
ApplicationException
{
EntityType
expected
=
new
EntityType
();
Mockito
.
when
(
queryHelper
.
keyExistsInTable
(
Mockito
.
any
(),
Mockito
.
any
())).
thenReturn
(
false
);
Mockito
.
doNothing
().
when
(
queryHelper
).
save
(
Mockito
.
any
());
Mockito
.
when
(
headers
.
getPartitionId
()).
thenReturn
(
COMMON_TENANT_ID
);
EntityType
actual
=
entityTypeStore
.
create
(
expected
);
assertEquals
(
expected
,
actual
);
}
@Mock
private
JaxRsDpsLog
logger
;
private
static
final
String
COMMON_TENANT_ID
=
"common"
;
@Before
public
void
setUp
()
throws
Exception
{
Mockito
.
when
(
queryHelperFactory
.
getQueryHelperForPartition
(
Mockito
.
any
(
DpsHeaders
.
class
),
Mockito
.
any
()))
.
thenReturn
(
queryHelper
);
ReflectionTestUtils
.
setField
(
entityTypeStore
,
"sharedTenant"
,
COMMON_TENANT_ID
);
}
@Rule
public
ExpectedException
expectedException
=
ExpectedException
.
none
();
@Test
public
void
get
()
throws
NotFoundException
,
ApplicationException
{
String
entityTypeId
=
"id"
;
String
partitionId
=
"partitionId"
;
EntityType
expected
=
new
EntityType
();
EntityTypeDoc
entityTypeDoc
=
new
EntityTypeDoc
(
"id"
,
partitionId
,
expected
);
Mockito
.
when
(
queryHelper
.
loadByPrimaryKey
(
Mockito
.
any
(),
Mockito
.
any
())).
thenReturn
(
entityTypeDoc
);
Mockito
.
when
(
headers
.
getPartitionId
()).
thenReturn
(
partitionId
);
EntityType
actual
=
entityTypeStore
.
get
(
entityTypeId
);
Assert
.
assertEquals
(
expected
,
actual
);
}
@Test
(
expected
=
NotFoundException
.
class
)
public
void
getThrowsNotFoundException
()
throws
NotFoundException
,
ApplicationException
{
String
entityTypeId
=
"id"
;
String
partitionId
=
"partitionId"
;
Mockito
.
when
(
queryHelper
.
loadByPrimaryKey
(
Mockito
.
any
(),
Mockito
.
any
())).
thenReturn
(
null
);
Mockito
.
when
(
headers
.
getPartitionId
()).
thenReturn
(
partitionId
);
entityTypeStore
.
get
(
entityTypeId
);
}
@Test
public
void
get_SystemSchemas
()
throws
NotFoundException
,
ApplicationException
{
String
entityTypeId
=
"id"
;
EntityType
expected
=
new
EntityType
();
EntityTypeDoc
entityTypeDoc
=
new
EntityTypeDoc
(
"id"
,
COMMON_TENANT_ID
,
expected
);
Mockito
.
when
(
queryHelper
.
loadByPrimaryKey
(
Mockito
.
any
(),
Mockito
.
any
())).
thenReturn
(
entityTypeDoc
);
Mockito
.
when
(
headers
.
getPartitionId
()).
thenReturn
(
COMMON_TENANT_ID
);
EntityType
actual
=
entityTypeStore
.
get
(
entityTypeId
);
Assert
.
assertEquals
(
expected
,
actual
);
}
@Test
public
void
create
()
throws
BadRequestException
,
ApplicationException
{
String
partitionId
=
"partitionId"
;
EntityType
expected
=
new
EntityType
();
Mockito
.
when
(
queryHelper
.
keyExistsInTable
(
Mockito
.
any
(),
Mockito
.
any
())).
thenReturn
(
false
);
Mockito
.
doNothing
().
when
(
queryHelper
).
save
(
Mockito
.
any
());
Mockito
.
when
(
headers
.
getPartitionId
()).
thenReturn
(
partitionId
);
EntityType
actual
=
entityTypeStore
.
create
(
expected
);
assertEquals
(
expected
,
actual
);
}
@Test
(
expected
=
BadRequestException
.
class
)
public
void
createHandleskeyExistsInTable
()
throws
BadRequestException
,
ApplicationException
{
String
partitionId
=
"partitionId"
;
EntityType
expected
=
new
EntityType
();
Mockito
.
when
(
queryHelper
.
keyExistsInTable
(
Mockito
.
any
(),
Mockito
.
any
())).
thenReturn
(
true
);
Mockito
.
when
(
headers
.
getPartitionId
()).
thenReturn
(
partitionId
);
entityTypeStore
.
create
(
expected
);
}
@Test
public
void
create_SystemSchemas
()
throws
BadRequestException
,
ApplicationException
{
EntityType
expected
=
new
EntityType
();
Mockito
.
when
(
queryHelper
.
keyExistsInTable
(
Mockito
.
any
(),
Mockito
.
any
())).
thenReturn
(
false
);
Mockito
.
doNothing
().
when
(
queryHelper
).
save
(
Mockito
.
any
());
Mockito
.
when
(
headers
.
getPartitionId
()).
thenReturn
(
COMMON_TENANT_ID
);
EntityType
actual
=
entityTypeStore
.
create
(
expected
);
assertEquals
(
expected
,
actual
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment