// Path: src/main/java/org/ucmtwine/parameter/IParameter.java
// public interface IParameter {
// 
//   public String getName();
// 
//   public boolean isRequired();
// 
//   /**
//    * Get the value from the binder, checking for type compatibility and
//    * mandatory requirements.
//    * 
//    * @param service
//    *          The execution context.
//    * @return A type cast value or null
//    * @throws IllegalAccessException
//    * 
//    */
//   public Object getBinderValue(Service service) throws IllegalAccessException;
// 
//   /**
//    * Get the value from another object, casting if needed.
//    * 
//    * @param object
//    * @return
//    * @throws ClassCastException
//    */
//   public Object getArgumentValue(Object object, Service service) throws ClassCastException;
// 
//   /**
//    * Returns the class of the binder variable after type coercion.
//    * 
//    * @return
//    */
//   public Class<?> getType();
// 
//   /**
//    * Gets a parameter definition string for use in service actions.
//    * 
//    * @return
//    */
//   public String toActionString();
// 
//   /**
//    * Returns the GrammarElement type for use in idoc script function
//    * definitions.
//    * 
//    * @return
//    */
//   public int getGrammarElementType();
// }
// 
// Path: src/main/java/org/ucmtwine/parameter/types/FloatParameter.java
// public class FloatParameter extends Parameter {
// 
//   public FloatParameter() {
//     super("", Float.class);
//   }
// 
//   public FloatParameter(String name) {
//     super(name, Float.class);
//   }
// 
//   public FloatParameter(String name, Class<?> type) {
//     super(name, type);
//   }
// 
//   @Override
//   public Object getBinderValue(Service service) {
//     
//     String floatString = getStringValue(service.getBinder());
// 
//     Float value = null;
// 
//     try {
//       value = Float.parseFloat(floatString);
// 
//     } catch (NumberFormatException e) {
// 
//       // null is ok (unless param is required) but invalid parse is not.
//       if (floatString != null) {
//         throw new IllegalArgumentException("Parameter " + name + " must be parseable as a float");
//       }
//     }
// 
//     return value;
//   }
// 
//   /**
//    * {@inheritDoc}
//    */
//   public int getGrammarElementType() {
//     return GrammarElement.FLOAT_VAL;
//   }
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.when;
import intradoc.common.ServiceException;
import intradoc.data.DataBinder;
import intradoc.data.DataException;
import intradoc.server.Service;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.ucmtwine.parameter.IParameter;
import org.ucmtwine.parameter.types.FloatParameter;
package org.ucmtwine.test.parameter.types;



@RunWith(MockitoJUnitRunner.class)
public class TestFloatParameter {

  private DataBinder testBinder;

  @Mock
  private Service testService;

  @Before
  public void setUp() throws DataException, ServiceException {
    testBinder = new DataBinder();

    testBinder.putLocal("emptyParam", "");
    testBinder.putLocal("zeroParam", "0.0");
    testBinder.putLocal("oneParam", "1.0");
    testBinder.putLocal("invalidParam", "sdsd");
    testBinder.putLocal("negativeParam", "-1.0");
    testBinder.putLocal("positiveParam", "200.0");

    when(testService.getBinder()).thenReturn(testBinder);
  }

  @Test
  public void testGetValueFromBinderIsCorrectType() {
    assertEquals(1.0f, new FloatParameter("oneParam").getBinderValue(testService));
  }

  @Test
  public void testParsesStringValuesIntoIntegers() {
    assertEquals(0.0f, new FloatParameter("zeroParam").getBinderValue(testService));
    assertEquals(1.0f, new FloatParameter("oneParam").getBinderValue(testService));
  }

  @Test(expected = IllegalArgumentException.class)
  public void testEmptyStringValueThrowsException() {
// Path: src/main/java/org/ucmtwine/parameter/IParameter.java
// public interface IParameter {
// 
//   public String getName();
// 
//   public boolean isRequired();
// 
//   /**
//    * Get the value from the binder, checking for type compatibility and
//    * mandatory requirements.
//    * 
//    * @param service
//    *          The execution context.
//    * @return A type cast value or null
//    * @throws IllegalAccessException
//    * 
//    */
//   public Object getBinderValue(Service service) throws IllegalAccessException;
// 
//   /**
//    * Get the value from another object, casting if needed.
//    * 
//    * @param object
//    * @return
//    * @throws ClassCastException
//    */
//   public Object getArgumentValue(Object object, Service service) throws ClassCastException;
// 
//   /**
//    * Returns the class of the binder variable after type coercion.
//    * 
//    * @return
//    */
//   public Class<?> getType();
// 
//   /**
//    * Gets a parameter definition string for use in service actions.
//    * 
//    * @return
//    */
//   public String toActionString();
// 
//   /**
//    * Returns the GrammarElement type for use in idoc script function
//    * definitions.
//    * 
//    * @return
//    */
//   public int getGrammarElementType();
// }
// 
// Path: src/main/java/org/ucmtwine/parameter/types/FloatParameter.java
// public class FloatParameter extends Parameter {
// 
//   public FloatParameter() {
//     super("", Float.class);
//   }
// 
//   public FloatParameter(String name) {
//     super(name, Float.class);
//   }
// 
//   public FloatParameter(String name, Class<?> type) {
//     super(name, type);
//   }
// 
//   @Override
//   public Object getBinderValue(Service service) {
//     
//     String floatString = getStringValue(service.getBinder());
// 
//     Float value = null;
// 
//     try {
//       value = Float.parseFloat(floatString);
// 
//     } catch (NumberFormatException e) {
// 
//       // null is ok (unless param is required) but invalid parse is not.
//       if (floatString != null) {
//         throw new IllegalArgumentException("Parameter " + name + " must be parseable as a float");
//       }
//     }
// 
//     return value;
//   }
// 
//   /**
//    * {@inheritDoc}
//    */
//   public int getGrammarElementType() {
//     return GrammarElement.FLOAT_VAL;
//   }
// }


// Path: src/test/java/org/ucmtwine/test/parameter/types/TestFloatParameter.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.when;
import intradoc.common.ServiceException;
import intradoc.data.DataBinder;
import intradoc.data.DataException;
import intradoc.server.Service;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.ucmtwine.parameter.IParameter;
import org.ucmtwine.parameter.types.FloatParameter;

package org.ucmtwine.test.parameter.types;



@RunWith(MockitoJUnitRunner.class)
public class TestFloatParameter {

  private DataBinder testBinder;

  @Mock
  private Service testService;

  @Before
  public void setUp() throws DataException, ServiceException {
    testBinder = new DataBinder();

    testBinder.putLocal("emptyParam", "");
    testBinder.putLocal("zeroParam", "0.0");
    testBinder.putLocal("oneParam", "1.0");
    testBinder.putLocal("invalidParam", "sdsd");
    testBinder.putLocal("negativeParam", "-1.0");
    testBinder.putLocal("positiveParam", "200.0");

    when(testService.getBinder()).thenReturn(testBinder);
  }

  @Test
  public void testGetValueFromBinderIsCorrectType() {
    assertEquals(1.0f, new FloatParameter("oneParam").getBinderValue(testService));
  }

  @Test
  public void testParsesStringValuesIntoIntegers() {
    assertEquals(0.0f, new FloatParameter("zeroParam").getBinderValue(testService));
    assertEquals(1.0f, new FloatParameter("oneParam").getBinderValue(testService));
  }

  @Test(expected = IllegalArgumentException.class)
  public void testEmptyStringValueThrowsException() {
    @SuppressWarnings("unused")