use of net.nemerosa.ontrack.model.events.Event in project ontrack by nemerosa.
the class EventJdbcRepository method toEvent.
private Event toEvent(ResultSet rs, BiFunction<ProjectEntityType, ID, ProjectEntity> entityLoader, Function<String, EventType> eventTypeLoader) throws SQLException {
// Event type name
String eventTypeName = rs.getString("event_type");
// Signature
Signature signature = readSignature(rs, "event_time", "event_user");
// Entities
Map<ProjectEntityType, ProjectEntity> entities = new LinkedHashMap<>();
for (ProjectEntityType type : ProjectEntityType.values()) {
int entityId = rs.getInt(type.name());
if (!rs.wasNull()) {
ProjectEntity entity = entityLoader.apply(type, ID.of(entityId));
entities.put(type, entity);
}
}
// Reference (if any)
ProjectEntityType refEntity = getEnum(ProjectEntityType.class, rs, "ref");
// Values
Map<String, NameValue> values = loadValues(rs);
// OK
return new Event(eventTypeLoader.apply(eventTypeName), signature, entities, refEntity, values);
}
use of net.nemerosa.ontrack.model.events.Event in project ontrack by nemerosa.
the class EventPostServiceImpl method post.
@Override
public void post(Event event) {
Event e = event;
if (e.getSignature() == null) {
e = e.withSignature(securityService.getCurrentSignature());
}
eventRepository.post(e);
// Notification to the listeners
eventListenerService.onEvent(event);
}
use of net.nemerosa.ontrack.model.events.Event in project ontrack by nemerosa.
the class ConfigurationServiceTest method event_on_delete_configuration.
@Test
public void event_on_delete_configuration() {
TestConfiguration config = config("test");
Event event = Event.of(EventFactory.DELETE_CONFIGURATION).with("configuration", "test").get();
when(configurationRepository.find(TestConfiguration.class, "test")).thenReturn(Optional.of(config));
when(eventFactory.deleteConfiguration(config.withPassword("xxxxx"))).thenReturn(event);
when(encryptionService.decrypt(PLAIN_PASSWORD)).thenReturn("xxxxx");
configurationService.deleteConfiguration("test");
verify(eventPostService).post(event);
}
use of net.nemerosa.ontrack.model.events.Event in project ontrack by nemerosa.
the class ConfigurationServiceTest method event_on_update_configuration.
@Test
public void event_on_update_configuration() {
TestConfiguration config = config("test");
Event event = Event.of(EventFactory.UPDATE_CONFIGURATION).with("configuration", "test").get();
when(eventFactory.updateConfiguration(config)).thenReturn(event);
when(configurationRepository.find(TestConfiguration.class, "test")).thenReturn(Optional.of(config));
configurationService.updateConfiguration("test", config);
verify(eventPostService).post(event);
}
use of net.nemerosa.ontrack.model.events.Event in project ontrack by nemerosa.
the class ConfigurationServiceTest method event_on_new_configuration.
@Test
public void event_on_new_configuration() {
TestConfiguration config = config("test");
Event event = Event.of(EventFactory.NEW_CONFIGURATION).with("configuration", "test").get();
when(eventFactory.newConfiguration(config)).thenReturn(event);
configurationService.newConfiguration(config);
verify(eventPostService).post(event);
}
Aggregations