Coverage Report - org.mule.example.geomail.components.DataGenerator
 
Classes in this File Line Coverage Branch Coverage Complexity
DataGenerator
0%
0/12
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.example.geomail.components;
 8  
 
 9  
 import org.mule.api.MuleEventContext;
 10  
 import org.mule.api.lifecycle.Callable;
 11  
 
 12  
 import java.util.ArrayList;
 13  
 import java.util.List;
 14  
 import java.util.Random;
 15  
 
 16  
 /**
 17  
  * TODO
 18  
  */
 19  0
 public class DataGenerator implements Callable
 20  
 {
 21  0
     private Random generator = new Random();
 22  0
     private int batchSize = 10;
 23  
     
 24  
     public Object onCall(MuleEventContext eventContext) throws Exception
 25  
     {
 26  0
         eventContext.getMessage().setOutboundProperty("from.email.address", "testdatagenerator@geomail.com");
 27  
 
 28  
         // Create multiple IPs for each run since many addresses will not be valid
 29  0
         List<String> ipAddresses = new ArrayList<String>(batchSize);
 30  0
         for (int i = 0; i < batchSize; i++)
 31  
         {
 32  0
             String address = new StringBuffer().append(generator.nextInt(255)).append(".")
 33  
                 .append(generator.nextInt(255)).append(".").append(generator.nextInt(255)).
 34  
                 append(".").append(generator.nextInt(255)).toString();
 35  0
             ipAddresses.add(address);
 36  
         }
 37  
 
 38  0
         return ipAddresses;
 39  
     }
 40  
 
 41  
     public int getBatchSize()
 42  
     {
 43  0
         return batchSize;
 44  
     }
 45  
 
 46  
     public void setBatchSize(int batchSize)
 47  
     {
 48  0
         this.batchSize = batchSize;
 49  0
     }
 50  
 }