Skip to content

Commit cfe21bd

Browse files
Add new junit test 'testGetEMLMetadataDocInputStream_NotAuthorized' to 'RequestReportJobTest' class
1 parent 2053d86 commit cfe21bd

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ public void testGetSystemMetadataFromHashStoreOrNode() throws Exception {
169169
}
170170

171171
/**
172-
* Confirm that when a NotAuthorized is thrown after calling the MN API, that this test method
173-
* does not bubble up the exception and simply returns
172+
* Confirm that when a NotAuthorized is thrown after calling the MN API to retrieve system
173+
* metadata, this test method does not bubble up the exception and simply returns
174174
*/
175175
@Test
176176
public void testGetSystemMetadataFromHashStoreOrNode_NotAuthorized() throws Exception {
@@ -204,6 +204,25 @@ public void testGetEMLMetadataDocInputStream() throws Exception {
204204
assertInstanceOf(InputStream.class, objectIS, "This should be an InputStream");
205205
}
206206

207+
/**
208+
* Confirm that when a NotAuthorized is thrown after calling the MN API to retrieve an eml
209+
* metadata document, this test method does not bubble up the exception and simply returns
210+
*/
211+
@Test
212+
public void testGetEMLMetadataDocInputStream_NotAuthorized() throws Exception {
213+
RequestReportJob job = new RequestReportJob();
214+
MultipartCNode cnNode = mock(MultipartCNode.class);
215+
MultipartMNode mnNode = mock(MultipartMNode.class);
216+
Session session = mock(Session.class);
217+
Identifier pid = new Identifier();
218+
pid.setValue("pid.not.found");
219+
220+
when(mnNode.get(session, pid)).thenThrow(
221+
new NotAuthorized("8000", "User is not authorized"));
222+
223+
job.getEMLMetadataDocInputStream(pid, hashStore, cnNode, mnNode, false, session);
224+
}
225+
207226
/**
208227
* Check that we get a hashstore successfully, no exceptions should be thrown.
209228
*/

0 commit comments

Comments
 (0)