@Test public void getFormattedUrl_WhenFilename_AddFilename() throws Exception { Location loc = MockLocations.builder("MOCK", 12.193, 19.456).withTime(1457205869949l).build(); CustomUrlLogger logger = new CustomUrlLogger("",0, "GET", "",""); String expected="http: String urlTemplate = "http: assertThat("Start timestamp is in seconds", logger.getFormattedTextblock(urlTemplate, loc, "", "", 0, "", 1495884681283l, "20170527abc","", 0), is(expected)); }
public String getFormattedTextblock(String customLoggingUrl, Location loc, String description, String androidId, float batteryLevel, String buildSerial, long sessionStartTimeStamp, String fileName, String profileName, double distance) throws Exception { String logUrl = customLoggingUrl; SerializableLocation sLoc = new SerializableLocation(loc); logUrl = logUrl.replaceAll("(?i)%lat", String.valueOf(sLoc.getLatitude())); logUrl = logUrl.replaceAll("(?i)%lon", String.valueOf(sLoc.getLongitude())); logUrl = logUrl.replaceAll("(?i)%sat", String.valueOf(sLoc.getSatelliteCount())); logUrl = logUrl.replaceAll("(?i)%desc", String.valueOf(URLEncoder.encode(Strings.htmlDecode(description), "UTF-8"))); logUrl = logUrl.replaceAll("(?i)%alt", String.valueOf(sLoc.getAltitude())); logUrl = logUrl.replaceAll("(?i)%acc", String.valueOf(sLoc.getAccuracy())); logUrl = logUrl.replaceAll("(?i)%dir", String.valueOf(sLoc.getBearing())); logUrl = logUrl.replaceAll("(?i)%prov", String.valueOf(sLoc.getProvider())); logUrl = logUrl.replaceAll("(?i)%spd", String.valueOf(sLoc.getSpeed())); logUrl = logUrl.replaceAll("(?i)%timestamp", String.valueOf(sLoc.getTime()/1000)); logUrl = logUrl.replaceAll("(?i)%time", String.valueOf(Strings.getIsoDateTime(new Date(sLoc.getTime())))); logUrl = logUrl.replaceAll("(?i)%date", String.valueOf(Strings.getIsoCalendarDate(new Date(sLoc.getTime())))); logUrl = logUrl.replaceAll("(?i)%starttimestamp", String.valueOf(sessionStartTimeStamp/1000)); logUrl = logUrl.replaceAll("(?i)%batt", String.valueOf(batteryLevel)); logUrl = logUrl.replaceAll("(?i)%aid", String.valueOf(androidId)); logUrl = logUrl.replaceAll("(?i)%ser", String.valueOf(buildSerial)); logUrl = logUrl.replaceAll("(?i)%act", String.valueOf(sLoc.getDetectedActivity())); logUrl = logUrl.replaceAll("(?i)%filename", fileName); logUrl = logUrl.replaceAll("(?i)%profile",URLEncoder.encode(profileName, "UTF-8")); logUrl = logUrl.replaceAll("(?i)%hdop", sLoc.getHDOP()); logUrl = logUrl.replaceAll("(?i)%vdop", sLoc.getVDOP()); logUrl = logUrl.replaceAll("(?i)%pdop", sLoc.getPDOP()); logUrl = logUrl.replaceAll("(?i)%dist", String.valueOf((int)distance)); return logUrl; }
CustomUrlLogger implements FileLogger { public String getFormattedTextblock(String customLoggingUrl, Location loc, String description, String androidId, float batteryLevel, String buildSerial, long sessionStartTimeStamp, String fileName, String profileName, double distance) throws Exception { String logUrl = customLoggingUrl; SerializableLocation sLoc = new SerializableLocation(loc); logUrl = logUrl.replaceAll("(?i)%lat", String.valueOf(sLoc.getLatitude())); logUrl = logUrl.replaceAll("(?i)%lon", String.valueOf(sLoc.getLongitude())); logUrl = logUrl.replaceAll("(?i)%sat", String.valueOf(sLoc.getSatelliteCount())); logUrl = logUrl.replaceAll("(?i)%desc", String.valueOf(URLEncoder.encode(Strings.htmlDecode(description), "UTF-8"))); logUrl = logUrl.replaceAll("(?i)%alt", String.valueOf(sLoc.getAltitude())); logUrl = logUrl.replaceAll("(?i)%acc", String.valueOf(sLoc.getAccuracy())); logUrl = logUrl.replaceAll("(?i)%dir", String.valueOf(sLoc.getBearing())); logUrl = logUrl.replaceAll("(?i)%prov", String.valueOf(sLoc.getProvider())); logUrl = logUrl.replaceAll("(?i)%spd", String.valueOf(sLoc.getSpeed())); logUrl = logUrl.replaceAll("(?i)%timestamp", String.valueOf(sLoc.getTime()/1000)); logUrl = logUrl.replaceAll("(?i)%time", String.valueOf(Strings.getIsoDateTime(new Date(sLoc.getTime())))); logUrl = logUrl.replaceAll("(?i)%date", String.valueOf(Strings.getIsoCalendarDate(new Date(sLoc.getTime())))); logUrl = logUrl.replaceAll("(?i)%starttimestamp", String.valueOf(sessionStartTimeStamp/1000)); logUrl = logUrl.replaceAll("(?i)%batt", String.valueOf(batteryLevel)); logUrl = logUrl.replaceAll("(?i)%aid", String.valueOf(androidId)); logUrl = logUrl.replaceAll("(?i)%ser", String.valueOf(buildSerial)); logUrl = logUrl.replaceAll("(?i)%act", String.valueOf(sLoc.getDetectedActivity())); logUrl = logUrl.replaceAll("(?i)%filename", fileName); logUrl = logUrl.replaceAll("(?i)%profile",URLEncoder.encode(profileName, "UTF-8")); logUrl = logUrl.replaceAll("(?i)%hdop", sLoc.getHDOP()); logUrl = logUrl.replaceAll("(?i)%vdop", sLoc.getVDOP()); logUrl = logUrl.replaceAll("(?i)%pdop", sLoc.getPDOP()); logUrl = logUrl.replaceAll("(?i)%dist", String.valueOf((int)distance)); return logUrl; } }
CustomUrlLogger implements FileLogger { public String getFormattedTextblock(String customLoggingUrl, Location loc, String description, String androidId, float batteryLevel, String buildSerial, long sessionStartTimeStamp, String fileName, String profileName, double distance) throws Exception { String logUrl = customLoggingUrl; SerializableLocation sLoc = new SerializableLocation(loc); logUrl = logUrl.replaceAll("(?i)%lat", String.valueOf(sLoc.getLatitude())); logUrl = logUrl.replaceAll("(?i)%lon", String.valueOf(sLoc.getLongitude())); logUrl = logUrl.replaceAll("(?i)%sat", String.valueOf(sLoc.getSatelliteCount())); logUrl = logUrl.replaceAll("(?i)%desc", String.valueOf(URLEncoder.encode(Strings.htmlDecode(description), "UTF-8"))); logUrl = logUrl.replaceAll("(?i)%alt", String.valueOf(sLoc.getAltitude())); logUrl = logUrl.replaceAll("(?i)%acc", String.valueOf(sLoc.getAccuracy())); logUrl = logUrl.replaceAll("(?i)%dir", String.valueOf(sLoc.getBearing())); logUrl = logUrl.replaceAll("(?i)%prov", String.valueOf(sLoc.getProvider())); logUrl = logUrl.replaceAll("(?i)%spd", String.valueOf(sLoc.getSpeed())); logUrl = logUrl.replaceAll("(?i)%timestamp", String.valueOf(sLoc.getTime()/1000)); logUrl = logUrl.replaceAll("(?i)%time", String.valueOf(Strings.getIsoDateTime(new Date(sLoc.getTime())))); logUrl = logUrl.replaceAll("(?i)%date", String.valueOf(Strings.getIsoCalendarDate(new Date(sLoc.getTime())))); logUrl = logUrl.replaceAll("(?i)%starttimestamp", String.valueOf(sessionStartTimeStamp/1000)); logUrl = logUrl.replaceAll("(?i)%batt", String.valueOf(batteryLevel)); logUrl = logUrl.replaceAll("(?i)%aid", String.valueOf(androidId)); logUrl = logUrl.replaceAll("(?i)%ser", String.valueOf(buildSerial)); logUrl = logUrl.replaceAll("(?i)%act", String.valueOf(sLoc.getDetectedActivity())); logUrl = logUrl.replaceAll("(?i)%filename", fileName); logUrl = logUrl.replaceAll("(?i)%profile",URLEncoder.encode(profileName, "UTF-8")); logUrl = logUrl.replaceAll("(?i)%hdop", sLoc.getHDOP()); logUrl = logUrl.replaceAll("(?i)%vdop", sLoc.getVDOP()); logUrl = logUrl.replaceAll("(?i)%pdop", sLoc.getPDOP()); logUrl = logUrl.replaceAll("(?i)%dist", String.valueOf((int)distance)); return logUrl; } CustomUrlLogger(String customLoggingUrl, int batteryLevel, String httpMethod, String httpBody, String httpHeaders);  CustomUrlLogger(String customLoggingUrl, int batteryLevel, String httpMethod, String httpBody, String httpHeaders, String basicAuthUsername, String basicAuthPassword); }
CustomUrlLogger implements FileLogger { public String getFormattedTextblock(String customLoggingUrl, Location loc, String description, String androidId, float batteryLevel, String buildSerial, long sessionStartTimeStamp, String fileName, String profileName, double distance) throws Exception { String logUrl = customLoggingUrl; SerializableLocation sLoc = new SerializableLocation(loc); logUrl = logUrl.replaceAll("(?i)%lat", String.valueOf(sLoc.getLatitude())); logUrl = logUrl.replaceAll("(?i)%lon", String.valueOf(sLoc.getLongitude())); logUrl = logUrl.replaceAll("(?i)%sat", String.valueOf(sLoc.getSatelliteCount())); logUrl = logUrl.replaceAll("(?i)%desc", String.valueOf(URLEncoder.encode(Strings.htmlDecode(description), "UTF-8"))); logUrl = logUrl.replaceAll("(?i)%alt", String.valueOf(sLoc.getAltitude())); logUrl = logUrl.replaceAll("(?i)%acc", String.valueOf(sLoc.getAccuracy())); logUrl = logUrl.replaceAll("(?i)%dir", String.valueOf(sLoc.getBearing())); logUrl = logUrl.replaceAll("(?i)%prov", String.valueOf(sLoc.getProvider())); logUrl = logUrl.replaceAll("(?i)%spd", String.valueOf(sLoc.getSpeed())); logUrl = logUrl.replaceAll("(?i)%timestamp", String.valueOf(sLoc.getTime()/1000)); logUrl = logUrl.replaceAll("(?i)%time", String.valueOf(Strings.getIsoDateTime(new Date(sLoc.getTime())))); logUrl = logUrl.replaceAll("(?i)%date", String.valueOf(Strings.getIsoCalendarDate(new Date(sLoc.getTime())))); logUrl = logUrl.replaceAll("(?i)%starttimestamp", String.valueOf(sessionStartTimeStamp/1000)); logUrl = logUrl.replaceAll("(?i)%batt", String.valueOf(batteryLevel)); logUrl = logUrl.replaceAll("(?i)%aid", String.valueOf(androidId)); logUrl = logUrl.replaceAll("(?i)%ser", String.valueOf(buildSerial)); logUrl = logUrl.replaceAll("(?i)%act", String.valueOf(sLoc.getDetectedActivity())); logUrl = logUrl.replaceAll("(?i)%filename", fileName); logUrl = logUrl.replaceAll("(?i)%profile",URLEncoder.encode(profileName, "UTF-8")); logUrl = logUrl.replaceAll("(?i)%hdop", sLoc.getHDOP()); logUrl = logUrl.replaceAll("(?i)%vdop", sLoc.getVDOP()); logUrl = logUrl.replaceAll("(?i)%pdop", sLoc.getPDOP()); logUrl = logUrl.replaceAll("(?i)%dist", String.valueOf((int)distance)); return logUrl; } CustomUrlLogger(String customLoggingUrl, int batteryLevel, String httpMethod, String httpBody, String httpHeaders);  CustomUrlLogger(String customLoggingUrl, int batteryLevel, String httpMethod, String httpBody, String httpHeaders, String basicAuthUsername, String basicAuthPassword); @Override void write(Location loc); @Override void annotate(String description, Location loc); String getFormattedTextblock(String customLoggingUrl, Location loc, String description, String androidId,
                                        float batteryLevel, String buildSerial, long sessionStartTimeStamp, String fileName, String profileName, double distance); @Override String getName(); }
CustomUrlLogger implements FileLogger { public String getFormattedTextblock(String customLoggingUrl, Location loc, String description, String androidId, float batteryLevel, String buildSerial, long sessionStartTimeStamp, String fileName, String profileName, double distance) throws Exception { String logUrl = customLoggingUrl; SerializableLocation sLoc = new SerializableLocation(loc); logUrl = logUrl.replaceAll("(?i)%lat", String.valueOf(sLoc.getLatitude())); logUrl = logUrl.replaceAll("(?i)%lon", String.valueOf(sLoc.getLongitude())); logUrl = logUrl.replaceAll("(?i)%sat", String.valueOf(sLoc.getSatelliteCount())); logUrl = logUrl.replaceAll("(?i)%desc", String.valueOf(URLEncoder.encode(Strings.htmlDecode(description), "UTF-8"))); logUrl = logUrl.replaceAll("(?i)%alt", String.valueOf(sLoc.getAltitude())); logUrl = logUrl.replaceAll("(?i)%acc", String.valueOf(sLoc.getAccuracy())); logUrl = logUrl.replaceAll("(?i)%dir", String.valueOf(sLoc.getBearing())); logUrl = logUrl.replaceAll("(?i)%prov", String.valueOf(sLoc.getProvider())); logUrl = logUrl.replaceAll("(?i)%spd", String.valueOf(sLoc.getSpeed())); logUrl = logUrl.replaceAll("(?i)%timestamp", String.valueOf(sLoc.getTime()/1000)); logUrl = logUrl.replaceAll("(?i)%time", String.valueOf(Strings.getIsoDateTime(new Date(sLoc.getTime())))); logUrl = logUrl.replaceAll("(?i)%date", String.valueOf(Strings.getIsoCalendarDate(new Date(sLoc.getTime())))); logUrl = logUrl.replaceAll("(?i)%starttimestamp", String.valueOf(sessionStartTimeStamp/1000)); logUrl = logUrl.replaceAll("(?i)%batt", String.valueOf(batteryLevel)); logUrl = logUrl.replaceAll("(?i)%aid", String.valueOf(androidId)); logUrl = logUrl.replaceAll("(?i)%ser", String.valueOf(buildSerial)); logUrl = logUrl.replaceAll("(?i)%act", String.valueOf(sLoc.getDetectedActivity())); logUrl = logUrl.replaceAll("(?i)%filename", fileName); logUrl = logUrl.replaceAll("(?i)%profile",URLEncoder.encode(profileName, "UTF-8")); logUrl = logUrl.replaceAll("(?i)%hdop", sLoc.getHDOP()); logUrl = logUrl.replaceAll("(?i)%vdop", sLoc.getVDOP()); logUrl = logUrl.replaceAll("(?i)%pdop", sLoc.getPDOP()); logUrl = logUrl.replaceAll("(?i)%dist", String.valueOf((int)distance)); return logUrl; } CustomUrlLogger(String customLoggingUrl, int batteryLevel, String httpMethod, String httpBody, String httpHeaders);  CustomUrlLogger(String customLoggingUrl, int batteryLevel, String httpMethod, String httpBody, String httpHeaders, String basicAuthUsername, String basicAuthPassword); @Override void write(Location loc); @Override void annotate(String description, Location loc); String getFormattedTextblock(String customLoggingUrl, Location loc, String description, String androidId,
                                        float batteryLevel, String buildSerial, long sessionStartTimeStamp, String fileName, String profileName, double distance); @Override String getName();  }