Search in sources :

Example 6 with GetRecordByIdType

use of net.opengis.cat.csw.v_2_0_2.GetRecordByIdType in project ddf by codice.

the class TestCswEndpoint method testPostRetrieveProductGetRecordByIdWithMultiIds.

@Test(expected = CswException.class)
public void testPostRetrieveProductGetRecordByIdWithMultiIds() throws CswException, FederationException, SourceUnavailableException, UnsupportedQueryException, ResourceNotFoundException, IOException, ResourceNotSupportedException {
    final GetRecordByIdType getRecordByIdType = new GetRecordByIdType();
    getRecordByIdType.setOutputFormat(MediaType.APPLICATION_OCTET_STREAM);
    getRecordByIdType.setOutputSchema(OCTET_STREAM_OUTPUT_SCHEMA);
    getRecordByIdType.setId(Arrays.asList("123", "124"));
    csw.getRecordById(getRecordByIdType, null);
}
Also used : GetRecordByIdType(net.opengis.cat.csw.v_2_0_2.GetRecordByIdType) Test(org.junit.Test)

Example 7 with GetRecordByIdType

use of net.opengis.cat.csw.v_2_0_2.GetRecordByIdType in project ddf by codice.

the class CswEndpointTest method testPostRetrieveProductGetRecordById.

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

Example 8 with GetRecordByIdType

use of net.opengis.cat.csw.v_2_0_2.GetRecordByIdType in project ddf by codice.

the class CswEndpointTest method testPostRetrieveProductGetRecordByIdIncorrectOutputFormat.

@Test(expected = CswException.class)
public void testPostRetrieveProductGetRecordByIdIncorrectOutputFormat() throws CswException, FederationException, SourceUnavailableException, UnsupportedQueryException, ResourceNotFoundException, IOException, ResourceNotSupportedException {
    final GetRecordByIdType getRecordByIdType = new GetRecordByIdType();
    getRecordByIdType.setOutputFormat(MediaType.APPLICATION_XML);
    getRecordByIdType.setOutputSchema(OCTET_STREAM_OUTPUT_SCHEMA);
    getRecordByIdType.setId(Collections.singletonList("123"));
    csw.getRecordById(getRecordByIdType, null);
}
Also used : GetRecordByIdType(net.opengis.cat.csw.v_2_0_2.GetRecordByIdType) Test(org.junit.Test)

Example 9 with GetRecordByIdType

use of net.opengis.cat.csw.v_2_0_2.GetRecordByIdType in project ddf by codice.

the class CswEndpointTest method testPostGetRecordByWithIdNoId.

@Test(expected = CswException.class)
public void testPostGetRecordByWithIdNoId() throws CswException {
    final GetRecordByIdType getRecordByIdType = new GetRecordByIdType();
    getRecordByIdType.setOutputFormat(MediaType.APPLICATION_XML);
    getRecordByIdType.setOutputSchema(CswConstants.CSW_OUTPUT_SCHEMA);
    csw.getRecordById(getRecordByIdType, null);
}
Also used : GetRecordByIdType(net.opengis.cat.csw.v_2_0_2.GetRecordByIdType) Test(org.junit.Test)

Example 10 with GetRecordByIdType

use of net.opengis.cat.csw.v_2_0_2.GetRecordByIdType in project ddf by codice.

the class CswEndpointTest method testPostGetRecordById.

@Test
public void testPostGetRecordById() throws CswException, FederationException, SourceUnavailableException, UnsupportedQueryException {
    final GetRecordByIdType getRecordByIdType = new GetRecordByIdType();
    getRecordByIdType.setId(Collections.singletonList("123,456"));
    getRecordByIdType.setOutputFormat(MediaType.APPLICATION_XML);
    getRecordByIdType.setOutputSchema(CswConstants.CSW_OUTPUT_SCHEMA);
    final Metacard metacard1 = new MetacardImpl();
    final Metacard metacard2 = new MetacardImpl();
    final List<Result> mockResults = Arrays.asList(new ResultImpl(metacard1), new ResultImpl(metacard2));
    final QueryResponse queryResponse = new QueryResponseImpl(null, mockResults, mockResults.size());
    doReturn(queryResponse).when(catalogFramework).query(any(QueryRequest.class));
    final CswRecordCollection cswRecordCollection = csw.getRecordById(getRecordByIdType, null);
    verifyCswRecordCollection(cswRecordCollection, metacard1, metacard2);
    // "summary" is the default if none is specified in the request.
    assertThat(cswRecordCollection.getElementSetType(), is(ElementSetType.SUMMARY));
}
Also used : Metacard(ddf.catalog.data.Metacard) QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) QueryRequest(ddf.catalog.operation.QueryRequest) QueryResponse(ddf.catalog.operation.QueryResponse) CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) ResultImpl(ddf.catalog.data.impl.ResultImpl) GetRecordByIdType(net.opengis.cat.csw.v_2_0_2.GetRecordByIdType) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Result(ddf.catalog.data.Result) Test(org.junit.Test)

Aggregations

GetRecordByIdType (net.opengis.cat.csw.v_2_0_2.GetRecordByIdType)20 Test (org.junit.Test)20 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)8 Metacard (ddf.catalog.data.Metacard)2 Result (ddf.catalog.data.Result)2 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)2 ResultImpl (ddf.catalog.data.impl.ResultImpl)2 QueryRequest (ddf.catalog.operation.QueryRequest)2 QueryResponse (ddf.catalog.operation.QueryResponse)2 ResourceRequest (ddf.catalog.operation.ResourceRequest)2 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)2