Fix protocol formatter unit test
Этот коммит содержится в:
@@ -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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.traccar.client;
|
||||
|
||||
import android.location.Location;
|
||||
import android.net.Uri;
|
||||
|
||||
public class ProtocolFormatter {
|
||||
@@ -23,7 +22,7 @@ public class ProtocolFormatter {
|
||||
public static String formatRequest(String address, int port, boolean secure, Position position) {
|
||||
|
||||
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("timestamp", String.valueOf(position.getTime().getTime() / 1000))
|
||||
.appendQueryParameter("lat", String.valueOf(position.getLatitude()))
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ProtocolFormatterTest {
|
||||
Position position = new Position("123456789012345", new Location("gps"), 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×tamp=0&lat=0.0&lon=0.0&speed=0.0&bearing=0.0&altitude=0.0&batt=0.0", url);
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user