Search in sources :

Example 1 with GetCustomersByNameResponse

use of com.example.customerservice.multipart.GetCustomersByNameResponse in project camel by apache.

the class MultiPartCustomerServiceImpl method getCustomersByName.

@Override
public GetCustomersByNameResponse getCustomersByName(GetCustomersByName parameters, Product product) {
    if (product == null) {
        throw new IllegalArgumentException("product may not be null");
    }
    GetCustomersByNameResponse response = new GetCustomersByNameResponse();
    Customer customer = new Customer();
    customer.setName(product.getName());
    customer.setRevenue(100000);
    response.getReturn().add(customer);
    return response;
}
Also used : GetCustomersByNameResponse(com.example.customerservice.multipart.GetCustomersByNameResponse) Customer(com.example.customerservice.multipart.Customer) SaveCustomer(com.example.customerservice.multipart.SaveCustomer)

Example 2 with GetCustomersByNameResponse

use of com.example.customerservice.multipart.GetCustomersByNameResponse in project camel by apache.

the class MultiPartCxfServerTest method testSendRequestWithInPart.

@Test
public void testSendRequestWithInPart() throws Exception {
    Exchange exchange = producerTemplate.send("direct:start", new Processor() {

        public void process(Exchange exchange) throws Exception {
            BeanInvocation beanInvocation = new BeanInvocation();
            GetCustomersByName getCustomersByName = new GetCustomersByName();
            getCustomersByName.setName("Dr. Multipart");
            beanInvocation.setMethod(MultiPartCustomerService.class.getMethod("getCustomersByName", GetCustomersByName.class, com.example.customerservice.multipart.Product.class));
            Product product = new Product();
            product.setName("Multipart Product");
            product.setDescription("Useful for lots of things.");
            Object[] args = new Object[] { getCustomersByName, product };
            beanInvocation.setArgs(args);
            exchange.getIn().setBody(beanInvocation);
        }
    });
    if (exchange.getException() != null) {
        throw exchange.getException();
    }
    Object responseObj = exchange.getOut().getBody();
    assertTrue(responseObj instanceof GetCustomersByNameResponse);
    GetCustomersByNameResponse response = (GetCustomersByNameResponse) responseObj;
    assertTrue(response.getReturn().get(0).getName().equals("Multipart Product"));
}
Also used : Exchange(org.apache.camel.Exchange) GetCustomersByNameResponse(com.example.customerservice.multipart.GetCustomersByNameResponse) Processor(org.apache.camel.Processor) GetCustomersByName(com.example.customerservice.multipart.GetCustomersByName) BeanInvocation(org.apache.camel.component.bean.BeanInvocation) Product(com.example.customerservice.multipart.Product) Test(org.junit.Test)

Aggregations

GetCustomersByNameResponse (com.example.customerservice.multipart.GetCustomersByNameResponse)2 Customer (com.example.customerservice.multipart.Customer)1 GetCustomersByName (com.example.customerservice.multipart.GetCustomersByName)1 Product (com.example.customerservice.multipart.Product)1 SaveCustomer (com.example.customerservice.multipart.SaveCustomer)1 Exchange (org.apache.camel.Exchange)1 Processor (org.apache.camel.Processor)1 BeanInvocation (org.apache.camel.component.bean.BeanInvocation)1 Test (org.junit.Test)1