// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Wembley.java
// public class Wembley extends Fraggle {
//     public Wembley(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
//                    @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
//                    @JsonProperty(value = JOB_KEY) Optional<Job> job) {
//         super(hairColour, wearsHats, job);
//     }
// 
//     @Override
//     public FraggleName getFraggleName() {
//         return FraggleName.WEMBLEY;
//     }
// }
// 
// Path: examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
// public enum FraggleName {
//     WEMBLEY, BOOBER
// }
// 
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Boober.java
// public class Boober extends Fraggle {
//     public Boober(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
//                   @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
//                   @JsonProperty(value = JOB_KEY) Optional<Job> job) {
//         super(hairColour, wearsHats, job);
//     }
// 
//     @Override
//     public FraggleName getFraggleName() {
//         return FraggleName.BOOBER;
//     }
// }


import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.github.peckb1.examples.base.fraggles.Wembley;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.base.Fraggle.FraggleName;
import com.github.peckb1.examples.base.fraggles.Boober;
import java.io.File;
import java.io.IOException;
import java.util.List;
package com.github.peckb1.examples.base;



public class TestBaseModel {

    private ObjectMapper objectMapper;

    @Before
    public void setUp() throws Exception {
        this.objectMapper = new ObjectMapper();
        this.objectMapper.registerModule(new Jdk8Module());
        this.objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
        this.objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
        AutoJacksonSetup.configureObjectMapper(this.objectMapper);
    }

    @Test
    public void testSimpleModel() throws IOException {
        File baseModelFile = new File("resources/base_model.json");
        FraggleList fraggleList = this.objectMapper.readValue(baseModelFile, FraggleList.class);

        checkFraggleList(fraggleList);

        String fraggleListJson = this.objectMapper.writeValueAsString(fraggleList);
        FraggleList fraggleListAgain = this.objectMapper.readValue(fraggleListJson, FraggleList.class);

        checkFraggleList(fraggleListAgain);
    }

    private void checkFraggleList(FraggleList fraggleListAgain) {
        List<Fraggle> fraggles = fraggleListAgain.getFraggles();
        checkBoober(fraggles.get(0));
        checkWembley(fraggles.get(1));
    }

    private void checkWembley(Fraggle fraggle) {
        Assert.assertTrue(fraggle instanceof Wembley);
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Wembley.java
// public class Wembley extends Fraggle {
//     public Wembley(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
//                    @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
//                    @JsonProperty(value = JOB_KEY) Optional<Job> job) {
//         super(hairColour, wearsHats, job);
//     }
// 
//     @Override
//     public FraggleName getFraggleName() {
//         return FraggleName.WEMBLEY;
//     }
// }
// 
// Path: examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
// public enum FraggleName {
//     WEMBLEY, BOOBER
// }
// 
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Boober.java
// public class Boober extends Fraggle {
//     public Boober(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
//                   @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
//                   @JsonProperty(value = JOB_KEY) Optional<Job> job) {
//         super(hairColour, wearsHats, job);
//     }
// 
//     @Override
//     public FraggleName getFraggleName() {
//         return FraggleName.BOOBER;
//     }
// }


// Path: examples/src/test/java/com/github/peckb1/examples/base/TestBaseModel.java
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.github.peckb1.examples.base.fraggles.Wembley;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.base.Fraggle.FraggleName;
import com.github.peckb1.examples.base.fraggles.Boober;
import java.io.File;
import java.io.IOException;
import java.util.List;

package com.github.peckb1.examples.base;



public class TestBaseModel {

    private ObjectMapper objectMapper;

    @Before
    public void setUp() throws Exception {
        this.objectMapper = new ObjectMapper();
        this.objectMapper.registerModule(new Jdk8Module());
        this.objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
        this.objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
        AutoJacksonSetup.configureObjectMapper(this.objectMapper);
    }

    @Test
    public void testSimpleModel() throws IOException {
        File baseModelFile = new File("resources/base_model.json");
        FraggleList fraggleList = this.objectMapper.readValue(baseModelFile, FraggleList.class);

        checkFraggleList(fraggleList);

        String fraggleListJson = this.objectMapper.writeValueAsString(fraggleList);
        FraggleList fraggleListAgain = this.objectMapper.readValue(fraggleListJson, FraggleList.class);

        checkFraggleList(fraggleListAgain);
    }

    private void checkFraggleList(FraggleList fraggleListAgain) {
        List<Fraggle> fraggles = fraggleListAgain.getFraggles();
        checkBoober(fraggles.get(0));
        checkWembley(fraggles.get(1));
    }

    private void checkWembley(Fraggle fraggle) {
        Assert.assertTrue(fraggle instanceof Wembley);
        Assert.assertEquals(FraggleName.WEMBLEY, fraggle.getFraggleName());