protected ObjectMemberAbstractImpl(final String id, final ServicesInjector servicesInjector) { super(FacetedMethod.createForProperty(Customer.class, "firstName"), FeatureType.PROPERTY, servicesInjector); }
public void testAnnotationWithEagerlyHintPickedUpOnProperty() { class Customer { @SuppressWarnings({ "deprecation", "unused" }) @org.apache.isis.applib.annotation.Resolve(org.apache.isis.applib.annotation.Resolve.Type.EAGERLY) public int getNumberOfOrders() { return 0; } } facetedMethod = FacetedMethod.createForProperty(Customer.class, "numberOfOrders"); facetFactory.process(new ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), methodRemover, facetedMethod)); final RenderFacet facet = facetedMethod.getFacet(RenderFacet.class); assertThat(facet.value(), is(Render.Type.EAGERLY)); }
public void testAnnotationForLazilyPickedUpOnProperty() { class Customer { @SuppressWarnings({ "deprecation", "unused" }) @org.apache.isis.applib.annotation.Resolve(org.apache.isis.applib.annotation.Resolve.Type.LAZILY) public int getNumberOfOrders() { return 0; } } facetedMethod = FacetedMethod.createForProperty(Customer.class, "numberOfOrders"); facetFactory.process(new ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), methodRemover, facetedMethod)); final RenderFacet facet = facetedMethod.getFacet(RenderFacet.class); assertThat(facet.value(), is(Render.Type.LAZILY)); }
public void testAnnotationForLazilyPickedUpOnProperty() { class Customer { @SuppressWarnings("unused") @Render(Type.LAZILY) public int getNumberOfOrders() { return 0; } } facetedMethod = FacetedMethod.createForProperty(Customer.class, "numberOfOrders"); facetFactory.process(new ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), methodRemover, facetedMethod)); final RenderFacet facet = facetedMethod.getFacet(RenderFacet.class); assertThat(facet.value(), is(Render.Type.LAZILY)); }
public void testAnnotationWithEagerlyHintPickedUpOnProperty() { class Customer { @SuppressWarnings("unused") @Render(Type.EAGERLY) public int getNumberOfOrders() { return 0; } } facetedMethod = FacetedMethod.createForProperty(Customer.class, "numberOfOrders"); facetFactory.process(new ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), methodRemover, facetedMethod)); final RenderFacet facet = facetedMethod.getFacet(RenderFacet.class); assertThat(facet.value(), is(Render.Type.EAGERLY)); }
@Test public void testCssClassAnnotationPickedUpOnProperty() { final CssClassFacetOnMemberFactory facetFactory = new CssClassFacetOnMemberFactory(); class Customer { @CssClass(value = "user") public String getName() { return "Joe"; } } expectNoMethodsRemoved(); facetedMethod = FacetedMethod.createForProperty(Customer.class, "name"); facetFactory.process(new FacetFactory.ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), mockMethodRemover, facetedMethod)); final Facet facet = facetedMethod.getFacet(CssClassFacet.class); assertThat(facet, is(not(nullValue()))); assertThat(facet instanceof CssClassFacetAbstract, is(true)); final CssClassFacetAbstract cssClassFacetAbstract = (CssClassFacetAbstract) facet; assertThat(cssClassFacetAbstract.cssClass(null), equalTo("user")); } }
public void testAnnotationWithNoHintPickedUpOnProperty() { class Customer { @SuppressWarnings({ "deprecation", "unused" }) @org.apache.isis.applib.annotation.Resolve public int getNumberOfOrders() { return 0; } } facetedMethod = FacetedMethod.createForProperty(Customer.class, "numberOfOrders"); facetFactory.process(new ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), methodRemover, facetedMethod)); final Facet facet = facetedMethod.getFacet(RenderFacet.class); assertNotNull(facet); assertTrue(facet instanceof RenderFacetViaResolveAnnotation); RenderFacet resolveFacet = (RenderFacet) facet; assertThat(resolveFacet.value(), is(Render.Type.EAGERLY)); assertNoMethodsRemoved(); }
public void testAnnotationWithNoHintPickedUpOnProperty() { class Customer { @SuppressWarnings("unused") @Render public int getNumberOfOrders() { return 0; } } facetedMethod = FacetedMethod.createForProperty(Customer.class, "numberOfOrders"); facetFactory.process(new ProcessMethodContext(Customer.class, null, null, facetedMethod.getMethod(), methodRemover, facetedMethod)); final Facet facet = facetedMethod.getFacet(RenderFacet.class); assertNotNull(facet); assertTrue(facet instanceof RenderFacetAnnotation); RenderFacet resolveFacet = (RenderFacet) facet; assertThat(resolveFacet.value(), is(Render.Type.EAGERLY)); assertNoMethodsRemoved(); }
private FacetedMethod facetedMethodForProperty( Method init, Method accessor, Method modify, Method clear, Method hide, Method disable, Method validate) { FacetedMethod facetedMethod = FacetedMethod.createForProperty(accessor.getDeclaringClass(), accessor); FacetUtil.addFacet(new PropertyAccessorFacetViaAccessor(mockOnType, accessor, facetedMethod, mockSpecificationLoader, mockAuthenticationSessionProvider, mockAdapterManager )); FacetUtil.addFacet(new PropertyInitializationFacetViaSetterMethod(init, facetedMethod)); FacetUtil.addFacet(new PropertySetterFacetViaModifyMethod(modify, facetedMethod)); FacetUtil.addFacet(new PropertyClearFacetViaClearMethod(clear, facetedMethod)); FacetUtil.addFacet(new HideForContextFacetViaMethod(hide, facetedMethod)); FacetUtil.addFacet(new DisableForContextFacetViaMethod(disable, null, null, facetedMethod)); FacetUtil.addFacet(new PropertyValidateFacetViaMethod(validate, null, null, facetedMethod)); FacetUtil.addFacet(new NamedFacetInferred(accessor.getName(), facetedMethod)); return facetedMethod; }
private FacetedMethod facetedMethodForProperty( Method init, Method accessor, Method modify, Method clear, Method hide, Method disable, Method validate) { FacetedMethod facetedMethod = FacetedMethod.createForProperty(accessor.getDeclaringClass(), accessor); FacetUtil.addFacet(new PropertyAccessorFacetViaAccessor(mockOnType, accessor, facetedMethod, mockDeploymentCategoryProvider.getDeploymentCategory(), mockConfiguration, mockSpecificationLoader, mockAuthenticationSessionProvider, mockAdapterManager )); FacetUtil.addFacet(new PropertyInitializationFacetViaSetterMethod(init, facetedMethod)); FacetUtil.addFacet(new PropertySetterFacetViaModifyMethod(modify, facetedMethod)); FacetUtil.addFacet(new PropertyClearFacetViaClearMethod(clear, facetedMethod)); FacetUtil.addFacet(new HideForContextFacetViaMethod(hide, facetedMethod)); FacetUtil.addFacet(new DisableForContextFacetViaMethod(disable, null, null, facetedMethod)); FacetUtil.addFacet(new PropertyValidateFacetViaMethod(validate, null, null, facetedMethod)); FacetUtil.addFacet(new NamedFacetInferred(accessor.getName(), facetedMethod)); return facetedMethod; }
@Before public void setup() { facetedMethod = FacetedMethod.createForProperty(Customer.class, "firstName");
@Before public void setup() { facetedMethod = FacetedMethod.createForProperty(Customer.class, "firstName");
facetedMethod = FacetedMethod.createForProperty(Customer.class, "firstName"); facetedMethodParameter = new FacetedMethodParameter( FeatureType.ACTION_PARAMETER_SCALAR, facetedMethod.getOwningType(), facetedMethod.getMethod(), String.class
@Before public void setUpFacetedMethodAndParameter() throws Exception { context.checking(new Expectations() {{ allowing(mockServicesInjector).getDeploymentCategoryProvider(); will(returnValue(mockDeploymentCategoryProvider)); allowing(mockServicesInjector).lookupService(DeploymentCategoryProvider.class); will(returnValue(mockDeploymentCategoryProvider)); allowing(mockDeploymentCategoryProvider).getDeploymentCategory(); will(returnValue(DeploymentCategory.PRODUCTION)); allowing(mockServicesInjector).getConfigurationServiceInternal(); will(returnValue(mockConfiguration)); allowing(mockServicesInjector).getPersistenceSessionServiceInternal(); will(returnValue(mockPersistenceSessionServiceInternal)); allowing(mockServicesInjector).lookupService(TranslationService.class); will(returnValue(mockTranslationService)); allowing(mockServicesInjector).getAuthenticationSessionProvider(); will(returnValue(mockAuthenticationSessionProvider)); allowing(mockServicesInjector).lookupService(AuthenticationSessionProvider.class); will(returnValue(mockAuthenticationSessionProvider)); allowing(mockServicesInjector).getSpecificationLoader(); will(returnValue(mockSpecificationLoader)); }}); facetHolder = new AbstractFacetFactoryTest.IdentifiedHolderImpl(Identifier.propertyOrCollectionIdentifier(Customer.class, "firstName")); facetedMethod = FacetedMethod.createForProperty(AbstractFacetFactoryTest.Customer.class, "firstName"); facetedMethodParameter = new FacetedMethodParameter(FeatureType.ACTION_PARAMETER_SCALAR, facetedMethod.getOwningType(), facetedMethod.getMethod(), String.class ); }