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
MappedPojo
s.- 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
ModifierConstructorDescriptionprivate
Not allowed to create a MappedPojoTest instance -
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertDoubleGetSet
(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 givenMappedPojo
class, it will create a new instance using no constructor parameters.static void
assertEmptyPojo
(com.github.tadukoo.util.pojo.MappedPojo pojo) Checks that the givenMappedPojo
is empty.static <P extends Class<? extends com.github.tadukoo.util.pojo.MappedPojo>>
voidassertPojoConstructor
(P pojoClass) Using the givenMappedPojo
class, it will create a new instance using another MappedPojo as a constructor parameter.static void
assertStringGetSet
(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> 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.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 givenMappedPojo
class, 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
- TheMappedPojo
class- Parameters:
pojoClass
- TheMappedPojo
class 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 givenMappedPojo
class, 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
- TheMappedPojo
class- Parameters:
pojoClass
- TheMappedPojo
class 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 givenMappedPojo
is 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
- TheMappedPojo
to 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
- TheMappedPojo
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:
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
- TheMappedPojo
to 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
- TheMappedPojo
to 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
- AThrowable
that the getter may throwT2
- AThrowable
that the setter may throw- Parameters:
pojo
- TheMappedPojo
to 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
- AThrowable
that the getter may throwT2
- AThrowable
that the setter may throw- Parameters:
pojo
- TheMappedPojo
to 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
- AThrowable
that the getter may throwT2
- AThrowable
that the setter may throw- Parameters:
pojo
- TheMappedPojo
to 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
-