Coverage Report - org.mule.module.ibeans.spi.support.HttpStatusCodeCallback
 
Classes in this File Line Coverage Branch Coverage Complexity
HttpStatusCodeCallback
0%
0/8
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.module.ibeans.spi.support;
 8  
 
 9  
 import org.mule.message.DefaultExceptionPayload;
 10  
 import org.mule.module.ibeans.spi.MuleResponseMessage;
 11  
 
 12  
 import org.ibeans.impl.test.MockMessageCallback;
 13  
 
 14  
 /**
 15  
  * Sets a Http status code on the result message created on a mock invocation
 16  
  */
 17  0
 public class HttpStatusCodeCallback implements MockMessageCallback<MuleResponseMessage>
 18  
 {
 19  
     private int status;
 20  
 
 21  
     public HttpStatusCodeCallback(int status)
 22  0
     {
 23  0
         this.status = status;
 24  0
     }
 25  
 
 26  
     public void onMessage(MuleResponseMessage response)
 27  
     {
 28  
         //TODO should this really be read/write
 29  0
         response.setStatusCode(String.valueOf(status));
 30  0
         if(status >= 400)
 31  
         {
 32  0
             response.getMessage().setExceptionPayload(new DefaultExceptionPayload(new Exception("Mock Http Error")));
 33  
         }
 34  0
     }
 35  
 }