// Path: src/main/java/pl/jalokim/propertiestojson/util/exception/ParsePropertiesException.java
// public class ParsePropertiesException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public static final String STRING_RESOLVER_AS_NOT_LAST = "Added some type resolver after " + StringJsonTypeResolver.class.getCanonicalName()
//         + ". This type resolver always should be last when is in configuration of resolvers";
// 
//     public static final String STRING_TO_JSON_RESOLVER_AS_NOT_LAST = "Added some type resolver after " + StringToJsonTypeConverter.class.getCanonicalName()
//         + ". This type resolver always should be last when is in configuration of resolvers";
// 
//     public static final String PROPERTY_KEY_NEEDS_TO_BE_STRING_TYPE = "Unsupported property key type: %s for key: %s, Property key needs to be a string type";
//     public static final String CANNOT_FIND_TYPE_RESOLVER_MSG = "Cannot find valid JSON type resolver for class: '%s'. %n"
//         + "Please consider add sufficient resolver to your resolvers.";
// 
//     public static final String CANNOT_FIND_JSON_TYPE_OBJ = "Cannot find valid JSON type resolver for class: '%s'. %n"
//         + " for property: %s, and object value: %s %n"
//         + "Please consider add sufficient resolver to your resolvers.";
// 
//     public ParsePropertiesException(String message) {
//         super(message);
//     }
// }


import static java.util.Arrays.asList;
import static junit.framework.TestCase.fail;
import static org.assertj.core.api.Assertions.assertThat;
import static pl.jalokim.utils.string.StringUtils.concatElementsAsLines;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.junit.Test;
import pl.jalokim.propertiestojson.util.exception.ParsePropertiesException;
package pl.jalokim.propertiestojson.resolvers.hierarchy;




public class HierarchyClassResolverTest {

    public static final String ERR_MSG_FORMAT = "Found %s resolvers for instance type: %s%nfound resolvers:%n%s";

    @Test
    public void willFoundTheSameTypeOfResolver() {
        // given
        HierarchyClassResolver hierarchyClassResolver = new HierarchyClassResolver(asList(Object.class, Number.class, Comparable.class, BigDecimal.class));
        BigDecimal bigDecimal = BigDecimal.ONE;
        // when
        Class<?> aClass = hierarchyClassResolver.searchResolverClass(bigDecimal);
        // then
        assertThat(aClass).isEqualTo(BigDecimal.class);
    }

    @Test
    public void foundCollectionInResolverTypeForArrayList() {
        // given
        HierarchyClassResolver hierarchyClassResolver = new HierarchyClassResolver(asList(Collection.class, Double.class));
        List<String> arrayList = Arrays.asList("test1", "test2");
        // when
        Class<?> aClass = hierarchyClassResolver.searchResolverClass(arrayList);
        // then
        assertThat(aClass).isEqualTo(Collection.class);
    }

    @Test
    public void foundToMuchResolversToMuchInterfaces() {
        // given
        HierarchyClassResolver hierarchyClassResolver = new HierarchyClassResolver(
            asList(HasMind.class, HasHair.class, HasLegs.class, Object.class, HasBrain.class, HasAwareness.class));

        Human human = new Human();
        // when
        try {
            hierarchyClassResolver.searchResolverClass(human);
            fail();
// Path: src/main/java/pl/jalokim/propertiestojson/util/exception/ParsePropertiesException.java
// public class ParsePropertiesException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public static final String STRING_RESOLVER_AS_NOT_LAST = "Added some type resolver after " + StringJsonTypeResolver.class.getCanonicalName()
//         + ". This type resolver always should be last when is in configuration of resolvers";
// 
//     public static final String STRING_TO_JSON_RESOLVER_AS_NOT_LAST = "Added some type resolver after " + StringToJsonTypeConverter.class.getCanonicalName()
//         + ". This type resolver always should be last when is in configuration of resolvers";
// 
//     public static final String PROPERTY_KEY_NEEDS_TO_BE_STRING_TYPE = "Unsupported property key type: %s for key: %s, Property key needs to be a string type";
//     public static final String CANNOT_FIND_TYPE_RESOLVER_MSG = "Cannot find valid JSON type resolver for class: '%s'. %n"
//         + "Please consider add sufficient resolver to your resolvers.";
// 
//     public static final String CANNOT_FIND_JSON_TYPE_OBJ = "Cannot find valid JSON type resolver for class: '%s'. %n"
//         + " for property: %s, and object value: %s %n"
//         + "Please consider add sufficient resolver to your resolvers.";
// 
//     public ParsePropertiesException(String message) {
//         super(message);
//     }
// }


// Path: src/test/java/pl/jalokim/propertiestojson/resolvers/hierarchy/HierarchyClassResolverTest.java
import static java.util.Arrays.asList;
import static junit.framework.TestCase.fail;
import static org.assertj.core.api.Assertions.assertThat;
import static pl.jalokim.utils.string.StringUtils.concatElementsAsLines;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import org.junit.Test;
import pl.jalokim.propertiestojson.util.exception.ParsePropertiesException;

package pl.jalokim.propertiestojson.resolvers.hierarchy;




public class HierarchyClassResolverTest {

    public static final String ERR_MSG_FORMAT = "Found %s resolvers for instance type: %s%nfound resolvers:%n%s";

    @Test
    public void willFoundTheSameTypeOfResolver() {
        // given
        HierarchyClassResolver hierarchyClassResolver = new HierarchyClassResolver(asList(Object.class, Number.class, Comparable.class, BigDecimal.class));
        BigDecimal bigDecimal = BigDecimal.ONE;
        // when
        Class<?> aClass = hierarchyClassResolver.searchResolverClass(bigDecimal);
        // then
        assertThat(aClass).isEqualTo(BigDecimal.class);
    }

    @Test
    public void foundCollectionInResolverTypeForArrayList() {
        // given
        HierarchyClassResolver hierarchyClassResolver = new HierarchyClassResolver(asList(Collection.class, Double.class));
        List<String> arrayList = Arrays.asList("test1", "test2");
        // when
        Class<?> aClass = hierarchyClassResolver.searchResolverClass(arrayList);
        // then
        assertThat(aClass).isEqualTo(Collection.class);
    }

    @Test
    public void foundToMuchResolversToMuchInterfaces() {
        // given
        HierarchyClassResolver hierarchyClassResolver = new HierarchyClassResolver(
            asList(HasMind.class, HasHair.class, HasLegs.class, Object.class, HasBrain.class, HasAwareness.class));

        Human human = new Human();
        // when
        try {
            hierarchyClassResolver.searchResolverClass(human);
            fail();
        } catch (ParsePropertiesException ex) {