use of biblemulticonverter.schema.zefdic1.ObjectFactory in project ddf by codice.
the class TestGetRecordsResponseConverter method testMarshalRecordCollectionGetBrief.
@Ignore
public void testMarshalRecordCollectionGetBrief() throws UnsupportedEncodingException, JAXBException {
final int totalResults = 5;
XStream xstream = createXStream(CswConstants.GET_RECORDS_RESPONSE);
GetRecordsType getRecords = new GetRecordsType();
QueryType query = new QueryType();
ElementSetNameType set = new ElementSetNameType();
set.setValue(ElementSetType.BRIEF);
query.setElementSetName(set);
ObjectFactory objectFactory = new ObjectFactory();
getRecords.setAbstractQuery(objectFactory.createAbstractQuery(query));
CswRecordCollection collection = createCswRecordCollection(getRecords, totalResults);
collection.setElementSetType(ElementSetType.BRIEF);
ArgumentCaptor<MarshallingContext> captor = ArgumentCaptor.forClass(MarshallingContext.class);
String xml = xstream.toXML(collection);
// Verify the context arguments were set correctly
verify(mockProvider, times(totalResults)).marshal(any(Object.class), any(HierarchicalStreamWriter.class), captor.capture());
MarshallingContext context = captor.getValue();
assertThat(context, not(nullValue()));
assertThat(context.get(CswConstants.OUTPUT_SCHEMA_PARAMETER), is(CswConstants.CSW_OUTPUT_SCHEMA));
assertThat(context.get(CswConstants.ELEMENT_SET_TYPE), is(ElementSetType.BRIEF));
JAXBElement<GetRecordsResponseType> jaxb = (JAXBElement<GetRecordsResponseType>) getJaxBContext().createUnmarshaller().unmarshal(new ByteArrayInputStream(xml.getBytes("UTF-8")));
GetRecordsResponseType response = jaxb.getValue();
// Assert the GetRecordsResponse elements and attributes
assertThat(response, not(nullValue()));
SearchResultsType resultsType = response.getSearchResults();
assertThat(resultsType, not(nullValue()));
assertThat(resultsType.getElementSet(), is(ElementSetType.BRIEF));
assertThat(resultsType.getNumberOfRecordsMatched().intValue(), is(totalResults));
assertThat(resultsType.getNumberOfRecordsReturned().intValue(), is(totalResults));
assertThat(resultsType.getRecordSchema(), is(CswConstants.CSW_OUTPUT_SCHEMA));
}
use of biblemulticonverter.schema.zefdic1.ObjectFactory in project ddf by codice.
the class TestGetRecordsResponseConverter method testMarshalRecordCollectionGetFull.
@Ignore
public void testMarshalRecordCollectionGetFull() throws UnsupportedEncodingException, JAXBException {
final int totalResults = 5;
XStream xstream = createXStream(CswConstants.GET_RECORDS_RESPONSE);
GetRecordsType getRecords = new GetRecordsType();
QueryType query = new QueryType();
ElementSetNameType set = new ElementSetNameType();
set.setValue(ElementSetType.FULL);
query.setElementSetName(set);
ObjectFactory objectFactory = new ObjectFactory();
getRecords.setAbstractQuery(objectFactory.createAbstractQuery(query));
CswRecordCollection collection = createCswRecordCollection(getRecords, totalResults);
collection.setElementSetType(ElementSetType.FULL);
ArgumentCaptor<MarshallingContext> captor = ArgumentCaptor.forClass(MarshallingContext.class);
String xml = xstream.toXML(collection);
// Verify the context arguments were set correctly
verify(mockProvider, times(totalResults)).marshal(any(Object.class), any(HierarchicalStreamWriter.class), captor.capture());
MarshallingContext context = captor.getValue();
assertThat(context, not(nullValue()));
assertThat(context.get(CswConstants.OUTPUT_SCHEMA_PARAMETER), is(CswConstants.CSW_OUTPUT_SCHEMA));
assertThat(context.get(CswConstants.ELEMENT_SET_TYPE), is(ElementSetType.FULL));
JAXBElement<GetRecordsResponseType> jaxb = (JAXBElement<GetRecordsResponseType>) getJaxBContext().createUnmarshaller().unmarshal(new ByteArrayInputStream(xml.getBytes("UTF-8")));
GetRecordsResponseType response = jaxb.getValue();
// Assert the GetRecordsResponse elements and attributes
assertThat(response, not(nullValue()));
SearchResultsType resultsType = response.getSearchResults();
assertThat(resultsType, not(nullValue()));
assertThat(resultsType.getElementSet(), is(ElementSetType.FULL));
assertThat(resultsType.getNumberOfRecordsMatched().intValue(), is(totalResults));
assertThat(resultsType.getNumberOfRecordsReturned().intValue(), is(totalResults));
assertThat(resultsType.getRecordSchema(), is(CswConstants.CSW_OUTPUT_SCHEMA));
}
use of biblemulticonverter.schema.zefdic1.ObjectFactory in project ddf by codice.
the class WfsFilterDelegate method createFeatureIdFilter.
private JAXBElement<ResourceIdType> createFeatureIdFilter(final String id) {
ResourceIdType resId = new ResourceIdType();
resId.setRid(id);
ObjectFactory objFact = new ObjectFactory();
return objFact.createResourceId(resId);
}
use of biblemulticonverter.schema.zefdic1.ObjectFactory in project ddf by codice.
the class SendEventTest method setUp.
@Before
public void setUp() throws Exception {
System.setProperty("ddf.home", ".");
callbackURI = new URL("https://localhost:12345/services/csw/subscription/event");
ObjectFactory objectFactory = new ObjectFactory();
request = new GetRecordsType();
request.setOutputSchema(CswConstants.CSW_OUTPUT_SCHEMA);
request.setResultType(ResultType.RESULTS);
request.getResponseHandler().add(callbackURI.toString());
queryType = new QueryType();
elementSetNameType = new ElementSetNameType();
elementSetNameType.setValue(ElementSetType.BRIEF);
queryType.setElementSetName(elementSetNameType);
request.setAbstractQuery(objectFactory.createAbstractQuery(queryType));
transformerManager = mock(TransformerManager.class);
transformer = mock(QueryResponseTransformer.class);
binaryContent = mock(BinaryContent.class);
when(transformerManager.getTransformerBySchema(Matchers.contains(CswConstants.CSW_OUTPUT_SCHEMA))).thenReturn(transformer);
when(transformer.transform(any(SourceResponse.class), anyMap())).thenReturn(binaryContent);
when(binaryContent.getByteArray()).thenReturn("byte array with message contents".getBytes());
query = mock(QueryRequest.class);
metacard = mock(Metacard.class);
webclient = mock(WebClient.class);
mockCxfClientFactory = mock(SecureCxfClientFactory.class);
response = mock(Response.class);
subject = mock(Subject.class);
mockSecurity = mock(Security.class);
headers.put(Subject.class.toString(), Arrays.asList(new Subject[] { subject }));
AccessPlugin accessPlugin = mock(AccessPlugin.class);
accessPlugins.add(accessPlugin);
when(mockCxfClientFactory.getWebClient()).thenReturn(webclient);
when(webclient.invoke(anyString(), any(QueryResponse.class))).thenReturn(response);
when(response.getHeaders()).thenReturn(headers);
when(accessPlugin.processPostQuery(any(QueryResponse.class))).thenAnswer(invocationOnMock -> invocationOnMock.getArguments()[0]);
sendEvent = new SendEventExtension(transformerManager, request, query, mockCxfClientFactory);
sendEvent.setSubject(subject);
}
use of biblemulticonverter.schema.zefdic1.ObjectFactory in project ddf by codice.
the class AbstractCswSource method createSubscriptionGetRecordsRequest.
private GetRecordsType createSubscriptionGetRecordsRequest() {
GetRecordsType getRecordsType = new GetRecordsType();
getRecordsType.setVersion(cswVersion);
getRecordsType.setService(CswConstants.CSW);
getRecordsType.setResultType(ResultType.RESULTS);
getRecordsType.setStartPosition(BigInteger.ONE);
getRecordsType.setMaxRecords(BigInteger.TEN);
getRecordsType.setOutputFormat(MediaType.APPLICATION_XML);
getRecordsType.setOutputSchema("urn:catalog:metacard");
getRecordsType.getResponseHandler().add(SystemBaseUrl.constructUrl("csw/subscription/event", true));
QueryType queryType = new QueryType();
queryType.setElementSetName(createElementSetName(ElementSetType.FULL));
ObjectFactory objectFactory = new ObjectFactory();
getRecordsType.setAbstractQuery(objectFactory.createQuery(queryType));
return getRecordsType;
}
Aggregations