@Test
public void testWriteFeatureCollectionToJsonString() throws
                                                     Exception {

    // given Feature1 as Point
    final Feature feature1 = mock(Feature.class);
    doReturn("id1").when(feature1)
                   .getId();
    doReturn("Feature").when(feature1)
                       .getType();
    doReturn(createPoint(gf,
                         47.2256258d,
                         -1.5545135d)).when(feature1)
                                      .getGeometry();
    doReturn(new Bundle()).when(feature1)
                          .getProperties();
    // given Feature2 as MultiPoint
    final Feature feature2 = mock(Feature.class);
    doReturn("id2").when(feature2)
                   .getId();
    doReturn("Feature").when(feature2)
                       .getType();
    doReturn(createMultiPoint(gf,
                              createPoint(gf,
                                          47.2256258d,
                                          -1.5545135d),
                              createPoint(gf,
                                          47.225136d,
                                          -1.553913d))).when(feature2)
                                                       .getGeometry();
    doReturn(new Bundle()).when(feature2)
                          .getProperties();
    // given Feature3 as LineString
    final Feature feature3 = mock(Feature.class);
    doReturn("id3").when(feature3)
                   .getId();
    doReturn("Feature").when(feature3)
                       .getType();
    doReturn(createLineString(gf,
                              createCoordinate(gf,
                                               47.2256258d,
                                               -1.5545135d),
                              createCoordinate(gf,
                                               47.225136d,
                                               -1.553913d))).when(feature3)
                                                            .getGeometry();
    doReturn(new Bundle()).when(feature3)
                          .getProperties();
    // given Feature4 as MultiLineString
    final Feature feature4 = mock(Feature.class);
    doReturn("id4").when(feature4)
                   .getId();
    doReturn("Feature").when(feature4)
                       .getType();
    doReturn(createMultiLineString(gf,
                                   createLineString(gf,
                                                    createCoordinate(gf,
                                                                     47.2256258d,
                                                                     -1.5545135d),
                                                    createCoordinate(gf,
                                                                     47.225136d,
                                                                     -1.553913d)))).when(feature4)
                                                                                   .getGeometry();
    doReturn(new Bundle()).when(feature4)
                          .getProperties();
    // given Feature5 as simple Polygon
    final Feature feature5 = mock(Feature.class);
    doReturn("id5").when(feature5)
                   .getId();
    doReturn("Feature").when(feature5)
                       .getType();
    doReturn(createPolygon(gf,
                           createCoordinate(gf,
                                            47.226219d,
                                            -1.554430d),
                           createCoordinate(gf,
                                            47.226237d,
                                            -1.554261d),
                           createCoordinate(gf,
                                            47.226122d,
                                            -1.554245d),
                           createCoordinate(gf,
                                            47.226106d,
                                            -1.554411d),
                           createCoordinate(gf,
                                            47.226219d,
                                            -1.554430d))).when(feature5)
                                                         .getGeometry();
    doReturn(new Bundle()).when(feature5)
                          .getProperties();
    // given a FeatureCollection
    final FeatureCollection featureCollection = mock(FeatureCollection.class);
    doReturn("FeatureCollection").when(featureCollection)
                                 .getType();
    doReturn(asList(feature1,
                    feature2,
                    feature3,
                    feature4,
                    feature5)).when(featureCollection)
                              .getFeatures();
    // when write this FeatureCollection as JSON string
    final String json = geoJsonWriter.write(featureCollection);
    // then
    assertNotNull(json);
    assertEquals(TestHelper.getFixture("featurecollection.json"),
                 json);
}