use of net.opengis.cat.csw.v_2_0_2.AcknowledgementType in project ddf by codice.
the class TestCswQueryResponseTransformer method testMarshalAcknowledgement.
@Test
public void testMarshalAcknowledgement() throws WebApplicationException, IOException, JAXBException, CatalogTransformerException {
GetRecordsType query = new GetRecordsType();
query.setResultType(ResultType.VALIDATE);
query.setMaxRecords(BigInteger.valueOf(6));
query.setStartPosition(BigInteger.valueOf(4));
SourceResponse sourceResponse = createSourceResponse(query, 22);
Map<String, Serializable> args = new HashMap<>();
args.put(CswConstants.RESULT_TYPE_PARAMETER, ResultType.VALIDATE);
args.put(CswConstants.GET_RECORDS, query);
BinaryContent content = transformer.transform(sourceResponse, args);
String xml = new String(content.getByteArray());
JAXBElement<?> jaxb = (JAXBElement<?>) getJaxBContext().createUnmarshaller().unmarshal(new ByteArrayInputStream(xml.getBytes("UTF-8")));
assertThat(jaxb.getValue(), is(instanceOf(AcknowledgementType.class)));
AcknowledgementType response = (AcknowledgementType) jaxb.getValue();
assertThat(response.getEchoedRequest().getAny(), is(instanceOf(JAXBElement.class)));
JAXBElement<?> jaxB = (JAXBElement<?>) response.getEchoedRequest().getAny();
assertThat(jaxB.getValue(), is(instanceOf(GetRecordsType.class)));
}
use of net.opengis.cat.csw.v_2_0_2.AcknowledgementType in project ddf by codice.
the class TestCswSource method testRefreshWithRegisterForEvents.
@Test
public void testRefreshWithRegisterForEvents() throws Exception {
String subscriptionId = "subscriptionid";
String eventEndpoint = "https://ddf/services/csw/subscriptions";
CswSourceStub cswSource = (CswSourceStub) getCswSource(mockCsw, mockContext, "contentType");
CswSubscribe client = mock(CswSubscribe.class);
Response response = mock(Response.class);
AcknowledgementType ack = mock(AcknowledgementType.class);
when(client.createRecordsSubscription(any(GetRecordsType.class))).thenReturn(response);
when(response.getStatus()).thenReturn(200);
when(response.readEntity(any(Class.class))).thenReturn(ack);
when(ack.getRequestId()).thenReturn(subscriptionId);
when(cswSource.getSubscriberClientFactory().getClientForSubject(cswSource.getSubject())).thenReturn(client);
// Set Configuration Map
Map<String, Object> configuration = getConfigurationMap(cswSource);
configuration.put(cswSource.REGISTER_FOR_EVENTS, true);
configuration.put(cswSource.EVENT_SERVICE_ADDRESS, eventEndpoint);
// Call Refresh
cswSource.refresh(configuration);
// Get Configuration
CswSourceConfiguration cswSourceConfiguration = cswSource.cswSourceConfiguration;
// Assert Refresh Changes
Assert.assertTrue(cswSourceConfiguration.isRegisterForEvents());
Assert.assertEquals(cswSourceConfiguration.getEventServiceAddress(), eventEndpoint);
verify(ack).getRequestId();
}
use of net.opengis.cat.csw.v_2_0_2.AcknowledgementType 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));
}
use of net.opengis.cat.csw.v_2_0_2.AcknowledgementType in project ddf by codice.
the class CswSubscriptionEndpointTest method testGetRecordsSubscription.
@Test
public void testGetRecordsSubscription() throws Exception {
cswSubscriptionEndpoint.addOrUpdateSubscription(defaultRequest.get202RecordsType(), true);
Response response = cswSubscriptionEndpoint.getRecordsSubscription(subscriptionId);
AcknowledgementType getAck = (AcknowledgementType) response.getEntity();
assertThat(defaultRequest.get202RecordsType(), is(((JAXBElement<GetRecordsType>) getAck.getEchoedRequest().getAny()).getValue()));
verify(mockContext).getService(eq(subscriptionReference));
}
use of net.opengis.cat.csw.v_2_0_2.AcknowledgementType in project ddf by codice.
the class CswSourceTest method testRefreshWithRegisterForEvents.
@Test
public void testRefreshWithRegisterForEvents() throws Exception {
String subscriptionId = "subscriptionid";
String eventEndpoint = "https://ddf/services/csw/subscriptions";
CswSourceStub cswSource = (CswSourceStub) getCswSource(mockCsw, mockContext, "contentType");
CswSubscribe client = mock(CswSubscribe.class);
Response response = mock(Response.class);
AcknowledgementType ack = mock(AcknowledgementType.class);
when(client.createRecordsSubscription(any(GetRecordsType.class))).thenReturn(response);
when(response.getStatus()).thenReturn(200);
when(response.readEntity(any(Class.class))).thenReturn(ack);
when(ack.getRequestId()).thenReturn(subscriptionId);
when(cswSource.getSubscriberClientFactory().getClientForSubject(cswSource.getSubject())).thenReturn(client);
when(cswSource.getSubscriberClientFactory().getClientForSystemSubject(cswSource.getSubject())).thenReturn(client);
// Set Configuration Map
Map<String, Object> configuration = getConfigurationMap(cswSource);
configuration.put(cswSource.REGISTER_FOR_EVENTS, true);
configuration.put(cswSource.EVENT_SERVICE_ADDRESS, eventEndpoint);
// Call Refresh
cswSource.refresh(configuration);
// Get Configuration
CswSourceConfiguration cswSourceConfiguration = cswSource.cswSourceConfiguration;
// Assert Refresh Changes
Assert.assertTrue(cswSourceConfiguration.isRegisterForEvents());
Assert.assertEquals(cswSourceConfiguration.getEventServiceAddress(), eventEndpoint);
verify(ack).getRequestId();
}
Aggregations