// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/StandardVariable.java
// public class StandardVariable {
//     public String result;
//     public String id;
// 
//     public StandardVariable(String result,
//                             String id) {
//         this.result = result;
//         this.id = id;
//     }
// }
// 
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java
// public class User {
//     public enum Gender { MALE, FEMALE };
// 
//     public static class Name {
//         private String _first, _last;
// 
//         public String getFirst() { return _first; }
//         public String getLast() { return _last; }
// 
//         public void setFirst(String s) { _first = s; }
//         public void setLast(String s) { _last = s; }
//     }
// 
//     private Gender _gender;
//     private Name _name;
//     private boolean _isVerified;
//     private byte[] _userImage;
// 
//     public Name getName() { return _name; }
//     public boolean isVerified() { return _isVerified; }
//     public Gender getGender() { return _gender; }
//     public byte[] getUserImage() { return _userImage; }
// 
//     public void setName(Name n) { _name = n; }
//     public void setVerified(boolean b) { _isVerified = b; }
//     public void setGender(Gender g) { _gender = g; }
//     public void setUserImage(byte[] b) { _userImage = b; }
// }
// 
// Path: src/main/java/com/github/agiledon/sisyphus/Fixture.java
// public static Composer from(String resourceName) {
//     String fileExtension = Files.getFileExtension(resourceName);
//     Composer composer = composers.get(fileExtension);
//     if (composer == null) {
//         composer = createComposer(fileExtension);
//         composers.put(fileExtension, composer);
//     }
//     composer.setResourceName(resourceName);
//     return composer;
// }


import com.github.agiledon.sisyphus.domain.json.StandardVariable;
import com.github.agiledon.sisyphus.domain.json.User;
import com.google.common.base.Objects;
import org.junit.Test;
import java.util.List;
import static com.github.agiledon.sisyphus.Fixture.from;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.core.IsNot.not;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
                .to(User.class);
        assertThat(user, not(nullValue()));
        assertUserName(user, "Joe", "Sixpack");
    }

    @Test
    public void should_compose_multi_user_data_by_parsing_template_file() {
        List<User> users = Fixture.from("userWithMultiSections.json")
                                  .withTemplate("template/user.template")
                                  .toList(User.class);
        assertThat(users, not(nullValue()));

        User firstUser = users.get(0);
        assertUserName(firstUser, "Joe", "Sixpack");

        User thirdUser = users.get(2);
        assertUserName(thirdUser, "Yi", "Zhang");
    }

    private void assertUserName(User thirdUser, String yi, String zhang) {
        assertThat(thirdUser.getName().getFirst(), is(yi));
        assertThat(thirdUser.getName().getLast(), is(zhang));
    }


    @Test
    public void should_be_null_if_missing_variable_by_parsing_template_file() {
        User user = from("userWithTemplateMissingVariable.json")
                .withTemplate("template/user.template")
                .to(User.class);
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/StandardVariable.java
// public class StandardVariable {
//     public String result;
//     public String id;
// 
//     public StandardVariable(String result,
//                             String id) {
//         this.result = result;
//         this.id = id;
//     }
// }
// 
// Path: src/test/java/com/github/agiledon/sisyphus/domain/json/User.java
// public class User {
//     public enum Gender { MALE, FEMALE };
// 
//     public static class Name {
//         private String _first, _last;
// 
//         public String getFirst() { return _first; }
//         public String getLast() { return _last; }
// 
//         public void setFirst(String s) { _first = s; }
//         public void setLast(String s) { _last = s; }
//     }
// 
//     private Gender _gender;
//     private Name _name;
//     private boolean _isVerified;
//     private byte[] _userImage;
// 
//     public Name getName() { return _name; }
//     public boolean isVerified() { return _isVerified; }
//     public Gender getGender() { return _gender; }
//     public byte[] getUserImage() { return _userImage; }
// 
//     public void setName(Name n) { _name = n; }
//     public void setVerified(boolean b) { _isVerified = b; }
//     public void setGender(Gender g) { _gender = g; }
//     public void setUserImage(byte[] b) { _userImage = b; }
// }
// 
// Path: src/main/java/com/github/agiledon/sisyphus/Fixture.java
// public static Composer from(String resourceName) {
//     String fileExtension = Files.getFileExtension(resourceName);
//     Composer composer = composers.get(fileExtension);
//     if (composer == null) {
//         composer = createComposer(fileExtension);
//         composers.put(fileExtension, composer);
//     }
//     composer.setResourceName(resourceName);
//     return composer;
// }


// Path: src/test/java/com/github/agiledon/sisyphus/JsonFixtureTest.java
import com.github.agiledon.sisyphus.domain.json.StandardVariable;
import com.github.agiledon.sisyphus.domain.json.User;
import com.google.common.base.Objects;
import org.junit.Test;
import java.util.List;
import static com.github.agiledon.sisyphus.Fixture.from;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.core.IsNot.not;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;

                .to(User.class);
        assertThat(user, not(nullValue()));
        assertUserName(user, "Joe", "Sixpack");
    }

    @Test
    public void should_compose_multi_user_data_by_parsing_template_file() {
        List<User> users = Fixture.from("userWithMultiSections.json")
                                  .withTemplate("template/user.template")
                                  .toList(User.class);
        assertThat(users, not(nullValue()));

        User firstUser = users.get(0);
        assertUserName(firstUser, "Joe", "Sixpack");

        User thirdUser = users.get(2);
        assertUserName(thirdUser, "Yi", "Zhang");
    }

    private void assertUserName(User thirdUser, String yi, String zhang) {
        assertThat(thirdUser.getName().getFirst(), is(yi));
        assertThat(thirdUser.getName().getLast(), is(zhang));
    }


    @Test
    public void should_be_null_if_missing_variable_by_parsing_template_file() {
        User user = from("userWithTemplateMissingVariable.json")
                .withTemplate("template/user.template")
                .to(User.class);
        assertThat(user, is(nullValue()));