use of org.mule.tck.testmodels.fruit.Banana in project mule by mulesoft.
the class CachedConnectionHandlerTestCase method getConnectionConcurrentlyAndConnectOnlyOnce.
@Test
public void getConnectionConcurrentlyAndConnectOnlyOnce() throws Exception {
Banana mockConnection = mock(Banana.class);
connectionProvider = mock(ConnectionProvider.class);
before();
Latch latch = new Latch();
when(connectionProvider.connect()).thenAnswer(invocation -> {
new Thread(() -> {
try {
latch.release();
getConnection();
} catch (Exception e) {
throw new RuntimeException(e);
}
}).start();
return mockConnection;
});
Banana connection = managedConnection.getConnection();
assertThat(latch.await(5, TimeUnit.SECONDS), is(true));
assertThat(connection, is(sameInstance(mockConnection)));
verify(connectionProvider).connect();
}
use of org.mule.tck.testmodels.fruit.Banana in project mule by mulesoft.
the class FlowListenerOperationExecutionTestCase method listenSuccessfulFlow.
@Test
public void listenSuccessfulFlow() throws Exception {
Message message = flowRunner("listenAndByteBanana").run().getMessage();
assertThat(message.getPayload().getValue(), is(instanceOf(Banana.class)));
final Banana banana = (Banana) message.getPayload().getValue();
check(() -> {
assertThat(banana.isPeeled(), is(true));
assertThat(banana.isBitten(), is(true));
assertThat(config.getBananasCount(), is(1));
assertThat(config.getNonBananasCount(), is(0));
assertThat(config.getExceptionCount(), is(0));
});
}
use of org.mule.tck.testmodels.fruit.Banana in project mule by mulesoft.
the class ParameterDslFunctionalTestCase method eatPealed.
@Test
public void eatPealed() throws Exception {
Banana banana = (Banana) flowRunner("eatPealedBanana").run().getMessage().getPayload().getValue();
assertThat(banana.isBitten(), is(true));
}
use of org.mule.tck.testmodels.fruit.Banana in project mule by mulesoft.
the class VeganBananaConnectionProvider method connect.
@Override
public Banana connect() throws ConnectionException {
Banana banana = new Banana();
banana.setOrigin(originCountry);
return banana;
}
use of org.mule.tck.testmodels.fruit.Banana in project mule by mulesoft.
the class FlowListenerBananaOperations method getLunch.
@OutputResolver(output = FruitMetadataResolver.class)
public Fruit getLunch(@Config BananaConfig config, FlowListener listener) {
final Banana banana = new Banana();
listener.onSuccess(message -> {
if (message.getPayload().getValue() instanceof Banana) {
config.onBanana();
} else {
config.onNotBanana();
}
});
listener.onError(exception -> config.onException());
listener.onComplete(() -> banana.peel());
return banana;
}
Aggregations