use of org.opensmartgridplatform.throttling.api.Permit in project open-smart-grid-platform by OSGP.
the class ThrottlingClientTest method clientReleasesPermitForNetworkSegment.
@Test
void clientReleasesPermitForNetworkSegment() {
final short throttlingConfigId = 901;
final int clientId = 4518988;
final int baseTransceiverStationId = 10029;
final int cellId = 1;
final int requestId = 23938477;
this.whenTheThrottlingConfigIsIdentifiedById(throttlingConfigId);
this.whenTheThrottlingClientHasRegisteredWithId(clientId);
this.whenTheThrottlingServiceReleasesThePermit(throttlingConfigId, clientId, baseTransceiverStationId, cellId, requestId, true);
final Permit permitToBeReleased = new Permit(throttlingConfigId, clientId, requestId, baseTransceiverStationId, cellId, Instant.now().minusSeconds(3));
final boolean released = this.throttlingClient.releasePermit(permitToBeReleased);
assertThat(released).isTrue();
}
use of org.opensmartgridplatform.throttling.api.Permit in project open-smart-grid-platform by OSGP.
the class ThrottlingClientTest method unregisteredClientRequestsPermitByNetworkSegment.
@Test
void unregisteredClientRequestsPermitByNetworkSegment() {
final short throttlingConfigId = 37;
final int clientId = 347198;
final int baseTransceiverStationId = 983745;
final int cellId = 2;
final int requestId = 894;
this.whenTheThrottlingClientUsesNextRequestId(requestId);
this.whenTheThrottlingServiceGrantsTheRequestedPermit(throttlingConfigId, clientId, baseTransceiverStationId, cellId, requestId);
final Permit expectedPermit = new Permit(throttlingConfigId, clientId, requestId, baseTransceiverStationId, cellId, null);
final Optional<Permit> requestedPermit = this.throttlingClient.requestPermit(baseTransceiverStationId, cellId);
assertThat(requestedPermit).usingRecursiveComparison().ignoringExpectedNullFields().isEqualTo(Optional.of(expectedPermit));
}
Aggregations