Search in sources :

Example 1 with PayloadHashingService

use of com.adaptris.core.services.metadata.PayloadHashingService in project interlok by adaptris.

the class JavaxValidationCheckerTest method createAdapterConfig.

private Adapter createAdapterConfig(boolean validates, boolean channels) throws Exception {
    Adapter adapter = new Adapter();
    if (validates) {
        // have a unique-id
        adapter.setUniqueId("MyAdapter");
        AddTimestampMetadataService ts = new AddTimestampMetadataService();
        ts.setUniqueId("valid-add-timestamp-service");
        PayloadHashingService ph = new PayloadHashingService();
        ph.setUniqueId("valid-payload-hasher");
        ph.setMetadataKey("payloadHash");
        ph.setHashAlgorithm("SHA-256");
        adapter.getSharedComponents().addService(ts);
        adapter.getSharedComponents().addService(ph);
    } else {
        // no adapter unique-id
        // explicitly set add timestamp to have an empty key, thankfully
        // no checks on the setter...
        AddTimestampMetadataService ts = new AddTimestampMetadataService();
        ts.setUniqueId("invalid-add-timestamp-service");
        ts.setMetadataKey("");
        // don't specify the hash algo or the metadata-key
        PayloadHashingService ph = new PayloadHashingService();
        ph.setUniqueId("invalid-payload-hasher");
        adapter.getSharedComponents().addService(ts);
        adapter.getSharedComponents().addService(ph);
    }
    if (channels) {
        Channel c = new Channel();
        c.setUniqueId("channel");
        StandardWorkflow w = new StandardWorkflow();
        w.setUniqueId("workflow");
        if (!validates) {
            PayloadHashingService ph = new PayloadHashingService();
            ph.setUniqueId("invalid-payload-hasher-2");
            w.getServiceCollection().add(ph);
        }
        c.getWorkflowList().add(w);
        adapter.getChannelList().add(c);
    }
    return adapter;
}
Also used : PayloadHashingService(com.adaptris.core.services.metadata.PayloadHashingService) StandardWorkflow(com.adaptris.core.StandardWorkflow) AddTimestampMetadataService(com.adaptris.core.services.metadata.AddTimestampMetadataService) Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter)

Aggregations

Adapter (com.adaptris.core.Adapter)1 Channel (com.adaptris.core.Channel)1 StandardWorkflow (com.adaptris.core.StandardWorkflow)1 AddTimestampMetadataService (com.adaptris.core.services.metadata.AddTimestampMetadataService)1 PayloadHashingService (com.adaptris.core.services.metadata.PayloadHashingService)1