use of org.traccar.config.Config in project traccar by tananaev.
the class OverspeedEventHandlerTest method testOverspeedWithStatus.
private void testOverspeedWithStatus(boolean notRepeat) {
Config config = new Config();
config.setString(Keys.EVENT_OVERSPEED_NOT_REPEAT, String.valueOf(notRepeat));
config.setString(Keys.EVENT_OVERSPEED_MINIMAL_DURATION, String.valueOf(15));
config.setString(Keys.EVENT_OVERSPEED_PREFER_LOWEST, String.valueOf(false));
OverspeedEventHandler overspeedEventHandler = new OverspeedEventHandler(config, null, null);
Position position = new Position();
position.setTime(new Date(System.currentTimeMillis() - 30000));
position.setSpeed(50);
DeviceState deviceState = new DeviceState();
deviceState.setOverspeedState(false);
deviceState.setOverspeedPosition(position);
Map<Event, Position> events = overspeedEventHandler.updateOverspeedState(deviceState, 40);
assertNotNull(events);
Event event = events.keySet().iterator().next();
assertEquals(Event.TYPE_DEVICE_OVERSPEED, event.getType());
assertEquals(notRepeat, deviceState.getOverspeedState());
}
use of org.traccar.config.Config in project traccar by tananaev.
the class FilterHandlerTest method before.
@Before
public void before() {
Config config = new Config();
config.setString(Keys.FILTER_INVALID, String.valueOf(true));
config.setString(Keys.FILTER_ZERO, String.valueOf(true));
config.setString(Keys.FILTER_DUPLICATE, String.valueOf(true));
config.setString(Keys.FILTER_FUTURE, String.valueOf(5 * 60));
config.setString(Keys.FILTER_APPROXIMATE, String.valueOf(true));
config.setString(Keys.FILTER_STATIC, String.valueOf(true));
config.setString(Keys.FILTER_DISTANCE, String.valueOf(10));
config.setString(Keys.FILTER_MAX_SPEED, String.valueOf(500));
config.setString(Keys.FILTER_SKIP_LIMIT, String.valueOf(10));
config.setString(Keys.FILTER_SKIP_ATTRIBUTES_ENABLE, String.valueOf(true));
filteringHandler = new FilterHandler(config);
}
use of org.traccar.config.Config in project traccar by tananaev.
the class Context method init.
public static void init(IdentityManager testIdentityManager, MediaManager testMediaManager) {
config = new Config();
objectMapper = new ObjectMapper();
objectMapper.registerModule(new JSR353Module());
client = ClientBuilder.newClient().register(new ObjectMapperContextResolver());
identityManager = testIdentityManager;
mediaManager = testMediaManager;
}
use of org.traccar.config.Config in project traccar by tananaev.
the class Context method init.
public static void init(String configFile) throws Exception {
try {
config = new Config(configFile);
Log.setupLogger(config);
} catch (Exception e) {
config = new Config();
Log.setupDefaultLogger();
throw e;
}
objectMapper = new ObjectMapper();
objectMapper.registerModule(new SanitizerModule());
objectMapper.registerModule(new JSR353Module());
objectMapper.setConfig(objectMapper.getSerializationConfig().without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS));
client = ClientBuilder.newClient().register(new ObjectMapperContextResolver());
if (config.hasKey(Keys.DATABASE_URL)) {
dataManager = new DataManager(config);
}
if (config.hasKey(Keys.LDAP_URL)) {
ldapProvider = new LdapProvider(config);
}
mailManager = new MailManager();
mediaManager = new MediaManager(config.getString(Keys.MEDIA_PATH));
if (dataManager != null) {
usersManager = new UsersManager(dataManager);
groupsManager = new GroupsManager(dataManager);
deviceManager = new DeviceManager(dataManager);
}
identityManager = deviceManager;
if (config.hasKey(Keys.WEB_PORT)) {
webServer = new WebServer(config);
}
permissionsManager = new PermissionsManager(dataManager, usersManager);
connectionManager = new ConnectionManager();
tripsConfig = initTripsConfig();
if (config.hasKey(Keys.SMS_HTTP_URL)) {
smsManager = new HttpSmsClient();
} else if (config.hasKey(Keys.SMS_AWS_REGION)) {
smsManager = new SnsSmsClient();
}
initEventsModule();
serverManager = new ServerManager();
scheduleManager = new ScheduleManager();
if (config.hasKey(Keys.EVENT_FORWARD_URL)) {
eventForwarder = new EventForwarder();
}
attributesManager = new AttributesManager(dataManager);
driversManager = new DriversManager(dataManager);
commandsManager = new CommandsManager(dataManager, config.getBoolean(Keys.COMMANDS_QUEUEING));
orderManager = new OrderManager(dataManager);
}
Aggregations