├── .circleci └── config.yml ├── .gitignore ├── .springBeans ├── .travis.yml ├── LICENSE.txt ├── README.md ├── pom.xml ├── serenity.properties └── src ├── main ├── assembly │ ├── bin.xml │ └── project.xml └── java │ └── uk │ └── co │ └── jemos │ └── podam │ ├── api │ ├── AbstractClassInfoStrategy.java │ ├── AbstractExternalFactory.java │ ├── AbstractMapArguments.java │ ├── AbstractRandomDataProviderStrategy.java │ ├── AttributeMetadata.java │ ├── ClassAttribute.java │ ├── ClassAttributeApprover.java │ ├── ClassInfo.java │ ├── ClassInfoStrategy.java │ ├── DataProviderStrategy.java │ ├── DefaultClassInfoStrategy.java │ ├── MapArguments.java │ ├── MapKeyOrElementsArguments.java │ ├── NullExternalFactory.java │ ├── ObjectStrategy.java │ ├── PodamFactory.java │ ├── PodamFactoryImpl.java │ ├── PodamUtils.java │ ├── RandomDataProviderStrategy.java │ ├── RandomDataProviderStrategyImpl.java │ └── package-info.java │ ├── common │ ├── AbstractConstructorComparator.java │ ├── AbstractMethodComparator.java │ ├── AttributeStrategy.java │ ├── BeanValidationStrategy.java │ ├── ConstructorHeavyFirstComparator.java │ ├── ConstructorLightFirstComparator.java │ ├── EmailStrategy.java │ ├── Holder.java │ ├── ManufacturingContext.java │ ├── MethodHeavyFirstComparator.java │ ├── MethodLightFirstComparator.java │ ├── PodamAnnotation.java │ ├── PodamBooleanValue.java │ ├── PodamByteValue.java │ ├── PodamCharValue.java │ ├── PodamCollection.java │ ├── PodamConstants.java │ ├── PodamConstructor.java │ ├── PodamDoubleValue.java │ ├── PodamExclude.java │ ├── PodamFloatValue.java │ ├── PodamIntValue.java │ ├── PodamLongValue.java │ ├── PodamShortValue.java │ ├── PodamStrategyValue.java │ ├── PodamStringValue.java │ └── package-info.java │ ├── exceptions │ ├── PodamMockeryException.java │ └── package-info.java │ └── typeManufacturers │ ├── AbstractTypeManufacturer.java │ ├── ArrayTypeManufacturerImpl.java │ ├── BooleanTypeManufacturerImpl.java │ ├── ByteTypeManufacturerImpl.java │ ├── CharTypeManufacturerImpl.java │ ├── CollectionTypeManufacturerImpl.java │ ├── DoubleTypeManufacturerImpl.java │ ├── EnumTypeManufacturerImpl.java │ ├── FloatTypeManufacturerImpl.java │ ├── IntTypeManufacturerImpl.java │ ├── LongTypeManufacturerImpl.java │ ├── MapTypeManufacturerImpl.java │ ├── ShortTypeManufacturerImpl.java │ ├── StringTypeManufacturerImpl.java │ ├── TypeManufacturer.java │ ├── TypeManufacturerUtil.java │ ├── TypeTypeManufacturerImpl.java │ └── package-info.java ├── site ├── apt │ ├── annotations.apt │ ├── corner-cases.apt │ ├── downloads.apt │ ├── how-to-contribute.apt │ ├── index.apt │ ├── usage.apt │ ├── validation-api.apt │ └── walk-through-example.apt ├── fml │ └── faqs.fml ├── resources │ ├── css │ │ └── podam.css │ ├── images │ │ ├── idea.jpg │ │ ├── logo.gif │ │ ├── nexus-oss.png │ │ └── walkthrough-example.png │ ├── release-notes │ │ └── release-notes.html │ ├── sponsors │ │ └── sponsors.html │ └── uml │ │ ├── Type Hierarchy.png │ │ ├── architecture.html │ │ ├── podam-architecture.png │ │ ├── podam.mdj │ │ └── type-manufacturers-architecture.png └── site.xml └── test ├── java └── uk │ └── co │ └── jemos │ └── podam │ └── test │ ├── dto │ ├── AbstractClass.java │ ├── AbstractOneDimensionalPojo.java │ ├── AbstractTestPojo.java │ ├── AddressTestPojo.java │ ├── ArrayPojo.java │ ├── BadlyTypedFixedPojo.java │ ├── BadlyTypedPojo.java │ ├── BankAccountTestPojo.java │ ├── BooleanPojo.java │ ├── CharSequencePojo.java │ ├── ClassGenericConstructorPojo.java │ ├── ClassGenericPojo.java │ ├── ClassInheritedPojo.java │ ├── ClassPojo.java │ ├── ClientTestPojo.java │ ├── CollectionExtendingGenericsPojo.java │ ├── CollectionExtendingImplementingPojo.java │ ├── CollectionExtendingNoGenericsPojo.java │ ├── CollectionImplementingGenericsInterface.java │ ├── CollectionIndirectExtendingGenericsPojo.java │ ├── CollectionIndirectRawImplPojo.java │ ├── CollectionReadOnlyPojo.java │ ├── CollectionsPojo.java │ ├── ConcreteTestPojo.java │ ├── ConcreteTestPojoWithAdditionalString.java │ ├── ConstructorWithSelfReferencesButNoDefaultConstructorPojo.java │ ├── ConstructorWithSelfReferencesPojoAndDefaultConstructor.java │ ├── DefaultFieldPojo.java │ ├── DefaultMapSingleTypePojo.java │ ├── EmbeddedAbstractFieldTestPojo.java │ ├── EmptyTestPojo.java │ ├── EnumsPojo.java │ ├── ExcludeAnnotationPojo.java │ ├── ExtendedTypedClassPojo.java │ ├── FactoryInstantiablePojo.java │ ├── FactoryInstantiablePojoImpl.java │ ├── FactoryInstantiableReadOnlyPojo.java │ ├── FactoryInstantiableReadOnlyPojoImpl.java │ ├── FloatExt.java │ ├── FloatExt2.java │ ├── GenericArrayInConstructorPojo.java │ ├── GenericInConstructorPojo.java │ ├── GenericInSetterPojo.java │ ├── GenericInStaticConstructorPojo.java │ ├── GenericInStaticConstructorPojoImpl.java │ ├── ImmutableDefaultFieldsPojo.java │ ├── ImmutableHashtable.java │ ├── ImmutableNoHierarchicalAnnotatedPojo.java │ ├── ImmutableNonAnnotatedPojo.java │ ├── ImmutablePojo.java │ ├── ImmutableVector.java │ ├── ImmutableWithGenericCollectionsPojo.java │ ├── ImmutableWithNonGenericCollectionsPojo.java │ ├── InnerClassPojo.java │ ├── InterfacePojo.java │ ├── JAXBElementPojo.java │ ├── JacksonDatabindPojo.java │ ├── MapExtendingGenericsPojo.java │ ├── MapExtendingImplementingPojo.java │ ├── MapExtendingNoGenericsPojo.java │ ├── MapImplementingGenericInterface.java │ ├── MapIndirectExtendingGenericsPojo.java │ ├── MapIndirectRawImplPojo.java │ ├── MemoizationPojo.java │ ├── MultiDimensionalConstructorPojo.java │ ├── MultiDimensionalTestPojo.java │ ├── MultipleGenericInConstructorPojo.java │ ├── MultipleInterfacesHolderPojo.java │ ├── MultipleInterfacesListPojo.java │ ├── MultipleInterfacesMapPojo.java │ ├── NoDefaultConstructorPojo.java │ ├── NonEJBPojo.java │ ├── NonInstantiatableClass.java │ ├── NonStandardPojoToTestSetters.java │ ├── ObjectExt.java │ ├── OneDimensionalChildPojo.java │ ├── OneDimensionalTestPojo.java │ ├── OptionalList.java │ ├── PodamParameterizedType.java │ ├── PodamRawList.java │ ├── PodamRawMap.java │ ├── PodamTestInterface.java │ ├── PojoWithCollectionAndMap.java │ ├── PojoWithInterfaces.java │ ├── PojoWithMapsAndCollections.java │ ├── PrivateNoArgConstructorPojo.java │ ├── ReadOnlyAbstract.java │ ├── ReadOnlyComplexTypesPojo.java │ ├── ReadOnlyGenericComplexTypesPojo.java │ ├── ReadOnlyNonAccessible.java │ ├── ReadOnlyRawFieldsPojo.java │ ├── ReadOnlyWildcardFieldsPojo.java │ ├── RecursivePojo.java │ ├── RecursivePojoWithList.java │ ├── ShortNamesPojo.java │ ├── SimplePojoToTestSetters.java │ ├── SimplePojoWithExcludeAnnotationToTestSetters.java │ ├── SimplePojoWithMultipleAnnotationsToAttribute.java │ ├── SimpleTypedClassPojo.java │ ├── SingletonWithParametersInStaticFactoryPojo.java │ ├── TypedClassPojo.java │ ├── TypedClassPojo2.java │ ├── UnsupportedCollectionInConstructorPojo.java │ ├── UnsupportedMapInConstructorPojo.java │ ├── ValidatedPatternPojo.java │ ├── ValidatedPojo.java │ ├── ValidatedPojo2.java │ ├── ValidatedPojoMultipleConstraints.java │ ├── ValidatedTimePojo.java │ ├── ValidationPojoForStringWithSizeAndNoMax.java │ ├── WildcardEnumPojo.java │ ├── XMLDatatypePojo.java │ ├── annotations │ │ ├── AnnotatedFieldAndSetterPojo.java │ │ ├── BooleanValuePojo.java │ │ ├── ByteValuePojo.java │ │ ├── ByteValueWithErrorPojo.java │ │ ├── CharValuePojo.java │ │ ├── CollectionAnnotationPojo.java │ │ ├── DoubleValuePojo.java │ │ ├── DoubleValueWithErrorPojo.java │ │ ├── EmailStrategyPojo.java │ │ ├── FloatValuePojo.java │ │ ├── FloatValueWithErrorPojo.java │ │ ├── IntegerValuePojo.java │ │ ├── IntegerValueWithErrorPojo.java │ │ ├── LongValuePojo.java │ │ ├── LongValueWithErrorPojo.java │ │ ├── PodamStrategyPojo.java │ │ ├── PojoClassic.java │ │ ├── PojoSpecific.java │ │ ├── ShortValuePojo.java │ │ ├── ShortValueWithErrorPojo.java │ │ ├── StringValuePojo.java │ │ └── StringWithWrongStrategyTypePojo.java │ ├── docs │ │ └── example │ │ │ ├── Address.java │ │ │ ├── Article.java │ │ │ ├── BankAccount.java │ │ │ ├── Client.java │ │ │ ├── Country.java │ │ │ ├── Order.java │ │ │ └── OrderItem.java │ ├── issue123 │ │ └── GenericCollectionsConstructorPojo.java │ ├── pdm3 │ │ ├── Pdm3Pojo.java │ │ ├── Pdm3PojoConstructor.java │ │ ├── Pdm3PojoGenericsConstructor.java │ │ ├── WildcardPojo.java │ │ └── package-info.java │ ├── pdm33 │ │ ├── NoDefaultPublicConstructorPojo.java │ │ ├── PrivateOnlyConstructorPojo.java │ │ └── ProtectedNonDefaultConstructorPojo.java │ ├── pdm4 │ │ ├── Pdm4PojoWithSetters.java │ │ ├── PojoWithFactoryMethods.java │ │ └── PojoWithMultipleNonPublicConstructors.java │ ├── pdm42 │ │ ├── A.java │ │ ├── B.java │ │ ├── C.java │ │ └── FieldInfo.java │ ├── pdm43 │ │ ├── BusinessObject.java │ │ ├── BusinessObjectWithErrors.java │ │ └── ConcreteBusinessObject.java │ ├── pdm45 │ │ ├── GenericArrayPojo.java │ │ ├── GenericAttributePojo.java │ │ ├── GenericListPojo.java │ │ ├── GenericMapPojo.java │ │ ├── GenericPojo.java │ │ ├── MultiDimensionalConstructorPojo.java │ │ └── MultiDimensionalTestPojo.java │ ├── pdm5 │ │ └── InvisibleConstructorAndNoSettersPojo.java │ └── pdm6 │ │ ├── Child.java │ │ ├── Parent.java │ │ ├── RecursiveList.java │ │ └── RecursiveMap.java │ ├── enums │ └── ExternalRatePodamEnum.java │ ├── integration │ └── PodamFactoryInjectionIntegrationTest.java │ ├── strategies │ ├── AnnotationStrategy.java │ ├── ByteArrayStrategy.java │ ├── CustomRandomDataProviderStrategy.java │ ├── MyBirthdayStrategy.java │ ├── PatternStrategy.java │ ├── PostCodeStrategy.java │ └── WrongTypeStrategy.java │ ├── unit │ ├── AbstractPodamSteps.java │ ├── features │ │ ├── annotations │ │ │ ├── AnnotationsExceptionsTest.java │ │ │ ├── AnnotationsTest.java │ │ │ └── package-info.java │ │ ├── basicTypes │ │ │ ├── BooleanUnitTest.java │ │ │ ├── ClassUnitTest.java │ │ │ ├── PodamFactoryBasicTypesTest.java │ │ │ └── package-info.java │ │ ├── classInfo │ │ │ ├── ClassInfoTest.java │ │ │ └── package-info.java │ │ ├── collections │ │ │ ├── CollectionsTest.java │ │ │ └── package-info.java │ │ ├── constructors │ │ │ ├── ConstructorsUnitTest.java │ │ │ ├── PackagePrivatePojo.java │ │ │ ├── ReadOnlyComplexTypesTest.java │ │ │ └── package-info.java │ │ ├── dataProviderStrategy │ │ │ ├── RandomDataProviderStrategyImplInitialisationUnitTest.java │ │ │ └── package-info.java │ │ ├── edgeCases │ │ │ ├── AbnormalPojosTest.java │ │ │ └── package-info.java │ │ ├── extensions │ │ │ ├── ExtensionsTest.java │ │ │ ├── NonEJBClassInfoStrategy.java │ │ │ ├── NonEJBPojoTest.java │ │ │ └── package-info.java │ │ ├── externalFactory │ │ │ ├── ExternalFactoryUnitTest.java │ │ │ ├── TestExternalFactory.java │ │ │ └── package-info.java │ │ ├── factories │ │ │ ├── FactoryUnitTest.java │ │ │ └── package-info.java │ │ ├── inheritance │ │ │ ├── CustomDataProviderStrategy.java │ │ │ ├── InheritanceTest.java │ │ │ ├── MultipleInterfacesInheritanceTest.java │ │ │ ├── TrackingExternalFactory.java │ │ │ └── package-info.java │ │ ├── memoization │ │ │ ├── MemoizationTest.java │ │ │ └── package-info.java │ │ ├── randomness │ │ │ ├── RandomnessTest.java │ │ │ └── package-info.java │ │ ├── singletons │ │ │ ├── SingletonsTest.java │ │ │ └── package-info.java │ │ ├── typeManufacturing │ │ │ ├── TypeManufacturingTest.java │ │ │ └── package-info.java │ │ ├── validatorFramework │ │ │ ├── ValidatedPojoTest.java │ │ │ ├── ValidatorExternalFactory.java │ │ │ └── package-info.java │ │ ├── walkThroughExample │ │ │ ├── WalkThroughExampleUnitTest.java │ │ │ └── package-info.java │ │ └── xmlTypes │ │ │ ├── XMLDatatypeUnitTest.java │ │ │ ├── XmlTypesExternalFactory.java │ │ │ └── package-info.java │ ├── issue86 │ │ ├── ExtraMethodsPojo.java │ │ ├── ExtraMethodsUnitTest.java │ │ ├── MyInitPojo.java │ │ └── MyInitPojoUnitTest.java │ ├── issue93 │ │ ├── A.java │ │ ├── B.java │ │ ├── C.java │ │ └── Issue93UnitTest.java │ ├── pdm3 │ │ └── Pdm3PojoUnitTest.java │ ├── pdm4 │ │ └── InstantiationUnitTest.java │ ├── pdm43 │ │ └── Pdm43UnitTest.java │ ├── pdm45 │ │ └── Pdm45UnitTest.java │ ├── pdm5 │ │ └── InvisibleConstructorAndNoSettersTest.java │ └── steps │ │ ├── ClassInfoValidationSteps.java │ │ ├── ConstructorSelfReferenceValidationSteps.java │ │ ├── OneDimentionalPojoValidationSteps.java │ │ ├── PodamFactorySteps.java │ │ ├── PodamInvocationSteps.java │ │ ├── PodamStrategySteps.java │ │ ├── PodamValidationSteps.java │ │ ├── RecursivePojoValidationSteps.java │ │ ├── ValidatorSteps.java │ │ └── WalkThroughSteps.java │ └── utils │ ├── PodamTestConstants.java │ ├── PodamTestUtils.java │ └── TypesUtils.java └── resources ├── log4j2.xml └── podam-test-appContext.xml /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | jobs: 3 | build: 4 | working_directory: ~/project 5 | docker: 6 | - image: circleci/openjdk:11-jdk-buster 7 | steps: 8 | - checkout 9 | - run: mvn clean install 10 | - run: mvn verify 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .idea 3 | .settings/ 4 | .classpath 5 | .project 6 | *.iml 7 | /bin -------------------------------------------------------------------------------- /.springBeans: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1 4 | 5 | 6 | 7 | 8 | 9 | 10 | src/test/resources/podam-test-appContext.xml 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - openjdk8 4 | - openjdk11 5 | script: 6 | - mvn clean verify 7 | branches: 8 | only: 9 | - develop 10 | 11 | after_success: 12 | - bash <(curl -s https://codecov.io/bash) 13 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2002-2014 Marco Tedone, Jemos 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | podam 2 | ===== 3 | 4 | [![CircleCI](https://circleci.com/gh/mtedone/podam.svg?style=shield)](https://circleci.com/gh/mtedone/podam) 5 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/uk.co.jemos.podam/podam/badge.svg)](https://maven-badges.herokuapp.com/maven-central/uk.co.jemos.podam/podam) 6 | [![Test Coverage](https://codecov.io/github/mtedone/podam/coverage.svg?branch=develop)](https://codecov.io/gh/mtedone/podam) 7 | 8 | PODAM - POjo DAta Mocker 9 | 10 | Podam (http://mtedone.github.io/podam/) is a Java testing tool which auto-fills POJOs with made-up data. 11 | 12 | Podam can fill any tree of objects with data. It supports generics, collections, arrays and Java native types. 13 | 14 | To get an idea of Podam's full potential, please visit the [Podam Requirements Page](http://mtedone.github.io/podam/serenity/capabilities.html) 15 | -------------------------------------------------------------------------------- /serenity.properties: -------------------------------------------------------------------------------- 1 | serenity.test.root=uk.co.jemos.podam.test.unit.features 2 | serenity.requirement.types=epics,stories -------------------------------------------------------------------------------- /src/main/assembly/bin.xml: -------------------------------------------------------------------------------- 1 | 4 | bin 5 | 6 | tar.gz 7 | tar.bz2 8 | zip 9 | 10 | 11 | 12 | ${project.basedir} 13 | / 14 | 15 | README* 16 | LICENSE* 17 | NOTICE* 18 | 19 | 20 | 21 | ${project.build.directory} 22 | / 23 | 24 | *.jar 25 | 26 | 27 | **/*.log 28 | ${project.basedir}/.settings/ 29 | ${project.basedir}/.classpath 30 | ${project.basedir}/.project 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/main/assembly/project.xml: -------------------------------------------------------------------------------- 1 | 4 | project 5 | 6 | tar.gz 7 | tar.bz2 8 | zip 9 | 10 | 11 | 12 | ${project.basedir} 13 | / 14 | true 15 | 16 | **/*.log 17 | **/${project.build.directory}/** 18 | ${project.basedir}/.settings/ 19 | ${project.basedir}/.classpath 20 | ${project.basedir}/.project 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/api/AbstractExternalFactory.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.api; 2 | 3 | import java.lang.reflect.Type; 4 | 5 | /** 6 | * Adapter pattern for boilerplate code when creating an external factory 7 | * 8 | * @author Marco Tedone 9 | * 10 | * @since 5.2.1 11 | */ 12 | public abstract class AbstractExternalFactory implements PodamFactory { 13 | 14 | @Override 15 | public T manufacturePojoWithFullData(Class pojoClass, 16 | Type... genericTypeArgs) { 17 | return this.manufacturePojo(pojoClass, genericTypeArgs); 18 | } 19 | 20 | @Override 21 | public DataProviderStrategy getStrategy() { 22 | return null; 23 | } 24 | 25 | @Override 26 | public PodamFactory setStrategy(DataProviderStrategy strategy) { 27 | return this; 28 | } 29 | 30 | @Override 31 | public ClassInfoStrategy getClassStrategy() { 32 | return null; 33 | } 34 | 35 | @Override 36 | public PodamFactory setClassStrategy( 37 | ClassInfoStrategy classInfoStrategy) { 38 | return this; 39 | } 40 | 41 | @Override 42 | public PodamFactory getExternalFactory() { 43 | return null; 44 | } 45 | 46 | @Override 47 | public PodamFactory setExternalFactory(PodamFactory externalFactory) { 48 | return this; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/api/AbstractMapArguments.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.api; 2 | 3 | import java.lang.annotation.Annotation; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | /** 9 | * Parent for map-related arguments POJO 10 | * 11 | * @author Marco Tedone 12 | * 13 | */ 14 | public abstract class AbstractMapArguments { 15 | 16 | /** The name of map attribute in enclosing POJO */ 17 | private String attributeName; 18 | /** The type of the Map key. */ 19 | private Class keyOrValueType; 20 | /** The Map to be returned. */ 21 | private Map mapToBeFilled; 22 | /** The annotations for the attribute. */ 23 | private List annotations = new ArrayList(); 24 | 25 | /** 26 | * @return the attribute name for this map 27 | */ 28 | public String getAttributeName() { 29 | return attributeName; 30 | } 31 | 32 | /** 33 | * @param attributeName 34 | * the attribute name for this map 35 | */ 36 | public void setAttributeName(String attributeName) { 37 | this.attributeName = attributeName; 38 | } 39 | 40 | /** 41 | * @return the keyOrValueType 42 | */ 43 | public Class getKeyOrValueType() { 44 | return keyOrValueType; 45 | } 46 | 47 | /** 48 | * @param keyOrValueType 49 | * the keyOrValueType to set 50 | */ 51 | public void setKeyOrValueType(Class keyOrValueType) { 52 | this.keyOrValueType = keyOrValueType; 53 | } 54 | 55 | /** 56 | * @return the mapToBeFilled 57 | */ 58 | public Map getMapToBeFilled() { 59 | return mapToBeFilled; 60 | } 61 | 62 | /** 63 | * @param mapToBeFilled 64 | * the mapToBeFilled to set 65 | */ 66 | public void setMapToBeFilled( 67 | Map mapToBeFilled) { 68 | this.mapToBeFilled = mapToBeFilled; 69 | } 70 | 71 | /** 72 | * @return the annotations 73 | */ 74 | public List getAnnotations() { 75 | return annotations; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/api/ClassAttributeApprover.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.api; 5 | 6 | /** 7 | * An interface, which is used to customize selection of class' attributes 8 | * for further filling or skipping. 9 | * 10 | * @author daivanov 11 | * 12 | */ 13 | public interface ClassAttributeApprover { 14 | 15 | /** 16 | * Override this method to select or reject class attributes 17 | * 18 | * @param attribute 19 | * class attribute to analyze for further processing or skipping 20 | * @return 21 | * true, if attribute should be kept, false, if it should be skipped 22 | */ 23 | boolean approve(ClassAttribute attribute); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/api/DefaultClassInfoStrategy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.api; 5 | 6 | /** 7 | * Singleton implementation of a {@link AbstractClassInfoStrategy} 8 | *

9 | * This singleton implementation performs class attribute introspection 10 | * on the basis of class declared fields 11 | *

12 | * 13 | * @author daivanov 14 | * 15 | * @since 5.1.0 16 | * 17 | */ 18 | 19 | public final class DefaultClassInfoStrategy extends 20 | AbstractClassInfoStrategy { 21 | 22 | // ------------------->> Constants 23 | 24 | /** The singleton instance of this implementation */ 25 | private static final DefaultClassInfoStrategy SINGLETON = new DefaultClassInfoStrategy(); 26 | 27 | // ------------------->> Instance / Static variables 28 | 29 | // ------------------->> Constructors 30 | 31 | /** 32 | * Implementation of the Singleton pattern 33 | */ 34 | private DefaultClassInfoStrategy() { 35 | super(); 36 | } 37 | 38 | // ------------------->> Public methods 39 | 40 | /** 41 | * Implementation of the Singleton pattern 42 | * 43 | * @return A singleton instance of this class 44 | */ 45 | public static DefaultClassInfoStrategy getInstance() { 46 | return SINGLETON; 47 | } 48 | 49 | // ------------------->> Getters / Setters 50 | 51 | // ------------------->> Private methods 52 | 53 | // ------------------->> equals() / hashcode() / toString() 54 | 55 | // ------------------->> Inner classes 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/api/MapArguments.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.api; 2 | 3 | import java.io.Serializable; 4 | import java.lang.reflect.Type; 5 | 6 | /** 7 | * Pojo which contains the arguments required to fill a Map as a POJO attribute 8 | * 9 | * @author Marco Tedone 10 | * 11 | */ 12 | public class MapArguments extends AbstractMapArguments implements Serializable { 13 | 14 | private static final long serialVersionUID = 1L; 15 | 16 | /** The type of the Map element. */ 17 | private Class elementClass; 18 | 19 | /** 20 | * The generic type arguments for the current key generic class instance. 21 | */ 22 | private Type[] keyGenericTypeArgs; 23 | 24 | /** 25 | * The generic type arguments for the current element generic class 26 | * instance. 27 | */ 28 | private Type[] elementGenericTypeArgs; 29 | 30 | /** 31 | * @return the elementClass 32 | */ 33 | public Class getElementClass() { 34 | return elementClass; 35 | } 36 | 37 | /** 38 | * @param elementClass 39 | * the elementClass to set 40 | */ 41 | public void setElementClass(Class elementClass) { 42 | this.elementClass = elementClass; 43 | } 44 | 45 | /** 46 | * @return the keyGenericTypeArgs 47 | */ 48 | public Type[] getKeyGenericTypeArgs() { 49 | return keyGenericTypeArgs; 50 | } 51 | 52 | /** 53 | * @param keyGenericTypeArgs 54 | * the keyGenericTypeArgs to set 55 | */ 56 | public void setKeyGenericTypeArgs(Type[] keyGenericTypeArgs) { 57 | this.keyGenericTypeArgs = keyGenericTypeArgs.clone(); 58 | } 59 | 60 | /** 61 | * @return the elementGenericTypeArgs 62 | */ 63 | public Type[] getElementGenericTypeArgs() { 64 | return elementGenericTypeArgs; 65 | } 66 | 67 | /** 68 | * @param elementGenericTypeArgs 69 | * the elementGenericTypeArgs to set 70 | */ 71 | public void setElementGenericTypeArgs(Type[] elementGenericTypeArgs) { 72 | this.elementGenericTypeArgs = elementGenericTypeArgs.clone(); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/api/MapKeyOrElementsArguments.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.api; 2 | 3 | import java.io.Serializable; 4 | import java.lang.reflect.Type; 5 | 6 | import uk.co.jemos.podam.common.AttributeStrategy; 7 | 8 | /** 9 | * Contains attributes for the arguments to pass to the factory method to fill 10 | * map key or elements. 11 | * 12 | * @author Marco Tedone 13 | * 14 | */ 15 | public class MapKeyOrElementsArguments extends AbstractMapArguments implements 16 | Serializable { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** The strategy to use to fill the Map key or value element. */ 21 | private AttributeStrategy elementStrategy; 22 | 23 | /** 24 | * The generic type arguments for the current generic class 25 | * instance. 26 | */ 27 | private Type[] genericTypeArgs; 28 | 29 | /** 30 | * @return the elementStrategy 31 | */ 32 | public AttributeStrategy getElementStrategy() { 33 | return elementStrategy; 34 | } 35 | 36 | /** 37 | * @param elementStrategy 38 | * the elementStrategy to set 39 | */ 40 | public void setElementStrategy(AttributeStrategy elementStrategy) { 41 | this.elementStrategy = elementStrategy; 42 | } 43 | 44 | /** 45 | * @return the genericTypeArgs 46 | */ 47 | public Type[] getGenericTypeArgs() { 48 | return genericTypeArgs; 49 | } 50 | 51 | /** 52 | * @param genericTypeArgs 53 | * the genericTypeArgs to set 54 | */ 55 | public void setGenericTypeArgs(Type[] genericTypeArgs) { 56 | this.genericTypeArgs = genericTypeArgs.clone(); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/api/NullExternalFactory.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.api; 5 | 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import java.lang.reflect.Type; 11 | import java.util.Arrays; 12 | 13 | /** 14 | * Default implementation of an external factory which does nothing. 15 | * 16 | * @author daivanov 17 | * 18 | * @since 4.3.0 19 | * 20 | */ 21 | public class NullExternalFactory extends AbstractExternalFactory { 22 | 23 | // ------------------->> Constants 24 | 25 | /** Application logger */ 26 | private static final Logger LOG = LoggerFactory.getLogger(NullExternalFactory.class); 27 | 28 | // ------------------->> Constructors 29 | 30 | /** 31 | * Implementation of the Singleton pattern 32 | */ 33 | private NullExternalFactory() { 34 | } 35 | 36 | // ------------------->> Public methods 37 | 38 | /** 39 | * Instantiation method 40 | * 41 | * @return A singleton instance of this class 42 | */ 43 | public static NullExternalFactory getInstance() { 44 | return new NullExternalFactory(); 45 | } 46 | 47 | /** 48 | * {@inheritDoc} 49 | */ 50 | @Override 51 | public T manufacturePojo(Class pojoClass, Type... genericTypeArgs) { 52 | LOG.warn("Cannot instantiate {} with arguments {}. Returning null.", 53 | pojoClass, Arrays.toString(genericTypeArgs)); 54 | return null; 55 | } 56 | 57 | @Override 58 | public T populatePojo(T pojo, Type... genericTypeArgs) { 59 | return pojo; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/api/ObjectStrategy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.api; 5 | 6 | import java.lang.annotation.Annotation; 7 | import java.util.List; 8 | 9 | import uk.co.jemos.podam.common.AttributeStrategy; 10 | import uk.co.jemos.podam.common.PodamCollection; 11 | 12 | /** 13 | * A default Object strategy, just to provide a default to 14 | * {@link PodamCollection#collectionElementStrategy()}. 15 | * 16 | * @author mtedone 17 | * 18 | */ 19 | public class ObjectStrategy implements AttributeStrategy { 20 | 21 | /** 22 | * {@inheritDoc} 23 | */ 24 | @Override 25 | public Object getValue(Class attrType, List attrAnnotations) { 26 | return null; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/api/RandomDataProviderStrategyImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.api; 5 | 6 | import net.jcip.annotations.ThreadSafe; 7 | 8 | /** 9 | * Default implementation of a {@link DataProviderStrategy} 10 | *

11 | * This default implementation returns values based on a random generator. 12 | * Don't use this implementation if you seek deterministic values 13 | *

14 | * 15 | *

16 | * All values returned by this implementation are different from zero. 17 | *

18 | * 19 | *

20 | * This implementation is a Singleton 21 | *

22 | * 23 | * @author mtedone 24 | * 25 | * @since 1.0.0 26 | * 27 | */ 28 | @ThreadSafe 29 | public final class RandomDataProviderStrategyImpl extends 30 | AbstractRandomDataProviderStrategy { 31 | 32 | // ------------------->> Constants 33 | 34 | // ------------------->> Instance / Static variables 35 | 36 | // ------------------->> Constructors 37 | 38 | /** 39 | * Implementation of the Singleton pattern 40 | */ 41 | public RandomDataProviderStrategyImpl() { 42 | super(); 43 | setMemoization(false); 44 | } 45 | 46 | // ------------------->> Public methods 47 | 48 | // ------------------->> Getters / Setters 49 | 50 | // ------------------->> Private methods 51 | 52 | // ------------------->> equals() / hashcode() / toString() 53 | 54 | // ------------------->> Inner classes 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/api/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains PODAM main APIs 3 | */ 4 | package uk.co.jemos.podam.api; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/AbstractConstructorComparator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.common; 5 | 6 | import java.lang.reflect.Constructor; 7 | import java.lang.reflect.Modifier; 8 | import java.util.Comparator; 9 | 10 | /** 11 | * It provides a comparator to sort the constructor to choose first. 12 | *

13 | * The priority goes to constructors with the {@link PodamConstructor} 14 | * annotation first, and then to those with less arguments. 15 | *

16 | * 17 | * @author daivanov 18 | * 19 | */ 20 | public abstract class AbstractConstructorComparator implements Comparator> { 21 | 22 | public int constructorComplexity(Constructor constructor) { 23 | 24 | int complexity = 0; 25 | for (Class parameter : constructor.getParameterTypes()) { 26 | if (parameter.isInterface() 27 | || (Modifier.isAbstract(parameter.getModifiers()) && !parameter.isPrimitive()) 28 | || parameter.isAssignableFrom(constructor.getDeclaringClass())) { 29 | complexity++; 30 | } 31 | } 32 | return complexity; 33 | } 34 | 35 | public int compareAnnotations(Constructor constructor1, Constructor constructor2) { 36 | 37 | /* Constructors with Podam annotation first */ 38 | boolean choose1 = (constructor1.getAnnotation(PodamConstructor.class) != null); 39 | boolean choose2 = (constructor2.getAnnotation(PodamConstructor.class) != null); 40 | if (choose1) { 41 | if (!choose2) { 42 | return Integer.MIN_VALUE; 43 | } 44 | } else { 45 | if (choose2) { 46 | return Integer.MAX_VALUE; 47 | } 48 | } 49 | return 0; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/AbstractMethodComparator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.common; 5 | 6 | import java.lang.reflect.Method; 7 | import java.lang.reflect.Modifier; 8 | import java.util.Comparator; 9 | 10 | /** 11 | * It provides a comparator to sort the constructor to choose first. 12 | *

13 | * The priority goes to constructors with the {@link PodamConstructor} 14 | * annotation first, and then to those with more arguments. 15 | *

16 | * 17 | * @author tedonema 18 | * 19 | */ 20 | public abstract class AbstractMethodComparator implements Comparator { 21 | 22 | public int methodComplexity(Method method) { 23 | 24 | int complexity = 0; 25 | for (Class parameter : method.getParameterTypes()) { 26 | if (!parameter.isPrimitive() && !parameter.equals(String.class)) { 27 | if (parameter.isInterface() 28 | || Modifier.isAbstract(parameter.getModifiers()) 29 | || parameter.isAssignableFrom(method.getDeclaringClass())) { 30 | complexity++; 31 | } 32 | } 33 | } 34 | return complexity; 35 | } 36 | 37 | public int compareAnnotations(Method method1, Method method2) { 38 | 39 | /* Constructors with Podam annotation first */ 40 | boolean choose1 = method1.getAnnotation(PodamConstructor.class) != null; 41 | boolean choose2 = method2.getAnnotation(PodamConstructor.class) != null; 42 | if (choose1 && !choose2) { 43 | return Integer.MIN_VALUE; 44 | } else if (!choose1 && choose2) { 45 | return Integer.MAX_VALUE; 46 | } 47 | return 0; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/AttributeStrategy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.common; 5 | 6 | import java.lang.annotation.Annotation; 7 | import java.util.List; 8 | 9 | /** 10 | * Generic contract for attribute-level data provider strategies. 11 | * 12 | * @author mtedone 13 | * 14 | */ 15 | public interface AttributeStrategy { 16 | 17 | /** 18 | * It returns a value of the given type 19 | * 20 | * @param attrType 21 | * an attribute's type 22 | * @param attrAnnotations 23 | * list of annotations attached to an attribute 24 | * @return A value of the given type 25 | */ 26 | T getValue(Class attrType, List attrAnnotations); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/ConstructorHeavyFirstComparator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.common; 5 | 6 | import java.lang.reflect.Constructor; 7 | 8 | /** 9 | * It provides a comparator to sort the constructor to choose first. 10 | *

11 | * The priority goes to constructors with the {@link PodamConstructor} 12 | * annotation first, and then to those with less arguments. 13 | *

14 | * 15 | * @author daivanov 16 | * 17 | */ 18 | public class ConstructorHeavyFirstComparator extends AbstractConstructorComparator { 19 | 20 | public static final ConstructorHeavyFirstComparator INSTANCE = 21 | new ConstructorHeavyFirstComparator(); 22 | 23 | private ConstructorHeavyFirstComparator() { 24 | } 25 | 26 | @Override 27 | public int compare(Constructor constructor1, Constructor constructor2) { 28 | 29 | int result = super.compareAnnotations(constructor1, constructor2); 30 | if (result != 0) { 31 | return result; 32 | } 33 | 34 | /* Then constructors with more parameters */ 35 | result = -constructor1.getParameterTypes().length 36 | + constructor2.getParameterTypes().length; 37 | if (result != 0) { 38 | return result; 39 | } 40 | 41 | /* Then less complex constructor */ 42 | return constructorComplexity(constructor1) 43 | - constructorComplexity(constructor2); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/ConstructorLightFirstComparator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.common; 5 | 6 | import java.lang.reflect.Constructor; 7 | 8 | /** 9 | * It provides a comparator to sort the constructor to choose first. 10 | *

11 | * The priority goes to constructors with the {@link PodamConstructor} 12 | * annotation first, and then to those with less arguments. 13 | *

14 | * 15 | * @author tedonema 16 | * 17 | */ 18 | public class ConstructorLightFirstComparator extends AbstractConstructorComparator { 19 | 20 | public static final ConstructorLightFirstComparator INSTANCE = 21 | new ConstructorLightFirstComparator(); 22 | 23 | private ConstructorLightFirstComparator() { 24 | } 25 | 26 | @Override 27 | public int compare(Constructor constructor1, Constructor constructor2) { 28 | 29 | int result = super.compareAnnotations(constructor1, constructor2); 30 | if (result != 0) { 31 | return result; 32 | } 33 | 34 | /* Then constructors with less parameters */ 35 | result = constructor1.getParameterTypes().length 36 | - constructor2.getParameterTypes().length; 37 | if (result != 0) { 38 | return result; 39 | } 40 | 41 | /* Then less complex constructor */ 42 | return constructorComplexity(constructor1) 43 | - constructorComplexity(constructor2); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/EmailStrategy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.common; 5 | 6 | import uk.co.jemos.podam.api.PodamUtils; 7 | import uk.co.jemos.podam.exceptions.PodamMockeryException; 8 | 9 | import java.lang.annotation.Annotation; 10 | import java.util.List; 11 | 12 | /** 13 | * This strategy fills Email attributes and parameters annotated with Java bean 14 | * validation annotations 15 | * 16 | * @author daivanov 17 | */ 18 | public class EmailStrategy implements AttributeStrategy { 19 | 20 | /** 21 | * Constructor for the strategy 22 | */ 23 | public EmailStrategy() { 24 | } 25 | 26 | /** 27 | * It returns objects complying with Java bean Email validation 28 | * annotation. 29 | * 30 | * {@inheritDoc} 31 | */ 32 | public CharSequence getValue(Class attrType, List annotations) throws PodamMockeryException { 33 | 34 | StringBuilder sb = new StringBuilder(); 35 | sb.append(PodamUtils.getNiceString(3)).append(".").append(PodamUtils.getNiceString(4)); 36 | sb.append("@"); 37 | sb.append(PodamUtils.getNiceString(4)).append(".").append(PodamUtils.getNiceString(3)); 38 | return sb.toString(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/Holder.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.common; 2 | 3 | /** 4 | * Object to pass objects by reference 5 | * 6 | * @param type of objects to be hold by this class 7 | * @author daivanov 8 | * 9 | */ 10 | public class Holder { 11 | 12 | /** Object to hold */ 13 | private T value; 14 | 15 | /** 16 | * Default constructor 17 | */ 18 | public Holder() { 19 | } 20 | 21 | /** 22 | * Default constructor 23 | * @param value value to set 24 | */ 25 | public Holder(T value) { 26 | this.value = value; 27 | } 28 | 29 | /** 30 | * Setter for holder's value 31 | * @param value value to set 32 | */ 33 | public void setValue(T value) { 34 | this.value = value; 35 | } 36 | 37 | /** 38 | * Getter for holder's value 39 | * @return value 40 | */ 41 | public T getValue() { 42 | return this.value; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/MethodHeavyFirstComparator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.common; 5 | 6 | import java.lang.reflect.Method; 7 | 8 | /** 9 | * It provides a comparator to sort the constructor to choose first. 10 | *

11 | * The priority goes to constructors with the {@link PodamConstructor} 12 | * annotation first, and then to those with more arguments. 13 | *

14 | * 15 | * @author tedonema 16 | * 17 | */ 18 | public class MethodHeavyFirstComparator extends AbstractMethodComparator { 19 | 20 | public static final MethodHeavyFirstComparator INSTANCE = 21 | new MethodHeavyFirstComparator(); 22 | 23 | private MethodHeavyFirstComparator() { 24 | } 25 | 26 | @Override 27 | public int compare(Method method1, Method method2) { 28 | 29 | int result = super.compareAnnotations(method1, method2); 30 | if (result != 0) { 31 | return result; 32 | } 33 | 34 | /* Then constructors with more parameters */ 35 | result = method2.getParameterTypes().length 36 | - method1.getParameterTypes().length; 37 | if (result != 0) { 38 | return result; 39 | } 40 | 41 | /* Then less complex method */ 42 | return methodComplexity(method1) 43 | - methodComplexity(method2); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/MethodLightFirstComparator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.common; 5 | 6 | import java.lang.reflect.Method; 7 | 8 | /** 9 | * It provides a comparator to sort the constructor to choose first. 10 | *

11 | * The priority goes to constructors with the {@link PodamConstructor} 12 | * annotation first, and then to those with more arguments. 13 | *

14 | * 15 | * @author tedonema 16 | * 17 | */ 18 | public class MethodLightFirstComparator extends AbstractMethodComparator { 19 | 20 | public static final MethodLightFirstComparator INSTANCE = 21 | new MethodLightFirstComparator(); 22 | 23 | private MethodLightFirstComparator() { 24 | } 25 | 26 | @Override 27 | public int compare(Method method1, Method method2) { 28 | 29 | int result = super.compareAnnotations(method1, method2); 30 | if (result != 0) { 31 | return result; 32 | } 33 | 34 | /* Then constructors with less parameters */ 35 | result = method1.getParameterTypes().length 36 | - method2.getParameterTypes().length; 37 | if (result != 0) { 38 | return result; 39 | } 40 | 41 | /* Then less complex method */ 42 | return methodComplexity(method1) 43 | - methodComplexity(method2); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/PodamAnnotation.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.common; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * Annotation to mark PODAM annotations. 11 | * 12 | * 13 | * @author maxdidato 14 | * 15 | */ 16 | @Documented 17 | @Target({ElementType.ANNOTATION_TYPE}) 18 | @Retention(RetentionPolicy.RUNTIME) 19 | public @interface PodamAnnotation { 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/PodamBooleanValue.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.common; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * Annotation used to customise a boolean value on the annotated field 14 | * 15 | * @author mtedone 16 | * 17 | */ 18 | @Documented 19 | @PodamAnnotation 20 | @Target(value = { ElementType.FIELD, ElementType.PARAMETER }) 21 | @Retention(RetentionPolicy.RUNTIME) 22 | public @interface PodamBooleanValue { 23 | 24 | /** 25 | * The value to assign to the annotated attribute. 26 | * 27 | * @return The value to assign to the annotated attribute 28 | */ 29 | boolean boolValue() default false; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/PodamCharValue.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.common; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * Annotation used to customise min and max values of a char type attribute or 14 | * constructor parameter. 15 | * 16 | * 17 | * @author mtedone 18 | * 19 | */ 20 | @Documented 21 | @PodamAnnotation 22 | @Target(value = { ElementType.FIELD, ElementType.PARAMETER }) 23 | @Retention(RetentionPolicy.RUNTIME) 24 | public @interface PodamCharValue { 25 | 26 | /** The minimum value for the annotated field 27 | * 28 | * @return min value 29 | */ 30 | char minValue() default 0; 31 | 32 | /** The minimum value for the annotated field 33 | * 34 | * @return max value 35 | */ 36 | char maxValue() default 0; 37 | 38 | /** It allows clients to make comments 39 | * 40 | * @return comment value 41 | */ 42 | String comment() default ""; 43 | 44 | /** 45 | * A precise char value to assign to the annotated attribute. 46 | *

47 | * If set, it will take precedence over all other annotation attributes 48 | * (e.g. min/max). It is assumed that if the value of {@code charValue} is 49 | * the default, the user didn't set it and therefore this value will not 50 | * take precedence over {@code minValue} and {@code maxValue}. 51 | *

52 | *

53 | * This attribute defaults to an empty char. 54 | *

55 | * 56 | * @return A precise char value to assign to the annotated attribute. 57 | */ 58 | char charValue() default ' '; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/PodamConstants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.common; 5 | 6 | 7 | import java.lang.reflect.Type; 8 | 9 | /** 10 | * PODAM constants. 11 | * 12 | * @author mtedone 13 | * 14 | * @since 1.0.0 15 | * 16 | */ 17 | public interface PodamConstants { 18 | 19 | /** 20 | * The default string length that Podam will assign to an annotated 21 | * attribute 22 | */ 23 | public static final int STR_DEFAULT_LENGTH = 10; 24 | 25 | /** The default number of elements for a collection-type element. */ 26 | public static final int DEFAULT_NBR_COLLECTION_ELEMENTS = 5; 27 | 28 | /** The default encoding for Strings. */ 29 | public static final String STR_DEFAULT_ENCODING = "UTF-8"; 30 | 31 | /** The Podam Spring rool configuration file name. */ 32 | public static final String SPRING_ROOT_CONFIG_LOCATION = "META-INF/spring/podam-config.xml"; 33 | 34 | /** A String used for messages. */ 35 | public static final String THE_ANNOTATION_VALUE_STR = "The annotation value: "; 36 | 37 | /** An empty array of Classes. */ 38 | public static final Class[] NO_CLASSES = new Class[0]; 39 | 40 | /** An empty array of Types. */ 41 | public static final Type[] NO_TYPES = new Type[0]; 42 | 43 | /** An empty object array. */ 44 | public static final Object[] NO_ARGS = new Object[0]; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/PodamConstructor.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.common; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * It identifies a constructor to use in order to create an instance of a class. 11 | *

12 | * This annotation should be used in POJOs with attributes but without setters. 13 | * A typical example are immutable classes, where attributes are final and 14 | * declared in the constructor and they have getters but not setters. 15 | *

16 | * 17 | * @author mtedone 18 | * 19 | */ 20 | @Documented 21 | @PodamAnnotation 22 | @Target({ElementType.CONSTRUCTOR, ElementType.METHOD}) 23 | @Retention(RetentionPolicy.RUNTIME) 24 | public @interface PodamConstructor { 25 | 26 | /** Gives users the possibility to leave comments 27 | * 28 | * @return comment value 29 | */ 30 | String comment() default ""; 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/PodamExclude.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.common; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * Annotation which will have PODAM to skip the annotated attribute from 14 | * consideration. 15 | *

16 | * PODAM will skip POJO attributes annotated with this annotation, thus their 17 | * value will not be set. 18 | *

19 | * 20 | * @author mtedone 21 | * 22 | */ 23 | @Documented 24 | @PodamAnnotation 25 | @Target(value = ElementType.FIELD) 26 | @Retention(RetentionPolicy.RUNTIME) 27 | public @interface PodamExclude { 28 | 29 | /** Gives users the possibility to leave comments 30 | * 31 | * @return comment value 32 | */ 33 | String comment() default ""; 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/PodamStrategyValue.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.common; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * Annotation to drive the value of the annotated attribute. 14 | *

15 | * If specified, this annotation will take precedence over all other annotations 16 | * which influence the value of an attribute. In few words, this annotation 17 | * dictates law in terms of which value the attribute ultimately will get. 18 | *

19 | * 20 | * @author mtedone 21 | * 22 | */ 23 | @Documented 24 | @PodamAnnotation 25 | @Target({ElementType.FIELD, ElementType.PARAMETER}) 26 | @Retention(RetentionPolicy.RUNTIME) 27 | public @interface PodamStrategyValue { 28 | 29 | /** 30 | * The strategy that will populate the annotated attribute 31 | * 32 | * @return The strategy that will populate the annotated attribute 33 | */ 34 | Class> value(); 35 | 36 | /** 37 | * It allows clients to write a comment on the usage of this annotation 38 | * 39 | * @return The comment string 40 | */ 41 | String comment() default ""; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/PodamStringValue.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.common; 5 | 6 | import java.lang.annotation.Documented; 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * Annotation used to customise string type attributes or constructor parameter. 14 | * 15 | *

16 | * The {@code strValue} attribute takes precedence over {@code length}. If the 17 | * former was specified the latter will be ignored. 18 | *

19 | * 20 | * @author mtedone 21 | * 22 | */ 23 | @Documented 24 | @PodamAnnotation 25 | @Target(value = { ElementType.FIELD, ElementType.PARAMETER }) 26 | @Retention(RetentionPolicy.RUNTIME) 27 | public @interface PodamStringValue { 28 | 29 | /** 30 | * The length of the String for the annotated attribute. It defaults to 31 | * {@link PodamConstants#STR_DEFAULT_LENGTH} 32 | * 33 | * @return string length 34 | */ 35 | int length() default PodamConstants.STR_DEFAULT_LENGTH; 36 | 37 | /** If specified, it allows clients to specify an exact value for the string 38 | * 39 | * @return string value 40 | */ 41 | String strValue() default ""; 42 | 43 | /** It allows clients to specify a comment on this annotation 44 | * 45 | * @return comment value 46 | */ 47 | String comment() default ""; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/common/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains PODAM common APIs 3 | */ 4 | package uk.co.jemos.podam.common; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/exceptions/PodamMockeryException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.exceptions; 5 | 6 | /** 7 | * The exception which occurs while PODAM is filling a POJO. 8 | * 9 | * @author mtedone 10 | * 11 | * @since 1.0.0 12 | * 13 | */ 14 | public class PodamMockeryException extends RuntimeException { 15 | 16 | // ------------------->> Constants 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | // ------------------->> Instance / Static variables 21 | 22 | // ------------------->> Constructors 23 | 24 | /** 25 | * Full constructor 26 | * 27 | * @param message 28 | * The exception message 29 | * @param cause 30 | * The error which caused this exception to be thrown 31 | */ 32 | public PodamMockeryException(String message, Throwable cause) { 33 | super(message, cause); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/exceptions/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains PODAM exceptions. 3 | */ 4 | package uk.co.jemos.podam.exceptions; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/typeManufacturers/AbstractTypeManufacturer.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.typeManufacturers; 2 | 3 | import java.util.Collection; 4 | 5 | import uk.co.jemos.podam.api.PodamUtils; 6 | 7 | /** 8 | * Parent of all type manufacturer. 9 | * 10 | * Created by tedonema on 28/06/2015. 11 | * 12 | * @param The type of the value to be manufactured 13 | * @since 6.0.0.RELEASE 14 | */ 15 | public abstract class AbstractTypeManufacturer implements TypeManufacturer { 16 | 17 | /** 18 | * @param The type for which should be found 19 | 20 | * @param collection collection with elements 21 | * @param type a type of which element should be found 22 | * @return element of desired type or null, if the collection doesn't 23 | * contain any object of that type. 24 | */ 25 | public R findElementOfType(Collection collection, Class type) { 26 | for (Object element : collection) { 27 | if (type.isInstance(element)) { 28 | return type.cast(element); 29 | } 30 | } 31 | return null; 32 | } 33 | 34 | /** It returns a int/Integer value in an interval (0, bound). 35 | * 36 | * @param bound 37 | * the upper bound (inclusive). Must be positive. 38 | * @return A random int value. 39 | */ 40 | public int getInteger(int bound) { 41 | 42 | return PodamUtils.getIntegerInRange(0, bound); 43 | } 44 | 45 | /** It returns a double value in an interval (0, 1.0) 46 | * 47 | * @return A random double value 48 | */ 49 | public double getDouble() { 50 | 51 | return PodamUtils.getDoubleInRange(0.0, 1.0); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/typeManufacturers/BooleanTypeManufacturerImpl.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.typeManufacturers; 2 | 3 | import uk.co.jemos.podam.api.AttributeMetadata; 4 | import uk.co.jemos.podam.api.DataProviderStrategy; 5 | import uk.co.jemos.podam.common.ManufacturingContext; 6 | import uk.co.jemos.podam.common.PodamBooleanValue; 7 | 8 | import java.lang.reflect.Type; 9 | import java.util.Map; 10 | 11 | /** 12 | * Default boolean type manufacturer. 13 | * 14 | * Created by tedonema on 17/05/2015. 15 | * 16 | * @since 6.0.0.RELEASE 17 | */ 18 | public class BooleanTypeManufacturerImpl extends AbstractTypeManufacturer { 19 | 20 | /** 21 | * {@inheritDoc} 22 | */ 23 | @Override 24 | public Boolean getType(DataProviderStrategy strategy, 25 | AttributeMetadata attributeMetadata, 26 | ManufacturingContext manufacturingCtx) { 27 | 28 | Boolean retValue; 29 | 30 | PodamBooleanValue annotationStrategy = findElementOfType( 31 | attributeMetadata.getAttributeAnnotations(), PodamBooleanValue.class); 32 | 33 | if (null != annotationStrategy) { 34 | retValue = annotationStrategy.boolValue(); 35 | } else { 36 | retValue = getBoolean(attributeMetadata); 37 | } 38 | 39 | return retValue; 40 | } 41 | 42 | /** It returns a boolean/Boolean value. 43 | * 44 | * @param attributeMetadata 45 | * attribute metadata for instance to be fetched 46 | * @return a boolean/Boolean value 47 | */ 48 | public Boolean getBoolean(AttributeMetadata attributeMetadata) { 49 | 50 | return Boolean.TRUE; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/typeManufacturers/CollectionTypeManufacturerImpl.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.typeManufacturers; 2 | 3 | import uk.co.jemos.podam.api.AttributeMetadata; 4 | import uk.co.jemos.podam.api.DataProviderStrategy; 5 | import uk.co.jemos.podam.common.ManufacturingContext; 6 | 7 | import java.lang.reflect.Type; 8 | import java.util.ArrayList; 9 | import java.util.Collection; 10 | import java.util.HashSet; 11 | import java.util.LinkedList; 12 | import java.util.Map; 13 | 14 | /** 15 | * Default collection type manufacturer. 16 | * 17 | * @since 7.0.0.RELEASE 18 | */ 19 | public class CollectionTypeManufacturerImpl extends AbstractTypeManufacturer> { 20 | 21 | @Override 22 | public Collection getType(DataProviderStrategy strategy, 23 | AttributeMetadata attributeMetadata, 24 | ManufacturingContext manufacturingCtx) { 25 | 26 | Class collectionType = attributeMetadata.getAttributeType(); 27 | Collection retValue = null; 28 | 29 | // Default list and set are ArrayList and HashSet. If users 30 | // wants a particular collection flavour they have to initialise 31 | // the collection 32 | if (collectionType.isAssignableFrom(ArrayList.class)) { 33 | // List 34 | retValue = new ArrayList(); 35 | } else if (collectionType.isAssignableFrom(HashSet.class)) { 36 | // Set 37 | retValue = new HashSet(); 38 | } else if (collectionType.isAssignableFrom(LinkedList.class)) { 39 | // Queue 40 | retValue = new LinkedList(); 41 | } 42 | return retValue; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/typeManufacturers/EnumTypeManufacturerImpl.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.typeManufacturers; 2 | 3 | import java.lang.reflect.Type; 4 | import java.util.Map; 5 | 6 | import uk.co.jemos.podam.api.AttributeMetadata; 7 | import uk.co.jemos.podam.api.DataProviderStrategy; 8 | import uk.co.jemos.podam.api.PodamUtils; 9 | import uk.co.jemos.podam.common.ManufacturingContext; 10 | 11 | /** 12 | * Default Enum type manufacturer. 13 | * 14 | * Created by tedonema on 17/05/2015. 15 | * 16 | * @since 6.0.0.RELEASE 17 | */ 18 | public class EnumTypeManufacturerImpl extends AbstractTypeManufacturer> { 19 | 20 | /** 21 | * {@inheritDoc} 22 | */ 23 | @Override 24 | public Enum getType(DataProviderStrategy strategy, 25 | AttributeMetadata attributeMetadata, 26 | ManufacturingContext manufacturingCtx) { 27 | 28 | Class realAttributeType = attributeMetadata.getAttributeType(); 29 | 30 | Object[] enumConstants = realAttributeType.getEnumConstants(); 31 | if (null == enumConstants) { 32 | enumConstants = Thread.State.class.getEnumConstants(); 33 | } 34 | 35 | Enum retValue = null; 36 | final int enumConstantsLength = enumConstants.length; 37 | if (enumConstantsLength > 0) { 38 | int enumIndex = PodamUtils.getIntegerInRange(0, enumConstantsLength) 39 | % enumConstantsLength; 40 | retValue = (Enum) enumConstants[enumIndex]; 41 | } 42 | 43 | return retValue; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/typeManufacturers/MapTypeManufacturerImpl.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.typeManufacturers; 2 | 3 | import uk.co.jemos.podam.api.AttributeMetadata; 4 | import uk.co.jemos.podam.api.DataProviderStrategy; 5 | import uk.co.jemos.podam.common.ManufacturingContext; 6 | 7 | import java.lang.reflect.Type; 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | import java.util.TreeMap; 11 | import java.util.concurrent.ConcurrentHashMap; 12 | 13 | /** 14 | * Default map type manufacturer. 15 | * 16 | * @since 7.0.0.RELEASE 17 | */ 18 | public class MapTypeManufacturerImpl extends AbstractTypeManufacturer> { 19 | 20 | @Override 21 | public Map getType(DataProviderStrategy strategy, 22 | AttributeMetadata attributeMetadata, 23 | ManufacturingContext manufacturingCtx) { 24 | 25 | Class mapType = attributeMetadata.getAttributeType(); 26 | Map retValue = null; 27 | 28 | if (mapType.isAssignableFrom(HashMap.class)) { 29 | // Map 30 | retValue = new HashMap(); 31 | } else if (mapType.isAssignableFrom(TreeMap.class)) { 32 | // SortedMap 33 | retValue = new TreeMap(); 34 | } else if (mapType.isAssignableFrom(ConcurrentHashMap.class)) { 35 | // ConcurrentMap 36 | retValue = new ConcurrentHashMap(); 37 | } 38 | 39 | return retValue; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/typeManufacturers/TypeManufacturer.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.typeManufacturers; 2 | 3 | import java.lang.reflect.Type; 4 | import java.util.Map; 5 | 6 | import uk.co.jemos.podam.api.AttributeMetadata; 7 | import uk.co.jemos.podam.api.DataProviderStrategy; 8 | import uk.co.jemos.podam.common.ManufacturingContext; 9 | 10 | /** 11 | * Interface for a type manufacturer 12 | * Created by tedonema on 17/05/2015. 13 | * 14 | * @param The type of the value to be manufactured 15 | * @since 6.0.0.RELEASE 16 | */ 17 | public interface TypeManufacturer { 18 | 19 | /** 20 | * Returns a type value conforming to the annotations and the AttributeMetadata provided. 21 | * 22 | * @param strategy The DataProviderStrategy 23 | * @param attributeMetadata The AttributeMetadata 24 | * @param manufacturingCtx pojo manufacturing context with types defintions 25 | * 26 | * @return A type value conforming to the annotations and the AttributeMetadata provided. 27 | */ 28 | T getType(DataProviderStrategy strategy, 29 | AttributeMetadata attributeMetadata, 30 | ManufacturingContext manufacturingCtx); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/typeManufacturers/TypeTypeManufacturerImpl.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.typeManufacturers; 2 | 3 | import uk.co.jemos.podam.api.AttributeMetadata; 4 | import uk.co.jemos.podam.api.DataProviderStrategy; 5 | import uk.co.jemos.podam.common.ManufacturingContext; 6 | import uk.co.jemos.podam.common.PodamConstants; 7 | 8 | import java.lang.reflect.Type; 9 | import java.util.Map; 10 | import java.util.concurrent.atomic.AtomicReference; 11 | 12 | /** 13 | * Default generic type type manufacturer. 14 | * 15 | * Created by tedonema on 17/05/2015. 16 | * 17 | * @since 6.0.0.RELEASE 18 | */ 19 | public class TypeTypeManufacturerImpl extends AbstractTypeManufacturer { 20 | 21 | @Override 22 | public Object getType(DataProviderStrategy strategy, 23 | AttributeMetadata attributeMetadata, 24 | ManufacturingContext manufacturingCtx) { 25 | 26 | Type genericAttributeType = attributeMetadata.getAttributeGenericType(); 27 | AtomicReference elementGenericTypeArgs 28 | = new AtomicReference(PodamConstants.NO_TYPES); 29 | TypeManufacturerUtil.resolveGenericParameter(genericAttributeType, 30 | manufacturingCtx, elementGenericTypeArgs); 31 | 32 | if (elementGenericTypeArgs.get().length > 0) { 33 | 34 | Type resolvedType = elementGenericTypeArgs.get()[0]; 35 | return TypeManufacturerUtil.resolveGenericParameter(resolvedType, 36 | manufacturingCtx, elementGenericTypeArgs); 37 | } else { 38 | 39 | return attributeMetadata.getAttributeType(); 40 | } 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/uk/co/jemos/podam/typeManufacturers/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains Type Manufacturers. 3 | * Created by tedonema on 30/06/2015. 4 | */ 5 | package uk.co.jemos.podam.typeManufacturers; -------------------------------------------------------------------------------- /src/site/apt/downloads.apt: -------------------------------------------------------------------------------- 1 | Podam Downloads 2 | 3 | Podam can be downloaded from {{{http://search.maven.org/#search|ga|1|podam} Maven Central}} 4 | 5 | -------------------------------------------------------------------------------- /src/site/apt/how-to-contribute.apt: -------------------------------------------------------------------------------- 1 | How to contribute 2 | 3 | There are various ways you could contribute to PODAM: 4 | 5 | * By forking PODAM source code from {{{https://github.com/mtedone/podam} GitHub}} and submit code contributions. 6 | 7 | * By joining our {{{http://groups.google.com/group/podam} Google group}} and join the discussion. 8 | 9 | * By submitting a bug. In this case, please submit a bug at {{https://github.com/mtedone/podam/issues}}. When submitting a bug, please 10 | ensure the following is defined: 11 | 12 | * The failing POJO (of in case of copyright issues, a POJO which reflects the problem) 13 | 14 | * A description of the problem (e.g. why you think PODAM didn't work properly) 15 | 16 | [] 17 | 18 | * By submitting new feature requests at {{https://github.com/mtedone/podam/issues}}. When submitting a feature request, 19 | please attach the POJO (of in case of copyright issues, a similar POJO) for which you would like the new feature. 20 | 21 | * By providing feedback. This can be done by starting a discussion on 22 | our {{{http://groups.google.com/group/podam} Google group}} 23 | 24 | [] 25 | 26 | Happy technology! 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/site/resources/images/idea.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtedone/podam/16e5f6716cee16b72226fa0763508a63f78175e0/src/site/resources/images/idea.jpg -------------------------------------------------------------------------------- /src/site/resources/images/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtedone/podam/16e5f6716cee16b72226fa0763508a63f78175e0/src/site/resources/images/logo.gif -------------------------------------------------------------------------------- /src/site/resources/images/nexus-oss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtedone/podam/16e5f6716cee16b72226fa0763508a63f78175e0/src/site/resources/images/nexus-oss.png -------------------------------------------------------------------------------- /src/site/resources/images/walkthrough-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtedone/podam/16e5f6716cee16b72226fa0763508a63f78175e0/src/site/resources/images/walkthrough-example.png -------------------------------------------------------------------------------- /src/site/resources/release-notes/release-notes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | PODAM - Release Notes 7 | 8 | 9 | Home 10 |
11 | 12 | 13 |

4.7.2.RELEASE - 2nd February 2015

14 |

Enhancement

15 |
    16 |
  • [Enhancement] - 17 | Skipping methods starting with "set" and having non single parameter 18 | instead of throwing exception 19 |
  • 20 |
21 |

Bug

22 |
    23 |
  • [Bug Fix] - 24 | Properly handle immutable default values 25 |
  • 26 |
27 |

4.7.1.RELEASE - 17th January 2015

28 |

Bug

29 |
    30 |
  • [Bug] - 31 | Properly handle default values for collection and map types 32 |
  • 33 |
34 |

3.0.5.RELEASE - 27th July 2013

35 |

Enhancement

36 |
    37 |
  • [Enhancement] - 38 | Adding support for excluding fields based on custom annotations 39 |
  • 40 |
41 |

3.0.4.RELEASE - 20th June 2013

42 |

Bug

43 |
    44 |
  • [Bug Fix] - 45 | Resolve generics parameters in a safe and uniform way 46 |
  • 47 |
48 | 49 | -------------------------------------------------------------------------------- /src/site/resources/sponsors/sponsors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | PODAM - Sponsors and Testimonials 7 | 8 | 9 | 10 |

Sponsors

11 | 12 | Home 13 | 14 |

As an open source, PODAM received some sponsorship from the community. Here follows a list of sponsors 15 | who contributed to the success of PODAM. Thank you all.

16 | 17 |

Atlassian - JIRA and Greenhopper

18 | 19 |

PODAM wants to warmly thank Atlassian for providing a free, 20 | unlimited, open source license for JIRA 21 | and Greenhopper. 22 |

23 | 24 | 25 |

Sonatype OSS

26 | 27 |

Nexus OSS provides Open Source Software with the infrastructure required to deploy SNAPSHOTS and releases to 28 | Maven Central. The full documentation on how to use Nexus OSS 29 | is available here.

30 | 31 | 32 | Nexus OSS 33 | 34 | 35 | 36 |

JetBrains - Intellij Open Source Edition

37 | 38 |

PODAM wants to warmly thank JetBrains for providing a free, 39 | unlimited, open source license for IntelliJ. 40 |

41 | 42 | 43 | IntelliJ 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/site/resources/uml/Type Hierarchy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtedone/podam/16e5f6716cee16b72226fa0763508a63f78175e0/src/site/resources/uml/Type Hierarchy.png -------------------------------------------------------------------------------- /src/site/resources/uml/architecture.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | PODAM - Sponsors and Testimonials 7 | 8 | 9 | 10 |

PODAM Architecture

11 | 12 | Home 13 | 14 |

Podam API architecture

15 |

16 | PODAM API architecture 17 |

18 | 19 |

Podam Type Manufacturing architecture

20 |

21 | PODAM Type Manufacturers architecture 23 |

24 | 25 | 26 | -------------------------------------------------------------------------------- /src/site/resources/uml/podam-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtedone/podam/16e5f6716cee16b72226fa0763508a63f78175e0/src/site/resources/uml/podam-architecture.png -------------------------------------------------------------------------------- /src/site/resources/uml/type-manufacturers-architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtedone/podam/16e5f6716cee16b72226fa0763508a63f78175e0/src/site/resources/uml/type-manufacturers-architecture.png -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/AbstractClass.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | /** 4 | * Class which doesn't have any specific implementation 5 | * @author daivanov 6 | */ 7 | public abstract class AbstractClass { 8 | private String name; 9 | 10 | public AbstractClass(String name) { 11 | this.name = name; 12 | } 13 | 14 | public String getName() { 15 | return name; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/AbstractTestPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * @author mtedone 8 | * 9 | */ 10 | public abstract class AbstractTestPojo { 11 | 12 | // ------------------->> Constants 13 | 14 | // ------------------->> Instance / Static variables 15 | 16 | /** An int field */ 17 | private int intField; 18 | 19 | // ------------------->> Constructors 20 | 21 | /** 22 | * 23 | */ 24 | public AbstractTestPojo() { 25 | // TODO Auto-generated constructor stub 26 | } 27 | 28 | // ------------------->> Public methods 29 | 30 | // ------------------->> Getters / Setters 31 | 32 | /** 33 | * @return the intField 34 | */ 35 | public int getIntField() { 36 | return intField; 37 | } 38 | 39 | /** 40 | * @param intField 41 | * the intField to set 42 | */ 43 | public void setIntField(int intField) { 44 | this.intField = intField; 45 | } 46 | 47 | // ------------------->> Private methods 48 | 49 | // ------------------->> equals() / hashcode() / toString() 50 | 51 | // ------------------->> Inner classes 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ArrayPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * POJO to test when Podam sets an array. 8 | * 9 | * @author tedonema 10 | * 11 | */ 12 | public class ArrayPojo { 13 | 14 | private String[] myStringArray = new String[10]; 15 | 16 | private Object[] myObjectArray; 17 | 18 | /** 19 | * Default constructor. 20 | */ 21 | public ArrayPojo() { 22 | 23 | } 24 | 25 | /** 26 | * Gets the array. 27 | * 28 | * @return An array of Strings 29 | */ 30 | public String[] getMyStringArray() { 31 | return myStringArray; 32 | } 33 | 34 | /** 35 | * Sets the array. 36 | * 37 | * @param myStringArray An array of strings 38 | */ 39 | public void setMyStringArray(String[] myStringArray) { 40 | this.myStringArray = myStringArray; 41 | } 42 | 43 | /** 44 | * Gets the array. 45 | * 46 | * @return An array of Objects 47 | */ 48 | public Object[] getMyObjectArray() { 49 | return myObjectArray; 50 | } 51 | 52 | /** 53 | * Sets the array. 54 | * 55 | * @param myObjectArray An array of Objects 56 | */ 57 | public void setMyObjectArray(Object[] myObjectArray) { 58 | this.myObjectArray = myObjectArray; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/BadlyTypedFixedPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * POJO to test class with setters for strings, which are being 8 | * then parsed to some other types. This creates problems for PODAM 9 | * 10 | * @author daivanov 11 | * 12 | */ 13 | public class BadlyTypedFixedPojo extends BadlyTypedPojo { 14 | 15 | /** 16 | * We created guide for PODAM what is real type of field to set 17 | * @param value integer value to set 18 | */ 19 | public void setValue(Integer value) { 20 | setValue(value.toString()); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/BadlyTypedPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * POJO to test class with setters for strings, which are being 8 | * then parsed to some other types. This creates problems for PODAM 9 | * 10 | * @author daivanov 11 | * 12 | */ 13 | public class BadlyTypedPojo { 14 | private Integer value; 15 | 16 | public Integer getValue() { 17 | return value; 18 | } 19 | 20 | public void setValue(String value) { 21 | this.value = Integer.valueOf(value); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/BooleanPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import uk.co.jemos.podam.test.dto.SimplePojoWithExcludeAnnotationToTestSetters.TestExclude; 7 | 8 | /** 9 | * POJO to test when Podam sets a boolean. 10 | * 11 | * @author daivanov 12 | * 13 | */ 14 | public class BooleanPojo { 15 | private boolean value1; 16 | private Boolean value2; 17 | private Boolean value3; 18 | private Boolean value4; 19 | 20 | public BooleanPojo() { 21 | } 22 | 23 | public boolean isValue1() { 24 | return value1; 25 | } 26 | 27 | public void setValue1(boolean value1) { 28 | this.value1 = value1; 29 | } 30 | 31 | @TestExclude 32 | public Boolean isValue2() { 33 | return value2; 34 | } 35 | 36 | public void setValue2(Boolean value2) { 37 | this.value2 = value2; 38 | } 39 | 40 | public Boolean getValue3() { 41 | return value3; 42 | } 43 | 44 | public void setValue3(Boolean value3) { 45 | this.value3 = value3; 46 | } 47 | 48 | public Boolean getValue4() { 49 | return value4; 50 | } 51 | 52 | public void setValue4(Boolean value4) { 53 | this.value4 = value4; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/CharSequencePojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * POJO to test when Podam sets signle letter fields with number. 8 | * 9 | * @author marcelmaatkamp 10 | * 11 | */ 12 | public class CharSequencePojo { 13 | private CharSequence v1; 14 | 15 | public CharSequence getV1() { 16 | return v1; 17 | } 18 | 19 | public void setV1(CharSequence v1) { 20 | this.v1 = v1; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ClassGenericConstructorPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * POJO to test Class instantiation 8 | * 9 | * @author daivanov 10 | * 11 | */ 12 | public class ClassGenericConstructorPojo { 13 | private Class clazz; 14 | 15 | public ClassGenericConstructorPojo(Class clazz) { 16 | this.clazz = clazz; 17 | } 18 | 19 | public Class getClazz() { 20 | return clazz; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ClassGenericPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * POJO to test Class instantiation 8 | * 9 | * @author daivanov 10 | * 11 | */ 12 | public class ClassGenericPojo { 13 | private Class clazz; 14 | 15 | public ClassGenericPojo() { 16 | } 17 | 18 | public Class getClazz() { 19 | return clazz; 20 | } 21 | 22 | public void setClazz(Class clazz) { 23 | this.clazz = clazz; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ClassInheritedPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * POJO to test Class instantiation 8 | * 9 | * @author daivanov 10 | * 11 | */ 12 | public class ClassInheritedPojo extends ClassGenericPojo { 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ClassPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * POJO to test Class instantiation 8 | * 9 | * @author daivanov 10 | * 11 | */ 12 | public class ClassPojo { 13 | private Class clazz; 14 | 15 | public ClassPojo() { 16 | } 17 | 18 | public Class getClazz() { 19 | return clazz; 20 | } 21 | 22 | public void setClazz(Class clazz) { 23 | this.clazz = clazz; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/CollectionExtendingGenericsPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.LinkedList; 7 | 8 | /** 9 | * Test pojo 10 | *

11 | * Pojo extending Pojo with generic type. 12 | *

13 | * 14 | * @author daivanov 15 | * 16 | */ 17 | public class CollectionExtendingGenericsPojo extends LinkedList { 18 | private static final long serialVersionUID = 1L; 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/CollectionExtendingImplementingPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.LinkedList; 7 | import java.util.Observable; 8 | import java.util.Observer; 9 | 10 | /** 11 | * Test pojo 12 | *

13 | * Pojo extending Pojo with generic type and implementing another inteface 14 | *

15 | * 16 | * @author daivanov 17 | * 18 | */ 19 | public class CollectionExtendingImplementingPojo extends LinkedList 20 | implements Observer { 21 | private static final long serialVersionUID = 1L; 22 | 23 | @Override 24 | public void update(Observable o, Object arg) { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/CollectionExtendingNoGenericsPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.LinkedList; 7 | 8 | /** 9 | * Test pojo 10 | *

11 | * Pojo extending Pojo with generic type. 12 | *

13 | * 14 | * @author daivanov 15 | * 16 | */ 17 | @SuppressWarnings("rawtypes") 18 | public class CollectionExtendingNoGenericsPojo extends LinkedList { 19 | private static final long serialVersionUID = 1L; 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/CollectionIndirectExtendingGenericsPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | public class CollectionIndirectExtendingGenericsPojo extends CollectionExtendingGenericsPojo { 4 | private static final long serialVersionUID = 1L; 5 | } 6 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ConcreteTestPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | public class ConcreteTestPojo extends AbstractTestPojo { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ConcreteTestPojoWithAdditionalString.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | public class ConcreteTestPojoWithAdditionalString extends AbstractTestPojo { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/DefaultFieldPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.Map; 4 | import java.util.TreeMap; 5 | 6 | /** 7 | * Pojo with default field 8 | * 9 | * @author daivanov 10 | * 11 | */ 12 | public class DefaultFieldPojo { 13 | 14 | private Map map = new TreeMap(); 15 | 16 | public DefaultFieldPojo(K key) { 17 | map.remove(key); 18 | } 19 | 20 | public Map getMap() { 21 | return map; 22 | } 23 | 24 | public void setMap(Map map) { 25 | this.map = map; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/DefaultMapSingleTypePojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.Map; 4 | import java.util.TreeMap; 5 | 6 | /** 7 | * Pojo with default map, which has key and value of the same type 8 | * 9 | * @author daivanov 10 | * 11 | */ 12 | public class DefaultMapSingleTypePojo { 13 | 14 | private Map map = new TreeMap(); 15 | 16 | public Map getMap() { 17 | return map; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/EmbeddedAbstractFieldTestPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import org.junit.Assert; 7 | 8 | public class EmbeddedAbstractFieldTestPojo { 9 | 10 | private final AbstractTestPojo testPojo; 11 | 12 | public EmbeddedAbstractFieldTestPojo(final AbstractTestPojo pojo) { 13 | Assert.assertNotNull(pojo); 14 | testPojo = pojo; 15 | } 16 | 17 | public AbstractTestPojo getPojo() { 18 | return testPojo; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/EmptyTestPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Empty POJO. 10 | *

11 | * No state should be set in this POJO 12 | *

13 | * 14 | * @author mtedone 15 | * 16 | */ 17 | public class EmptyTestPojo implements Serializable { 18 | 19 | private static final long serialVersionUID = 1L; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ExtendedTypedClassPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | /** 4 | * Pojo typed class 5 | * 6 | * @author daivanov 7 | * 8 | */ 9 | public class ExtendedTypedClassPojo extends SimpleTypedClassPojo { 10 | 11 | private T typedValue2; 12 | 13 | /** 14 | * @return the typedValue2 15 | */ 16 | public T getTypedValue2() { 17 | return typedValue2; 18 | } 19 | 20 | /** 21 | * @param typedValue2 22 | * the typedList to set 23 | */ 24 | public void setTypedValue2(T typedValue2) { 25 | this.typedValue2 = typedValue2; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/FactoryInstantiablePojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | /** 4 | * Abstract factory instantiable class 5 | * 6 | * @author daivanov 7 | * 8 | */ 9 | public abstract class FactoryInstantiablePojo { 10 | 11 | private T typedValue; 12 | 13 | public static FactoryInstantiablePojo getInstance(E typedValue) { 14 | return new FactoryInstantiablePojoImpl(typedValue); 15 | } 16 | 17 | /** 18 | * @return the typedValue 19 | */ 20 | public T getTypedValue() { 21 | return typedValue; 22 | } 23 | 24 | /** 25 | * @param typedValue 26 | * the typedList to set 27 | */ 28 | public void setTypedValue(T typedValue) { 29 | this.typedValue = typedValue; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/FactoryInstantiablePojoImpl.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | /** 4 | * Implementation of factory instantiable class 5 | * 6 | * @author daivanov 7 | * 8 | */ 9 | class FactoryInstantiablePojoImpl extends FactoryInstantiablePojo { 10 | 11 | protected FactoryInstantiablePojoImpl(T typedValue) { 12 | setTypedValue(typedValue); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/FactoryInstantiableReadOnlyPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | /** 4 | * Abstract factory instantiable read-only class 5 | * 6 | * @author daivanov 7 | * 8 | */ 9 | public abstract class FactoryInstantiableReadOnlyPojo { 10 | 11 | protected T typedValue; 12 | 13 | public static FactoryInstantiableReadOnlyPojo getInstance(E typedValue) { 14 | return new FactoryInstantiableReadOnlyPojoImpl(typedValue); 15 | } 16 | 17 | /** 18 | * @return the typedValue 19 | */ 20 | public T getTypedValue() { 21 | return typedValue; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/FactoryInstantiableReadOnlyPojoImpl.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | /** 4 | * Implementation of factory instantiable read-only class 5 | * 6 | * @author daivanov 7 | * 8 | */ 9 | class FactoryInstantiableReadOnlyPojoImpl extends FactoryInstantiableReadOnlyPojo { 10 | 11 | protected FactoryInstantiableReadOnlyPojoImpl(T typedValue) { 12 | this.typedValue = typedValue; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/FloatExt.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * @author tedonema 8 | * 9 | */ 10 | public class FloatExt implements ObjectExt { 11 | 12 | private T value; 13 | 14 | @Override 15 | public T getValue() { 16 | return value; 17 | } 18 | 19 | @Override 20 | public void setValue(T value) { 21 | this.value = value; 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/FloatExt2.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * @author tedonema 8 | * 9 | */ 10 | public class FloatExt2 implements ObjectExt { 11 | 12 | private Float value; 13 | 14 | @Override 15 | public Float getValue() { 16 | return value; 17 | } 18 | 19 | @Override 20 | public void setValue(Float value) { 21 | this.value = value; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/GenericArrayInConstructorPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | /** 4 | * Generic Pojo with generic array type in constructor 5 | * 6 | * @author daivanov 7 | */ 8 | public class GenericArrayInConstructorPojo { 9 | 10 | private E[] array; 11 | 12 | public GenericArrayInConstructorPojo(E[] array) { 13 | this.array = array; 14 | } 15 | 16 | public E[] getArray() { 17 | return array; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/GenericInConstructorPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.Vector; 4 | 5 | /** 6 | * Generic Pojo with generic type in constructor 7 | * 8 | * @author daivanov 9 | */ 10 | public class GenericInConstructorPojo { 11 | 12 | private Vector vector; 13 | 14 | public GenericInConstructorPojo(Vector vector) { 15 | this.vector = vector; 16 | } 17 | 18 | public Vector getVector() { 19 | return vector; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/GenericInSetterPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.Vector; 4 | 5 | /** 6 | * Generic Pojo with generic type in constructor 7 | * 8 | * @author daivanov 9 | */ 10 | public class GenericInSetterPojo { 11 | 12 | private Vector vector; 13 | 14 | public Vector getVector() { 15 | return vector; 16 | } 17 | 18 | public void setVector(Vector vector) { 19 | this.vector = vector; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/GenericInStaticConstructorPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.Vector; 4 | 5 | /** 6 | * Generic Pojo with generic type in constructor 7 | * 8 | * @author daivanov 9 | */ 10 | public abstract class GenericInStaticConstructorPojo { 11 | 12 | protected Vector vector; 13 | 14 | public static GenericInStaticConstructorPojo getInstance(Vector vector) { 15 | return new GenericInStaticConstructorPojoImpl(vector); 16 | } 17 | 18 | public Vector getVector() { 19 | return vector; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/GenericInStaticConstructorPojoImpl.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.Vector; 4 | 5 | /** 6 | * Generic Pojo with generic type in constructor 7 | * 8 | * @author daivanov 9 | */ 10 | public class GenericInStaticConstructorPojoImpl 11 | extends GenericInStaticConstructorPojo { 12 | 13 | protected GenericInStaticConstructorPojoImpl(Vector vector) { 14 | this.vector = vector; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ImmutableDefaultFieldsPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.Collections; 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | /** 11 | * @author divanov 12 | * 13 | */ 14 | public class ImmutableDefaultFieldsPojo { 15 | 16 | private List list = Collections.singletonList("key"); 17 | 18 | private Map map = Collections.singletonMap("key", 100); 19 | 20 | public List getList() { 21 | return list; 22 | } 23 | 24 | public void setList(List list) { 25 | this.list = list; 26 | } 27 | 28 | public Map getMap() { 29 | return map; 30 | } 31 | 32 | public void setMap(Map map) { 33 | this.map = map; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ImmutableHashtable.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.Hashtable; 4 | import java.util.Map; 5 | 6 | /** 7 | * @author daivanov 8 | * 9 | */ 10 | public class ImmutableHashtable extends Hashtable { 11 | private static final long serialVersionUID = -1L; 12 | 13 | @Override 14 | public V put(K key, V value) { 15 | throw new UnsupportedOperationException("Immutable hashtable"); 16 | } 17 | 18 | @Override 19 | public V remove(Object key) { 20 | throw new UnsupportedOperationException("Immutable hashtable"); 21 | } 22 | 23 | @Override 24 | public void putAll(Map m) { 25 | throw new UnsupportedOperationException("Immutable hashtable"); 26 | } 27 | 28 | @Override 29 | public void clear() { 30 | throw new UnsupportedOperationException("Immutable hashtable"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ImmutablePojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * Immutable POJO 8 | * 9 | * @author daivanov 10 | * 11 | */ 12 | public class ImmutablePojo { 13 | private String value; 14 | private Integer value2; 15 | 16 | public ImmutablePojo(String value, Integer value2) { 17 | this(value); 18 | this.value2 = value2; 19 | } 20 | 21 | public ImmutablePojo(String value) { 22 | this.value = value; 23 | } 24 | 25 | public ImmutablePojo() { 26 | } 27 | 28 | public String getValue() { 29 | return value; 30 | } 31 | 32 | public Integer getValue2() { 33 | return value2; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ImmutableVector.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.Collection; 4 | import java.util.Vector; 5 | 6 | /** 7 | * @author daivanov 8 | * 9 | */ 10 | public class ImmutableVector extends Vector { 11 | private static final long serialVersionUID = 1L; 12 | 13 | @Override 14 | public boolean add(E e) { 15 | throw new UnsupportedOperationException("Immutable vector"); 16 | } 17 | 18 | @Override 19 | public boolean remove(Object o) { 20 | throw new UnsupportedOperationException("Immutable vector"); 21 | } 22 | 23 | @Override 24 | public boolean addAll(Collection c) { 25 | throw new UnsupportedOperationException("Immutable vector"); 26 | } 27 | 28 | @Override 29 | public boolean removeAll(Collection c) { 30 | throw new UnsupportedOperationException("Immutable vector"); 31 | } 32 | 33 | @Override 34 | public boolean retainAll(Collection c) { 35 | throw new UnsupportedOperationException("Immutable vector"); 36 | } 37 | 38 | @Override 39 | public void clear() { 40 | throw new UnsupportedOperationException("Immutable vector"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/InnerClassPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | public class InnerClassPojo { 4 | 5 | private InnerPojo ip; 6 | 7 | public InnerPojo getIp() { 8 | return ip; 9 | } 10 | 11 | public InnerClassPojo(InnerPojo ip) { 12 | this.ip = ip; 13 | } 14 | 15 | public class InnerPojo { 16 | private String data; 17 | 18 | public InnerPojo(String data) { 19 | this.data = data; 20 | } 21 | 22 | public String getData() { 23 | return data; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/InterfacePojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * An interface to test for errors 8 | * 9 | * @author mtedone 10 | * 11 | */ 12 | public interface InterfacePojo { 13 | 14 | void setIntField(int intField); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/JAXBElementPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import javax.xml.bind.JAXBElement; 7 | 8 | /** 9 | * POJO to test when Podam sets a boolean. 10 | * 11 | * @author daivanov 12 | * 13 | */ 14 | public class JAXBElementPojo { 15 | private JAXBElement value; 16 | 17 | public JAXBElementPojo() { 18 | } 19 | 20 | public JAXBElement getValue() { 21 | return value; 22 | } 23 | 24 | public void setValue(JAXBElement value) { 25 | this.value = value; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/JacksonDatabindPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.List; 7 | 8 | import org.openapitools.jackson.nullable.JsonNullable; 9 | 10 | /** 11 | * POJO to test jackson-databind-nullable 12 | * 13 | * @author daivanov 14 | * 15 | */ 16 | public class JacksonDatabindPojo { 17 | private JsonNullable> stringList = JsonNullable.>undefined(); 18 | 19 | public JacksonDatabindPojo(List stringList) { 20 | this.stringList = JsonNullable.of(stringList); 21 | } 22 | 23 | public List getStringList() { 24 | return stringList.orElse(null); 25 | } 26 | 27 | public void setStringList(List stringList) { 28 | this.stringList = JsonNullable.>of(stringList); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/MapExtendingGenericsPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.TreeMap; 7 | 8 | /** 9 | * Test pojo 10 | *

11 | * Pojo extending Pojo with generic type. 12 | *

13 | * 14 | * @author daivanov 15 | * 16 | */ 17 | public class MapExtendingGenericsPojo extends TreeMap { 18 | private static final long serialVersionUID = 1L; 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/MapExtendingImplementingPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.Observable; 7 | import java.util.Observer; 8 | import java.util.TreeMap; 9 | 10 | /** 11 | * Test pojo 12 | *

13 | * Pojo extending Pojo with generic type. 14 | *

15 | * 16 | * @author daivanov 17 | * 18 | */ 19 | public class MapExtendingImplementingPojo extends TreeMap 20 | implements Observer { 21 | private static final long serialVersionUID = 1L; 22 | 23 | @Override 24 | public void update(Observable o, Object arg) { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/MapExtendingNoGenericsPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.HashMap; 7 | 8 | /** 9 | * Test pojo 10 | *

11 | * Pojo extending Pojo with generic type. 12 | *

13 | * 14 | * @author daivanov 15 | * 16 | */ 17 | @SuppressWarnings("rawtypes") 18 | public class MapExtendingNoGenericsPojo extends HashMap { 19 | private static final long serialVersionUID = 1L; 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/MapImplementingGenericInterface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.Collection; 7 | import java.util.Map; 8 | import java.util.Set; 9 | import java.util.TreeMap; 10 | 11 | /** 12 | * Test pojo 13 | *

14 | * Pojo implementing generic interface 15 | *

16 | * 17 | * @author daivanov 18 | * 19 | */ 20 | public class MapImplementingGenericInterface implements Map { 21 | 22 | private Map map = new TreeMap(); 23 | 24 | @Override 25 | public int size() { 26 | return map.size(); 27 | } 28 | 29 | @Override 30 | public boolean isEmpty() { 31 | return map.isEmpty(); 32 | } 33 | 34 | @Override 35 | public boolean containsKey(Object key) { 36 | return map.containsKey(key); 37 | } 38 | 39 | @Override 40 | public boolean containsValue(Object value) { 41 | return map.containsValue(value); 42 | } 43 | 44 | @Override 45 | public String get(Object key) { 46 | return map.get(key); 47 | } 48 | 49 | @Override 50 | public String put(Integer key, String value) { 51 | return map.put(key, value); 52 | } 53 | 54 | @Override 55 | public String remove(Object key) { 56 | return map.remove(key); 57 | } 58 | 59 | @Override 60 | public void putAll(Map m) { 61 | map.putAll(m); 62 | } 63 | 64 | @Override 65 | public void clear() { 66 | map.clear(); 67 | } 68 | 69 | @Override 70 | public Set keySet() { 71 | return map.keySet(); 72 | } 73 | 74 | @Override 75 | public Collection values() { 76 | return map.values(); 77 | } 78 | 79 | @Override 80 | public Set> entrySet() { 81 | return map.entrySet(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/MapIndirectExtendingGenericsPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * Test pojo 8 | *

9 | * Pojo extending Pojo with generic type. 10 | *

11 | * 12 | * @author daivanov 13 | * 14 | */ 15 | public class MapIndirectExtendingGenericsPojo extends MapExtendingGenericsPojo { 16 | private static final long serialVersionUID = 1L; 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/MapIndirectRawImplPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.Collection; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | import java.util.Set; 7 | 8 | public class MapIndirectRawImplPojo implements PodamRawMap { 9 | 10 | private Map map = new HashMap(); 11 | 12 | @Override 13 | public int size() { 14 | return map.size(); 15 | } 16 | 17 | @Override 18 | public boolean isEmpty() { 19 | return map.isEmpty(); 20 | } 21 | 22 | @Override 23 | public boolean containsKey(Object key) { 24 | return map.containsKey(key); 25 | } 26 | 27 | @Override 28 | public boolean containsValue(Object value) { 29 | return map.containsValue(value); 30 | } 31 | 32 | @Override 33 | public Object get(Object key) { 34 | return map.get(key); 35 | } 36 | 37 | @Override 38 | public Object put(Object key, Object value) { 39 | return map.put(key, value); 40 | } 41 | 42 | @Override 43 | public Object remove(Object key) { 44 | return map.remove(key); 45 | } 46 | 47 | @Override 48 | @SuppressWarnings("unchecked") 49 | public void putAll(@SuppressWarnings("rawtypes") Map m) { 50 | map.putAll(m); 51 | } 52 | 53 | @Override 54 | public void clear() { 55 | map.clear(); 56 | } 57 | 58 | @Override 59 | public Set keySet() { 60 | return map.keySet(); 61 | } 62 | 63 | @Override 64 | public Collection values() { 65 | return map.values(); 66 | } 67 | 68 | @Override 69 | public Set> entrySet() { 70 | return map.entrySet(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/MemoizationPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.Currency; 7 | import java.util.Map; 8 | import java.util.Set; 9 | 10 | /** 11 | * POJO to test when Podam memoization with collections and arrays 12 | * 13 | * @author daivanov 14 | * 15 | */ 16 | public class MemoizationPojo { 17 | 18 | private Currency single; 19 | private Currency singleReadOnly; 20 | private Currency[] array; 21 | private Set collection; 22 | private Map map; 23 | 24 | public MemoizationPojo(Currency singleReadOnly) { 25 | this.singleReadOnly = singleReadOnly; 26 | } 27 | 28 | public Currency getSingle() { 29 | return single; 30 | } 31 | 32 | public Currency getSingleReadOnly() { 33 | return singleReadOnly; 34 | } 35 | 36 | public void setSingle(Currency single) { 37 | this.single = single; 38 | } 39 | 40 | public Currency[] getArray() { 41 | return array; 42 | } 43 | 44 | public void setArray(Currency[] array) { 45 | this.array = array; 46 | } 47 | 48 | public Set getCollection() { 49 | return collection; 50 | } 51 | 52 | public void setCollection(Set collection) { 53 | this.collection = collection; 54 | } 55 | 56 | public Map getMap() { 57 | return map; 58 | } 59 | 60 | public void setMap(Map map) { 61 | this.map = map; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/MultiDimensionalConstructorPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.Calendar; 4 | import java.util.Collection; 5 | import java.util.Date; 6 | import java.util.List; 7 | import java.util.Map; 8 | import java.util.Queue; 9 | import java.util.Set; 10 | 11 | /** 12 | * This is POJO to test PODAM's ability to create an instance 13 | * using a constructor with multidimensional collections, arrays 14 | * and maps parameters 15 | * 16 | * @author mcarmona 17 | * 18 | */ 19 | public class MultiDimensionalConstructorPojo extends MultiDimensionalTestPojo { 20 | 21 | public MultiDimensionalConstructorPojo( 22 | List>> threeDimensionalList, 23 | Set>> threeDimensionalSet, 24 | Collection>> threeDimensionalCollection, 25 | Map>> threeDimensionalMap, 26 | Queue>> threeDimensionalQueue, 27 | String[][][] threeDimensionalArray) { 28 | setThreeDimensionalArray(threeDimensionalArray); 29 | setThreeDimensionalCollection(threeDimensionalCollection); 30 | setThreeDimensionalList(threeDimensionalList); 31 | setThreeDimensionalMap(threeDimensionalMap); 32 | setThreeDimensionalQueue(threeDimensionalQueue); 33 | setThreeDimensionalSet(threeDimensionalSet); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/MultipleGenericInConstructorPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | /** 7 | * Generic Pojo with generic types in constructor 8 | * 9 | * @author daivanov 10 | */ 11 | public class MultipleGenericInConstructorPojo { 12 | 13 | private Class type; 14 | 15 | private List list; 16 | 17 | private Map map; 18 | 19 | public MultipleGenericInConstructorPojo(Class type, List list, Map map) { 20 | this.type = type; 21 | this.list = list; 22 | this.map = map; 23 | } 24 | 25 | public Class getType() { 26 | return type; 27 | } 28 | 29 | public List getList() { 30 | return list; 31 | } 32 | 33 | public Map getMap() { 34 | return map; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/MultipleInterfacesHolderPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | 4 | /** 5 | * Holder for pojo derived from two interfaces: Map/List and another one 6 | * 7 | * @author daivanov 8 | * 9 | */ 10 | public class MultipleInterfacesHolderPojo { 11 | 12 | private MultipleInterfacesListPojo list; 13 | 14 | private MultipleInterfacesMapPojo map; 15 | 16 | public MultipleInterfacesListPojo getList() { 17 | return list; 18 | } 19 | 20 | public void setList(MultipleInterfacesListPojo list) { 21 | this.list = list; 22 | } 23 | 24 | public MultipleInterfacesMapPojo getMap() { 25 | return map; 26 | } 27 | 28 | public void setMap(MultipleInterfacesMapPojo map) { 29 | this.map = map; 30 | } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/MultipleInterfacesListPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Pojo derived from two interfaces: List and another one 7 | * 8 | * @author daivanov 9 | * 10 | */ 11 | public interface MultipleInterfacesListPojo extends List, Appendable { 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/MultipleInterfacesMapPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Pojo derived from two interfaces: Map and another one 7 | * 8 | * @author daivanov 9 | * 10 | */ 11 | public interface MultipleInterfacesMapPojo extends Map, Appendable { 12 | } 13 | 14 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/NoDefaultConstructorPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @author mtedone 10 | * 11 | */ 12 | public class NoDefaultConstructorPojo implements Serializable { 13 | 14 | // ------------------->> Constants 15 | 16 | private static final long serialVersionUID = 1L; 17 | 18 | // ------------------->> Instance / Static variables 19 | 20 | /** An int field */ 21 | private int intField; 22 | 23 | // ------------------->> Constructors 24 | 25 | /** 26 | * @param intField The int field 27 | */ 28 | public NoDefaultConstructorPojo(int intField) { 29 | super(); 30 | this.intField = intField; 31 | } 32 | 33 | // ------------------->> Public methods 34 | 35 | // ------------------->> Getters / Setters 36 | 37 | /** 38 | * @return the intField 39 | */ 40 | public int getIntField() { 41 | return intField; 42 | } 43 | 44 | /** 45 | * @param intField 46 | * the intField to set 47 | */ 48 | public void setIntField(int intField) { 49 | this.intField = intField; 50 | } 51 | 52 | // ------------------->> Private methods 53 | 54 | // ------------------->> equals() / hashcode() / toString() 55 | 56 | /** 57 | * Constructs a String with all attributes in name = value 58 | * format. 59 | * 60 | * @return a String representation of this object. 61 | */ 62 | @Override 63 | public String toString() { 64 | final String TAB = " "; 65 | 66 | StringBuilder retValue = new StringBuilder(); 67 | 68 | retValue.append("NoDefaultConstructorPojo ( ").append("intField = ") 69 | .append(intField).append(TAB).append(" )"); 70 | 71 | return retValue.toString(); 72 | } 73 | 74 | // ------------------->> Inner classes 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/NonEJBPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * POJO , which doesn't comply with EJB standard 8 | * 9 | * @author daivanov 10 | * 11 | */ 12 | public class NonEJBPojo { 13 | private static class Holder { 14 | private String holdingString; 15 | private Long holdingLong; 16 | } 17 | 18 | private Holder myHolder = new Holder(); 19 | 20 | public String getMyString() { 21 | return myHolder.holdingString; 22 | } 23 | 24 | public void setMyString(String myString) { 25 | myHolder.holdingString = myString; 26 | } 27 | 28 | public Long getMyLong() { 29 | return myHolder.holdingLong; 30 | } 31 | 32 | public void setMyLong(Long myLong) { 33 | myHolder.holdingLong = myLong; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/NonInstantiatableClass.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | /** 4 | * @author kurtinaitis 5 | */ 6 | public class NonInstantiatableClass { 7 | private String name; 8 | 9 | public NonInstantiatableClass() throws Exception { 10 | throw new Exception(); 11 | } 12 | 13 | public void setName(String name) { 14 | this.name = name; 15 | } 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/NonStandardPojoToTestSetters.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @author daivanov 10 | * 11 | */ 12 | public class NonStandardPojoToTestSetters implements Serializable { 13 | 14 | private static final long serialVersionUID = 1L; 15 | 16 | private String stringField; 17 | 18 | private int intField; 19 | 20 | public String whatIsStringField() { 21 | return stringField; 22 | } 23 | 24 | public NonStandardPojoToTestSetters withStringField(String stringField) { 25 | this.stringField = stringField; 26 | return this; 27 | } 28 | 29 | public int whatIsIntField() { 30 | return intField; 31 | } 32 | 33 | public NonStandardPojoToTestSetters withIntField(int intField) { 34 | this.intField = intField; 35 | return this; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ObjectExt.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * @author tedonema 8 | * 9 | */ 10 | public interface ObjectExt { 11 | 12 | public T getValue(); 13 | 14 | public void setValue(T value); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/OptionalList.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | public class OptionalList { 7 | 8 | private final Optional> optionalList; 9 | 10 | public OptionalList(Optional> optionalList) { 11 | this.optionalList = optionalList; 12 | } 13 | 14 | public Optional> getOptionalList() { 15 | return optionalList; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/PodamParameterizedType.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.lang.reflect.ParameterizedType; 4 | import java.lang.reflect.Type; 5 | 6 | /** 7 | * {@link ParameterizedType} implementation for generic multidimensional pojo 8 | * manufacturing 9 | * 10 | * @author marciocarmona 11 | * 12 | */ 13 | public class PodamParameterizedType implements ParameterizedType { 14 | 15 | private final Class rawType; 16 | private final Type[] actualTypeArguments; 17 | 18 | /** 19 | * Base constructor. 20 | * 21 | * @param rawType 22 | * the generic class type 23 | * @param actualTypeArguments 24 | * the type arguments 25 | */ 26 | public PodamParameterizedType(final Class rawType, 27 | final Type... actualTypeArguments) { 28 | super(); 29 | this.rawType = rawType; 30 | this.actualTypeArguments = actualTypeArguments; 31 | } 32 | 33 | /** 34 | * {@inheritDoc} 35 | */ 36 | @Override 37 | public Type[] getActualTypeArguments() { 38 | return actualTypeArguments; 39 | } 40 | 41 | /** 42 | * {@inheritDoc} 43 | */ 44 | @Override 45 | public Class getRawType() { 46 | return rawType; 47 | } 48 | 49 | /** 50 | * {@inheritDoc} 51 | */ 52 | @Override 53 | public Type getOwnerType() { 54 | return null; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/PodamRawList.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Test pojo 10 | *

11 | * Pojo extending Pojo with generic interface. 12 | *

13 | * 14 | * @author daivanov 15 | * 16 | */ 17 | @SuppressWarnings("rawtypes") 18 | public interface PodamRawList extends List { 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/PodamRawMap.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.Map; 7 | 8 | /** 9 | * Test pojo 10 | *

11 | * Pojo extending Pojo with generic interface. 12 | *

13 | * 14 | * @author daivanov 15 | * 16 | */ 17 | @SuppressWarnings("rawtypes") 18 | public interface PodamRawMap extends Map { 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/PodamTestInterface.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | /** 4 | * @author divanov 5 | */ 6 | public interface PodamTestInterface { 7 | } 8 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/PojoWithInterfaces.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * An class with interfaces as parameters 8 | * 9 | * @author daivanov 10 | * 11 | */ 12 | public class PojoWithInterfaces { 13 | 14 | private InterfacePojo value; 15 | 16 | public PojoWithInterfaces(ObjectExt value) { 17 | } 18 | 19 | public InterfacePojo getValue() { 20 | return value; 21 | } 22 | 23 | public void setValue(InterfacePojo value) { 24 | this.value = value; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/PojoWithMapsAndCollections.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | /** 7 | * Pojo typed class 8 | * 9 | * @author daivanov 10 | * 11 | */ 12 | public class PojoWithMapsAndCollections { 13 | 14 | private String[] array; 15 | private List list; 16 | private Map map; 17 | 18 | /** 19 | * @return the array 20 | */ 21 | public String[] getArray() { 22 | return array; 23 | } 24 | 25 | /** 26 | * @param array 27 | * the array to set 28 | */ 29 | public void setArray(String[] array) { 30 | this.array = array; 31 | } 32 | 33 | /** 34 | * @return the list 35 | */ 36 | public List getList() { 37 | return list; 38 | } 39 | 40 | /** 41 | * @param list 42 | * the list to set 43 | */ 44 | public void setList(List list) { 45 | this.list = list; 46 | } 47 | 48 | /** 49 | * @return the map 50 | */ 51 | public Map getMap() { 52 | return map; 53 | } 54 | 55 | /** 56 | * @param map 57 | * the map to set 58 | */ 59 | public void setMap(Map map) { 60 | this.map = map; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/PrivateNoArgConstructorPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * @author mtedone 10 | * 11 | */ 12 | public class PrivateNoArgConstructorPojo implements Serializable { 13 | 14 | // ------------------->> Constants 15 | 16 | private static final long serialVersionUID = 1L; 17 | 18 | // ------------------->> Instance / Static variables 19 | 20 | private int intField; 21 | 22 | // ------------------->> Constructors 23 | 24 | private PrivateNoArgConstructorPojo() { 25 | 26 | } 27 | 28 | // ------------------->> Public methods 29 | 30 | // ------------------->> Getters / Setters 31 | 32 | /** 33 | * @return the intField 34 | */ 35 | public int getIntField() { 36 | return intField; 37 | } 38 | 39 | /** 40 | * @param intField 41 | * the intField to set 42 | */ 43 | public void setIntField(int intField) { 44 | this.intField = intField; 45 | } 46 | 47 | // ------------------->> Private methods 48 | 49 | // ------------------->> equals() / hashcode() / toString() 50 | 51 | // ------------------->> Inner classes 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ReadOnlyAbstract.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | /** 4 | * POJO with read only fields which are not accessible 5 | * 6 | * @author daivanov 7 | */ 8 | public abstract class ReadOnlyAbstract { 9 | 10 | public static ReadOnlyAbstract getInstance() { 11 | return new ReadOnlyNonAccessible(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ReadOnlyComplexTypesPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | /** 9 | * Generic POJO with read only complex type fields 10 | * 11 | * @author daivanov 12 | */ 13 | public class ReadOnlyComplexTypesPojo { 14 | 15 | public static class Value { 16 | private String value; 17 | 18 | public String getValue() { 19 | return value; 20 | } 21 | 22 | public void setValue(String value) { 23 | this.value = value; 24 | } 25 | } 26 | 27 | private String[] array = new String[3]; 28 | 29 | private List list = new ArrayList(); 30 | 31 | private Map map = new HashMap(); 32 | 33 | private Value value = new Value(); 34 | 35 | public String[] getArray() { 36 | return array; 37 | } 38 | 39 | public List getList() { 40 | return list; 41 | } 42 | 43 | public Map getMap() { 44 | return map; 45 | } 46 | 47 | public Value getValue() { 48 | return value; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ReadOnlyGenericComplexTypesPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | /** 9 | * Generic POJO with read only complex type fields 10 | * 11 | * @author daivanov 12 | */ 13 | public class ReadOnlyGenericComplexTypesPojo { 14 | 15 | public static class Value { 16 | private T value; 17 | 18 | public T getValue() { 19 | return value; 20 | } 21 | 22 | public void setValue(T value) { 23 | this.value = value; 24 | } 25 | } 26 | 27 | private List list = new ArrayList(); 28 | 29 | private Map map = new HashMap(); 30 | 31 | private Value value = new Value(); 32 | 33 | public List getList() { 34 | return list; 35 | } 36 | 37 | public Map getMap() { 38 | return map; 39 | } 40 | 41 | public Value getValue() { 42 | return value; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ReadOnlyNonAccessible.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | /** 9 | * POJO with read only fields which are not accessible 10 | * 11 | * @author daivanov 12 | */ 13 | final class ReadOnlyNonAccessible extends ReadOnlyAbstract { 14 | 15 | private List list = new ArrayList(); 16 | 17 | private Map map = new HashMap(); 18 | 19 | public List getList() { 20 | return list; 21 | } 22 | 23 | public Map getMap() { 24 | return map; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ReadOnlyRawFieldsPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * POJO to test read-only fields with wildcards instantiation 13 | * 14 | * @author daivanov 15 | * 16 | */ 17 | @SuppressWarnings("rawtypes") 18 | public class ReadOnlyRawFieldsPojo { 19 | 20 | private Class clazz = Object.class; 21 | 22 | private List list = new ArrayList(); 23 | 24 | private Map map = new HashMap(); 25 | 26 | public Class getClazz() { 27 | return clazz; 28 | } 29 | 30 | public List getList() { 31 | return list; 32 | } 33 | 34 | public Map getMap() { 35 | return map; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ReadOnlyWildcardFieldsPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * POJO to test read-only fields with wildcards instantiation 13 | * 14 | * @author daivanov 15 | * 16 | */ 17 | public class ReadOnlyWildcardFieldsPojo { 18 | 19 | private Class clazz = Object.class; 20 | 21 | private List list = new ArrayList(); 22 | 23 | private Map map = new HashMap(); 24 | 25 | public Class getClazz() { 26 | return clazz; 27 | } 28 | 29 | public List getList() { 30 | return list; 31 | } 32 | 33 | public Map getMap() { 34 | return map; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/RecursivePojoWithList.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.List; 4 | 5 | public class RecursivePojoWithList { 6 | 7 | private String name; 8 | 9 | private RecursivePojoWithList related; 10 | 11 | private List children; 12 | 13 | public String getName() { 14 | return this.name; 15 | } 16 | 17 | public void setName(String name) { 18 | this.name = name; 19 | } 20 | 21 | public RecursivePojoWithList getRelated() { 22 | return this.related; 23 | } 24 | 25 | public void setRelated(RecursivePojoWithList related) { 26 | this.related = related; 27 | } 28 | 29 | public List getChildren() { 30 | return this.children; 31 | } 32 | 33 | public void setChildren(List children) { 34 | this.children = children; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ShortNamesPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | /** 7 | * POJO to test when Podam sets signle letter fields with number. 8 | * 9 | * @author daivanov 10 | * 11 | */ 12 | public class ShortNamesPojo { 13 | private String v1; 14 | 15 | public String getV1() { 16 | return v1; 17 | } 18 | 19 | public void setV1(String v1) { 20 | this.v1 = v1; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/SimpleTypedClassPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | /** 4 | * Pojo typed class 5 | * 6 | * @author daivanov 7 | * 8 | */ 9 | public class SimpleTypedClassPojo { 10 | 11 | private T typedValue; 12 | 13 | /** 14 | * @return the typedValue 15 | */ 16 | public T getTypedValue() { 17 | return typedValue; 18 | } 19 | 20 | /** 21 | * @param typedValue 22 | * the typedList to set 23 | */ 24 | public void setTypedValue(T typedValue) { 25 | this.typedValue = typedValue; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/TypedClassPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Pojo typed class 7 | * 8 | * @author daivanov 9 | * 10 | */ 11 | public class TypedClassPojo { 12 | 13 | private T typedValue; 14 | 15 | private List typedList; 16 | 17 | /** 18 | * @return the typedValue 19 | */ 20 | public T getTypedValue() { 21 | return typedValue; 22 | } 23 | 24 | /** 25 | * @param typedValue 26 | * the typedList to set 27 | */ 28 | public void setTypedValue(T typedValue) { 29 | this.typedValue = typedValue; 30 | } 31 | 32 | /** 33 | * @return the typedList 34 | */ 35 | public List getTypedList() { 36 | return typedList; 37 | } 38 | 39 | /** 40 | * @param typedList 41 | * the typedList to set 42 | */ 43 | public void setTypedList(List typedList) { 44 | this.typedList = typedList; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/TypedClassPojo2.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | 4 | /** 5 | * Pojo derived from typed class 6 | * 7 | * @author daivanov 8 | * 9 | */ 10 | public class TypedClassPojo2 extends TypedClassPojo { 11 | } 12 | 13 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/UnsupportedCollectionInConstructorPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.Vector; 7 | 8 | /** 9 | * @author daivanov 10 | * 11 | */ 12 | public class UnsupportedCollectionInConstructorPojo { 13 | 14 | private Vector vector; 15 | 16 | public UnsupportedCollectionInConstructorPojo(Vector vector) { 17 | this.vector = vector; 18 | } 19 | 20 | public Vector getVector() { 21 | return vector; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/UnsupportedMapInConstructorPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import java.util.Hashtable; 7 | 8 | /** 9 | * @author daivanov 10 | * 11 | */ 12 | public class UnsupportedMapInConstructorPojo { 13 | 14 | private Hashtable hashTable; 15 | 16 | public UnsupportedMapInConstructorPojo(Hashtable hashTable) { 17 | this.hashTable = hashTable; 18 | } 19 | 20 | public Hashtable getHashTable() { 21 | return hashTable; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ValidatedPatternPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | 7 | import jakarta.validation.constraints.Pattern; 8 | 9 | /** 10 | * POJO to test bean validation API 11 | * 12 | * @author daivanov 13 | * 14 | */ 15 | public class ValidatedPatternPojo { 16 | 17 | @Pattern(regexp = "^[0-9]{1,45}$") 18 | private String number; 19 | 20 | @Pattern(regexp = "^[a-zA-Z0-9_]*$") 21 | private String identifier; 22 | 23 | public String getNumber() { 24 | return number; 25 | } 26 | 27 | public void setNumber(String number) { 28 | this.number = number; 29 | } 30 | 31 | public String getIdentifier() { 32 | return identifier; 33 | } 34 | 35 | public void setIdentifier(String identifier) { 36 | this.identifier = identifier; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ValidatedPojo2.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | 7 | import jakarta.validation.constraints.Negative; 8 | import jakarta.validation.constraints.NegativeOrZero; 9 | import jakarta.validation.constraints.Positive; 10 | import jakarta.validation.constraints.PositiveOrZero; 11 | 12 | /** 13 | * POJO to test bean validation API 2.0 14 | * 15 | * @author daivanov 16 | * 17 | */ 18 | public class ValidatedPojo2 { 19 | 20 | @PositiveOrZero 21 | private int intPositiveOrZero; 22 | 23 | @Positive 24 | private int intPositive; 25 | 26 | @NegativeOrZero 27 | private int intNegativeOrZero; 28 | 29 | @Negative 30 | private int intNegative; 31 | 32 | public int getIntPositive() { 33 | return intPositive; 34 | } 35 | 36 | public void setIntPositive(int intPositive) { 37 | this.intPositive = intPositive; 38 | } 39 | 40 | public int getIntPositiveOrZero() { 41 | return intPositiveOrZero; 42 | } 43 | 44 | public void setIntPositiveOrZero(int intPositiveOrZero) { 45 | this.intPositiveOrZero = intPositiveOrZero; 46 | } 47 | 48 | public int getIntNegative() { 49 | return intNegative; 50 | } 51 | 52 | public void setIntNegative(int intNegative) { 53 | this.intNegative = intNegative; 54 | } 55 | 56 | public int getIntNegativeOrZero() { 57 | return intNegativeOrZero; 58 | } 59 | 60 | public void setIntNegativeOrZero(int intNegativeOrZero) { 61 | this.intNegativeOrZero = intNegativeOrZero; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/ValidationPojoForStringWithSizeAndNoMax.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import jakarta.validation.constraints.Size; 4 | 5 | /** 6 | * POJO to test Issue 110 7 | *

8 | * When a String is annotated with @Size and only min value is defined, 9 | * Podam should allow for sensible, max defaults 10 | *

11 | * Created by tedonema on 26/06/2015. 12 | */ 13 | public class ValidationPojoForStringWithSizeAndNoMax { 14 | 15 | @Size(min = 0) 16 | private String name; 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public void setName(String name) { 23 | this.name = name; 24 | } 25 | 26 | @Size(max = 100) 27 | private String name2; 28 | 29 | public String getName2() { 30 | return name2; 31 | } 32 | 33 | public void setName2(String name2) { 34 | this.name2 = name2; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | final StringBuilder sb = new StringBuilder("ValidationPojoForStringWithSizeAndNoMax{"); 40 | sb.append("name='").append(name).append('\''); 41 | sb.append("name2='").append(name2).append('\''); 42 | sb.append('}'); 43 | return sb.toString(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/WildcardEnumPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | public class WildcardEnumPojo implements Serializable { 6 | 7 | private static final long serialVersionUID = -5155458756992548038L; 8 | 9 | private Enum wildcardEnumField; 10 | 11 | public Enum getWildcardEnumField() { 12 | return wildcardEnumField; 13 | } 14 | 15 | public void setWildcardEnumField(Enum wildcardEnumField) { 16 | this.wildcardEnumField = wildcardEnumField; 17 | } 18 | 19 | @Override 20 | public String toString() { 21 | return "WildcardEnumPojo{" + 22 | "wildcardEnumField=" + wildcardEnumField + 23 | '}'; 24 | } 25 | } -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/XMLDatatypePojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto; 5 | 6 | import javax.xml.datatype.Duration; 7 | import javax.xml.datatype.XMLGregorianCalendar; 8 | 9 | /** 10 | * POJO to test when Podam sets a boolean. 11 | * 12 | * @author daivanov 13 | * 14 | */ 15 | public class XMLDatatypePojo { 16 | private XMLGregorianCalendar calendar; 17 | private Duration duration; 18 | 19 | public XMLDatatypePojo() { 20 | } 21 | 22 | public XMLGregorianCalendar getCalendar() { 23 | return calendar; 24 | } 25 | 26 | public void setCalendar(XMLGregorianCalendar calendar) { 27 | this.calendar = calendar; 28 | } 29 | 30 | public Duration getDuration() { 31 | return duration; 32 | } 33 | 34 | public void setDuration(Duration duration) { 35 | this.duration = duration; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/annotations/AnnotatedFieldAndSetterPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.annotations; 2 | 3 | import uk.co.jemos.podam.common.PodamStringValue; 4 | import uk.co.jemos.podam.test.utils.PodamTestConstants; 5 | 6 | /** 7 | * POJO to with annotated field and field setter 8 | * 9 | * @author daivanov 10 | * 11 | */ 12 | public class AnnotatedFieldAndSetterPojo { 13 | 14 | @PodamStringValue(strValue = PodamTestConstants.POST_CODE) 15 | private String postCode; 16 | 17 | public String getPostCode() { 18 | return postCode; 19 | } 20 | 21 | public void setPostCode(@PodamStringValue(strValue = PodamTestConstants.POST_CODE) String postCode) { 22 | this.postCode = postCode; 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/annotations/ByteValueWithErrorPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto.annotations; 5 | 6 | import java.io.Serializable; 7 | 8 | import uk.co.jemos.podam.common.PodamByteValue; 9 | 10 | /** 11 | * POJO to test error case when {@link PodamByteValue#numValue()} contains an 12 | * unformattable value. 13 | * 14 | * @author mtedone 15 | * 16 | */ 17 | public class ByteValueWithErrorPojo implements Serializable { 18 | 19 | // ------------------->> Constants 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | // ------------------->> Instance / Static variables 24 | 25 | @PodamByteValue(numValue = "afasdfafa", comment = "This should throw an exception") 26 | private byte byteAttributeWithErrorAnnotation; 27 | 28 | // ------------------->> Constructors 29 | 30 | // ------------------->> Public methods 31 | 32 | // ------------------->> Getters / Setters 33 | 34 | /** 35 | * @return the byteAttributeWithErrorAnnotation 36 | */ 37 | public byte getByteAttributeWithErrorAnnotation() { 38 | return byteAttributeWithErrorAnnotation; 39 | } 40 | 41 | /** 42 | * @param byteAttributeWithErrorAnnotation 43 | * the byteAttributeWithErrorAnnotation to set 44 | */ 45 | public void setByteAttributeWithErrorAnnotation( 46 | byte byteAttributeWithErrorAnnotation) { 47 | this.byteAttributeWithErrorAnnotation = byteAttributeWithErrorAnnotation; 48 | } 49 | 50 | // ------------------->> Private methods 51 | 52 | // ------------------->> equals() / hashcode() / toString() 53 | 54 | // ------------------->> Inner classes 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/annotations/DoubleValueWithErrorPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto.annotations; 5 | 6 | import java.io.Serializable; 7 | 8 | import uk.co.jemos.podam.common.PodamDoubleValue; 9 | 10 | /** 11 | * POJO to test that {@link PodamDoubleValue#numValue()} with non parsable 12 | * values produces an error. 13 | * 14 | * @author mtedone 15 | * 16 | */ 17 | public class DoubleValueWithErrorPojo implements Serializable { 18 | 19 | // ------------------->> Constants 20 | private static final long serialVersionUID = 1L; 21 | 22 | // ------------------->> Instance / Static variables 23 | @PodamDoubleValue(numValue = "fajhfakh") 24 | private double doubleFieldWithErrorInAnnotation; 25 | 26 | // ------------------->> Constructors 27 | 28 | // ------------------->> Public methods 29 | 30 | // ------------------->> Getters / Setters 31 | 32 | /** 33 | * @return the doubleFieldWithErrorInAnnotation 34 | */ 35 | public double getDoubleFieldWithErrorInAnnotation() { 36 | return doubleFieldWithErrorInAnnotation; 37 | } 38 | 39 | /** 40 | * @param doubleFieldWithErrorInAnnotation 41 | * the doubleFieldWithErrorInAnnotation to set 42 | */ 43 | public void setDoubleFieldWithErrorInAnnotation( 44 | double doubleFieldWithErrorInAnnotation) { 45 | this.doubleFieldWithErrorInAnnotation = doubleFieldWithErrorInAnnotation; 46 | } 47 | 48 | // ------------------->> Private methods 49 | 50 | // ------------------->> equals() / hashcode() / toString() 51 | 52 | // ------------------->> Inner classes 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/annotations/EmailStrategyPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto.annotations; 5 | 6 | import jakarta.validation.constraints.Email; 7 | import jakarta.validation.constraints.NotEmpty; 8 | 9 | /** 10 | * POJO to test the attribute-level data strategy, through the use of 11 | * {@link uk.co.jemos.podam.common.AttributeStrategy} implementations. 12 | * 13 | * @author daivanov 14 | * 15 | */ 16 | public class EmailStrategyPojo { 17 | 18 | @Email 19 | @NotEmpty 20 | private String email; 21 | 22 | /** 23 | * @return the email 24 | */ 25 | public String getEmail() { 26 | return email; 27 | } 28 | 29 | /** 30 | * @param email 31 | * the email to set 32 | */ 33 | public void setEmail(String email) { 34 | this.email = email; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/annotations/FloatValueWithErrorPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto.annotations; 5 | 6 | import java.io.Serializable; 7 | 8 | import uk.co.jemos.podam.common.PodamFloatValue; 9 | 10 | /** 11 | * POJO to test that a {@link PodamFloatValue#numValue()} is non parseable. 12 | * 13 | * @author mtedone 14 | * 15 | */ 16 | public class FloatValueWithErrorPojo implements Serializable { 17 | 18 | // ------------------->> Constants 19 | private static final long serialVersionUID = 1L; 20 | 21 | // ------------------->> Instance / Static variables 22 | 23 | @PodamFloatValue(numValue = "fafhakljhf") 24 | private float floatFieldWithErrorInAnnotation; 25 | 26 | // ------------------->> Constructors 27 | 28 | // ------------------->> Public methods 29 | 30 | // ------------------->> Getters / Setters 31 | 32 | /** 33 | * @return the floatFieldWithErrorInAnnotation 34 | */ 35 | public float getFloatFieldWithErrorInAnnotation() { 36 | return floatFieldWithErrorInAnnotation; 37 | } 38 | 39 | /** 40 | * @param floatFieldWithErrorInAnnotation 41 | * the floatFieldWithErrorInAnnotation to set 42 | */ 43 | public void setFloatFieldWithErrorInAnnotation( 44 | float floatFieldWithErrorInAnnotation) { 45 | this.floatFieldWithErrorInAnnotation = floatFieldWithErrorInAnnotation; 46 | } 47 | 48 | // ------------------->> Private methods 49 | 50 | // ------------------->> equals() / hashcode() / toString() 51 | 52 | // ------------------->> Inner classes 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/annotations/IntegerValueWithErrorPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto.annotations; 5 | 6 | import java.io.Serializable; 7 | 8 | import uk.co.jemos.podam.common.PodamIntValue; 9 | 10 | /** 11 | * POJO to test that {@link PodamIntValue#numValue()} with a non parseable value 12 | * triggers an error. 13 | * 14 | * @author mtedone 15 | * 16 | */ 17 | public class IntegerValueWithErrorPojo implements Serializable { 18 | 19 | // ------------------->> Constants 20 | private static final long serialVersionUID = 1L; 21 | 22 | // ------------------->> Instance / Static variables 23 | 24 | @PodamIntValue(numValue = "hfajkfhalfh") 25 | private int intFieldWithErrorInAnnotation; 26 | 27 | // ------------------->> Constructors 28 | 29 | // ------------------->> Public methods 30 | 31 | // ------------------->> Getters / Setters 32 | 33 | /** 34 | * @return the intFieldWithErrorInAnnotation 35 | */ 36 | public int getIntFieldWithErrorInAnnotation() { 37 | return intFieldWithErrorInAnnotation; 38 | } 39 | 40 | /** 41 | * @param intFieldWithErrorInAnnotation 42 | * the intFieldWithErrorInAnnotation to set 43 | */ 44 | public void setIntFieldWithErrorInAnnotation( 45 | int intFieldWithErrorInAnnotation) { 46 | this.intFieldWithErrorInAnnotation = intFieldWithErrorInAnnotation; 47 | } 48 | 49 | // ------------------->> Private methods 50 | 51 | // ------------------->> equals() / hashcode() / toString() 52 | 53 | // ------------------->> Inner classes 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/annotations/LongValueWithErrorPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto.annotations; 5 | 6 | import java.io.Serializable; 7 | 8 | import uk.co.jemos.podam.common.PodamLongValue; 9 | 10 | /** 11 | * POJO to test that {@link PodamLongValue#numValue()} which contains a non 12 | * parseable value triggers exception. 13 | * 14 | * @author mtedone 15 | * 16 | */ 17 | public class LongValueWithErrorPojo implements Serializable { 18 | 19 | // ------------------->> Constants 20 | 21 | private static final long serialVersionUID = 1L; 22 | // ------------------->> Instance / Static variables 23 | 24 | @PodamLongValue(numValue = "afhafhakflh") 25 | private long longFieldWithErrorInAnnotation; 26 | 27 | // ------------------->> Constructors 28 | 29 | // ------------------->> Public methods 30 | 31 | // ------------------->> Getters / Setters 32 | 33 | /** 34 | * @return the longFieldWithErrorInAnnotation 35 | */ 36 | public long getLongFieldWithErrorInAnnotation() { 37 | return longFieldWithErrorInAnnotation; 38 | } 39 | 40 | /** 41 | * @param longFieldWithErrorInAnnotation 42 | * the longFieldWithErrorInAnnotation to set 43 | */ 44 | public void setLongFieldWithErrorInAnnotation( 45 | long longFieldWithErrorInAnnotation) { 46 | this.longFieldWithErrorInAnnotation = longFieldWithErrorInAnnotation; 47 | } 48 | 49 | // ------------------->> Private methods 50 | 51 | // ------------------->> equals() / hashcode() / toString() 52 | 53 | // ------------------->> Inner classes 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/annotations/PojoClassic.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.annotations; 2 | 3 | /** 4 | * Created by tedonema on 07/06/2015. 5 | */ 6 | public class PojoClassic { 7 | 8 | private String att; 9 | 10 | public String getAtt() { 11 | return att; 12 | } 13 | 14 | public void setAtt(String att) { 15 | this.att = att; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/annotations/PojoSpecific.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.annotations; 2 | 3 | /** 4 | * Created by tedonema on 07/06/2015. 5 | */ 6 | public class PojoSpecific { 7 | 8 | private String att; 9 | 10 | public String getAtt() { 11 | return att; 12 | } 13 | 14 | public void setAtt(String att) { 15 | this.att = att; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/annotations/ShortValueWithErrorPojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto.annotations; 5 | 6 | import java.io.Serializable; 7 | 8 | import uk.co.jemos.podam.common.PodamShortValue; 9 | 10 | /** 11 | * POJO to test that {@link PodamShortValue#numValue()} with non parseable value 12 | * throws exception. 13 | * 14 | * @author mtedone 15 | * 16 | */ 17 | public class ShortValueWithErrorPojo implements Serializable { 18 | 19 | // ------------------->> Constants 20 | private static final long serialVersionUID = 1L; 21 | 22 | // ------------------->> Instance / Static variables 23 | 24 | @PodamShortValue(numValue = "fajkfhaf") 25 | private short shortFieldWithErrorInAnnotation; 26 | 27 | // ------------------->> Constructors 28 | 29 | // ------------------->> Public methods 30 | 31 | // ------------------->> Getters / Setters 32 | 33 | /** 34 | * @return the shortFieldWithErrorInAnnotation 35 | */ 36 | public short getShortFieldWithErrorInAnnotation() { 37 | return shortFieldWithErrorInAnnotation; 38 | } 39 | 40 | /** 41 | * @param shortFieldWithErrorInAnnotation 42 | * the shortFieldWithErrorInAnnotation to set 43 | */ 44 | public void setShortFieldWithErrorInAnnotation( 45 | short shortFieldWithErrorInAnnotation) { 46 | this.shortFieldWithErrorInAnnotation = shortFieldWithErrorInAnnotation; 47 | } 48 | 49 | // ------------------->> Private methods 50 | 51 | // ------------------->> equals() / hashcode() / toString() 52 | 53 | // ------------------->> Inner classes 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/annotations/StringWithWrongStrategyTypePojo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto.annotations; 5 | 6 | import java.io.Serializable; 7 | 8 | import uk.co.jemos.podam.common.PodamStrategyValue; 9 | import uk.co.jemos.podam.test.strategies.WrongTypeStrategy; 10 | 11 | /** 12 | * POJO to test that when a wrong type is given to 13 | * {@link PodamStrategyValue} an exception will be thrown. 14 | * 15 | * @author mtedone 16 | * 17 | */ 18 | public class StringWithWrongStrategyTypePojo implements Serializable { 19 | 20 | // ------------------->> Constants 21 | private static final long serialVersionUID = 1L; 22 | // ------------------->> Instance / Static variables 23 | 24 | @PodamStrategyValue(value = WrongTypeStrategy.class) 25 | private String postCodeDestinedToFail; 26 | 27 | // ------------------->> Constructors 28 | 29 | // ------------------->> Public methods 30 | 31 | // ------------------->> Getters / Setters 32 | 33 | /** 34 | * @return the postCodeDestinedToFail 35 | */ 36 | public String getPostCodeDestinedToFail() { 37 | return postCodeDestinedToFail; 38 | } 39 | 40 | /** 41 | * @param postCodeDestinedToFail 42 | * the postCodeDestinedToFail to set 43 | */ 44 | public void setPostCodeDestinedToFail(String postCodeDestinedToFail) { 45 | this.postCodeDestinedToFail = postCodeDestinedToFail; 46 | } 47 | 48 | // ------------------->> Private methods 49 | 50 | // ------------------->> equals() / hashcode() / toString() 51 | 52 | // ------------------->> Inner classes 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/issue123/GenericCollectionsConstructorPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.issue123; 2 | 3 | import java.util.List; 4 | import java.util.Vector; 5 | 6 | /** 7 | * Created by tedonema on 03/10/2015. 8 | */ 9 | public class GenericCollectionsConstructorPojo { 10 | 11 | private final List list1; 12 | private final List list2; 13 | private final List list3; 14 | 15 | /** 16 | * Full constructor 17 | * @param list1 First List 18 | * @param list2 Second List 19 | * @param list3 Third List 20 | */ 21 | public GenericCollectionsConstructorPojo(Vector list1, Vector list2, Vector list3) { 22 | this.list1 = new Vector(list1); 23 | this.list2 = new Vector(list2); 24 | this.list3 = new Vector(list3); 25 | } 26 | 27 | public Vector getList1() { 28 | return new Vector(list1); 29 | } 30 | 31 | public Vector getList2() { 32 | return new Vector(list2); 33 | } 34 | 35 | public Vector getList3() { 36 | return new Vector(list3); 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | final StringBuilder sb = new StringBuilder("GenericCollectionsConstructorPojo{"); 42 | sb.append("list1=").append(list1); 43 | sb.append(", list2=").append(list2); 44 | sb.append(", list3=").append(list3); 45 | sb.append('}'); 46 | return sb.toString(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm3/Pdm3Pojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm3; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Pojo to test PDM-3 7 | * 8 | * @author Marco Tedone 9 | * 10 | */ 11 | public class Pdm3Pojo { 12 | 13 | private List something; 14 | 15 | private List descendants; 16 | 17 | private List ancestors; 18 | 19 | public List getSomething() { 20 | return something; 21 | } 22 | 23 | public void setSomething(List something) { 24 | this.something = something; 25 | } 26 | 27 | public List getDescendants() { 28 | return descendants; 29 | } 30 | 31 | public void setDescendants(List descendants) { 32 | this.descendants = descendants; 33 | } 34 | 35 | public List getAncestors() { 36 | return ancestors; 37 | } 38 | 39 | public void setAncestors(List ancestors) { 40 | this.ancestors = ancestors; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return String.format( 46 | "{something: '%s'} {descendants: '%s'} {ancestors: '%s'}", 47 | something, descendants, ancestors); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm3/Pdm3PojoConstructor.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm3; 2 | 3 | /** 4 | * Pojo to test PDM-3 5 | * 6 | * @author daivanov 7 | * 8 | */ 9 | public class Pdm3PojoConstructor { 10 | 11 | private T name; 12 | 13 | public Pdm3PojoConstructor(T name) { 14 | this.name = name; 15 | } 16 | 17 | public T getName() { 18 | return name; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return String.format("{name: '%s'}", name); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm3/Pdm3PojoGenericsConstructor.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm3; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Pojo to test PDM-3 7 | * 8 | * @author daivanov 9 | * 10 | */ 11 | public class Pdm3PojoGenericsConstructor { 12 | 13 | public Pdm3PojoGenericsConstructor( 14 | List something, 15 | List descendants, 16 | List ancestors) { 17 | this.something = something; 18 | this.descendants = descendants; 19 | this.ancestors = ancestors; 20 | } 21 | 22 | private List something; 23 | 24 | private List descendants; 25 | 26 | private List ancestors; 27 | 28 | public List getSomething() { 29 | return something; 30 | } 31 | 32 | public List getDescendants() { 33 | return descendants; 34 | } 35 | 36 | public List getAncestors() { 37 | return ancestors; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return String.format( 43 | "{something: '%s'} {descendants: '%s'} {ancestors: '%s'}", 44 | something, descendants, ancestors); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm3/WildcardPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm3; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import javax.xml.bind.JAXBElement; 7 | 8 | /** 9 | * Pojo to test PDM-3 10 | * 11 | * @author daivanov 12 | * 13 | */ 14 | public class WildcardPojo { 15 | 16 | private List> something = new ArrayList>(); 17 | 18 | private List> descendants = new ArrayList>(); 19 | 20 | private List> ancestors = new ArrayList>(); 21 | 22 | public List> getSomething() { 23 | return something; 24 | } 25 | 26 | public List> getAncestors() { 27 | return ancestors; 28 | } 29 | 30 | public List> getDescendants() { 31 | return descendants; 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return String.format( 37 | "{something: '%s'} {descendants: '%s'} {ancestors: '%s'}", 38 | something, descendants, ancestors); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm3/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Pojos for PDM-3 3 | * @author Marco Tedone 4 | * 5 | */ 6 | package uk.co.jemos.podam.test.dto.pdm3; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm4/Pdm4PojoWithSetters.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm4; 2 | 3 | import java.io.InputStream; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import uk.co.jemos.podam.common.PodamConstructor; 8 | 9 | /** 10 | * Pojo to test to test multiple constructors and setters 11 | * 12 | * @author divanov 13 | * 14 | */ 15 | public class Pdm4PojoWithSetters { 16 | 17 | public static List invocationOrder = new ArrayList(); 18 | 19 | private String value; 20 | 21 | public Pdm4PojoWithSetters(InputStream inputStream) { 22 | invocationOrder.add("InputStream"); 23 | throw new IllegalStateException("Cannot use me also"); 24 | } 25 | 26 | public Pdm4PojoWithSetters(int num, int num2) { 27 | invocationOrder.add("int,int"); 28 | throw new IllegalStateException("Cannot use me neither"); 29 | } 30 | 31 | public Pdm4PojoWithSetters(InputStream inputStream, int num) { 32 | invocationOrder.add("abstract,int"); 33 | throw new IllegalStateException("Cannot use me also"); 34 | } 35 | 36 | @PodamConstructor(comment = "choose this one") 37 | public Pdm4PojoWithSetters(String value) { 38 | invocationOrder.add("PodamConstructor"); 39 | throw new IllegalStateException("Cannot use me"); 40 | } 41 | 42 | public Pdm4PojoWithSetters() { 43 | invocationOrder.add("no-op"); 44 | throw new IllegalStateException("Cannot use me too"); 45 | } 46 | 47 | public void setValue(String value) { 48 | this.value = value; 49 | } 50 | 51 | public String getValue() { 52 | return value; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return String.format("{value: '%s'}", value); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm4/PojoWithMultipleNonPublicConstructors.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm4; 2 | 3 | import java.io.InputStream; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import uk.co.jemos.podam.common.PodamConstructor; 8 | 9 | /** 10 | * Pojo to test to test multiple non-public constructors and setters 11 | * 12 | * @author divanov 13 | * 14 | */ 15 | public class PojoWithMultipleNonPublicConstructors { 16 | 17 | public static List invocationOrder = new ArrayList(); 18 | 19 | private String value; 20 | 21 | protected PojoWithMultipleNonPublicConstructors(InputStream inputStream) { 22 | invocationOrder.add("InputStream"); 23 | throw new IllegalStateException("Cannot use me also"); 24 | } 25 | 26 | protected PojoWithMultipleNonPublicConstructors(int num, int num2) { 27 | invocationOrder.add("int,int"); 28 | throw new IllegalStateException("Cannot use me neither"); 29 | } 30 | 31 | protected PojoWithMultipleNonPublicConstructors(InputStream inputStream, int num) { 32 | invocationOrder.add("abstract,int"); 33 | throw new IllegalStateException("Cannot use me also"); 34 | } 35 | 36 | @PodamConstructor(comment = "choose this one") 37 | private PojoWithMultipleNonPublicConstructors(String value) { 38 | invocationOrder.add("PodamConstructor"); 39 | throw new IllegalStateException("Cannot use me"); 40 | } 41 | 42 | protected PojoWithMultipleNonPublicConstructors() { 43 | invocationOrder.add("no-op"); 44 | throw new IllegalStateException("Cannot use me too"); 45 | } 46 | 47 | public void setValue(String value) { 48 | this.value = value; 49 | } 50 | 51 | public String getValue() { 52 | return value; 53 | } 54 | 55 | @Override 56 | public String toString() { 57 | return String.format("{value: '%s'}", value); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm42/A.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm42; 2 | 3 | public class A { 4 | 5 | private B b; 6 | 7 | public B getB() { 8 | return b; 9 | } 10 | 11 | public void setB(B b) { 12 | this.b = b; 13 | 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm42/B.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm42; 2 | 3 | public class B extends C { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm42/C.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm42; 2 | 3 | import java.util.Map; 4 | 5 | public abstract class C { 6 | 7 | private Map customValue; 8 | 9 | public Map getCustomValue() { 10 | return customValue; 11 | } 12 | 13 | public void setCustomValue(Map customValue) { 14 | this.customValue = customValue; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm42/FieldInfo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm42; 2 | 3 | public class FieldInfo { 4 | 5 | private String fieldName; 6 | 7 | private String namespace; 8 | 9 | private String namespacePrefix; 10 | 11 | public FieldInfo() { 12 | } 13 | 14 | public FieldInfo(String fieldName, String namespace) { 15 | this.fieldName = fieldName; 16 | this.namespace = namespace; 17 | } 18 | 19 | public String getFieldName() { 20 | return fieldName; 21 | } 22 | 23 | public void setFieldName(String fieldName) { 24 | this.fieldName = fieldName; 25 | } 26 | 27 | public String getNamespace() { 28 | return namespace; 29 | } 30 | 31 | public void setNamespace(String namespace) { 32 | this.namespace = namespace; 33 | } 34 | 35 | public String getNamespacePrefix() { 36 | return namespacePrefix; 37 | } 38 | 39 | public void setNamespacePrefix(String namespacePrefix) { 40 | this.namespacePrefix = namespacePrefix; 41 | } 42 | 43 | /** 44 | * Constructs a String with all attributes 45 | * in name = value format. 46 | * 47 | * @return a String representation 48 | * of this object. 49 | */ 50 | public String toString() 51 | { 52 | final String TAB = " "; 53 | 54 | StringBuilder retValue = new StringBuilder(); 55 | 56 | retValue.append("FieldInfo ( ") 57 | .append(super.toString()).append(TAB) 58 | .append("fieldName = ").append(this.fieldName).append(TAB) 59 | .append("namespace = ").append(this.namespace).append(TAB) 60 | .append("namespacePrefix = ").append(this.namespacePrefix).append(TAB) 61 | .append(" )"); 62 | 63 | return retValue.toString(); 64 | } 65 | 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm43/BusinessObject.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto.pdm43; 5 | 6 | /** 7 | * @author mtedone 8 | * 9 | */ 10 | public class BusinessObject { 11 | 12 | //------------------->> Constants 13 | 14 | //------------------->> Instance / Static variables 15 | 16 | //------------------->> Constructors 17 | 18 | //------------------->> Public methods 19 | 20 | // ------------------->> Getters / Setters 21 | 22 | //------------------->> Private methods 23 | 24 | //------------------->> equals() / hashcode() / toString() 25 | 26 | //------------------->> Inner classes 27 | 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm43/BusinessObjectWithErrors.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto.pdm43; 5 | 6 | import java.io.Serializable; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * @author mtedone 12 | * 13 | */ 14 | public abstract class BusinessObjectWithErrors extends 15 | BusinessObject { 16 | 17 | private List errorCodeList = new ArrayList(); 18 | 19 | /** 20 | * @return the errorCodes 21 | */ 22 | public List getErrorCodeList() { 23 | return errorCodeList; 24 | } 25 | 26 | /** 27 | * Set the error strings. 28 | * @param allErrors The list of all errors 29 | */ 30 | public void setErrorCodeList(List allErrors) { 31 | this.errorCodeList = allErrors; 32 | } 33 | 34 | // body 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm43/ConcreteBusinessObject.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.dto.pdm43; 5 | 6 | /** 7 | * @author mtedone 8 | * 9 | */ 10 | public class ConcreteBusinessObject extends BusinessObjectWithErrors 11 | implements Cloneable { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm45/GenericArrayPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm45; 2 | 3 | /** 4 | * Pojo with array of generic attributes. 5 | * 6 | * @author daivanov 7 | * 8 | */ 9 | public class GenericArrayPojo { 10 | 11 | private GenericPojo[] genericPojos; 12 | 13 | /** 14 | * Generic getter 15 | * @return the genericPojo 16 | */ 17 | public GenericPojo[] getGenericPojos() { 18 | return genericPojos; 19 | } 20 | 21 | /** 22 | * Generic setter 23 | * @param genericPojos the genericPojo to set 24 | */ 25 | public void setGenericPojos(GenericPojo[] genericPojos) { 26 | this.genericPojos = genericPojos; 27 | } 28 | 29 | /** 30 | * @see java.lang.Object#toString() 31 | */ 32 | @Override 33 | public String toString() { 34 | return "GenericAttributePojo [genericPojo=" + genericPojos + "]"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm45/GenericAttributePojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm45; 2 | 3 | /** 4 | * Pojo with generic attribute. 5 | * 6 | * @author marciocarmona 7 | * 8 | */ 9 | public class GenericAttributePojo { 10 | 11 | private GenericPojo genericPojo; 12 | 13 | /** 14 | * @return the genericPojo 15 | */ 16 | public GenericPojo getGenericPojo() { 17 | return genericPojo; 18 | } 19 | 20 | /** 21 | * @param genericPojo the genericPojo to set 22 | */ 23 | public void setGenericPojo(GenericPojo genericPojo) { 24 | this.genericPojo = genericPojo; 25 | } 26 | 27 | /* 28 | * (non-Javadoc) 29 | * 30 | * @see java.lang.Object#toString() 31 | */ 32 | @Override 33 | public String toString() { 34 | return "GenericAttributePojo [genericPojo=" + genericPojo + "]"; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm45/GenericListPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm45; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Pojo with list of generic attributes. 7 | * 8 | * @author daivanov 9 | * 10 | */ 11 | public class GenericListPojo { 12 | 13 | private List> genericPojos; 14 | 15 | /** 16 | * List getter 17 | * @return the genericPojo 18 | */ 19 | public List> getGenericPojos() { 20 | return genericPojos; 21 | } 22 | 23 | /** 24 | * List setter 25 | * @param genericPojos the genericPojo to set 26 | */ 27 | public void setGenericPojos(List> genericPojos) { 28 | this.genericPojos = genericPojos; 29 | } 30 | 31 | /** 32 | * @see java.lang.Object#toString() 33 | */ 34 | @Override 35 | public String toString() { 36 | return "GenericAttributePojo [genericPojo=" + genericPojos + "]"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm45/GenericMapPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm45; 2 | 3 | import java.util.List; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | /** 8 | * Pojo with map of generic attributes. 9 | * 10 | * @author daivanov 11 | * 12 | */ 13 | public class GenericMapPojo { 14 | 15 | private Map> genericPojos; 16 | 17 | private Map genericRawLists = new HashMap(); 18 | 19 | /** 20 | * Map getter 21 | * @return the genericPojo 22 | */ 23 | public Map> getGenericPojos() { 24 | return genericPojos; 25 | } 26 | 27 | /** 28 | * Map setter 29 | * @param genericPojos the genericPojo to set 30 | */ 31 | public void setGenericPojos(Map> genericPojos) { 32 | this.genericPojos = genericPojos; 33 | } 34 | 35 | /** 36 | * Map getter 37 | * @return the genericRawLists 38 | */ 39 | public Map getGenericRawLists() { 40 | return genericRawLists; 41 | } 42 | 43 | /** 44 | * @see java.lang.Object#toString() 45 | */ 46 | @Override 47 | public String toString() { 48 | return "GenericAttributePojo [genericPojo=" + genericPojos + "]"; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm45/MultiDimensionalConstructorPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm45; 2 | 3 | import java.util.Calendar; 4 | import java.util.Collection; 5 | import java.util.Date; 6 | import java.util.List; 7 | import java.util.Map; 8 | import java.util.Queue; 9 | import java.util.Set; 10 | 11 | /** 12 | * This is POJO to test PODAM's ability to create an instance 13 | * using a constructor with multidimensional collections, arrays 14 | * and maps parameters 15 | * 16 | * @author marciocarmona 17 | * 18 | */ 19 | public class MultiDimensionalConstructorPojo extends MultiDimensionalTestPojo { 20 | 21 | public MultiDimensionalConstructorPojo( 22 | List>> threeDimensionalList, 23 | Set>> threeDimensionalSet, 24 | Collection>> threeDimensionalCollection, 25 | Map>> threeDimensionalMap, 26 | Queue>> threeDimensionalQueue, 27 | String[][][] threeDimensionalArray) { 28 | setThreeDimensionalArray(threeDimensionalArray); 29 | setThreeDimensionalCollection(threeDimensionalCollection); 30 | setThreeDimensionalList(threeDimensionalList); 31 | setThreeDimensionalMap(threeDimensionalMap); 32 | setThreeDimensionalQueue(threeDimensionalQueue); 33 | setThreeDimensionalSet(threeDimensionalSet); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm5/InvisibleConstructorAndNoSettersPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm5; 2 | 3 | /** 4 | * Pojo to test invisible constructor 5 | * 6 | * @author divanov 7 | * 8 | */ 9 | public class InvisibleConstructorAndNoSettersPojo { 10 | 11 | private String value; 12 | 13 | InvisibleConstructorAndNoSettersPojo(String value) { 14 | this.value = value; 15 | } 16 | 17 | public String getValue() { 18 | return value; 19 | } 20 | 21 | @Override 22 | public String toString() { 23 | return String.format("{value: '%s'}", value); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm6/Child.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm6; 2 | 3 | /** 4 | * Pojo to test recursive dependencies 5 | * 6 | * @author ludochane 7 | * 8 | */ 9 | public class Child { 10 | 11 | private Parent parent; 12 | private String name; 13 | 14 | public Parent getParent() { 15 | return parent; 16 | } 17 | 18 | public void setParent(Parent parent) { 19 | this.parent = parent; 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | } -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm6/Parent.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm6; 2 | 3 | /** 4 | * Pojo to test recursive dependencies 5 | * 6 | * @author ludochane 7 | * 8 | */ 9 | public class Parent { 10 | 11 | private Child child; 12 | private String name; 13 | 14 | public Child getChild() { 15 | return child; 16 | } 17 | 18 | public void setChild(Child child) { 19 | this.child = child; 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | } -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm6/RecursiveList.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm6; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Pojo to test recursive dependencies 7 | * 8 | * @author daivanov 9 | * 10 | */ 11 | public class RecursiveList { 12 | 13 | private List list; 14 | 15 | public List getList() { 16 | return this.list; 17 | } 18 | 19 | public void setList(List list) { 20 | this.list = list; 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/dto/pdm6/RecursiveMap.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.dto.pdm6; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Pojo to test recursive dependencies 7 | * 8 | * @author daivanov 9 | * 10 | */ 11 | public class RecursiveMap { 12 | 13 | private Map map; 14 | 15 | public Map getMap() { 16 | return this.map; 17 | } 18 | 19 | public void setMap(Map map) { 20 | this.map = map; 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/enums/ExternalRatePodamEnum.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.enums; 5 | 6 | /** 7 | * An enum to use in tests 8 | * 9 | * @author mtedone 10 | * 11 | */ 12 | public enum ExternalRatePodamEnum { 13 | 14 | EXTERNAL_COOL, EXTERNAL_ROCKS, EXTERNAL_SUPERCOOL 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/strategies/AnnotationStrategy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.strategies; 5 | 6 | import java.lang.annotation.Annotation; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import uk.co.jemos.podam.api.PodamUtils; 11 | import uk.co.jemos.podam.common.AttributeStrategy; 12 | 13 | /** 14 | * @author daivanov 15 | * Class for handling all annotations at once 16 | */ 17 | public class AnnotationStrategy implements AttributeStrategy { 18 | 19 | private final List> recordedCalls = new ArrayList>(); 20 | 21 | @Override 22 | public Object getValue(Class attrType, List annotations) { 23 | recordedCalls.add(annotations); 24 | return null; 25 | } 26 | 27 | public List> getRecordedCalls() { 28 | return recordedCalls; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/strategies/ByteArrayStrategy.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.strategies; 2 | 3 | import java.lang.annotation.Annotation; 4 | import java.util.concurrent.ThreadLocalRandom; 5 | import java.util.List; 6 | 7 | import uk.co.jemos.podam.common.AttributeStrategy; 8 | 9 | public class ByteArrayStrategy implements AttributeStrategy { 10 | 11 | public static int LENGTH = 20; 12 | 13 | @Override 14 | public byte[] getValue(Class attrType, List annotations) { 15 | byte[] b = new byte[LENGTH]; 16 | ThreadLocalRandom.current().nextBytes(b); 17 | return b; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/strategies/CustomRandomDataProviderStrategy.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.strategies; 2 | 3 | import uk.co.jemos.podam.api.AbstractRandomDataProviderStrategy; 4 | 5 | /** 6 | * Random data provider strategy with variable map and collection length 7 | * 8 | * @author daivanov 9 | * 10 | */ 11 | public class CustomRandomDataProviderStrategy extends AbstractRandomDataProviderStrategy { 12 | 13 | /** 14 | * {@inheritDoc} 15 | */ 16 | @Override 17 | public int getMaxDepth(Class type) { 18 | return 1; 19 | } 20 | 21 | /** 22 | * {@inheritDoc} 23 | */ 24 | @Override 25 | public int getNumberOfCollectionElements(Class type) { 26 | 27 | int number; 28 | if (String[].class.isAssignableFrom(type)) { 29 | number = 2; 30 | } else if (Boolean.class.isAssignableFrom(type)) { 31 | number = 3; 32 | } else if (Long.class.isAssignableFrom(type)) { 33 | number = 4; 34 | } else if (Integer.class.isAssignableFrom(type)) { 35 | number = 5; 36 | } else { 37 | number = super.getNumberOfCollectionElements(type); 38 | } 39 | return number; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/strategies/MyBirthdayStrategy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.strategies; 5 | 6 | import java.lang.annotation.Annotation; 7 | import java.util.Calendar; 8 | import java.util.List; 9 | 10 | import uk.co.jemos.podam.common.AttributeStrategy; 11 | import uk.co.jemos.podam.test.utils.PodamTestUtils; 12 | 13 | /** 14 | * @author mtedone 15 | * 16 | */ 17 | public class MyBirthdayStrategy implements AttributeStrategy { 18 | 19 | /** 20 | * It returns a {@link Calendar} object set with the exact date of my 21 | * birthday. 22 | * 23 | * {@inheritDoc} 24 | */ 25 | @Override 26 | public Calendar getValue(Class attrType, List annotations) { 27 | 28 | Calendar myBirthday = PodamTestUtils.getMyBirthday(); 29 | 30 | return myBirthday; 31 | } 32 | 33 | // ------------------->> Constants 34 | 35 | // ------------------->> Instance / Static variables 36 | 37 | // ------------------->> Constructors 38 | 39 | // ------------------->> Public methods 40 | 41 | // ------------------->> Getters / Setters 42 | 43 | // ------------------->> Private methods 44 | 45 | // ------------------->> equals() / hashcode() / toString() 46 | 47 | // ------------------->> Inner classes 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/strategies/PatternStrategy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.strategies; 5 | 6 | import java.lang.annotation.Annotation; 7 | import java.util.List; 8 | 9 | import jakarta.validation.constraints.Pattern; 10 | 11 | import uk.co.jemos.podam.api.PodamUtils; 12 | import uk.co.jemos.podam.common.AttributeStrategy; 13 | import uk.co.jemos.podam.common.BeanValidationStrategy; 14 | 15 | /** 16 | * @author daivanov 17 | * 18 | */ 19 | public class PatternStrategy implements AttributeStrategy { 20 | 21 | /** 22 | * Produces valid patterns. 23 | * 24 | * {@inheritDoc} 25 | */ 26 | @Override 27 | public String getValue(Class attrType, List attrAnnotations) { 28 | 29 | Pattern patternAnnotation 30 | = BeanValidationStrategy.findTypeFromList(attrAnnotations, Pattern.class) ; 31 | StringBuffer sb = new StringBuffer(); 32 | 33 | if ("^[0-9]{1,45}$".equals(patternAnnotation.regexp())) { 34 | 35 | sb.append(Integer.toString(PodamUtils.getIntegerInRange(0, 1000000))); 36 | } else if ("^[a-zA-Z0-9_]*$".equals(patternAnnotation.regexp())) { 37 | 38 | for (int i = 0; i < 2; i++) { 39 | sb.append(PodamUtils.getNiceCharacter()); 40 | } 41 | sb.append(Integer.toString(PodamUtils.getIntegerInRange(0, 10))); 42 | } 43 | return sb.toString(); 44 | } 45 | 46 | // ------------------->> Constants 47 | 48 | // ------------------->> Instance / Static variables 49 | 50 | // ------------------->> Constructors 51 | 52 | // ------------------->> Public methods 53 | 54 | // ------------------->> Getters / Setters 55 | 56 | // ------------------->> Private methods 57 | 58 | // ------------------->> equals() / hashcode() / toString() 59 | 60 | // ------------------->> Inner classes 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/strategies/PostCodeStrategy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.strategies; 5 | 6 | import java.lang.annotation.Annotation; 7 | import java.util.List; 8 | 9 | import uk.co.jemos.podam.common.AttributeStrategy; 10 | import uk.co.jemos.podam.exceptions.PodamMockeryException; 11 | import uk.co.jemos.podam.test.utils.PodamTestConstants; 12 | 13 | /** 14 | * A test strategy to manufacture UK-like post codes. 15 | * 16 | * @author mtedone 17 | * 18 | */ 19 | public class PostCodeStrategy implements AttributeStrategy { 20 | 21 | // ------------------->> Constants 22 | 23 | // ------------------->> Instance / Static variables 24 | 25 | /** 26 | * It returns an English post code. 27 | *

28 | * This is just an example. More elaborated code could the implemented by 29 | * this method. This is just to proof the point. 30 | *

31 | * 32 | * {@inheritDoc} 33 | */ 34 | @Override 35 | public String getValue(Class attrType, List annotations) throws PodamMockeryException { 36 | return PodamTestConstants.POST_CODE; 37 | } 38 | 39 | // ------------------->> Constructors 40 | 41 | // ------------------->> Public methods 42 | 43 | // ------------------->> Getters / Setters 44 | 45 | // ------------------->> Private methods 46 | 47 | // ------------------->> equals() / hashcode() / toString() 48 | 49 | // ------------------->> Inner classes 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/strategies/WrongTypeStrategy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.strategies; 5 | 6 | import java.lang.annotation.Annotation; 7 | import java.util.List; 8 | 9 | import uk.co.jemos.podam.common.AttributeStrategy; 10 | import uk.co.jemos.podam.common.PodamStrategyValue; 11 | import uk.co.jemos.podam.exceptions.PodamMockeryException; 12 | import uk.co.jemos.podam.test.dto.OneDimensionalTestPojo; 13 | 14 | /** 15 | * A dummy strategy to proof the point that when given as type for 16 | * {@link PodamStrategyValue} it will trigger an exception. 17 | * 18 | * @author mtedone 19 | * 20 | */ 21 | public class WrongTypeStrategy 22 | implements 23 | AttributeStrategy { 24 | 25 | /** 26 | * {@inheritDoc} 27 | */ 28 | @Override 29 | public OneDimensionalTestPojo getValue(Class attrType, List annotations) throws PodamMockeryException { 30 | return new OneDimensionalTestPojo(); 31 | } 32 | 33 | // ------------------->> Constants 34 | 35 | // ------------------->> Instance / Static variables 36 | 37 | // ------------------->> Constructors 38 | 39 | // ------------------->> Public methods 40 | 41 | // ------------------->> Getters / Setters 42 | 43 | // ------------------->> Private methods 44 | 45 | // ------------------->> equals() / hashcode() / toString() 46 | 47 | // ------------------->> Inner classes 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/AbstractPodamSteps.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit; 2 | 3 | import net.thucydides.core.annotations.Steps; 4 | import uk.co.jemos.podam.test.unit.steps.*; 5 | 6 | /** 7 | * Created by tedonema on 31/05/2015. 8 | */ 9 | public abstract class AbstractPodamSteps { 10 | 11 | @Steps 12 | protected PodamFactorySteps podamFactorySteps; 13 | 14 | @Steps 15 | protected PodamInvocationSteps podamInvocationSteps; 16 | 17 | @Steps 18 | protected PodamValidationSteps podamValidationSteps; 19 | 20 | @Steps 21 | protected OneDimentionalPojoValidationSteps oneDimentionalPojoValidationSteps; 22 | 23 | @Steps 24 | protected PodamStrategySteps podamStrategySteps; 25 | 26 | @Steps 27 | protected RecursivePojoValidationSteps recursivePojoValidationSteps; 28 | 29 | @Steps 30 | protected ConstructorSelfReferenceValidationSteps constructorSelfReferenceValidationSteps; 31 | 32 | @Steps 33 | protected ClassInfoValidationSteps classInfoValidationSteps; 34 | 35 | @Steps 36 | protected ValidatorSteps validatorSteps; 37 | 38 | @Steps 39 | protected WalkThroughSteps walkThroughSteps; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/annotations/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains stories for Podam annotations. 3 | * 4 | * Created by tedonema on 31/05/2015. 5 | * 6 | * @since 5.5.0 7 | */ 8 | package uk.co.jemos.podam.test.unit.features.annotations; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/basicTypes/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains stories for Podam normal scenarios. 3 | * 4 | * Created by tedonema on 31/05/2015. 5 | * 6 | * @since 5.5.0 7 | */ 8 | package uk.co.jemos.podam.test.unit.features.basicTypes; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/classInfo/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains stories for filling class info into an object 3 | * Created by tedonema on 14/06/2015. 4 | */ 5 | package uk.co.jemos.podam.test.unit.features.classInfo; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/collections/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains stories for Podam's handling of collections 3 | * Created by tedonema on 31/05/2015. 4 | */ 5 | package uk.co.jemos.podam.test.unit.features.collections; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/constructors/PackagePrivatePojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.features.constructors; 2 | 3 | /** 4 | * Package private pojo 5 | * 6 | * @author daivanov 7 | * 8 | */ 9 | class PackagePrivatePojo { 10 | 11 | public PackagePrivatePojo() { 12 | } 13 | 14 | private String value; 15 | 16 | /** 17 | * @return the value 18 | */ 19 | public String getValue() { 20 | return value; 21 | } 22 | 23 | /** 24 | * @param value 25 | * the value to set 26 | */ 27 | public void setValue(String value) { 28 | this.value = value; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/constructors/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains stories for Podam constructors handling. 3 | * Created by tedonema on 14/06/2015. 4 | */ 5 | package uk.co.jemos.podam.test.unit.features.constructors; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/dataProviderStrategy/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Tests the correct initialisation of Random Data Provider Strategy. 3 | * Created by tedonema on 20/06/2015. 4 | */ 5 | package uk.co.jemos.podam.test.unit.features.dataProviderStrategy; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/edgeCases/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains stories for Podam Edge cases. 3 | * 4 | * Created by tedonema on 31/05/2015. 5 | * 6 | * @since 5.5.0 7 | */ 8 | package uk.co.jemos.podam.test.unit.features.edgeCases; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/extensions/NonEJBClassInfoStrategy.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.features.extensions; 2 | 3 | import uk.co.jemos.podam.api.AbstractClassInfoStrategy; 4 | import uk.co.jemos.podam.api.ClassAttribute; 5 | import uk.co.jemos.podam.test.dto.NonEJBPojo; 6 | 7 | import java.lang.reflect.Method; 8 | 9 | /** 10 | * Created by tedonema on 20/06/2015. 11 | */ 12 | public class NonEJBClassInfoStrategy extends AbstractClassInfoStrategy { 13 | 14 | @Override 15 | public boolean approve(ClassAttribute attribute) { 16 | 17 | /* EJB attributes: field and setter */ 18 | if (attribute.getAttribute() != null) { 19 | return true; 20 | } 21 | 22 | /* Exclusion for NonEJBPojo class */ 23 | for (Method setter : attribute.getSetters()) { 24 | if (NonEJBPojo.class.equals(setter.getDeclaringClass())) { 25 | return true; 26 | } 27 | } 28 | return false; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/extensions/NonEJBPojoTest.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.features.extensions; 2 | 3 | import net.serenitybdd.junit.runners.SerenityRunner; 4 | import net.thucydides.core.annotations.Title; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import uk.co.jemos.podam.api.PodamFactory; 8 | import uk.co.jemos.podam.test.dto.NonEJBPojo; 9 | import uk.co.jemos.podam.test.unit.AbstractPodamSteps; 10 | 11 | /** 12 | * Test @uk.co.jemos.podam.test.dto.NonEJBPojo@ construction 13 | * 14 | * @author daivanov 15 | * 16 | */ 17 | @RunWith(SerenityRunner.class) 18 | public class NonEJBPojoTest extends AbstractPodamSteps { 19 | 20 | @Test 21 | @Title("Podam should handle attributes in accordance with custom Class Info Strategies") 22 | public void podamShouldHandleAttributesInAccordanceWithCustomClassInfoStrategies() throws Exception { 23 | 24 | NonEJBClassInfoStrategy classInfoStrategy = podamFactorySteps.givenANonEJBClassInfoStrategy(); 25 | 26 | PodamFactory podamFactory = podamFactorySteps.givenAPodamFactoryWithCustomClassInfoStrategy(classInfoStrategy); 27 | podamValidationSteps.theTwoObjectsShouldBeEqual(podamFactory.getClassStrategy(), classInfoStrategy); 28 | 29 | NonEJBPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(NonEJBPojo.class, podamFactory); 30 | podamValidationSteps.thePojoMustBeOfTheType(pojo, NonEJBPojo.class); 31 | podamValidationSteps.theStringFieldCannotBeNullOrEmpty(pojo.getMyString()); 32 | podamValidationSteps.thePojoMustBeOfTheType(pojo.getMyLong(), Long.class); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/extensions/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains stories for extending Podam. 3 | * 4 | * Created by tedonema on 31/05/2015. 5 | * 6 | * @since 5.5.0 7 | *//** 8 | * Created by tedonema on 07/06/2015. 9 | */ 10 | package uk.co.jemos.podam.test.unit.features.extensions; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/externalFactory/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains stories for using external factories in Podam. 3 | * 4 | * Created by tedonema on 31/05/2015. 5 | * 6 | * @since 5.5.0 7 | */ 8 | package uk.co.jemos.podam.test.unit.features.externalFactory; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/factories/FactoryUnitTest.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.features.factories; 2 | 3 | import javax.xml.transform.Transformer; 4 | import javax.xml.transform.TransformerFactory; 5 | 6 | import net.serenitybdd.junit.runners.SerenityRunner; 7 | import net.thucydides.core.annotations.Title; 8 | 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | 12 | import uk.co.jemos.podam.api.PodamFactory; 13 | import uk.co.jemos.podam.test.unit.AbstractPodamSteps; 14 | 15 | /** 16 | * Test @uk.co.jemos.podam.test.dto.JAXBElementPojo@ construction 17 | * 18 | * @author daivanov 19 | * 20 | */ 21 | @RunWith(SerenityRunner.class) 22 | public class FactoryUnitTest extends AbstractPodamSteps { 23 | 24 | @Test 25 | @Title("Podam should be able to create an abstract class with help of factory") 26 | public void podamShouldBeAbleToCreateAnAbstractClassWithHelpOfFactory() 27 | throws Exception { 28 | 29 | PodamFactory podamFactory = podamFactorySteps.givenAPodamFactoryWithDefinedFactoryForAnAbstractClass( 30 | Transformer.class, TransformerFactory.class); 31 | 32 | Transformer pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(Transformer.class, podamFactory); 33 | podamValidationSteps.theObjectShouldNotBeNull(pojo); 34 | 35 | podamFactorySteps.removeADefinedFactoryForAnAbstractClassFromAPodamFactory(podamFactory, TransformerFactory.class); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/factories/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains stories for using factories in Podam. 3 | * 4 | * Created by daivanov on 19/08/2016. 5 | * 6 | * @since 6.0.3 7 | */ 8 | package uk.co.jemos.podam.test.unit.features.factories; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/inheritance/CustomDataProviderStrategy.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.features.inheritance; 2 | 3 | import uk.co.jemos.podam.api.AbstractRandomDataProviderStrategy; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | /** 9 | * Created by tedonema on 20/06/2015. 10 | */ 11 | public class CustomDataProviderStrategy extends AbstractRandomDataProviderStrategy { 12 | private List> accessed = new ArrayList>(); 13 | 14 | @Override 15 | public Class getSpecificClass( 16 | Class nonInstantiatableClass) { 17 | accessed.add(nonInstantiatableClass); 18 | return nonInstantiatableClass; 19 | } 20 | 21 | public List> getAccessed() { 22 | return accessed; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/inheritance/TrackingExternalFactory.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.features.inheritance; 2 | 3 | import uk.co.jemos.podam.api.AbstractExternalFactory; 4 | 5 | import java.lang.reflect.Type; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | * Created by tedonema on 20/06/2015. 11 | */ 12 | public class TrackingExternalFactory extends AbstractExternalFactory { 13 | 14 | List> failures = new ArrayList>(); 15 | 16 | @Override 17 | public T manufacturePojo(Class pojoClass, Type... genericTypeArgs) { 18 | failures.add(pojoClass); 19 | return null; 20 | } 21 | 22 | @Override 23 | public T populatePojo(T pojo, Type... genericTypeArgs) { 24 | return pojo; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/inheritance/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains stories for Podam Inheritance coverage 3 | * 4 | * Created by tedonema on 31/05/2015. 5 | * 6 | * @since 5.5.0 7 | */ 8 | package uk.co.jemos.podam.test.unit.features.inheritance; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/memoization/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains stories for memoization 3 | * Created by tedonema on 20/06/2015. 4 | */ 5 | package uk.co.jemos.podam.test.unit.features.memoization; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/randomness/RandomnessTest.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.features.randomness; 2 | 3 | import net.serenitybdd.junit.runners.SerenityRunner; 4 | import net.thucydides.core.annotations.Title; 5 | 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | 9 | import uk.co.jemos.podam.api.PodamUtils; 10 | import uk.co.jemos.podam.test.unit.AbstractPodamSteps; 11 | 12 | /** 13 | * Created by daivanov on 05/02/2017. 14 | */ 15 | @RunWith(SerenityRunner.class) 16 | public class RandomnessTest extends AbstractPodamSteps { 17 | 18 | @Test 19 | @Title("Podam should generate evenly distributed random integers") 20 | public void podamShouldGenerateEvenlyDistributedRandomIntegers() throws Exception { 21 | final int cnt = 10; 22 | final int runs = 1000000; 23 | int[] counters = new int[cnt]; 24 | 25 | for (int i = 0; i < runs; i++) { 26 | int idx = (int)PodamUtils.getLongInRange(0, cnt - 1); 27 | counters[idx]++; 28 | } 29 | 30 | double mse = 0; 31 | double expected = runs / cnt; 32 | for (int i = 0; i < cnt; i++) { 33 | double error = 100 * (counters[i] - expected) / expected; 34 | mse += (error * error / cnt); 35 | } 36 | podamValidationSteps.theDoubleValueShouldBeBetween(mse, 0.0, 1.0); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/randomness/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains stories for randomness validation. 3 | * 4 | * Created by daivanov on 05/02/2017. 5 | * 6 | * @since 7.0.5 7 | */ 8 | package uk.co.jemos.podam.test.unit.features.randomness; 9 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/singletons/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains stories for Podam Singleton coverage 3 | * 4 | * Created by tedonema on 31/05/2015. 5 | * 6 | * @since 5.5.0 7 | */ 8 | package uk.co.jemos.podam.test.unit.features.singletons; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/typeManufacturing/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains tests for Spring integration type manufacturing. 3 | * 4 | * Created by tedonema on 28/06/2015. 5 | * 6 | * @since 6.0.0.RELEASE 7 | */ 8 | package uk.co.jemos.podam.test.unit.features.typeManufacturing; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/validatorFramework/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains tests for Podam support for the Validator framework. 3 | * Created by tedonema on 21/06/2015. 4 | */ 5 | package uk.co.jemos.podam.test.unit.features.validatorFramework; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/walkThroughExample/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains tests to validate the Walk Through Example 3 | * Created by tedonema on 21/06/2015. 4 | */ 5 | package uk.co.jemos.podam.test.unit.features.walkThroughExample; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/xmlTypes/XmlTypesExternalFactory.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.features.xmlTypes; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import uk.co.jemos.podam.api.AbstractExternalFactory; 7 | 8 | import javax.xml.datatype.DatatypeFactory; 9 | import javax.xml.datatype.Duration; 10 | import javax.xml.datatype.XMLGregorianCalendar; 11 | 12 | import java.lang.reflect.Type; 13 | import java.util.GregorianCalendar; 14 | 15 | /** 16 | * Created by tedonema on 21/06/2015. 17 | */ 18 | public class XmlTypesExternalFactory extends AbstractExternalFactory { 19 | 20 | 21 | /** The application logger */ 22 | private static final Logger LOG = LoggerFactory.getLogger(XmlTypesExternalFactory.class); 23 | 24 | @Override 25 | public T manufacturePojo(Class pojoClass, Type... genericTypeArgs) { 26 | try { 27 | if (pojoClass.isAssignableFrom(XMLGregorianCalendar.class)) { 28 | DatatypeFactory factory = DatatypeFactory.newInstance(); 29 | @SuppressWarnings("unchecked") 30 | T calendar = (T) factory.newXMLGregorianCalendar(new GregorianCalendar()); 31 | LOG.info("Externally created XMLGregorianCalendar"); 32 | return calendar; 33 | } else if (pojoClass.isAssignableFrom(Duration.class)) { 34 | DatatypeFactory factory = DatatypeFactory.newInstance(); 35 | @SuppressWarnings("unchecked") 36 | T duration = (T) factory.newDuration(0L); 37 | LOG.info("Externally created Duration"); 38 | return duration; 39 | } 40 | } catch (Exception e) { 41 | throw new IllegalStateException("Manufacturing failed", e); 42 | } 43 | return null; 44 | } 45 | 46 | @Override 47 | public T populatePojo(T pojo, Type... genericTypeArgs) { 48 | return pojo; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/features/xmlTypes/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains tests for XML types. 3 | * Created by tedonema on 21/06/2015. 4 | */ 5 | package uk.co.jemos.podam.test.unit.features.xmlTypes; -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/issue86/ExtraMethodsPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.issue86; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Created by tedonema on 12/04/2015. 7 | */ 8 | public class ExtraMethodsPojo implements Serializable { 9 | private static final long serialVersionUID = 1L; 10 | 11 | private static class Holder { 12 | private String holdingString = null; 13 | private Long holdingLong = null; 14 | } 15 | 16 | private Holder myHolder; 17 | 18 | public ExtraMethodsPojo() { 19 | myHolder = new Holder(); 20 | } 21 | 22 | public String getMyString() { 23 | return myHolder.holdingString; 24 | } 25 | 26 | public void setMyString(String myString) { 27 | myHolder.holdingString = myString; 28 | } 29 | 30 | public Long getMyLong() { 31 | return myHolder.holdingLong; 32 | } 33 | 34 | public void setMyLong(Long myLong) { 35 | myHolder.holdingLong = myLong; 36 | } 37 | 38 | @Override 39 | public boolean equals(Object o) { 40 | if (this == o) return true; 41 | if (o == null || getClass() != o.getClass()) return false; 42 | 43 | ExtraMethodsPojo that = (ExtraMethodsPojo) o; 44 | 45 | return myHolder.equals(that.myHolder); 46 | 47 | } 48 | 49 | @Override 50 | public int hashCode() { 51 | return myHolder.hashCode(); 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | final StringBuilder sb = new StringBuilder("ExtraMethodsPojo{"); 57 | sb.append("serialVersionUID=").append(serialVersionUID); 58 | sb.append(", myHolder=").append(myHolder); 59 | sb.append('}'); 60 | return sb.toString(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/issue86/ExtraMethodsUnitTest.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.issue86; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | 7 | import uk.co.jemos.podam.api.*; 8 | 9 | /** 10 | * Created by tedonema on 12/04/2015. 11 | */ 12 | public class ExtraMethodsUnitTest { 13 | 14 | 15 | private DataProviderStrategy dataProviderStrategy = new RandomDataProviderStrategyImpl(); 16 | 17 | private AbstractClassInfoStrategy classInfoStrategy = DefaultClassInfoStrategy.getInstance(); 18 | 19 | private PodamFactory podam = new PodamFactoryImpl(dataProviderStrategy); 20 | 21 | @Before 22 | public void setup() throws Exception { 23 | 24 | classInfoStrategy.addExtraMethod(ExtraMethodsPojo.class, "setMyString", String.class); 25 | classInfoStrategy.addExtraMethod(ExtraMethodsPojo.class, "setMyLong", Long.class); 26 | } 27 | 28 | @Test 29 | public void testExtraMethods() throws Exception { 30 | 31 | ExtraMethodsPojo pojo = podam.manufacturePojo(ExtraMethodsPojo.class); 32 | Assert.assertNotNull("The pojo cannot be null", pojo); 33 | Assert.assertNotNull("The long value cannot be zero", pojo.getMyLong()); 34 | Assert.assertNotNull("The string value cannot be null", pojo.getMyString()); 35 | Assert.assertTrue("The string value cannot be empty", pojo.getMyString().length() > 0); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/issue86/MyInitPojo.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.issue86; 2 | 3 | import uk.co.jemos.podam.common.PodamExclude; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by tedonema on 14/04/2015. 9 | */ 10 | public class MyInitPojo implements Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | private String string1; 15 | 16 | private String string2; 17 | 18 | @PodamExclude 19 | private String backupString1; 20 | 21 | @PodamExclude 22 | private String backupString2; 23 | 24 | public MyInitPojo() {} 25 | 26 | /** 27 | * It re-initialise the strings 28 | * @param s1 String 1 29 | * @param s2 String 2 30 | */ 31 | public void init(String s1, String s2) { 32 | 33 | this.string1 = s1; 34 | this.string2 = s2; 35 | } 36 | 37 | public String getString1() { 38 | return string1; 39 | } 40 | 41 | public void setString1(String string1) { 42 | this.string1 = string1; 43 | this.backupString1 = string1; 44 | } 45 | 46 | public String getString2() { 47 | return string2; 48 | } 49 | 50 | public void setString2(String string2) { 51 | this.string2 = string2; 52 | this.backupString2 = string2; 53 | } 54 | 55 | public String getBackupString1() { 56 | return backupString1; 57 | } 58 | 59 | public String getBackupString2() { 60 | return backupString2; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/issue86/MyInitPojoUnitTest.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.issue86; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | 7 | import uk.co.jemos.podam.api.DefaultClassInfoStrategy; 8 | import uk.co.jemos.podam.api.PodamFactory; 9 | import uk.co.jemos.podam.api.PodamFactoryImpl; 10 | 11 | /** 12 | * Created by tedonema on 14/04/2015. 13 | */ 14 | public class MyInitPojoUnitTest { 15 | 16 | private DefaultClassInfoStrategy classInfoStrategy = DefaultClassInfoStrategy.getInstance(); 17 | 18 | 19 | private final PodamFactory podam = new PodamFactoryImpl(); 20 | 21 | @Before 22 | public void init() throws Exception { 23 | classInfoStrategy.addExtraMethod(MyInitPojo.class, "init", String.class, String.class); 24 | } 25 | 26 | @Test 27 | public void testMyInitPojo() throws Exception { 28 | 29 | MyInitPojo pojo = podam.manufacturePojo(MyInitPojo.class); 30 | Assert.assertNotNull(pojo); 31 | Assert.assertNotSame(pojo.getString1(), pojo.getBackupString1()); 32 | Assert.assertNotSame(pojo.getString2(), pojo.getBackupString2()); 33 | 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/issue93/A.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.issue93; 2 | 3 | import uk.co.jemos.podam.common.PodamCollection; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by tedonema on 05/05/2015. 9 | */ 10 | public class A { 11 | 12 | @PodamCollection(nbrElements = 2) 13 | private List listOfC; 14 | 15 | public List getListOfC() { 16 | return listOfC; 17 | } 18 | 19 | public void setListOfC(List listOfC) { 20 | this.listOfC = listOfC; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/issue93/B.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.issue93; 2 | 3 | import uk.co.jemos.podam.common.PodamCollection; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by tedonema on 05/05/2015. 9 | */ 10 | public class B { 11 | 12 | @PodamCollection(nbrElements = 2) 13 | List listOfC; 14 | 15 | public List getListOfC() { 16 | return listOfC; 17 | } 18 | 19 | public void setListOfC(List listOfC) { 20 | this.listOfC = listOfC; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/issue93/C.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.issue93; 2 | 3 | import uk.co.jemos.podam.common.PodamCollection; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by tedonema on 05/05/2015. 9 | */ 10 | public class C { 11 | 12 | @PodamCollection(nbrElements = 2) 13 | List listOfB; 14 | 15 | 16 | public List getListOfB() { 17 | return listOfB; 18 | } 19 | 20 | public void setListOfB(List listOfB) { 21 | this.listOfB = listOfB; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/issue93/Issue93UnitTest.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.issue93; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | import uk.co.jemos.podam.api.PodamFactoryImpl; 7 | 8 | /** 9 | * Created by tedonema on 05/05/2015. 10 | */ 11 | public class Issue93UnitTest { 12 | 13 | @Test 14 | public void testLoop() { 15 | A a =new PodamFactoryImpl().manufacturePojo(A.class); 16 | Assert.assertNotNull("The Pojo for class A should not be null", a); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/pdm43/Pdm43UnitTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.unit.pdm43; 5 | 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | 9 | import uk.co.jemos.podam.api.PodamFactory; 10 | import uk.co.jemos.podam.api.PodamFactoryImpl; 11 | import uk.co.jemos.podam.test.dto.pdm43.ConcreteBusinessObject; 12 | 13 | /** 14 | * Unit tests for PDM-43. 15 | * 16 | * @author mtedone 17 | * 18 | */ 19 | public class Pdm43UnitTest { 20 | 21 | @Test 22 | public void validateDtoInstantiation() { 23 | 24 | PodamFactory podamFactory = new PodamFactoryImpl(); 25 | ConcreteBusinessObject pojo = podamFactory 26 | .manufacturePojo(ConcreteBusinessObject.class); 27 | Assert.assertNotNull("The created POJO cannot be null!", pojo); 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/pdm5/InvisibleConstructorAndNoSettersTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Test multiple constructors with setters 3 | */ 4 | package uk.co.jemos.podam.test.unit.pdm5; 5 | 6 | import static org.junit.Assert.assertNotNull; 7 | 8 | import org.junit.Test; 9 | 10 | import uk.co.jemos.podam.api.PodamFactory; 11 | import uk.co.jemos.podam.api.PodamFactoryImpl; 12 | import uk.co.jemos.podam.test.dto.pdm5.InvisibleConstructorAndNoSettersPojo; 13 | 14 | /** 15 | * @author divanov 16 | * 17 | */ 18 | public class InvisibleConstructorAndNoSettersTest { 19 | 20 | @Test 21 | public void testInvisibleConstructorAndNoSetters() { 22 | 23 | PodamFactory factory = new PodamFactoryImpl(); 24 | InvisibleConstructorAndNoSettersPojo pojo = factory.manufacturePojo( 25 | InvisibleConstructorAndNoSettersPojo.class); 26 | assertNotNull(pojo); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/steps/ClassInfoValidationSteps.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.steps; 2 | 3 | import static org.hamcrest.MatcherAssert.assertThat; 4 | import static org.hamcrest.Matchers.*; 5 | import net.thucydides.core.annotations.Step; 6 | 7 | import org.junit.Assert; 8 | 9 | import uk.co.jemos.podam.api.ClassAttribute; 10 | 11 | import java.util.HashSet; 12 | import java.util.Set; 13 | 14 | /** 15 | * Validation steps for ClassInfo stories 16 | * Created by tedonema on 14/06/2015. 17 | */ 18 | public class ClassInfoValidationSteps { 19 | 20 | @Step("Then the attributes contains in ClassInfo should match the ones contains in the POJO") 21 | public void theClassInfoAttributesShouldMatchthePojoOnes(Set attribs, Set classAttributes) { 22 | 23 | Set missingAttribs = new HashSet(attribs); 24 | for (ClassAttribute attribute : classAttributes) { 25 | String attrName = attribute.getName(); 26 | assertThat("Unexpected attribute", attrName, isIn(missingAttribs)); 27 | missingAttribs.remove(attrName); 28 | Assert.assertEquals("Wrong number of getters for " + attribute.getName(), 29 | 1, attribute.getGetters().size()); 30 | Assert.assertEquals("Wrong number of setters for " + attribute.getName(), 31 | 1, attribute.getSetters().size()); 32 | } 33 | assertThat("Missing attributes", missingAttribs, is(empty())); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/steps/ConstructorSelfReferenceValidationSteps.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.steps; 2 | 3 | import net.thucydides.core.annotations.Step; 4 | import org.junit.Assert; 5 | import uk.co.jemos.podam.test.dto.ConstructorWithSelfReferencesButNoDefaultConstructorPojo; 6 | import uk.co.jemos.podam.test.dto.ConstructorWithSelfReferencesPojoAndDefaultConstructor; 7 | 8 | /** 9 | * Created by tedonema on 31/05/2015. 10 | */ 11 | public class ConstructorSelfReferenceValidationSteps { 12 | 13 | @Step("Then the first self-reference for a POJO with default constructor should not be null") 14 | public void theFirstSelfReferenceForPojoWithDefaultConstructorShouldNotBeNull(ConstructorWithSelfReferencesPojoAndDefaultConstructor parentPojo) { 15 | Assert.assertNotNull("The first self-reference should not be null", parentPojo.getParent()); 16 | } 17 | 18 | @Step("Then the second self-reference for a POJO with default constructor should not be null") 19 | public void theSecondSelfReferenceForPojoWithDefaultConstructorShouldNotBeNull(ConstructorWithSelfReferencesPojoAndDefaultConstructor parentPojo) { 20 | Assert.assertNotNull("The second self-reference should not be null", parentPojo.getAnotherParent()); 21 | } 22 | 23 | @Step("Then the first self-reference for a POJO without default constructor should not be null") 24 | public void theFirstSelfReferenceForPojoWithoutDefaultConstructorShouldNotBeNull(ConstructorWithSelfReferencesButNoDefaultConstructorPojo parentPojo) { 25 | Assert.assertNotNull("The first self-reference should not be null", parentPojo.getParent()); 26 | } 27 | 28 | @Step("Then the first self-reference for a POJO without default constructor should not be null") 29 | public void theSecondSelfReferenceForPojoWithoutDefaultConstructorShouldNotBeNull(ConstructorWithSelfReferencesButNoDefaultConstructorPojo parentPojo) { 30 | Assert.assertNotNull("The seciond self-reference should not be null", parentPojo.getAnotherParent()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/steps/PodamStrategySteps.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.steps; 2 | 3 | import net.thucydides.core.annotations.Step; 4 | import uk.co.jemos.podam.api.DataProviderStrategy; 5 | import uk.co.jemos.podam.api.PodamFactory; 6 | 7 | /** 8 | * Created by tedonema on 30/05/2015. 9 | */ 10 | public class PodamStrategySteps { 11 | 12 | @Step("When I add a specific type {2} for an abstract type or interface {1}") 13 | public void addOrReplaceSpecific(PodamFactory podamFactory, Class abstractType, Class concreteType) { 14 | DataProviderStrategy strategy = podamFactory.getStrategy(); 15 | strategy.addOrReplaceSpecific(abstractType, concreteType); 16 | } 17 | 18 | @Step("When I remove a specific type {1} for an abstract type or interface") 19 | public void removeSpecific(PodamFactory podamFactory, Class abstractType) { 20 | DataProviderStrategy strategy = podamFactory.getStrategy(); 21 | strategy.removeSpecific(abstractType); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/steps/RecursivePojoValidationSteps.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.steps; 2 | 3 | import static org.hamcrest.MatcherAssert.assertThat; 4 | import static org.hamcrest.Matchers.*; 5 | 6 | import net.thucydides.core.annotations.Step; 7 | import uk.co.jemos.podam.test.dto.RecursivePojo; 8 | 9 | /** 10 | * Created by tedonema on 30/05/2015. 11 | */ 12 | public class RecursivePojoValidationSteps { 13 | 14 | @Step("Then all the POJOs in the recursive hierarchy should be valid") 15 | public void allPojosInTheRecursiveStrategyShouldBeValid(RecursivePojo pojo) { 16 | 17 | assertThat("The integer value in the pojo should not be zero!", 18 | pojo.getIntField(), not(equalTo(0))); 19 | 20 | RecursivePojo parentPojo = pojo.getParent(); 21 | assertThat("The parent pojo cannot be null!", parentPojo, not(nullValue())); 22 | assertThat( 23 | "The integer value in the parent pojo should not be zero!", 24 | parentPojo.getIntField(), not(equalTo(0))); 25 | assertThat( 26 | "The parent attribute of the parent pojo cannot be null!", 27 | parentPojo.getParent(), not(nullValue())); 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/unit/steps/ValidatorSteps.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.unit.steps; 2 | 3 | import static org.hamcrest.MatcherAssert.assertThat; 4 | import static org.hamcrest.Matchers.*; 5 | 6 | import net.thucydides.core.annotations.Step; 7 | 8 | import jakarta.validation.ConstraintViolation; 9 | import jakarta.validation.Validator; 10 | import java.util.Set; 11 | 12 | /** 13 | * Created by tedonema on 21/06/2015. 14 | */ 15 | public class ValidatorSteps { 16 | 17 | @Step("Then the POJO should not have any Validator violations for {1}") 18 | public void thePojoShouldNotViolateAnyValidations(Validator validator, T pojo) throws Exception { 19 | 20 | Set> violations = validator.validate(pojo); 21 | assertThat("There should be no violations", 22 | violations, is(empty())); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/utils/PodamTestUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package uk.co.jemos.podam.test.utils; 5 | 6 | import java.util.Calendar; 7 | import java.util.TimeZone; 8 | 9 | /** 10 | * Test utility class 11 | * 12 | * @author mtedone 13 | * 14 | */ 15 | public class PodamTestUtils { 16 | 17 | // ------------------->> Constants 18 | 19 | // ------------------->> Instance / Static variables 20 | 21 | // ------------------->> Constructors 22 | 23 | /** Non instantiable class */ 24 | private PodamTestUtils() { 25 | } 26 | 27 | // ------------------->> Public methods 28 | 29 | /** 30 | * Returns a Calendar with my birthday date. 31 | * 32 | * @return A Calendar with my birthday date. 33 | */ 34 | public static Calendar getMyBirthday() { 35 | Calendar myBirthday = Calendar.getInstance(TimeZone.getTimeZone("UTC")); 36 | myBirthday.set(Calendar.DAY_OF_MONTH, 20); 37 | myBirthday.set(Calendar.MONTH, 5); 38 | myBirthday.set(Calendar.YEAR, 1972); 39 | myBirthday.set(Calendar.HOUR_OF_DAY, 2); 40 | myBirthday.set(Calendar.MINUTE, 0); 41 | myBirthday.set(Calendar.SECOND, 0); 42 | myBirthday.set(Calendar.MILLISECOND, 0); 43 | 44 | return myBirthday; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/uk/co/jemos/podam/test/utils/TypesUtils.java: -------------------------------------------------------------------------------- 1 | package uk.co.jemos.podam.test.utils; 2 | 3 | import org.junit.Assert; 4 | 5 | import java.util.Calendar; 6 | import java.util.Date; 7 | 8 | public abstract class TypesUtils { 9 | 10 | /** 11 | * It checks that the Calendar instance is valid 12 | *

13 | * If the calendar returns a valid date then it's a valid instance 14 | *

15 | * 16 | * @param calendarField The calendar instance to check 17 | */ 18 | public static void checkCalendarIsValid(Calendar calendarField) { 19 | Assert.assertNotNull("The Calendar field cannot be null", calendarField); 20 | Date calendarDate = calendarField.getTime(); 21 | Assert.assertNotNull("It appears the Calendar field is not valid", 22 | calendarDate); 23 | } 24 | } -------------------------------------------------------------------------------- /src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/test/resources/podam-test-appContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | --------------------------------------------------------------------------------