コード例 #1
0
  public void testMaskAnnotationNotIgnoredForPrimitiveOnActionParameter() {
    final MaskAnnotationForParameterFacetFactory facetFactory =
        new MaskAnnotationForParameterFacetFactory();
    facetFactory.setSpecificationLookup(reflector);

    class Customer {
      @SuppressWarnings("unused")
      public void someAction(@Mask("###") final int foo) {}
    }
    final Method method = findMethod(Customer.class, "someAction", new Class[] {int.class});

    facetFactory.processParams(new ProcessParameterContext(method, 0, facetedMethodParameter));

    assertNotNull(facetedMethodParameter.getFacet(MaskFacet.class));
  }
コード例 #2
0
  public void testMaskAnnotationPickedUpOnActionParameter() {
    final MaskAnnotationForParameterFacetFactory facetFactory =
        new MaskAnnotationForParameterFacetFactory();
    facetFactory.setSpecificationLookup(reflector);

    class Customer {
      @SuppressWarnings("unused")
      public void someAction(@Mask("###") final String foo) {}
    }
    final Method method = findMethod(Customer.class, "someAction", new Class[] {String.class});

    facetFactory.processParams(new ProcessParameterContext(method, 0, facetedMethodParameter));

    final Facet facet = facetedMethodParameter.getFacet(MaskFacet.class);
    assertNotNull(facet);
    assertTrue(facet instanceof MaskFacetAnnotationForParameter);
    final MaskFacetAnnotationForParameter maskFacet = (MaskFacetAnnotationForParameter) facet;
    assertEquals("###", maskFacet.value());
  }