// Path: src/test/java/com/moozvine/detox/testtypes/SimpleType.java
// @GenerateDTO
// public interface SimpleType extends Serializable {
//   String getSomeString();
//   int getAnInt();
// }
// 
// Path: src/test/java/com/moozvine/detox/testtypes/TypeWithOptionalFields.java
// @GenerateDTO
// public interface TypeWithOptionalFields extends Serializable {
//   String getFirstRequiredField();
//   Date getSecondRequiredField();
//   @Nullable Integer getFirstOptionalField();
//   @Nullable Float getSecondOptionalField();
// }
// 
// Path: src/test/java/com/moozvine/detox/JsonTestUtil.java
// public static void assertJsonEquivalence(final String left, final String right) {
//   final JSONObject leftObj = new JSONObject(left);
//   final JSONObject rightObj = new JSONObject(right);
//   assertJsonEquivalence(leftObj, rightObj, null);
// }


import com.moozvine.detox.testtypes.SimpleType;
import com.moozvine.detox.testtypes.TypeWithOptionalFields;
import org.junit.Test;
import javax.annotation.Nullable;
import java.util.Date;
import static com.moozvine.detox.JsonTestUtil.assertJsonEquivalence;
package com.moozvine.detox;




public class TestInstanceGeneratorTest {
  private final TestInstanceGenerator generator = new TestInstanceGenerator();
  private final SerializationService serializationService = new AbstractSerializationService() {
    {
      registerSerializer(new StringSerializer<Date>(Date.class) {
        @Override public Date fromString(final String value) throws DeserializationException {
          return new Date(Long.parseLong(value));
        }

        @Override public String toJson(final Date value) {
          return String.valueOf(value.getTime());
        }
      });
    }
  };

  @Test
  public void simpleTest() throws Exception {
    final SimpleType simpleType = generator.generate(SimpleType.class);
    assertJsonEquivalence(
        "{\"serializedType\":\"com.moozvine.detox.testtypes.SimpleType\",\"someString\":\"some string\",\"anInt\":1234}",
        serializationService.serialize(simpleType));
  }

  @Test
  public void withAddedValueGeneratorForClass() throws Exception {
    generator.setValueGeneratorForClass(Date.class, new ValueGenerator<Date>() {
      @Nullable @Override public Date apply(final String input) {
        return new Date(0);
      }
    });

// Path: src/test/java/com/moozvine/detox/testtypes/SimpleType.java
// @GenerateDTO
// public interface SimpleType extends Serializable {
//   String getSomeString();
//   int getAnInt();
// }
// 
// Path: src/test/java/com/moozvine/detox/testtypes/TypeWithOptionalFields.java
// @GenerateDTO
// public interface TypeWithOptionalFields extends Serializable {
//   String getFirstRequiredField();
//   Date getSecondRequiredField();
//   @Nullable Integer getFirstOptionalField();
//   @Nullable Float getSecondOptionalField();
// }
// 
// Path: src/test/java/com/moozvine/detox/JsonTestUtil.java
// public static void assertJsonEquivalence(final String left, final String right) {
//   final JSONObject leftObj = new JSONObject(left);
//   final JSONObject rightObj = new JSONObject(right);
//   assertJsonEquivalence(leftObj, rightObj, null);
// }


// Path: src/test/java/com/moozvine/detox/TestInstanceGeneratorTest.java
import com.moozvine.detox.testtypes.SimpleType;
import com.moozvine.detox.testtypes.TypeWithOptionalFields;
import org.junit.Test;
import javax.annotation.Nullable;
import java.util.Date;
import static com.moozvine.detox.JsonTestUtil.assertJsonEquivalence;

package com.moozvine.detox;




public class TestInstanceGeneratorTest {
  private final TestInstanceGenerator generator = new TestInstanceGenerator();
  private final SerializationService serializationService = new AbstractSerializationService() {
    {
      registerSerializer(new StringSerializer<Date>(Date.class) {
        @Override public Date fromString(final String value) throws DeserializationException {
          return new Date(Long.parseLong(value));
        }

        @Override public String toJson(final Date value) {
          return String.valueOf(value.getTime());
        }
      });
    }
  };

  @Test
  public void simpleTest() throws Exception {
    final SimpleType simpleType = generator.generate(SimpleType.class);
    assertJsonEquivalence(
        "{\"serializedType\":\"com.moozvine.detox.testtypes.SimpleType\",\"someString\":\"some string\",\"anInt\":1234}",
        serializationService.serialize(simpleType));
  }

  @Test
  public void withAddedValueGeneratorForClass() throws Exception {
    generator.setValueGeneratorForClass(Date.class, new ValueGenerator<Date>() {
      @Nullable @Override public Date apply(final String input) {
        return new Date(0);
      }
    });

    final TypeWithOptionalFields object = generator.generate(TypeWithOptionalFields.class);