Package br.com.caelum.iogi.parameters

Examples of br.com.caelum.iogi.parameters.Parameter


  }

  @Test
  public void isCapableOfDealingWithEmptyParameterForInternalValueWhichNeedsAConverter() throws OgnlException {
    final Target<House> target = Target.create(House.class, "house");
    final Parameter parameter = new Parameter("house.cat.firstLeg.birthDay", "10/5/2010");
    when(mockLocaleProvider.getLocale()).thenReturn(new Locale("pt", "BR"));
    final House house = iogi.instantiate(target, parameter);
    assertThat(house.cat.firstLeg.birthDay, is(equalTo((Calendar)new GregorianCalendar(2010, 4, 10))));
  }
View Full Code Here


  @Test
  public void canInstantiatingStringsInAListSettingItsInternalValueWithoutInvokingConverters1() throws Exception {
  final Type type = ContainsParameterizedList.class.getField("listOfString").getGenericType();
    final Target<List<String>> target = new Target<List<String>>(type, "legLength");
    final List<String> legs = iogi.instantiate(target , new Parameter("legLength[0]", "small"), new Parameter("legLength[1]", "big"));
  assertThat(legs.get(1), is(equalTo("big")));
  }
View Full Code Here

  }
 
  @Test
  public void canInstantiatingStringsInAListSettingItsInternalValueWithoutInvokingConverters2() throws Exception {
    final Target<Cat> target = Target.create(Cat.class, "cat");
    final Cat cat = iogi.instantiate(target , new Parameter("cat.legLength[0]", "small"), new Parameter("cat.legLength[1]", "big"));
    assertThat(cat.legLength.get(1), is(equalTo("big")));
  }
View Full Code Here

  }
 
  @Test
  public void canInstantiateAndPopulateAnArrayOfWrappers1() {
    final Target<long[]> target = Target.create(long[].class, "ids");
    final long[] ids = iogi.instantiate(target, new Parameter("ids[0]", "3"), new Parameter("ids[1]", "5"));
    assertThat(ids[0], is(equalTo(3L)));
  assertThat(ids[1], is(equalTo(5L)));
  }
View Full Code Here

  }
 
  @Test
  public void canInstantiateAndPopulateAnArrayOfWrappers2() {
    final Target<Cat> target = Target.create(Cat.class, "cat");
    final Cat cat = iogi.instantiate(target, new Parameter("cat.ids[0]", "3"), new Parameter("cat.ids[1]", "5"));
    assertThat(cat.ids[0], is(equalTo(3L)));
    assertThat(cat.ids[1], is(equalTo(5L)));
  }
View Full Code Here

  @Test
  public void canInstantiateAndPopulateAListOfWrappers1() throws Exception {
    final Type type = ContainsParameterizedList.class.getField("listOfLong").getGenericType();
    final Target<List<Long>> target = new Target<List<Long>>(type, "eyeColorCode");
    final List<Long> eyeColorCode = iogi.instantiate(target, new Parameter("eyeColorCode[0]", "3"), new Parameter("eyeColorCode[1]", "5"));
  assertThat(eyeColorCode.get(0), is(equalTo(3L)));
  assertThat(eyeColorCode.get(1), is(equalTo(5L)));
  }
View Full Code Here

  }
 
  @Test
  public void canInstantiateAndPopulateAListOfWrappers() {
    final Target<Cat> target = Target.create(Cat.class, "myCat");
  final Cat myCat = iogi.instantiate(target, new Parameter("myCat.eyeColorCode[0]", "3"), new Parameter("myCat.eyeColorCode[1]", "5"));
    assertThat(myCat.eyeColorCode.get(0), is(equalTo(3L)));
  assertThat(myCat.eyeColorCode.get(1), is(equalTo(5L)));
  }
View Full Code Here

    ResourceMethod anyMethod = buyA;
    requestParameterIs(anyMethod, "name", "a", "b");

    final InstantiatorWithErrors mockInstantiator = mock(InstantiatorWithErrors.class);
    final Parameters expectedParamters = new Parameters(
        Arrays.asList(new Parameter("name", "a"), new Parameter("name", "b")));

    IogiParametersProvider iogiProvider = new IogiParametersProvider(nameProvider, request, mockInstantiator);

    iogiProvider.getParametersFor(anyMethod, errors, null);
View Full Code Here

      return converters.existsFor(target.getClassType(), container);
    }

    public Object instantiate(Target<?> target, Parameters parameters) {
      try {
        Parameter parameter = parameters.namedAfter(target);
        return converterForTarget(target).convert(parameter.getValue(), target.getClassType(), localization.getBundle());
      }
      catch (ConversionError ex) {
        validator.add(new ValidationMessage(ex.getMessage(), target.getName()));
      }
      catch (Exception e) {
View Full Code Here

    Enumeration<?> enumeration = request.getParameterNames();
    while (enumeration.hasMoreElements()) {
      String parameterName = (String) enumeration.nextElement();
      String[] parameterValues = request.getParameterValues(parameterName);
      for (String value : parameterValues) {
        Parameter newParameter = new Parameter(parameterName, value);
        parameterList.add(newParameter);
      }
    }

    return new Parameters(parameterList);
View Full Code Here

TOP

Related Classes of br.com.caelum.iogi.parameters.Parameter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.