diff --git a/annotations.html b/annotations.html old mode 100644 new mode 100755 index a79215a88..22da2267b --- a/annotations.html +++ b/annotations.html @@ -1,5 +1,5 @@ - +
@@ -10,7 +10,7 @@ @import url("./css/site.css"); - + @@ -27,7 +27,7 @@For the full syntax of PODAM annotations, please refer to the Javadocs
-This is probably the most valuable annotation of all. It allows users to define the strategy PODAM should use at the attribute level. To create a custom strategy, create an implementation of the AttributeStrategy<T> interface and use it in the value attribute of this annotation.
-Example:
--@PodamStrategyValue(PostCodeStrategy.class) -private String postCode; - -@PodamStrategyValue(MyBirthdayStrategy.class) -private Calendar myBirthday; -
It allows the customisation of boolean / Boolean attributes.
-Attribute | -Description |
boolValue | -It dictates the value that will be assigned to the annotated attribute. Can only be true or false |
Example:
--/** A boolean field with value forced to true */ -@PodamBooleanValue(boolValue = true) -private boolean boolDefaultToTrue; - -/** A boolean field with value forced to false */ -@PodamBooleanValue(boolValue = false) -private boolean boolDefaultToFalse = true; -
It allows the customisation of byte / Byte attributes.
-Attribute | -Description |
numValue | -Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute |
minValue | -It identifies the minimum value (inclusive) that the annotated attribute will be assigned. |
maxValue | -It identifies the maximum value (inclusive) that the annotated attribute will be assigned. |
Example:
--@PodamByteValue(minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE) -private byte byteFieldWithMinValueOnly; - -@PodamByteValue(maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED) -private byte byteFieldWithMaxValueOnly; - -@PodamByteValue(minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE, maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED) -private byte byteFieldWithMinAndMaxValue; - -@PodamByteValue(numValue = PodamTestConstants.BYTE_PRECISE_VALUE) -private byte byteFieldWithPreciseValue; -
It allows the customisation of short / Short attributes.
-Attribute | -Description |
numValue | -Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute |
minValue | -It identifies the minimum value (inclusive) that the annotated attribute will be assigned. |
maxValue | -It identifies the maximum value (inclusive) that the annotated attribute will be assigned. |
Example:
--@PodamShortValue(minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE) -private short shortFieldWithMinValueOnly; - -@PodamShortValue(maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED) -private short shortFieldWithMaxValueOnly; - -@PodamShortValue(minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE, maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED) -private short shortFieldWithMinAndMaxValue; - -@PodamShortValue(numValue = PodamTestConstants.SHORT_PRECISE_VALUE) -private short shortFieldWithPreciseValue; -
It allows the customisation of char / Character attributes.
-Attribute | -Description |
charValue | -Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute |
minValue | -It identifies the minimum value (inclusive) that the annotated attribute will be assigned. |
maxValue | -It identifies the maximum value (inclusive) that the annotated attribute will be assigned. |
Example:
--@PodamCharValue(minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE) -private char charFieldWithMinValueOnly; - -@PodamCharValue(maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED) -private char charFieldWithMaxValueOnly; - -@PodamCharValue(minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE, maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED) -private char charFieldWithMinAndMaxValue; - -@PodamCharValue(charValue = PodamTestConstants.CHAR_PRECISE_VALUE) -private char charFieldWithPreciseValue; -
It allows the customisation of int / Integer attributes.
-Attribute | -Description |
numValue | -Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute |
minValue | -It identifies the minimum value (inclusive) that the annotated attribute will be assigned. |
maxValue | -It identifies the maximum value (inclusive) that the annotated attribute will be assigned. |
Example:
--@PodamIntValue(minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE) -private int intFieldWithMinValueOnly; - -@PodamIntValue(numValue = PodamTestConstants.INTEGER_PRECISE_VALUE) -private int intFieldWithPreciseValue; - -@PodamIntValue(maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED) -private int intFieldWithMaxValueOnly; - -@PodamIntValue(numValue = PodamTestConstants.INTEGER_PRECISE_VALUE) -private Integer integerObjectFieldWithPreciseValue; -
It allows the customisation of long / Long attributes.
-Attribute | -Description |
numValue | -Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute |
minValue | -It identifies the minimum value (inclusive) that the annotated attribute will be assigned. |
maxValue | -It identifies the maximum value (inclusive) that the annotated attribute will be assigned. |
Example:
--@PodamLongValue(minValue = 0) -private long longFieldWithMinValueOnly; - -@PodamLongValue(maxValue = 100) -private long longFieldWithMaxValueOnly; - -@PodamLongValue(minValue = 0, maxValue = 1000) -private long longFieldWithMinAndMaxValue; - -@PodamLongValue(numValue = PodamTestConstants.LONG_PRECISE_VALUE) -private Long longObjectFieldWithPreciseValue; -
It allows the customisation of float / Float attributes.
-Attribute | -Description |
numValue | -Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute |
minValue | -It identifies the minimum value (inclusive) that the annotated attribute will be assigned. |
maxValue | -It identifies the maximum value (inclusive) that the annotated attribute will be assigned. |
Example:
--@PodamFloatValue(minValue = PodamTestConstants.NUMBER_FLOAT_MIN_VALUE) -private float floatFieldWithMinValueOnly; - -@PodamFloatValue(maxValue = PodamTestConstants.NUMBER_FLOAT_ONE_HUNDRED) -private float floatFieldWithMaxValueOnly; - -@PodamFloatValue(minValue = PodamTestConstants.NUMBER_FLOAT_MIN_VALUE, maxValue = PodamTestConstants.NUMBER_FLOAT_MAX_VALUE) -private float floatFieldWithMinAndMaxValue; - -@PodamFloatValue(numValue = PodamTestConstants.FLOAT_PRECISE_VALUE) -private Float floatObjectFieldWithPreciseValue; -
It allows the customisation of double / Double attributes.
-Attribute | -Description |
numValue | -Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute |
minValue | -It identifies the minimum value (inclusive) that the annotated attribute will be assigned. |
maxValue | -It identifies the maximum value (inclusive) that the annotated attribute will be assigned. |
Example:
--@PodamDoubleValue(minValue = PodamTestConstants.NUMBER_DOUBLE_MIN_VALUE) -private double doubleFieldWithMinValueOnly; - -@PodamDoubleValue(maxValue = PodamTestConstants.NUMBER_DOUBLE_ONE_HUNDRED) -private double doubleFieldWithMaxValueOnly; - -@PodamDoubleValue(minValue = PodamTestConstants.NUMBER_DOUBLE_MIN_VALUE, maxValue = PodamTestConstants.NUMBER_DOUBLE_MAX_VALUE) -private double doubleFieldWithMinAndMaxValue; - -@PodamDoubleValue(numValue = PodamTestConstants.DOUBLE_PRECISE_VALUE) -private Double doubleObjectFieldWithPreciseValue; -
It allows the customisation of String attributes
-Attribute | -Description |
strValue | -Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute |
length | -It defines how long the string shall be. This attribute will be taken into consideration only if strValue has not been defined. |
Example:
--@PodamStringValue(length = PodamTestConstants.STR_ANNOTATION_TWENTY_LENGTH) -/** A String attribute with length 20 */ -private String twentyLengthString; - -@PodamStringValue(strValue = PodamTestConstants.STR_ANNOTATION_PRECISE_VALUE) -private String preciseValueString; -
It allows the customisation of container-like data structures, such as Collections, Maps and Arrays. The default strategy for all container-like data structure is uk.co.jemos.podam.annotations.strategies.ObjectStrategy whose behaviour is to return a new Object instance. This strategy will be used only if the container element type is Object itself. Otherwise the element type wins.
-Attribute | -Description |
nbrElements | -It defines how many elements should be created for the container-like data structure |
collectionElementStrategy | -It defines which AttributeStrategy<T> should be used to fill each element in the collection. Used for Collections and Arrays. Not used for Maps. |
mapKeyStrategy | -It defines which AttributeStrategy<T> should be used to fill keys of a Map. Used only for Maps |
mapElementStrategy | -It defines which AttributeStrategy<T> should be used to fill elements of a Map. Used only for Maps |
Example for a Collection. It will fill a ListCalendar with two elements. Each element will be filled according to the MyBirthdayStrategy strategy.
--@PodamCollection(nbrElements = 2, collectionElementStrategy = MyBirthdayStrategy.class) -private List<Calendar> myBirthdays = new ArrayList<Calendar>(); -
Example for a Map. It will fill a MapString, Calendar with two elements. Each Map element will be filled according to the MyBirthdayStrategy strategy.
--@PodamCollection(nbrElements = 2, mapElementStrategy = MyBirthdayStrategy.class) -private Map<String, Calendar> myBirthdaysMap = new HashMap<String, Calendar>(); -
Example for an Array. It will fill an array of Calendars. Each array element will be filled according to the MyBirthdayStrategy strategy.
--@PodamCollection(nbrElements = 2, collectionElementStrategy = MyBirthdayStrategy.class) -private Calendar[] myBirthdaysArray; -
Allows a constructor to be identified in a setter-less POJO. This is a PODAM requirement: for those POJOs without setters (e.g. immutable classes) a constructor annotated with this annotations is required. @PodamConstructor can be used as a marker interface.
-Attribute | -Description |
comment | -It allows users to write a comment on the use of this annotation |
Example:
-/** - * - */ -package uk.co.jemos.podam.test.dto; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.Calendar; - -import net.jcip.annotations.Immutable; -import uk.co.jemos.podam.annotations.PodamConstructor; - -/** - * This is an immutable POJO to test PODAM's ability to create an instance which - * hasn't got setters - * - * @author mtedone - * - */ -@Immutable -public class ImmutableNoHierarchicalAnnotatedPojo implements Serializable { - - private static final long serialVersionUID = 1L; - - - /** An int field */ - private final int intField; - - /** A Calendar field */ - private final Calendar dateCreated; - - /** An array of longs */ - private final long[] longArray; - - /** - * Full constructor - * - * @param intField - * @param dateCreated - * @param longArray - */ - @PodamConstructor - public ImmutableNoHierarchicalAnnotatedPojo(int intField, Calendar dateCreated, - long[] longArray) { - super(); - this.intField = intField; - this.dateCreated = dateCreated; - this.longArray = longArray; - } - - - /** - * @return the intField - */ - public int getIntField() { - return intField; - } - - /** - * @return the dateCreated - */ - public Calendar getDateCreated() { - return dateCreated; - } - - /** - * @return the longArray - */ - public long[] getLongArray() { - return longArray; - } - - -} -
This annotation is used to instruct PODAM to skip the initialisation of a certain attribute.
-Attribute | -Description |
comment | -It allows users to write a comment on the use of this annotation |
Example:
-- public class Pojo { - - /** PODAM will not fill this attribute */ - @PodamExclude - private SimplePojoToTestSetters somePojo; - } -
An alternative to this annotation is reloading ClassInfoStrategy.getExcludedFields()
-Example:
-- private final static DefaultClassInfoStrategy classInfoStrategy = - DefaultClassInfoStrategy.getInstance(); - classInfoStrategy.addExcludedField(Pojo.class, "somePojo"); ++Podam Custom Annotations
+For the full syntax of PODAM annotations, please refer to the Javadocs
+++@PodamStrategyValue
+This is probably the most valuable annotation of all. It allows users to define the strategy PODAM should use at the attribute level. To create a custom strategy, create an implementation of the AttributeStrategy<T> interface and use it in the value attribute of this annotation.
+Example:
+++@PodamStrategyValue(PostCodeStrategy.class) +private String postCode; + +@PodamStrategyValue(MyBirthdayStrategy.class) +private Calendar myBirthday; + +++@PodamBooleanValue
+It allows the customisation of boolean / Boolean attributes.
++
++ +Attribute +Description + boolValue +It dictates the value that will be assigned to the annotated attribute. Can only be true or false Example:
++++/** A boolean field with value forced to true */ +@PodamBooleanValue(boolValue = true) +private boolean boolDefaultToTrue; + +/** A boolean field with value forced to false */ +@PodamBooleanValue(boolValue = false) +private boolean boolDefaultToFalse = true; + +++@PodamByteValue
+It allows the customisation of byte / Byte attributes.
++
++ +Attribute +Description + +numValue +Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute + +minValue +It identifies the minimum value (inclusive) that the annotated attribute will be assigned. + maxValue +It identifies the maximum value (inclusive) that the annotated attribute will be assigned. Example:
++++@PodamByteValue(minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE) +private byte byteFieldWithMinValueOnly; + +@PodamByteValue(maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED) +private byte byteFieldWithMaxValueOnly; + +@PodamByteValue(minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE, maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED) +private byte byteFieldWithMinAndMaxValue; + +@PodamByteValue(numValue = PodamTestConstants.BYTE_PRECISE_VALUE) +private byte byteFieldWithPreciseValue; + +++@PodamShortValue
+It allows the customisation of short / Short attributes.
++
++ +Attribute +Description + +numValue +Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute + +minValue +It identifies the minimum value (inclusive) that the annotated attribute will be assigned. + maxValue +It identifies the maximum value (inclusive) that the annotated attribute will be assigned. Example:
++++@PodamShortValue(minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE) +private short shortFieldWithMinValueOnly; + +@PodamShortValue(maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED) +private short shortFieldWithMaxValueOnly; + +@PodamShortValue(minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE, maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED) +private short shortFieldWithMinAndMaxValue; + +@PodamShortValue(numValue = PodamTestConstants.SHORT_PRECISE_VALUE) +private short shortFieldWithPreciseValue; + +++@PodamCharValue
+It allows the customisation of char / Character attributes.
++
++ +Attribute +Description + +charValue +Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute + +minValue +It identifies the minimum value (inclusive) that the annotated attribute will be assigned. + maxValue +It identifies the maximum value (inclusive) that the annotated attribute will be assigned. Example:
++++@PodamCharValue(minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE) +private char charFieldWithMinValueOnly; + +@PodamCharValue(maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED) +private char charFieldWithMaxValueOnly; + +@PodamCharValue(minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE, maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED) +private char charFieldWithMinAndMaxValue; + +@PodamCharValue(charValue = PodamTestConstants.CHAR_PRECISE_VALUE) +private char charFieldWithPreciseValue; + +++@PodamIntValue
+It allows the customisation of int / Integer attributes.
++
++ +Attribute +Description + +numValue +Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute + +minValue +It identifies the minimum value (inclusive) that the annotated attribute will be assigned. + maxValue +It identifies the maximum value (inclusive) that the annotated attribute will be assigned. Example:
++++@PodamIntValue(minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE) +private int intFieldWithMinValueOnly; + +@PodamIntValue(numValue = PodamTestConstants.INTEGER_PRECISE_VALUE) +private int intFieldWithPreciseValue; + +@PodamIntValue(maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED) +private int intFieldWithMaxValueOnly; + +@PodamIntValue(numValue = PodamTestConstants.INTEGER_PRECISE_VALUE) +private Integer integerObjectFieldWithPreciseValue; + +++@PodamLongValue
+It allows the customisation of long / Long attributes.
++
++ +Attribute +Description + +numValue +Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute + +minValue +It identifies the minimum value (inclusive) that the annotated attribute will be assigned. + maxValue +It identifies the maximum value (inclusive) that the annotated attribute will be assigned. Example:
++++@PodamLongValue(minValue = 0) +private long longFieldWithMinValueOnly; + +@PodamLongValue(maxValue = 100) +private long longFieldWithMaxValueOnly; + +@PodamLongValue(minValue = 0, maxValue = 1000) +private long longFieldWithMinAndMaxValue; + +@PodamLongValue(numValue = PodamTestConstants.LONG_PRECISE_VALUE) +private Long longObjectFieldWithPreciseValue; + +++@PodamFloatValue
+It allows the customisation of float / Float attributes.
++
++ +Attribute +Description + +numValue +Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute + +minValue +It identifies the minimum value (inclusive) that the annotated attribute will be assigned. + maxValue +It identifies the maximum value (inclusive) that the annotated attribute will be assigned. Example:
++++@PodamFloatValue(minValue = PodamTestConstants.NUMBER_FLOAT_MIN_VALUE) +private float floatFieldWithMinValueOnly; + +@PodamFloatValue(maxValue = PodamTestConstants.NUMBER_FLOAT_ONE_HUNDRED) +private float floatFieldWithMaxValueOnly; + +@PodamFloatValue(minValue = PodamTestConstants.NUMBER_FLOAT_MIN_VALUE, maxValue = PodamTestConstants.NUMBER_FLOAT_MAX_VALUE) +private float floatFieldWithMinAndMaxValue; + +@PodamFloatValue(numValue = PodamTestConstants.FLOAT_PRECISE_VALUE) +private Float floatObjectFieldWithPreciseValue; + +++@PodamDoubleValue
+It allows the customisation of double / Double attributes.
++
++ +Attribute +Description + +numValue +Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute + +minValue +It identifies the minimum value (inclusive) that the annotated attribute will be assigned. + maxValue +It identifies the maximum value (inclusive) that the annotated attribute will be assigned. Example:
++++@PodamDoubleValue(minValue = PodamTestConstants.NUMBER_DOUBLE_MIN_VALUE) +private double doubleFieldWithMinValueOnly; + +@PodamDoubleValue(maxValue = PodamTestConstants.NUMBER_DOUBLE_ONE_HUNDRED) +private double doubleFieldWithMaxValueOnly; + +@PodamDoubleValue(minValue = PodamTestConstants.NUMBER_DOUBLE_MIN_VALUE, maxValue = PodamTestConstants.NUMBER_DOUBLE_MAX_VALUE) +private double doubleFieldWithMinAndMaxValue; + +@PodamDoubleValue(numValue = PodamTestConstants.DOUBLE_PRECISE_VALUE) +private Double doubleObjectFieldWithPreciseValue; + +++@PodamStringValue
+It allows the customisation of String attributes
++
++ +Attribute +Description + +strValue +Takes precedence over all other attributes. It dictates the value that will be assigned to the annotated attribute + length +It defines how long the string shall be. This attribute will be taken into consideration only if strValue has not been defined. Example:
++++@PodamStringValue(length = PodamTestConstants.STR_ANNOTATION_TWENTY_LENGTH) +/** A String attribute with length 20 */ +private String twentyLengthString; + +@PodamStringValue(strValue = PodamTestConstants.STR_ANNOTATION_PRECISE_VALUE) +private String preciseValueString; + +++@PodamCollection
+It allows the customisation of container-like data structures, such as Collections, Maps and Arrays. The default strategy for all container-like data structure is uk.co.jemos.podam.annotations.strategies.ObjectStrategy whose behaviour is to return a new Object instance. This strategy will be used only if the container element type is Object itself. Otherwise the element type wins.
++
++ +Attribute +Description + +nbrElements +It defines how many elements should be created for the container-like data structure + +collectionElementStrategy +It defines which AttributeStrategy<T> should be used to fill each element in the collection. Used for Collections and Arrays. Not used for Maps. + +mapKeyStrategy +It defines which AttributeStrategy<T> should be used to fill keys of a Map. Used only for Maps + mapElementStrategy +It defines which AttributeStrategy<T> should be used to fill elements of a Map. Used only for Maps Example for a Collection. It will fill a ListCalendar with two elements. Each element will be filled according to the MyBirthdayStrategy strategy.
++++@PodamCollection(nbrElements = 2, collectionElementStrategy = MyBirthdayStrategy.class) +private List<Calendar> myBirthdays = new ArrayList<Calendar>(); + +Example for a Map. It will fill a MapString, Calendar with two elements. Each Map element will be filled according to the MyBirthdayStrategy strategy.
++++@PodamCollection(nbrElements = 2, mapElementStrategy = MyBirthdayStrategy.class) +private Map<String, Calendar> myBirthdaysMap = new HashMap<String, Calendar>(); + +Example for an Array. It will fill an array of Calendars. Each array element will be filled according to the MyBirthdayStrategy strategy.
++++@PodamCollection(nbrElements = 2, collectionElementStrategy = MyBirthdayStrategy.class) +private Calendar[] myBirthdaysArray; + +++@PodamConstructor
+Allows a constructor to be identified in a setter-less POJO. This is a PODAM requirement: for those POJOs without setters (e.g. immutable classes) a constructor annotated with this annotations is required. @PodamConstructor can be used as a marker interface.
++
++ +Attribute +Description + comment +It allows users to write a comment on the use of this annotation Example:
+++/** + * + */ +package uk.co.jemos.podam.test.dto; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.Calendar; + +import net.jcip.annotations.Immutable; +import uk.co.jemos.podam.annotations.PodamConstructor; + +/** + * This is an immutable POJO to test PODAM's ability to create an instance which + * hasn't got setters + * + * @author mtedone + * + */ +@Immutable +public class ImmutableNoHierarchicalAnnotatedPojo implements Serializable { + + private static final long serialVersionUID = 1L; + + + /** An int field */ + private final int intField; + + /** A Calendar field */ + private final Calendar dateCreated; + + /** An array of longs */ + private final long[] longArray; + + /** + * Full constructor + * + * @param intField + * @param dateCreated + * @param longArray + */ + @PodamConstructor + public ImmutableNoHierarchicalAnnotatedPojo(int intField, Calendar dateCreated, + long[] longArray) { + super(); + this.intField = intField; + this.dateCreated = dateCreated; + this.longArray = longArray; + } + + + /** + * @return the intField + */ + public int getIntField() { + return intField; + } + + /** + * @return the dateCreated + */ + public Calendar getDateCreated() { + return dateCreated; + } + + /** + * @return the longArray + */ + public long[] getLongArray() { + return longArray; + } + + +} + ++@PodamExclude
+This annotation is used to instruct PODAM to skip the initialisation of a certain attribute.
++
++ +Attribute +Description + comment +It allows users to write a comment on the use of this annotation Example:
++++ public class Pojo { + + /** PODAM will not fill this attribute */ + @PodamExclude + private SimplePojoToTestSetters somePojo; + } + +An alternative to this annotation is reloading ClassInfoStrategy.getExcludedFields()
+Example:
+++ private final static DefaultClassInfoStrategy classInfoStrategy = + DefaultClassInfoStrategy.getInstance(); + classInfoStrategy.addExcludedField(Pojo.class, "somePojo"); +
In the Walk-through page we documented the most common scenarios where you would want to use PODAM. These include:
-In this page I will show how PODAM handles some corner cases, such as:
-PODAM supports inheritance. It will fill parent attributes if an accessible setter is available to the POJOs which you are filling with data.
-The following example illustrates a parent class, uk.co.jemos.podam.test.dto.AbstractOneDimensionalPojo which is extended by another POJO, uk.co.jemos.podam.test.dto.OneDimensionalChildPojo.
-/** - * - */ -package uk.co.jemos.podam.test.dto; - -import java.util.Calendar; - -import uk.co.jemos.podam.annotations.PodamIntValue; - -/** - * Abstract POJO to test inheritance. - * - * @author mtedone - * - */ -public abstract class AbstractOneDimensionalPojo { - - @PodamIntValue(maxValue = 10) - private int parentIntField; - - private Calendar parentCalendarField; - - public int getParentIntField() { - return parentIntField; - } - - protected void setParentIntField(int parentIntField) { - this.parentIntField = parentIntField; - } - - public Calendar getParentCalendarField() { - return parentCalendarField; - } - - protected void setParentCalendarField(Calendar parentCalendarField) { - this.parentCalendarField = parentCalendarField; - } - - @Override - public String toString() { - final String TAB = " "; - - StringBuilder retValue = new StringBuilder(); - - retValue.append("AbstractOneDimensionalPojo ( ") - .append("parentIntField = ").append(parentIntField).append(TAB) - .append("parentCalendarField = ").append(parentCalendarField.getTime()) - .append(TAB).append(" )"); - - return retValue.toString(); - } -} -
The class above defines two private attributes, parentIntField and parentCalendarField. It also provides two protected setters which are available to sub-classes. The presence of accessible setter methods is a pre-requisite for this inheritance to be handled properly by PODAM.
-This is the child class:
--/** - * - */ -package uk.co.jemos.podam.test.dto; - -/** - * A child class to test inheritance - * @author mtedone - * - */ -public class OneDimensionalChildPojo extends AbstractOneDimensionalPojo { - - private int intField; - - private String strField; - - public OneDimensionalChildPojo() { - super(); - } - - public int getIntField() { - return intField; - } - - public void setIntField(int intField) { - this.intField = intField; - } - - public String getStrField() { - return strField; - } - - public void setStrField(String strField) { - this.strField = strField; - } - - /** - * Constructs a <code>String</code> with all attributes in name = value - * format. - * - * @return a <code>String</code> representation of this object. - */ - @Override - public String toString() { - final String TAB = " "; - - StringBuilder retValue = new StringBuilder(); - retValue.append(super.toString()).append(TAB); - - retValue.append("OneDimensionalChildPojo ( ").append("intField = ") - .append(intField).append(TAB).append("strField = ") - .append(strField).append(TAB).append(" )"); - - return retValue.toString(); - } - -} - -
Running PODAM on the OneDimensionalChildPojo class will produce the following toString() result:
-AbstractOneDimensionalPojo ( parentIntField = 3 parentCalendarField = Sat Apr 30 13:49:49 BST 2011 ) - OneDimensionalChildPojo ( intField = -516418302 strField = ﶖ藾冋荬馫콈愁㵼藙酬 )
As you can see Podam has set both the parent attributes values.
A Singleton is a class which provides only an instance of itself. One of the implementation details of a Singleton is that, unless one used an Enum, the class should forbid clients from creating new instances. This is typically achieved by declaring the constructor private and by providing a public static method (e.g. getInstance()) which returns a singleton instance of the class.
-PODAM handles Singleton-like classes, as the following example demonstrates:
-/** - * - */ -package uk.co.jemos.podam.test.dto; - -import java.io.Serializable; -import java.util.Calendar; -import java.util.List; -import java.util.Map; - -/** - * A POJO to test a Singleton-like scenario where the public static Singleton - * method contains parameters. - * - * @author mtedone - * - */ -public class SingletonWithParametersInStaticFactoryPojo implements Serializable { - - private static final long serialVersionUID = 1L; - - private final Calendar createDate; - - private final List<OneDimensionalTestPojo> pojoList; - - private final Map<String, OneDimensionalTestPojo> pojoMap; - - private final String firstName; - - private static SingletonWithParametersInStaticFactoryPojo singleton; - - // ------------------->> Constructors - - /** - * A private constructor to enforce the Singleton pattern - * - * @param createDate - * The creation date - * @param pojoList - * A list - * @param pojoMap - * A map - * @param firstName - * The first name - */ - private SingletonWithParametersInStaticFactoryPojo(Calendar createDate, - List<OneDimensionalTestPojo> pojoList, - Map<String, OneDimensionalTestPojo> pojoMap, String firstName) { - super(); - this.createDate = createDate; - this.pojoList = pojoList; - this.pojoMap = pojoMap; - this.firstName = firstName; - } - - - /** - * Singleton method - * - * @param createDate - * The creation date - * @param pojoList - * A list - * @param pojoMap - * A map - * @param firstName - * The first name - * @return a singleton instance of this class - */ - public static SingletonWithParametersInStaticFactoryPojo getInstance( - Calendar createDate, List<OneDimensionalTestPojo> pojoList, - Map<String, OneDimensionalTestPojo> pojoMap, String firstName) { - if (null == singleton) { - singleton = new SingletonWithParametersInStaticFactoryPojo( - createDate, pojoList, pojoMap, firstName); - } - - return singleton; - } - - public Calendar getCreateDate() { - return createDate; - } - - public List<OneDimensionalTestPojo> getPojoList() { - return pojoList; - } - - public Map<String, OneDimensionalTestPojo> getPojoMap() { - return pojoMap; - } - - public String getFirstName() { - return firstName; - } - -} -
The class above shows an interesting scenario: a Singleton-like class with the Singleton method which accepts parameters. To make the example even more palatable, some arguments are container-like (collections, maps).
-Running the test on the class above produces the following result:
-SingletonWithParametersInStaticFactoryPojo ( - createDate = Sat Apr 30 14:05:21 BST 2011 - pojoList = [ - OneDimensionalTestPojo ( booleanField = true booleanObjectField = true byteField = 116 - byteObjectField = 10 shortField = 77 shortObjectField = 4 charField = 㐘 - charObjectField = ꪁ intField = 1339494839 intObjectField = 980291811 - longField = -3119222069530856219 longObjectField = 4260197822662475631 - floatField = 0.24369287 floatObjectField = 0.7073253 doubleField = 0.7151146071422815 - doubleObjectField = 0.8253745751884359 stringField = ౠ᮷᳃┸㯪쭵Ὼాꎐᆫ - objectField = java.lang.Object@57a7ddcf calendarField = Sat Apr 30 14:05:21 BST 2011 - dateField = Sat Apr 30 14:05:21 BST 2011 randomArray = [Ljava.util.Random;@4dd36dfe )] - pojoMap = { - 研䷢쫗㛗á룸ꁧ╝楫=OneDimensionalTestPojo ( booleanField = false booleanObjectField = true byteField = 8 - byteObjectField = 39 shortField = 17 shortObjectField = 24 - charField = 끰 charObjectField = 뿩 intField = 1412793167 - intObjectField = -1521479114 longField = -5054977360881301041 - longObjectField = 8252315121779248953 floatField = 0.13922673 - floatObjectField = 0.6835188 doubleField = 0.7345653869074095 - doubleObjectField = 0.7172732709165366 - stringField = 英訆ฤ뭧㜲펮憷ᮻ焜懪 objectField = java.lang.Object@73da669c - calendarField = Sat Apr 30 14:05:21 BST 2011 - dateField = Sat Apr 30 14:05:21 BST 2011 - randomArray = [Ljava.util.Random;@786c730 )} - firstName = 㪜됰찄狇브穊厣텾ꧠ )
All three arguments to the Singleton method have been filled with data.
PODAM support classes with generic attributes by solving its currently generic types by the owner setter declaration.
-The following example illustrates a generic class, uk.co.jemos.podam.test.dto.pdm45.GenericPojo<F, S>, which is used several times as attributes of another POJO, uk.co.jemos.podam.test.dto.pdm45.GenericAttributePojo.
-package uk.co.jemos.podam.test.dto.pdm45; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -/** - * Generic Pojo. - * - * @author marciocarmona - * - * @param <F> - * the first generic type - * @param <S> - * the second generic type - */ -public class GenericPojo<F, S> { - - private F firstValue; - private S secondValue; - @PodamCollection(nbrElements = 2) - private List<F> firstList; - @PodamCollection(nbrElements = 2) - private S[] secondArray; - @PodamCollection(nbrElements = 2) - private Map<F, S> firstSecondMap; - - public F getFirstValue() { - return firstValue; - } - - public void setFirstValue(F firstValue) { - this.firstValue = firstValue; - } - - public S getSecondValue() { - return secondValue; - } - - public void setSecondValue(S secondValue) { - this.secondValue = secondValue; - } - - public List<F> getFirstList() { - return firstList; - } - - public void setFirstList(List<F> firstList) { - this.firstList = firstList; - } - - public S[] getSecondArray() { - return secondArray; - } - - public void setSecondArray(S[] secondArray) { - this.secondArray = secondArray; - } - - public Map<F, S> getFirstSecondMap() { - return firstSecondMap; - } - - public void setFirstSecondMap(Map<F, S> firstSecondMap) { - this.firstSecondMap = firstSecondMap; - } - - @Override - public String toString() { - return "GenericPojo [firstValue=" + firstValue + ", secondValue=" - + secondValue + ", firstList=" + firstList + ", secondArray=" - + Arrays.toString(secondArray) + ", firstSecondMap=" - + firstSecondMap + "]"; - } -} -
Notice all the generic types (F and S) used by the class attributes, for each instance of this class we may use different types. It is very important to use the generic notation on the setters because this is where the current types are solved to create the instance that will be supplied for the setter.
-Now this is a POJO using the generic class as an attribute, defining F and S as String and Long respectively.
-package uk.co.jemos.podam.test.dto.pdm45; - -/** - * Pojo with generic attribute. - * - * @author marciocarmona - * - */ -public class GenericAttributePojo { - - private GenericPojo<String, Long> genericPojo; - - public GenericPojo<String, Long> getGenericPojo() { - return genericPojo; - } - - public void setGenericPojo(GenericPojo<String, Long> genericPojo) { - this.genericPojo = genericPojo; - } - - @Override - public String toString() { - return "GenericAttributePojo [genericPojo=" + genericPojo + "]"; - } -}
As before, it is necessary to specify the types to be used on the setter, because these will be the types used during the generic class instantiation.
-Running the test on the class above produces the following result:
-GenericAttributePojo [ - genericPojo=GenericPojo [ - firstValue=mJdAWTgzkv, - secondValue=1340162143705, - firstList=[EMZeLCj8qf, VJZbWl8Xyo], - secondArray=[1340162143705, 1340162143705], - firstSecondMap={sSb8TCcOZB=1340162143700, EqVTVO78RR=1340162143700} - ] -]
As you can notice all the generic types have been solved properly as String or Long according to the types defined on GenericAttributePojo class. Also the collections, the array and the map have 2 items as specified by the @PodamCollection annotation.
-If you want to manufacture a generic class directly, i.e., that is not wrapped by a non-generic class like on the example above, please refer to "Manufacturing generic types" section in the Introduction page.
There are some classes for which PODAM is not able to instantiate an object. Typically these classes are not POJOs, but require sophisticate instantiation. PODAM will leave values for such classes as null, but you still can manufacture them with second level factory registered to the PODAM factory.
-Define your own external factory implementing PodamFactory interface.
-package uk.co.jemos.podam.example; - -/** - * External factory - */ -public class MyExternalFactory implements PodamFactory { - - private static final Logger LOG = LoggerFactory - .getLogger(MyExternalFactory.class); - - private static final Type[] NO_TYPES = new Type[0]; - - @Override - public <T> T manufacturePojo(Class<T> pojoClass) { - return this.manufacturePojo(pojoClass, NO_TYPES); - } - - @Override - public <T> T manufacturePojo(Class<T> pojoClass, Type... genericTypeArgs) { - if (pojoClass.equals(InputStream.class)) { - byte[] buffer = new byte[256]; - @SuppressWarnings("unchecked") - T result = (T) new ByteArrayInputStream(buffer); - return result; - } else { - LOG.warn("Cannot instantiate {} with arguments {}. Returning null.", - pojoClass, Arrays.toString(genericTypeArgs)); - return null; - } - } - - @Override - public DataProviderStrategy getStrategy() { - return null; - } -}
Set the external factory, when instantiation PODAM factory.
-PodamFactory factory = new PodamFactoryImpl(externalFactory); -InputStream pojo = factory.manufacturePojo(InputStream.class);
In the Walk-through page we documented the most common scenarios where you would want to use PODAM. These include:
+In this page I will show how PODAM handles some corner cases, such as:
+PODAM supports inheritance. It will fill parent attributes if an accessible setter is available to the POJOs which you are filling with data.
+The following example illustrates a parent class, uk.co.jemos.podam.test.dto.AbstractOneDimensionalPojo which is extended by another POJO, uk.co.jemos.podam.test.dto.OneDimensionalChildPojo.
+/** + * + */ +package uk.co.jemos.podam.test.dto; + +import java.util.Calendar; + +import uk.co.jemos.podam.annotations.PodamIntValue; + +/** + * Abstract POJO to test inheritance. + * + * @author mtedone + * + */ +public abstract class AbstractOneDimensionalPojo { + + @PodamIntValue(maxValue = 10) + private int parentIntField; + + private Calendar parentCalendarField; + + public int getParentIntField() { + return parentIntField; + } + + protected void setParentIntField(int parentIntField) { + this.parentIntField = parentIntField; + } + + public Calendar getParentCalendarField() { + return parentCalendarField; + } + + protected void setParentCalendarField(Calendar parentCalendarField) { + this.parentCalendarField = parentCalendarField; + } + + @Override + public String toString() { + final String TAB = " "; + + StringBuilder retValue = new StringBuilder(); + + retValue.append("AbstractOneDimensionalPojo ( ") + .append("parentIntField = ").append(parentIntField).append(TAB) + .append("parentCalendarField = ").append(parentCalendarField.getTime()) + .append(TAB).append(" )"); + + return retValue.toString(); + } +} + +
The class above defines two private attributes, parentIntField and parentCalendarField. It also provides two protected setters which are available to sub-classes. The presence of accessible setter methods is a pre-requisite for this inheritance to be handled properly by PODAM.
+This is the child class:
++/** + * + */ +package uk.co.jemos.podam.test.dto; + +/** + * A child class to test inheritance + * @author mtedone + * + */ +public class OneDimensionalChildPojo extends AbstractOneDimensionalPojo { + + private int intField; + + private String strField; + + public OneDimensionalChildPojo() { + super(); + } + + public int getIntField() { + return intField; + } + + public void setIntField(int intField) { + this.intField = intField; + } + + public String getStrField() { + return strField; + } + + public void setStrField(String strField) { + this.strField = strField; + } + + /** + * Constructs a <code>String</code> with all attributes in name = value + * format. + * + * @return a <code>String</code> representation of this object. + */ + @Override + public String toString() { + final String TAB = " "; + + StringBuilder retValue = new StringBuilder(); + retValue.append(super.toString()).append(TAB); + + retValue.append("OneDimensionalChildPojo ( ").append("intField = ") + .append(intField).append(TAB).append("strField = ") + .append(strField).append(TAB).append(" )"); + + return retValue.toString(); + } + +} + + +
Running PODAM on the OneDimensionalChildPojo class will produce the following toString() result:
+AbstractOneDimensionalPojo ( parentIntField = 3 parentCalendarField = Sat Apr 30 13:49:49 BST 2011 ) + OneDimensionalChildPojo ( intField = -516418302 strField = ﶖ藾冋荬馫콈愁㵼藙酬 ) +
As you can see Podam has set both the parent attributes values.
A Singleton is a class which provides only an instance of itself. One of the implementation details of a Singleton is that, unless one used an Enum, the class should forbid clients from creating new instances. This is typically achieved by declaring the constructor private and by providing a public static method (e.g. getInstance()) which returns a singleton instance of the class.
+PODAM handles Singleton-like classes, as the following example demonstrates:
+/** + * + */ +package uk.co.jemos.podam.test.dto; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.List; +import java.util.Map; + +/** + * A POJO to test a Singleton-like scenario where the public static Singleton + * method contains parameters. + * + * @author mtedone + * + */ +public class SingletonWithParametersInStaticFactoryPojo implements Serializable { + + private static final long serialVersionUID = 1L; + + private final Calendar createDate; + + private final List<OneDimensionalTestPojo> pojoList; + + private final Map<String, OneDimensionalTestPojo> pojoMap; + + private final String firstName; + + private static SingletonWithParametersInStaticFactoryPojo singleton; + + // ------------------->> Constructors + + /** + * A private constructor to enforce the Singleton pattern + * + * @param createDate + * The creation date + * @param pojoList + * A list + * @param pojoMap + * A map + * @param firstName + * The first name + */ + private SingletonWithParametersInStaticFactoryPojo(Calendar createDate, + List<OneDimensionalTestPojo> pojoList, + Map<String, OneDimensionalTestPojo> pojoMap, String firstName) { + super(); + this.createDate = createDate; + this.pojoList = pojoList; + this.pojoMap = pojoMap; + this.firstName = firstName; + } + + + /** + * Singleton method + * + * @param createDate + * The creation date + * @param pojoList + * A list + * @param pojoMap + * A map + * @param firstName + * The first name + * @return a singleton instance of this class + */ + public static SingletonWithParametersInStaticFactoryPojo getInstance( + Calendar createDate, List<OneDimensionalTestPojo> pojoList, + Map<String, OneDimensionalTestPojo> pojoMap, String firstName) { + if (null == singleton) { + singleton = new SingletonWithParametersInStaticFactoryPojo( + createDate, pojoList, pojoMap, firstName); + } + + return singleton; + } + + public Calendar getCreateDate() { + return createDate; + } + + public List<OneDimensionalTestPojo> getPojoList() { + return pojoList; + } + + public Map<String, OneDimensionalTestPojo> getPojoMap() { + return pojoMap; + } + + public String getFirstName() { + return firstName; + } + +} + +
The class above shows an interesting scenario: a Singleton-like class with the Singleton method which accepts parameters. To make the example even more palatable, some arguments are container-like (collections, maps).
+Running the test on the class above produces the following result:
+SingletonWithParametersInStaticFactoryPojo ( + createDate = Sat Apr 30 14:05:21 BST 2011 + pojoList = [ + OneDimensionalTestPojo ( booleanField = true booleanObjectField = true byteField = 116 + byteObjectField = 10 shortField = 77 shortObjectField = 4 charField = 㐘 + charObjectField = ꪁ intField = 1339494839 intObjectField = 980291811 + longField = -3119222069530856219 longObjectField = 4260197822662475631 + floatField = 0.24369287 floatObjectField = 0.7073253 doubleField = 0.7151146071422815 + doubleObjectField = 0.8253745751884359 stringField = ౠ᮷᳃┸㯪쭵Ὼాꎐᆫ + objectField = java.lang.Object@57a7ddcf calendarField = Sat Apr 30 14:05:21 BST 2011 + dateField = Sat Apr 30 14:05:21 BST 2011 randomArray = [Ljava.util.Random;@4dd36dfe )] + pojoMap = { + 研䷢쫗㛗á룸ꁧ╝楫=OneDimensionalTestPojo ( booleanField = false booleanObjectField = true byteField = 8 + byteObjectField = 39 shortField = 17 shortObjectField = 24 + charField = 끰 charObjectField = 뿩 intField = 1412793167 + intObjectField = -1521479114 longField = -5054977360881301041 + longObjectField = 8252315121779248953 floatField = 0.13922673 + floatObjectField = 0.6835188 doubleField = 0.7345653869074095 + doubleObjectField = 0.7172732709165366 + stringField = 英訆ฤ뭧㜲펮憷ᮻ焜懪 objectField = java.lang.Object@73da669c + calendarField = Sat Apr 30 14:05:21 BST 2011 + dateField = Sat Apr 30 14:05:21 BST 2011 + randomArray = [Ljava.util.Random;@786c730 )} + firstName = 㪜됰찄狇브穊厣텾ꧠ ) +
All three arguments to the Singleton method have been filled with data.
PODAM support classes with generic attributes by solving its currently generic types by the owner setter declaration.
+The following example illustrates a generic class, uk.co.jemos.podam.test.dto.pdm45.GenericPojo<F, S>, which is used several times as attributes of another POJO, uk.co.jemos.podam.test.dto.pdm45.GenericAttributePojo.
+package uk.co.jemos.podam.test.dto.pdm45; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * Generic Pojo. + * + * @author marciocarmona + * + * @param <F> + * the first generic type + * @param <S> + * the second generic type + */ +public class GenericPojo<F, S> { + + private F firstValue; + private S secondValue; + @PodamCollection(nbrElements = 2) + private List<F> firstList; + @PodamCollection(nbrElements = 2) + private S[] secondArray; + @PodamCollection(nbrElements = 2) + private Map<F, S> firstSecondMap; + + public F getFirstValue() { + return firstValue; + } + + public void setFirstValue(F firstValue) { + this.firstValue = firstValue; + } + + public S getSecondValue() { + return secondValue; + } + + public void setSecondValue(S secondValue) { + this.secondValue = secondValue; + } + + public List<F> getFirstList() { + return firstList; + } + + public void setFirstList(List<F> firstList) { + this.firstList = firstList; + } + + public S[] getSecondArray() { + return secondArray; + } + + public void setSecondArray(S[] secondArray) { + this.secondArray = secondArray; + } + + public Map<F, S> getFirstSecondMap() { + return firstSecondMap; + } + + public void setFirstSecondMap(Map<F, S> firstSecondMap) { + this.firstSecondMap = firstSecondMap; + } + + @Override + public String toString() { + return "GenericPojo [firstValue=" + firstValue + ", secondValue=" + + secondValue + ", firstList=" + firstList + ", secondArray=" + + Arrays.toString(secondArray) + ", firstSecondMap=" + + firstSecondMap + "]"; + } +} + +
Notice all the generic types (F and S) used by the class attributes, for each instance of this class we may use different types. It is very important to use the generic notation on the setters because this is where the current types are solved to create the instance that will be supplied for the setter.
+Now this is a POJO using the generic class as an attribute, defining F and S as String and Long respectively.
+package uk.co.jemos.podam.test.dto.pdm45; + +/** + * Pojo with generic attribute. + * + * @author marciocarmona + * + */ +public class GenericAttributePojo { + + private GenericPojo<String, Long> genericPojo; + + public GenericPojo<String, Long> getGenericPojo() { + return genericPojo; + } + + public void setGenericPojo(GenericPojo<String, Long> genericPojo) { + this.genericPojo = genericPojo; + } + + @Override + public String toString() { + return "GenericAttributePojo [genericPojo=" + genericPojo + "]"; + } +} +
As before, it is necessary to specify the types to be used on the setter, because these will be the types used during the generic class instantiation.
+Running the test on the class above produces the following result:
+GenericAttributePojo [ + genericPojo=GenericPojo [ + firstValue=mJdAWTgzkv, + secondValue=1340162143705, + firstList=[EMZeLCj8qf, VJZbWl8Xyo], + secondArray=[1340162143705, 1340162143705], + firstSecondMap={sSb8TCcOZB=1340162143700, EqVTVO78RR=1340162143700} + ] +] +
As you can notice all the generic types have been solved properly as String or Long according to the types defined on GenericAttributePojo class. Also the collections, the array and the map have 2 items as specified by the @PodamCollection annotation.
+If you want to manufacture a generic class directly, i.e., that is not wrapped by a non-generic class like on the example above, please refer to "Manufacturing generic types" section in the Introduction page.
There are some classes for which PODAM is not able to instantiate an object. Typically these classes are not POJOs, but require sophisticate instantiation. PODAM will leave values for such classes as null, but you still can manufacture them with second level factory registered to the PODAM factory.
+Define your own external factory implementing PodamFactory interface.
+package uk.co.jemos.podam.example; + +/** + * External factory + */ +public class MyExternalFactory implements PodamFactory { + + private static final Logger LOG = LoggerFactory + .getLogger(MyExternalFactory.class); + + private static final Type[] NO_TYPES = new Type[0]; + + @Override + public <T> T manufacturePojo(Class<T> pojoClass) { + return this.manufacturePojo(pojoClass, NO_TYPES); + } + + @Override + public <T> T manufacturePojo(Class<T> pojoClass, Type... genericTypeArgs) { + if (pojoClass.equals(InputStream.class)) { + byte[] buffer = new byte[256]; + @SuppressWarnings("unchecked") + T result = (T) new ByteArrayInputStream(buffer); + return result; + } else { + LOG.warn("Cannot instantiate {} with arguments {}. Returning null.", + pojoClass, Arrays.toString(genericTypeArgs)); + return null; + } + } + + @Override + public DataProviderStrategy getStrategy() { + return null; + } +} +
Set the external factory, when instantiation PODAM factory.
+PodamFactory factory = new PodamFactoryImpl(externalFactory); +InputStream pojo = factory.manufacturePojo(InputStream.class); +
InputStream class was given just for an example.
Podam can be downloaded from Maven Central
[Summary] [Package List] [Test Cases]
Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|
191 | -0 | -0 | -0 | -100% | -18.193 |
Note: failures are anticipated and checked for with assertions while errors are unanticipated.
[Summary] [Package List] [Test Cases]
Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.
-- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | AbnormalPojosTest | -12 | -0 | -0 | -0 | -100% | -0.455 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | BooleanUnitTest | -1 | -0 | -0 | -0 | -100% | -0.199 |
- | PodamFactoryBasicTypesTest | -15 | -0 | -0 | -0 | -100% | -1.641 |
- | ClassUnitTest | -3 | -0 | -0 | -0 | -100% | -0.298 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | Pdm43UnitTest | -1 | -0 | -0 | -0 | -100% | -0.001 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | SingletonsTest | -1 | -0 | -0 | -0 | -100% | -0.397 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | ExtraMethodsUnitTest | -1 | -0 | -0 | -0 | -100% | -0 |
- | MyInitPojoUnitTest | -1 | -0 | -0 | -0 | -100% | -0 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | Pdm45UnitTest | -5 | -0 | -0 | -0 | -100% | -0.339 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | MemoizationTest | -6 | -0 | -0 | -0 | -100% | -0.242 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | PodamFactoryInjectionIntegrationTest | -1 | -0 | -0 | -0 | -100% | -1.98 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | CollectionsTest | -9 | -0 | -0 | -0 | -100% | -0.931 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | ConstructorsUnitTest | -23 | -0 | -0 | -0 | -100% | -0.638 |
- | ReadOnlyComplexTypesTest | -4 | -0 | -0 | -0 | -100% | -0.246 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | ExternalFactoryUnitTest | -7 | -0 | -0 | -0 | -100% | -0.201 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | TypeManufacturingTest | -19 | -0 | -0 | -0 | -100% | -0.947 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | ValidatedPojoTest | -2 | -0 | -0 | -0 | -100% | -0.814 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | ClassInfoTest | -4 | -0 | -0 | -0 | -100% | -0.134 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | Issue93UnitTest | -1 | -0 | -0 | -0 | -100% | -0.255 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | Pdm3PojoUnitTest | -18 | -0 | -0 | -0 | -100% | -0.382 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | MultipleInterfacesInheritanceTest | -3 | -0 | -0 | -0 | -100% | -6.122 |
- | InheritanceTest | -4 | -0 | -0 | -0 | -100% | -0.414 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | AnnotationsTest | -15 | -0 | -0 | -0 | -100% | -0.631 |
- | AnnotationsExceptionsTest | -7 | -0 | -0 | -0 | -100% | -0.05 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | InstantiationUnitTest | -6 | -0 | -0 | -0 | -100% | -0.053 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | InvisibleConstructorAndNoSettersTest | -1 | -0 | -0 | -0 | -100% | -0 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | XMLDatatypeUnitTest | -3 | -0 | -0 | -0 | -100% | -0.129 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | RandomDataProviderStrategyImplInitialisationUnitTest | -7 | -0 | -0 | -0 | -100% | -0.174 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | WalkThroughExampleUnitTest | -7 | -0 | -0 | -0 | -100% | -0.327 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | ExtensionsTest | -2 | -0 | -0 | -0 | -100% | -0.094 |
- | NonEJBPojoTest | -1 | -0 | -0 | -0 | -100% | -0.066 |
- | Class | -Tests | -Errors | -Failures | -Skipped | -Success Rate | -Time |
---|---|---|---|---|---|---|---|
- | FactoryUnitTest | -1 | -0 | -0 | -0 | -100% | -0.033 |
[Summary] [Package List] [Test Cases]
- - -- | whenMemoizationIsFalsePodamShouldReturnDifferentInstancesForDifferentInvocations | -0.014 |
- | whenMemoizationIsTruePodamShouldReturnTheSameInstanceForDifferentInvocations | -0.015 |
- | memoizationShouldWorkCorrectlyForCollectionsAndArrays | -0.042 |
- | memoizationShouldWorkForRecursivePojos | -0.022 |
- | memoizationShouldWorkWithGenerics | -0.007 |
- | evenWhenMemoizationIsTrueIfGenericPojosHaveDifferentTypesObjectsShouldNotBeEqual | -0.005 |
- | podamShouldHandleImmutableNonAnnotatedPojos | -0.063 |
- | podamShouldFillJavaNativeTypes | -0.034 |
- | podamShouldFillPojoWithEnums | -0.01 |
- | podamShouldSupportRecursiveMaps | -0.354 |
- | invokingPodamOnAnInterfaceShouldReturnAnEmptyPojo | -0.029 |
- | podamShouldGenerateBasicTypes | -0.048 |
- | invokingPodamOnAbstractClassShouldReturnANullPojo | -0.011 |
- | podamShouldFillRecursivePojosWhenInvokingPopulationDirectly | -0.012 |
- | podamShouldFillArraysWithElements | -0.013 |
- | podamShouldFillRecursivePojos | -0.007 |
- | podamShouldFillPojosWithNonDefaultConstructor | -0.016 |
- | podamShouldSupportRecursiveLists | -0.276 |
- | podamShouldSupportCircularDependencies | -0.016 |
- | podamShouldFillJavaStringType | -0.007 |
- | podamShouldFillJavaStringTypeWithFullConstructor | -0.004 |
- | podamMessagingSystemShouldReturnAFloatWrappedValue | -0.036 |
- | podamMessagingSystemShouldReturnAShortPrimitiveValue | -0.03 |
- | podamMessagingSystemShouldReturnAnEnumValue | -0.027 |
- | podamMessagingSystemShouldReturnALongWrappedValue | -0.008 |
- | podamMessagingSystemShouldReturnALongPrimitiveValue | -0.005 |
- | podamMessagingSystemShouldReturnAnIntegerValue | -0.011 |
- | podamMessagingSystemShouldReturnABytePrimitiveValue | -0.01 |
- | podamMessagingSystemShouldReturnABooleanWrappedValue | -0.011 |
- | podamMessagingSystemShouldReturnACharacterPrimitiveValue | -0.011 |
- | podamMessagingSystemShouldReturnAByteWrappedValue | -0.007 |
- | podamMessagingSystemShouldReturnAStringValue | -0.002 |
- | podamMessagingSystemShouldReturnAnIntValue | -0.021 |
- | podamMessagingSystemShouldReturnAShortWrappedValue | -0.012 |
- | podamMessagingSystemShouldReturnAGenericTypeValue | -0.012 |
- | podamMessagingSystemShouldReturnAFloatPrimitiveValue | -0.017 |
- | podamMessagingSystemShouldReturnACharacterWrappedValue | -0.012 |
- | podamMessagingSystemShouldReturnADoublePrimitiveValue | -0.022 |
- | podamMessagingSystemShouldReturnABooleanPrimitiveValue | -0.005 |
- | podamMessagingSystemShouldReturnADoubleWrappedValue | -0.01 |
- | testImmutablePojoConstructionFailure | -0.007 |
- | podamShouldManufacturePackagePrivatePojos | -0.004 |
- | podamShouldBeAbleToManufactureInstancesOfTheObservableClass | -0.003 |
- | podamShouldBeAbleToInstantiatePojosWithImmutableCollections | -0.016 |
- | podamShouldCreateInstancesOfJAXBElementsDeclaredAsInstanceVariablesInAPojo | -0.035 |
- | podamShouldBeAbleToManufactureAnyTypeOfCollections | -0.007 |
- | podamShouldCreateInstancesOfInnerClasses | -0.006 |
- | podamShouldBeAbleToManufacturePojosWhichContainImmutableCollections | -0.009 |
- | podamShouldHandleGenericsInConstructor | -0.016 |
- | podamShouldHandleGenericCollectionsInConstructorWithMemoizationEnabled | -0.028 |
- | podamShouldCreateInstancesOfGenericPojosWithFactoryMethodsWhenTheConcreteTypeIsKnown | -0.01 |
- | podamShouldCreateInstancesOfPojosExtendingGenericClasses | -0.011 |
- | podamShouldHandleClassesWithKeyValueGenericTypes | -0.015 |
- | podamShouldHandleGenericCollectionsInConstructorWithMemoizationDisabled | -0.018 |
- | podamShouldHandleGenericsInSettersDuringPojoInstantiation | -0.022 |
- | podamShouldBeAbleToManufactureAnyTypeOfMaps | -0.006 |
- | podamShouldHandleConstructorsWithGenericArraysDuringPojoInstantiation | -0.004 |
- | podamShouldBeAbleToInstantiatePojosWithImmutableMaps | -0.005 |
- | podamShouldHandleConstructorsWithMultipleGenericsDuringPojoInstantiation | -0.022 |
- | podamShouldInstantiateAbstractClassesForWhichItKnowsConcreteTypes | -0.019 |
- | podamShouldChooseTheFullestConstructorWhenInvokedForFullData | -0.004 |
- | podamShouldHandleGenericsInStaticConstructorsDuringPojoInstantiation | -0.006 |
- | podamShouldCreateInstancesOfJAXBElements | -0.007 |
- | podamShouldReturnAValidClassInfoForPojoWithNoAttributes | -0.013 |
- | inPresenceOfExcludeAnnotationsTheClassInfoObjectShouldContainAValidSetOfPojoAttributes | -0.009 |
- | inPresenceOfExcludedAttributesTheClassInfoObjectShouldNotContainThoseAttributes | -0.005 |
- | podamShouldReturnAClassInfoObjectWhichContainsTheSameAttributesAsThePojoBeingProcessed | -0.005 |
- | podamShouldCreatePojosInAccordanceWithCustomDataProviderStrategies | -0.019 |
- | podamShouldFillTheAttributeMetadataWithTheAttributeNames | -0.013 |
- | testPdm3IndirectImplementingMapOfPojos | -0.008 |
- | testPdm3MapOfGenericPojos | -0.085 |
- | testPdm3ListOfGenericPojos | -0.09 |
- | testPdm3ExtendingMapOfPojos | -0.001 |
- | testPdm3ListOfPojos | -0.027 |
- | testPdm3IndirectImplementingListOfPojos | -0.003 |
- | testPdm3MapOfPojos | -0.018 |
- | testPdm3PojoConstructor | -0.002 |
- | testPdm3ImplementingListOfPojos | -0.001 |
- | testPdm3WildcardPojo | -0.096 |
- | testPdm3ImplementingMapOfPojos | -0 |
- | testPdm3ExtendingImplementingMapOfPojos | -0.006 |
- | testPdm3Pojo | -0.013 |
- | testPdm3ExtendingListOfPojos | -0.001 |
- | testPdm3ExtendingNonRawMapOfPojos | -0.002 |
- | testPdm3ExtendingImplementingListOfPojos | -0.002 |
- | testPdm3PojoGenericsConstructor | -0.018 |
- | testPdm3ExtendingRawListOfPojos | -0.002 |
- | podamCannotInstantiateInterfacesWhichExtendMap | -0.624 |
- | testHolderOfPojoWithMultiInterfaces | -0.118 |
- | podamCannotInstantiateInterfaces | -0.03 |
- | testDurationManufacturing | -0.03 |
- | testXMLDatatypesFieldSetting | -0.011 |
- | testXMLGregorianCalendarManufacturing | -0.01 |
- | podamShouldNotFillFieldsAnnotatedWithExcludeAnnotation | -0.01 |
- | podamShouldHandleIntegerValues | -0.027 |
- | podamShouldHandleBooleanValuesWithThePodamBooleanValueAnnotation | -0.032 |
- | podamShouldHandleByteValuesWithThePodamByteValueAnnotation | -0.019 |
- | podamShouldHandleCharValuesWithThePodamCharValueAnnotation | -0.017 |
- | podamShouldHandleDoubleValuesWithThePodamDoubleValueAnnotation | -0.012 |
- | podamShouldAssignExactValuesDefinedInPodamStrategyValueAnnotation | -0.042 |
- | podamShouldHandleImmutablePojosAnnotatedWithPodamConstructor | -0.02 |
- | podamShouldHandlePojosWithAnnotatedFieldAndSetter | -0.014 |
- | podamShouldHandleFloatValuesWithThePodamFloatValueAnnotation | -0.022 |
- | podamShouldHandleConstructorsWithOneOrMoreSelfReferences | -0.015 |
- | podamShouldHandleLongValues | -0.027 |
- | podamShouldHandleShortValuesWithThePodamShortValueAnnotation | -0.041 |
- | thePodamCollectionAnnotationShouldWorkOnAllCollections | -0.029 |
- | podamShouldAssignPreciseValuesWithTheStringValueAnnotation | -0.009 |
- | testCountrySetup | -0.029 |
- | testClientSetup | -0.103 |
- | testOrderSetup | -0.02 |
- | testArticleSetup | -0.011 |
- | testBankAccountSetup | -0.008 |
- | testAddressSetup | -0.008 |
- | testOrderItemSetup | -0.004 |
- | randomDataProviderStrategyShouldBeInitialisedCorrectlyAndAllowForChangesInNbrOfCollectionElements | -0 |
- | creatingARandomDataProviderStrategyShouldCreateAConstructorHeavyComparator | -0.004 |
- | creatingARandomDataProviderStrategyShouldCreateAMethodHeavyComparator | -0.007 |
- | creatingARandomDataProviderStrategyShouldCreateAConstructorLightComparator | -0.01 |
- | creatingARandomDataProviderStrategyShouldCreateAMethodLightComparator | -0.009 |
- | podamShouldCorrectGenerateHashMapsWithLongAsKeyType | -0.032 |
- | podamShouldCreatePojosInAccordanceWithCustomDataProviderStrategies | -0.009 |
- | podamShouldCreateAnInstanceOfAnAbstractClassWithAFactoryMethodWhichReturnsAConcreteType | -0.017 |
- | podamShouldFillReadOnlyComplexTypes | -0.012 |
- | podamShouldFillInPojosWhichContainInternalLoops | -0.043 |
- | podamShouldFillReadOnlyTypes | -0.037 |
- | testPdm4PojoWithSetters | -0.015 |
- | testPdm4PojoWithFullData | -0.008 |
- | testPojoWithFactoryMethods | -0.005 |
- | testPojoWithFactoryMethodsWithFullData | -0.007 |
- | testPojoWithMultipleNonPublicConstructorsWithFullData | -0.007 |
- | testPojoWithMultipleNonPublicConstructors | -0.001 |
- | whenMaxLengthIsNotSpecifiedInSizeAnnotationPodamShouldAssignASensibleDefault | -0.511 |
- | podamShouldFulfillMostOfTheJavaxValidationFramework | -0.216 |
- | podamShouldNotCreateInstancesOfAnAbstractClassEvenIfPojoHasFullConstructor | -0.015 |
- | podamShouldNotcreateInstancesOfNonInstantiableClasses | -0.009 |
- | theManagementOfExternalFactoriesShouldBeCorrectAndChainingShouldWord | -0.006 |
- | podamDoesNotCreateInstancesOfAbstractClassesIfExternalFactoryDoesNotDefineThem | -0.014 |
- | podamCannotFillInterfaceAttributesIfTheExternalFactoryDoesNotManufactureTheRightType | -0.02 |
- | podamShouldNotBeAbleToCreateInterfaceInstancesGivenAnExternalFactoryWhichDoesNotManufactureTheConcreteType | -0.014 |
- | podamShouldFillPojoInterfaceAttributeIfFullConstructorSetsItsValue | -0.01 |
- | podamShouldManufactureAttributesImplementingCollectionAndMapInterfaces | -0.055 |
- | podamShouldHandleBasicInheritance | -0.048 |
- | podamShouldManufactureAllPojosInATreeHierarchy | -0.045 |
- | podamShouldHandleTheManufacturingOfPojosWhichInheritFromOtherClasses | -0.018 |
- | podamShouldThrowExceptionWhenPodamIntegerValueContainsInvalidCharacters | -0.004 |
- | podamShouldThrowExceptionWhenPodamByteValueContainsInvalidCharacters | -0.004 |
- | podamShouldThrowExceptionWhenPodamDoubleValueContainsInvalidCharacters | -0.006 |
- | podamShouldThrowExceptionWhenPodamFloatValueContainsInvalidCharacters | -0.006 |
- | podamShouldThrowExceptionWhenPodamStrategyValueContainsInvalidStrategy | -0.008 |
- | podamShouldThrowExceptionWhenPodamShortValueContainsInvalidCharacters | -0.009 |
- | podamShouldThrowExceptionWhenPodamLongValueContainsInvalidCharacters | -0.011 |
- | testConstructorMultiDimensionalPojo | -0.269 |
- | testPojoWithGenericFields | -0.008 |
- | testGenericPojoManufacture | -0 |
- | testMultiDimensionalPojoManufacture | -0.012 |
- | testMultiDimensionalTestPojo | -0.041 |
- | podamShouldHandleTheManufacturingOfPojosWithGenericTypesInTheConstructor | -0.06 |
- | podamShouldHandleTheManufacturingOfBasicTypes | -0.026 |
- | podamShouldHandleTheManufacturingOfGenericPojos | -0.021 |
- | podamShouldFillValuesInvokingChildrenSettersHavingDifferentTypesThanParent | -0.007 |
- | invokingPodamOnaPojoWithPrivateNoArgumentsConstructorShouldReturnANonEmptyPojo | -0.022 |
- | podamCannotHandleCircularConstructors | -0.079 |
- | podamShouldFillPojosWithPublicNonDefaultPublicConstructors | -0.006 |
- | podamShouldFillEmbeddedAbstractClassesIfAConcreteTypeHasBeenSpecified | -0.038 |
- | podamShouldFillPojosWithProtectedNonDefaultConstructors | -0.005 |
- | podamShouldReturnANullValueForNonInstantiablePojos | -0.004 |
- | podamShouldGenerateANonNullPojoForAbstractTypesWithConcreteImplementation | -0.002 |
- | podamShouldHandlePojosWithSelfReferenceConstructorsButNotDefaultConstructors | -0.008 |
- | podamShouldThrowAnExceptionIfAPojoContainsInvalidGettersOrSetters | -0.002 |
- | podamShouldHandlePojosWithPrivateOnlyConstructors | -0.01 |
- | podamShouldHandlePojosWithAMixOfCircularAndNonCircularConstructors | -0.07 |
- | podamShouldBeAbleToFillInPojosWithRawTypeCollectionAttributesAndDefaultValueToObject | -0.019 |
- | testSortedMapCreation | -0.024 |
- | podamShouldHandleStandardCollections | -0.357 |
- | podamShouldHandlePojosWithNoSettersAndCollectionsInTheConstructor | -0.02 |
- | podamShouldHandleImmutablePojoWithGenerifiedCollectionsInConstructor | -0.163 |
- | testConcurrentMapCreation | -0.021 |
- | podamShouldHandleImmutablePojosWithNonGenericCollections | -0.023 |
- | testHashMapCreation | -0.007 |
- | podamShouldFillInPojosWithAttributesContainingWildcards | -0.009 |
[Summary] [Package List] [Test Cases]
Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|
217 | +0 | +0 | +0 | +100% | +32.072 |
Note: failures are anticipated and checked for with assertions while errors are unanticipated.
[Summary] [Package List] [Test Cases]
Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.
++ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | AbnormalPojosTest | +12 | +0 | +0 | +0 | +100% | +1.713 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | BooleanUnitTest | +1 | +0 | +0 | +0 | +100% | +0.188 |
+ | ClassUnitTest | +3 | +0 | +0 | +0 | +100% | +0.376 |
+ | PodamFactoryBasicTypesTest | +20 | +0 | +0 | +0 | +100% | +4.09 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | Pdm43UnitTest | +1 | +0 | +0 | +0 | +100% | +0 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | SingletonsTest | +1 | +0 | +0 | +0 | +100% | +0.132 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | ExtraMethodsUnitTest | +1 | +0 | +0 | +0 | +100% | +0 |
+ | MyInitPojoUnitTest | +1 | +0 | +0 | +0 | +100% | +0 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | Pdm45UnitTest | +9 | +0 | +0 | +0 | +100% | +0.334 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | PodamFactoryInjectionIntegrationTest | +1 | +0 | +0 | +0 | +100% | +0.727 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | MemoizationTest | +7 | +0 | +0 | +0 | +100% | +0.8 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | CollectionsTest | +11 | +0 | +0 | +0 | +100% | +1.208 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | ConstructorsUnitTest | +26 | +0 | +0 | +0 | +100% | +3.289 |
+ | ReadOnlyComplexTypesTest | +4 | +0 | +0 | +0 | +100% | +0.516 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | ExternalFactoryUnitTest | +7 | +0 | +0 | +0 | +100% | +0.955 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | TypeManufacturingTest | +18 | +0 | +0 | +0 | +100% | +2.135 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | ValidatedPojoTest | +6 | +0 | +0 | +0 | +100% | +1.02 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | ClassInfoTest | +6 | +0 | +0 | +0 | +100% | +0 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | Issue93UnitTest | +1 | +0 | +0 | +0 | +100% | +5.118 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | Pdm3PojoUnitTest | +18 | +0 | +0 | +0 | +100% | +0.016 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | InheritanceTest | +4 | +0 | +0 | +0 | +100% | +0.505 |
+ | MultipleInterfacesInheritanceTest | +3 | +0 | +0 | +0 | +100% | +0.373 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | AnnotationsExceptionsTest | +7 | +0 | +0 | +0 | +100% | +0.008 |
+ | AnnotationsTest | +18 | +0 | +0 | +0 | +100% | +5.587 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | InstantiationUnitTest | +6 | +0 | +0 | +0 | +100% | +0.168 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | InvisibleConstructorAndNoSettersTest | +1 | +0 | +0 | +0 | +100% | +0 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | RandomDataProviderStrategyImplInitialisationUnitTest | +7 | +0 | +0 | +0 | +100% | +0.84 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | XMLDatatypeUnitTest | +3 | +0 | +0 | +0 | +100% | +0.362 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | RandomnessTest | +1 | +0 | +0 | +0 | +100% | +0.155 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | WalkThroughExampleUnitTest | +7 | +0 | +0 | +0 | +100% | +0.87 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | ExtensionsTest | +4 | +0 | +0 | +0 | +100% | +0.297 |
+ | NonEJBPojoTest | +1 | +0 | +0 | +0 | +100% | +0.155 |
+ | Class | +Tests | +Errors | +Failures | +Skipped | +Success Rate | +Time |
---|---|---|---|---|---|---|---|
+ | FactoryUnitTest | +1 | +0 | +0 | +0 | +100% | +0.135 |
[Summary] [Package List] [Test Cases]
+ ++ | podamShouldThrowExceptionWhenPodamIntegerValueContainsInvalidCharacters | +0 |
+ | podamShouldThrowExceptionWhenPodamByteValueContainsInvalidCharacters | +0 |
+ | podamShouldThrowExceptionWhenPodamDoubleValueContainsInvalidCharacters | +0 |
+ | podamShouldThrowExceptionWhenPodamFloatValueContainsInvalidCharacters | +0 |
+ | podamShouldThrowExceptionWhenPodamStrategyValueContainsInvalidStrategy | +0.004 |
+ | podamShouldThrowExceptionWhenPodamShortValueContainsInvalidCharacters | +0 |
+ | podamShouldThrowExceptionWhenPodamLongValueContainsInvalidCharacters | +0.004 |
+ | podamShouldNotFillFieldsAnnotatedWithExcludeAnnotation | +0.795 |
+ | podamShouldHandleIntegerValues | +0.178 |
+ | podamShouldHandleBooleanValuesWithThePodamBooleanValueAnnotation | +0.132 |
+ | podamShouldHandlePojosWithAnnotatedFieldsUsingHibernateConstraintsAnnotations | +0.154 |
+ | podamShouldHandleByteValuesWithThePodamByteValueAnnotation | +0.124 |
+ | podamShouldHandleCharValuesWithThePodamCharValueAnnotation | +0.112 |
+ | podamShouldHandleDoubleValuesWithThePodamDoubleValueAnnotation | +0.122 |
+ | podamShouldAssignExactValuesDefinedInPodamStrategyValueAnnotation | +0.196 |
+ | podamShouldHandleImmutablePojosAnnotatedWithPodamConstructor | +0.158 |
+ | podamShouldHandlePojosWithAnnotatedFieldAndSetter | +0.108 |
+ | podamShouldHandleFloatValuesWithThePodamFloatValueAnnotation | +0.114 |
+ | podamShouldHandlePojosWithAnnotatedFieldsAndCustomGenericAnnotationStrategy | +0.118 |
+ | podamShouldHandleConstructorsWithOneOrMoreSelfReferences | +0.238 |
+ | podamShouldHandleLongValues | +0.032 |
+ | podamShouldHandleShortValuesWithThePodamShortValueAnnotation | +0.13 |
+ | thePodamCollectionAnnotationShouldWorkOnAllCollections | +0.112 |
+ | podamShouldAssignExactValuesDefinedInEmailAnnotation | +0.108 |
+ | podamShouldAssignPreciseValuesWithTheStringValueAnnotation | +0.124 |
+ | podamShouldHandleTheManufacturingOfPojosWithGenericTypesInTheConstructor | +0.138 |
+ | podamShouldHandleTheManufacturingOfBasicTypes | +0.114 |
+ | podamShouldHandleTheManufacturingOfGenericPojos | +0.11 |
+ | podamShouldFillCharSequenceType | +0.126 |
+ | podamShouldSupportCircularDependenciesCustomDepth | +0.142 |
+ | podamShouldHandleImmutableNonAnnotatedPojos | +0.152 |
+ | podamShouldFillJavaNativeTypes | +0.12 |
+ | podamShouldFillPojoWithEnums | +0.122 |
+ | podamShouldSupportRecursiveMaps | +1.488 |
+ | invokingPodamOnAnInterfaceShouldReturnAnEmptyPojo | +0.012 |
+ | podamShouldGenerateBasicTypes | +0 |
+ | podamShouldIgnoreWildcardEnumFields | +0 |
+ | invokingPodamOnAbstractClassShouldReturnANullPojo | +0.01 |
+ | podamShouldFillRecursivePojosWithLists | +0.425 |
+ | podamShouldFillRecursivePojosWhenInvokingPopulationDirectly | +0.01 |
+ | podamShouldFillArraysWithElements | +0 |
+ | podamShouldFillRecursivePojos | +0.012 |
+ | podamShouldFillArrays | +0 |
+ | podamShouldFillPojosWithNonDefaultConstructor | +0 |
+ | podamShouldSupportRecursiveLists | +1.463 |
+ | podamShouldSupportCircularDependencies | +0.008 |
+ | podamShouldFillJavaStringType | +0 |
+ | podamShouldFillJavaStringTypeWithFullConstructor | +0 |
+ | podamShouldReturnAValidClassInfoForPojoWithNoAttributes | +0 |
+ | podamShouldReturnAClassInfoObjectWithNonStandardAttributesWithCustomStrategy | +0 |
+ | inPresenceOfExcludeAnnotationsTheClassInfoObjectShouldContainAValidSetOfPojoAttributes | +0 |
+ | podamShouldReturnAClassInfoObjectWithSingleLetterAndNumberAtrributes | +0 |
+ | inPresenceOfExcludedAttributesTheClassInfoObjectShouldNotContainThoseAttributes | +0 |
+ | podamShouldReturnAClassInfoObjectWhichContainsTheSameAttributesAsThePojoBeingProcessed | +0 |
+ | podamShouldBeAbleToFillInPojosWithRawTypeCollectionAttributesAndDefaultValueToObject | +0.008 |
+ | testSortedMapCreation | +0.063 |
+ | podamShouldHandleStandardCollections | +0.028 |
+ | podamShouldHandlePojosWithNoSettersAndCollectionsInTheConstructor | +0.18 |
+ | podamShouldHandleImmutablePojoWithGenerifiedCollectionsInConstructor | +0.261 |
+ | testConcurrentMapCreation | +0.048 |
+ | podamShouldHandleOptionalListOfStrings | +0.064 |
+ | podamShouldBeAbleToFillInPojosWithJsonNullableCollectionWrapper | +0.312 |
+ | podamShouldHandleImmutablePojosWithNonGenericCollections | +0.028 |
+ | testHashMapCreation | +0.104 |
+ | podamShouldFillInPojosWithAttributesContainingWildcards | +0.072 |
+ | testImmutablePojoConstructionFailure | +0.152 |
+ | podamShouldManufacturePackagePrivatePojos | +0.14 |
+ | podamShouldBeAbleToManufactureInstancesOfTheObservableClass | +0.1 |
+ | podamShouldBeAbleToInstantiatePojosWithImmutableCollections | +0.109 |
+ | podamShouldCreateInstancesOfJAXBElementsDeclaredAsInstanceVariablesInAPojo | +0.113 |
+ | podamShouldBeAbleToManufactureAnyTypeOfCollections | +0.125 |
+ | podamShouldCreateInstancesOfInnerClasses | +0.135 |
+ | podamShouldBeAbleToManufacturePojosWhichContainImmutableCollections | +0.106 |
+ | podamShouldHandleGenericsInConstructor | +0.128 |
+ | podamShouldHandleGenericCollectionsInConstructorWithMemoizationEnabled | +0.138 |
+ | podamShouldCreateInstancesOfPojosExtendingGenericClassesWithMatchingGenericPlaceholders | +0.134 |
+ | podamShouldCreateInstancesOfGenericPojosWithFactoryMethodsWhenTheConcreteTypeIsKnown | +0.136 |
+ | podamShouldCreateInstancesOfPojosExtendingGenericClasses | +0.178 |
+ | podamShouldHandleClassesWithKeyValueGenericTypes | +0.118 |
+ | podamShouldHandleGenericCollectionsInConstructorWithMemoizationDisabled | +0.114 |
+ | podamShouldHandleGenericsInSettersDuringPojoInstantiation | +0.13 |
+ | podamShouldBeAbleToManufactureAnyTypeOfMaps | +0.119 |
+ | podamShouldHandleConstructorsWithGenericArraysDuringPojoInstantiation | +0.109 |
+ | podamShouldCreateInstancesOfGenericReadOnlyPojosWithFactoryMethodsWhenTheConcreteTypeIsKnown | +0.11 |
+ | podamShouldBeAbleToInstantiatePojosWithImmutableMaps | +0.12 |
+ | podamShouldHandleConstructorsWithMultipleGenericsDuringPojoInstantiation | +0.131 |
+ | podamShouldInstantiateAbstractClassesForWhichItKnowsConcreteTypes | +0.104 |
+ | podamShouldChooseTheFullestConstructorWhenInvokedForFullData | +0.1 |
+ | podamShouldHandleGenericsInStaticConstructorsDuringPojoInstantiation | +0.113 |
+ | podamShouldCreateInstancesOfJAXBElements | +0.111 |
+ | podamShouldHandleGenericClassesWithParameterUsedInMultiplePlaces | +0.151 |
+ | podamShouldCreateAnInstanceOfAnAbstractClassWithAFactoryMethodWhichReturnsAConcreteType | +0.131 |
+ | podamShouldFillReadOnlyComplexTypes | +0.112 |
+ | podamShouldFillInPojosWhichContainInternalLoops | +0.173 |
+ | podamShouldFillReadOnlyTypes | +0.085 |
+ | randomDataProviderStrategyShouldBeInitialisedCorrectlyAndAllowForChangesInNbrOfCollectionElements | +0.12 |
+ | creatingARandomDataProviderStrategyShouldCreateAConstructorHeavyComparator | +0.16 |
+ | creatingARandomDataProviderStrategyShouldCreateAMethodHeavyComparator | +0.104 |
+ | creatingARandomDataProviderStrategyShouldCreateAConstructorLightComparator | +0.11 |
+ | creatingARandomDataProviderStrategyShouldCreateAMethodLightComparator | +0.119 |
+ | podamShouldCorrectGenerateHashMapsWithLongAsKeyType | +0.105 |
+ | podamShouldCreatePojosInAccordanceWithCustomDataProviderStrategies | +0.104 |
+ | podamShouldFillValuesInvokingChildrenSettersHavingDifferentTypesThanParent | +0.12 |
+ | invokingPodamOnaPojoWithPrivateNoArgumentsConstructorShouldReturnANonEmptyPojo | +0.11 |
+ | podamCannotHandleCircularConstructors | +0.375 |
+ | podamShouldFillPojosWithPublicNonDefaultPublicConstructors | +0 |
+ | podamShouldFillEmbeddedAbstractClassesIfAConcreteTypeHasBeenSpecified | +0 |
+ | podamShouldFillPojosWithProtectedNonDefaultConstructors | +0.106 |
+ | podamShouldReturnANullValueForNonInstantiablePojos | +0.122 |
+ | podamShouldGenerateANonNullPojoForAbstractTypesWithConcreteImplementation | +0.129 |
+ | podamShouldHandlePojosWithSelfReferenceConstructorsButNotDefaultConstructors | +0.198 |
+ | podamShouldThrowAnExceptionIfAPojoContainsInvalidGettersOrSetters | +0.015 |
+ | podamShouldHandlePojosWithPrivateOnlyConstructors | +0.113 |
+ | podamShouldHandlePojosWithAMixOfCircularAndNonCircularConstructors | +0.425 |
+ | podamShouldCreatePojosInAccordanceWithCustomDataProviderStrategies | +0 |
+ | podamShouldCreateTimestampWithCustomTypeManufacturer | +0.013 |
+ | podamShouldCreateInputStreamWithCustomTypeManufacturer | +0.131 |
+ | podamShouldFillTheAttributeMetadataWithTheAttributeNames | +0.133 |
+ | podamShouldNotCreateInstancesOfAnAbstractClassEvenIfPojoHasFullConstructor | +0.135 |
+ | podamShouldNotcreateInstancesOfNonInstantiableClasses | +0.12 |
+ | theManagementOfExternalFactoriesShouldBeCorrectAndChainingShouldWord | +0.117 |
+ | podamDoesNotCreateInstancesOfAbstractClassesIfExternalFactoryDoesNotDefineThem | +0.138 |
+ | podamCannotFillInterfaceAttributesIfTheExternalFactoryDoesNotManufactureTheRightType | +0.22 |
+ | podamShouldNotBeAbleToCreateInterfaceInstancesGivenAnExternalFactoryWhichDoesNotManufactureTheConcreteType | +0.101 |
+ | podamShouldFillPojoInterfaceAttributeIfFullConstructorSetsItsValue | +0.124 |
+ | podamShouldManufactureAttributesImplementingCollectionAndMapInterfaces | +0.133 |
+ | podamShouldHandleBasicInheritance | +0.14 |
+ | podamShouldManufactureAllPojosInATreeHierarchy | +0.112 |
+ | podamShouldHandleTheManufacturingOfPojosWhichInheritFromOtherClasses | +0.105 |
+ | podamCannotInstantiateInterfacesWhichExtendMap | +0.133 |
+ | testHolderOfPojoWithMultiInterfaces | +0.13 |
+ | podamCannotInstantiateInterfaces | +0.1 |
+ | whenMemoizationIsFalsePodamShouldReturnDifferentInstancesForDifferentInvocations | +0.115 |
+ | whenMemoizationIsTruePodamShouldReturnTheSameInstanceForDifferentInvocations | +0.11 |
+ | whenMemoizationCacheIsClearedThenObjectsShouldNotBeEqual | +0.117 |
+ | memoizationShouldWorkCorrectlyForCollectionsAndArrays | +0.12 |
+ | memoizationShouldWorkForRecursivePojos | +0.108 |
+ | memoizationShouldWorkWithGenerics | +0.107 |
+ | evenWhenMemoizationIsTrueIfGenericPojosHaveDifferentTypesObjectsShouldNotBeEqual | +0.108 |
+ | podamMessagingSystemShouldReturnAFloatWrappedValue | +0.115 |
+ | podamMessagingSystemShouldReturnAShortPrimitiveValue | +0.115 |
+ | podamMessagingSystemShouldReturnAnEnumValue | +0.12 |
+ | podamMessagingSystemShouldReturnALongWrappedValue | +0.121 |
+ | podamMessagingSystemShouldReturnALongPrimitiveValue | +0.111 |
+ | podamMessagingSystemShouldReturnAnIntegerValue | +0.112 |
+ | podamMessagingSystemShouldReturnABytePrimitiveValue | +0.11 |
+ | podamMessagingSystemShouldReturnABooleanWrappedValue | +0.104 |
+ | podamMessagingSystemShouldReturnACharacterPrimitiveValue | +0.21 |
+ | podamMessagingSystemShouldReturnAByteWrappedValue | +0.103 |
+ | podamMessagingSystemShouldReturnAStringValue | +0.107 |
+ | podamMessagingSystemShouldReturnAnIntValue | +0.1 |
+ | podamMessagingSystemShouldReturnAShortWrappedValue | +0.11 |
+ | podamMessagingSystemShouldReturnAFloatPrimitiveValue | +0.112 |
+ | podamMessagingSystemShouldReturnACharacterWrappedValue | +0.112 |
+ | podamMessagingSystemShouldReturnADoublePrimitiveValue | +0.111 |
+ | podamMessagingSystemShouldReturnABooleanPrimitiveValue | +0.105 |
+ | podamMessagingSystemShouldReturnADoubleWrappedValue | +0.112 |
+ | whenDigitsAndDecimalMinOrDecimalMaxAreAttachedToTheSameFieldPodamShouldUseMinimumRequirement | +0.355 |
+ | podamShouldAllowValidationAnnotationsCustomization | +0.115 |
+ | whenMaxLengthIsNotSpecifiedInSizeAnnotationPodamShouldAssignASensibleDefault | +0.115 |
+ | podamShouldFulfillMostOfTheJavaxValidationFramework | +0.175 |
+ | whenTheAnnotationStrategyAndTheTypeManufacturerAreSpecifiedTheFormerHasPrecedence | +0.13 |
+ | podamShouldFulfillMostOfTheJavaxValidation20Framework | +0.109 |
+ | testCountrySetup | +0.12 |
+ | testClientSetup | +0.138 |
+ | testOrderSetup | +0.122 |
+ | testArticleSetup | +0.108 |
+ | testBankAccountSetup | +0.122 |
+ | testAddressSetup | +0.122 |
+ | testOrderItemSetup | +0.116 |
+ | testDurationManufacturing | +0.134 |
+ | testXMLDatatypesFieldSetting | +0.12 |
+ | testXMLGregorianCalendarManufacturing | +0.108 |
+ | testPdm3IndirectImplementingMapOfPojos | +0.004 |
+ | testPdm3MapOfGenericPojos | +0 |
+ | testPdm3ListOfGenericPojos | +0 |
+ | testPdm3ExtendingMapOfPojos | +0 |
+ | testPdm3ListOfPojos | +0 |
+ | testPdm3IndirectImplementingListOfPojos | +0.004 |
+ | testPdm3MapOfPojos | +0 |
+ | testPdm3PojoConstructor | +0 |
+ | testPdm3ImplementingListOfPojos | +0 |
+ | testPdm3WildcardPojo | +0 |
+ | testPdm3ImplementingMapOfPojos | +0 |
+ | testPdm3ExtendingImplementingMapOfPojos | +0 |
+ | testPdm3Pojo | +0 |
+ | testPdm3ExtendingListOfPojos | +0 |
+ | testPdm3ExtendingNonRawMapOfPojos | +0.004 |
+ | testPdm3ExtendingImplementingListOfPojos | +0 |
+ | testPdm3PojoGenericsConstructor | +0 |
+ | testPdm3ExtendingRawListOfPojos | +0.004 |
+ | testPdm4PojoWithSetters | +0.024 |
+ | testPdm4PojoWithFullData | +0.028 |
+ | testPojoWithFactoryMethods | +0.032 |
+ | testPojoWithFactoryMethodsWithFullData | +0.032 |
+ | testPojoWithMultipleNonPublicConstructorsWithFullData | +0.028 |
+ | testPojoWithMultipleNonPublicConstructors | +0.024 |
+ | testParametrizedNestedGenericPojo | +0.012 |
+ | testConstructorMultiDimensionalPojo | +0.104 |
+ | testGenericArrayPojoManufacture | +0 |
+ | testPojoWithGenericFields | +0 |
+ | testGenericPojoManufacture | +0 |
+ | testMultiDimensionalPojoManufacture | +0.08 |
+ | testGenericListPojoManufacture | +0 |
+ | testGenericMapPojoManufacture | +0.014 |
+ | testMultiDimensionalTestPojo | +0.124 |
PODAM FAQs
-- Ok, so you have set a property firstName with the annotation @PodamStringValue(strValue = "Michael"). - This means that PODAM will fill every instance of the annotated POJO attribute with the value "Michael". - Unfortunately, there is no easy way around this: when you use a PODAM custom annotation, the values driven by the - annotation are assigned to every instance of the annotated POJO. There is an acceptable solution though: - you can have PODAM to fill the POJO for you and then manually change the attributes for which a particular - run needs particular values. This is obviously possible if the POJO allows for changes in state. For - immutable-like POJOs there is no easy way to get around this issue and ultimately you might want to - manufacture an immutable-like POJO by hand. -
- - -- - ...In Client.java - - @PodamStringValue(strValue = "Michael") - private String firstName; - - [etc.] - - ...In your client - - Client client = PodamFactory.manufacturePojo(Client.class); - - //firstName is now set with the value "Michael" but you can change it - //with the value of your choice (provided the POJO is not immutable) - pojo.setFirstName("MyOtherValue"); - -
- You want to provide your own implementation of the DataProviderStrategy. Podam uses the - default implementation (RandomDataProviderStrategy) but you can define pretty much what - you want. We've provided AbstractRandomDataProviderStrategy to take away most of the - boilerplate code. So you could write your own extension to this class customising the - types you want to provide yourself. -
- -- Please refer to the home page documentation for examples on how to do this. -
+PODAM FAQs
++ Ok, so you have set a property firstName with the annotation @PodamStringValue(strValue = "Michael"). + This means that PODAM will fill every instance of the annotated POJO attribute with the value "Michael". + Unfortunately, there is no easy way around this: when you use a PODAM custom annotation, the values driven by the + annotation are assigned to every instance of the annotated POJO. There is an acceptable solution though: + you can have PODAM to fill the POJO for you and then manually change the attributes for which a particular + run needs particular values. This is obviously possible if the POJO allows for changes in state. For + immutable-like POJOs there is no easy way to get around this issue and ultimately you might want to + manufacture an immutable-like POJO by hand. +
+ + ++ + ...In Client.java + + @PodamStringValue(strValue = "Michael") + private String firstName; + + [etc.] + + ...In your client + + Client client = PodamFactory.manufacturePojo(Client.class); + + //firstName is now set with the value "Michael" but you can change it + //with the value of your choice (provided the POJO is not immutable) + pojo.setFirstName("MyOtherValue"); + +
+ You want to provide your own implementation of the DataProviderStrategy. Podam uses the + default implementation (RandomDataProviderStrategy) but you can define pretty much what + you want. We've provided AbstractRandomDataProviderStrategy to take away most of the + boilerplate code. So you could write your own extension to this class customising the + types you want to provide yourself. +
+ ++ Please refer to the home page documentation for examples on how to do this. +
There are various ways you could contribute to PODAM:
-There are various ways you could contribute to PODAM:
+Happy technology!
PODAM is a lightweight tool to auto-fill Java POJOs with data. This comes handy when developing unit tests. Thanks to PODAM users now have a one-liner that does all the work them.
-To see how you add PODAM to your project, please refer to the usage page.
// Simplest scenario. Will delegate to Podam all decisions -PodamFactory factory = new PodamFactoryImpl(); - -// This will use constructor with minimum arguments and -// then setters to populate POJO -Pojo myPojo = factory.manufacturePojo(Pojo.class); - -// This will use constructor with maximum arguments and -// then setters to populate POJO -Pojo myPojo2 = factory.manufacturePojoWithFullData(Pojo.class); - -// If object instance is already available, -// Podam can fill it with random data -Pojo myPojo3 = MyFactory.getPojoInstance(); -factory.populatePojo(myPojo3);
PODAM allows users to customise the way data are assigned in several ways:
-The default strategy for PODAM is Random values. However users can define their own global strategy by providing an implementation of the DataProviderStrategy interface, as follows:
--DataProviderStrategy strategy = new MyDataProviderStrategy(); -PodamFactory factory = new PodamFactoryImpl(strategy); - -Pojo myPojo = factory.manufacturePojo(Pojo.class); - -Pojo myPojo2 = factory.manufacturePojoWithFullData(Pojo.class); -
Please note that annotations are not required to use PODAM. The tool will automatically introspect and fill your tree of POJOs out-of-the-box. The preferred way to customise the way PODAM fills your data is through a custom DataProviderStrategy, as shown above. However one can annotate Java classes to provide custom values, as shown below. Podam also supports your own annotations.
PODAM allows also users to define data strategies at the attribute level: this includes the capability to define custom strategies for elements and keys in collections, maps and arrays. In order to define an attribute-level strategy, users will need to:
-Example:
--@PodamStrategyValue(PostCodeStrategy.class) -private String postCode; - -@PodamStrategyValue(MyBirthdayStrategy.class) -private Calendar myBirthday; -
In this example I defined two attribute-level strategies:
-The PostCodeStrategy class looks like the following:
-/** - * - */ -package uk.co.jemos.podam.test.strategies; - -import uk.co.jemos.podam.api.AttributeStrategy; -import uk.co.jemos.podam.exceptions.PodamMockeryException; -import uk.co.jemos.podam.test.utils.PodamTestConstants; - -/** - * A test strategy to manufacture UK-like post codes. - * - * @author mtedone - * - */ -public class PostCodeStrategy implements AttributeStrategy<String> { - - /** - * It returns an English post code. - * <p> - * This is just an example. More elaborated code could the implemented by - * this method. This is just to proof the point. - * </p> - * - * {@inheritDoc} - */ - public String getValue() throws PodamMockeryException { - return PodamTestConstants.POST_CODE; - } - -} -
There is nothing special about the above class: it's job is just to provide a value of the right type.
-The MyBirthdayStrategy class looks like the following:
--/** - * - */ -package uk.co.jemos.podam.test.strategies; - -import java.util.Calendar; - -import uk.co.jemos.podam.api.AttributeStrategy; -import uk.co.jemos.podam.exceptions.PodamMockeryException; -import uk.co.jemos.podam.test.utils.PodamTestUtils; - -/** - * An attribute strategy which returns a Calendar object set with my DOB. - * - * @author mtedone - * - */ -public class MyBirthdayStrategy implements AttributeStrategy<Calendar> { - - /** - * It returns a {@link Calendar} object set with the exact date of my - * birthday. - * - * {@inheritDoc} - */ - public Calendar getValue() throws PodamMockeryException { - - Calendar myBirthday = PodamTestUtils.getMyBirthday(); - - return myBirthday; - } - -} - -
The capability to customise the strategy PODAM uses to fill attribute data is extended to container-like data structures, such as Collections, Maps and Arrays; however for these data structures use the @PodamCollection annotation. Please refer to The annotation page for more details.
-Example on how to use PODAM custom attribute strategy to fill collection elements:
--@PodamCollection(nbrElements = 2, collectionElementStrategy = MyBirthdayStrategy.class) -private List<Calendar> myBirthdays = new ArrayList<Calendar>(); -
Example on how to use PODAM custom attribute strategy to fill Map keys and elements. Please note that @PodamCollection offers also the possibility to define a strategy to set the values for keys in a Map, through the mapKeyStrategy attribute:
--@PodamCollection(nbrElements = 2, mapElementStrategy = MyBirthdayStrategy.class) -private Map<String, Calendar> myBirthdaysMap = new HashMap<String, Calendar>(); -
Example on how to use PODAM custom attribute strategy to fill array elements:
--@PodamCollection(nbrElements = 2, collectionElementStrategy = MyBirthdayStrategy.class) -private Calendar[] myBirthdaysArray; -
PODAM will use the MyBirthdayStrategy to set the value for the two array elements.
Primitive and Wrapper type values can be customised through annotations.
-@PodamDoubleValue(minValue = PodamTestConstants.NUMBER_DOUBLE_MIN_VALUE, maxValue = PodamTestConstants.NUMBER_DOUBLE_MAX_VALUE) -private double doubleFieldWithMinAndMaxValue;
Please note that by contract (DataProviderStrategy) min and max values are inclusive.
-For a full list of supported annotations, please refer to the Annotations page.
-To know more about how PODAM works, please refer to the The walk-through example page or to the Corner Cases page on the left menu.
You can use PODAM to fill in generic collections with dummy data.
-PodamFactory podam = new PodamFactoryImpl(); - -// Annotation required to remove warning because of type erasure although it would work without -@SuppressWarnings("unchecked") -List<String> list = podam.manufacturePojo(ArrayList.class, String.class); -
Assuming we are filling the class
-public static class Pojo { - private String randomString; - private String postCode; - private URL url; - - public String getRandomString() { return randomString; } - - public void setRandomString(String randomString) { this.randomString = randomString; } - - public String getUrl() { return url.toString(); } - - public void setUrl(String url) throws MalformedURLException { this.url = new URL(url); } - - public String getPostCode() { return postCode; } - - public void setPostCode(String postCode) { this.postCode = postCode; } -}
Define custom TypeManufacturer, which will be producing string values depending on attribute name
-public class CustomStringManufacturer extends StringTypeManufacturerImpl() { - - @Override - public String getType(DataProviderStrategy strategy, - AttributeMetadata attributeMetadata, - Map<String, Type> genericTypesArgumentsMap) { - - if (Pojo.class.isAssignableFrom(attributeMetadata.getPojoClass())) { - - if ("url".equals(attributeMetadata.getAttributeName())) { - return "http://wikipedia.org"; - } else if ("postCode".equals(attributeMetadata.getAttributeName())) { - return "00100"; - } - } - return super.getType(strategy, attributeMetadata, genericTypesArgumentsMap); - }; -}
Intantiate POJO with PodamFactory
-CustomStringManufacturer customStringManufacturer = new CustomStringManufacturer(); -PodamFactory factory = new PodamFactoryImpl(); -factory.getStrategy().addOrReplaceTypeManufacturer(String.class, customStringManufacturer);
Result:
-{ - "randomString":"rP_yOK2EtR", - "postCode":"00100", - "url":"http://wikipedia.org" -}
DataProviderStrategy can be extended to hint Podam with factory classes to initialize POJOs.
-RandomDataProviderStrategy strategy = (RandomDataProviderStrategy) factory.getStrategy(); -strategy.addOrReplaceFactory( - javax.xml.transform.Transformer.class, - javax.xml.transform.TransformerFactory.class); -Transformer pojo = factory.manufacturePojo(javax.xml.transform.Transformer.class);
Sometimes you may want to manufacture a generic type directly without a wrapper class or a subclass.
-As you should have noticed, the manufacturePojo method of the PodamFactory interface can take some additional parameters through varargs. This is a way to allow the definition of the generic types for a given class.
-The following class is an example of a generic POJO:
-public class GenericPojo<F, S> { - - private F firstValue; - private S secondValue; - @PodamCollection(nbrElements = 2) - private List<F> firstList; - @PodamCollection(nbrElements = 2) - private S[] secondArray; - @PodamCollection(nbrElements = 2) - private Map<F, S> firstSecondMap; - - ... getter, setters and toString -}
Now imagine that you want an instance of this class defining F and S as Double and String respectively. This is how it should be done:
-GenericPojo pojo = factory.manufacturePojo(GenericPojo.class, Double.class, String.class);
As you can see, the first class is the POJO to be manufactured (GenericPojo), and the subsequent classes are the type parameters to be used for this GenericPojo instance.
-This is the result of the call above:
-GenericPojo [ - firstValue=0.03181392348712919, - secondValue=L4OicBAhKY, - firstList=[0.770082469177622, 0.7924208229673068], - secondArray=[8EsGFHtwwE, Zqz8B_4oAr], - firstSecondMap={0.778926356384843=sl4FxQIEYe, 0.2909259461070528=j8mlZshNsv} -]
It is also possible to specify some complex nested generic types like GenericPojo<GenericPojo<String, Long>, Map<Integer, List<Boolean>>> using the uk.co.jemos.podam.api.PodamParameterizedType class as in the following example:
-ParameterizedType stringLongGenericPojoType = - new PodamParameterizedType(GenericPojo.class, String.class, Long.class); - -ParameterizedType IntegerBooleanListMapType = - new PodamParameterizedType(Map.class, - Integer.class, - new PodamParameterizedType(List.class, Boolean.class)); - -GenericPojo<GenericPojo<String, Long>, Map<Integer, List<Boolean>>> pojo = - factory.manufacturePojo(GenericPojo.class, stringLongGenericPojoType, IntegerBooleanListMapType);
Running the code above the following result is produced:
-GenericPojo [ - firstValue=GenericPojo [ - firstValue=e0NI7ZnKfW, - secondValue=1340165351073, - firstList=[2UlUwNJdOS, bZ7X0KZWtV], - secondArray=[1340165351073, 1340165351073], - firstSecondMap={QiB36seL99=1340165351072, Dk_KwHCGOq=1340165351072} - ], - secondValue={2081811337=[true]}, - firstList=[ - GenericPojo [ - firstValue=ECNfFuF6WM, - secondValue=1340165351067, - firstList=[QfZXnqOk1N, HDAGfxdat0], - secondArray=[1340165351067, 1340165351067], - firstSecondMap={UgJ4VNvro_=1340165351067, 5NGtW0hH0h=1340165351067} - ], - GenericPojo [ - firstValue=kHryFVavEn, - secondValue=1340165351070, - firstList=[wAKe40d3zO, OH8q03P9Cw], - secondArray=[1340165351070, 1340165351070], - firstSecondMap={LhRoWR2DNX=1340165351068, zg0IAN4ZZ5=1340165351068} - ] - ], - secondArray=[{2115657799=[true, true], -1507554610=[true, true]}, {1990372468=[true, true], -340173617=[true, true]}], - firstSecondMap={ - GenericPojo [ - firstValue=WeEDkbr2pc, - secondValue=1340165351058, - firstList=[0TRSKWur8n, vbIptzObXA], - secondArray=[1340165351057, 1340165351057], - firstSecondMap={49wLsEiuip=1340165351056, LGIUi7CptX=1340165351056} - ] = {1126207473=[true, true], -1973087621=[true, true]}, - GenericPojo [ - firstValue=2RtNOrjgjZ, - secondValue=1340165351064, - firstList=[l1S7URCgFT, ntoKQnI1Kj], - secondArray=[1340165351064, 1340165351064], - firstSecondMap={F0gqzGJMZL=1340165351061, vXdlU9NCfR=1340165351061} - ] = {-485029362=[true, true], 609129754=[true, true]} - } -]
Building huge graphs of nested objects may take time. Podam has a memoization option to help it. When enabled, Podam will only create a unique object for each class and reuse it. This reduces algorithmic complexity in scenarios where distinct random data is not needed. To disable memoization, you can do the following:
-PodamFactory podam = new PodamFactoryImpl(); -podam.getStrategy().setMemoizationEnabled(false);
Class info strategy can be instructed to execute arbitrary methods after POJO creation and hydation.
-For example, the class
-public class MyPojo { - - private String strValue; - private Integer intValue; - - public void init(String strValue, Integer intValue) { - this.strValue = strValue; - this.intValue = intValue; - } -}
One needs to specify POJO class, method name and list of method parameter types.
-DefaultClassInfoStrategy classInfoStrategy = DefaultClassInfoStrategy.getInstance(); -classInfoStrategy.addExtraMethod(MyPojo.class, "init", String.class, Integer.class);
Then instantiation will look like:
-PodamFactory podam = new PodamFactoryImpl(); -Pojo myPojo = factory.manufacturePojo(Pojo.class);
PODAM is a lightweight tool to auto-fill Java POJOs with data. This comes handy when developing unit tests. Thanks to PODAM users now have a one-liner that does all the work them.
+To see how you add PODAM to your project, please refer to the usage page.
// Simplest scenario. Will delegate to Podam all decisions +PodamFactory factory = new PodamFactoryImpl(); + +// This will use constructor with minimum arguments and +// then setters to populate POJO +Pojo myPojo = factory.manufacturePojo(Pojo.class); + +// This will use constructor with maximum arguments and +// then setters to populate POJO +Pojo myPojo2 = factory.manufacturePojoWithFullData(Pojo.class); + +// If object instance is already available, +// Podam can fill it with random data +Pojo myPojo3 = MyFactory.getPojoInstance(); +factory.populatePojo(myPojo3); +
PODAM allows users to customise the way data are assigned in several ways:
+The default strategy for PODAM is Random values. However users can define their own global strategy by providing an implementation of the DataProviderStrategy interface, as follows:
++DataProviderStrategy strategy = new MyDataProviderStrategy(); +PodamFactory factory = new PodamFactoryImpl(strategy); + +Pojo myPojo = factory.manufacturePojo(Pojo.class); + +Pojo myPojo2 = factory.manufacturePojoWithFullData(Pojo.class); + +
Please note that annotations are not required to use PODAM. The tool will automatically introspect and fill your tree of POJOs out-of-the-box. The preferred way to customise the way PODAM fills your data is through a custom DataProviderStrategy, as shown above. However one can annotate Java classes to provide custom values, as shown below. Podam also supports your own annotations.
PODAM allows also users to define data strategies at the attribute level: this includes the capability to define custom strategies for elements and keys in collections, maps and arrays. In order to define an attribute-level strategy, users will need to:
+Example:
++@PodamStrategyValue(PostCodeStrategy.class) +private String postCode; + +@PodamStrategyValue(MyBirthdayStrategy.class) +private Calendar myBirthday; + +
In this example I defined two attribute-level strategies:
+The PostCodeStrategy class looks like the following:
+/** + * + */ +package uk.co.jemos.podam.test.strategies; + +import uk.co.jemos.podam.api.AttributeStrategy; +import uk.co.jemos.podam.exceptions.PodamMockeryException; +import uk.co.jemos.podam.test.utils.PodamTestConstants; + +/** + * A test strategy to manufacture UK-like post codes. + * + * @author mtedone + * + */ +public class PostCodeStrategy implements AttributeStrategy<String> { + + /** + * It returns an English post code. + * <p> + * This is just an example. More elaborated code could the implemented by + * this method. This is just to proof the point. + * </p> + * + * {@inheritDoc} + */ + public String getValue() throws PodamMockeryException { + return PodamTestConstants.POST_CODE; + } + +} + +
There is nothing special about the above class: it's job is just to provide a value of the right type.
+The MyBirthdayStrategy class looks like the following:
++/** + * + */ +package uk.co.jemos.podam.test.strategies; + +import java.util.Calendar; + +import uk.co.jemos.podam.api.AttributeStrategy; +import uk.co.jemos.podam.exceptions.PodamMockeryException; +import uk.co.jemos.podam.test.utils.PodamTestUtils; + +/** + * An attribute strategy which returns a Calendar object set with my DOB. + * + * @author mtedone + * + */ +public class MyBirthdayStrategy implements AttributeStrategy<Calendar> { + + /** + * It returns a {@link Calendar} object set with the exact date of my + * birthday. + * + * {@inheritDoc} + */ + public Calendar getValue() throws PodamMockeryException { + + Calendar myBirthday = PodamTestUtils.getMyBirthday(); + + return myBirthday; + } + +} + + +
The capability to customise the strategy PODAM uses to fill attribute data is extended to container-like data structures, such as Collections, Maps and Arrays; however for these data structures use the @PodamCollection annotation. Please refer to The annotation page for more details.
+Example on how to use PODAM custom attribute strategy to fill collection elements:
++@PodamCollection(nbrElements = 2, collectionElementStrategy = MyBirthdayStrategy.class) +private List<Calendar> myBirthdays = new ArrayList<Calendar>(); + +
Example on how to use PODAM custom attribute strategy to fill Map keys and elements. Please note that @PodamCollection offers also the possibility to define a strategy to set the values for keys in a Map, through the mapKeyStrategy attribute:
++@PodamCollection(nbrElements = 2, mapElementStrategy = MyBirthdayStrategy.class) +private Map<String, Calendar> myBirthdaysMap = new HashMap<String, Calendar>(); + +
Example on how to use PODAM custom attribute strategy to fill array elements:
++@PodamCollection(nbrElements = 2, collectionElementStrategy = MyBirthdayStrategy.class) +private Calendar[] myBirthdaysArray; + +
PODAM will use the MyBirthdayStrategy to set the value for the two array elements.
Primitive and Wrapper type values can be customised through annotations.
+@PodamDoubleValue(minValue = PodamTestConstants.NUMBER_DOUBLE_MIN_VALUE, maxValue = PodamTestConstants.NUMBER_DOUBLE_MAX_VALUE) +private double doubleFieldWithMinAndMaxValue; +
Please note that by contract (DataProviderStrategy) min and max values are inclusive.
+For a full list of supported annotations, please refer to the Annotations page.
+To know more about how PODAM works, please refer to the The walk-through example page or to the Corner Cases page on the left menu.
You can use PODAM to fill in generic collections with dummy data.
+PodamFactory podam = new PodamFactoryImpl(); + +// Annotation required to remove warning because of type erasure although it would work without +@SuppressWarnings("unchecked") +List<String> list = podam.manufacturePojo(ArrayList.class, String.class); + +
Assuming we are filling the class
+public static class Pojo { + private String randomString; + private String postCode; + private URL url; + + public String getRandomString() { return randomString; } + + public void setRandomString(String randomString) { this.randomString = randomString; } + + public String getUrl() { return url.toString(); } + + public void setUrl(String url) throws MalformedURLException { this.url = new URL(url); } + + public String getPostCode() { return postCode; } + + public void setPostCode(String postCode) { this.postCode = postCode; } +} +
Define custom TypeManufacturer, which will be producing string values depending on attribute name
+public class CustomStringManufacturer extends StringTypeManufacturerImpl() { + + @Override + public String getType(DataProviderStrategy strategy, + AttributeMetadata attributeMetadata, + Map<String, Type> genericTypesArgumentsMap) { + + if (Pojo.class.isAssignableFrom(attributeMetadata.getPojoClass())) { + + if ("url".equals(attributeMetadata.getAttributeName())) { + return "http://wikipedia.org"; + } else if ("postCode".equals(attributeMetadata.getAttributeName())) { + return "00100"; + } + } + return super.getType(strategy, attributeMetadata, genericTypesArgumentsMap); + }; +} +
Intantiate POJO with PodamFactory
+CustomStringManufacturer customStringManufacturer = new CustomStringManufacturer(); +PodamFactory factory = new PodamFactoryImpl(); +factory.getStrategy().addOrReplaceTypeManufacturer(String.class, customStringManufacturer); +
Result:
+{ + "randomString":"rP_yOK2EtR", + "postCode":"00100", + "url":"http://wikipedia.org" +} +
DataProviderStrategy can be extended to hint Podam with factory classes to initialize POJOs.
+RandomDataProviderStrategy strategy = (RandomDataProviderStrategy) factory.getStrategy(); +strategy.addOrReplaceFactory( + javax.xml.transform.Transformer.class, + javax.xml.transform.TransformerFactory.class); +Transformer pojo = factory.manufacturePojo(javax.xml.transform.Transformer.class); +
Sometimes you may want to manufacture a generic type directly without a wrapper class or a subclass.
+As you should have noticed, the manufacturePojo method of the PodamFactory interface can take some additional parameters through varargs. This is a way to allow the definition of the generic types for a given class.
+The following class is an example of a generic POJO:
+public class GenericPojo<F, S> { + + private F firstValue; + private S secondValue; + @PodamCollection(nbrElements = 2) + private List<F> firstList; + @PodamCollection(nbrElements = 2) + private S[] secondArray; + @PodamCollection(nbrElements = 2) + private Map<F, S> firstSecondMap; + + ... getter, setters and toString +} +
Now imagine that you want an instance of this class defining F and S as Double and String respectively. This is how it should be done:
+GenericPojo pojo = factory.manufacturePojo(GenericPojo.class, Double.class, String.class); +
As you can see, the first class is the POJO to be manufactured (GenericPojo), and the subsequent classes are the type parameters to be used for this GenericPojo instance.
+This is the result of the call above:
+GenericPojo [ + firstValue=0.03181392348712919, + secondValue=L4OicBAhKY, + firstList=[0.770082469177622, 0.7924208229673068], + secondArray=[8EsGFHtwwE, Zqz8B_4oAr], + firstSecondMap={0.778926356384843=sl4FxQIEYe, 0.2909259461070528=j8mlZshNsv} +] +
It is also possible to specify some complex nested generic types like GenericPojo<GenericPojo<String, Long>, Map<Integer, List<Boolean>>> using the uk.co.jemos.podam.api.PodamParameterizedType class as in the following example:
+ParameterizedType stringLongGenericPojoType = + new PodamParameterizedType(GenericPojo.class, String.class, Long.class); + +ParameterizedType IntegerBooleanListMapType = + new PodamParameterizedType(Map.class, + Integer.class, + new PodamParameterizedType(List.class, Boolean.class)); + +GenericPojo<GenericPojo<String, Long>, Map<Integer, List<Boolean>>> pojo = + factory.manufacturePojo(GenericPojo.class, stringLongGenericPojoType, IntegerBooleanListMapType); +
Running the code above the following result is produced:
+GenericPojo [ + firstValue=GenericPojo [ + firstValue=e0NI7ZnKfW, + secondValue=1340165351073, + firstList=[2UlUwNJdOS, bZ7X0KZWtV], + secondArray=[1340165351073, 1340165351073], + firstSecondMap={QiB36seL99=1340165351072, Dk_KwHCGOq=1340165351072} + ], + secondValue={2081811337=[true]}, + firstList=[ + GenericPojo [ + firstValue=ECNfFuF6WM, + secondValue=1340165351067, + firstList=[QfZXnqOk1N, HDAGfxdat0], + secondArray=[1340165351067, 1340165351067], + firstSecondMap={UgJ4VNvro_=1340165351067, 5NGtW0hH0h=1340165351067} + ], + GenericPojo [ + firstValue=kHryFVavEn, + secondValue=1340165351070, + firstList=[wAKe40d3zO, OH8q03P9Cw], + secondArray=[1340165351070, 1340165351070], + firstSecondMap={LhRoWR2DNX=1340165351068, zg0IAN4ZZ5=1340165351068} + ] + ], + secondArray=[{2115657799=[true, true], -1507554610=[true, true]}, {1990372468=[true, true], -340173617=[true, true]}], + firstSecondMap={ + GenericPojo [ + firstValue=WeEDkbr2pc, + secondValue=1340165351058, + firstList=[0TRSKWur8n, vbIptzObXA], + secondArray=[1340165351057, 1340165351057], + firstSecondMap={49wLsEiuip=1340165351056, LGIUi7CptX=1340165351056} + ] = {1126207473=[true, true], -1973087621=[true, true]}, + GenericPojo [ + firstValue=2RtNOrjgjZ, + secondValue=1340165351064, + firstList=[l1S7URCgFT, ntoKQnI1Kj], + secondArray=[1340165351064, 1340165351064], + firstSecondMap={F0gqzGJMZL=1340165351061, vXdlU9NCfR=1340165351061} + ] = {-485029362=[true, true], 609129754=[true, true]} + } +] +
Building huge graphs of nested objects may take time. Podam has a memoization option to help it. When enabled, Podam will only create a unique object for each class and reuse it. This reduces algorithmic complexity in scenarios where distinct random data is not needed. To disable memoization, you can do the following:
+PodamFactory podam = new PodamFactoryImpl(); +podam.getStrategy().setMemoizationEnabled(false); +
Class info strategy can be instructed to execute arbitrary methods after POJO creation and hydation.
+For example, the class
+public class MyPojo { + + private String strValue; + private Integer intValue; + + public void init(String strValue, Integer intValue) { + this.strValue = strValue; + this.intValue = intValue; + } +} +
One needs to specify POJO class, method name and list of method parameter types.
+DefaultClassInfoStrategy classInfoStrategy = DefaultClassInfoStrategy.getInstance(); +classInfoStrategy.addExtraMethod(MyPojo.class, "init", String.class, Integer.class); +
Then instantiation will look like:
+PodamFactory podam = new PodamFactoryImpl(); +Pojo myPojo = factory.manufacturePojo(Pojo.class); +
PODAM will use values provided by DataProviderStrategy as parameters to call the methods.
Issues, bugs, and feature requests should be submitted to the following issue tracking system for this project.
-Typically the licenses listed for the project are that of the project itself, and not of dependencies.
The MIT License - -Copyright (c) 2002-2014 Marco Tedone, Jemos - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +++Overview
+Typically the licenses listed for the project are that of the project itself, and not of dependencies.
+Project License
++Podam runs under the MIT license
++The MIT License + +Copyright (c) 2002-2014 Marco Tedone, Jemos + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
These are the mailing lists that have been established for this project. For each list, there is a subscribe, unsubscribe, and an archive link.
-