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

    class Customer {
      @SuppressWarnings("unused")
      @Mask("###")
      public int getNumberOfOrders() {
        return 0;
      }
    }
    final Method method = findMethod(Customer.class, "getNumberOfOrders");

    facetFactory.process(
        new ProcessMethodContext(Customer.class, null, null, method, methodRemover, facetedMethod));

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

    class Customer {
      @SuppressWarnings("unused")
      @Mask("###")
      public String getFirstName() {
        return null;
      }
    }
    final Method method = findMethod(Customer.class, "getFirstName");

    facetFactory.process(
        new ProcessMethodContext(Customer.class, null, null, method, methodRemover, facetedMethod));

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