use of org.openkilda.model.SwitchId in project open-kilda by telstra.
the class SwitchPropertiesFrame method getSwitchObj.
@Override
public Switch getSwitchObj() {
if (switchObj == null) {
List<? extends SwitchFrame> switchFrames = traverse(v -> v.in(HAS_BY_EDGE).hasLabel(SwitchFrame.FRAME_LABEL)).toListExplicit(SwitchFrame.class);
switchObj = !switchFrames.isEmpty() ? new Switch(switchFrames.get(0)) : null;
SwitchId switchId = switchObj != null ? switchObj.getSwitchId() : null;
if (!Objects.equals(getSwitchId(), switchId)) {
throw new IllegalStateException(format("The switch properties %s has inconsistent switch %s / %s", getId(), getSwitchId(), switchId));
}
}
return switchObj;
}
use of org.openkilda.model.SwitchId in project open-kilda by telstra.
the class PortPropertiesFrame method getSwitchObj.
@Override
public Switch getSwitchObj() {
if (switchObj == null) {
List<? extends SwitchFrame> switchFrames = traverse(v -> v.in(OWNS_SWITCH_EDGE).hasLabel(SwitchFrame.FRAME_LABEL)).toListExplicit(SwitchFrame.class);
switchObj = !switchFrames.isEmpty() ? new Switch(switchFrames.get(0)) : null;
SwitchId switchId = switchObj != null ? switchObj.getSwitchId() : null;
if (!Objects.equals(getSwitchId(), switchId)) {
throw new IllegalStateException(format("The port properties %s has inconsistent switch %s / %s", getId(), getSwitchId(), switchId));
}
}
return switchObj;
}
use of org.openkilda.model.SwitchId in project open-kilda by telstra.
the class TimeModifyPropertyOnFramesTest method shouldUpdateTimeModifyOnImplementedPropertyChange.
@Test
public void shouldUpdateTimeModifyOnImplementedPropertyChange() {
Instant timeModifyBefore = transactionManager.doInTransaction(() -> createTestSwitch(1).getTimeModify());
waitUntilNowIsAfter(timeModifyBefore);
transactionManager.doInTransaction(() -> switchRepository.findById(new SwitchId(1)).get().setSocketAddress(new IpSocketAddress("192.168.10.20", 12345)));
Instant timeModifyAfter = switchRepository.findById(new SwitchId(1)).get().getTimeModify();
assertNotEquals(timeModifyBefore, timeModifyAfter);
}
use of org.openkilda.model.SwitchId in project open-kilda by telstra.
the class TimeModifyPropertyOnFramesTest method shouldNotUpdateTimeModifyOnAnnotatedPropertyWithConverterAndSameValueChange.
@Test
public void shouldNotUpdateTimeModifyOnAnnotatedPropertyWithConverterAndSameValueChange() {
Instant timeModifyBefore = transactionManager.doInTransaction(() -> createTestSwitch(1).getTimeModify());
waitUntilNowIsAfter(timeModifyBefore);
transactionManager.doInTransaction(() -> {
Switch sw = switchRepository.findById(new SwitchId(1)).get();
sw.setStatus(sw.getStatus());
});
Instant timeModifyAfter = switchRepository.findById(new SwitchId(1)).get().getTimeModify();
assertEquals(timeModifyBefore, timeModifyAfter);
}
use of org.openkilda.model.SwitchId in project open-kilda by telstra.
the class TimeModifyPropertyOnFramesTest method shouldUpdateTimeModifyOnAnnotatedPropertyWithConverterChange.
@Test
public void shouldUpdateTimeModifyOnAnnotatedPropertyWithConverterChange() {
Instant timeModifyBefore = transactionManager.doInTransaction(() -> createTestSwitch(1).getTimeModify());
waitUntilNowIsAfter(timeModifyBefore);
transactionManager.doInTransaction(() -> {
switchRepository.findById(new SwitchId(1)).get().setStatus(SwitchStatus.REMOVED);
});
Instant timeModifyAfter = switchRepository.findById(new SwitchId(1)).get().getTimeModify();
assertNotEquals(timeModifyBefore, timeModifyAfter);
}
Aggregations