use of org.openkilda.model.Isl in project open-kilda by telstra.
the class FermaIslRepositoryTest method shouldUpdateAvailableBandwidthByPath.
@Test
public void shouldUpdateAvailableBandwidthByPath() {
Isl isl = createIsl(switchA, 1, switchB, 2, IslStatus.ACTIVE, 100L);
isl.setMaxBandwidth(100L);
createPathWithSegment(TEST_FLOW_ID, switchA, 1, switchB, 2, 33L);
islRepository.updateAvailableBandwidthOnIslsOccupiedByPath(new PathId(TEST_FLOW_ID));
Isl islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
assertEquals(67, islAfter.getAvailableBandwidth());
}
use of org.openkilda.model.Isl in project open-kilda by telstra.
the class FermaIslRepositoryTest method shouldFindIslBySrcSwitch.
@Test
public void shouldFindIslBySrcSwitch() {
Isl isl1 = createIsl(switchA, 111, switchB, 112);
Isl isl2 = createIsl(switchA, 112, switchB, 113);
List<Isl> foundIsls = Lists.newArrayList(islRepository.findBySrcSwitch(TEST_SWITCH_A_ID));
assertThat(foundIsls, Matchers.hasSize(2));
assertThat(foundIsls, Matchers.containsInAnyOrder(isl1, isl2));
}
use of org.openkilda.model.Isl in project open-kilda by telstra.
the class FermaIslRepositoryTest method shouldFindIslByPartialEndpoints.
@Test
public void shouldFindIslByPartialEndpoints() {
Isl isl1 = createIsl(switchA, 111, switchB, 121);
Isl isl2 = createIsl(switchA, 112, switchC, 121);
List<Isl> foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, 111, TEST_SWITCH_B_ID, 121));
assertThat(foundIsls, Matchers.hasSize(1));
assertThat(foundIsls, Matchers.contains(isl1));
foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, 111, TEST_SWITCH_B_ID, null));
assertThat(foundIsls, Matchers.hasSize(1));
assertThat(foundIsls, Matchers.contains(isl1));
foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, null, TEST_SWITCH_B_ID, 121));
assertThat(foundIsls, Matchers.hasSize(1));
assertThat(foundIsls, Matchers.contains(isl1));
foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, null, TEST_SWITCH_B_ID, null));
assertThat(foundIsls, Matchers.hasSize(1));
assertThat(foundIsls, Matchers.contains(isl1));
foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, 111, null, null));
assertThat(foundIsls, Matchers.hasSize(1));
assertThat(foundIsls, Matchers.contains(isl1));
foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, null, null, 121));
assertThat(foundIsls, Matchers.hasSize(2));
assertThat(foundIsls, Matchers.containsInAnyOrder(isl1, isl2));
foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, null, null, null));
assertThat(foundIsls, Matchers.hasSize(2));
assertThat(foundIsls, Matchers.containsInAnyOrder(isl1, isl2));
foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(new SwitchId(123456), null, null, null));
assertThat(foundIsls, Matchers.empty());
foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(TEST_SWITCH_A_ID, null, new SwitchId(123456), null));
assertThat(foundIsls, Matchers.empty());
foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(null, 111, TEST_SWITCH_B_ID, 121));
assertThat(foundIsls, Matchers.hasSize(1));
assertThat(foundIsls, Matchers.contains(isl1));
foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(null, 111, TEST_SWITCH_B_ID, null));
assertThat(foundIsls, Matchers.hasSize(1));
assertThat(foundIsls, Matchers.contains(isl1));
foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(null, null, TEST_SWITCH_B_ID, 121));
assertThat(foundIsls, Matchers.hasSize(1));
assertThat(foundIsls, Matchers.contains(isl1));
foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(null, 111, null, null));
assertThat(foundIsls, Matchers.hasSize(1));
assertThat(foundIsls, Matchers.contains(isl1));
foundIsls = Lists.newArrayList(islRepository.findByPartialEndpoints(null, null, null, 121));
assertThat(foundIsls, Matchers.hasSize(2));
assertThat(foundIsls, Matchers.containsInAnyOrder(isl1, isl2));
}
Aggregations