Coverage Report - org.mule.example.bookstore.transformers.OrderToEmailTransformer
 
Classes in this File Line Coverage Branch Coverage Complexity
OrderToEmailTransformer
0%
0/11
N/A
0
 
 1  
 /*
 2  
  * $Id: OrderToEmailTransformer.java 19423 2010-09-08 08:04:54Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.example.bookstore.transformers;
 12  
 
 13  
 import org.mule.RequestContext;
 14  
 import org.mule.api.transformer.TransformerException;
 15  
 import org.mule.example.bookstore.Book;
 16  
 import org.mule.example.bookstore.Order;
 17  
 import org.mule.transformer.AbstractTransformer;
 18  
 import org.mule.transformer.types.DataTypeFactory;
 19  
 import org.mule.transport.email.MailProperties;
 20  
 
 21  
 /**
 22  
  * Composes an e-mail notification message to be sent based on the Book Order.
 23  
  */
 24  
 public class OrderToEmailTransformer extends AbstractTransformer
 25  
 {
 26  
     public OrderToEmailTransformer()
 27  
     {
 28  0
         super();
 29  0
         registerSourceType(DataTypeFactory.create(Order.class));
 30  0
         setReturnDataType(DataTypeFactory.STRING);
 31  0
     }
 32  
     
 33  
     @Override
 34  
     protected Object doTransform(Object src, String outputEncoding) throws TransformerException
 35  
     {
 36  0
         Order order = (Order) src;
 37  0
         Book book = order.getBook();
 38  
         
 39  0
         String body =  "Thank you for placing your order for " +
 40  
                        book.getTitle() + " with the Mule-powered On-line Bookstore. " +
 41  
                        "Your order will be shipped  to " +
 42  
                        order.getAddress() + " by the next business day.";
 43  
         
 44  0
         String email = order.getEmail();
 45  0
         RequestContext.getEventContext().getMessage().setOutboundProperty(MailProperties.TO_ADDRESSES_PROPERTY,
 46  
                                                                           email);
 47  0
         logger.info("Sending e-mail notification to " + email);
 48  0
         return body;
 49  
     }
 50  
 }