public void testInstallsNamedFacetUsingNameMethodAndRemovesMethod() { final NamedFacetViaNameMethodFacetFactory facetFactory = new NamedFacetViaNameMethodFacetFactory(); facetFactory.setSpecificationLookup(reflector); final Method collectionAccessorMethod = findMethod(CustomerStatic.class, "getOrders"); final Method nameMethod = findMethod(CustomerStatic.class, "nameOrders"); facetFactory.process(new ProcessMethodContext(CustomerStatic.class, collectionAccessorMethod, methodRemover, facetedMethod)); final Facet facet = facetedMethod.getFacet(NamedFacet.class); assertNotNull(facet); assertTrue(facet instanceof NamedFacetViaMethod); final NamedFacetViaMethod namedFacet = (NamedFacetViaMethod) facet; assertEquals("Most Recent Orders", namedFacet.value()); assertTrue(methodRemover.getRemovedMethodMethodCalls().contains(nameMethod)); }
public void testInstallsNamedFacetUsingNameMethodAndRemovesMethod() { final NamedFacetViaNameMethodFacetFactory facetFactory = new NamedFacetViaNameMethodFacetFactory(); facetFactory.setSpecificationLookup(reflector); final Method propertyAccessorMethod = findMethod(CustomerStatic.class, "getFirstName"); final Method nameMethod = findMethod(CustomerStatic.class, "nameFirstName"); facetFactory.process(new ProcessMethodContext(CustomerStatic.class, propertyAccessorMethod, methodRemover, facetedMethod)); final Facet facet = facetedMethod.getFacet(NamedFacet.class); assertNotNull(facet); assertTrue(facet instanceof NamedFacetViaMethod); final NamedFacetViaMethod namedFacet = (NamedFacetViaMethod) facet; assertEquals("Given name", namedFacet.value()); assertTrue(methodRemover.getRemovedMethodMethodCalls().contains(nameMethod)); }
public void testInstallsNamedFacetUsingNameMethodAndRemovesMethod() { final NamedFacetViaNameMethodFacetFactory facetFactory = new NamedFacetViaNameMethodFacetFactory(); facetFactory.setSpecificationLookup(reflector); reflector.setLoadSpecificationStringReturn(voidSpec); final Method actionMethod = findMethod(CustomerStatic.class, "someAction", new Class[] { int.class, Long.class }); final Method nameMethod = findMethod(CustomerStatic.class, "nameSomeAction"); facetFactory.process(new ProcessMethodContext(CustomerStatic.class, actionMethod, methodRemover, facetedMethod)); final Facet facet = facetedMethod.getFacet(NamedFacet.class); assertNotNull(facet); assertTrue(facet instanceof NamedFacetAbstract); final NamedFacetAbstract namedFacetAbstract = (NamedFacetAbstract) facet; assertEquals("Another Name", namedFacetAbstract.value()); assertTrue(methodRemover.getRemovedMethodMethodCalls().contains(nameMethod)); }