Package com.github.tadukoo.junit
Class MappedPojoTest
java.lang.Object
com.github.tadukoo.junit.MappedPojoTest
- All Implemented Interfaces:
DefaultTestValues
Mapped Pojo Test is used to test
MappedPojos.- Version:
- Alpha v.0.1
- Author:
- Logan Ferree (Tadukoo)
-
Field Summary
Fields inherited from interface com.github.tadukoo.junit.constant.DefaultTestValues
DEFAULT_TEST_DOUBLE, DEFAULT_TEST_DOUBLE_2, DEFAULT_TEST_KEY, DEFAULT_TEST_KEY_2, DEFAULT_TEST_STRING, DEFAULT_TEST_STRING_2, DEFAULT_WRONG_DOUBLE, DEFAULT_WRONG_KEY, DEFAULT_WRONG_STRING -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateNot allowed to create a MappedPojoTest instance -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertDoubleGetSet(com.github.tadukoo.util.pojo.MappedPojo pojo, String key) ChecksMappedPojo.getItem(String)andMappedPojo.setItem(String, Object)on the given pojo, to test that those get and set methods work for the given key for a double value.assertDoubleGetSetCustom(com.github.tadukoo.util.pojo.MappedPojo pojo, com.github.tadukoo.util.functional.supplier.ThrowingSupplier<Double, T> getter, com.github.tadukoo.util.functional.consumer.ThrowingConsumer<Double, T2> setter, String key) ChecksMappedPojo.getItem(String)andMappedPojo.setItem(String, Object)on the given pojo, along with the given custom getter and setter that the methods work for the given key for double values.static <P extends Class<? extends com.github.tadukoo.util.pojo.MappedPojo>>
voidassertEmptyConstructor(P pojoClass) Using the givenMappedPojoclass, it will create a new instance using no constructor parameters.static voidassertEmptyPojo(com.github.tadukoo.util.pojo.MappedPojo pojo) Checks that the givenMappedPojois empty.static <P extends Class<? extends com.github.tadukoo.util.pojo.MappedPojo>>
voidassertPojoConstructor(P pojoClass) Using the givenMappedPojoclass, it will create a new instance using another MappedPojo as a constructor parameter.static voidassertStringGetSet(com.github.tadukoo.util.pojo.MappedPojo pojo, String key) ChecksMappedPojo.getItem(String)andMappedPojo.setItem(String, Object)on the given pojo, to test that those get and set methods work for the given key for a String value.assertStringGetSetCustom(com.github.tadukoo.util.pojo.MappedPojo pojo, com.github.tadukoo.util.functional.supplier.ThrowingSupplier<String, T> getter, com.github.tadukoo.util.functional.consumer.ThrowingConsumer<String, T2> setter, String key) ChecksMappedPojo.getItem(String)andMappedPojo.setItem(String, Object)on the given pojo, along with the given custom getter and setter that the methods work for the given key for string values.static <V> voidassertValueGetSet(com.github.tadukoo.util.pojo.MappedPojo pojo, String key, V value, V value2) ChecksMappedPojo.getItem(String)andMappedPojo.setItem(String, Object)on the given pojo, to test that those get and set methods work for the given key and values.assertValueGetSetCustom(com.github.tadukoo.util.pojo.MappedPojo pojo, com.github.tadukoo.util.functional.supplier.ThrowingSupplier<V, T> getter, com.github.tadukoo.util.functional.consumer.ThrowingConsumer<V, T2> setter, String key, V value, V value2) ChecksMappedPojo.getItem(String)andMappedPojo.setItem(String, Object)on the given pojo, along with the given custom getter and setter that the methods work for the given key with the given values.
-
Constructor Details
-
MappedPojoTest
private MappedPojoTest()Not allowed to create a MappedPojoTest instance
-
-
Method Details
-
assertEmptyConstructor
public static <P extends Class<? extends com.github.tadukoo.util.pojo.MappedPojo>> void assertEmptyConstructor(P pojoClass) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException Using the givenMappedPojoclass, it will create a new instance using no constructor parameters. Then it'll test that the map and keys are correctly empty.- Type Parameters:
P- TheMappedPojoclass- Parameters:
pojoClass- TheMappedPojoclass to be tested- Throws:
NoSuchMethodException- If the empty constructor does not existInvocationTargetException- If the constructor throws an exceptionInstantiationException- If the class is abstractIllegalAccessException- If the constructor is not publicorg.opentest4j.AssertionFailedError- If an assertion fails
-
assertPojoConstructor
public static <P extends Class<? extends com.github.tadukoo.util.pojo.MappedPojo>> void assertPojoConstructor(P pojoClass) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException Using the givenMappedPojoclass, it will create a new instance using another MappedPojo as a constructor parameter. Then it will check that the map and keys (and getItem) are correct.- Type Parameters:
P- TheMappedPojoclass- Parameters:
pojoClass- TheMappedPojoclass to be tested- Throws:
NoSuchMethodException- If the pojo constructor does not existInvocationTargetException- If the constructor throws an exceptionInstantiationException- If the class is abstractIllegalAccessException- If the constructor is not publicorg.opentest4j.AssertionFailedError- If an assertion fails
-
assertEmptyPojo
public static void assertEmptyPojo(com.github.tadukoo.util.pojo.MappedPojo pojo) Checks that the givenMappedPojois empty. Checks thatMappedPojo.isEmpty()is true, thatMappedPojo.getMap()is not null and is empty, and thatMappedPojo.getKeys()is not null and is empty- Parameters:
pojo- TheMappedPojoto be tested- Throws:
org.opentest4j.AssertionFailedError- If an assertion fails
-
assertValueGetSet
public static <V> void assertValueGetSet(com.github.tadukoo.util.pojo.MappedPojo pojo, String key, V value, V value2) ChecksMappedPojo.getItem(String)andMappedPojo.setItem(String, Object)on the given pojo, to test that those get and set methods work for the given key and values. The set and retrieve are done twice (once for each given value) to ensure we're not adding/appending or just always returning the expected value. We also check that the keys and map are correct on the pojo.
Note: The given pojo should be empty- Type Parameters:
V- The value type being set and retrieved- Parameters:
pojo- TheMappedPojoto be testedkey- The key to be usedvalue- The first value to be used for testingvalue2- The second value to be used for testing- Throws:
org.opentest4j.AssertionFailedError- If an assertion fails
-
assertStringGetSet
ChecksMappedPojo.getItem(String)andMappedPojo.setItem(String, Object)on the given pojo, to test that those get and set methods work for the given key for a String value. The set and retrieve are done twice to ensure we're not adding/appending or just always returning the expected value. We also check that the keys and map are correct on the pojo.
Note: The given pojo should be empty- Parameters:
pojo- TheMappedPojoto be testedkey- The key to be used- Throws:
org.opentest4j.AssertionFailedError- If an assertion fails
-
assertDoubleGetSet
ChecksMappedPojo.getItem(String)andMappedPojo.setItem(String, Object)on the given pojo, to test that those get and set methods work for the given key for a double value. The set and retrieve are done twice to ensure we're not adding/appending or just always returning the expected value. We also check that the keys and map are correct on the pojo.
Note: The given pojo should be empty- Parameters:
pojo- TheMappedPojoto be testedkey- The key to be used- Throws:
org.opentest4j.AssertionFailedError- If an assertion fails
-
assertValueGetSetCustom
public static <V,T extends Throwable, void assertValueGetSetCustomT2 extends Throwable> (com.github.tadukoo.util.pojo.MappedPojo pojo, com.github.tadukoo.util.functional.supplier.ThrowingSupplier<V, T> getter, com.github.tadukoo.util.functional.consumer.ThrowingConsumer<V, throws T, T2T2> setter, String key, V value, V value2) ChecksMappedPojo.getItem(String)andMappedPojo.setItem(String, Object)on the given pojo, along with the given custom getter and setter that the methods work for the given key with the given values. The set and retrieve are done twice per getter/setter combo to ensure we're not adding/appending or just always returning the expected value. We also check that the keys and map are correct on the pojo.
Note: The given pojo should be empty- Type Parameters:
V- The value type being set and retrievedT- AThrowablethat the getter may throwT2- AThrowablethat the setter may throw- Parameters:
pojo- TheMappedPojoto be testedgetter- The getter to be testedsetter- The setter to be testedkey- The key to be usedvalue- The first value to be used for testingvalue2- The second value to be used for testing- Throws:
T- If the getter throws itT2- If the setter throws itorg.opentest4j.AssertionFailedError- If an assertion fails
-
assertStringGetSetCustom
public static <T extends Throwable,T2 extends Throwable> void assertStringGetSetCustom(com.github.tadukoo.util.pojo.MappedPojo pojo, com.github.tadukoo.util.functional.supplier.ThrowingSupplier<String, T> getter, com.github.tadukoo.util.functional.consumer.ThrowingConsumer<String, throws T, T2T2> setter, String key) ChecksMappedPojo.getItem(String)andMappedPojo.setItem(String, Object)on the given pojo, along with the given custom getter and setter that the methods work for the given key for string values. The set and retrieve are done twice per getter/setter combo to ensure we're not adding/appending or just always returning the expected value. We also check that the keys and map are correct on the pojo.
Note: The given pojo should be empty- Type Parameters:
T- AThrowablethat the getter may throwT2- AThrowablethat the setter may throw- Parameters:
pojo- TheMappedPojoto be testedgetter- The getter to be testedsetter- The setter to be testedkey- The key to be used- Throws:
T- If the getter throws itT2- If the setter throws itorg.opentest4j.AssertionFailedError- If an assertion fails
-
assertDoubleGetSetCustom
public static <T extends Throwable,T2 extends Throwable> void assertDoubleGetSetCustom(com.github.tadukoo.util.pojo.MappedPojo pojo, com.github.tadukoo.util.functional.supplier.ThrowingSupplier<Double, T> getter, com.github.tadukoo.util.functional.consumer.ThrowingConsumer<Double, throws T, T2T2> setter, String key) ChecksMappedPojo.getItem(String)andMappedPojo.setItem(String, Object)on the given pojo, along with the given custom getter and setter that the methods work for the given key for double values. The set and retrieve are done twice per getter/setter combo to ensure we're not adding/appending or just always returning the expected value. We also check that the keys and map are correct on the pojo.
Note: The given pojo should be empty- Type Parameters:
T- AThrowablethat the getter may throwT2- AThrowablethat the setter may throw- Parameters:
pojo- TheMappedPojoto be testedgetter- The getter to be testedsetter- The setter to be testedkey- The key to be used- Throws:
T- If the getter throws itT2- If the setter throws itorg.opentest4j.AssertionFailedError- If an assertion fails
-