DatabaseFDFlowManager extends BaseService implements FDFlowManager { @Override public Optional<FDFlowEvent> getLatestFlowEvent(final String flowId) { final Optional<FDFlowEventEntity> latestFlowEvent = getLatestFlowEventEntity(flowId); if (latestFlowEvent.isPresent()) { final FDFlowEvent flowEvent = modelMapper.map(latestFlowEvent.get(), FDFlowEvent.class); return Optional.of(flowEvent); } else { return Optional.empty(); } } @Autowired  DatabaseFDFlowManager(final FDFlowRepository flowRepository,
                                 final FDFlowEventRepository flowEventRepository,
                                 final OptionalModelMapper modelMapper,
                                 final ObjectMapper objectMapper,
                                 final Validator validator); @Override Optional<FDFlowMetadata> getFlowMetadata(final String flowId); @Override Optional<FDFlow> getFlow(final String flowId); @Override FDFlowMetadata createFlow(final String agentClass, final NiFiUser user); @Override List<FDFlowMetadata> getAvailableFlows(); @Override List<FDFlowSummary> getFlowSummaries(); @Override FDFlowMetadata deleteFlow(final String flowId); @Override List<FDFlowEvent> getFlowEvents(final String flowId); @Override Optional<FDFlowEvent> getLatestFlowEvent(final String flowId); @Override Optional<FDFlowEvent> getLatestPublishFlowEvent(final String flowId); @Override Optional<FDFlowEvent> getFlowEvent(final String flowEventId); @Override FDFlowEvent addFlowEvent(final FDFlowEvent flowEvent, final VersionedProcessGroup flowContent, final NiFiUser user); @Override FDFlowEvent deleteFlowEvent(final String flowEventId); @Override void retainPublishEvents(final String flowId); @Override void revertToFlowRevision(final String flowId, final BigInteger flowRevision); static final FDFlowFormat CURRENT_FLOW_FORMAT; }
@Test public void testGetLatestFlowEventWhenFlowExists() { final String flowId = "2"; final Optional<FDFlowEvent> flowEventOptional = flowManager.getLatestFlowEvent(flowId); assertTrue(flowEventOptional.isPresent()); final FDFlowEvent flowEvent = flowEventOptional.get(); assertEquals("4", flowEvent.getIdentifier()); assertEquals(3, flowEvent.getFlowRevision().intValue()); }
@Test(expected = ResourceNotFoundException.class) public void testGetLatestFlowWhenFlowDoesNotExist() { flowManager.getLatestFlowEvent("DOES-NOT-EXIST"); }