Coverage Report - org.mule.module.ws.construct.builder.WSProxyBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
WSProxyBuilder
0%
0/21
0%
0/4
0
 
 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.module.ws.construct.builder;
 8  
 
 9  
 import java.io.File;
 10  
 import java.io.IOException;
 11  
 import java.net.URI;
 12  
 import java.util.Arrays;
 13  
 
 14  
 import org.mule.MessageExchangePattern;
 15  
 import org.mule.api.MuleContext;
 16  
 import org.mule.api.MuleException;
 17  
 import org.mule.api.config.ConfigurationException;
 18  
 import org.mule.api.processor.MessageProcessor;
 19  
 import org.mule.api.transformer.Transformer;
 20  
 import org.mule.construct.builder.AbstractFlowConstructWithSingleInboundAndOutboundEndpointBuilder;
 21  
 import org.mule.module.ws.construct.WSProxy;
 22  
 import org.mule.util.FileUtils;
 23  
 
 24  0
 public class WSProxyBuilder extends
 25  
     AbstractFlowConstructWithSingleInboundAndOutboundEndpointBuilder<WSProxyBuilder, WSProxy>
 26  
 {
 27  
     protected URI wsldLocation;
 28  
     protected File wsdlFile;
 29  
 
 30  
     @Override
 31  
     protected MessageExchangePattern getInboundMessageExchangePattern()
 32  
     {
 33  0
         return MessageExchangePattern.REQUEST_RESPONSE;
 34  
     }
 35  
 
 36  
     @Override
 37  
     protected MessageExchangePattern getOutboundMessageExchangePattern()
 38  
     {
 39  0
         return MessageExchangePattern.REQUEST_RESPONSE;
 40  
     }
 41  
 
 42  
     public WSProxyBuilder outboundTransformers(Transformer... outboundTransformers)
 43  
     {
 44  0
         this.outboundTransformers = Arrays.asList((MessageProcessor[]) outboundTransformers);
 45  0
         return this;
 46  
     }
 47  
 
 48  
     public WSProxyBuilder outboundResponseTransformers(Transformer... outboundResponseTransformers)
 49  
     {
 50  0
         this.outboundResponseTransformers = Arrays.asList((MessageProcessor[]) outboundResponseTransformers);
 51  0
         return this;
 52  
     }
 53  
 
 54  
     public WSProxyBuilder wsldLocation(URI wsldLocation)
 55  
     {
 56  0
         this.wsldLocation = wsldLocation;
 57  0
         return this;
 58  
     }
 59  
 
 60  
     public WSProxyBuilder wsdlFile(File wsdlFile)
 61  
     {
 62  0
         this.wsdlFile = wsdlFile;
 63  0
         return this;
 64  
     }
 65  
 
 66  
     @Override
 67  
     protected WSProxy buildFlowConstruct(MuleContext muleContext) throws MuleException
 68  
     {
 69  0
         if (wsdlFile != null)
 70  
         {
 71  0
             return buildStaticWsdlContentsWSProxy(muleContext);
 72  
         }
 73  
 
 74  0
         if (wsldLocation != null)
 75  
         {
 76  0
             return buildStaticWsdlUriWSProxy(muleContext);
 77  
         }
 78  
 
 79  0
         return buildDynamicWsdlUriWSProxy(muleContext);
 80  
     }
 81  
 
 82  
     private WSProxy buildDynamicWsdlUriWSProxy(MuleContext muleContext) throws MuleException
 83  
     {
 84  0
         return new WSProxy(name, muleContext, getOrBuildInboundEndpoint(muleContext),
 85  
             getOrBuildOutboundEndpoint(muleContext));
 86  
     }
 87  
 
 88  
     private WSProxy buildStaticWsdlContentsWSProxy(MuleContext muleContext) throws MuleException
 89  
     {
 90  
         try
 91  
         {
 92  0
             return new WSProxy(name, muleContext, getOrBuildInboundEndpoint(muleContext),
 93  
                 getOrBuildOutboundEndpoint(muleContext), FileUtils.readFileToString(wsdlFile));
 94  
         }
 95  0
         catch (final IOException ioe)
 96  
         {
 97  0
             throw new ConfigurationException(ioe);
 98  
         }
 99  
     }
 100  
 
 101  
     private WSProxy buildStaticWsdlUriWSProxy(MuleContext muleContext) throws MuleException
 102  
     {
 103  0
         return new WSProxy(name, muleContext, getOrBuildInboundEndpoint(muleContext),
 104  
             getOrBuildOutboundEndpoint(muleContext), wsldLocation);
 105  
     }
 106  
 }