use of ddf.catalog.CatalogFramework in project ddf by codice.
the class TestRestEndpoint method testAddDocumentNullMessage.
@Test(expected = ServerErrorException.class)
public void testAddDocumentNullMessage() {
CatalogFramework framework = mock(CatalogFramework.class);
RESTEndpoint rest = new RESTEndpoint(framework);
HttpHeaders headers = mock(HttpHeaders.class);
rest.addDocument(headers, mock(UriInfo.class), mock(HttpServletRequest.class), mock(MultipartBody.class), null, null);
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class TestRestEndpoint method testGetDocumentLocalNullQueryResponse.
/**
* Tests local retrieve with a null QueryResponse
*
* @throws Exception
*/
@Test(expected = ServerErrorException.class)
public void testGetDocumentLocalNullQueryResponse() throws Exception {
CatalogFramework framework = givenCatalogFramework(SAMPLE_ID);
String transformer = mockTestSetup(framework, TestType.QUERY_RESPONSE_TEST);
executeTest(framework, transformer, true, null);
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class TestRestEndpoint method testGetDocumentResourceFedSuccess.
/**
* Tests retrieving a federated resource with a successful response
*
* @throws Exception
*/
@Test
public void testGetDocumentResourceFedSuccess() throws Exception {
CatalogFramework framework = givenCatalogFramework(SAMPLE_ID);
String transformer = mockTestSetup(framework, TestType.RESOURCE_TEST);
Response response = executeTest(framework, transformer, false, null);
String responseMessage = IOUtils.toString((ByteArrayInputStream) response.getEntity());
assertEquals(GET_STREAM, responseMessage);
assertEquals(OK, response.getStatus());
assertEquals(GET_TYPE_OUTPUT, response.getMetadata().toString());
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class TestRestEndpoint method testGetDocumentResourceLocalSuccess.
/**
* Tests retrieving a local resource with a successful response
*
* @throws Exception
*/
@Test
public void testGetDocumentResourceLocalSuccess() throws Exception {
CatalogFramework framework = givenCatalogFramework(SAMPLE_ID);
String transformer = mockTestSetup(framework, TestType.RESOURCE_TEST);
Response response = executeTest(framework, transformer, true, null);
String responseMessage = IOUtils.toString((ByteArrayInputStream) response.getEntity());
assertEquals(GET_STREAM, responseMessage);
assertEquals(OK, response.getStatus());
assertEquals(GET_TYPE_OUTPUT, response.getMetadata().toString());
}
use of ddf.catalog.CatalogFramework in project ddf by codice.
the class TestRestEndpoint method headTest.
private Response headTest(boolean local) throws CatalogTransformerException, URISyntaxException, UnsupportedEncodingException, UnsupportedQueryException, SourceUnavailableException, FederationException, IngestException {
MetacardImpl metacard = null;
List<Result> list = new ArrayList<Result>();
Result result = mock(Result.class);
InputStream inputStream = null;
UriInfo uriInfo;
Response response;
CatalogFramework framework = givenCatalogFramework(SAMPLE_ID);
list.add(result);
QueryResponse queryResponse = mock(QueryResponse.class);
when(queryResponse.getResults()).thenReturn(list);
when(framework.query(isA(QueryRequest.class), isNull(FederationStrategy.class))).thenReturn(queryResponse);
metacard = new MetacardImpl();
metacard.setSourceId(GET_SITENAME);
when(result.getMetacard()).thenReturn(metacard);
Resource resource = mock(Resource.class);
inputStream = new ByteArrayInputStream(GET_STREAM.getBytes(GET_OUTPUT_TYPE));
when(resource.getInputStream()).thenReturn(inputStream);
when(resource.getMimeTypeValue()).thenReturn(GET_MIME_TYPE);
when(resource.getName()).thenReturn(GET_FILENAME);
when(framework.transform(isA(Metacard.class), anyString(), isA(Map.class))).thenReturn(resource);
RESTEndpoint restEndpoint = new RESTEndpoint(framework);
restEndpoint.setTikaMimeTypeResolver(new TikaMimeTypeResolver());
FilterBuilder filterBuilder = new GeotoolsFilterBuilder();
restEndpoint.setFilterBuilder(filterBuilder);
uriInfo = createSpecificUriInfo(LOCAL_RETRIEVE_ADDRESS);
if (local) {
response = restEndpoint.getHeaders(GET_ID, uriInfo, null);
} else {
response = restEndpoint.getHeaders(null, GET_ID, uriInfo, null);
}
return response;
}
Aggregations