Search in sources :

Example 1 with ClaimCheckOutTransformer

use of org.springframework.integration.transformer.ClaimCheckOutTransformer in project spring-integration by spring-projects.

the class ClaimCheckParserTests method checkMessageStoreReferenceOnCheckOut.

@Test
public void checkMessageStoreReferenceOnCheckOut() {
    ClaimCheckOutTransformer transformer = (ClaimCheckOutTransformer) new DirectFieldAccessor(new DirectFieldAccessor(checkout).getPropertyValue("handler")).getPropertyValue("transformer");
    MessageStore messageStore = (MessageStore) new DirectFieldAccessor(transformer).getPropertyValue("messageStore");
    assertEquals(context.getBean("testMessageStore"), messageStore);
}
Also used : MessageStore(org.springframework.integration.store.MessageStore) ClaimCheckOutTransformer(org.springframework.integration.transformer.ClaimCheckOutTransformer) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 2 with ClaimCheckOutTransformer

use of org.springframework.integration.transformer.ClaimCheckOutTransformer in project spring-integration by spring-projects.

the class MongoDbMessageStoreClaimCheckIntegrationTests method stringPayload.

@Test
@MongoDbAvailable
public void stringPayload() throws Exception {
    MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new MongoClient(), "test");
    MongoDbMessageStore messageStore = new MongoDbMessageStore(mongoDbFactory);
    messageStore.afterPropertiesSet();
    ClaimCheckInTransformer checkin = new ClaimCheckInTransformer(messageStore);
    ClaimCheckOutTransformer checkout = new ClaimCheckOutTransformer(messageStore);
    Message<?> originalMessage = MessageBuilder.withPayload("test1").build();
    Message<?> claimCheckMessage = checkin.transform(originalMessage);
    assertEquals(originalMessage.getHeaders().getId(), claimCheckMessage.getPayload());
    Message<?> checkedOutMessage = checkout.transform(claimCheckMessage);
    assertEquals(claimCheckMessage.getPayload(), checkedOutMessage.getHeaders().getId());
    assertEquals(originalMessage.getPayload(), checkedOutMessage.getPayload());
    assertEquals(originalMessage, checkedOutMessage);
}
Also used : MongoClient(com.mongodb.MongoClient) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) MongoDbFactory(org.springframework.data.mongodb.MongoDbFactory) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) ClaimCheckInTransformer(org.springframework.integration.transformer.ClaimCheckInTransformer) ClaimCheckOutTransformer(org.springframework.integration.transformer.ClaimCheckOutTransformer) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Example 3 with ClaimCheckOutTransformer

use of org.springframework.integration.transformer.ClaimCheckOutTransformer in project spring-integration by spring-projects.

the class MongoDbMessageStoreClaimCheckIntegrationTests method objectPayloadConfigurable.

@Test
@MongoDbAvailable
public void objectPayloadConfigurable() throws Exception {
    MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new MongoClient(), "test");
    ConfigurableMongoDbMessageStore messageStore = new ConfigurableMongoDbMessageStore(mongoDbFactory);
    GenericApplicationContext testApplicationContext = TestUtils.createTestApplicationContext();
    testApplicationContext.refresh();
    messageStore.setApplicationContext(testApplicationContext);
    messageStore.afterPropertiesSet();
    ClaimCheckInTransformer checkin = new ClaimCheckInTransformer(messageStore);
    ClaimCheckOutTransformer checkout = new ClaimCheckOutTransformer(messageStore);
    Beverage payload = new Beverage();
    payload.setName("latte");
    payload.setShots(3);
    payload.setIced(false);
    Message<?> originalMessage = MessageBuilder.withPayload(payload).build();
    Message<?> claimCheckMessage = checkin.transform(originalMessage);
    assertEquals(originalMessage.getHeaders().getId(), claimCheckMessage.getPayload());
    Message<?> checkedOutMessage = checkout.transform(claimCheckMessage);
    assertEquals(originalMessage.getPayload(), checkedOutMessage.getPayload());
    assertEquals(claimCheckMessage.getPayload(), checkedOutMessage.getHeaders().getId());
    assertEquals(originalMessage, checkedOutMessage);
}
Also used : MongoClient(com.mongodb.MongoClient) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) MongoDbFactory(org.springframework.data.mongodb.MongoDbFactory) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) ClaimCheckInTransformer(org.springframework.integration.transformer.ClaimCheckInTransformer) ClaimCheckOutTransformer(org.springframework.integration.transformer.ClaimCheckOutTransformer) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Example 4 with ClaimCheckOutTransformer

use of org.springframework.integration.transformer.ClaimCheckOutTransformer in project spring-integration by spring-projects.

the class MongoDbMessageStoreClaimCheckIntegrationTests method objectPayload.

@Test
@MongoDbAvailable
public void objectPayload() throws Exception {
    MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new MongoClient(), "test");
    MongoDbMessageStore messageStore = new MongoDbMessageStore(mongoDbFactory);
    messageStore.afterPropertiesSet();
    ClaimCheckInTransformer checkin = new ClaimCheckInTransformer(messageStore);
    ClaimCheckOutTransformer checkout = new ClaimCheckOutTransformer(messageStore);
    Beverage payload = new Beverage();
    payload.setName("latte");
    payload.setShots(3);
    payload.setIced(false);
    Message<?> originalMessage = MessageBuilder.withPayload(payload).build();
    Message<?> claimCheckMessage = checkin.transform(originalMessage);
    assertEquals(originalMessage.getHeaders().getId(), claimCheckMessage.getPayload());
    Message<?> checkedOutMessage = checkout.transform(claimCheckMessage);
    assertEquals(originalMessage.getPayload(), checkedOutMessage.getPayload());
    assertEquals(claimCheckMessage.getPayload(), checkedOutMessage.getHeaders().getId());
    assertEquals(originalMessage, checkedOutMessage);
}
Also used : MongoClient(com.mongodb.MongoClient) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) MongoDbFactory(org.springframework.data.mongodb.MongoDbFactory) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) ClaimCheckInTransformer(org.springframework.integration.transformer.ClaimCheckInTransformer) ClaimCheckOutTransformer(org.springframework.integration.transformer.ClaimCheckOutTransformer) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Example 5 with ClaimCheckOutTransformer

use of org.springframework.integration.transformer.ClaimCheckOutTransformer in project spring-integration by spring-projects.

the class IntegrationFlowDefinition method claimCheckOut.

/**
 * Populate the {@link MessageTransformingHandler} for the {@link ClaimCheckOutTransformer}
 * with provided {@link MessageStore} and {@code removeMessage} flag.
 * In addition accept options for the integration endpoint using {@link GenericEndpointSpec}.
 * @param messageStore the {@link MessageStore} to use.
 * @param removeMessage the removeMessage boolean flag.
 * @param endpointConfigurer the {@link Consumer} to provide integration endpoint options.
 * @return the current {@link IntegrationFlowDefinition}.
 * @see GenericEndpointSpec
 * @see ClaimCheckOutTransformer#setRemoveMessage(boolean)
 */
public B claimCheckOut(MessageStore messageStore, boolean removeMessage, Consumer<GenericEndpointSpec<MessageTransformingHandler>> endpointConfigurer) {
    ClaimCheckOutTransformer claimCheckOutTransformer = new ClaimCheckOutTransformer(messageStore);
    claimCheckOutTransformer.setRemoveMessage(removeMessage);
    return this.transform(claimCheckOutTransformer, endpointConfigurer);
}
Also used : ClaimCheckOutTransformer(org.springframework.integration.transformer.ClaimCheckOutTransformer)

Aggregations

ClaimCheckOutTransformer (org.springframework.integration.transformer.ClaimCheckOutTransformer)6 Test (org.junit.Test)5 MongoClient (com.mongodb.MongoClient)4 MongoDbFactory (org.springframework.data.mongodb.MongoDbFactory)4 SimpleMongoDbFactory (org.springframework.data.mongodb.core.SimpleMongoDbFactory)4 MongoDbAvailable (org.springframework.integration.mongodb.rules.MongoDbAvailable)4 ClaimCheckInTransformer (org.springframework.integration.transformer.ClaimCheckInTransformer)4 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)2 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 MessageStore (org.springframework.integration.store.MessageStore)1