Segment { public static List<Segment> parseSegments(InputStream in) { BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); Gson gson = new Gson(); return gson.fromJson(reader, new TypeToken<List<Segment>>() {}.getType()); } catch (UnsupportedEncodingException e) { return new ArrayList<Segment>(); } }  Date getLastUpdate(); void setLastUpdate(Date lastUpdate); Integer getColorId(); void setColorId(Integer colorId); String getName(); void setName(String name); List<IE6GeoPoint> getCoords(); void setCoords(List<IE6GeoPoint> coords); static List<Segment> parseSegments(InputStream in);  }
@Test public void parseSegments() { InputStream is = this.getClass().getResourceAsStream( "/segments.json"); List<Segment> segs = Segment.parseSegments(is); assertNotNull(segs); assertEquals(3, segs.size()); assertEquals(5, segs.get(2).coords.size()); assertEquals("80", segs.get(2).name); assertNull(segs.get(0).getColorId()); }