use of org.openkilda.persistence.exceptions.PersistenceException in project open-kilda by telstra.
the class FermaIslRepositoryTest method shouldNotUpdateAvailableBandwidthIfEndpointDoesntMatch.
@Test
public void shouldNotUpdateAvailableBandwidthIfEndpointDoesntMatch() {
Isl isl = createIsl(switchA, 1, switchB, 2, IslStatus.ACTIVE, 100L);
isl.setMaxBandwidth(100L);
try {
createPathWithSegment(TEST_FLOW_ID + "_1", switchA, 1, switchB, 3, 33L);
islRepository.updateAvailableBandwidth(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 3);
fail();
} catch (PersistenceException ex) {
// expected
}
Isl islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
assertEquals(100, islAfter.getAvailableBandwidth());
try {
createPathWithSegment(TEST_FLOW_ID + "_2", switchA, 2, switchB, 2, 33L);
islRepository.updateAvailableBandwidth(TEST_SWITCH_A_ID, 2, TEST_SWITCH_B_ID, 2);
fail();
} catch (PersistenceException ex) {
// expected
}
islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
assertEquals(100, islAfter.getAvailableBandwidth());
try {
createPathWithSegment(TEST_FLOW_ID + "_3", switchC, 1, switchB, 2, 33L);
islRepository.updateAvailableBandwidth(TEST_SWITCH_C_ID, 1, TEST_SWITCH_B_ID, 2);
fail();
} catch (PersistenceException ex) {
// expected
}
islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
assertEquals(100, islAfter.getAvailableBandwidth());
try {
createPathWithSegment(TEST_FLOW_ID + "_4", switchA, 1, switchC, 2, 33L);
islRepository.updateAvailableBandwidth(TEST_SWITCH_A_ID, 1, TEST_SWITCH_C_ID, 2);
fail();
} catch (PersistenceException ex) {
// expected
}
islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
assertEquals(100, islAfter.getAvailableBandwidth());
}
Aggregations