### Question:
DatabaseFDFlowManager extends BaseService implements FDFlowManager { @Override public Optional<FDFlowMetadata> getFlowMetadata(final String flowId) { if (StringUtils.isBlank(flowId)) { throw new IllegalArgumentException("Flow id cannot be null or blank"); } final Optional<FDFlowEntity> flowEntity = flowRepository.findById(flowId); if (!flowEntity.isPresent()) { return Optional.empty(); } final FDFlowMetadata flowMetadata = modelMapper.map(flowEntity.get(), FDFlowMetadata.class); return Optional.of(flowMetadata); } @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; }### Answer:
@Test public void testGetFlowMetadataWhenExists() { final Optional<FDFlowMetadata> flowMetadataOptional = flowManager.getFlowMetadata("2"); assertTrue(flowMetadataOptional.isPresent()); final FDFlowMetadata flowMetadata = flowMetadataOptional.get(); assertEquals("2", flowMetadata.getIdentifier()); assertEquals("Class 2", flowMetadata.getAgentClass()); assertNotNull(flowMetadata.getCreated()); assertNotNull(flowMetadata.getUpdated()); }
@Test public void testGetFlowMetadataWhenDoesNotExist() { final Optional<FDFlowMetadata> flowMetadataOptional = flowManager.getFlowMetadata("DOES-NOT-EXIST"); assertFalse(flowMetadataOptional.isPresent()); }