Cook { @Aggregator public Meal prepareMeal(List<Message<Product>> products) { Recipe recipe = (Recipe) products.get(0).getHeaders().get("recipe"); Meal meal = new Meal(recipe); for (Message<Product> message : products) { meal.cook(message.getPayload()); } return meal; }  @Aggregator Meal prepareMeal(List<Message<Product>> products); @CorrelationStrategy Object correlatingRecipeFor(Message<Product> message); @ReleaseStrategy boolean canCookMeal(List<Message<?>> products);  }
@Test public void shouldPrepareMeal() throws Exception { List<Message<Product>> messages = Collections.<Message<Product>>singletonList( wrapInMessage(mock(Product.class))); assertThat(cook.prepareMeal(messages).getRecipe(), is(recipe)); }
@Test public void shouldCookAllProducts() { Grocery grocery = mock(Grocery.class); Meat meat = mock(Meat.class); List<Message<Product>> products = Arrays.asList(wrapInMessage(grocery), wrapInMessage(meat)); Meal meal = cook.prepareMeal(products); DirectFieldAccessor accessor = new DirectFieldAccessor(meal); assertThat((List<Product>)accessor.getPropertyValue("products"), hasItems(grocery, meat)); }