### Question:
FermaSwitchPropertiesRepository extends FermaGenericRepository<SwitchProperties, SwitchPropertiesData, SwitchPropertiesFrame> implements SwitchPropertiesRepository { @Override public Optional<SwitchProperties> findBySwitchId(SwitchId switchId) { List<? extends SwitchPropertiesFrame> switchPropertiesFrames = framedGraph().traverse(g -> g.V() .hasLabel(SwitchPropertiesFrame.FRAME_LABEL) .has(SwitchPropertiesFrame.SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId))) .toListExplicit(SwitchPropertiesFrame.class); return switchPropertiesFrames.isEmpty() ? Optional.empty() : Optional.of(switchPropertiesFrames.get(0)) .map(SwitchProperties::new); } FermaSwitchPropertiesRepository(FramedGraphFactory<?> graphFactory, TransactionManager transactionManager); @Override Collection<SwitchProperties> findAll(); @Override Optional<SwitchProperties> findBySwitchId(SwitchId switchId);  }### Answer:
@Test public void shouldFindSwitchPropertiesBySwitchId() { Switch origSwitch = Switch.builder() .switchId(TEST_SWITCH_ID) .description("Some description") .build(); switchRepository.add(origSwitch); SwitchProperties switchProperties = SwitchProperties.builder() .switchObj(origSwitch) .supportedTransitEncapsulation(SwitchProperties.DEFAULT_FLOW_ENCAPSULATION_TYPES) .build(); switchPropertiesRepository.add(switchProperties); Optional<SwitchProperties> switchPropertiesOptional = switchPropertiesRepository.findBySwitchId(TEST_SWITCH_ID); assertTrue(switchPropertiesOptional.isPresent()); }
@Test public void shouldCreatePropertiesWithServer42Props() { Switch origSwitch = Switch.builder().switchId(TEST_SWITCH_ID) .description("Some description").build(); switchRepository.add(origSwitch); SwitchProperties switchProperties = SwitchProperties.builder() .switchObj(origSwitch) .server42FlowRtt(true) .server42Port(SERVER_42_PORT) .server42Vlan(SERVER_42_VLAN) .server42MacAddress(SERVER_42_MAC_ADDRESS) .supportedTransitEncapsulation(SwitchProperties.DEFAULT_FLOW_ENCAPSULATION_TYPES) .build(); switchPropertiesRepository.add(switchProperties); Optional<SwitchProperties> switchPropertiesOptional = switchPropertiesRepository.findBySwitchId(TEST_SWITCH_ID); assertTrue(switchPropertiesOptional.isPresent()); assertTrue(switchPropertiesOptional.get().isServer42FlowRtt()); assertEquals(SERVER_42_PORT, switchPropertiesOptional.get().getServer42Port()); assertEquals(SERVER_42_VLAN, switchPropertiesOptional.get().getServer42Vlan()); assertEquals(SERVER_42_MAC_ADDRESS, switchPropertiesOptional.get().getServer42MacAddress()); }
@Test public void shouldCreatePropertiesWithNullServer42Props() { Switch origSwitch = Switch.builder().switchId(TEST_SWITCH_ID) .description("Some description").build(); switchRepository.add(origSwitch); SwitchProperties switchProperties = SwitchProperties.builder() .switchObj(origSwitch) .server42Port(null) .server42Vlan(null) .server42MacAddress(null) .supportedTransitEncapsulation(SwitchProperties.DEFAULT_FLOW_ENCAPSULATION_TYPES).build(); switchPropertiesRepository.add(switchProperties); Optional<SwitchProperties> switchPropertiesOptional = switchPropertiesRepository.findBySwitchId(TEST_SWITCH_ID); assertTrue(switchPropertiesOptional.isPresent()); assertFalse(switchPropertiesOptional.get().isServer42FlowRtt()); assertNull(switchPropertiesOptional.get().getServer42Port()); assertNull(switchPropertiesOptional.get().getServer42MacAddress()); }