use of org.apache.camel.component.salesforce.api.dto.AnnotationFieldKeySorter in project camel by apache.
the class DefaultCompositeApiClient method configureXStream.
static XStream configureXStream() {
final PureJavaReflectionProvider reflectionProvider = new PureJavaReflectionProvider(new FieldDictionary(new AnnotationFieldKeySorter()));
final XppDriver hierarchicalStreamDriver = new XppDriver(new NoNameCoder()) {
@Override
public HierarchicalStreamWriter createWriter(final Writer out) {
return new CompactWriter(out, getNameCoder());
}
};
final XStream xStream = new XStream(reflectionProvider, hierarchicalStreamDriver);
xStream.aliasSystemAttribute(null, "class");
xStream.ignoreUnknownElements();
XStreamUtils.addDefaultPermissions(xStream);
xStream.registerConverter(new DateTimeConverter());
xStream.setMarshallingStrategy(new TreeMarshallingStrategy());
xStream.processAnnotations(ADDITIONAL_TYPES);
return xStream;
}
use of org.apache.camel.component.salesforce.api.dto.AnnotationFieldKeySorter in project camel by apache.
the class SObjectBatchTest method shouldSerializeToXml.
@Test
public void shouldSerializeToXml() {
final String xml = //
"<batch>\n" + //
" <batchRequests>\n" + //
" <batchRequest>\n" + //
" <method>POST</method>\n" + //
" <url>v37.0/sobjects/Account/</url>\n" + //
" <richInput>\n" + //
" <Account>\n" + //
" <Name>NewAccountName</Name>\n" + //
" <Industry>Environmental</Industry>\n" + //
" </Account>\n" + //
" </richInput>\n" + //
" </batchRequest>\n" + //
" <batchRequest>\n" + //
" <method>DELETE</method>\n" + //
" <url>v37.0/sobjects/Account/001D000000K0fXOIAZ</url>\n" + //
" </batchRequest>\n" + //
" <batchRequest>\n" + //
" <method>GET</method>\n" + //
" <url>v37.0/sobjects/Account/001D000000K0fXOIAZ?fields=Name,BillingPostalCode</url>\n" + //
" </batchRequest>\n" + //
" <batchRequest>\n" + //
" <method>GET</method>\n" + //
" <url>v37.0/sobjects/Account/EPK/12345</url>\n" + //
" </batchRequest>\n" + //
" <batchRequest>\n" + //
" <method>GET</method>\n" + //
" <url>v37.0/sobjects/Account/001D000000K0fXOIAZ/CreatedBy?fields=Name</url>\n" + //
" </batchRequest>\n" + //
" <batchRequest>\n" + //
" <method>GET</method>\n" + //
" <url>v37.0/limits/</url>\n" + //
" </batchRequest>\n" + //
" <batchRequest>\n" + //
" <method>PATCH</method>\n" + //
" <url>v37.0/sobjects/Account/001D000000K0fXOIAZ</url>\n" + //
" <richInput>\n" + //
" <Account>\n" + //
" <Name>NewName</Name>\n" + //
" <AccountNumber>AC12345</AccountNumber>\n" + //
" </Account>\n" + //
" </richInput>\n" + //
" </batchRequest>\n" + //
" <batchRequest>\n" + //
" <method>PATCH</method>\n" + //
" <url>v37.0/sobjects/Account/EPK/12345</url>\n" + //
" <richInput>\n" + //
" <Account>\n" + //
" <Name>NewName</Name>\n" + //
" </Account>\n" + //
" </richInput>\n" + //
" </batchRequest>\n" + //
" <batchRequest>\n" + //
" <method>PATCH</method>\n" + //
" <url>v37.0/sobjects/Account/EPK/12345</url>\n" + //
" <richInput>\n" + //
" <Account>\n" + //
" <Name>NewName</Name>\n" + //
" </Account>\n" + //
" </richInput>\n" + //
" </batchRequest>\n" + //
" <batchRequest>\n" + //
" <method>PATCH</method>\n" + //
" <url>v37.0/some/url</url>\n" + //
" </batchRequest>\n" + //
" <batchRequest>\n" + //
" <method>GET</method>\n" + //
" <url>v37.0/query/?q=SELECT Name FROM Account</url>\n" + //
" </batchRequest>\n" + //
" <batchRequest>\n" + //
" <method>GET</method>\n" + //
" <url>v37.0/queryAll/?q=SELECT Name FROM Account</url>\n" + //
" </batchRequest>\n" + //
" <batchRequest>\n" + //
" <method>GET</method>\n" + //
" <url>v37.0/search/?q=FIND {joe}</url>\n" + //
" </batchRequest>\n" + //
" </batchRequests>\n" + "</batch>";
final PureJavaReflectionProvider reflectionProvider = new PureJavaReflectionProvider(new FieldDictionary(new AnnotationFieldKeySorter()));
final XStream xStream = new XStream(reflectionProvider);
xStream.aliasSystemAttribute(null, "class");
xStream.processAnnotations(SObjectBatch.class);
xStream.processAnnotations(batch.objectTypes());
final String serialized = xStream.toXML(batch);
assertEquals("Should serialize as expected by Salesforce", xml, serialized);
}
Aggregations