TriggerLocation extends Trigger { @Override public synchronized String toJSON() { JSONObject o = new JSONObject(); try { o.put("type", TriggerLocation.class.getName()); JSONObject data = new JSONObject(); data.put("latitude", latitude.getValue()); data.put("longitude", longitude.getValue()); data.put("distance", distance.getValue()); data.put("name", name.getValue()); data.put("mode", modeSelected.getValue()); data.put("lastRun", lastRun); o.put("data", data); } catch (JSONException e) { log.error("Unhandled exception", e); } return o.toString(); } TriggerLocation(); private  TriggerLocation(TriggerLocation triggerLocation); @Override synchronized boolean shouldRun(); @Override synchronized String toJSON(); @Override int friendlyName(); @Override String friendlyDescription(); @Override Optional<Integer> icon(); @Override Trigger duplicate(); @Override void generateDialog(LinearLayout root, FragmentManager fragmentManager);  }
@Test public void toJSONTest() { TriggerLocation t = new TriggerLocation(); t.latitude.setValue(213); t.longitude.setValue(212); t.distance.setValue(2); t.modeSelected = t.modeSelected.setValue(InputLocationMode.Mode.OUTSIDE); Assert.assertEquals(locationJson, t.toJSON()); }