use of com.example.customerservice.Customer in project camel by apache.
the class CustomerServiceImpl method getCustomersByName.
/**
* If the request.name is "none" a NoSuchCustomerException is thrown in any
* other case a dummy customer is returned that has the same name as the
* request
*/
public GetCustomersByNameResponse getCustomersByName(GetCustomersByName request) throws NoSuchCustomerException {
if ("none".equals(request.getName())) {
NoSuchCustomer noSuchCustomer = new NoSuchCustomer();
noSuchCustomer.setCustomerId(request.getName());
throw new NoSuchCustomerException("Customer not found", noSuchCustomer);
}
GetCustomersByNameResponse response = new GetCustomersByNameResponse();
Customer customer = new Customer();
customer.setName(request.getName());
customer.setRevenue(100000);
response.getReturn().add(customer);
return response;
}
use of com.example.customerservice.Customer in project camel by apache.
the class CustomerServiceImpl method getAllAmericanCustomers.
/**
* This method is to test a call without input parameter
*/
public GetAllAmericanCustomersResponse getAllAmericanCustomers() {
GetAllAmericanCustomersResponse response = new GetAllAmericanCustomersResponse();
Customer customer = new Customer();
customer.setName("Schmitz");
customer.setRevenue(100000);
response.getReturn().add(customer);
return response;
}
use of com.example.customerservice.Customer in project camel by apache.
the class SoapCxfClientTest method testRoundTripSaveCustomer.
@Test
public void testRoundTripSaveCustomer() throws Exception {
Customer testCustomer = new Customer();
testCustomer.setName("testName");
SaveCustomer request = new SaveCustomer();
request.setCustomer(testCustomer);
customerService.saveCustomer(request);
Customer customer2 = serverBean.getLastSavedCustomer();
Assert.assertEquals("testName", customer2.getName());
}
use of com.example.customerservice.Customer in project camel by apache.
the class SoapCxfClientTest method testSuccess.
@Test
public void testSuccess() throws NoSuchCustomerException {
GetCustomersByName request = new GetCustomersByName();
request.setName("test");
GetCustomersByNameResponse response = customerService.getCustomersByName(request);
Assert.assertNotNull(response);
List<Customer> customers = response.getReturn();
Assert.assertEquals(1, customers.size());
Assert.assertEquals("test", customers.get(0).getName());
}
use of com.example.customerservice.Customer in project cxf by apache.
the class CustomerServiceTester method testCustomerService.
public void testCustomerService() throws NoSuchCustomerException {
List<Customer> customers = null;
// First we test the positive case where customers are found and we retreive
// a list of customers
System.out.println("Sending request for customers named Smith");
customers = customerService.getCustomersByName("Smith");
System.out.println("Response received");
Assert.assertEquals(2, customers.size());
Assert.assertEquals("Smith", customers.get(0).getName());
// Then we test for an unknown Customer name and expect the NoSuchCustomerException
try {
customers = customerService.getCustomersByName("None");
Assert.fail("We should get a NoSuchCustomerException here");
} catch (NoSuchCustomerException e) {
System.out.println(e.getMessage());
Assert.assertNotNull("FaultInfo must not be null", e.getFaultInfo());
Assert.assertEquals("None", e.getFaultInfo().getCustomerName());
System.out.println("NoSuchCustomer exception was received as expected");
}
// The implementation of updateCustomer is set to sleep for some seconds.
// Still this method should return instantly as the method is declared
// as a one way method in the WSDL
Customer customer = new Customer();
customer.setName("Smith");
customerService.updateCustomer(customer);
System.out.println("All calls were successful");
}
Aggregations