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
Lib
cloud
azure
OS Core Lib Azure
Commits
4b1246d7
Commit
4b1246d7
authored
Aug 05, 2020
by
Aman Verma
Browse files
adding required UTs
parent
174fbff9
Pipeline
#4907
passed with stages
in 2 minutes and 13 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/test/java/org/opengroup/osdu/azure/CosmosStoreTest.java
View file @
4b1246d7
...
...
@@ -14,17 +14,7 @@
package
org.opengroup.osdu.azure
;
import
com.azure.cosmos.CosmosClient
;
import
com.azure.cosmos.CosmosClientException
;
import
com.azure.cosmos.CosmosContainer
;
import
com.azure.cosmos.CosmosDatabase
;
import
com.azure.cosmos.CosmosItem
;
import
com.azure.cosmos.CosmosItemProperties
;
import
com.azure.cosmos.CosmosItemResponse
;
import
com.azure.cosmos.FeedOptions
;
import
com.azure.cosmos.FeedResponse
;
import
com.azure.cosmos.NotFoundException
;
import
com.azure.cosmos.SqlQuerySpec
;
import
com.azure.cosmos.*
;
import
com.azure.cosmos.internal.AsyncDocumentClient
;
import
com.azure.cosmos.internal.Document
;
import
org.junit.jupiter.api.BeforeEach
;
...
...
@@ -43,19 +33,10 @@ import java.util.Collections;
import
java.util.Iterator
;
import
java.util.List
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertFalse
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertThrows
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyString
;
import
static
org
.
mockito
.
Mockito
.
doReturn
;
import
static
org
.
mockito
.
Mockito
.
doThrow
;
import
static
org
.
mockito
.
Mockito
.
eq
;
import
static
org
.
mockito
.
Mockito
.
lenient
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
mockito
.
Mockito
.*;
@ExtendWith
(
MockitoExtension
.
class
)
class
CosmosStoreTest
{
...
...
@@ -158,6 +139,33 @@ class CosmosStoreTest {
assertEquals
(
500
,
exception
.
getError
().
getCode
());
}
@Test
void
createItem_throws409_ifDuplicateDocument
()
throws
CosmosClientException
{
doThrow
(
ConflictException
.
class
).
when
(
container
).
createItem
(
any
());
AppException
exception
=
assertThrows
(
AppException
.
class
,
()
->
{
cosmosStore
.
createItem
(
DATA_PARTITION_ID
,
COSMOS_DB
,
COLLECTION
,
"some-data"
);
});
assertEquals
(
409
,
exception
.
getError
().
getCode
());
}
@Test
void
createItem_throws500_ifUnknownError
()
throws
CosmosClientException
{
doThrow
(
CosmosClientException
.
class
).
when
(
container
).
createItem
(
any
());
AppException
exception
=
assertThrows
(
AppException
.
class
,
()
->
{
cosmosStore
.
createItem
(
DATA_PARTITION_ID
,
COSMOS_DB
,
COLLECTION
,
"some-data"
);
});
assertEquals
(
500
,
exception
.
getError
().
getCode
());
}
@Test
void
createItem_Success
()
throws
CosmosClientException
{
try
{
cosmosStore
.
createItem
(
DATA_PARTITION_ID
,
COSMOS_DB
,
COLLECTION
,
"some-data"
);
}
catch
(
Exception
ex
)
{
fail
(
"Should not fail."
);
}
}
@Test
void
findAllItems_executesCorrectQuery
()
throws
IOException
{
mockQueryResponse
(
"s1"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment