Search in sources :

Example 1 with Offer

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("==================================");
    }
}
Also used : RemoteMessage(org.switchyard.remote.RemoteMessage) Offer(org.switchyard.quickstarts.demo.txpropagation.Offer) RemoteInvoker(org.switchyard.remote.RemoteInvoker) HttpInvoker(org.switchyard.remote.http.HttpInvoker) Deal(org.switchyard.quickstarts.demo.txpropagation.Deal)

Example 2 with Offer

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;
}
Also used : Car(org.switchyard.quickstarts.demo.txpropagation.Car) Offer(org.switchyard.quickstarts.demo.txpropagation.Offer) Application(org.switchyard.quickstarts.demo.txpropagation.Application)

Example 3 with 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());
}
Also used : Offer(org.switchyard.quickstarts.demo.txpropagation.Offer) Application(org.switchyard.quickstarts.demo.txpropagation.Application) Test(org.junit.Test)

Example 4 with Offer

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());
}
Also used : Offer(org.switchyard.quickstarts.demo.txpropagation.Offer) Application(org.switchyard.quickstarts.demo.txpropagation.Application) Test(org.junit.Test)

Example 5 with Offer

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());
}
Also used : Car(org.switchyard.quickstarts.demo.txpropagation.Car) Offer(org.switchyard.quickstarts.demo.txpropagation.Offer) Deal(org.switchyard.quickstarts.demo.txpropagation.Deal) Test(org.junit.Test)

Aggregations

Offer (org.switchyard.quickstarts.demo.txpropagation.Offer)6 Test (org.junit.Test)4 Application (org.switchyard.quickstarts.demo.txpropagation.Application)4 Car (org.switchyard.quickstarts.demo.txpropagation.Car)3 Deal (org.switchyard.quickstarts.demo.txpropagation.Deal)3 RemoteInvoker (org.switchyard.remote.RemoteInvoker)1 RemoteMessage (org.switchyard.remote.RemoteMessage)1 HttpInvoker (org.switchyard.remote.http.HttpInvoker)1 MockHandler (org.switchyard.test.MockHandler)1