aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-07 16:38:58 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-07 16:38:58 -0700
commitb745e3804950fefd24b38937c90c4d5c61219321 (patch)
treef362ea259e557cc6ffd778fde6b15e59be46d068
parent32b39cffc6dd705e9aacbe5b8d68bc37106997d2 (diff)
downloadtrackermap-server-b745e3804950fefd24b38937c90c4d5c61219321.tar.gz
trackermap-server-b745e3804950fefd24b38937c90c4d5c61219321.tar.bz2
trackermap-server-b745e3804950fefd24b38937c90c4d5c61219321.zip
Remove drivers manager
-rw-r--r--schema/changelog-5.1.xml17
-rw-r--r--schema/changelog-master.xml1
-rw-r--r--src/main/java/org/traccar/Context.java12
-rw-r--r--src/main/java/org/traccar/database/DriversManager.java100
-rw-r--r--src/main/java/org/traccar/database/PermissionsManager.java7
-rw-r--r--src/main/java/org/traccar/notification/NotificationFormatter.java3
-rw-r--r--src/main/java/org/traccar/reports/StopsReportProvider.java12
-rw-r--r--src/main/java/org/traccar/reports/TripsReportProvider.java12
-rw-r--r--src/main/java/org/traccar/reports/common/ReportUtils.java28
-rw-r--r--src/main/java/org/traccar/session/cache/CacheManager.java7
-rw-r--r--src/test/java/org/traccar/reports/ReportUtilsTest.java43
11 files changed, 85 insertions, 157 deletions
diff --git a/schema/changelog-5.1.xml b/schema/changelog-5.1.xml
new file mode 100644
index 000000000..26c2088b9
--- /dev/null
+++ b/schema/changelog-5.1.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<databaseChangeLog
+ xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
+ http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd"
+ logicalFilePath="changelog-5.1">
+
+ <changeSet author="author" id="changelog-5.1">
+
+ <createIndex tableName="tc_drivers" indexName="idx_drivers_uniqueid">
+ <column name="uniqueid" />
+ </createIndex>
+
+ </changeSet>
+
+</databaseChangeLog>
diff --git a/schema/changelog-master.xml b/schema/changelog-master.xml
index bb2b3e2f3..471b0fe5d 100644
--- a/schema/changelog-master.xml
+++ b/schema/changelog-master.xml
@@ -31,5 +31,6 @@
<include file="changelog-4.15.xml" relativeToChangelogFile="true" />
<include file="changelog-5.0.xml" relativeToChangelogFile="true" />
+ <include file="changelog-5.1.xml" relativeToChangelogFile="true" />
</databaseChangeLog>
diff --git a/src/main/java/org/traccar/Context.java b/src/main/java/org/traccar/Context.java
index e5a0c640f..899f8ea54 100644
--- a/src/main/java/org/traccar/Context.java
+++ b/src/main/java/org/traccar/Context.java
@@ -26,7 +26,6 @@ import org.traccar.config.Keys;
import org.traccar.database.BaseObjectManager;
import org.traccar.database.DataManager;
import org.traccar.database.DeviceManager;
-import org.traccar.database.DriversManager;
import org.traccar.database.GeofenceManager;
import org.traccar.database.GroupsManager;
import org.traccar.database.IdentityManager;
@@ -39,7 +38,6 @@ import org.traccar.helper.Log;
import org.traccar.helper.SanitizerModule;
import org.traccar.model.BaseModel;
import org.traccar.model.Device;
-import org.traccar.model.Driver;
import org.traccar.model.Geofence;
import org.traccar.model.Group;
import org.traccar.model.Notification;
@@ -178,12 +176,6 @@ public final class Context {
return eventForwarder;
}
- private static DriversManager driversManager;
-
- public static DriversManager getDriversManager() {
- return driversManager;
- }
-
private static SmsManager smsManager;
public static SmsManager getSmsManager() {
@@ -277,8 +269,6 @@ public final class Context {
eventForwarder = new EventForwarder(config);
}
- driversManager = new DriversManager(dataManager);
-
}
private static void initEventsModule() {
@@ -324,8 +314,6 @@ public final class Context {
return (BaseObjectManager<T>) usersManager;
} else if (clazz.equals(Geofence.class)) {
return (BaseObjectManager<T>) geofenceManager;
- } else if (clazz.equals(Driver.class)) {
- return (BaseObjectManager<T>) driversManager;
} else if (clazz.equals(Notification.class)) {
return (BaseObjectManager<T>) notificationManager;
}
diff --git a/src/main/java/org/traccar/database/DriversManager.java b/src/main/java/org/traccar/database/DriversManager.java
deleted file mode 100644
index d111cd643..000000000
--- a/src/main/java/org/traccar/database/DriversManager.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2017 - 2020 Anton Tananaev (anton@traccar.org)
- * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.database;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.traccar.model.Driver;
-
-public class DriversManager extends ExtendedObjectManager<Driver> {
-
- private Map<String, Driver> driversByUniqueId;
-
- public DriversManager(DataManager dataManager) {
- super(dataManager, Driver.class);
- try {
- writeLock();
- if (driversByUniqueId == null) {
- driversByUniqueId = new ConcurrentHashMap<>();
- }
- } finally {
- writeUnlock();
- }
- }
-
- private void addByUniqueId(Driver driver) {
- try {
- writeLock();
- if (driversByUniqueId == null) {
- driversByUniqueId = new ConcurrentHashMap<>();
- }
- driversByUniqueId.put(driver.getUniqueId(), driver);
- } finally {
- writeUnlock();
- }
- }
-
- private void removeByUniqueId(String driverUniqueId) {
- try {
- writeLock();
- if (driversByUniqueId == null) {
- driversByUniqueId = new ConcurrentHashMap<>();
- }
- driversByUniqueId.remove(driverUniqueId);
- } finally {
- writeUnlock();
- }
- }
-
- @Override
- protected void addNewItem(Driver driver) {
- super.addNewItem(driver);
- addByUniqueId(driver);
- }
-
- @Override
- protected void updateCachedItem(Driver driver) {
- Driver cachedDriver = getById(driver.getId());
- cachedDriver.setName(driver.getName());
- if (!driver.getUniqueId().equals(cachedDriver.getUniqueId())) {
- removeByUniqueId(cachedDriver.getUniqueId());
- cachedDriver.setUniqueId(driver.getUniqueId());
- addByUniqueId(cachedDriver);
- }
- cachedDriver.setAttributes(driver.getAttributes());
- }
-
- @Override
- protected void removeCachedItem(long driverId) {
- Driver cachedDriver = getById(driverId);
- if (cachedDriver != null) {
- String driverUniqueId = cachedDriver.getUniqueId();
- super.removeCachedItem(driverId);
- removeByUniqueId(driverUniqueId);
- }
- }
-
- public Driver getDriverByUniqueId(String uniqueId) {
- try {
- readLock();
- return driversByUniqueId.get(uniqueId);
- } finally {
- readUnlock();
- }
- }
-}
diff --git a/src/main/java/org/traccar/database/PermissionsManager.java b/src/main/java/org/traccar/database/PermissionsManager.java
index 544faf697..47941d681 100644
--- a/src/main/java/org/traccar/database/PermissionsManager.java
+++ b/src/main/java/org/traccar/database/PermissionsManager.java
@@ -20,7 +20,6 @@ import org.slf4j.LoggerFactory;
import org.traccar.Context;
import org.traccar.model.BaseModel;
import org.traccar.model.Device;
-import org.traccar.model.Driver;
import org.traccar.model.Geofence;
import org.traccar.model.Group;
import org.traccar.model.ManagedUser;
@@ -360,7 +359,6 @@ public class PermissionsManager {
if (Context.getGeofenceManager() != null) {
Context.getGeofenceManager().refreshUserItems();
}
- Context.getDriversManager().refreshUserItems();
if (Context.getNotificationManager() != null) {
Context.getNotificationManager().refreshUserItems();
}
@@ -370,7 +368,6 @@ public class PermissionsManager {
if (Context.getGeofenceManager() != null) {
Context.getGeofenceManager().refreshExtendedPermissions();
}
- Context.getDriversManager().refreshExtendedPermissions();
}
public void refreshPermissions(Permission permission) {
@@ -383,8 +380,6 @@ public class PermissionsManager {
usersManager.refreshUserItems();
} else if (permission.getPropertyClass().equals(Geofence.class) && Context.getGeofenceManager() != null) {
Context.getGeofenceManager().refreshUserItems();
- } else if (permission.getPropertyClass().equals(Driver.class)) {
- Context.getDriversManager().refreshUserItems();
} else if (permission.getPropertyClass().equals(Notification.class)
&& Context.getNotificationManager() != null) {
Context.getNotificationManager().refreshUserItems();
@@ -392,8 +387,6 @@ public class PermissionsManager {
} else if (permission.getOwnerClass().equals(Device.class) || permission.getOwnerClass().equals(Group.class)) {
if (permission.getPropertyClass().equals(Geofence.class) && Context.getGeofenceManager() != null) {
Context.getGeofenceManager().refreshExtendedPermissions();
- } else if (permission.getPropertyClass().equals(Driver.class)) {
- Context.getDriversManager().refreshExtendedPermissions();
} else if (permission.getPropertyClass().equals(Notification.class)
&& Context.getNotificationManager() != null) {
Context.getNotificationManager().refreshExtendedPermissions();
diff --git a/src/main/java/org/traccar/notification/NotificationFormatter.java b/src/main/java/org/traccar/notification/NotificationFormatter.java
index c3e37c9e9..be90761b1 100644
--- a/src/main/java/org/traccar/notification/NotificationFormatter.java
+++ b/src/main/java/org/traccar/notification/NotificationFormatter.java
@@ -17,7 +17,6 @@
package org.traccar.notification;
import org.apache.velocity.VelocityContext;
-import org.traccar.Context;
import org.traccar.model.Device;
import org.traccar.model.Event;
import org.traccar.model.Geofence;
@@ -55,7 +54,7 @@ public final class NotificationFormatter {
}
String driverUniqueId = event.getString(Position.KEY_DRIVER_UNIQUE_ID);
if (driverUniqueId != null) {
- velocityContext.put("driver", Context.getDriversManager().getDriverByUniqueId(driverUniqueId));
+ velocityContext.put("driver", cacheManager.findDriverByUniqueId(device.getId(), driverUniqueId));
}
return TextTemplateFormatter.formatMessage(velocityContext, event.getType(), templatePath);
diff --git a/src/main/java/org/traccar/reports/StopsReportProvider.java b/src/main/java/org/traccar/reports/StopsReportProvider.java
index 8dedb9a24..58dc71d2d 100644
--- a/src/main/java/org/traccar/reports/StopsReportProvider.java
+++ b/src/main/java/org/traccar/reports/StopsReportProvider.java
@@ -35,10 +35,20 @@ import org.traccar.model.Group;
import org.traccar.reports.common.ReportUtils;
import org.traccar.reports.model.DeviceReportSection;
import org.traccar.reports.model.StopReportItem;
+import org.traccar.storage.Storage;
import org.traccar.storage.StorageException;
+import javax.inject.Inject;
+
public class StopsReportProvider {
+ private final Storage storage;
+
+ @Inject
+ public StopsReportProvider(Storage storage) {
+ this.storage = storage;
+ }
+
private Collection<StopReportItem> detectStops(long deviceId, Date from, Date to) throws StorageException {
boolean ignoreOdometer = Context.getDeviceManager()
.lookupAttributeBoolean(deviceId, "report.ignoreOdometer", false, false, true);
@@ -47,7 +57,7 @@ public class StopsReportProvider {
DeviceManager deviceManager = Main.getInjector().getInstance(DeviceManager.class);
return ReportUtils.detectTripsAndStops(
- identityManager, deviceManager, Context.getDataManager().getPositions(deviceId, from, to),
+ storage, identityManager, deviceManager, Context.getDataManager().getPositions(deviceId, from, to),
Context.getTripsConfig(), ignoreOdometer, StopReportItem.class);
}
diff --git a/src/main/java/org/traccar/reports/TripsReportProvider.java b/src/main/java/org/traccar/reports/TripsReportProvider.java
index 6aff08a1d..5ff31dbe2 100644
--- a/src/main/java/org/traccar/reports/TripsReportProvider.java
+++ b/src/main/java/org/traccar/reports/TripsReportProvider.java
@@ -34,10 +34,20 @@ import org.traccar.model.Group;
import org.traccar.reports.common.ReportUtils;
import org.traccar.reports.model.DeviceReportSection;
import org.traccar.reports.model.TripReportItem;
+import org.traccar.storage.Storage;
import org.traccar.storage.StorageException;
+import javax.inject.Inject;
+
public class TripsReportProvider {
+ private final Storage storage;
+
+ @Inject
+ public TripsReportProvider(Storage storage) {
+ this.storage = storage;
+ }
+
private Collection<TripReportItem> detectTrips(long deviceId, Date from, Date to) throws StorageException {
boolean ignoreOdometer = Context.getDeviceManager()
.lookupAttributeBoolean(deviceId, "report.ignoreOdometer", false, false, true);
@@ -46,7 +56,7 @@ public class TripsReportProvider {
DeviceManager deviceManager = Main.getInjector().getInstance(DeviceManager.class);
return ReportUtils.detectTripsAndStops(
- identityManager, deviceManager, Context.getDataManager().getPositions(deviceId, from, to),
+ storage, identityManager, deviceManager, Context.getDataManager().getPositions(deviceId, from, to),
Context.getTripsConfig(), ignoreOdometer, TripReportItem.class);
}
diff --git a/src/main/java/org/traccar/reports/common/ReportUtils.java b/src/main/java/org/traccar/reports/common/ReportUtils.java
index b56b58a58..4bcb54899 100644
--- a/src/main/java/org/traccar/reports/common/ReportUtils.java
+++ b/src/main/java/org/traccar/reports/common/ReportUtils.java
@@ -146,9 +146,11 @@ public final class ReportUtils {
return null;
}
- public static String findDriverName(String driverUniqueId) {
- if (driverUniqueId != null && Context.getDriversManager() != null) {
- Driver driver = Context.getDriversManager().getDriverByUniqueId(driverUniqueId);
+ public static String findDriverName(Storage storage, String driverUniqueId) throws StorageException {
+ if (driverUniqueId != null) {
+ Driver driver = storage.getObject(Driver.class, new Request(
+ new Columns.All(),
+ new Condition.Equals("uniqueId", "uniqueId", driverUniqueId)));
if (driver != null) {
return driver.getName();
}
@@ -186,8 +188,8 @@ public final class ReportUtils {
}
private static TripReportItem calculateTrip(
- IdentityManager identityManager, ArrayList<Position> positions,
- int startIndex, int endIndex, boolean ignoreOdometer) {
+ Storage storage, IdentityManager identityManager, ArrayList<Position> positions,
+ int startIndex, int endIndex, boolean ignoreOdometer) throws StorageException {
Position startTrip = positions.get(startIndex);
Position endTrip = positions.get(endIndex);
@@ -238,7 +240,7 @@ public final class ReportUtils {
trip.setSpentFuel(calculateFuel(startTrip, endTrip));
trip.setDriverUniqueId(findDriver(startTrip, endTrip));
- trip.setDriverName(findDriverName(trip.getDriverUniqueId()));
+ trip.setDriverName(findDriverName(storage, trip.getDriverUniqueId()));
if (!ignoreOdometer
&& startTrip.getDouble(Position.KEY_ODOMETER) != 0
@@ -303,11 +305,11 @@ public final class ReportUtils {
}
private static <T extends BaseReportItem> T calculateTripOrStop(
- IdentityManager identityManager, ArrayList<Position> positions,
- int startIndex, int endIndex, boolean ignoreOdometer, Class<T> reportClass) {
+ Storage storage, IdentityManager identityManager, ArrayList<Position> positions,
+ int startIndex, int endIndex, boolean ignoreOdometer, Class<T> reportClass) throws StorageException {
if (reportClass.equals(TripReportItem.class)) {
- return (T) calculateTrip(identityManager, positions, startIndex, endIndex, ignoreOdometer);
+ return (T) calculateTrip(storage, identityManager, positions, startIndex, endIndex, ignoreOdometer);
} else {
return (T) calculateStop(identityManager, positions, startIndex, endIndex, ignoreOdometer);
}
@@ -334,9 +336,9 @@ public final class ReportUtils {
}
public static <T extends BaseReportItem> Collection<T> detectTripsAndStops(
- IdentityManager identityManager, DeviceManager deviceManager,
+ Storage storage, IdentityManager identityManager, DeviceManager deviceManager,
Collection<Position> positionCollection,
- TripsConfig tripsConfig, boolean ignoreOdometer, Class<T> reportClass) {
+ TripsConfig tripsConfig, boolean ignoreOdometer, Class<T> reportClass) throws StorageException {
Collection<T> result = new ArrayList<>();
@@ -369,13 +371,13 @@ public final class ReportUtils {
}
if (startEventIndex != -1 && startNoEventIndex != -1 && event != null
&& trips != deviceState.getMotionState()) {
- result.add(calculateTripOrStop(identityManager, positions,
+ result.add(calculateTripOrStop(storage, identityManager, positions,
startEventIndex, startNoEventIndex, ignoreOdometer, reportClass));
startEventIndex = -1;
}
}
if (startEventIndex != -1 && (startNoEventIndex != -1 || !trips)) {
- result.add(calculateTripOrStop(identityManager, positions,
+ result.add(calculateTripOrStop(storage, identityManager, positions,
startEventIndex, startNoEventIndex != -1 ? startNoEventIndex : positions.size() - 1,
ignoreOdometer, reportClass));
}
diff --git a/src/main/java/org/traccar/session/cache/CacheManager.java b/src/main/java/org/traccar/session/cache/CacheManager.java
index 102a31ecd..6ea0f252d 100644
--- a/src/main/java/org/traccar/session/cache/CacheManager.java
+++ b/src/main/java/org/traccar/session/cache/CacheManager.java
@@ -105,6 +105,13 @@ public class CacheManager {
}
}
+ public Driver findDriverByUniqueId(long deviceId, String driverUniqueId) {
+ return getDeviceObjects(deviceId, Driver.class).stream()
+ .filter(driver -> driver.getUniqueId().equals(driverUniqueId))
+ .findFirst()
+ .orElse(null);
+ }
+
public void addDevice(long deviceId) throws StorageException {
try {
lock.writeLock().lock();
diff --git a/src/test/java/org/traccar/reports/ReportUtilsTest.java b/src/test/java/org/traccar/reports/ReportUtilsTest.java
index e947a9afa..9b287a0fd 100644
--- a/src/test/java/org/traccar/reports/ReportUtilsTest.java
+++ b/src/test/java/org/traccar/reports/ReportUtilsTest.java
@@ -9,6 +9,7 @@ import org.traccar.reports.common.ReportUtils;
import org.traccar.reports.model.StopReportItem;
import org.traccar.reports.model.TripReportItem;
import org.traccar.reports.common.TripsConfig;
+import org.traccar.storage.Storage;
import java.text.DateFormat;
import java.text.ParseException;
@@ -79,7 +80,7 @@ public class ReportUtilsTest extends BaseTest {
}
@Test
- public void testDetectTripsSimple() throws ParseException {
+ public void testDetectTripsSimple() throws Exception {
List<Position> data = Arrays.asList(
position("2016-01-01 00:00:00.000", 0, 0),
@@ -94,7 +95,7 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01);
Collection<TripReportItem> trips = ReportUtils.detectTripsAndStops(
- mockIdentityManager(), null, data, tripsConfig, false, TripReportItem.class);
+ mock(Storage.class), mockIdentityManager(), null, data, tripsConfig, false, TripReportItem.class);
assertNotNull(trips);
assertFalse(trips.isEmpty());
@@ -109,7 +110,7 @@ public class ReportUtilsTest extends BaseTest {
assertEquals(3000, itemTrip.getDistance(), 0.01);
Collection<StopReportItem> stops = ReportUtils.detectTripsAndStops(
- mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
+ mock(Storage.class), mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
assertNotNull(stops);
assertFalse(stops.isEmpty());
@@ -131,7 +132,7 @@ public class ReportUtilsTest extends BaseTest {
}
@Test
- public void testDetectTripsSimpleWithIgnition() throws ParseException {
+ public void testDetectTripsSimpleWithIgnition() throws Exception {
List<Position> data = Arrays.asList(
position("2016-01-01 00:00:00.000", 0, 0),
@@ -148,7 +149,7 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, true, false, 0.01);
Collection<TripReportItem> trips = ReportUtils.detectTripsAndStops(
- mockIdentityManager(), null, data, tripsConfig, false, TripReportItem.class);
+ mock(Storage.class), mockIdentityManager(), null, data, tripsConfig, false, TripReportItem.class);
assertNotNull(trips);
assertFalse(trips.isEmpty());
@@ -163,7 +164,7 @@ public class ReportUtilsTest extends BaseTest {
assertEquals(3000, itemTrip.getDistance(), 0.01);
trips = ReportUtils.detectTripsAndStops(
- mockIdentityManager(), null, data, tripsConfig, false, TripReportItem.class);
+ mock(Storage.class), mockIdentityManager(), null, data, tripsConfig, false, TripReportItem.class);
assertNotNull(trips);
assertFalse(trips.isEmpty());
@@ -178,7 +179,7 @@ public class ReportUtilsTest extends BaseTest {
assertEquals(3000, itemTrip.getDistance(), 0.01);
Collection<StopReportItem> stops = ReportUtils.detectTripsAndStops(
- mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
+ mock(Storage.class), mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
assertNotNull(stops);
assertFalse(stops.isEmpty());
@@ -200,7 +201,7 @@ public class ReportUtilsTest extends BaseTest {
}
@Test
- public void testDetectTripsWithFluctuation() throws ParseException {
+ public void testDetectTripsWithFluctuation() throws Exception {
List<Position> data = Arrays.asList(
position("2016-01-01 00:00:00.000", 0, 0),
@@ -219,7 +220,7 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01);
Collection<TripReportItem> trips = ReportUtils.detectTripsAndStops(
- mockIdentityManager(), null, data, tripsConfig, false, TripReportItem.class);
+ mock(Storage.class), mockIdentityManager(), null, data, tripsConfig, false, TripReportItem.class);
assertNotNull(trips);
assertFalse(trips.isEmpty());
@@ -234,7 +235,7 @@ public class ReportUtilsTest extends BaseTest {
assertEquals(7000, itemTrip.getDistance(), 0.01);
Collection<StopReportItem> stops = ReportUtils.detectTripsAndStops(
- mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
+ mock(Storage.class), mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
assertNotNull(stops);
assertFalse(stops.isEmpty());
@@ -256,7 +257,7 @@ public class ReportUtilsTest extends BaseTest {
}
@Test
- public void testDetectStopsOnly() throws ParseException {
+ public void testDetectStopsOnly() throws Exception {
Collection<Position> data = Arrays.asList(
position("2016-01-01 00:00:00.000", 0, 0),
@@ -269,7 +270,7 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
Collection<StopReportItem> result = ReportUtils.detectTripsAndStops(
- mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
+ mock(Storage.class), mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
assertNotNull(result);
assertFalse(result.isEmpty());
@@ -283,7 +284,7 @@ public class ReportUtilsTest extends BaseTest {
}
@Test
- public void testDetectStopsWithTripCut() throws ParseException {
+ public void testDetectStopsWithTripCut() throws Exception {
Collection<Position> data = Arrays.asList(
position("2016-01-01 00:00:00.000", 0, 0),
@@ -296,7 +297,7 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
Collection<StopReportItem> result = ReportUtils.detectTripsAndStops(
- mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
+ mock(Storage.class), mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
assertNotNull(result);
assertFalse(result.isEmpty());
@@ -310,7 +311,7 @@ public class ReportUtilsTest extends BaseTest {
}
@Test
- public void testDetectStopsStartedFromTrip() throws ParseException {
+ public void testDetectStopsStartedFromTrip() throws Exception {
Collection<Position> data = Arrays.asList(
position("2016-01-01 00:00:00.000", 2, 0),
@@ -323,7 +324,7 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
Collection<StopReportItem> result = ReportUtils.detectTripsAndStops(
- mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
+ mock(Storage.class), mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
assertNotNull(result);
assertFalse(result.isEmpty());
@@ -337,7 +338,7 @@ public class ReportUtilsTest extends BaseTest {
}
@Test
- public void testDetectStopsMoving() throws ParseException {
+ public void testDetectStopsMoving() throws Exception {
Collection<Position> data = Arrays.asList(
position("2016-01-01 00:00:00.000", 5, 0),
@@ -350,7 +351,7 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
Collection<StopReportItem> result = ReportUtils.detectTripsAndStops(
- mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
+ mock(Storage.class), mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
assertNotNull(result);
assertTrue(result.isEmpty());
@@ -358,7 +359,7 @@ public class ReportUtilsTest extends BaseTest {
}
@Test
- public void testDetectTripAndStopByGap() throws ParseException {
+ public void testDetectTripAndStopByGap() throws Exception {
Collection<Position> data = Arrays.asList(
position("2016-01-01 00:00:00.000", 7, 100),
@@ -373,7 +374,7 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 200000, 200000, 900000, false, false, 0.01);
Collection<TripReportItem> trips = ReportUtils.detectTripsAndStops(
- mockIdentityManager(), null, data, tripsConfig, false, TripReportItem.class);
+ mock(Storage.class), mockIdentityManager(), null, data, tripsConfig, false, TripReportItem.class);
assertNotNull(trips);
assertFalse(trips.isEmpty());
@@ -388,7 +389,7 @@ public class ReportUtilsTest extends BaseTest {
assertEquals(600, itemTrip.getDistance(), 0.01);
Collection<StopReportItem> stops = ReportUtils.detectTripsAndStops(
- mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
+ mock(Storage.class), mockIdentityManager(), null, data, tripsConfig, false, StopReportItem.class);
assertNotNull(stops);
assertFalse(stops.isEmpty());