Skip to content

Commit d7ef057

Browse files
Fix bug in 'getHashStoreFromMetadigProps' where exception was thrown instead of a return value and update junit tests
1 parent f8dc759 commit d7ef057

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/main/java/edu/ucsb/nceas/mdqengine/scheduler/RequestReportJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ public HashStore getHashStoreFromMetadigProps()
865865

866866
} catch (Exception e) {
867867
log.error("Unable to instantiate a hashstore: " + e.getMessage());
868-
throw e;
868+
return hashStore;
869869
}
870870
return hashStore;
871871
}

src/test/java/edu/ucsb/nceas/mdqengine/scheduler/RequestReportJobTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public void testGetSystemMetadataFromHashStore_nullHashStore() throws Exception
209209
* Confirm that an input stream to a data object is returned. No exception should be thrown.
210210
*/
211211
@Test
212-
public void testGetObjectFromHashStore() {
212+
public void testGetObjectFromHashStore() throws Exception {
213213
RequestReportJob job = new RequestReportJob();
214214
Identifier pid = new Identifier();
215215
pid.setValue(testPid);
@@ -239,10 +239,10 @@ public void testGetObjectFromHashStore_NotAuthorized() throws Exception {
239239

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

255-
job.getSystemMetadataFromHashStore(pid, null);
255+
job.getObjectFromHashStore(pid, null);
256256
}
257257

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

294-
HashStore result = job.getHashStoreFromMetadigProps();
294+
HashStore hashstore = job.getHashStoreFromMetadigProps();
295295

296296
assertNull(
297-
result,
297+
hashstore,
298298
"HashStore should return as null when any exception is thrown ");
299299
}
300300
}

0 commit comments

Comments
 (0)