// Path: src/main/java/com/github/jsonj/tools/JsonBuilder.java
// public static @Nonnull JsonArray array() {
//     return new JsonArray();
// }
// 
// Path: src/main/java/com/github/jsonj/tools/JsonBuilder.java
// public static @Nonnull Entry<String,JsonElement> field(String key, JsonElement value) {
//     Entry<String, JsonElement> entry = new Entry<String,JsonElement>() {
// 
//         @Override
//         public String getKey() {
//             return key;
//         }
// 
//         @Override
//         public JsonElement getValue() {
//             return value;
//         }
// 
//         @Override
//         public JsonElement setValue(JsonElement value) {
//             throw new UnsupportedOperationException("entries are immutable");
//         }};
//         return entry;
// }
// 
// Path: src/main/java/com/github/jsonj/tools/JsonBuilder.java
// public static @Nonnull JsonBuilder object() {
//     return new JsonBuilder();
// }


import static com.github.jsonj.tools.JsonBuilder.array;
import static com.github.jsonj.tools.JsonBuilder.field;
import static com.github.jsonj.tools.JsonBuilder.object;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.StreamSupport;
import org.testng.annotations.Test;
package com.github.jsonj;



@Test
public class JsonjCollectorsTest {
    public void shouldStreamAndCollectInArray() {
        JsonArray array = array(1,2,3,4,5,6,7,8,9);
        JsonArray array2 = array.stream().collect(JsonjCollectors.array());
        assertThat(array2, is(array2));
    }

    public void shouldStreamAndCollectObjectsInArray() {
        JsonArray array = array(object(field("1",1)), object(field("2",2)));
        JsonArray array2 = array.stream().collect(JsonjCollectors.array());
        assertThat(array, is(array2));
    }

    public void shouldStreamAndCollectObjectsIntoArray() {
        Object[] os = new Object[] {"", 1, null};
        Spliterator<Object> spliterator = Spliterators.spliterator(os, Spliterator.ORDERED);
        JsonArray array = StreamSupport.stream(spliterator, false).collect(JsonjCollectors.array());
        assertThat(array.size(), is(3));
    }

    public void shouldStreamAndCollectInSet() {
        JsonArray array = array(1,2,1,2);
        JsonSet set = array.stream().collect(JsonjCollectors.set());
        assertThat(array, not(is(set)));
        assertThat(set.size(), is(2));
    }

    public void shouldStreamAndCollectObjectsInSet() {
// Path: src/main/java/com/github/jsonj/tools/JsonBuilder.java
// public static @Nonnull JsonArray array() {
//     return new JsonArray();
// }
// 
// Path: src/main/java/com/github/jsonj/tools/JsonBuilder.java
// public static @Nonnull Entry<String,JsonElement> field(String key, JsonElement value) {
//     Entry<String, JsonElement> entry = new Entry<String,JsonElement>() {
// 
//         @Override
//         public String getKey() {
//             return key;
//         }
// 
//         @Override
//         public JsonElement getValue() {
//             return value;
//         }
// 
//         @Override
//         public JsonElement setValue(JsonElement value) {
//             throw new UnsupportedOperationException("entries are immutable");
//         }};
//         return entry;
// }
// 
// Path: src/main/java/com/github/jsonj/tools/JsonBuilder.java
// public static @Nonnull JsonBuilder object() {
//     return new JsonBuilder();
// }


// Path: src/test/java/com/github/jsonj/JsonjCollectorsTest.java
import static com.github.jsonj.tools.JsonBuilder.array;
import static com.github.jsonj.tools.JsonBuilder.field;
import static com.github.jsonj.tools.JsonBuilder.object;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.StreamSupport;
import org.testng.annotations.Test;

package com.github.jsonj;



@Test
public class JsonjCollectorsTest {
    public void shouldStreamAndCollectInArray() {
        JsonArray array = array(1,2,3,4,5,6,7,8,9);
        JsonArray array2 = array.stream().collect(JsonjCollectors.array());
        assertThat(array2, is(array2));
    }

    public void shouldStreamAndCollectObjectsInArray() {
        JsonArray array = array(object(field("1",1)), object(field("2",2)));
        JsonArray array2 = array.stream().collect(JsonjCollectors.array());
        assertThat(array, is(array2));
    }

    public void shouldStreamAndCollectObjectsIntoArray() {
        Object[] os = new Object[] {"", 1, null};
        Spliterator<Object> spliterator = Spliterators.spliterator(os, Spliterator.ORDERED);
        JsonArray array = StreamSupport.stream(spliterator, false).collect(JsonjCollectors.array());
        assertThat(array.size(), is(3));
    }

    public void shouldStreamAndCollectInSet() {
        JsonArray array = array(1,2,1,2);
        JsonSet set = array.stream().collect(JsonjCollectors.set());
        assertThat(array, not(is(set)));
        assertThat(set.size(), is(2));
    }

    public void shouldStreamAndCollectObjectsInSet() {
        JsonArray array = array(object(field("1",1)), object(field("1",1)));