use of ddf.catalog.CatalogFramework in project ddf by codice.
the class TestResourceMetacardTransformer method testFrameworkThrowsIoException.
@Test
public void testFrameworkThrowsIoException() throws Exception {
String filePath = ABSOLUTE_PATH + TEST_PATH + JPEG_FILE_NAME_1;
URI uri = getUri(filePath);
Metacard metacard = getMockMetacard(uri);
thrown.expect(CatalogTransformerException.class);
thrown.expectMessage("Unable to retrieve resource.");
thrown.expectMessage("Metacard id: " + TEST_ID);
thrown.expectMessage("Uri: " + uri);
thrown.expectMessage("Source: " + TEST_SITE);
boolean expectSuccess = false;
MimeType mimeType = getMimeType(JPEG_MIME_TYPE);
CatalogFramework framework = getFrameworkException(new IOException("Test IO Exception"));
testGetResource(metacard, filePath, mimeType, framework, expectSuccess);
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class TestResourceMetacardTransformer method givenFramework.
private CatalogFramework givenFramework(ArgumentCapture answer) throws IOException, ResourceNotFoundException, ResourceNotSupportedException {
CatalogFramework framework = mock(CatalogFramework.class);
when(framework.getId()).thenReturn(TEST_SITE);
when(framework.getResource(any(ResourceRequest.class), isA(String.class))).thenAnswer(answer);
return framework;
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class TestResourceMetacardTransformer method testResourceHasNullMimeType.
@Test
public void testResourceHasNullMimeType() throws Exception {
String filePath = ABSOLUTE_PATH + TEST_PATH + TS_FILE_NAME_1;
URI uri = getUri(filePath);
Metacard metacard = getMockMetacard(uri);
boolean expectSuccess = true;
MimeType mimeType = getMimeType(DEFAULT_MIME_TYPE);
CatalogFramework framework = getFramework(getResourceResponse(getResource(null, uri)));
testGetResource(metacard, filePath, mimeType, framework, expectSuccess);
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class TestResourceMetacardTransformer method getFramework.
private CatalogFramework getFramework(ResourceResponse resourceResponse) throws Exception {
CatalogFramework framework = mock(CatalogFramework.class);
when(framework.getId()).thenReturn(TEST_SITE);
when(framework.getResource(any(ResourceRequest.class), eq(TEST_SITE))).thenReturn(resourceResponse);
return framework;
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class TestResourceMetacardTransformer method testGetResourceJpegFromFedSource.
/**
* Tests that the metacard source name is passed to the {@link CatalogFramework}
*
* @throws Exception
*/
@Test
public void testGetResourceJpegFromFedSource() throws Exception {
// given
String filePath = ABSOLUTE_PATH + TEST_PATH + JPEG_FILE_NAME_1;
String federatedSourceId = "fedSourceId";
URI uri = getUri(filePath);
Metacard metacard = getMockMetacard(uri, federatedSourceId);
MimeType mimeType = getMimeType(JPEG_MIME_TYPE);
ArgumentCapture capture = new ArgumentCapture(getResourceResponse(getResource(mimeType, uri)));
CatalogFramework framework = givenFramework(capture);
ResourceMetacardTransformer resourceTransformer = new ResourceMetacardTransformer(framework);
// when
resourceTransformer.transform(metacard, new HashMap<String, Serializable>());
// then
assertEquals(federatedSourceId, capture.inputArgs[1]);
}
Aggregations