Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
Legal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
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
Security and Compliance
Legal
Commits
3f85b1ad
Commit
3f85b1ad
authored
4 years ago
by
Aalekh Jain
Browse files
Options
Downloads
Patches
Plain Diff
Added UTs for `get` method in `LegalTagRepositoryImpl.java`
parent
016c7212
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!61
Improve code coverage
Pipeline
#9579
failed
4 years ago
Stage: build
Stage: scan
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
provider/legal-azure/src/test/java/org/opengroup/osdu/legal/azure/tags/dataaccess/LegalTagRepositoryImplTest.java
+36
-0
36 additions, 0 deletions
...gal/azure/tags/dataaccess/LegalTagRepositoryImplTest.java
with
36 additions
and
0 deletions
provider/legal-azure/src/test/java/org/opengroup/osdu/legal/azure/tags/dataaccess/LegalTagRepositoryImplTest.java
+
36
−
0
View file @
3f85b1ad
...
...
@@ -15,6 +15,7 @@
package
org.opengroup.osdu.legal.azure.tags.dataaccess
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.ArgumentCaptor
;
import
org.mockito.InjectMocks
;
...
...
@@ -22,7 +23,12 @@ import org.mockito.Mock;
import
org.mockito.junit.MockitoJUnitRunner
;
import
org.opengroup.osdu.azure.CosmosStore
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
import
org.opengroup.osdu.core.common.model.legal.LegalTag
;
import
java.util.List
;
import
java.util.Optional
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Mockito
.*;
@RunWith
(
MockitoJUnitRunner
.
class
)
...
...
@@ -43,4 +49,34 @@ public class LegalTagRepositoryImplTest {
public
void
init
()
{
lenient
().
doReturn
(
dataPartitionId
).
when
(
headers
).
getPartitionId
();
}
@Test
public
void
testGetLegalTagCollections_whenIdsIsNull
()
{
long
[]
ids
=
null
;
List
<
LegalTag
>
output
=
(
List
<
LegalTag
>)
sut
.
get
(
ids
);
assertEquals
(
output
.
size
(),
0
);
}
@Test
public
void
testGetLegalTagCollections_whenIdsIsNotNull
()
{
long
[]
ids
=
{
0
,
1
};
String
[]
strIds
=
{
"0"
,
"1"
};
Optional
[]
legalTagDocs
=
new
Optional
[
2
];
legalTagDocs
[
0
]
=
Optional
.
of
(
new
LegalTagDoc
(
strIds
[
0
],
getLegalTagWithId
(
ids
[
0
])));
legalTagDocs
[
1
]
=
Optional
.
of
(
new
LegalTagDoc
(
strIds
[
0
],
getLegalTagWithId
(
ids
[
1
])));
doReturn
(
legalTagDocs
[
0
]).
when
(
cosmosStore
).
findItem
(
eq
(
dataPartitionId
),
any
(),
any
(),
eq
(
strIds
[
0
]),
eq
(
strIds
[
0
]),
any
());
doReturn
(
legalTagDocs
[
1
]).
when
(
cosmosStore
).
findItem
(
eq
(
dataPartitionId
),
any
(),
any
(),
eq
(
strIds
[
1
]),
eq
(
strIds
[
1
]),
any
());
List
<
LegalTag
>
output
=
(
List
<
LegalTag
>)
sut
.
get
(
ids
);
assertEquals
(
output
.
size
(),
2
);
assertEquals
(
output
.
get
(
0
).
getId
().
longValue
(),
ids
[
0
]);
assertEquals
(
output
.
get
(
1
).
getId
().
longValue
(),
ids
[
1
]);
}
private
LegalTag
getLegalTagWithId
(
long
id
)
{
LegalTag
legalTag
=
new
LegalTag
();
legalTag
.
setId
(
id
);
return
legalTag
;
}
}
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