### Question:
FermaLinkPropsRepository extends FermaGenericRepository<LinkProps, LinkPropsData, LinkPropsFrame> implements LinkPropsRepository { @Override public Collection<LinkProps> findByEndpoints(SwitchId srcSwitch, Integer srcPort, SwitchId dstSwitch, Integer dstPort) { return framedGraph().traverse(g -> { GraphTraversal<Vertex, Vertex> traversal = g.V() .hasLabel(LinkPropsFrame.FRAME_LABEL); if (srcSwitch != null) { traversal = traversal.has(LinkPropsFrame.SRC_SWITCH_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(srcSwitch)); } if (srcPort != null) { traversal = traversal.has(LinkPropsFrame.SRC_PORT_PROPERTY, srcPort); } if (dstSwitch != null) { traversal = traversal.has(LinkPropsFrame.DST_SWITCH_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(dstSwitch)); } if (dstPort != null) { traversal = traversal.has(LinkPropsFrame.DST_PORT_PROPERTY, dstPort); } return traversal; }).toListExplicit(LinkPropsFrame.class).stream() .map(LinkProps::new) .collect(Collectors.toList()); } FermaLinkPropsRepository(FramedGraphFactory<?> graphFactory, TransactionManager transactionManager); @Override Collection<LinkProps> findAll(); @Override Collection<LinkProps> findByEndpoints(SwitchId srcSwitch, Integer srcPort,
                                                 SwitchId dstSwitch, Integer dstPort);  }### Answer:
@Test public void shouldFindLinkPropsByEndpoints() { createLinkProps(2); List<LinkProps> foundLinkProps = Lists.newArrayList( linkPropsRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2)); assertThat(foundLinkProps, Matchers.hasSize(1)); }
@Test public void shouldFindLinkPropsBySrcEndpoint() { createLinkProps(2); List<LinkProps> foundLinkProps = Lists.newArrayList( linkPropsRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, null, null)); assertThat(foundLinkProps, Matchers.hasSize(1)); }
@Test public void shouldFindLinkPropsByDestEndpoint() { createLinkProps(2); List<LinkProps> foundLinkProps = Lists.newArrayList( linkPropsRepository.findByEndpoints(null, null, TEST_SWITCH_B_ID, 2)); assertThat(foundLinkProps, Matchers.hasSize(1)); }
@Test public void shouldFindLinkPropsBySrcAndDestSwitches() { createLinkProps(1); List<LinkProps> foundLinkProps = Lists.newArrayList( linkPropsRepository.findByEndpoints(TEST_SWITCH_A_ID, null, TEST_SWITCH_B_ID, null)); assertThat(foundLinkProps, Matchers.hasSize(1)); }