use of org.openkilda.model.history.FlowEvent in project open-kilda by telstra.
the class FermaFlowEventRepositoryTest method findByFlowIdAndTimeFrameOrderTest.
@Test
public void findByFlowIdAndTimeFrameOrderTest() {
List<FlowEvent> expected = new ArrayList<>();
expected.add(buildFlowEvent(FLOW_1, TASK_1, ACTION_1, TIME_1));
expected.add(buildFlowEvent(FLOW_1, TASK_2, ACTION_2, TIME_2));
expected.add(buildFlowEvent(FLOW_1, TASK_3, ACTION_3, TIME_3));
for (FlowEvent flowHistory : expected) {
flowEventRepository.add(flowHistory);
}
List<FlowEvent> actual = new ArrayList<>(flowEventRepository.findByFlowIdAndTimeFrame(FLOW_1, TIME_1.minusSeconds(1), TIME_3.plusSeconds(1), 100));
assertEquals(expected, actual);
// result must be sorted by time
assertTrue(actual.get(0).getTimestamp().isBefore(actual.get(1).getTimestamp()));
assertTrue(actual.get(1).getTimestamp().isBefore(actual.get(2).getTimestamp()));
}
use of org.openkilda.model.history.FlowEvent in project open-kilda by telstra.
the class HistoryService method store.
/**
* Save history data into data storage.
*
* @param historyHolder holder of history information.
*/
public void store(FlowHistoryHolder historyHolder) {
transactionManager.doInTransaction(() -> {
String taskId = historyHolder.getTaskId();
if (historyHolder.getFlowEventData() != null) {
FlowEvent event = HistoryMapper.INSTANCE.map(historyHolder.getFlowEventData());
event.setTaskId(taskId);
flowEventRepository.add(event);
}
if (historyHolder.getFlowHistoryData() != null) {
FlowEventAction history = HistoryMapper.INSTANCE.map(historyHolder.getFlowHistoryData());
history.setTaskId(taskId);
flowEventActionRepository.add(history);
}
if (historyHolder.getFlowDumpData() != null) {
FlowEventDump dump = HistoryMapper.INSTANCE.map(historyHolder.getFlowDumpData());
dump.setTaskId(taskId);
flowEventDumpRepository.add(dump);
}
});
}
Aggregations