Skip to content

Commit

Permalink
verify jp2Processor is called
Browse files Browse the repository at this point in the history
  • Loading branch information
krwong committed Dec 9, 2024
1 parent 22ac6ff commit 1721b83
Showing 1 changed file with 7 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,34 +85,28 @@ public void testAccessCopyRouteNoForceNoFileExists() throws Exception {
when(addAccessCopyProcessor.needsRun(any())).thenReturn(true);
createContext(accessCopyRoute);

var jp2Endpoint = getMockEndpoint("mock:bean:jp2Processor");
jp2Endpoint.expectedMessageCount(0);

Map<String, Object> headers = createEvent(fileID, eventTypes, "false");

template.sendBodyAndHeaders("", headers);

verify(jp2Processor).process(any(Exchange.class));
verify(addAccessCopyProcessor).process(any(Exchange.class));
verify(addAccessCopyProcessor).cleanupTempFile(any(Exchange.class));
verify(imageCacheInvalidationProcessor).process(any());
jp2Endpoint.assertIsSatisfied();
}

@Test
public void testAccessCopyRouteForceNoFileExists() throws Exception {
when(addAccessCopyProcessor.needsRun(any())).thenReturn(true);
createContext(accessCopyRoute);

var jp2Endpoint = getMockEndpoint("mock:bean:jp2Processor");
jp2Endpoint.expectedMessageCount(0);

Map<String, Object> headers = createEvent(fileID, eventTypes, "true");

template.sendBodyAndHeaders("", headers);

verify(jp2Processor).process(any(Exchange.class));
verify(addAccessCopyProcessor).process(any(Exchange.class));
verify(imageCacheInvalidationProcessor).process(any());
jp2Endpoint.assertIsSatisfied();
}

@Test
Expand All @@ -123,17 +117,14 @@ public void testAccessCopyRouteNoForceFileExists() throws Exception {

createContext(accessCopyRoute);

var jp2Endpoint = getMockEndpoint("mock:bean:jp2Processor");
jp2Endpoint.expectedMessageCount(0);

Map<String, Object> headers = createEvent(fileID, eventTypes, "false");

template.sendBodyAndHeaders("", headers);

verify(jp2Processor, never()).process(any(Exchange.class));
verify(addAccessCopyProcessor, never()).process(any(Exchange.class));
verify(addAccessCopyProcessor, never()).cleanupTempFile(any(Exchange.class));
verify(imageCacheInvalidationProcessor, never()).process(any());
jp2Endpoint.assertIsSatisfied();
}

@Test
Expand All @@ -145,16 +136,13 @@ public void testAccessCopyRouteForceFileExists() throws Exception {

createContext(accessCopyRoute);

var jp2Endpoint = getMockEndpoint("mock:bean:jp2Processor");
jp2Endpoint.expectedMessageCount(0);

Map<String, Object> headers = createEvent(fileID, eventTypes, "true");

template.sendBodyAndHeaders("", headers);

verify(jp2Processor).process(any(Exchange.class));
verify(addAccessCopyProcessor).process(any(Exchange.class));
verify(imageCacheInvalidationProcessor).process(any());
jp2Endpoint.assertIsSatisfied();
}

@Test
Expand All @@ -170,43 +158,39 @@ public void testAccessCopyRejection() throws Exception {

template.sendBodyAndHeaders("", headers);

verify(jp2Processor, never()).process(any(Exchange.class));
verify(addAccessCopyProcessor, never()).process(any(Exchange.class));
imageEndpoint.assertIsSatisfied();
}

@Test
public void testAccessCopyDisallowedImageType() throws Exception {
createContext(accessCopyRoute);

when(addAccessCopyProcessor.needsRun(any())).thenReturn(true);
var jp2Endpoint = getMockEndpoint("mock:bean:jp2Processor");
jp2Endpoint.expectedMessageCount(0);

Map<String, Object> headers = createEvent(fileID, eventTypes, "false");
headers.put(CdrBinaryMimeType, "image/vnd.fpx");

template.sendBodyAndHeaders("", headers);

verify(jp2Processor, never()).process(any(Exchange.class));
verify(addAccessCopyProcessor, never()).process(any(Exchange.class));
jp2Endpoint.assertIsSatisfied();
}

@Test
public void testAccessCopyIconFile() throws Exception {
createContext(accessCopyRoute);

when(addAccessCopyProcessor.needsRun(any())).thenReturn(true);
var jp2Endpoint = getMockEndpoint("mock:bean:jp2Processor");
jp2Endpoint.expectedMessageCount(0);

Map<String, Object> headers = createEvent(fileID, eventTypes, "false");
headers.put(CdrBinaryMimeType, "image/x-icon");

template.sendBodyAndHeaders("", headers);

verify(jp2Processor, never()).process(any(Exchange.class));
verify(addAccessCopyProcessor).needsRun(any(Exchange.class));
verify(addAccessCopyProcessor, never()).process(any(Exchange.class));
jp2Endpoint.assertIsSatisfied();
}

private void createContext(String routeName) throws Exception {
Expand Down

0 comments on commit 1721b83

Please sign in to comment.