Search in sources :

Example 1 with GetRecordsRequest

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

the class CswSubscriptionEndpointTest method testUpdateRecordsSubscription.

@Test
public void testUpdateRecordsSubscription() throws Exception {
    GetRecordsRequest getRecordsRequest = createDefaultGetRecordsRequest();
    getRecordsRequest.setResponseHandler(RESPONSE_HANDLER_URL);
    Response response = cswSubscriptionEndpoint.createRecordsSubscription(getRecordsRequest);
    AcknowledgementType createAck = (AcknowledgementType) response.getEntity();
    getRecordsRequest = createDefaultGetRecordsRequest();
    getRecordsRequest.setResponseHandler(RESPONSE_HANDLER_URL);
    getRecordsRequest.setResultType(ResultType.HITS.value());
    response = cswSubscriptionEndpoint.updateRecordsSubscription(createAck.getRequestId(), getRecordsRequest.get202RecordsType());
    AcknowledgementType updateAck = (AcknowledgementType) response.getEntity();
    assertThat(((GetRecordsType) ((JAXBElement) updateAck.getEchoedRequest().getAny()).getValue()).getResultType(), is(ResultType.HITS));
    verify(serviceRegistration).unregister();
    verify(config).delete();
    verify(mockContext, times(2)).registerService(eq(Subscription.class.getName()), any(Subscription.class), any(Dictionary.class));
}
Also used : Response(javax.ws.rs.core.Response) Dictionary(java.util.Dictionary) JAXBElement(javax.xml.bind.JAXBElement) Subscription(ddf.catalog.event.Subscription) CswSubscription(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.event.CswSubscription) AcknowledgementType(net.opengis.cat.csw.v_2_0_2.AcknowledgementType) GetRecordsRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordsRequest) Test(org.junit.Test)

Example 2 with GetRecordsRequest

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

the class CswSubscriptionEndpointTest method testCreateRecordsSubscriptionPOSTBadResponseHandler.

@Test(expected = CswException.class)
public void testCreateRecordsSubscriptionPOSTBadResponseHandler() throws CswException {
    GetRecordsRequest getRecordsRequest = createDefaultGetRecordsRequest();
    getRecordsRequest.setResponseHandler("[]@!$&'()*+,;=");
    cswSubscriptionEndpoint.createRecordsSubscription(getRecordsRequest.get202RecordsType());
}
Also used : GetRecordsRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordsRequest) Test(org.junit.Test)

Example 3 with GetRecordsRequest

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

the class CswSubscriptionEndpointTest method testCreateRecordsSubscriptionPOSTwithoutResponseHandler.

@Test(expected = CswException.class)
public void testCreateRecordsSubscriptionPOSTwithoutResponseHandler() throws Exception {
    GetRecordsRequest getRecordsRequest = createDefaultGetRecordsRequest();
    getRecordsRequest.setResponseHandler(null);
    cswSubscriptionEndpoint.createRecordsSubscription(getRecordsRequest.get202RecordsType());
}
Also used : GetRecordsRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordsRequest) Test(org.junit.Test)

Example 4 with GetRecordsRequest

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

the class CswSubscriptionEndpointTest method createDefaultGetRecordsRequest.

private GetRecordsRequest createDefaultGetRecordsRequest() {
    GetRecordsRequest grr = new GetRecordsRequest();
    grr.setRequestId(subscriptionId);
    grr.setResponseHandler(RESPONSE_HANDLER_URL);
    grr.setService(CswConstants.CSW);
    grr.setVersion(CswConstants.VERSION_2_0_2);
    grr.setRequest(CswConstants.GET_RECORDS);
    grr.setNamespace(CswConstants.XMLNS_DEFINITION_PREFIX + CswConstants.CSW_NAMESPACE_PREFIX + CswConstants.EQUALS + CswConstants.CSW_OUTPUT_SCHEMA + CswConstants.XMLNS_DEFINITION_POSTFIX + CswConstants.COMMA + CswConstants.XMLNS_DEFINITION_PREFIX + CswConstants.OGC_NAMESPACE_PREFIX + CswConstants.EQUALS + CswConstants.OGC_SCHEMA + CswConstants.XMLNS_DEFINITION_POSTFIX + CswConstants.COMMA + CswConstants.XMLNS_DEFINITION_PREFIX + CswConstants.GML_NAMESPACE_PREFIX + CswConstants.EQUALS + CswConstants.GML_SCHEMA + CswConstants.XMLNS_DEFINITION_POSTFIX + CswConstants.COMMA);
    grr.setOutputSchema(CswConstants.CSW_OUTPUT_SCHEMA);
    grr.setOutputFormat(CswConstants.OUTPUT_FORMAT_XML);
    grr.setTypeNames(VALID_TYPES);
    return grr;
}
Also used : GetRecordsRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordsRequest)

Example 5 with GetRecordsRequest

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

the class TestCswEndpoint method testGetRecordsValidInput.

@Test
public void testGetRecordsValidInput() throws CswException {
    GetRecordsRequest grr = createDefaultGetRecordsRequest();
    csw.getRecords(grr);
}
Also used : GetRecordsRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordsRequest) Test(org.junit.Test)

Aggregations

GetRecordsRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.GetRecordsRequest)13 Test (org.junit.Test)9 Subscription (ddf.catalog.event.Subscription)3 Dictionary (java.util.Dictionary)3 Response (javax.ws.rs.core.Response)3 AcknowledgementType (net.opengis.cat.csw.v_2_0_2.AcknowledgementType)3 CswSubscription (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.event.CswSubscription)3 QueryImpl (ddf.catalog.operation.impl.QueryImpl)1 JAXBElement (javax.xml.bind.JAXBElement)1