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
Kelly Domico
OS Core Lib Azure
Commits
23c62fc3
Commit
23c62fc3
authored
Aug 26, 2020
by
harshit aggarwal
Browse files
Initial Commit
parent
66a13540
Changes
3
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
23c62fc3
...
...
@@ -21,7 +21,7 @@
<groupId>
org.opengroup.osdu
</groupId>
<artifactId>
core-lib-azure
</artifactId>
<packaging>
jar
</packaging>
<version>
0.0.2
0
</version>
<version>
0.0.2
1
</version>
<name>
core-lib-azure
</name>
<properties>
...
...
src/main/java/org/opengroup/osdu/azure/CosmosStore.java
View file @
23c62fc3
...
...
@@ -141,11 +141,13 @@ public class CosmosStore {
}
catch
(
NotFoundException
e
)
{
LOGGER
.
info
(
String
.
format
(
"Unable to find item with ID=%s and PK=%s"
,
id
,
partitionKey
));
return
Optional
.
empty
();
}
catch
(
IOException
e
)
{
LOGGER
.
warning
(
String
.
format
(
"Malformed document for item with ID=%s and PK=%s"
,
id
,
partitionKey
));
return
Optional
.
empty
();
}
catch
(
CosmosClientException
e
)
{
String
errorMessage
=
"Unexpectedly encountered error calling CosmosDB"
;
}
catch
(
IOException
|
CosmosClientException
e
)
{
String
errorMessage
;
if
(
e
instanceof
IOException
)
{
errorMessage
=
String
.
format
(
"Malformed document for item with ID=%s and PK=%s"
,
id
,
partitionKey
);
}
else
{
errorMessage
=
"Unexpectedly encountered error calling CosmosDB"
;
}
LOGGER
.
log
(
Level
.
WARNING
,
errorMessage
,
e
);
throw
new
AppException
(
500
,
errorMessage
,
e
.
getMessage
(),
e
);
}
...
...
src/test/java/org/opengroup/osdu/azure/CosmosStoreTest.java
View file @
23c62fc3
...
...
@@ -137,9 +137,12 @@ class CosmosStoreTest {
}
@Test
void
findItem_
returnsEmpty
_ifMalformedDocument
()
throws
IOException
{
void
findItem_
throws500
_ifMalformedDocument
()
throws
IOException
{
doThrow
(
IOException
.
class
).
when
(
cosmosItemProperties
).
getObject
(
any
());
assertFalse
(
cosmosStore
.
findItem
(
DATA_PARTITION_ID
,
COSMOS_DB
,
COLLECTION
,
ID
,
PARTITION_KEY
,
String
.
class
).
isPresent
());
AppException
exception
=
assertThrows
(
AppException
.
class
,
()
->
{
cosmosStore
.
findItem
(
DATA_PARTITION_ID
,
COSMOS_DB
,
COLLECTION
,
ID
,
PARTITION_KEY
,
String
.
class
);
});
assertEquals
(
500
,
exception
.
getError
().
getCode
());
}
@Test
...
...
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