// Path: src/main/java/pl/jalokim/propertiestojson/object/AbstractJsonType.java
// public abstract class AbstractJsonType {
// 
//     /**
//      * This one simply concatenate to rest of json. Simply speaking when will not converted then will not create whole json correctly.
//      *
//      * @return string for part of json.
//      */
//     public abstract String toStringJson();
// 
//     @Override
//     public final String toString() {
//         return toStringJson();
//     }
// }
// 
// Path: src/main/java/pl/jalokim/propertiestojson/object/NumberJsonType.java
// public class NumberJsonType extends PrimitiveJsonType<Number> {
// 
//     public NumberJsonType(Number value) {
//         super(value);
//     }
// }
// 
// Path: src/main/java/pl/jalokim/propertiestojson/object/ObjectJsonType.java
// public class ObjectJsonType extends AbstractJsonType implements MergableObject<ObjectJsonType> {
// 
//     @SuppressWarnings("PMD.UseConcurrentHashMap")
//     private final Map<String, AbstractJsonType> fields = new LinkedHashMap<>();
// 
//     public void addField(final String field, final AbstractJsonType object, PathMetadata currentPathMetaData) {
//         if (object instanceof SkipJsonField) {
//             return;
//         }
// 
//         AbstractJsonType oldFieldValue = fields.get(field);
//         if (oldFieldValue == null) {
//             fields.put(field, object);
//         } else {
//             if (oldFieldValue instanceof MergableObject && object instanceof MergableObject) {
//                 mergeObjectIfPossible(oldFieldValue, object, currentPathMetaData);
//             } else {
//                 throw new CannotOverrideFieldException(currentPathMetaData.getCurrentFullPath(),
//                     oldFieldValue,
//                     currentPathMetaData.getOriginalPropertyKey());
//             }
//         }
//     }
// 
//     public boolean containsField(String field) {
//         return fields.containsKey(field);
//     }
// 
//     public AbstractJsonType getField(String field) {
//         return fields.get(field);
//     }
// 
//     public ArrayJsonType getJsonArray(String field) {
//         return (ArrayJsonType) fields.get(field);
//     }
// 
//     @Override
//     public String toStringJson() {
//         StringBuilder result = new StringBuilder().append(JSON_OBJECT_START);
//         int index = 0;
//         int lastIndex = getLastIndex(fields.keySet());
//         for (Map.Entry<String, AbstractJsonType> entry : fields.entrySet()) {
//             AbstractJsonType object = entry.getValue();
//             String lastSign = index == lastIndex ? EMPTY_STRING : NEW_LINE_SIGN;
//             result.append(StringToJsonStringWrapper.wrap(entry.getKey()))
//                 .append(':')
//                 .append(object.toStringJson())
//                 .append(lastSign);
//             index++;
//         }
//         result.append(JSON_OBJECT_END);
//         return result.toString();
//     }
// 
//     @Override
//     public void merge(ObjectJsonType mergeWith, PathMetadata currentPathMetadata) {
//         for (String fieldName : mergeWith.fields.keySet()) {
//             addField(fieldName, mergeWith.getField(fieldName), currentPathMetadata);
//         }
//     }
// }


import static org.assertj.core.api.Assertions.assertThat;
import java.time.LocalDate;
import org.junit.Test;
import pl.jalokim.propertiestojson.object.AbstractJsonType;
import pl.jalokim.propertiestojson.object.NumberJsonType;
import pl.jalokim.propertiestojson.object.ObjectJsonType;
package pl.jalokim.propertiestojson.resolvers.primitives.custom;



public class LocalDateToJsonTypeConverterTest {

    @Test
    public void convertLocalDateToUtcTimestamp() {
        // given
        LocalDate localDate = LocalDate.of(2019, 8, 4);
        LocalDateToJsonTypeConverter resolver = new LocalDateToJsonTypeConverter(true);
        // when
        AbstractJsonType jsonObject = resolver.convertToJsonTypeOrEmpty(null, localDate, "some.field").get();
        // then
        assertThat(jsonObject).isNotNull();
        NumberJsonType numberJsonType = (NumberJsonType) jsonObject;
        assertThat(numberJsonType.toString()).isEqualTo("1564876800");
    }

    @Test
    public void convertLocalDateToJsonObject() {
        // given
        LocalDate localDate = LocalDate.of(2019, 8, 4);
        LocalDateToJsonTypeConverter resolver = new LocalDateToJsonTypeConverter(false);
        // when
// Path: src/main/java/pl/jalokim/propertiestojson/object/AbstractJsonType.java
// public abstract class AbstractJsonType {
// 
//     /**
//      * This one simply concatenate to rest of json. Simply speaking when will not converted then will not create whole json correctly.
//      *
//      * @return string for part of json.
//      */
//     public abstract String toStringJson();
// 
//     @Override
//     public final String toString() {
//         return toStringJson();
//     }
// }
// 
// Path: src/main/java/pl/jalokim/propertiestojson/object/NumberJsonType.java
// public class NumberJsonType extends PrimitiveJsonType<Number> {
// 
//     public NumberJsonType(Number value) {
//         super(value);
//     }
// }
// 
// Path: src/main/java/pl/jalokim/propertiestojson/object/ObjectJsonType.java
// public class ObjectJsonType extends AbstractJsonType implements MergableObject<ObjectJsonType> {
// 
//     @SuppressWarnings("PMD.UseConcurrentHashMap")
//     private final Map<String, AbstractJsonType> fields = new LinkedHashMap<>();
// 
//     public void addField(final String field, final AbstractJsonType object, PathMetadata currentPathMetaData) {
//         if (object instanceof SkipJsonField) {
//             return;
//         }
// 
//         AbstractJsonType oldFieldValue = fields.get(field);
//         if (oldFieldValue == null) {
//             fields.put(field, object);
//         } else {
//             if (oldFieldValue instanceof MergableObject && object instanceof MergableObject) {
//                 mergeObjectIfPossible(oldFieldValue, object, currentPathMetaData);
//             } else {
//                 throw new CannotOverrideFieldException(currentPathMetaData.getCurrentFullPath(),
//                     oldFieldValue,
//                     currentPathMetaData.getOriginalPropertyKey());
//             }
//         }
//     }
// 
//     public boolean containsField(String field) {
//         return fields.containsKey(field);
//     }
// 
//     public AbstractJsonType getField(String field) {
//         return fields.get(field);
//     }
// 
//     public ArrayJsonType getJsonArray(String field) {
//         return (ArrayJsonType) fields.get(field);
//     }
// 
//     @Override
//     public String toStringJson() {
//         StringBuilder result = new StringBuilder().append(JSON_OBJECT_START);
//         int index = 0;
//         int lastIndex = getLastIndex(fields.keySet());
//         for (Map.Entry<String, AbstractJsonType> entry : fields.entrySet()) {
//             AbstractJsonType object = entry.getValue();
//             String lastSign = index == lastIndex ? EMPTY_STRING : NEW_LINE_SIGN;
//             result.append(StringToJsonStringWrapper.wrap(entry.getKey()))
//                 .append(':')
//                 .append(object.toStringJson())
//                 .append(lastSign);
//             index++;
//         }
//         result.append(JSON_OBJECT_END);
//         return result.toString();
//     }
// 
//     @Override
//     public void merge(ObjectJsonType mergeWith, PathMetadata currentPathMetadata) {
//         for (String fieldName : mergeWith.fields.keySet()) {
//             addField(fieldName, mergeWith.getField(fieldName), currentPathMetadata);
//         }
//     }
// }


// Path: src/test/java/pl/jalokim/propertiestojson/resolvers/primitives/custom/LocalDateToJsonTypeConverterTest.java
import static org.assertj.core.api.Assertions.assertThat;
import java.time.LocalDate;
import org.junit.Test;
import pl.jalokim.propertiestojson.object.AbstractJsonType;
import pl.jalokim.propertiestojson.object.NumberJsonType;
import pl.jalokim.propertiestojson.object.ObjectJsonType;

package pl.jalokim.propertiestojson.resolvers.primitives.custom;



public class LocalDateToJsonTypeConverterTest {

    @Test
    public void convertLocalDateToUtcTimestamp() {
        // given
        LocalDate localDate = LocalDate.of(2019, 8, 4);
        LocalDateToJsonTypeConverter resolver = new LocalDateToJsonTypeConverter(true);
        // when
        AbstractJsonType jsonObject = resolver.convertToJsonTypeOrEmpty(null, localDate, "some.field").get();
        // then
        assertThat(jsonObject).isNotNull();
        NumberJsonType numberJsonType = (NumberJsonType) jsonObject;
        assertThat(numberJsonType.toString()).isEqualTo("1564876800");
    }

    @Test
    public void convertLocalDateToJsonObject() {
        // given
        LocalDate localDate = LocalDate.of(2019, 8, 4);
        LocalDateToJsonTypeConverter resolver = new LocalDateToJsonTypeConverter(false);
        // when
        AbstractJsonType jsonObject = resolver.convertToJsonTypeOrEmpty(null, localDate, "some.field").get();