Fix protocol formatter unit test

Этот коммит содержится в:
Anton Tananaev
2016-07-24 12:50:42 +12:00
родитель 532a1f4249
Коммит 7ab99da14c
2 изменённых файлов: 3 добавлений и 4 удалений
+2 -3
Просмотреть файл
@@ -1,5 +1,5 @@
/* /*
* Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com) * Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com)
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
*/ */
package org.traccar.client; package org.traccar.client;
import android.location.Location;
import android.net.Uri; import android.net.Uri;
public class ProtocolFormatter { public class ProtocolFormatter {
@@ -23,7 +22,7 @@ public class ProtocolFormatter {
public static String formatRequest(String address, int port, boolean secure, Position position) { public static String formatRequest(String address, int port, boolean secure, Position position) {
Uri.Builder builder = new Uri.Builder(); Uri.Builder builder = new Uri.Builder();
builder.scheme(secure?"https":"http").encodedAuthority(address + ':' + port) builder.scheme(secure ? "https" : "http").encodedAuthority(address + ':' + port)
.appendQueryParameter("id", position.getDeviceId()) .appendQueryParameter("id", position.getDeviceId())
.appendQueryParameter("timestamp", String.valueOf(position.getTime().getTime() / 1000)) .appendQueryParameter("timestamp", String.valueOf(position.getTime().getTime() / 1000))
.appendQueryParameter("lat", String.valueOf(position.getLatitude())) .appendQueryParameter("lat", String.valueOf(position.getLatitude()))
+1 -1
Просмотреть файл
@@ -22,7 +22,7 @@ public class ProtocolFormatterTest {
Position position = new Position("123456789012345", new Location("gps"), 0); Position position = new Position("123456789012345", new Location("gps"), 0);
position.setTime(new Date(0)); position.setTime(new Date(0));
String url = ProtocolFormatter.formatRequest("localhost", 5055, position); String url = ProtocolFormatter.formatRequest("localhost", 5055, false, position);
assertEquals("http://localhost:5055?id=123456789012345&timestamp=0&lat=0.0&lon=0.0&speed=0.0&bearing=0.0&altitude=0.0&batt=0.0", url); assertEquals("http://localhost:5055?id=123456789012345&timestamp=0&lat=0.0&lon=0.0&speed=0.0&bearing=0.0&altitude=0.0&batt=0.0", url);