Search in sources :

Example 11 with EventEntity

use of io.gravitee.management.model.EventEntity in project gravitee-management-rest-api by gravitee-io.

the class ApiService_StartTest method mockEvent.

private EventEntity mockEvent(EventType eventType) throws Exception {
    final JsonNodeFactory factory = JsonNodeFactory.instance;
    ObjectNode node = factory.objectNode();
    node.set("id", factory.textNode(API_ID));
    Map<String, String> properties = new HashMap<>();
    properties.put(Event.EventProperties.API_ID.getValue(), API_ID);
    properties.put(Event.EventProperties.USER.getValue(), USER_NAME);
    Api api = new Api();
    api.setId(API_ID);
    EventEntity event = new EventEntity();
    event.setType(eventType);
    event.setId(UUID.randomUUID().toString());
    event.setPayload(objectMapper.writeValueAsString(api));
    event.setCreatedAt(new Date());
    event.setUpdatedAt(event.getCreatedAt());
    event.setProperties(properties);
    return event;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) EventEntity(io.gravitee.management.model.EventEntity) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory)

Aggregations

EventEntity (io.gravitee.management.model.EventEntity)11 Test (org.junit.Test)7 NewEventEntity (io.gravitee.management.model.NewEventEntity)6 EventCriteria (io.gravitee.repository.management.api.search.EventCriteria)3 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ApiEntity (io.gravitee.management.model.ApiEntity)1 UserEntity (io.gravitee.management.model.UserEntity)1 Permissions (io.gravitee.management.rest.security.Permissions)1 UserNotFoundException (io.gravitee.management.service.exceptions.UserNotFoundException)1 HashMap (java.util.HashMap)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1