Coverage Report - org.mule.example.bookstore.BookstoreImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
BookstoreImpl
0%
0/21
0%
0/4
0
 
 1  
 /*
 2  
  * $$Id: BookstoreImpl.java 12221 2008-07-01 20:04:09Z dfeist $$
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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;
 12  
 
 13  
 import java.util.ArrayList;
 14  
 import java.util.Collection;
 15  
 import java.util.HashMap;
 16  
 import java.util.List;
 17  
 import java.util.Map;
 18  
 
 19  
 import javax.jws.WebService;
 20  
 
 21  
 import org.mule.DefaultMuleMessage;
 22  
 import org.mule.RequestContext;
 23  
 import org.mule.api.MuleException;
 24  
 import org.mule.api.MuleMessage;
 25  
 
 26  
 @WebService(serviceName="BookstoreService",
 27  
     portName="BookstorePort",
 28  
     endpointInterface="org.mule.example.bookstore.Bookstore")
 29  0
 public class BookstoreImpl implements Bookstore
 30  
 {
 31  0
     private Map < Long, Book > books = new HashMap < Long, Book > ();
 32  
     
 33  
     public long addBook(Book book)
 34  
     {
 35  0
         System.out.println("Adding book " + book.getTitle());
 36  0
         long id = books.size() + 1;
 37  0
         book.setId(id);
 38  0
         books.put(id, book);
 39  0
         return id;
 40  
     }
 41  
 
 42  
     public Collection < Long > addBooks(Collection < Book > books)
 43  
     {
 44  0
         List < Long > ids = new ArrayList < Long > ();
 45  0
         if (books != null)
 46  
         {
 47  0
             for (Book book : books)
 48  
             {
 49  0
                 ids.add(addBook(book));
 50  
             }
 51  
         }
 52  0
         return ids;
 53  
     }
 54  
 
 55  
     public Collection < Book > getBooks()
 56  
     {
 57  0
         return books.values();
 58  
     }
 59  
 
 60  
     public void orderBook(long bookId, String address, String email)
 61  
     {
 62  
         // In the real world we'd want this hidden behind an OrderService interface
 63  
         try
 64  
         {
 65  0
             Book book = books.get(bookId);
 66  0
             MuleMessage msg = new DefaultMuleMessage(new Object[] { book, address, email} );
 67  
 
 68  0
             RequestContext.getEventContext().dispatchEvent(msg, "orderEmailService");
 69  0
             System.out.println("Dispatched message to orderService.");
 70  
         }
 71  0
         catch (MuleException e)
 72  
         {
 73  
             // If this was real, we'd want better error handling
 74  0
             throw new RuntimeException(e);
 75  0
         }
 76  0
     }
 77  
 }