Search in sources :

Example 31 with CatalogFramework

use of ddf.catalog.CatalogFramework in project ddf by codice.

the class TestRestEndpoint method testGetDocumentFedNullQueryResponse.

/**
     * Tests federated retrieve with a null QueryResponse
     *
     * @throws Exception
     */
@Test(expected = ServerErrorException.class)
public void testGetDocumentFedNullQueryResponse() throws Exception {
    CatalogFramework framework = givenCatalogFramework(SAMPLE_ID);
    String transformer = mockTestSetup(framework, TestType.QUERY_RESPONSE_TEST);
    executeTest(framework, transformer, false, null);
}
Also used : CatalogFramework(ddf.catalog.CatalogFramework) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 32 with CatalogFramework

use of ddf.catalog.CatalogFramework in project ddf by codice.

the class TestRestEndpoint method testGetDocumentLocalSuccess.

/**
     * Tests local retrieve with a successful response
     *
     * @throws Exception
     */
@Test
public void testGetDocumentLocalSuccess() throws Exception {
    CatalogFramework framework = givenCatalogFramework(SAMPLE_ID);
    String transformer = mockTestSetup(framework, TestType.SUCCESS_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());
}
Also used : QueryResponse(ddf.catalog.operation.QueryResponse) Response(javax.ws.rs.core.Response) SourceInfoResponse(ddf.catalog.operation.SourceInfoResponse) CatalogFramework(ddf.catalog.CatalogFramework) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 33 with CatalogFramework

use of ddf.catalog.CatalogFramework in project ddf by codice.

the class TestRestEndpoint method testGetDocumentKml.

@Test
public void testGetDocumentKml() throws Exception {
    CatalogFramework framework = givenCatalogFramework(SAMPLE_ID);
    String transformer = mockTestSetup(framework, TestType.KML_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_KML_TYPE_OUTPUT, response.getMetadata().toString());
}
Also used : QueryResponse(ddf.catalog.operation.QueryResponse) Response(javax.ws.rs.core.Response) SourceInfoResponse(ddf.catalog.operation.SourceInfoResponse) CatalogFramework(ddf.catalog.CatalogFramework) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 34 with CatalogFramework

use of ddf.catalog.CatalogFramework in project ddf by codice.

the class TestRestEndpoint method testAddDocumentPositiveCase.

@Test
public void testAddDocumentPositiveCase() throws IOException, CatalogTransformerException, IngestException, SourceUnavailableException, URISyntaxException {
    CatalogFramework framework = givenCatalogFramework(SAMPLE_ID);
    HttpHeaders headers = createHeaders(Arrays.asList(MediaType.APPLICATION_JSON));
    RESTEndpoint rest = new RESTEndpoint(framework);
    addMatchingService(rest, Arrays.asList(getSimpleTransformer()));
    UriInfo info = givenUriInfo(SAMPLE_ID);
    Response response = rest.addDocument(headers, info, mock(HttpServletRequest.class), mock(MultipartBody.class), null, new ByteArrayInputStream("".getBytes()));
    LOGGER.debug(ToStringBuilder.reflectionToString(response));
    assertThat(response.getStatus(), equalTo(201));
    assertThat(response.getMetadata(), notNullValue());
    assertThat(response.getMetadata().get(Metacard.ID).get(0).toString(), equalTo(SAMPLE_ID));
}
Also used : QueryResponse(ddf.catalog.operation.QueryResponse) Response(javax.ws.rs.core.Response) SourceInfoResponse(ddf.catalog.operation.SourceInfoResponse) HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpHeaders(javax.ws.rs.core.HttpHeaders) ByteArrayInputStream(java.io.ByteArrayInputStream) MultipartBody(org.apache.cxf.jaxrs.ext.multipart.MultipartBody) CatalogFramework(ddf.catalog.CatalogFramework) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 35 with CatalogFramework

use of ddf.catalog.CatalogFramework in project ddf by codice.

the class TestRestEndpoint method testGetDocumentFedSuccess.

/**
     * Tests federated retrieve with a successful response
     *
     * @throws Exception
     */
@Test
public void testGetDocumentFedSuccess() throws Exception {
    CatalogFramework framework = givenCatalogFramework(SAMPLE_ID);
    String transformer = mockTestSetup(framework, TestType.SUCCESS_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());
}
Also used : QueryResponse(ddf.catalog.operation.QueryResponse) Response(javax.ws.rs.core.Response) SourceInfoResponse(ddf.catalog.operation.SourceInfoResponse) CatalogFramework(ddf.catalog.CatalogFramework) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

CatalogFramework (ddf.catalog.CatalogFramework)80 Test (org.junit.Test)63 Matchers.anyString (org.mockito.Matchers.anyString)30 Metacard (ddf.catalog.data.Metacard)27 QueryResponse (ddf.catalog.operation.QueryResponse)20 ArrayList (java.util.ArrayList)20 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)19 Serializable (java.io.Serializable)18 ContentType (ddf.catalog.data.ContentType)17 URI (java.net.URI)17 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)14 HashMap (java.util.HashMap)14 SourceInfoResponse (ddf.catalog.operation.SourceInfoResponse)12 Date (java.util.Date)12 BundleContext (org.osgi.framework.BundleContext)11 MimeType (javax.activation.MimeType)10 Response (javax.ws.rs.core.Response)10 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)9 ServiceReference (org.osgi.framework.ServiceReference)9 FilterBuilder (ddf.catalog.filter.FilterBuilder)8