muleContext.getRegistry().registerObject("redApple", redApple);
muleContext.getRegistry().registerObject("anotherRedApple", new RedApple());
muleContext.getRegistry().registerObject("aBanana", new Banana());
InvocationResult response = invokeResolver("listFruit", eventContext);
assertTrue("Message payload should be a List", response.getResult() instanceof List);
List<Fruit> result = (List<Fruit>) response.getResult();
assertEquals(2, result.size());
assertEquals(redApple, result.get(1));
//Add optional Orange
muleContext.getRegistry().registerObject("orange", new Orange());
response = invokeResolver("listFruit", eventContext);
assertTrue("Message payload should be a List", response.getResult() instanceof List);
result = (List<Fruit>) response.getResult();
//We now have an orange
assertEquals(3, result.size());
//Remove required object
muleContext.getRegistry().unregisterObject("redApple");