Coverage Report - org.mule.transport.xmpp.XmppConversationFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
XmppConversationFactory
0%
0/11
0%
0/4
2.75
XmppConversationFactory$1
0%
0/1
N/A
2.75
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.transport.xmpp;
 8  
 
 9  
 import org.mule.api.MuleRuntimeException;
 10  
 import org.mule.api.endpoint.ImmutableEndpoint;
 11  
 import org.mule.transport.xmpp.i18n.XmppMessages;
 12  
 
 13  
 /**
 14  
  * A factory that creates {@link XmppConversation} instances based on the endpoint's configuration.
 15  
  */
 16  0
 public class XmppConversationFactory
 17  
 {
 18  
     public XmppConversation create(ImmutableEndpoint endpoint)
 19  
     {
 20  0
         String host = endpoint.getEndpointURI().getHost();
 21  0
         XmppMessageType type = XmppMessageType.valueOf(host);
 22  
         
 23  0
         switch (type)
 24  
         {
 25  
             case MESSAGE:
 26  0
                 return createMessageConversation(endpoint);
 27  
             
 28  
             case CHAT:
 29  0
                 return createChatConversation(endpoint);
 30  
 
 31  
             case GROUPCHAT:
 32  0
                 return createGroupchatConversation(endpoint);
 33  
         }                
 34  
 
 35  
         // we should never get here as valueOf on the enum above will choke if you pass
 36  
         // in an invalid string
 37  0
         throw new MuleRuntimeException(XmppMessages.invalidConversationType(type));
 38  
     }
 39  
 
 40  
     protected XmppConversation createMessageConversation(ImmutableEndpoint endpoint)
 41  
     {
 42  0
         return new XmppMessageConversation(endpoint);
 43  
     }
 44  
 
 45  
     protected XmppConversation createChatConversation(ImmutableEndpoint endpoint)
 46  
     {
 47  0
         return new XmppChatConversation(endpoint);
 48  
     }
 49  
 
 50  
     protected XmppConversation createGroupchatConversation(ImmutableEndpoint endpoint)
 51  
     {
 52  0
         return new XmppMultiUserChatConversation(endpoint);
 53  
     }
 54  
 }
 55  
 
 56