podam
podam copied to clipboard
AttributeStrategies have priority over TypeManufacturers
Hello,
Ive implemented my custom StringTypeManufacturerImp like this:
public class CustomStringManufacturer extends StringTypeManufacturerImpl {
@Override
public String getType(DataProviderStrategy strategy, AttributeMetadata attributeMetadata,
Map<String, Type> genericTypesArgumentsMap) {
String attrName = attributeMetadata.getAttributeName().toLowerCase();
System.out.println(attrName );
//some logic based on the name of the attribute.
return super.getType(strategy, attributeMetadata, genericTypesArgumentsMap);
}
getType() function is not getting called for attributes of type String that are annotated with javax.validation.constraints.Size
@Data // lombok
public class Role {
@NotNull (message = "Role Name cannot be null") // this annotation not giving me any issues
@Size(max = 100, message = "Role name must be at most 100 characters")
private String roleName;
}
When i remove the @Size annotation CustomStringManufacturer works as expected.
The problem with this, if we change order of invocation. This will force all TypeManufacturers to implement what currently AttributeStrategies do and will reduce value of AttributeStrategies. While in fact AttributeStrategies are more specific than TypeManufacturers, and in general Podam tries to go from calling more specific strategies over more generic.
Thanks, Daniil