Remove WithSpringContextRule (#1505)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2023-12-07 23:52:23 +02:00
committed by GitHub
parent aa1bad91e1
commit 1ae72d4ead
16 changed files with 69 additions and 103 deletions

View File

@@ -50,7 +50,7 @@ import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.test.TestConfiguration;
import org.eclipse.hawkbit.repository.test.util.TestdataFactory;
import org.eclipse.hawkbit.repository.test.util.WithSpringAuthorityRule;
import org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch;
import org.eclipse.hawkbit.util.IpUtil;
import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mockito;
@@ -102,10 +102,10 @@ public abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpInt
protected <T> T waitUntilIsPresent(final Callable<Optional<T>> callable) {
createConditionFactory()
.until(() -> WithSpringAuthorityRule.runAsPrivileged(() -> callable.call().isPresent()));
.until(() -> SecurityContextSwitch.runAsPrivileged(() -> callable.call().isPresent()));
try {
return WithSpringAuthorityRule.runAsPrivileged(() -> callable.call().get());
return SecurityContextSwitch.runAsPrivileged(() -> callable.call().get());
} catch (final Exception e) {
return null;
}
@@ -429,7 +429,7 @@ public abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpInt
createConditionFactory().untilAsserted(() -> {
try {
final Map<String, String> controllerAttributes = WithSpringAuthorityRule
final Map<String, String> controllerAttributes = SecurityContextSwitch
.runAsPrivileged(() -> targetManagement.getControllerAttributes(controllerId));
assertThat(controllerAttributes.size()).isEqualTo(attributes.size());
assertThat(controllerAttributes).containsAllEntriesOf(attributes);

View File

@@ -72,7 +72,7 @@ import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.test.matcher.Expect;
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
import org.eclipse.hawkbit.repository.test.util.WithSpringAuthorityRule;
import org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
@@ -565,7 +565,7 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
}
private void waitUntil(final Callable<Boolean> callable) {
createConditionFactory().until(() -> WithSpringAuthorityRule.runAsPrivileged(callable));
createConditionFactory().until(() -> SecurityContextSwitch.runAsPrivileged(callable));
}
private void assertLatestMultiActionMessageContainsInstallMessages(final String controllerId,

View File

@@ -63,7 +63,7 @@ import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.test.matcher.Expect;
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
import org.eclipse.hawkbit.repository.test.util.TargetTestData;
import org.eclipse.hawkbit.repository.test.util.WithSpringAuthorityRule;
import org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.NullSource;
@@ -941,7 +941,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
private void assertAction(final Long actionId, final int messages, final Status... expectedActionStates) {
createConditionFactory().await().untilAsserted(() -> {
try {
WithSpringAuthorityRule.runAsPrivileged(() -> {
SecurityContextSwitch.runAsPrivileged(() -> {
final List<ActionStatus> actionStatusList = deploymentManagement
.findActionStatusByAction(PAGE, actionId).getContent();
@@ -979,7 +979,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
final Status... expectedActionStates) {
createConditionFactory().await().untilAsserted(() -> {
try {
WithSpringAuthorityRule.runAsPrivileged(() -> {
SecurityContextSwitch.runAsPrivileged(() -> {
final List<ActionStatus> actionStatusList = deploymentManagement
.findActionStatusByAction(PAGE, actionId).getContent();
assertThat(actionStatusList).hasSize(statusListCount);