final CollectionAccessorFacetViaAccessor collectionAccessorFacetViaMethod = (CollectionAccessorFacetViaAccessor) facet;
assertEquals(collectionAccessorMethod, collectionAccessorFacetViaMethod.getMethods().get(0));
}
public void testMethodFoundInSuperclassButHelpeMethodsFoundInSubclasses() {
final CollectionAccessorFacetFactory facetFactoryForAccessor = new CollectionAccessorFacetFactory();
facetFactoryForAccessor.setSpecificationLookup(reflector);
final CollectionAddRemoveAndValidateFacetFactory facetFactoryForHelpers = new CollectionAddRemoveAndValidateFacetFactory();
facetFactoryForHelpers.setSpecificationLookup(reflector);
@SuppressWarnings("hiding")
class Order {
}
class Customer {
@SuppressWarnings("unused")
public Collection<Order> getOrders() {
return null;
}
}
class CustomerEx extends Customer {
@SuppressWarnings("unused")
public void removeFromOrders(final Order o) {
};
@SuppressWarnings("unused")
public String validateRemoveFromOrders(final Order o) {
return null;
};
}
final Method collectionAccessorMethod = findMethod(Customer.class, "getOrders");
final Method removeFromMethod = findMethod(CustomerEx.class, "removeFromOrders", new Class[] { Order.class });
final Method validateRemoveFromMethod = findMethod(CustomerEx.class, "validateRemoveFromOrders", new Class[] { Order.class });
facetFactoryForAccessor.process(new ProcessMethodContext(CustomerEx.class, null, null, collectionAccessorMethod, methodRemover, facetedMethod));
facetFactoryForHelpers.process(new ProcessMethodContext(CustomerEx.class, null, null, collectionAccessorMethod, methodRemover, facetedMethod));
final Facet facet = facetedMethod.getFacet(CollectionRemoveFromFacet.class);
assertNotNull(facet);
assertTrue(facet instanceof CollectionRemoveFromFacetViaMethod);