Search in sources :

Example 6 with EventId

use of org.thingsboard.server.common.data.id.EventId in project thingsboard by thingsboard.

the class JpaBaseEventDaoTest method getEvent.

private Event getEvent(UUID eventId, UUID tenantId, UUID entityId) {
    Event event = new Event();
    event.setId(new EventId(eventId));
    event.setTenantId(new TenantId(tenantId));
    EntityId deviceId = new DeviceId(entityId);
    event.setEntityId(deviceId);
    event.setUid(event.getId().getId().toString());
    event.setType(STATS);
    ObjectMapper mapper = new ObjectMapper();
    try {
        JsonNode jsonNode = mapper.readTree("{\"key\":\"value\"}");
        event.setBody(jsonNode);
    } catch (IOException e) {
        log.error(e.getMessage(), e);
    }
    return event;
}
Also used : EntityId(org.thingsboard.server.common.data.id.EntityId) TenantId(org.thingsboard.server.common.data.id.TenantId) DeviceId(org.thingsboard.server.common.data.id.DeviceId) Event(org.thingsboard.server.common.data.Event) EventId(org.thingsboard.server.common.data.id.EventId) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

EventId (org.thingsboard.server.common.data.id.EventId)6 Event (org.thingsboard.server.common.data.Event)4 TenantId (org.thingsboard.server.common.data.id.TenantId)3 EventEntity (org.thingsboard.server.dao.model.nosql.EventEntity)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 DeviceId (org.thingsboard.server.common.data.id.DeviceId)1 EntityId (org.thingsboard.server.common.data.id.EntityId)1