コード例 #1
0
  @Test(expectedExceptions = IllegalArgumentException.class)
  public void illegalParameterIndexCausesException() throws Exception {

    Method method = CustomerRepository.class.getMethod("foo");
    ExecutableMetaData methodMetaData =
        beanMetaData.getMetaDataFor(ExecutableElement.forMethod(method));

    methodMetaData.getParameterMetaData(0);
  }
コード例 #2
0
  @Test
  public void locallyDefinedGroupConversion() throws Exception {

    Method method =
        CustomerRepository.class.getMethod("methodWithParameterGroupConversion", Set.class);
    ExecutableMetaData methodMetaData =
        beanMetaData.getMetaDataFor(ExecutableElement.forMethod(method));

    assertThat(methodMetaData.getParameterMetaData(0).convertGroup(Default.class))
        .isEqualTo(ValidationGroup.class);
  }
コード例 #3
0
  @Test
  public void unconstrainedParameterMetaData() throws Exception {

    Method method = CustomerRepository.class.getMethod("updateCustomer", Customer.class);
    ExecutableMetaData methodMetaData =
        beanMetaData.getMetaDataFor(ExecutableElement.forMethod(method));

    ParameterMetaData parameterMetaData = methodMetaData.getParameterMetaData(0);

    assertFalse(parameterMetaData.isCascading());
    assertFalse(parameterMetaData.isConstrained());
    assertThat(parameterMetaData).isEmpty();
  }
コード例 #4
0
  @Test
  public void cascadingParameterMetaData() throws Exception {

    Method method = CustomerRepository.class.getMethod("saveCustomer", Customer.class);
    ExecutableMetaData methodMetaData =
        beanMetaData.getMetaDataFor(ExecutableElement.forMethod(method));

    ParameterMetaData parameterMetaData = methodMetaData.getParameterMetaData(0);

    assertTrue(parameterMetaData.isCascading());
    assertTrue(parameterMetaData.isConstrained());
    assertEquals(parameterMetaData.getIndex(), 0);
    assertEquals(parameterMetaData.getName(), "arg0");
    assertThat(parameterMetaData).isEmpty();
  }
コード例 #5
0
  @Test
  public void constrainedParameterMetaData() throws Exception {

    Method method =
        CustomerRepository.class.getMethod("createCustomer", CharSequence.class, String.class);
    ExecutableMetaData methodMetaData =
        beanMetaData.getMetaDataFor(ExecutableElement.forMethod(method));

    ParameterMetaData parameterMetaData = methodMetaData.getParameterMetaData(1);

    assertFalse(parameterMetaData.isCascading());
    assertTrue(parameterMetaData.isConstrained());
    assertEquals(parameterMetaData.getIndex(), 1);
    assertEquals(parameterMetaData.getName(), "arg1");
    assertThat(parameterMetaData).hasSize(1);
    assertEquals(
        parameterMetaData.iterator().next().getDescriptor().getAnnotation().annotationType(),
        NotNull.class);
  }