Search in sources :

Example 6 with Config

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());
}
Also used : DeviceState(org.traccar.model.DeviceState) Position(org.traccar.model.Position) Config(org.traccar.config.Config) Event(org.traccar.model.Event) Date(java.util.Date)

Example 7 with Config

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);
}
Also used : Config(org.traccar.config.Config) Before(org.junit.Before)

Example 8 with 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;
}
Also used : JSR353Module(com.fasterxml.jackson.datatype.jsr353.JSR353Module) TripsConfig(org.traccar.reports.model.TripsConfig) Config(org.traccar.config.Config) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 9 with Config

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);
}
Also used : JSR353Module(com.fasterxml.jackson.datatype.jsr353.JSR353Module) SnsSmsClient(org.traccar.sms.SnsSmsClient) TripsConfig(org.traccar.reports.model.TripsConfig) Config(org.traccar.config.Config) LdapProvider(org.traccar.database.LdapProvider) EventForwarder(org.traccar.notification.EventForwarder) ConnectionManager(org.traccar.database.ConnectionManager) SanitizerModule(org.traccar.helper.SanitizerModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) GroupsManager(org.traccar.database.GroupsManager) ScheduleManager(org.traccar.schedule.ScheduleManager) DriversManager(org.traccar.database.DriversManager) AttributesManager(org.traccar.database.AttributesManager) DataManager(org.traccar.database.DataManager) DeviceManager(org.traccar.database.DeviceManager) UnknownHostException(java.net.UnknownHostException) UsersManager(org.traccar.database.UsersManager) HttpSmsClient(org.traccar.sms.HttpSmsClient) WebServer(org.traccar.web.WebServer) MediaManager(org.traccar.database.MediaManager) MailManager(org.traccar.database.MailManager) PermissionsManager(org.traccar.database.PermissionsManager) CommandsManager(org.traccar.database.CommandsManager) OrderManager(org.traccar.database.OrderManager)

Aggregations

Config (org.traccar.config.Config)9 Position (org.traccar.model.Position)6 Test (org.junit.Test)4 Event (org.traccar.model.Event)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 JSR353Module (com.fasterxml.jackson.datatype.jsr353.JSR353Module)2 Date (java.util.Date)2 DeviceState (org.traccar.model.DeviceState)2 TripsConfig (org.traccar.reports.model.TripsConfig)2 UnknownHostException (java.net.UnknownHostException)1 Before (org.junit.Before)1 BaseTest (org.traccar.BaseTest)1 TestIdentityManager (org.traccar.TestIdentityManager)1 AttributesManager (org.traccar.database.AttributesManager)1 CommandsManager (org.traccar.database.CommandsManager)1 ConnectionManager (org.traccar.database.ConnectionManager)1 DataManager (org.traccar.database.DataManager)1 DeviceManager (org.traccar.database.DeviceManager)1 DriversManager (org.traccar.database.DriversManager)1 GroupsManager (org.traccar.database.GroupsManager)1