Search in sources :

Example 1 with GetRecordByIdRequest

use of org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordByIdRequest in project ddf by codice.

the class TestCswEndpoint method testRetrieveProductGetRecordByIdWithInvalidRangeHeader.

@Test(expected = CswException.class)
public void testRetrieveProductGetRecordByIdWithInvalidRangeHeader() throws IOException, ResourceNotFoundException, ResourceNotSupportedException, CswException {
    final GetRecordByIdRequest getRecordByIdRequest = new GetRecordByIdRequest();
    getRecordByIdRequest.setId("123");
    getRecordByIdRequest.setOutputFormat(MediaType.APPLICATION_OCTET_STREAM);
    getRecordByIdRequest.setOutputSchema(OCTET_STREAM_OUTPUT_SCHEMA);
    setUpMocksForProductRetrieval(true);
    csw.getRecordById(getRecordByIdRequest, "100");
}
Also used : GetRecordByIdRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordByIdRequest) Test(org.junit.Test)

Example 2 with GetRecordByIdRequest

use of org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordByIdRequest in project ddf by codice.

the class TestCswEndpoint method testGetRecordById.

@Test
public void testGetRecordById() throws CswException, FederationException, SourceUnavailableException, UnsupportedQueryException {
    final GetRecordByIdRequest getRecordByIdRequest = new GetRecordByIdRequest();
    getRecordByIdRequest.setId("123");
    getRecordByIdRequest.setOutputFormat(MediaType.APPLICATION_XML);
    getRecordByIdRequest.setOutputSchema(CswConstants.CSW_OUTPUT_SCHEMA);
    getRecordByIdRequest.setElementSetName("full");
    final Metacard metacard = new MetacardImpl();
    final List<Result> mockResults = Collections.singletonList(new ResultImpl(metacard));
    final QueryResponseImpl queryResponse = new QueryResponseImpl(null, mockResults, mockResults.size());
    doReturn(queryResponse).when(catalogFramework).query(any(QueryRequest.class));
    final CswRecordCollection cswRecordCollection = csw.getRecordById(getRecordByIdRequest, null);
    verifyCswRecordCollection(cswRecordCollection, metacard);
    assertThat(cswRecordCollection.getElementSetType(), is(ElementSetType.FULL));
}
Also used : Metacard(ddf.catalog.data.Metacard) QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) QueryRequest(ddf.catalog.operation.QueryRequest) CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) ResultImpl(ddf.catalog.data.impl.ResultImpl) GetRecordByIdRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordByIdRequest) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Example 3 with GetRecordByIdRequest

use of org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordByIdRequest in project ddf by codice.

the class TestCswEndpoint method testGetRecordByIdWithNoId.

@Test(expected = CswException.class)
public void testGetRecordByIdWithNoId() throws CswException {
    final GetRecordByIdRequest getRecordByIdRequest = new GetRecordByIdRequest();
    getRecordByIdRequest.setOutputFormat(MediaType.APPLICATION_XML);
    getRecordByIdRequest.setOutputSchema(CswConstants.CSW_OUTPUT_SCHEMA);
    csw.getRecordById(getRecordByIdRequest, null);
}
Also used : GetRecordByIdRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordByIdRequest) Test(org.junit.Test)

Example 4 with GetRecordByIdRequest

use of org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordByIdRequest in project ddf by codice.

the class TestCswEndpoint method testRetrieveProductGetRecordByIdWithRange.

@Test
public void testRetrieveProductGetRecordByIdWithRange() throws IOException, ResourceNotFoundException, ResourceNotSupportedException, CswException {
    final GetRecordByIdRequest getRecordByIdRequest = new GetRecordByIdRequest();
    getRecordByIdRequest.setId("123");
    getRecordByIdRequest.setOutputFormat(MediaType.APPLICATION_OCTET_STREAM);
    getRecordByIdRequest.setOutputSchema(OCTET_STREAM_OUTPUT_SCHEMA);
    setUpMocksForProductRetrieval(true);
    CswRecordCollection cswRecordCollection = csw.getRecordById(getRecordByIdRequest, RANGE_VALUE);
    assertThat(cswRecordCollection.getResource(), is(notNullValue()));
}
Also used : CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) GetRecordByIdRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordByIdRequest) Test(org.junit.Test)

Example 5 with GetRecordByIdRequest

use of org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordByIdRequest in project ddf by codice.

the class TestCswEndpoint method testRetrieveProductGetRecordById.

@Test
public void testRetrieveProductGetRecordById() throws IOException, ResourceNotFoundException, ResourceNotSupportedException, CswException {
    final GetRecordByIdRequest getRecordByIdRequest = new GetRecordByIdRequest();
    getRecordByIdRequest.setId("123");
    getRecordByIdRequest.setOutputFormat(MediaType.APPLICATION_OCTET_STREAM);
    getRecordByIdRequest.setOutputSchema(OCTET_STREAM_OUTPUT_SCHEMA);
    setUpMocksForProductRetrieval(true);
    CswRecordCollection cswRecordCollection = csw.getRecordById(getRecordByIdRequest, null);
    assertThat(cswRecordCollection.getResource(), is(notNullValue()));
}
Also used : CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) GetRecordByIdRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordByIdRequest) Test(org.junit.Test)

Aggregations

GetRecordByIdRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordByIdRequest)6 Test (org.junit.Test)5 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)4 Metacard (ddf.catalog.data.Metacard)1 Result (ddf.catalog.data.Result)1 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 ResultImpl (ddf.catalog.data.impl.ResultImpl)1 QueryRequest (ddf.catalog.operation.QueryRequest)1 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)1 ResourceResponseImpl (ddf.catalog.operation.impl.ResourceResponseImpl)1 Resource (ddf.catalog.resource.Resource)1 ResourceNotFoundException (ddf.catalog.resource.ResourceNotFoundException)1 ResourceImpl (ddf.catalog.resource.impl.ResourceImpl)1 BufferedInputStream (java.io.BufferedInputStream)1 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 Csw (org.codice.ddf.spatial.ogc.csw.catalog.common.Csw)1 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)1