@Test public void shouldFindBySwitchIdAndPort() { BfdSession bfdSession = createBfdSession(); BfdSession foundPort = repository.findBySwitchIdAndPort(TEST_SWITCH_ID, TEST_PORT).get(); assertEquals(bfdSession.getDiscriminator(), foundPort.getDiscriminator()); }
@Override public Optional<BfdSession> findBySwitchIdAndPort(SwitchId switchId, Integer port) { List<? extends BfdSessionFrame> bfdSessionFrames = framedGraph().traverse(g -> g.V() .hasLabel(BfdSessionFrame.FRAME_LABEL) .has(BfdSessionFrame.SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId)) .has(BfdSessionFrame.PORT_PROPERTY, port)) .toListExplicit(BfdSessionFrame.class); return bfdSessionFrames.isEmpty() ? Optional.empty() : Optional.of(bfdSessionFrames.get(0)) .map(BfdSession::new); }
FermaBfdSessionRepository extends FermaGenericRepository<BfdSession, BfdSessionData, BfdSessionFrame> implements BfdSessionRepository { @Override public Optional<BfdSession> findBySwitchIdAndPort(SwitchId switchId, Integer port) { List<? extends BfdSessionFrame> bfdSessionFrames = framedGraph().traverse(g -> g.V() .hasLabel(BfdSessionFrame.FRAME_LABEL) .has(BfdSessionFrame.SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId)) .has(BfdSessionFrame.PORT_PROPERTY, port)) .toListExplicit(BfdSessionFrame.class); return bfdSessionFrames.isEmpty() ? Optional.empty() : Optional.of(bfdSessionFrames.get(0)) .map(BfdSession::new); } }
FermaBfdSessionRepository extends FermaGenericRepository<BfdSession, BfdSessionData, BfdSessionFrame> implements BfdSessionRepository { @Override public Optional<BfdSession> findBySwitchIdAndPort(SwitchId switchId, Integer port) { List<? extends BfdSessionFrame> bfdSessionFrames = framedGraph().traverse(g -> g.V() .hasLabel(BfdSessionFrame.FRAME_LABEL) .has(BfdSessionFrame.SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId)) .has(BfdSessionFrame.PORT_PROPERTY, port)) .toListExplicit(BfdSessionFrame.class); return bfdSessionFrames.isEmpty() ? Optional.empty() : Optional.of(bfdSessionFrames.get(0)) .map(BfdSession::new); } FermaBfdSessionRepository(FramedGraphFactory<?> graphFactory, TransactionManager transactionManager); }
FermaBfdSessionRepository extends FermaGenericRepository<BfdSession, BfdSessionData, BfdSessionFrame> implements BfdSessionRepository { @Override public Optional<BfdSession> findBySwitchIdAndPort(SwitchId switchId, Integer port) { List<? extends BfdSessionFrame> bfdSessionFrames = framedGraph().traverse(g -> g.V() .hasLabel(BfdSessionFrame.FRAME_LABEL) .has(BfdSessionFrame.SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId)) .has(BfdSessionFrame.PORT_PROPERTY, port)) .toListExplicit(BfdSessionFrame.class); return bfdSessionFrames.isEmpty() ? Optional.empty() : Optional.of(bfdSessionFrames.get(0)) .map(BfdSession::new); } FermaBfdSessionRepository(FramedGraphFactory<?> graphFactory, TransactionManager transactionManager); @Override Collection<BfdSession> findAll(); @Override boolean exists(SwitchId switchId, Integer port); @Override Optional<BfdSession> findBySwitchIdAndPort(SwitchId switchId, Integer port); }
FermaBfdSessionRepository extends FermaGenericRepository<BfdSession, BfdSessionData, BfdSessionFrame> implements BfdSessionRepository { @Override public Optional<BfdSession> findBySwitchIdAndPort(SwitchId switchId, Integer port) { List<? extends BfdSessionFrame> bfdSessionFrames = framedGraph().traverse(g -> g.V() .hasLabel(BfdSessionFrame.FRAME_LABEL) .has(BfdSessionFrame.SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId)) .has(BfdSessionFrame.PORT_PROPERTY, port)) .toListExplicit(BfdSessionFrame.class); return bfdSessionFrames.isEmpty() ? Optional.empty() : Optional.of(bfdSessionFrames.get(0)) .map(BfdSession::new); } FermaBfdSessionRepository(FramedGraphFactory<?> graphFactory, TransactionManager transactionManager); @Override Collection<BfdSession> findAll(); @Override boolean exists(SwitchId switchId, Integer port); @Override Optional<BfdSession> findBySwitchIdAndPort(SwitchId switchId, Integer port);  }