MockDataSource { public static String getFakeWifiData() { long time = JoH.tsl(); double divisor_scale = 5000000; double mod_raw = (time / divisor_scale) % Math.PI; double mod_filtered = ((time - 500000) / divisor_scale) % Math.PI; double raw_value = (Math.sin(mod_raw) * 100000) + 50000; double filtered_value = (Math.sin(mod_filtered) * 100000) + 50000; if (Pref.getBooleanDefaultFalse(PREF_BROKEN_RAW)) { raw_value = Math.sin(mod_raw) * 1000; } final JSONObject json = new JSONObject(); try { json.put("CaptureDateTime", time); json.put("RelativeTime", 0L); json.put("TransmitterId", "123456"); json.put("RawValue", (long) raw_value); json.put("FilteredValue", (long) filtered_value); json.put("BatteryLife", "100"); json.put("ReceivedSignalStrength", 1); json.put("TransmissionId", 1); } catch (JSONException e) { UserError.Log.e(TAG, "Got weird Json exception: ", e); } return json.toString(); }  static String getFakeWifiData(); static void breakRaw(); static void fixRaw();  }
@Test public void test_getFakeWifiData() { final String str = MockDataSource.getFakeWifiData(); log("Mock Data: " + str); assertThat("Data not null", str != null, is(true)); assertThat("Marker found", str.contains("RelativeTime"), is(true)); final Gson gson = new GsonBuilder().create(); final TransmitterRawData trd = gson.fromJson(str, TransmitterRawData.class); log(trd.toTableString()); assertThat("Sane Raw", trd.getRawValue() < RAW_UPPER_BOUND && trd.getRawValue() > RAW_LOWER_BOUND, is(true)); assertThat("Sane Filtered", trd.getFilteredValue() < RAW_UPPER_BOUND && trd.getFilteredValue() > RAW_LOWER_BOUND, is(true)); }