### Question:
FermaFlowMeterRepository extends FermaGenericRepository<FlowMeter, FlowMeterData, FlowMeterFrame> implements FlowMeterRepository { @Override public Optional<FlowMeter> findByPathId(PathId pathId) { List<? extends FlowMeterFrame> flowMeterFrames = framedGraph().traverse(g -> g.V() .hasLabel(FlowMeterFrame.FRAME_LABEL) .has(FlowMeterFrame.PATH_ID_PROPERTY, PathIdConverter.INSTANCE.toGraphProperty(pathId))) .toListExplicit(FlowMeterFrame.class); return flowMeterFrames.isEmpty() ? Optional.empty() : Optional.of(flowMeterFrames.get(0)) .map(FlowMeter::new); } FermaFlowMeterRepository(FramedGraphFactory<?> graphFactory, TransactionManager transactionManager); @Override Collection<FlowMeter> findAll(); @Override Optional<FlowMeter> findByPathId(PathId pathId); @Override boolean exists(SwitchId switchId, MeterId meterId); @Override Optional<MeterId> findFirstUnassignedMeter(SwitchId switchId, MeterId lowestMeterId,
                                                      MeterId highestMeterId);  }### Answer:
@Ignore("InMemoryGraph doesn't enforce constraint") @Test(expected = PersistenceException.class) public void shouldNotGetMoreThanOneMetersForPath() { createFlowMeter(1, new PathId(TEST_PATH_ID)); createFlowMeter(2, new PathId(TEST_PATH_ID)); flowMeterRepository.findByPathId(new PathId(TEST_PATH_ID)); }
@Test public void shouldGetZeroMetersForPath() { Optional<FlowMeter> meters = flowMeterRepository.findByPathId(new PathId(TEST_PATH_ID)); assertFalse(meters.isPresent()); }