}
@Test
public void buildFromGetReponse() {
// Setup
GetResponse response = mock(GetResponse.class, Mockito.RETURNS_DEEP_STUBS);
when(response.getType()).thenReturn(ESEntityType.WAY.getIndiceName());
when(response.getId()).thenReturn("1");
Map<String, String> tags = new HashMap<String, String>();
tags.put("highway", "primary");
when(response.getField("tags").getValue()).thenReturn(tags);
List<List<List<Double>>> locations = new ArrayList<List<List<Double>>>();
ArrayList<List<Double>> subLocations = new ArrayList<List<Double>>();
subLocations.add(Arrays.asList(new Double[] { 2.0, 1.0 }));
subLocations.add(Arrays.asList(new Double[] { 3.0, 2.0 }));
locations.add(subLocations);
@SuppressWarnings("unchecked")
Map<String, Object> shape = mock(Map.class);
when(shape.get("type")).thenReturn("polygon");
when(shape.get("coordinates")).thenReturn(locations);
when(response.getField("shape").getValue()).thenReturn(shape);
when(response.getField("centroid").getValue()).thenReturn(Arrays.asList(new Double[] { 2.5, 1.5 }));
when(response.getField("lengthKm").getValue()).thenReturn(157.25358982950198d);
when(response.getField("areaKm2").getValue()).thenReturn(0d);
ESWay expected = ESWay.Builder.create().id(1l)
.addLocation(1.0, 2.0).addLocation(2.0, 3.0)
.addTag("highway", "primary").build();