// Path: src/test/java/org/hildan/fxgson/test/Expectation.java
// public class Expectation<T> {
// 
//     public final T object;
// 
//     public final String json;
// 
//     public Expectation(T object, String json) {
//         this.object = object;
//         this.json = json;
//     }
// 
//     @Override
//     public String toString() {
//         return "Expectation{" + "object=" + object + ", json='" + json + '\'' + '}';
//     }
// }
// 
// Path: src/test/java/org/hildan/fxgson/test/TestUtils.java
// public class TestUtils {
// 
//     public static <T> void testWrite(TypeAdapter<T> adapter, Expectation<T> expectation) throws IOException {
//         StringWriter strWriter = new StringWriter();
//         JsonWriter jsonWriter = new JsonWriter(strWriter);
//         adapter.write(jsonWriter, expectation.object);
//         assertEquals(expectation.json, strWriter.toString());
//     }
// 
//     public static <T> void testRead(TypeAdapter<T> adapter, Expectation<T> expectation) throws IOException {
//         StringReader strReader = new StringReader(expectation.json);
//         JsonReader jsonReader = new JsonReader(strReader);
//         T deserializedValue = adapter.read(jsonReader);
//         assertEquals(expectation.object, deserializedValue);
//     }
// 
//     public static void assertCannotBeInstantiated(Class<?> cls) {
//         try {
//             final Constructor<?> c = cls.getDeclaredConstructors()[0];
//             c.setAccessible(true);
//             c.newInstance();
//             fail();
//         } catch (InvocationTargetException ite) {
//             Throwable targetException = ite.getTargetException();
//             assertNotNull(targetException);
//             assertEquals(targetException.getClass(), InstantiationException.class);
//         } catch (IllegalAccessException e) {
//             fail("the constructor is made accessible in the test, this should not happen");
//         } catch (InstantiationException e) {
//             fail("this test is not expected to be run on abstract classes");
//         }
//     }
// }


import java.io.IOException;
import java.io.StringReader;
import javafx.scene.paint.Color;
import com.google.gson.stream.JsonReader;
import org.hildan.fxgson.test.Expectation;
import org.hildan.fxgson.test.TestUtils;
import org.junit.Test;
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;
package org.hildan.fxgson.adapters.extras;




@RunWith(Theories.class)
public class ColorTypeAdapterTest {

    private static class ColorExpectation extends Expectation<Color> {
        ColorExpectation(Color value, String json) {
            super(value, json);
        }
    }

    @DataPoints
    public static Expectation<Color>[] expectations() {
        return new ColorExpectation[]{
                new ColorExpectation(Color.BLUE, "\"#0000ffff\""),
                new ColorExpectation(Color.RED, "\"#ff0000ff\""),
                new ColorExpectation(null, "null"),
        };
    }

    @Theory
    public void write(ColorExpectation expectation) throws IOException {
        TestUtils.testWrite(new ColorTypeAdapter(), expectation);
    }

    @Theory
    public void read(ColorExpectation expectation) throws IOException {
        TestUtils.testRead(new ColorTypeAdapter(), expectation);
    }

    @Test(expected = ColorTypeAdapter.InvalidColorException.class)
// Path: src/test/java/org/hildan/fxgson/test/Expectation.java
// public class Expectation<T> {
// 
//     public final T object;
// 
//     public final String json;
// 
//     public Expectation(T object, String json) {
//         this.object = object;
//         this.json = json;
//     }
// 
//     @Override
//     public String toString() {
//         return "Expectation{" + "object=" + object + ", json='" + json + '\'' + '}';
//     }
// }
// 
// Path: src/test/java/org/hildan/fxgson/test/TestUtils.java
// public class TestUtils {
// 
//     public static <T> void testWrite(TypeAdapter<T> adapter, Expectation<T> expectation) throws IOException {
//         StringWriter strWriter = new StringWriter();
//         JsonWriter jsonWriter = new JsonWriter(strWriter);
//         adapter.write(jsonWriter, expectation.object);
//         assertEquals(expectation.json, strWriter.toString());
//     }
// 
//     public static <T> void testRead(TypeAdapter<T> adapter, Expectation<T> expectation) throws IOException {
//         StringReader strReader = new StringReader(expectation.json);
//         JsonReader jsonReader = new JsonReader(strReader);
//         T deserializedValue = adapter.read(jsonReader);
//         assertEquals(expectation.object, deserializedValue);
//     }
// 
//     public static void assertCannotBeInstantiated(Class<?> cls) {
//         try {
//             final Constructor<?> c = cls.getDeclaredConstructors()[0];
//             c.setAccessible(true);
//             c.newInstance();
//             fail();
//         } catch (InvocationTargetException ite) {
//             Throwable targetException = ite.getTargetException();
//             assertNotNull(targetException);
//             assertEquals(targetException.getClass(), InstantiationException.class);
//         } catch (IllegalAccessException e) {
//             fail("the constructor is made accessible in the test, this should not happen");
//         } catch (InstantiationException e) {
//             fail("this test is not expected to be run on abstract classes");
//         }
//     }
// }


// Path: src/test/java/org/hildan/fxgson/adapters/extras/ColorTypeAdapterTest.java
import java.io.IOException;
import java.io.StringReader;
import javafx.scene.paint.Color;
import com.google.gson.stream.JsonReader;
import org.hildan.fxgson.test.Expectation;
import org.hildan.fxgson.test.TestUtils;
import org.junit.Test;
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;

package org.hildan.fxgson.adapters.extras;




@RunWith(Theories.class)
public class ColorTypeAdapterTest {

    private static class ColorExpectation extends Expectation<Color> {
        ColorExpectation(Color value, String json) {
            super(value, json);
        }
    }

    @DataPoints
    public static Expectation<Color>[] expectations() {
        return new ColorExpectation[]{
                new ColorExpectation(Color.BLUE, "\"#0000ffff\""),
                new ColorExpectation(Color.RED, "\"#ff0000ff\""),
                new ColorExpectation(null, "null"),
        };
    }

    @Theory
    public void write(ColorExpectation expectation) throws IOException {
        TestUtils.testWrite(new ColorTypeAdapter(), expectation);
    }

    @Theory
    public void read(ColorExpectation expectation) throws IOException {
        TestUtils.testRead(new ColorTypeAdapter(), expectation);
    }

    @Test(expected = ColorTypeAdapter.InvalidColorException.class)
    public void read_invalid() throws IOException {