use of org.switchyard.quickstarts.demo.txpropagation.Deal in project quickstarts by jboss-switchyard.
the class RemoteClient method main.
/**
* Only execution point for this application.
* @param ignored not used.
* @throws Exception if something goes wrong.
*/
public static void main(final String[] args) throws Exception {
// Create a new remote client invoker
RemoteInvoker invoker = new HttpInvoker(URL);
// Create request payload
Offer offer = null;
if (args.length == 1 && args[0].equals("deny")) {
offer = createOffer(false);
} else {
offer = createOffer(true);
}
// Create the request message
RemoteMessage message = new RemoteMessage();
message.setService(SERVICE).setOperation("offer").setContent(offer);
// Invoke the service
RemoteMessage reply = invoker.invoke(message);
if (reply.isFault()) {
System.err.println("Oops ... something bad happened. " + reply.getContent());
} else {
Deal deal = (Deal) reply.getContent();
out.println("==================================");
out.println("Was the offer accepted? " + deal.isAccepted());
out.println("==================================");
}
}
use of org.switchyard.quickstarts.demo.txpropagation.Deal in project quickstarts by jboss-switchyard.
the class DealerTest method rejectLowBallOffer.
@Test
public void rejectLowBallOffer() throws Exception {
Car car = new Car();
car.setPrice(500.00);
Offer offer = new Offer();
offer.setCar(car);
offer.setAmount(100.00);
Deal deal = service.operation("offer").sendInOut(offer).getContent(Deal.class);
// verify the deal is rejected
Assert.assertFalse(deal.isAccepted());
}
use of org.switchyard.quickstarts.demo.txpropagation.Deal in project quickstarts by jboss-switchyard.
the class DealerTest method acceptValidOffer.
@Test
public void acceptValidOffer() throws Exception {
Car car = new Car();
car.setPrice(500.00);
Application app = new Application();
app.setCreditScore(650);
Offer offer = new Offer();
offer.setCar(car);
offer.setApplication(app);
offer.setAmount(450.00);
// configure our proxy for the service reference
testKit.replaceService("DealLogger");
MockHandler creditService = testKit.replaceService("CreditCheckService");
Application reply = new Application();
reply.setApproved(true);
creditService.replyWithOut(reply);
// Invoke the service
Deal deal = service.operation("offer").sendInOut(offer).getContent(Deal.class);
// verify the deal is rejected
Assert.assertTrue(deal.isAccepted());
}
Aggregations