@Test public void locationFeaturesInterpreterTest() { LocationRecord locationRecord = LocationRecord.newBuilder().setId("777").build(); LocationFeatureRecord record = LocationFeatureRecord.newBuilder().setId("777").build(); KeyValueStore<LatLng, String> kvStore = new KeyValueStore<LatLng, String>() { @Override public String get(LatLng latLng) { return "{\"layers: \"{\"cb1\":\"1\",\"cb2\":\"2\",\"cb3\":\"3\"}}"; } @Override public void close() { } }; Map<String, String> resultMap = new HashMap<>(); resultMap.put("cb1", "1"); resultMap.put("cb2", "2"); resultMap.put("cb3", "3"); LocationFeatureRecord result = LocationFeatureRecord.newBuilder().setId("777").setItems(resultMap).build(); LocationFeatureInterpreter.interpret(kvStore).accept(locationRecord, record); Assert.assertEquals(result, record); }
public static BiConsumer<LocationRecord, LocationFeatureRecord> interpret( KeyValueStore<LatLng, String> kvStore) { return (lr, asr) -> { if (kvStore != null) { try { String json = kvStore.get(new LatLng(lr.getDecimalLatitude(), lr.getDecimalLongitude())); if (!Strings.isNullOrEmpty(json)) { json = json.substring(11, json.length() - 1); ObjectMapper objectMapper = new ObjectMapper(); Map<String, String> map = objectMapper.readValue(json, new TypeReference<HashMap<String, String>>() {}); asr.setItems(map); } } catch (NoSuchElementException | NullPointerException | IOException ex) { log.error(ex.getMessage(), ex); } } }; }
LocationFeatureInterpreter { public static BiConsumer<LocationRecord, LocationFeatureRecord> interpret( KeyValueStore<LatLng, String> kvStore) { return (lr, asr) -> { if (kvStore != null) { try { String json = kvStore.get(new LatLng(lr.getDecimalLatitude(), lr.getDecimalLongitude())); if (!Strings.isNullOrEmpty(json)) { json = json.substring(11, json.length() - 1); ObjectMapper objectMapper = new ObjectMapper(); Map<String, String> map = objectMapper.readValue(json, new TypeReference<HashMap<String, String>>() {}); asr.setItems(map); } } catch (NoSuchElementException | NullPointerException | IOException ex) { log.error(ex.getMessage(), ex); } } }; } }
LocationFeatureInterpreter { public static BiConsumer<LocationRecord, LocationFeatureRecord> interpret( KeyValueStore<LatLng, String> kvStore) { return (lr, asr) -> { if (kvStore != null) { try { String json = kvStore.get(new LatLng(lr.getDecimalLatitude(), lr.getDecimalLongitude())); if (!Strings.isNullOrEmpty(json)) { json = json.substring(11, json.length() - 1); ObjectMapper objectMapper = new ObjectMapper(); Map<String, String> map = objectMapper.readValue(json, new TypeReference<HashMap<String, String>>() {}); asr.setItems(map); } } catch (NoSuchElementException | NullPointerException | IOException ex) { log.error(ex.getMessage(), ex); } } }; }  }
LocationFeatureInterpreter { public static BiConsumer<LocationRecord, LocationFeatureRecord> interpret( KeyValueStore<LatLng, String> kvStore) { return (lr, asr) -> { if (kvStore != null) { try { String json = kvStore.get(new LatLng(lr.getDecimalLatitude(), lr.getDecimalLongitude())); if (!Strings.isNullOrEmpty(json)) { json = json.substring(11, json.length() - 1); ObjectMapper objectMapper = new ObjectMapper(); Map<String, String> map = objectMapper.readValue(json, new TypeReference<HashMap<String, String>>() {}); asr.setItems(map); } } catch (NoSuchElementException | NullPointerException | IOException ex) { log.error(ex.getMessage(), ex); } } }; }  static BiConsumer<LocationRecord, LocationFeatureRecord> interpret(
      KeyValueStore<LatLng, String> kvStore); }
LocationFeatureInterpreter { public static BiConsumer<LocationRecord, LocationFeatureRecord> interpret( KeyValueStore<LatLng, String> kvStore) { return (lr, asr) -> { if (kvStore != null) { try { String json = kvStore.get(new LatLng(lr.getDecimalLatitude(), lr.getDecimalLongitude())); if (!Strings.isNullOrEmpty(json)) { json = json.substring(11, json.length() - 1); ObjectMapper objectMapper = new ObjectMapper(); Map<String, String> map = objectMapper.readValue(json, new TypeReference<HashMap<String, String>>() {}); asr.setItems(map); } } catch (NoSuchElementException | NullPointerException | IOException ex) { log.error(ex.getMessage(), ex); } } }; }  static BiConsumer<LocationRecord, LocationFeatureRecord> interpret(
      KeyValueStore<LatLng, String> kvStore);  }