@Test public void shouldSelectNextInOrderResourceWhenFindUnassignedTransitVlan() { int first = findUnassignedTransitVlanAndCreate("flow_1"); assertEquals(5, first); int second = findUnassignedTransitVlanAndCreate("flow_2"); assertEquals(6, second); int third = findUnassignedTransitVlanAndCreate("flow_3"); assertEquals(7, third); transactionManager.doInTransaction(() -> transitVlanRepository.findByVlan(second).ifPresent(transitVlanRepository::remove)); int fourth = findUnassignedTransitVlanAndCreate("flow_4"); assertEquals(6, fourth); int fifth = findUnassignedTransitVlanAndCreate("flow_5"); assertEquals(8, fifth); }
@Override public Optional<TransitVlan> findByVlan(int vlan) { List<? extends TransitVlanFrame> transitVlanFrames = framedGraph().traverse(g -> g.V() .hasLabel(TransitVlanFrame.FRAME_LABEL) .has(TransitVlanFrame.VLAN_PROPERTY, vlan)) .toListExplicit(TransitVlanFrame.class); return transitVlanFrames.isEmpty() ? Optional.empty() : Optional.of(transitVlanFrames.get(0)) .map(TransitVlan::new); }
FermaTransitVlanRepository extends FermaGenericRepository<TransitVlan, TransitVlanData, TransitVlanFrame> implements TransitVlanRepository { @Override public Optional<TransitVlan> findByVlan(int vlan) { List<? extends TransitVlanFrame> transitVlanFrames = framedGraph().traverse(g -> g.V() .hasLabel(TransitVlanFrame.FRAME_LABEL) .has(TransitVlanFrame.VLAN_PROPERTY, vlan)) .toListExplicit(TransitVlanFrame.class); return transitVlanFrames.isEmpty() ? Optional.empty() : Optional.of(transitVlanFrames.get(0)) .map(TransitVlan::new); } }
FermaTransitVlanRepository extends FermaGenericRepository<TransitVlan, TransitVlanData, TransitVlanFrame> implements TransitVlanRepository { @Override public Optional<TransitVlan> findByVlan(int vlan) { List<? extends TransitVlanFrame> transitVlanFrames = framedGraph().traverse(g -> g.V() .hasLabel(TransitVlanFrame.FRAME_LABEL) .has(TransitVlanFrame.VLAN_PROPERTY, vlan)) .toListExplicit(TransitVlanFrame.class); return transitVlanFrames.isEmpty() ? Optional.empty() : Optional.of(transitVlanFrames.get(0)) .map(TransitVlan::new); } FermaTransitVlanRepository(FramedGraphFactory<?> graphFactory, TransactionManager transactionManager); }
FermaTransitVlanRepository extends FermaGenericRepository<TransitVlan, TransitVlanData, TransitVlanFrame> implements TransitVlanRepository { @Override public Optional<TransitVlan> findByVlan(int vlan) { List<? extends TransitVlanFrame> transitVlanFrames = framedGraph().traverse(g -> g.V() .hasLabel(TransitVlanFrame.FRAME_LABEL) .has(TransitVlanFrame.VLAN_PROPERTY, vlan)) .toListExplicit(TransitVlanFrame.class); return transitVlanFrames.isEmpty() ? Optional.empty() : Optional.of(transitVlanFrames.get(0)) .map(TransitVlan::new); } FermaTransitVlanRepository(FramedGraphFactory<?> graphFactory, TransactionManager transactionManager); @Override Collection<TransitVlan> findAll(); @Override Collection<TransitVlan> findByPathId(PathId pathId, PathId oppositePathId); @Override Optional<TransitVlan> findByPathId(PathId pathId); @Override boolean exists(int vlan); @Override Optional<TransitVlan> findByVlan(int vlan); @Override Optional<Integer> findFirstUnassignedVlan(int lowestTransitVlan, int highestTransitVlan); }
FermaTransitVlanRepository extends FermaGenericRepository<TransitVlan, TransitVlanData, TransitVlanFrame> implements TransitVlanRepository { @Override public Optional<TransitVlan> findByVlan(int vlan) { List<? extends TransitVlanFrame> transitVlanFrames = framedGraph().traverse(g -> g.V() .hasLabel(TransitVlanFrame.FRAME_LABEL) .has(TransitVlanFrame.VLAN_PROPERTY, vlan)) .toListExplicit(TransitVlanFrame.class); return transitVlanFrames.isEmpty() ? Optional.empty() : Optional.of(transitVlanFrames.get(0)) .map(TransitVlan::new); } FermaTransitVlanRepository(FramedGraphFactory<?> graphFactory, TransactionManager transactionManager); @Override Collection<TransitVlan> findAll(); @Override Collection<TransitVlan> findByPathId(PathId pathId, PathId oppositePathId); @Override Optional<TransitVlan> findByPathId(PathId pathId); @Override boolean exists(int vlan); @Override Optional<TransitVlan> findByVlan(int vlan); @Override Optional<Integer> findFirstUnassignedVlan(int lowestTransitVlan, int highestTransitVlan);  }