@Test public void shouldPropagateBfdEnableFlagUpdateOnFullUpdate() throws IslNotFoundException { createIsl(IslStatus.ACTIVE); Collection<Isl> result = linkOperationsService.updateEnableBfdFlag( Endpoint.of(TEST_SWITCH_A_ID, TEST_SWITCH_A_PORT), Endpoint.of(TEST_SWITCH_B_ID, TEST_SWITCH_B_PORT), true); Assert.assertEquals(2, result.size()); verifyBfdEnabledStatus(true); verify(carrier, times(1)).islBfdFlagChanged(any(Isl.class)); verifyNoMoreInteractions(carrier); reset(carrier); result = linkOperationsService.updateEnableBfdFlag( Endpoint.of(TEST_SWITCH_A_ID, TEST_SWITCH_A_PORT), Endpoint.of(TEST_SWITCH_B_ID, TEST_SWITCH_B_PORT), true); Assert.assertEquals(2, result.size()); verifyZeroInteractions(carrier); }
public Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue) throws IslNotFoundException { return transactionManager.doInTransaction(() -> { List<Isl> processed = new ArrayList<>(2); boolean madeChange; madeChange = updateUniIslEnableBfdFlag(source, destination, flagValue, processed); madeChange |= updateUniIslEnableBfdFlag(destination, source, flagValue, processed); if (processed.size() != 2) { throw new IslNotFoundException(source, destination); } if (madeChange) { carrier.islBfdFlagChanged(processed.get(0)); } return processed; }); }
LinkOperationsService { public Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue) throws IslNotFoundException { return transactionManager.doInTransaction(() -> { List<Isl> processed = new ArrayList<>(2); boolean madeChange; madeChange = updateUniIslEnableBfdFlag(source, destination, flagValue, processed); madeChange |= updateUniIslEnableBfdFlag(destination, source, flagValue, processed); if (processed.size() != 2) { throw new IslNotFoundException(source, destination); } if (madeChange) { carrier.islBfdFlagChanged(processed.get(0)); } return processed; }); } }
LinkOperationsService { public Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue) throws IslNotFoundException { return transactionManager.doInTransaction(() -> { List<Isl> processed = new ArrayList<>(2); boolean madeChange; madeChange = updateUniIslEnableBfdFlag(source, destination, flagValue, processed); madeChange |= updateUniIslEnableBfdFlag(destination, source, flagValue, processed); if (processed.size() != 2) { throw new IslNotFoundException(source, destination); } if (madeChange) { carrier.islBfdFlagChanged(processed.get(0)); } return processed; }); } LinkOperationsService(ILinkOperationsServiceCarrier carrier,
                                 RepositoryFactory repositoryFactory,
                                 TransactionManager transactionManager); }
LinkOperationsService { public Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue) throws IslNotFoundException { return transactionManager.doInTransaction(() -> { List<Isl> processed = new ArrayList<>(2); boolean madeChange; madeChange = updateUniIslEnableBfdFlag(source, destination, flagValue, processed); madeChange |= updateUniIslEnableBfdFlag(destination, source, flagValue, processed); if (processed.size() != 2) { throw new IslNotFoundException(source, destination); } if (madeChange) { carrier.islBfdFlagChanged(processed.get(0)); } return processed; }); } LinkOperationsService(ILinkOperationsServiceCarrier carrier,
                                 RepositoryFactory repositoryFactory,
                                 TransactionManager transactionManager); List<Isl> updateLinkUnderMaintenanceFlag(SwitchId srcSwitchId, Integer srcPort,
                                                    SwitchId dstSwitchId, Integer dstPort,
                                                    boolean underMaintenance); Collection<Isl> getAllIsls(SwitchId srcSwitch, Integer srcPort,
                                      SwitchId dstSwitch, Integer dstPort); Collection<Isl> deleteIsl(SwitchId sourceSwitch, int sourcePort, SwitchId destinationSwitch,
                                     int destinationPort, boolean force); Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue); }
LinkOperationsService { public Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue) throws IslNotFoundException { return transactionManager.doInTransaction(() -> { List<Isl> processed = new ArrayList<>(2); boolean madeChange; madeChange = updateUniIslEnableBfdFlag(source, destination, flagValue, processed); madeChange |= updateUniIslEnableBfdFlag(destination, source, flagValue, processed); if (processed.size() != 2) { throw new IslNotFoundException(source, destination); } if (madeChange) { carrier.islBfdFlagChanged(processed.get(0)); } return processed; }); } LinkOperationsService(ILinkOperationsServiceCarrier carrier,
                                 RepositoryFactory repositoryFactory,
                                 TransactionManager transactionManager); List<Isl> updateLinkUnderMaintenanceFlag(SwitchId srcSwitchId, Integer srcPort,
                                                    SwitchId dstSwitchId, Integer dstPort,
                                                    boolean underMaintenance); Collection<Isl> getAllIsls(SwitchId srcSwitch, Integer srcPort,
                                      SwitchId dstSwitch, Integer dstPort); Collection<Isl> deleteIsl(SwitchId sourceSwitch, int sourcePort, SwitchId destinationSwitch,
                                     int destinationPort, boolean force); Collection<Isl> updateEnableBfdFlag(Endpoint source, Endpoint destination, boolean flagValue);  }