Commit 23c62fc3 authored by harshit aggarwal's avatar harshit aggarwal
Browse files

Initial Commit

parent 66a13540
Pipeline #6564 passed with stages
in 10 minutes and 54 seconds
......@@ -21,7 +21,7 @@
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<packaging>jar</packaging>
<version>0.0.20</version>
<version>0.0.21</version>
<name>core-lib-azure</name>
<properties>
......
......@@ -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);
}
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment