Class MappedPojoTest

java.lang.Object
com.github.tadukoo.junit.MappedPojoTest
All Implemented Interfaces:
DefaultTestValues

public class MappedPojoTest extends Object implements DefaultTestValues
Mapped Pojo Test is used to test MappedPojos.
Version:
Alpha v.0.1
Author:
Logan Ferree (Tadukoo)
  • Field Summary

  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Not allowed to create a MappedPojoTest instance
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    assertDoubleGetSet(com.github.tadukoo.util.pojo.MappedPojo pojo, String key)
    Checks MappedPojo.getItem(String) and MappedPojo.setItem(String, Object) on the given pojo, to test that those get and set methods work for the given key for a double value.
    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,T2> setter, String key)
    Checks MappedPojo.getItem(String) and MappedPojo.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>>
    void
    Using the given MappedPojo class, it will create a new instance using no constructor parameters.
    static void
    assertEmptyPojo(com.github.tadukoo.util.pojo.MappedPojo pojo)
    Checks that the given MappedPojo is empty.
    static <P extends Class<? extends com.github.tadukoo.util.pojo.MappedPojo>>
    void
    assertPojoConstructor(P pojoClass)
    Using the given MappedPojo 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)
    Checks MappedPojo.getItem(String) and MappedPojo.setItem(String, Object) on the given pojo, to test that those get and set methods work for the given key for a String value.
    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,T2> setter, String key)
    Checks MappedPojo.getItem(String) and MappedPojo.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)
    Checks MappedPojo.getItem(String) and MappedPojo.setItem(String, Object) on the given pojo, to test that those get and set methods work for the given key and values.
    static <V, T extends Throwable, T2 extends Throwable>
    void
    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)
    Checks MappedPojo.getItem(String) and MappedPojo.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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 given MappedPojo 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 - The MappedPojo class
      Parameters:
      pojoClass - The MappedPojo class to be tested
      Throws:
      NoSuchMethodException - If the empty constructor does not exist
      InvocationTargetException - If the constructor throws an exception
      InstantiationException - If the class is abstract
      IllegalAccessException - If the constructor is not public
      org.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 given MappedPojo 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 - The MappedPojo class
      Parameters:
      pojoClass - The MappedPojo class to be tested
      Throws:
      NoSuchMethodException - If the pojo constructor does not exist
      InvocationTargetException - If the constructor throws an exception
      InstantiationException - If the class is abstract
      IllegalAccessException - If the constructor is not public
      org.opentest4j.AssertionFailedError - If an assertion fails
    • assertEmptyPojo

      public static void assertEmptyPojo(com.github.tadukoo.util.pojo.MappedPojo pojo)
      Checks that the given MappedPojo is empty. Checks that MappedPojo.isEmpty() is true, that MappedPojo.getMap() is not null and is empty, and that MappedPojo.getKeys() is not null and is empty
      Parameters:
      pojo - The MappedPojo 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)
      Checks MappedPojo.getItem(String) and MappedPojo.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 - The MappedPojo to be tested
      key - The key to be used
      value - The first value to be used for testing
      value2 - The second value to be used for testing
      Throws:
      org.opentest4j.AssertionFailedError - If an assertion fails
    • assertStringGetSet

      public static void assertStringGetSet(com.github.tadukoo.util.pojo.MappedPojo pojo, String key)
      Checks MappedPojo.getItem(String) and MappedPojo.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 - The MappedPojo to be tested
      key - The key to be used
      Throws:
      org.opentest4j.AssertionFailedError - If an assertion fails
    • assertDoubleGetSet

      public static void assertDoubleGetSet(com.github.tadukoo.util.pojo.MappedPojo pojo, String key)
      Checks MappedPojo.getItem(String) and MappedPojo.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 - The MappedPojo to be tested
      key - The key to be used
      Throws:
      org.opentest4j.AssertionFailedError - If an assertion fails
    • assertValueGetSetCustom

      public static <V, T extends Throwable, T2 extends Throwable> void 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) throws T, T2
      Checks MappedPojo.getItem(String) and MappedPojo.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 retrieved
      T - A Throwable that the getter may throw
      T2 - A Throwable that the setter may throw
      Parameters:
      pojo - The MappedPojo to be tested
      getter - The getter to be tested
      setter - The setter to be tested
      key - The key to be used
      value - The first value to be used for testing
      value2 - The second value to be used for testing
      Throws:
      T - If the getter throws it
      T2 - If the setter throws it
      org.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,T2> setter, String key) throws T, T2
      Checks MappedPojo.getItem(String) and MappedPojo.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 - A Throwable that the getter may throw
      T2 - A Throwable that the setter may throw
      Parameters:
      pojo - The MappedPojo to be tested
      getter - The getter to be tested
      setter - The setter to be tested
      key - The key to be used
      Throws:
      T - If the getter throws it
      T2 - If the setter throws it
      org.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,T2> setter, String key) throws T, T2
      Checks MappedPojo.getItem(String) and MappedPojo.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 - A Throwable that the getter may throw
      T2 - A Throwable that the setter may throw
      Parameters:
      pojo - The MappedPojo to be tested
      getter - The getter to be tested
      setter - The setter to be tested
      key - The key to be used
      Throws:
      T - If the getter throws it
      T2 - If the setter throws it
      org.opentest4j.AssertionFailedError - If an assertion fails