From bf088fd09a5656c53be25e7bb444e614f026c6f4 Mon Sep 17 00:00:00 2001 From: Stefan Behl Date: Wed, 22 May 2019 16:18:02 +0200 Subject: [PATCH 1/5] Add remote event test for the new MultiActionEvent Signed-off-by: Stefan Behl --- .../event/remote/AbstractRemoteEventTest.java | 12 ++++--- .../event/remote/RemoteIdEventTest.java | 4 +-- .../remote/RemoteTenantAwareEventTest.java | 35 +++++++++++++++---- .../entity/AbstractRemoteEntityEventTest.java | 4 +-- .../event/remote/entity/ActionEventTest.java | 4 +-- .../remote/entity/RolloutGroupEventTest.java | 4 +-- 6 files changed, 43 insertions(+), 20 deletions(-) diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/AbstractRemoteEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/AbstractRemoteEventTest.java index 082d26c3c9..9295e23ef2 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/AbstractRemoteEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/AbstractRemoteEventTest.java @@ -79,13 +79,15 @@ protected Message createMessageWithImmutableHeader(final TenantAwareEvent eve return busProtoStuffMessageConverter.toMessage(event, new MessageHeaders(headers)); } - protected TenantAwareEvent createJacksonEvent(final TenantAwareEvent event) { - final Message message = createJsonMessage(event); - return (TenantAwareEvent) jacksonMessageConverter.fromMessage(message, event.getClass()); + @SuppressWarnings("unchecked") + protected T createJacksonEvent(final T event) { + final Message message = createJsonMessage(event); + return (T) jacksonMessageConverter.fromMessage(message, event.getClass()); } - protected TenantAwareEvent createProtoStuffEvent(final TenantAwareEvent event) { + @SuppressWarnings("unchecked") + protected T createProtoStuffEvent(final T event) { final Message message = createProtoStuffMessage(event); - return (TenantAwareEvent) busProtoStuffMessageConverter.fromMessage(message, event.getClass()); + return (T) busProtoStuffMessageConverter.fromMessage(message, event.getClass()); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteIdEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteIdEventTest.java index 0eb69ea2db..1094d8a681 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteIdEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteIdEventTest.java @@ -94,10 +94,10 @@ protected void assertAndCreateRemoteEvent(final Class e protected void assertEntity(final RemoteIdEvent event) { assertThat(event.getEntityId()).isSameAs(ENTITY_ID); - final RemoteIdEvent protoStuffEvent = (RemoteIdEvent) createProtoStuffEvent(event); + final RemoteIdEvent protoStuffEvent = createProtoStuffEvent(event); assertDeserializeEvent(protoStuffEvent, event); - final RemoteIdEvent jacksonEvent = (RemoteIdEvent) createJacksonEvent(event); + final RemoteIdEvent jacksonEvent = createJacksonEvent(event); assertDeserializeEvent(jacksonEvent, event); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEventTest.java index a0b40c3f2c..590ac452ae 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEventTest.java @@ -11,6 +11,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.Arrays; +import java.util.List; import org.eclipse.hawkbit.repository.jpa.model.JpaAction; import org.eclipse.hawkbit.repository.model.Action; @@ -29,15 +30,36 @@ @Story("RemoteTenantAwareEvent Tests") public class RemoteTenantAwareEventTest extends AbstractRemoteEventTest { + private static final String TENANT_DEFAULT = "DEFAULT"; + + private static final String APPLICATION_ID_DEFAULT = "Node"; + + @Test + @Description("Verifies that multi action event works") + public void testMultiActionEvent() { + + final List controllerIds = Arrays.asList("id0", "id1", "id2", "id3", + "id4loooooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnng"); + final MultiActionEvent event = new MultiActionEvent(TENANT_DEFAULT, APPLICATION_ID_DEFAULT, controllerIds); + + final MultiActionEvent remoteEventProtoStuff = createProtoStuffEvent(event); + assertThat(event).isEqualTo(remoteEventProtoStuff); + + final MultiActionEvent remoteEventJackson = createJacksonEvent(event); + assertThat(event).isEqualTo(remoteEventJackson); + + } + @Test @Description("Verifies that the download progress reloading by remote events works") public void reloadDownloadProgessByRemoteEvent() { - final DownloadProgressEvent downloadProgressEvent = new DownloadProgressEvent("DEFAULT", 1L, 3L, "Node"); + final DownloadProgressEvent downloadProgressEvent = new DownloadProgressEvent(TENANT_DEFAULT, 1L, 3L, + APPLICATION_ID_DEFAULT); - DownloadProgressEvent remoteEvent = (DownloadProgressEvent) createProtoStuffEvent(downloadProgressEvent); + DownloadProgressEvent remoteEvent = createProtoStuffEvent(downloadProgressEvent); assertThat(downloadProgressEvent).isEqualTo(remoteEvent); - remoteEvent = (DownloadProgressEvent) createJacksonEvent(downloadProgressEvent); + remoteEvent = createJacksonEvent(downloadProgressEvent); assertThat(downloadProgressEvent).isEqualTo(remoteEvent); } @@ -57,11 +79,10 @@ public void testTargetAssignDistributionSetEvent() { action.getTenant(), dsA.getId(), Arrays.asList(action), serviceMatcher.getServiceId(), action.isMaintenanceWindowAvailable()); - TargetAssignDistributionSetEvent underTest = (TargetAssignDistributionSetEvent) createProtoStuffEvent( - assignmentEvent); + TargetAssignDistributionSetEvent underTest = createProtoStuffEvent(assignmentEvent); assertTargetAssignDistributionSetEvent(action, underTest); - underTest = (TargetAssignDistributionSetEvent) createJacksonEvent(assignmentEvent); + underTest = createJacksonEvent(assignmentEvent); assertTargetAssignDistributionSetEvent(action, underTest); } @@ -69,7 +90,7 @@ private void assertTargetAssignDistributionSetEvent(final Action action, final TargetAssignDistributionSetEvent underTest) { assertThat(underTest.getActions().size()).isEqualTo(1); - ActionProperties actionProperties = underTest.getActions().get(action.getTarget().getControllerId()); + final ActionProperties actionProperties = underTest.getActions().get(action.getTarget().getControllerId()); assertThat(actionProperties).isNotNull(); assertThat(actionProperties).isEqualToComparingFieldByField(new ActionProperties(action)); assertThat(underTest.getDistributionSetId()).isEqualTo(action.getDistributionSet().getId()); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/AbstractRemoteEntityEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/AbstractRemoteEntityEventTest.java index 38bf6da219..f43afc8df9 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/AbstractRemoteEntityEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/AbstractRemoteEntityEventTest.java @@ -57,10 +57,10 @@ protected RemoteEntityEvent createRemoteEvent(final E baseEntity, protected RemoteEntityEvent assertEntity(final E baseEntity, final RemoteEntityEvent event) { assertThat(event.getEntity()).isSameAs(baseEntity); - RemoteEntityEvent underTestCreatedEvent = (RemoteEntityEvent) createProtoStuffEvent(event); + RemoteEntityEvent underTestCreatedEvent = createProtoStuffEvent(event); assertThat(underTestCreatedEvent.getEntity()).isEqualTo(baseEntity); - underTestCreatedEvent = (RemoteEntityEvent) createJacksonEvent(event); + underTestCreatedEvent = createJacksonEvent(event); assertThat(underTestCreatedEvent.getEntity()).isEqualTo(baseEntity); return underTestCreatedEvent; } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/ActionEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/ActionEventTest.java index 93b90783ed..b782a32e6d 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/ActionEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/ActionEventTest.java @@ -74,12 +74,12 @@ protected RemoteEntityEvent assertEntity(final Action baseEntity, final Remot assertThat(event.getEntity()).isSameAs(baseEntity); assertThat(event.getRolloutId()).isEqualTo(1L); - AbstractActionEvent underTestCreatedEvent = (AbstractActionEvent) createProtoStuffEvent(event); + AbstractActionEvent underTestCreatedEvent = createProtoStuffEvent(event); assertThat(underTestCreatedEvent.getEntity()).isEqualTo(baseEntity); assertThat(underTestCreatedEvent.getRolloutId()).isEqualTo(1L); assertThat(underTestCreatedEvent.getRolloutGroupId()).isEqualTo(2L); - underTestCreatedEvent = (AbstractActionEvent) createJacksonEvent(event); + underTestCreatedEvent = createJacksonEvent(event); assertThat(underTestCreatedEvent.getEntity()).isEqualTo(baseEntity); assertThat(underTestCreatedEvent.getRolloutId()).isEqualTo(1L); assertThat(underTestCreatedEvent.getRolloutGroupId()).isEqualTo(2L); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/RolloutGroupEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/RolloutGroupEventTest.java index b4e239eade..f155aaeb34 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/RolloutGroupEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/RolloutGroupEventTest.java @@ -76,11 +76,11 @@ protected RemoteEntityEvent assertEntity(final RolloutGroup baseEntity, final assertThat(event.getEntity()).isSameAs(baseEntity); assertThat(event.getRolloutId()).isEqualTo(1L); - AbstractRolloutGroupEvent underTestCreatedEvent = (AbstractRolloutGroupEvent) createProtoStuffEvent(event); + AbstractRolloutGroupEvent underTestCreatedEvent = createProtoStuffEvent(event); assertThat(underTestCreatedEvent.getEntity()).isEqualTo(baseEntity); assertThat(underTestCreatedEvent.getRolloutId()).isEqualTo(1L); - underTestCreatedEvent = (AbstractRolloutGroupEvent) createJacksonEvent(event); + underTestCreatedEvent = createJacksonEvent(event); assertThat(underTestCreatedEvent.getEntity()).isEqualTo(baseEntity); assertThat(underTestCreatedEvent.getRolloutId()).isEqualTo(1L); From 996ce5b6f23244b61bef214cfe8964df14891213 Mon Sep 17 00:00:00 2001 From: Stefan Behl Date: Wed, 22 May 2019 16:37:40 +0200 Subject: [PATCH 2/5] Improve test descriptions Signed-off-by: Stefan Behl --- .../remote/RemoteTenantAwareEventTest.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEventTest.java index 590ac452ae..1efb4b0911 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEventTest.java @@ -19,7 +19,6 @@ import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.ActionProperties; import org.eclipse.hawkbit.repository.model.DistributionSet; -import org.eclipse.hawkbit.repository.model.Target; import org.junit.Test; import io.qameta.allure.Description; @@ -35,7 +34,7 @@ public class RemoteTenantAwareEventTest extends AbstractRemoteEventTest { private static final String APPLICATION_ID_DEFAULT = "Node"; @Test - @Description("Verifies that multi action event works") + @Description("Verifies that a MultiActionEvent can be properly serialized and deserialized") public void testMultiActionEvent() { final List controllerIds = Arrays.asList("id0", "id1", "id2", "id3", @@ -44,46 +43,50 @@ public void testMultiActionEvent() { final MultiActionEvent remoteEventProtoStuff = createProtoStuffEvent(event); assertThat(event).isEqualTo(remoteEventProtoStuff); + assertThat(remoteEventProtoStuff.getControllerIds()).containsExactlyElementsOf(controllerIds); final MultiActionEvent remoteEventJackson = createJacksonEvent(event); assertThat(event).isEqualTo(remoteEventJackson); + assertThat(remoteEventJackson.getControllerIds()).containsExactlyElementsOf(controllerIds); } @Test - @Description("Verifies that the download progress reloading by remote events works") + @Description("Verifies that a DownloadProgressEvent can be properly serialized and deserialized") public void reloadDownloadProgessByRemoteEvent() { final DownloadProgressEvent downloadProgressEvent = new DownloadProgressEvent(TENANT_DEFAULT, 1L, 3L, APPLICATION_ID_DEFAULT); - DownloadProgressEvent remoteEvent = createProtoStuffEvent(downloadProgressEvent); - assertThat(downloadProgressEvent).isEqualTo(remoteEvent); + final DownloadProgressEvent remoteEventProtoStuff = createProtoStuffEvent(downloadProgressEvent); + assertThat(downloadProgressEvent).isEqualTo(remoteEventProtoStuff); - remoteEvent = createJacksonEvent(downloadProgressEvent); - assertThat(downloadProgressEvent).isEqualTo(remoteEvent); + final DownloadProgressEvent remoteEventJackson = createJacksonEvent(downloadProgressEvent); + assertThat(downloadProgressEvent).isEqualTo(remoteEventJackson); } @Test - @Description("Verifies that target assignment event works") + @Description("Verifies that a TargetAssignDistributionSetEvent can be properly serialized and deserialized") public void testTargetAssignDistributionSetEvent() { + final DistributionSet dsA = testdataFactory.createDistributionSet(""); + final JpaAction generateAction = new JpaAction(); generateAction.setActionType(ActionType.FORCED); - final Target target = testdataFactory.createTarget("Test"); - generateAction.setTarget(target); + generateAction.setTarget(testdataFactory.createTarget("Test")); generateAction.setDistributionSet(dsA); generateAction.setStatus(Status.RUNNING); + final Action action = actionRepository.save(generateAction); final TargetAssignDistributionSetEvent assignmentEvent = new TargetAssignDistributionSetEvent( action.getTenant(), dsA.getId(), Arrays.asList(action), serviceMatcher.getServiceId(), action.isMaintenanceWindowAvailable()); - TargetAssignDistributionSetEvent underTest = createProtoStuffEvent(assignmentEvent); - assertTargetAssignDistributionSetEvent(action, underTest); + final TargetAssignDistributionSetEvent remoteEventProtoStuff = createProtoStuffEvent(assignmentEvent); + assertTargetAssignDistributionSetEvent(action, remoteEventProtoStuff); - underTest = createJacksonEvent(assignmentEvent); - assertTargetAssignDistributionSetEvent(action, underTest); + final TargetAssignDistributionSetEvent remoteEventJackson = createJacksonEvent(assignmentEvent); + assertTargetAssignDistributionSetEvent(action, remoteEventJackson); } private void assertTargetAssignDistributionSetEvent(final Action action, From 7acf2c8530bd9298a6a9fbf68d1c0611e8db7b16 Mon Sep 17 00:00:00 2001 From: Stefan Behl Date: Thu, 23 May 2019 17:54:21 +0200 Subject: [PATCH 3/5] Improve sendMultiActionRequestMessages Signed-off-by: Stefan Behl --- .../amqp/AmqpMessageDispatcherService.java | 35 ++++++++----------- .../amqp/AmqpMessageHandlerService.java | 2 +- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java index c5ffd53ee6..a6fdeeadba 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java @@ -16,6 +16,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.function.Function; import java.util.stream.Collectors; import org.eclipse.hawkbit.api.ApiType; @@ -65,8 +66,6 @@ import org.springframework.data.domain.PageRequest; import org.springframework.util.CollectionUtils; -import com.google.common.collect.Maps; - /** * {@link AmqpMessageDispatcherService} create all outgoing AMQP messages and * delegate the messages to a {@link AmqpMessageSenderService}. @@ -172,7 +171,7 @@ protected void onMultiAction(final MultiActionEvent e) { protected void sendMultiActionRequestMessages(final String tenant, final List controllerIds) { - final Map>> softwareModuleMetadata = new HashMap<>(); + final Map> softwareModuleMetadata = new HashMap<>(); targetManagement.getByControllerID(controllerIds).stream() .filter(target -> IpUtil.isAmqpUri(target.getAddress())).forEach(target -> { @@ -180,14 +179,13 @@ protected void sendMultiActionRequestMessages(final String tenant, final List { - final DistributionSet distributionSet = action.getDistributionSet(); - softwareModuleMetadata.computeIfAbsent(distributionSet.getId(), - id -> getSoftwareModulesWithMetadata(distributionSet)); - }); + activeActions.forEach(action -> action.getDistributionSet().getModules().forEach( + module -> softwareModuleMetadata.computeIfAbsent(module, this::getSoftwareModuleMetadata))); if (!activeActions.isEmpty()) { - sendMultiActionRequestToTarget(tenant, target, activeActions, softwareModuleMetadata); + sendMultiActionRequestToTarget(tenant, target, activeActions, + action -> action.getDistributionSet().getModules().stream() + .collect(Collectors.toMap(m -> m, softwareModuleMetadata::get))); } }); @@ -195,7 +193,7 @@ protected void sendMultiActionRequestMessages(final String tenant, final List actions, - final Map>> softwareModulesPerDistributionSet) { + final Function>> getSoftwareModuleMetaData) { final URI targetAdress = target.getAddress(); if (!IpUtil.isAmqpUri(targetAdress) || CollectionUtils.isEmpty(actions)) { @@ -205,7 +203,7 @@ protected void sendMultiActionRequestToTarget(final String tenant, final Target final DmfMultiActionRequest multiActionRequest = new DmfMultiActionRequest(); actions.forEach(action -> { final DmfActionRequest actionRequest = createDmfActionRequest(target, action, - softwareModulesPerDistributionSet.get(action.getDistributionSet().getId())); + getSoftwareModuleMetaData.apply(action)); multiActionRequest.addElement(getEventTypeForAction(action), actionRequest); }); @@ -470,15 +468,12 @@ private DmfArtifact convertArtifact(final Target target, final Artifact localArt private Map> getSoftwareModulesWithMetadata( final DistributionSet distributionSet) { - final Map> moduleMetadata = Maps - .newHashMapWithExpectedSize(distributionSet.getModules().size()); - distributionSet.getModules() - .forEach( - module -> moduleMetadata.put(module, - softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible( - PageRequest.of(0, RepositoryConstants.MAX_META_DATA_COUNT), module.getId()) - .getContent())); - return moduleMetadata; + return distributionSet.getModules().stream().collect(Collectors.toMap(m -> m, this::getSoftwareModuleMetadata)); + } + + private List getSoftwareModuleMetadata(final SoftwareModule module) { + return softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible( + PageRequest.of(0, RepositoryConstants.MAX_META_DATA_COUNT), module.getId()).getContent(); } } \ No newline at end of file diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java index 31d369920d..0276278de1 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java @@ -227,7 +227,7 @@ private void sendCurrentActionsAsMultiActionToTarget(final Target target) { .stream().collect(Collectors.toMap(DistributionSet::getId, this::getSoftwareModulesWithMetadata)); amqpMessageDispatcherService.sendMultiActionRequestToTarget(target.getTenant(), target, actions, - softwareModulesPerDistributionSet); + action -> softwareModulesPerDistributionSet.get(action.getDistributionSet().getId())); } private void sendOldestActionToTarget(final Target target) { From 2bb0f3d4168a226d82d39d9eca44de336e520c55 Mon Sep 17 00:00:00 2001 From: Ahmed Sayed Date: Fri, 21 Jun 2019 14:05:39 +0200 Subject: [PATCH 4/5] moved action filtering to the database query level (#12) * simplified method * Use @ExpectedEvents instead of EventHandlerStubs * removed @Param from 'existsByTargetControllerIdAndStatusAndActiveIsTrue' * reverted metadata initialization Signed-off-by: Ahmed Sayed --- ...ssageDispatcherServiceIntegrationTest.java | 12 +- .../matcher/SoftwareModuleJsonMatcher.java | 43 ++--- .../hawkbit/dmf/json/model/DmfMetadata.java | 4 + .../dmf/json/model/DmfSoftwareModule.java | 7 + .../repository/jpa/ActionRepository.java | 14 ++ .../jpa/OnlineDsAssignmentStrategy.java | 4 +- .../jpa/DeploymentManagementTest.java | 163 ++---------------- 7 files changed, 61 insertions(+), 186 deletions(-) diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java index c2c626c647..c08f549ebb 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java @@ -135,21 +135,21 @@ public void sendDownloadAndInstallStatusMessageDuringMaintenanceWindow() { @Test @Description("Verify that a distribution assignment multiple times send cancel and assign events with right softwaremodules") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), - @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), + @Expect(type = TargetAssignDistributionSetEvent.class, count = 2), @Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6), - @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6), + @Expect(type = SoftwareModuleUpdatedEvent.class, count = 12), @Expect(type = DistributionSetCreatedEvent.class, count = 2), - @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 3) }) + @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 2) }) public void assignDistributionSetMultipleTimes() { final String controllerId = TARGET_PREFIX + "assignDistributionSetMultipleTimes"; final DistributionSetAssignmentResult assignmentResult = registerTargetAndAssignDistributionSet(controllerId); - final DistributionSet distributionSet2 = testdataFactory.createDistributionSet(UUID.randomUUID().toString()); - registerTargetAndAssignDistributionSet(distributionSet2.getId(), TargetUpdateStatus.PENDING, - getDistributionSet().getModules(), controllerId); + testdataFactory.addSoftwareModuleMetadata(distributionSet2); + assignDistributionSet(distributionSet2.getId(), controllerId); + assertDownloadAndInstallMessage(distributionSet2.getModules(), controllerId); assertCancelActionMessage(assignmentResult.getActionIds().get(0), controllerId); createAndSendThingCreated(controllerId, TENANT_EXIST); diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/matcher/SoftwareModuleJsonMatcher.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/matcher/SoftwareModuleJsonMatcher.java index 1e29fc2bce..f7cff9ed69 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/matcher/SoftwareModuleJsonMatcher.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/matcher/SoftwareModuleJsonMatcher.java @@ -57,50 +57,27 @@ public SoftwareModulesMatcher(final List expectedModules) { this.expectedModules = expectedModules; } - static boolean containsExactly(final Object actual, final List expected) { + boolean containsExactly(final Object actual) { if (actual == null) { - return expected == null; + return expectedModules == null; } @SuppressWarnings("unchecked") final Collection modules = (Collection) actual; - if (modules.size() != expected.size()) { - return false; - } - - for (final SoftwareModule repoSoftwareModule : modules) { - boolean containsElement = false; - - for (final DmfSoftwareModule jsonSoftwareModule : expected) { - if (!jsonSoftwareModule.getModuleId().equals(repoSoftwareModule.getId())) { - continue; - } - containsElement = true; - - if (!jsonSoftwareModule.getModuleType().equals(repoSoftwareModule.getType().getKey())) { - return false; - } - if (!jsonSoftwareModule.getModuleVersion().equals(repoSoftwareModule.getVersion())) { - return false; - } - if (jsonSoftwareModule.getArtifacts().size() != repoSoftwareModule.getArtifacts().size()) { - return false; - } - } - - if (!containsElement) { - return false; - } - - } + return expectedModules.stream().allMatch(e -> existsIn(e, modules)); + } - return true; + private static boolean existsIn(final DmfSoftwareModule module, final Collection actual) { + return actual.stream() + .anyMatch(e -> module.getModuleType().equals(e.getType().getKey()) + && module.getModuleVersion().equals(e.getVersion()) + && module.getArtifacts().size() == e.getArtifacts().size()); } @Override public boolean matches(final Object actualValue) { - return containsExactly(actualValue, expectedModules); + return containsExactly(actualValue); } @Override diff --git a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfMetadata.java b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfMetadata.java index 2f7ca7acc7..9df923de93 100644 --- a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfMetadata.java +++ b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfMetadata.java @@ -79,4 +79,8 @@ public boolean equals(final Object obj) { return true; } + @Override + public String toString() { + return String.format("DmfMetadata [key='%s', value='%s']", key, value); + } } diff --git a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfSoftwareModule.java b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfSoftwareModule.java index 4b89ea7127..63f285d504 100644 --- a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfSoftwareModule.java +++ b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfSoftwareModule.java @@ -83,4 +83,11 @@ public void setMetadata(final List metadata) { } } + @Override + public String toString() { + return String.format( + "DmfSoftwareModule [moduleId=%d, moduleType='%s', moduleVersion='%s', artifacts=%s, metadata=%s]", + moduleId, moduleType, moduleVersion, artifacts, metadata); + } + } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/ActionRepository.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/ActionRepository.java index 9abfa563e6..e9dfff7d36 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/ActionRepository.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/ActionRepository.java @@ -127,6 +127,20 @@ public interface ActionRepository extends BaseEntityRepository, @Query("SELECT CASE WHEN COUNT(a)>0 THEN 'true' ELSE 'false' END FROM JpaAction a JOIN a.target t WHERE t.controllerId=:controllerId AND a.active=1") boolean activeActionExistsForControllerId(@Param("controllerId") String controllerId); + /** + * Check if any active actions with given action status and given controller + * ID exist. + * + * @param controllerId + * of the target to check for actions + * @param currentStatus + * of the active action to look for + * + * @return true if one or more active actions for the given + * controllerId and action status are found + */ + boolean existsByTargetControllerIdAndStatusAndActiveIsTrue(String controllerId, Action.Status currentStatus); + /** * Retrieves latest {@link Action} for given target and * {@link SoftwareModule}. diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OnlineDsAssignmentStrategy.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OnlineDsAssignmentStrategy.java index c1d8c886fb..1740eff13b 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OnlineDsAssignmentStrategy.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OnlineDsAssignmentStrategy.java @@ -196,8 +196,8 @@ private void sendTargetAssignDistributionSetEvent(final String tenant, final lon } private boolean hasPendingCancellations(final Target target) { - return actionRepository.findByActiveAndTarget(ACTION_PAGE_REQUEST, target.getControllerId(), true).getContent() - .stream().anyMatch(action -> action.getStatus() == Status.CANCELING); + return actionRepository.existsByTargetControllerIdAndStatusAndActiveIsTrue(target.getControllerId(), + Status.CANCELING); } /** diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/DeploymentManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/DeploymentManagementTest.java index eb64b1ed11..a0e52c0016 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/DeploymentManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/DeploymentManagementTest.java @@ -17,10 +17,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.LinkedList; import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -31,6 +28,7 @@ import org.eclipse.hawkbit.repository.event.remote.entity.ActionUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.CancelTargetAssignmentEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent; +import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent; @@ -48,7 +46,6 @@ import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.Action.Status; -import org.eclipse.hawkbit.repository.model.ActionProperties; import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult; @@ -60,11 +57,7 @@ import org.eclipse.hawkbit.repository.test.matcher.Expect; import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; -import org.junit.Before; import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationListener; -import org.springframework.context.ConfigurableApplicationContext; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Slice; @@ -90,22 +83,6 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest { private static final boolean STATE_ACTIVE = true; private static final boolean STATE_INACTIVE = false; - private EventHandlerStub eventHandlerStub; - - private CancelEventHandlerStub cancelEventHandlerStub; - - @Autowired - private ConfigurableApplicationContext applicationContext; - - @Before - public void addHandler() { - eventHandlerStub = new EventHandlerStub(); - applicationContext.addApplicationListener(eventHandlerStub); - - cancelEventHandlerStub = new CancelEventHandlerStub(); - applicationContext.addApplicationListener(cancelEventHandlerStub); - } - @Test @Description("Verifies that management get access react as specfied on calls for non existing entities by means " + "of Optional not present.") @@ -276,7 +253,7 @@ public void assignDistributionSetToTagThatDoesNotExistThrowsException() { @Description("Test verifies that an assignment with automatic cancelation works correctly even if the update is split into multiple partitions on the database.") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = Constants.MAX_ENTRIES_IN_STATEMENT + 10), @Expect(type = TargetUpdatedEvent.class, count = 2 * (Constants.MAX_ENTRIES_IN_STATEMENT + 10)), - @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), + @Expect(type = TargetAssignDistributionSetEvent.class, count = 2), @Expect(type = ActionCreatedEvent.class, count = 2 * (Constants.MAX_ENTRIES_IN_STATEMENT + 10)), @Expect(type = CancelTargetAssignmentEvent.class, count = Constants.MAX_ENTRIES_IN_STATEMENT + 10), @Expect(type = ActionUpdatedEvent.class, count = Constants.MAX_ENTRIES_IN_STATEMENT + 10), @@ -581,12 +558,15 @@ private void assertDsExclusivelyAssignedToTargets(final List targets, fi * {@link TargetRepository#assignDistributionSet(DistributionSet, Iterable)} * and checking the active action and the action history of the targets. * - * @throws InterruptedException */ @Test @Description("Simple deployment or distribution set to target assignment test.") - public void assignDistributionSet2Targets() throws InterruptedException { - eventHandlerStub.setExpectedNumberOfEvents(1); + @ExpectEvents({@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), + @Expect(type = DistributionSetCreatedEvent.class, count = 1), + @Expect(type = TargetCreatedEvent.class, count = 30), @Expect(type = ActionCreatedEvent.class, count = 20), + @Expect(type = TargetUpdatedEvent.class, count = 20), + @Expect(type = SoftwareModuleCreatedEvent.class, count = 3)}) + public void assignDistributionSet2Targets() { final String myCtrlIDPref = "myCtrlID"; final Iterable savedNakedTargets = testdataFactory.createTargets(10, myCtrlIDPref, "first description"); @@ -631,17 +611,19 @@ public void assignDistributionSet2Targets() throws InterruptedException { assertThat(ua.getDistributionSet()).as("action has wrong ds").isEqualTo(ds); } } - - final List events = eventHandlerStub.getEvents(10, TimeUnit.SECONDS); - - assertTargetAssignDistributionSetEvents(savedDeployedTargets, ds, events); } @Test @Description("Test that it is not possible to assign a distribution set that is not complete.") + @ExpectEvents({@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), + @Expect(type = DistributionSetCreatedEvent.class, count = 1), + @Expect(type = TargetCreatedEvent.class, count = 10), @Expect(type = ActionCreatedEvent.class, count = 10), + @Expect(type = TargetUpdatedEvent.class, count = 10), + @Expect(type = SoftwareModuleCreatedEvent.class, count = 2), + @Expect(type = DistributionSetUpdatedEvent.class, count = 1) + + }) public void failDistributionSetAssigmentThatIsNotComplete() throws InterruptedException { - eventHandlerStub.setExpectedNumberOfEvents(0); - final List targets = testdataFactory.createTargets(10); final SoftwareModule ah = testdataFactory.createSoftwareModuleApp(); @@ -656,51 +638,32 @@ public void failDistributionSetAssigmentThatIsNotComplete() throws InterruptedEx } catch (final IncompleteDistributionSetException ex) { } - // give some chance to receive events asynchronously - Thread.sleep(1L); - final List events = eventHandlerStub.getEvents(5, TimeUnit.SECONDS); - assertThat(events).as("events should be empty").isEmpty(); - final DistributionSet nowComplete = distributionSetManagement.assignSoftwareModules(incomplete.getId(), Sets.newHashSet(os.getId())); - eventHandlerStub.setExpectedNumberOfEvents(1); - assertThat(assignDistributionSet(nowComplete, targets).getAssigned()).as("assign ds doesn't work") .isEqualTo(10); - - assertTargetAssignDistributionSetEvents(targets, nowComplete, eventHandlerStub.getEvents(15, TimeUnit.SECONDS)); } @Test @Description("Multiple deployments or distribution set to target assignment test. Expected behaviour is that a new deployment " + "overides unfinished old one which are canceled as part of the operation.") - @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 5 + 4), + @ExpectEvents({@Expect(type = TargetCreatedEvent.class, count = 5 + 4), @Expect(type = TargetUpdatedEvent.class, count = 3 * 4), @Expect(type = ActionCreatedEvent.class, count = 3 * 4), @Expect(type = ActionUpdatedEvent.class, count = 4 * 2), @Expect(type = CancelTargetAssignmentEvent.class, count = 4 * 2), @Expect(type = DistributionSetCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 9), - @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) + @Expect(type = TargetAssignDistributionSetEvent.class, count = 2)}) public void mutipleDeployments() throws InterruptedException { final String undeployedTargetPrefix = "undep-T"; final int noOfUndeployedTargets = 5; final String deployedTargetPrefix = "dep-T"; final int noOfDeployedTargets = 4; - final int noOfDistributionSets = 3; - // One assigment per DS - final int expectedNumberOfEventsForAssignment = 1; - eventHandlerStub.setExpectedNumberOfEvents(expectedNumberOfEventsForAssignment); - - // Each of the four targets get two more assignment the which are - // cancelled (4 * 2 = 8) - final int expectedNumberOfEventsForCancel = 8; - cancelEventHandlerStub.setExpectedNumberOfEvents(expectedNumberOfEventsForCancel); - final DeploymentResult deploymentResult = prepareComplexRepo(undeployedTargetPrefix, noOfUndeployedTargets, deployedTargetPrefix, noOfDeployedTargets, noOfDistributionSets, "myTestDS"); @@ -739,13 +702,6 @@ public void mutipleDeployments() throws InterruptedException { .doesNotContain(Iterables.toArray(undeployedTargetsFromDB, JpaTarget.class)); assertThat(undeployedTargetsFromDB).as("content of undeployed target is wrong").containsAll(savedNakedTargets) .doesNotContain(Iterables.toArray(deployedTargetsFromDB, JpaTarget.class)); - - // For each of the 4 targets 1 distribution sets gets assigned - eventHandlerStub.getEvents(10, TimeUnit.SECONDS); - - // For each of the 4 targets 2 distribution sets gets cancelled - cancelEventHandlerStub.getEvents(10, TimeUnit.SECONDS); - } @Test @@ -1111,22 +1067,6 @@ private DeploymentResult prepareComplexRepo(final String undeployedTargetPrefix, } - private void assertTargetAssignDistributionSetEvents(final List targets, final DistributionSet ds, - final List events) { - assertThat(events).hasSize(1); - final TargetAssignDistributionSetEvent event = events.get(0); - assertThat(event).isNotNull(); - assertThat(event.getDistributionSetId()).isEqualTo(ds.getId()); - - final List eventActionIds = event.getActions().values().stream().map(ActionProperties::getId) - .collect(Collectors.toList()); - - final List targetActiveActionIds = targets.stream() - .map(t -> deploymentManagement.findActiveActionsByTarget(PAGE, t.getControllerId()).getContent()) - .flatMap(List::stream).map(Action::getId).collect(Collectors.toList()); - assertThat(eventActionIds).containsOnlyElementsOf(targetActiveActionIds); - } - private class DeploymentResult { final List deployedTargetIDs = new ArrayList<>(); final List undeployedTargetIDs = new ArrayList<>(); @@ -1178,73 +1118,6 @@ public List getUndeployedTargetIDs() { } - protected static class EventHandlerStub implements ApplicationListener { - private final List events = Collections.synchronizedList(new LinkedList<>()); - private CountDownLatch latch; - private int expectedNumberOfEvents; - - /** - * @param expectedNumberOfEvents - * the expectedNumberOfEvents to set - */ - public void setExpectedNumberOfEvents(final int expectedNumberOfEvents) { - events.clear(); - this.expectedNumberOfEvents = expectedNumberOfEvents; - this.latch = new CountDownLatch(expectedNumberOfEvents); - } - - public List getEvents(final long timeout, final TimeUnit unit) - throws InterruptedException { - latch.await(timeout, unit); - final List handledEvents = Collections - .unmodifiableList(new LinkedList<>(events)); - assertThat(handledEvents).as("Did not receive the expected amount of events (" + expectedNumberOfEvents - + ") within timeout. Received events are " + handledEvents).hasSize(expectedNumberOfEvents); - return handledEvents; - - } - - @Override - public void onApplicationEvent(final TargetAssignDistributionSetEvent event) { - if (latch == null) { - return; - } - events.add(event); - latch.countDown(); - - } - } - - private static class CancelEventHandlerStub implements ApplicationListener { - private final List events = Collections.synchronizedList(new LinkedList<>()); - private CountDownLatch latch; - private int expectedNumberOfEvents; - - public void setExpectedNumberOfEvents(final int expectedNumberOfEvents) { - events.clear(); - this.expectedNumberOfEvents = expectedNumberOfEvents; - this.latch = new CountDownLatch(expectedNumberOfEvents); - } - - public List getEvents(final long timeout, final TimeUnit unit) - throws InterruptedException { - latch.await(timeout, unit); - final List handledEvents = new LinkedList<>(events); - assertThat(handledEvents).as("Did not receive the expected amount of events (" + expectedNumberOfEvents - + ") within timeout. Received events are " + handledEvents).hasSize(expectedNumberOfEvents); - return handledEvents; - } - - @Override - public void onApplicationEvent(final CancelTargetAssignmentEvent event) { - if (latch == null) { - return; - } - events.add(event); - latch.countDown(); - } - } - private void enableMultiAssignments() { tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.MULTI_ASSIGNMENTS_ENABLED, true); } From ab3321d9f6fe72bded3ab73ac817d08763afe70c Mon Sep 17 00:00:00 2001 From: Stefan Behl Date: Mon, 24 Jun 2019 10:22:03 +0200 Subject: [PATCH 5/5] Fix hawkBit bot findings Signed-off-by: Stefan Behl --- .../hawkbit/repository/jpa/OnlineDsAssignmentStrategy.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OnlineDsAssignmentStrategy.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OnlineDsAssignmentStrategy.java index 1740eff13b..66068972c0 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OnlineDsAssignmentStrategy.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/OnlineDsAssignmentStrategy.java @@ -8,8 +8,6 @@ */ package org.eclipse.hawkbit.repository.jpa; -import static org.eclipse.hawkbit.repository.RepositoryConstants.MAX_ACTION_COUNT; - import java.util.Collection; import java.util.Collections; import java.util.List; @@ -39,8 +37,6 @@ import org.eclipse.hawkbit.repository.model.TargetWithActionType; import org.springframework.cloud.bus.BusProperties; import org.springframework.context.ApplicationEventPublisher; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; import org.springframework.util.CollectionUtils; import com.google.common.collect.Lists; @@ -51,8 +47,6 @@ */ public class OnlineDsAssignmentStrategy extends AbstractDsAssignmentStrategy { - private static final Pageable ACTION_PAGE_REQUEST = PageRequest.of(0, MAX_ACTION_COUNT); - private final Supplier multiAssignmentsConfig; OnlineDsAssignmentStrategy(final TargetRepository targetRepository,