Skip to content

Commit

Permalink
Fix bug in 'getHashStoreFromMetadigProps' where exception was thrown …
Browse files Browse the repository at this point in the history
…instead of a return value and update junit tests
  • Loading branch information
doulikecookiedough committed Feb 3, 2025
1 parent f8dc759 commit d7ef057
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ public HashStore getHashStoreFromMetadigProps()

} catch (Exception e) {
log.error("Unable to instantiate a hashstore: " + e.getMessage());
throw e;
return hashStore;
}
return hashStore;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public void testGetSystemMetadataFromHashStore_nullHashStore() throws Exception
* Confirm that an input stream to a data object is returned. No exception should be thrown.
*/
@Test
public void testGetObjectFromHashStore() {
public void testGetObjectFromHashStore() throws Exception {
RequestReportJob job = new RequestReportJob();
Identifier pid = new Identifier();
pid.setValue(testPid);
Expand Down Expand Up @@ -239,10 +239,10 @@ public void testGetObjectFromHashStore_NotAuthorized() throws Exception {

/**
* Confirm that no exception bubbles up when a hashstore is null, and the MN and CN API
* throws an exception when retrieving an eml metadata object
* throws an exception when retrieving a data object (ex. eml metadata doc)
*/
@Test
public void testGetEMLMetadataDocFromHashStore_nullHashStore() throws Exception {
public void testGetObjectFromHashStore_nullHashStore() throws Exception {
RequestReportJob job = new RequestReportJob();
MultipartMNode mnNode = mock(MultipartMNode.class);
Session session = mock(Session.class);
Expand All @@ -252,7 +252,7 @@ public void testGetEMLMetadataDocFromHashStore_nullHashStore() throws Exception
when(mnNode.get(session, pid)).thenThrow(
new NotAuthorized("8000", "User is not authorized"));

job.getSystemMetadataFromHashStore(pid, null);
job.getObjectFromHashStore(pid, null);
}

/**
Expand Down Expand Up @@ -291,10 +291,10 @@ public void testGetHashStorePropsFromMetadigProps_hashStoreUnavailable() throws
.when(() -> HashStoreFactory.getHashStore(anyString(), any(Properties.class)))
.thenThrow(new IOException("Mocked IOException"));

HashStore result = job.getHashStoreFromMetadigProps();
HashStore hashstore = job.getHashStoreFromMetadigProps();

assertNull(
result,
hashstore,
"HashStore should return as null when any exception is thrown ");
}
}
Expand Down

0 comments on commit d7ef057

Please sign in to comment.