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
ac15cd7c
Commit
ac15cd7c
authored
4 years ago
by
Aalekh Jain
Browse files
Options
Downloads
Patches
Plain Diff
Added UTs for `update` method in `LegalTagRepositoryImpl.java`
parent
b385fbf0
Branches
trusted-EPMOSDU-1401-sast-fix
Branches containing commit
No related tags found
1 merge request
!61
Improve code coverage
Pipeline
#9593
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
+31
-0
31 additions, 0 deletions
...gal/azure/tags/dataaccess/LegalTagRepositoryImplTest.java
with
31 additions
and
0 deletions
provider/legal-azure/src/test/java/org/opengroup/osdu/legal/azure/tags/dataaccess/LegalTagRepositoryImplTest.java
+
31
−
0
View file @
ac15cd7c
...
...
@@ -22,6 +22,7 @@ import org.mockito.InjectMocks;
import
org.mockito.Mock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
org.opengroup.osdu.azure.CosmosStore
;
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.legal.LegalTag
;
...
...
@@ -29,6 +30,7 @@ import java.util.List;
import
java.util.Optional
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
mockito
.
Mockito
.*;
@RunWith
(
MockitoJUnitRunner
.
class
)
...
...
@@ -100,6 +102,35 @@ public class LegalTagRepositoryImplTest {
assertEquals
(
arg2
.
getValue
(),
strId
);
}
@Test
public
void
testUpdateLegalTag_whenProvidedLegalTagIsNull
()
{
LegalTag
legalTag
=
sut
.
update
(
null
);
assertNull
(
legalTag
);
}
@Test
(
expected
=
AppException
.
class
)
public
void
testUpdateLegalTag_whenValidItemDoesNotExist_throwsException
()
{
long
id
=
0
;
LegalTag
legalTag
=
getLegalTagWithId
(
id
);
sut
.
update
(
legalTag
);
}
@Test
public
void
testUpdateLegalTag_whenValidItemExists
()
{
long
id
=
0
;
String
strId
=
String
.
valueOf
(
id
);
LegalTag
legalTag
=
getLegalTagWithId
(
id
);
Optional
<
LegalTag
>
optionalLegalTag
=
Optional
.
of
(
legalTag
);
doReturn
(
optionalLegalTag
).
when
(
cosmosStore
).
findItem
(
eq
(
dataPartitionId
),
any
(),
any
(),
eq
(
strId
),
eq
(
strId
),
any
());
LegalTag
obtainedLegalTag
=
sut
.
update
(
legalTag
);
ArgumentCaptor
<
LegalTagDoc
>
arg
=
ArgumentCaptor
.
forClass
(
LegalTagDoc
.
class
);
verify
(
cosmosStore
).
upsertItem
(
anyString
(),
any
(),
any
(),
arg
.
capture
());
assertEquals
(
arg
.
getValue
().
getId
(),
strId
);
assertEquals
(
obtainedLegalTag
.
getId
().
longValue
(),
id
);
}
private
LegalTag
getLegalTagWithId
(
long
id
)
{
LegalTag
legalTag
=
new
LegalTag
();
legalTag
.
setId
(
id
);
...
...
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