-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1117 from OSGP/feature/SMHE-1775_permit_denied_delay
- Loading branch information
Showing
5 changed files
with
79 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...martgridplatform/adapter/protocol/dlms/application/config/ThrottlingClientConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-FileCopyrightText: Copyright Contributors to the GXF project | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.opensmartgridplatform.adapter.protocol.dlms.application.config; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
||
import java.time.Duration; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.EnumSource; | ||
import org.opensmartgridplatform.shared.wsheaderattribute.priority.MessagePriorityEnum; | ||
import org.springframework.test.util.ReflectionTestUtils; | ||
|
||
class ThrottlingClientConfigTest { | ||
private final Duration permitRejectedMinDelay = Duration.parse("PT50S"); | ||
private final Duration permitRejectedMaxDelay = Duration.parse("PT70S"); | ||
private final Duration permitRejectedHighPrioDelay = Duration.parse("PT2S"); | ||
|
||
@ParameterizedTest | ||
@EnumSource(MessagePriorityEnum.class) | ||
void testHttpComponentsMessageSender(final MessagePriorityEnum messagePriority) { | ||
final ThrottlingClientConfig throttlingClientConfig = new ThrottlingClientConfig(); | ||
|
||
ReflectionTestUtils.setField( | ||
throttlingClientConfig, | ||
"permitRejectedMinDelay", | ||
this.permitRejectedMinDelay, | ||
Duration.class); | ||
ReflectionTestUtils.setField( | ||
throttlingClientConfig, | ||
"permitRejectedMaxDelay", | ||
this.permitRejectedMaxDelay, | ||
Duration.class); | ||
ReflectionTestUtils.setField( | ||
throttlingClientConfig, | ||
"permitRejectedHighPrioDelay", | ||
this.permitRejectedHighPrioDelay, | ||
Duration.class); | ||
|
||
final Duration result = | ||
throttlingClientConfig.permitRejectedDelay(messagePriority.getPriority()); | ||
if (messagePriority.getPriority() > MessagePriorityEnum.DEFAULT.getPriority()) { | ||
assertThat(result).isEqualTo(this.permitRejectedHighPrioDelay); | ||
} else { | ||
assertThat(result).isBetween(this.permitRejectedMinDelay, this.permitRejectedMaxDelay); | ||
} | ||
} | ||
} |