/modules/plugin/mongodb/src/test/java/org/geotools/data/mongodb/MongoTestUtil.java

https://github.com/geotools/geotools · Java · 34 lines · 12 code · 4 blank · 18 comment · 0 complexity · f004d3fca551f85e82655b19cf34def6 MD5 · raw file

  1. /*
  2. * GeoTools - The Open Source Java GIS Toolkit
  3. * http://geotools.org
  4. *
  5. * (C) 2015, Open Source Geospatial Foundation (OSGeo)
  6. * (C) 2014-2015, Boundless
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation;
  11. * version 2.1 of the License.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. */
  18. package org.geotools.data.mongodb;
  19. import com.google.gson.GsonBuilder;
  20. import com.google.gson.JsonParser;
  21. import com.mongodb.DBObject;
  22. /** @author tkunicki@boundlessgeo.com */
  23. public class MongoTestUtil {
  24. public static String prettyPrint(DBObject dbo) {
  25. return prettyPrint(dbo.toString());
  26. }
  27. public static String prettyPrint(String json) {
  28. return new GsonBuilder().setPrettyPrinting().create().toJson(new JsonParser().parse(json));
  29. }
  30. }