Coverage Report - org.mule.construct.builder.ValidatorBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
ValidatorBuilder
0%
0/13
0%
0/2
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.construct.builder;
 8  
 
 9  
 import org.mule.MessageExchangePattern;
 10  
 import org.mule.api.MuleContext;
 11  
 import org.mule.api.MuleException;
 12  
 import org.mule.api.routing.filter.Filter;
 13  
 import org.mule.construct.Validator;
 14  
 import org.mule.util.StringUtils;
 15  
 
 16  0
 public class ValidatorBuilder extends
 17  
     AbstractFlowConstructWithSingleInboundAndOutboundEndpointBuilder<ValidatorBuilder, Validator>
 18  
 {
 19  
     protected Filter validationFilter;
 20  
     protected String ackExpression;
 21  
     protected String nackExpression;
 22  
     protected String errorExpression;
 23  
 
 24  
     public ValidatorBuilder validationFilter(Filter validationFilter)
 25  
     {
 26  0
         this.validationFilter = validationFilter;
 27  0
         return this;
 28  
     }
 29  
 
 30  
     public ValidatorBuilder ackExpression(String ackExpression)
 31  
     {
 32  0
         this.ackExpression = ackExpression;
 33  0
         return this;
 34  
     }
 35  
 
 36  
     public ValidatorBuilder nackExpression(String nackExpression)
 37  
     {
 38  0
         this.nackExpression = nackExpression;
 39  0
         return this;
 40  
     }
 41  
 
 42  
     public ValidatorBuilder errorExpression(String errorExpression)
 43  
     {
 44  0
         this.errorExpression = errorExpression;
 45  0
         return this;
 46  
     }
 47  
 
 48  
     @Override
 49  
     protected MessageExchangePattern getInboundMessageExchangePattern()
 50  
     {
 51  0
         return MessageExchangePattern.REQUEST_RESPONSE;
 52  
     }
 53  
 
 54  
     @Override
 55  
     protected MessageExchangePattern getOutboundMessageExchangePattern()
 56  
     {
 57  0
         return hasErrorExpression()
 58  
                                    ? MessageExchangePattern.REQUEST_RESPONSE
 59  
                                    : MessageExchangePattern.ONE_WAY;
 60  
     }
 61  
 
 62  
     @Override
 63  
     protected Validator buildFlowConstruct(MuleContext muleContext) throws MuleException
 64  
     {
 65  0
         return new Validator(name, muleContext, getOrBuildInboundEndpoint(muleContext),
 66  
             getOrBuildOutboundEndpoint(muleContext), validationFilter, ackExpression, nackExpression,
 67  
             errorExpression);
 68  
     }
 69  
 
 70  
     protected boolean hasErrorExpression()
 71  
     {
 72  0
         return StringUtils.isNotBlank(errorExpression);
 73  
     }
 74  
 }