### Question:
FermaBfdSessionRepository extends FermaGenericRepository<BfdSession, BfdSessionData, BfdSessionFrame> implements BfdSessionRepository { @Override public Collection<BfdSession> findAll() { return framedGraph().traverse(g -> g.V() .hasLabel(BfdSessionFrame.FRAME_LABEL)) .toListExplicit(BfdSessionFrame.class).stream() .map(BfdSession::new) .collect(Collectors.toList()); } FermaBfdSessionRepository(FramedGraphFactory<?> graphFactory, TransactionManager transactionManager); @Override Collection<BfdSession> findAll(); @Override boolean exists(SwitchId switchId, Integer port); @Override Optional<BfdSession> findBySwitchIdAndPort(SwitchId switchId, Integer port);  }### Answer:
@Test public void shouldCreateBfdPort() { createBfdSession(); assertEquals(1, repository.findAll().size()); }
@Test public void shouldDeleteBfdPort() { BfdSession bfdSession = createBfdSession(); assertEquals(1, repository.findAll().size()); transactionManager.doInTransaction(() -> repository.remove(bfdSession)); assertEquals(0, repository.findAll().size()); }
@Ignore("Need to fix: in-memory persistence doesn't impose constraints") @Test(expected = ConstraintViolationException.class) public void createUseCaseTest() { assertEquals(TEST_DISCRIMINATOR, getDiscriminator(TEST_SWITCH_ID, TEST_PORT, TEST_DISCRIMINATOR)); assertEquals(TEST_DISCRIMINATOR, getDiscriminator(TEST_SWITCH_ID, TEST_PORT, TEST_DISCRIMINATOR)); assertEquals(1, repository.findAll().size()); assertEquals(TEST_DISCRIMINATOR, getDiscriminator(TEST_SWITCH_ID, TEST_PORT + 1, TEST_DISCRIMINATOR)); }
@Test public void deleteUseCaseTest() { getDiscriminator(TEST_SWITCH_ID, TEST_PORT, TEST_DISCRIMINATOR); assertEquals(1, repository.findAll().size()); freeDiscriminator(TEST_SWITCH_ID, TEST_PORT); assertEquals(0, repository.findAll().size()); }