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)); }
@Override public int getParameterCount() { return getFacetedMethod().getParameters().size(); }
public static FacetedMethod createActionFacetedMethod(final Class<?> declaringType, final Method method) { return new FacetedMethod(FeatureType.ACTION, declaringType, method, method.getReturnType(), getParameters(method)); }
@Override public String toString() { return getFeatureType().name() + " Peer [identifier=\"" + getIdentifier() + "\",type=" + getType().getName() + " ]"; }
private FacetedMethod createActionFacetedMethod(final Method actionMethod) { if (!isAllParamTypesValid(actionMethod)) { return null; } final FacetedMethod action = FacetedMethod.createActionFacetedMethod(introspectedClass, actionMethod); // process facets on the action & parameters getFacetProcessor().process(introspectedClass, actionMethod, methodRemover, action, FeatureType.ACTION); final List<FacetedMethodParameter> actionParams = action.getParameters(); for (int j = 0; j < actionParams.size(); j++) { getFacetProcessor().processParams(actionMethod, j, actionParams.get(j)); } return action; }
public void testNoFacetIfPropertyTypeIsNotBigDecimal() throws Exception { final Class<?> cls = SimpleObjectWithBigDecimalColumnAnnotations.class; final Method method = cls.getMethod("getStringPropertyWithColumnAnnotation"); facetFactory.process(new FacetFactory.ProcessMethodContext(cls, null, null, method, methodRemover, facetedMethod)); final Facet facet = facetedMethod.getFacet(BigDecimalValueFacet.class); assertNull(facet); }
final Method disableMethod = findMethod(CustomerEx.class, "disableSomeAction", new Class[] {}); final FacetedMethod facetHolderWithParms = FacetedMethod.createActionFacetedMethod(CustomerEx.class, actionMethod); facetFactoryForDisable.process(processMethodContext); final Facet facet0 = facetHolderWithParms.getFacet(ActionInvocationFacet.class); assertNotNull(facet0); final Facet facet1 = facetHolderWithParms.getParameters().get(0).getFacet(ActionParameterChoicesFacet.class); assertNotNull(facet1); assertTrue(facet1 instanceof ActionParameterChoicesFacetViaMethod); assertEquals(choices0Method, actionChoicesFacetViaMethod0.getMethods().get(0)); final Facet facet2 = facetHolderWithParms.getParameters().get(1).getFacet(ActionParameterChoicesFacet.class); assertNotNull(facet2); assertTrue(facet2 instanceof ActionParameterChoicesFacetViaMethod); assertEquals(choices1Method, actionChoicesFacetViaMethod1.getMethods().get(0)); final Facet facet3 = facetHolderWithParms.getFacet(DisableForContextFacet.class); assertNotNull(facet3); assertTrue(facet3 instanceof DisableForContextFacetViaMethod);
final Method disableMethod = findMethod(CustomerEx.class, "disableSomeAction", new Class[] { int.class, long.class }); final FacetedMethod facetHolderWithParms = FacetedMethod.createForAction(CustomerEx.class, actionMethod, mockSpecificationLoader); facetFactoryForDisable.process(processMethodContext); final Facet facet0 = facetHolderWithParms.getFacet(ActionInvocationFacet.class); assertNotNull(facet0); final Facet facet1 = facetHolderWithParms.getParameters().get(0).getFacet(ActionParameterChoicesFacet.class); assertNotNull(facet1); assertTrue(facet1 instanceof ActionParameterChoicesFacetViaMethod); assertEquals(choices0Method, actionChoicesFacetViaMethod0.getMethods().get(0)); final Facet facet2 = facetHolderWithParms.getParameters().get(1).getFacet(ActionParameterChoicesFacet.class); assertNotNull(facet2); assertTrue(facet2 instanceof ActionParameterChoicesFacetViaMethod); assertEquals(choices1Method, actionChoicesFacetViaMethod1.getMethods().get(0)); final Facet facet3 = facetHolderWithParms.getFacet(DisableForContextFacet.class); assertNotNull(facet3); assertTrue(facet3 instanceof DisableForContextFacetViaMethod);
@Test public void given_noAnnotation_and_configurationSetToIgnoreQueryOnly_andSafeSemantics_thenNone() { // given allowingCommandConfigurationToReturn("ignoreQueryOnly"); final Method actionMethod = findMethod(ActionAnnotationFacetFactoryTest.Customer.class, "someAction"); facetedMethod.addFacet(new ActionSemanticsFacetAbstract(Of.SAFE, facetedMethod) {}); // when facetFactory.processCommand(new ProcessMethodContext(ActionAnnotationFacetFactoryTest.Customer.class, null, null, actionMethod, mockMethodRemover, facetedMethod)); // then final Facet facet = facetedMethod.getFacet(CommandFacet.class); assertNull(facet); }
@Override public int compare(final FacetedMethod o1, final FacetedMethod o2) { final Identifier identifier1 = o1.getIdentifier(); final Identifier identifier2 = o2.getIdentifier(); return identifier1.compareTo(identifier2); }
final Method default1Method = findMethod(Customer.class, "default1SomeAction", new Class[]{}); final FacetedMethod facetHolderWithParms = FacetedMethod.createForAction(Customer.class, actionMethod, mockSpecificationLoader); final Facet facet0 = facetHolderWithParms.getParameters().get(0).getFacet(ActionParameterDefaultsFacet.class); assertNotNull(facet0); assertTrue(facet0 instanceof ActionParameterDefaultsFacetViaMethod); final Facet facet1 = facetHolderWithParms.getParameters().get(1).getFacet(ActionParameterDefaultsFacet.class); assertNotNull(facet1); assertTrue(facet1 instanceof ActionParameterDefaultsFacetViaMethod);
returnType = facetedMethod.getType(); final List<FacetedMethodParameter> parameters = facetedMethod.getParameters(); parameterNames = immutableList(Iterables.transform(parameters, FacetedMethodParameter.Functions.GET_NAME)); parameterTypes = immutableList(Iterables.transform(parameters, FacetedMethodParameter.Functions.GET_TYPE));
public OneToOneAssociationImpl(final FacetedMethod facetedMethod, final ObjectMemberContext objectMemberContext) { super(facetedMethod, FeatureType.PROPERTY, getSpecification(objectMemberContext.getSpecificationLookup(), facetedMethod.getType()), objectMemberContext); }
facetedMethod = FacetedMethod.createForProperty(Customer.class, "firstName"); facetedMethodParameter = new FacetedMethodParameter( FeatureType.ACTION_PARAMETER_SCALAR, facetedMethod.getOwningType(), facetedMethod.getMethod(), String.class );
protected ObjectMemberAbstractImpl(final String id, final ServicesInjector servicesInjector) { super(FacetedMethod.createForProperty(Customer.class, "firstName"), FeatureType.PROPERTY, servicesInjector); }
protected ObjectMemberAbstractImpl(final String id) { super(FacetedMethod.createProperty(Customer.class, "firstName"), FeatureType.PROPERTY, new ObjectMemberContext(null, null, null, null, null)); }
public void testDefaultedMustHaveANoArgConstructor() { facetFactory.process(new ProcessClassContext(MyDefaultedWithoutNoArgConstructor.class, methodRemover, facetedMethod)); final DefaultedFacetAbstract facet = (DefaultedFacetAbstract) facetedMethod.getFacet(DefaultedFacet.class); assertNull(facet); }
final Method default1Method = findMethod(Customer.class, "default1SomeAction", new Class[] {}); final FacetedMethod facetHolderWithParms = FacetedMethod.createActionFacetedMethod(Customer.class, actionMethod); final Facet facet0 = facetHolderWithParms.getParameters().get(0).getFacet(ActionParameterDefaultsFacet.class); assertNotNull(facet0); assertTrue(facet0 instanceof ActionParameterDefaultsFacetViaMethod); final Facet facet1 = facetHolderWithParms.getParameters().get(1).getFacet(ActionParameterDefaultsFacet.class); assertNotNull(facet1); assertTrue(facet1 instanceof ActionParameterDefaultsFacetViaMethod);
@Override public Identifier getIdentifier() { return getFacetedMethod().getIdentifier(); }