use of org.switchyard.quickstarts.demo.txpropagation.Offer 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.Offer in project quickstarts by jboss-switchyard.
the class RemoteClient method createOffer.
public static Offer createOffer(boolean acceptable) {
Application app = new Application();
app.setName("John Smith");
app.setCreditScore(acceptable ? 700 : 300);
Car car = new Car();
car.setPrice(18000);
car.setVehicleId("Honda");
Offer offer = new Offer();
offer.setApplication(app);
offer.setCar(car);
offer.setAmount(17000);
return offer;
}
use of org.switchyard.quickstarts.demo.txpropagation.Offer in project quickstarts by jboss-switchyard.
the class CreditCheckTest method creditDenied.
// Verify that credit scores below 600 are denied
@Test
public void creditDenied() throws Exception {
Application app = new Application();
app.setName("bill whatwhatwhat");
app.setCreditScore(400);
Offer offer = new Offer();
offer.setApplication(app);
Application result = service.operation("checkCredit").sendInOut(offer).getContent(Application.class);
// validate the results
Assert.assertFalse(result.isApproved());
}
use of org.switchyard.quickstarts.demo.txpropagation.Offer in project quickstarts by jboss-switchyard.
the class CreditCheckTest method creditApproved.
// Verify that credit scores at or above 600 are approved
@Test
public void creditApproved() throws Exception {
Application app = new Application();
app.setName("phil garfield");
app.setCreditScore(600);
Offer offer = new Offer();
offer.setApplication(app);
Application result = service.operation("checkCredit").sendInOut(offer).getContent(Application.class);
// validate the results
Assert.assertTrue(result.isApproved());
}
use of org.switchyard.quickstarts.demo.txpropagation.Offer 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());
}
Aggregations