@Test public void getUrl_BasicLocation() throws Exception { Location loc = MockLocations.builder("GPS", 51.3579941, -0.1952438).withTime(1457205869949l).withAccuracy(20).build(); SerializableLocation sloc = new SerializableLocation(loc); PreferenceHelper pm = mock(PreferenceHelper.class); OpenGTSManager client = new OpenGTSManager(pm); URL url = new URL("http: assertThat("URL Generated from basic location", OpenGTSManager.getUrl("99","ACCT",sloc,"http","","example.com",9001, 0).toString() , is(url.toString())); }
public static String getUrl(String id, String accountName, SerializableLocation loc, String communication, String path, String server, int port, int batteryLevel) { List<AbstractMap.SimpleEntry<String,String>> qparams = new ArrayList<>(); qparams.add(new AbstractMap.SimpleEntry<>("id", id)); qparams.add(new AbstractMap.SimpleEntry<>("dev", id)); if (!Strings.isNullOrEmpty(accountName)) { qparams.add(new AbstractMap.SimpleEntry<>("acct", accountName)); } else { qparams.add(new AbstractMap.SimpleEntry<>("acct", id)); } qparams.add(new AbstractMap.SimpleEntry<>("batt", String.valueOf(batteryLevel))); qparams.add(new AbstractMap.SimpleEntry<>("code", "0xF020")); qparams.add(new AbstractMap.SimpleEntry<>("alt", String.valueOf(loc.getAltitude()))); qparams.add(new AbstractMap.SimpleEntry<>("gprmc", OpenGTSManager.gprmcEncode(loc))); if(path.startsWith("/")){ path = path.replaceFirst("/",""); } return String.format("%s: }
OpenGTSManager extends FileSender { public static String getUrl(String id, String accountName, SerializableLocation loc, String communication, String path, String server, int port, int batteryLevel) { List<AbstractMap.SimpleEntry<String,String>> qparams = new ArrayList<>(); qparams.add(new AbstractMap.SimpleEntry<>("id", id)); qparams.add(new AbstractMap.SimpleEntry<>("dev", id)); if (!Strings.isNullOrEmpty(accountName)) { qparams.add(new AbstractMap.SimpleEntry<>("acct", accountName)); } else { qparams.add(new AbstractMap.SimpleEntry<>("acct", id)); } qparams.add(new AbstractMap.SimpleEntry<>("batt", String.valueOf(batteryLevel))); qparams.add(new AbstractMap.SimpleEntry<>("code", "0xF020")); qparams.add(new AbstractMap.SimpleEntry<>("alt", String.valueOf(loc.getAltitude()))); qparams.add(new AbstractMap.SimpleEntry<>("gprmc", OpenGTSManager.gprmcEncode(loc))); if(path.startsWith("/")){ path = path.replaceFirst("/",""); } return String.format("%s: } }
OpenGTSManager extends FileSender { public static String getUrl(String id, String accountName, SerializableLocation loc, String communication, String path, String server, int port, int batteryLevel) { List<AbstractMap.SimpleEntry<String,String>> qparams = new ArrayList<>(); qparams.add(new AbstractMap.SimpleEntry<>("id", id)); qparams.add(new AbstractMap.SimpleEntry<>("dev", id)); if (!Strings.isNullOrEmpty(accountName)) { qparams.add(new AbstractMap.SimpleEntry<>("acct", accountName)); } else { qparams.add(new AbstractMap.SimpleEntry<>("acct", id)); } qparams.add(new AbstractMap.SimpleEntry<>("batt", String.valueOf(batteryLevel))); qparams.add(new AbstractMap.SimpleEntry<>("code", "0xF020")); qparams.add(new AbstractMap.SimpleEntry<>("alt", String.valueOf(loc.getAltitude()))); qparams.add(new AbstractMap.SimpleEntry<>("gprmc", OpenGTSManager.gprmcEncode(loc))); if(path.startsWith("/")){ path = path.replaceFirst("/",""); } return String.format("%s: } OpenGTSManager(PreferenceHelper preferenceHelper);  OpenGTSManager(PreferenceHelper preferenceHelper, int batteryLevel); }
OpenGTSManager extends FileSender { public static String getUrl(String id, String accountName, SerializableLocation loc, String communication, String path, String server, int port, int batteryLevel) { List<AbstractMap.SimpleEntry<String,String>> qparams = new ArrayList<>(); qparams.add(new AbstractMap.SimpleEntry<>("id", id)); qparams.add(new AbstractMap.SimpleEntry<>("dev", id)); if (!Strings.isNullOrEmpty(accountName)) { qparams.add(new AbstractMap.SimpleEntry<>("acct", accountName)); } else { qparams.add(new AbstractMap.SimpleEntry<>("acct", id)); } qparams.add(new AbstractMap.SimpleEntry<>("batt", String.valueOf(batteryLevel))); qparams.add(new AbstractMap.SimpleEntry<>("code", "0xF020")); qparams.add(new AbstractMap.SimpleEntry<>("alt", String.valueOf(loc.getAltitude()))); qparams.add(new AbstractMap.SimpleEntry<>("gprmc", OpenGTSManager.gprmcEncode(loc))); if(path.startsWith("/")){ path = path.replaceFirst("/",""); } return String.format("%s: } OpenGTSManager(PreferenceHelper preferenceHelper);  OpenGTSManager(PreferenceHelper preferenceHelper, int batteryLevel); @Override void uploadFile(List<File> files); void sendLocations(SerializableLocation[] locations); static String gprmcEncode(SerializableLocation loc); static String getNmeaGprmcTime(Date dateToFormat); static String getNmeaGprmcDate(Date dateToFormat); static String getNmeaGprmcCoordinates(double coord); static String getNmeaChecksum(String msg); static String getUrl(String id, String accountName, SerializableLocation loc, String communication, String path, String server, int port, int batteryLevel); @Override boolean isAvailable(); @Override boolean hasUserAllowedAutoSending(); @Override boolean accept(File dir, String name); }
OpenGTSManager extends FileSender { public static String getUrl(String id, String accountName, SerializableLocation loc, String communication, String path, String server, int port, int batteryLevel) { List<AbstractMap.SimpleEntry<String,String>> qparams = new ArrayList<>(); qparams.add(new AbstractMap.SimpleEntry<>("id", id)); qparams.add(new AbstractMap.SimpleEntry<>("dev", id)); if (!Strings.isNullOrEmpty(accountName)) { qparams.add(new AbstractMap.SimpleEntry<>("acct", accountName)); } else { qparams.add(new AbstractMap.SimpleEntry<>("acct", id)); } qparams.add(new AbstractMap.SimpleEntry<>("batt", String.valueOf(batteryLevel))); qparams.add(new AbstractMap.SimpleEntry<>("code", "0xF020")); qparams.add(new AbstractMap.SimpleEntry<>("alt", String.valueOf(loc.getAltitude()))); qparams.add(new AbstractMap.SimpleEntry<>("gprmc", OpenGTSManager.gprmcEncode(loc))); if(path.startsWith("/")){ path = path.replaceFirst("/",""); } return String.format("%s: } OpenGTSManager(PreferenceHelper preferenceHelper);  OpenGTSManager(PreferenceHelper preferenceHelper, int batteryLevel); @Override void uploadFile(List<File> files); void sendLocations(SerializableLocation[] locations); static String gprmcEncode(SerializableLocation loc); static String getNmeaGprmcTime(Date dateToFormat); static String getNmeaGprmcDate(Date dateToFormat); static String getNmeaGprmcCoordinates(double coord); static String getNmeaChecksum(String msg); static String getUrl(String id, String accountName, SerializableLocation loc, String communication, String path, String server, int port, int batteryLevel); @Override boolean isAvailable(); @Override boolean hasUserAllowedAutoSending(); @Override boolean accept(File dir, String name);  }