// 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.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
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 FontTypeAdapterTest {

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

    @DataPoints
    public static FontExpectation[] expectations() {
        // no exotic fonts as the test must pass on most machines
        return new FontExpectation[]{
                new FontExpectation(Font.font("System", FontWeight.NORMAL, 12.0), "\"System,Regular,12.0\""),
                new FontExpectation(Font.font("SansSerif", FontWeight.BOLD, 10.0), "\"SansSerif,Bold,10.0\""),
                new FontExpectation(Font.font("System", FontPosture.ITALIC, 10.0), "\"System,Italic,10.0\""),
                new FontExpectation(Font.font("System", FontWeight.BOLD, FontPosture.ITALIC, 10.0),
                        "\"System,Bold Italic,10.0\""),
                new FontExpectation(Font.font("SansSerif", FontWeight.BOLD, FontPosture.ITALIC, 20.0),
                        "\"SansSerif,Bold Italic,20.0\""),
                new FontExpectation(null, "null"),
        };
    }

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

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

// 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/FontTypeAdapterTest.java
import java.io.IOException;
import java.io.StringReader;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
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 FontTypeAdapterTest {

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

    @DataPoints
    public static FontExpectation[] expectations() {
        // no exotic fonts as the test must pass on most machines
        return new FontExpectation[]{
                new FontExpectation(Font.font("System", FontWeight.NORMAL, 12.0), "\"System,Regular,12.0\""),
                new FontExpectation(Font.font("SansSerif", FontWeight.BOLD, 10.0), "\"SansSerif,Bold,10.0\""),
                new FontExpectation(Font.font("System", FontPosture.ITALIC, 10.0), "\"System,Italic,10.0\""),
                new FontExpectation(Font.font("System", FontWeight.BOLD, FontPosture.ITALIC, 10.0),
                        "\"System,Bold Italic,10.0\""),
                new FontExpectation(Font.font("SansSerif", FontWeight.BOLD, FontPosture.ITALIC, 20.0),
                        "\"SansSerif,Bold Italic,20.0\""),
                new FontExpectation(null, "null"),
        };
    }

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

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

    @Test(expected = FontTypeAdapter.InvalidFontException.class)