blob: 10cdf6a9020d24dc020f5728101c59466547070c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package org.traccar.handler;
import org.junit.jupiter.api.Test;
import org.traccar.config.Config;
import org.traccar.config.Keys;
import org.traccar.model.Device;
import org.traccar.model.Position;
import org.traccar.session.cache.CacheManager;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class MotionHandlerTest {
@Test
public void testCalculateMotion() {
var cacheManager = mock(CacheManager.class);
when(cacheManager.getObject(eq(Device.class), anyLong())).thenReturn(mock(Device.class));
var config = mock(Config.class);
when(config.getString(Keys.EVENT_MOTION_SPEED_THRESHOLD.getKey())).thenReturn("0.01");
when(cacheManager.getConfig()).thenReturn(config);
MotionHandler motionHandler = new MotionHandler(cacheManager);
Position position = motionHandler.handlePosition(new Position());
assertEquals(false, position.getAttributes().get(Position.KEY_MOTION));
}
}
|