Remove unlimited collections from the repository API (#496)

* Started to get rid of unlimited collections

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Align API usage.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* fix compile issues.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix tests.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Remove comments

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Performance optimizations.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Remove dead code.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Allign method names

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Wait until the action update event is processed

Conflicts:
	hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>

* Started new tag APIs

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Quotas into central interface. Tag tests added. Event names fixed.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Simplified consumer run for every tenant.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* remove unused fields.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Alligned beans.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Deprecated client methods for old resources.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix new foreach method.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix transaction for foreach.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Extended DS creating to handle larger volumes. Fix on Readme.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fixed simulator bug and cleaned up tests.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix in sorting.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Remove configuration processor.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix wrong usage of sanitize.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Missing brackets.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix README API compatability.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix misinterpretation of pessimistic locking exceptions.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix stability sentence.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Code cleanup.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fixed page calculation

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-05-09 16:40:49 +02:00
committed by GitHub
parent aca87464bd
commit c18e9f515e
199 changed files with 3502 additions and 1607 deletions

View File

@@ -31,7 +31,7 @@ public class DistributionSetEventTest extends AbstractRemoteEntityEventTest<Dist
@Test
@Description("Verifies that the distribution set entity reloading by remote updated event works")
public void testDistributionSetUpdateEvent() {
assertAndCreateRemoteEvent(DistributionSetUpdateEvent.class);
assertAndCreateRemoteEvent(DistributionSetUpdatedEvent.class);
}
@Override

View File

@@ -31,7 +31,7 @@ public class DistributionSetTagEventTest extends AbstractRemoteEntityEventTest<D
@Test
@Description("Verifies that the distribution set tag entity reloading by remote updated event works")
public void testDistributionSetTagUpdateEvent() {
assertAndCreateRemoteEvent(DistributionSetTagUpdateEvent.class);
assertAndCreateRemoteEvent(DistributionSetTagUpdatedEvent.class);
}
@Override

View File

@@ -99,7 +99,7 @@ public class RolloutGroupEventTest extends AbstractRemoteEntityEventTest<Rollout
10, new RolloutGroupConditionBuilder().withDefaults()
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
return rolloutManagement.findRolloutById(entity.getId()).get().getRolloutGroups().get(0);
return rolloutGroupManagement.findRolloutGroupsByRolloutId(entity.getId(), PAGE).getContent().get(0);
}
}

View File

@@ -31,7 +31,7 @@ public class TargetTagEventTest extends AbstractRemoteEntityEventTest<TargetTag>
@Test
@Description("Verifies that the target tag entity reloading by remote updated event works")
public void testTargetTagUpdateEventt() {
assertAndCreateRemoteEvent(TargetTagUpdateEvent.class);
assertAndCreateRemoteEvent(TargetTagUpdatedEvent.class);
}
@Override

View File

@@ -98,7 +98,7 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
@Transactional(readOnly = true)
protected List<Action> findActionsByRolloutAndStatus(final Rollout rollout, final Action.Status actionStatus) {
return Lists.newArrayList(actionRepository.findByRolloutIdAndStatus(pageReq, rollout.getId(), actionStatus));
return Lists.newArrayList(actionRepository.findByRolloutIdAndStatus(PAGE, rollout.getId(), actionStatus));
}
protected static void verifyThrownExceptionBy(final ThrowingCallable tc, final String objectType) {

View File

@@ -76,7 +76,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
verifyThrownExceptionBy(() -> artifactManagement.deleteArtifact(NOT_EXIST_IDL), "Artifact");
verifyThrownExceptionBy(() -> artifactManagement.findArtifactBySoftwareModule(pageReq, NOT_EXIST_IDL),
verifyThrownExceptionBy(() -> artifactManagement.findArtifactBySoftwareModule(PAGE, NOT_EXIST_IDL),
"SoftwareModule");
assertThat(artifactManagement.findArtifactByFilename(NOT_EXIST_ID).isPresent()).isFalse();
@@ -260,12 +260,12 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
public void findArtifactBySoftwareModule() {
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
assertThat(artifactManagement.findArtifactBySoftwareModule(pageReq, sm.getId())).isEmpty();
assertThat(artifactManagement.findArtifactBySoftwareModule(PAGE, sm.getId())).isEmpty();
final Artifact result = artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), sm.getId(),
"file1", false);
assertThat(artifactManagement.findArtifactBySoftwareModule(pageReq, sm.getId())).hasSize(1);
assertThat(artifactManagement.findArtifactBySoftwareModule(PAGE, sm.getId())).hasSize(1);
}
@Test

View File

@@ -138,7 +138,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.FINISHED, Action.Status.FINISHED, false);
assertThat(actionStatusRepository.count()).isEqualTo(6);
assertThat(deploymentManagement.findActionStatusByAction(pageReq, actionId).getNumberOfElements()).isEqualTo(6);
assertThat(deploymentManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(6);
}
@Test
@@ -161,7 +161,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.FINISHED, Action.Status.FINISHED, false);
assertThat(actionStatusRepository.count()).isEqualTo(3);
assertThat(deploymentManagement.findActionStatusByAction(pageReq, actionId).getNumberOfElements()).isEqualTo(3);
assertThat(deploymentManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(3);
}
@Test
@@ -186,7 +186,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.RUNNING, Action.Status.RUNNING, true);
assertThat(actionStatusRepository.count()).isEqualTo(1);
assertThat(deploymentManagement.findActionStatusByAction(pageReq, actionId).getNumberOfElements()).isEqualTo(1);
assertThat(deploymentManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(1);
}
@@ -214,7 +214,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.CANCELED, Action.Status.FINISHED, false);
assertThat(actionStatusRepository.count()).isEqualTo(7);
assertThat(deploymentManagement.findActionStatusByAction(pageReq, actionId).getNumberOfElements()).isEqualTo(7);
assertThat(deploymentManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(7);
}
@Test
@@ -241,7 +241,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.CANCELED, Action.Status.CANCELED, false);
assertThat(actionStatusRepository.count()).isEqualTo(7);
assertThat(deploymentManagement.findActionStatusByAction(pageReq, actionId).getNumberOfElements()).isEqualTo(7);
assertThat(deploymentManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(7);
}
@Test
@@ -269,7 +269,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.RUNNING, Action.Status.CANCEL_REJECTED, true);
assertThat(actionStatusRepository.count()).isEqualTo(7);
assertThat(deploymentManagement.findActionStatusByAction(pageReq, actionId).getNumberOfElements()).isEqualTo(7);
assertThat(deploymentManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(7);
}
@Test
@@ -297,7 +297,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.RUNNING, Action.Status.ERROR, true);
assertThat(actionStatusRepository.count()).isEqualTo(7);
assertThat(deploymentManagement.findActionStatusByAction(pageReq, actionId).getNumberOfElements()).isEqualTo(7);
assertThat(deploymentManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(7);
}
@Step
@@ -308,7 +308,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
return deploymentManagement.findActiveActionsByTarget(TestdataFactory.DEFAULT_CONTROLLER_ID).get(0).getId();
return deploymentManagement.findActiveActionsByTarget(PAGE, TestdataFactory.DEFAULT_CONTROLLER_ID)
.getContent().get(0).getId();
}
@Step
@@ -366,7 +367,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
final Action action = deploymentManagement.findAction(actionId).get();
assertThat(action.getStatus()).isEqualTo(expectedActionActionStatus);
assertThat(action.isActive()).isEqualTo(actionActive);
final List<ActionStatus> actionStatusList = deploymentManagement.findActionStatusByAction(pageReq, actionId)
final List<ActionStatus> actionStatusList = deploymentManagement.findActionStatusByAction(PAGE, actionId)
.getContent();
assertThat(actionStatusList.get(actionStatusList.size() - 1).getStatus()).isEqualTo(expectedActionStatus);
if (actionActive) {
@@ -472,7 +473,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.ERROR, Action.Status.ERROR, false);
assertThat(actionStatusRepository.count()).isEqualTo(3);
assertThat(deploymentManagement.findActionStatusByAction(pageReq, actionId).getNumberOfElements()).isEqualTo(3);
assertThat(deploymentManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(3);
}
@@ -507,7 +508,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.FINISHED, Action.Status.FINISHED, false);
assertThat(actionStatusRepository.count()).isEqualTo(3);
assertThat(deploymentManagement.findActionStatusByAction(pageReq, actionId).getNumberOfElements()).isEqualTo(3);
assertThat(deploymentManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(3);
}
@@ -533,7 +534,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
assertThat(actionStatusRepository.count()).isEqualTo(3);
assertThat(deploymentManagement.findActionStatusByAction(pageReq, action.getId()).getNumberOfElements())
assertThat(deploymentManagement.findActionStatusByAction(PAGE, action.getId()).getNumberOfElements())
.isEqualTo(3);
}
@@ -558,8 +559,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
// however, additional action status has been stored
assertThat(actionStatusRepository.findAll(pageReq).getNumberOfElements()).isEqualTo(4);
assertThat(deploymentManagement.findActionStatusByAction(pageReq, action.getId()).getNumberOfElements())
assertThat(actionStatusRepository.findAll(PAGE).getNumberOfElements()).isEqualTo(4);
assertThat(deploymentManagement.findActionStatusByAction(PAGE, action.getId()).getNumberOfElements())
.isEqualTo(4);
}

View File

@@ -36,6 +36,7 @@ import org.eclipse.hawkbit.repository.exception.ForceQuitActionNotAllowedExcepti
import org.eclipse.hawkbit.repository.exception.IncompleteDistributionSetException;
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
import org.eclipse.hawkbit.repository.jpa.model.JpaActionStatus;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
import org.eclipse.hawkbit.repository.model.Action;
@@ -122,16 +123,15 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
verifyThrownExceptionBy(() -> deploymentManagement.countActionsByTarget(NOT_EXIST_ID), "Target");
verifyThrownExceptionBy(() -> deploymentManagement.countActionsByTarget("xxx", NOT_EXIST_ID), "Target");
verifyThrownExceptionBy(() -> deploymentManagement.findActionsByDistributionSet(pageReq, NOT_EXIST_IDL),
verifyThrownExceptionBy(() -> deploymentManagement.findActionsByDistributionSet(PAGE, NOT_EXIST_IDL),
"DistributionSet");
verifyThrownExceptionBy(() -> deploymentManagement.findActionsByTarget(NOT_EXIST_ID, pageReq), "Target");
verifyThrownExceptionBy(() -> deploymentManagement.findActionsByTarget("id==*", NOT_EXIST_ID, pageReq),
verifyThrownExceptionBy(() -> deploymentManagement.findActionsByTarget(NOT_EXIST_ID, PAGE), "Target");
verifyThrownExceptionBy(() -> deploymentManagement.findActionsByTarget("id==*", NOT_EXIST_ID, PAGE),
"Target");
verifyThrownExceptionBy(
() -> deploymentManagement.findActionsWithStatusCountByTargetOrderByIdDesc(NOT_EXIST_ID), "Target");
verifyThrownExceptionBy(() -> deploymentManagement.findActiveActionsByTarget(NOT_EXIST_ID), "Target");
verifyThrownExceptionBy(() -> deploymentManagement.findInActiveActionsByTarget(NOT_EXIST_ID), "Target");
verifyThrownExceptionBy(() -> deploymentManagement.findActiveActionsByTarget(PAGE, NOT_EXIST_ID), "Target");
verifyThrownExceptionBy(() -> deploymentManagement.findInActiveActionsByTarget(PAGE, NOT_EXIST_ID),
"Target");
verifyThrownExceptionBy(() -> deploymentManagement.forceQuitAction(NOT_EXIST_IDL), "Action");
verifyThrownExceptionBy(() -> deploymentManagement.forceTargetAction(NOT_EXIST_IDL), "Action");
}
@@ -164,7 +164,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
// act
final Slice<Action> actions = deploymentManagement.findActionsByTarget(testTarget.get(0).getControllerId(),
pageReq);
PAGE);
final Long count = deploymentManagement.countActionsByTarget(testTarget.get(0).getControllerId());
assertThat(count).as("One Action for target").isEqualTo(1L).isEqualTo(actions.getContent().size());
@@ -180,11 +180,11 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
// one action with one action status is generated
final Long actionId = assignDistributionSet(testDs, testTarget).getActions().get(0);
final Slice<Action> actions = deploymentManagement.findActionsByTarget(testTarget.get(0).getControllerId(),
pageReq);
final ActionStatus expectedActionStatus = actions.getContent().get(0).getActionStatus().get(0);
PAGE);
final ActionStatus expectedActionStatus = ((JpaAction) actions.getContent().get(0)).getActionStatus().get(0);
// act
final Page<ActionStatus> actionStates = deploymentManagement.findActionStatusByAction(pageReq, actionId);
final Page<ActionStatus> actionStates = deploymentManagement.findActionStatusByAction(PAGE, actionId);
assertThat(actionStates.getContent()).hasSize(1);
assertThat(actionStates.getContent().get(0)).as("Action-status of action").isEqualTo(expectedActionStatus);
@@ -201,14 +201,15 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
// create action-status entry with one message
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId)
.status(Action.Status.FINISHED).messages(Lists.newArrayList("finished message")));
final Page<ActionStatus> actionStates = deploymentManagement.findActionStatusByAction(pageReq, actionId);
final Page<ActionStatus> actionStates = deploymentManagement.findActionStatusByAction(PAGE, actionId);
// find newly created action-status entry with message
final ActionStatus actionStatusWithMessage = actionStates.getContent().stream()
final JpaActionStatus actionStatusWithMessage = actionStates.getContent().stream().map(c -> (JpaActionStatus) c)
.filter(entry -> entry.getMessages() != null && entry.getMessages().size() > 0).findFirst().get();
final String expectedMsg = actionStatusWithMessage.getMessages().get(0);
// act
final Page<String> messages = deploymentManagement.findMessagesByActionStatusId(pageReq,
final Page<String> messages = deploymentManagement.findMessagesByActionStatusId(PAGE,
actionStatusWithMessage.getId());
assertThat(actionStates.getTotalElements()).as("Two action-states in total").isEqualTo(2L);
@@ -425,7 +426,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get())
.as("wrong assigned ds").isEqualTo(ds);
final JpaAction action = actionRepository
.findByTargetAndDistributionSet(pageReq, (JpaTarget) target, (JpaDistributionSet) ds).getContent()
.findByTargetAndDistributionSet(PAGE, (JpaTarget) target, (JpaDistributionSet) ds).getContent()
.get(0);
assertThat(action).as("action should not be null").isNotNull();
return action;
@@ -455,12 +456,12 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
assignDistributionSet(ds, savedDeployedTargets);
// verify that one Action for each assignDistributionSet
assertThat(actionRepository.findAll(pageReq).getNumberOfElements()).as("wrong size of actions").isEqualTo(20);
assertThat(actionRepository.findAll(PAGE).getNumberOfElements()).as("wrong size of actions").isEqualTo(20);
final Iterable<Target> allFoundTargets = targetManagement.findTargetsAll(pageReq).getContent();
final Iterable<Target> allFoundTargets = targetManagement.findTargetsAll(PAGE).getContent();
// get final updated version of targets
savedDeployedTargets = targetManagement.findTargetByControllerID(
savedDeployedTargets = targetManagement.findTargetsByControllerID(
savedDeployedTargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()));
assertThat(allFoundTargets).as("founded targets are wrong").containsAll(savedDeployedTargets)
@@ -479,7 +480,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
for (final Target myt : savedDeployedTargets) {
final Target t = targetManagement.findTargetByControllerID(myt.getControllerId()).get();
final List<Action> activeActionsByTarget = deploymentManagement
.findActiveActionsByTarget(t.getControllerId());
.findActiveActionsByTarget(PAGE, t.getControllerId()).getContent();
assertThat(activeActionsByTarget).as("action should not be empty").isNotEmpty();
assertThat(t.getUpdateStatus()).as("wrong target update status").isEqualTo(TargetUpdateStatus.PENDING);
for (final Action ua : activeActionsByTarget) {
@@ -558,7 +559,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
final Collection<JpaTarget> savedDeployedTargets = (Collection) deploymentResult.getDeployedTargets();
// retrieving all Actions created by the assignDistributionSet call
final Page<JpaAction> page = actionRepository.findAll(pageReq);
final Page<JpaAction> page = actionRepository.findAll(PAGE);
// and verify the number
assertThat(page.getTotalElements()).as("wrong size of actions")
.isEqualTo(noOfDeployedTargets * noOfDistributionSets);
@@ -653,7 +654,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
.as("installed ds is wrong").isEqualTo(dsA);
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).get().getUpdateStatus())
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
assertThat(deploymentManagement.findActiveActionsByTarget(t.getControllerId()))
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, t.getControllerId()))
.as("no actions should be active").hasSize(0);
}
@@ -666,7 +667,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
actionRepository.findByDistributionSetId(pageRequest, dsA.getId()).getContent().get(1);
// get final updated version of targets
final List<Target> deployResWithDsBTargets = targetManagement.findTargetByControllerID(deployResWithDsB
final List<Target> deployResWithDsBTargets = targetManagement.findTargetsByControllerID(deployResWithDsB
.getDeployedTargets().stream().map(Target::getControllerId).collect(Collectors.toList()));
assertThat(deployed2DS).as("deployed ds is wrong").containsAll(deployResWithDsBTargets);
@@ -724,7 +725,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
// verify that deleted attribute is used correctly
List<DistributionSet> allFoundDS = distributionSetManagement
.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true).getContent();
.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true).getContent();
assertThat(allFoundDS.size()).as("no ds should be founded").isEqualTo(0);
allFoundDS = distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageRequest, true, true)
.getContent();
@@ -798,28 +799,28 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).get().getOptLockRevision());
// verifying that the assignment is correct
assertThat(deploymentManagement.findActiveActionsByTarget(targ.getControllerId()).size())
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements())
.as("Active target actions are wrong").isEqualTo(1);
assertThat(deploymentManagement.countActionsByTarget(targ.getControllerId())).as("Target actions are wrong")
.isEqualTo(1);
assertThat(targ.getUpdateStatus()).as("UpdateStatus of target is wrong").isEqualTo(TargetUpdateStatus.PENDING);
assertThat(deploymentManagement.getAssignedDistributionSet(targ.getControllerId()).get())
.as("Assigned distribution set of target is wrong").isEqualTo(dsA);
assertThat(deploymentManagement.findActiveActionsByTarget(targ.getControllerId()).get(0).getDistributionSet())
.as("Distribution set of actionn is wrong").isEqualTo(dsA);
assertThat(deploymentManagement.findActiveActionsByTarget(targ.getControllerId()).get(0).getDistributionSet())
.as("Installed distribution set of action should be null").isNotNull();
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getContent().get(0)
.getDistributionSet()).as("Distribution set of actionn is wrong").isEqualTo(dsA);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getContent().get(0)
.getDistributionSet()).as("Installed distribution set of action should be null").isNotNull();
final Page<Action> updAct = actionRepository.findByDistributionSetId(pageReq, dsA.getId());
final Page<Action> updAct = actionRepository.findByDistributionSetId(PAGE, dsA.getId());
controllerManagement.addUpdateActionStatus(
entityFactory.actionStatus().create(updAct.getContent().get(0).getId()).status(Status.FINISHED));
targ = targetManagement.findTargetByControllerID(targ.getControllerId()).get();
assertEquals("active target actions are wrong", 0,
deploymentManagement.findActiveActionsByTarget(targ.getControllerId()).size());
deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements());
assertEquals("active actions are wrong", 1,
deploymentManagement.findInActiveActionsByTarget(targ.getControllerId()).size());
deploymentManagement.findInActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements());
assertEquals("tagret update status is not correct", TargetUpdateStatus.IN_SYNC, targ.getUpdateStatus());
assertEquals("wrong assigned ds", dsA,
@@ -832,15 +833,15 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
targ = targs.iterator().next();
assertEquals("active actions are wrong", 1,
deploymentManagement.findActiveActionsByTarget(targ.getControllerId()).size());
deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements());
assertEquals("target status is wrong", TargetUpdateStatus.PENDING,
targetManagement.findTargetByControllerID(targ.getControllerId()).get().getUpdateStatus());
assertEquals("wrong assigned ds", dsB,
deploymentManagement.getAssignedDistributionSet(targ.getControllerId()).get());
assertEquals("Installed ds is wrong", dsA.getId(),
deploymentManagement.getInstalledDistributionSet(targ.getControllerId()).get().getId());
assertEquals("Active ds is wrong", dsB,
deploymentManagement.findActiveActionsByTarget(targ.getControllerId()).get(0).getDistributionSet());
assertEquals("Active ds is wrong", dsB, deploymentManagement
.findActiveActionsByTarget(PAGE, targ.getControllerId()).getContent().get(0).getDistributionSet());
}
@@ -972,7 +973,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
if (event.getControllerId().equals(myt.getControllerId())) {
found = true;
final List<Action> activeActionsByTarget = deploymentManagement
.findActiveActionsByTarget(myt.getControllerId());
.findActiveActionsByTarget(PAGE, myt.getControllerId()).getContent();
assertThat(activeActionsByTarget).as("size of active actions for target is wrong").isNotEmpty();
assertThat(event.getActionId()).as("Action id in database and event do not match")
.isEqualTo(activeActionsByTarget.get(0).getId());

View File

@@ -29,6 +29,7 @@ import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
import org.eclipse.hawkbit.repository.exception.UnsupportedSoftwareModuleForThisDistributionSetException;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetMetadata;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
import org.eclipse.hawkbit.repository.model.Action.Status;
@@ -121,6 +122,12 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
() -> distributionSetManagement.assignTag(Lists.newArrayList(NOT_EXIST_IDL), dsTag.getId()),
"DistributionSet");
verifyThrownExceptionBy(() -> distributionSetManagement.findDistributionSetsByTag(PAGE, NOT_EXIST_IDL),
"DistributionSetTag");
verifyThrownExceptionBy(
() -> distributionSetManagement.findDistributionSetsByTag(PAGE, "name==*", NOT_EXIST_IDL),
"DistributionSetTag");
verifyThrownExceptionBy(
() -> distributionSetManagement.toggleTagAssignment(Lists.newArrayList(NOT_EXIST_IDL), dsTag.getName()),
"DistributionSet");
@@ -128,9 +135,6 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
() -> distributionSetManagement.toggleTagAssignment(Lists.newArrayList(set.getId()), NOT_EXIST_ID),
"DistributionSetTag");
verifyThrownExceptionBy(() -> distributionSetManagement.unAssignAllDistributionSetsByTag(NOT_EXIST_IDL),
"DistributionSetTag");
verifyThrownExceptionBy(() -> distributionSetManagement.unAssignTag(set.getId(), NOT_EXIST_IDL),
"DistributionSetTag");
@@ -168,11 +172,11 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
"DistributionSet");
verifyThrownExceptionBy(
() -> distributionSetManagement.findDistributionSetMetadataByDistributionSetId(NOT_EXIST_IDL, pageReq),
() -> distributionSetManagement.findDistributionSetMetadataByDistributionSetId(NOT_EXIST_IDL, PAGE),
"DistributionSet");
verifyThrownExceptionBy(() -> distributionSetManagement
.findDistributionSetMetadataByDistributionSetId(NOT_EXIST_IDL, "name==*", pageReq), "DistributionSet");
.findDistributionSetMetadataByDistributionSetId(NOT_EXIST_IDL, "name==*", PAGE), "DistributionSet");
assertThatThrownBy(() -> distributionSetManagement.isDistributionSetInUse(NOT_EXIST_IDL))
.isInstanceOf(EntityNotFoundException.class).hasMessageContaining(NOT_EXIST_ID)
@@ -390,28 +394,28 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
final List<DistributionSet> assignedDS = distributionSetManagement.assignTag(assignDS, tag.getId());
assertThat(assignedDS.size()).as("assigned ds has wrong size").isEqualTo(4);
assignedDS.forEach(ds -> assertThat(ds.getTags().size()).as("ds has wrong tag size").isEqualTo(1));
assignedDS.stream().map(c -> (JpaDistributionSet) c)
.forEach(ds -> assertThat(ds.getTags().size()).as("ds has wrong tag size").isEqualTo(1));
DistributionSetTag findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1").get();
assertThat(assignedDS.size()).as("assigned ds has wrong size")
.isEqualTo(findDistributionSetTag.getAssignedToDistributionSet().size());
final DistributionSet unAssignDS = distributionSetManagement.unAssignTag(assignDS.get(0),
findDistributionSetTag.getId());
assertThat(assignedDS.size()).as("assigned ds has wrong size").isEqualTo(
distributionSetManagement.findDistributionSetsByTag(PAGE, tag.getId()).getNumberOfElements());
final JpaDistributionSet unAssignDS = (JpaDistributionSet) distributionSetManagement
.unAssignTag(assignDS.get(0), findDistributionSetTag.getId());
assertThat(unAssignDS.getId()).as("unassigned ds is wrong").isEqualTo(assignDS.get(0));
assertThat(unAssignDS.getTags().size()).as("unassigned ds has wrong tag size").isEqualTo(0);
findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1").get();
assertThat(findDistributionSetTag.getAssignedToDistributionSet().size()).as("ds tag ds has wrong ds size")
.isEqualTo(3);
assertThat(distributionSetManagement.findDistributionSetsByTag(PAGE, tag.getId()).getNumberOfElements())
.as("ds tag ds has wrong ds size").isEqualTo(3);
final List<DistributionSet> unAssignTargets = distributionSetManagement
.unAssignAllDistributionSetsByTag(findDistributionSetTag.getId());
findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1").get();
assertThat(findDistributionSetTag.getAssignedToDistributionSet().size()).as("ds tag has wrong ds size")
.isEqualTo(0);
assertThat(unAssignTargets.size()).as("unassigned target has wrong size").isEqualTo(3);
unAssignTargets
.forEach(target -> assertThat(target.getTags().size()).as("target has wrong tag size").isEqualTo(0));
assertThat(distributionSetManagement
.findDistributionSetsByTag(PAGE, "name==" + unAssignDS.getName(), tag.getId()).getNumberOfElements())
.as("ds tag ds has wrong ds size").isEqualTo(0);
assertThat(distributionSetManagement
.findDistributionSetsByTag(PAGE, "name!=" + unAssignDS.getName(), tag.getId()).getNumberOfElements())
.as("ds tag ds has wrong ds size").isEqualTo(3);
}
@Test
@@ -559,14 +563,14 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
// target first only has an assigned DS-three so check order correct
final List<DistributionSet> tFirstPin = distributionSetManagement.findDistributionSetsAllOrderedByLinkTarget(
pageReq, distributionSetFilterBuilder, tFirst.getControllerId()).getContent();
PAGE, distributionSetFilterBuilder, tFirst.getControllerId()).getContent();
assertThat(tFirstPin.get(0)).isEqualTo(dsThree);
assertThat(tFirstPin).hasSize(10);
// target second has installed DS-2 and assigned DS-4 so check order
// correct
final List<DistributionSet> tSecondPin = distributionSetManagement.findDistributionSetsAllOrderedByLinkTarget(
pageReq, distributionSetFilterBuilder, tSecond.getControllerId()).getContent();
PAGE, distributionSetFilterBuilder, tSecond.getControllerId()).getContent();
assertThat(tSecondPin.get(0)).isEqualTo(dsSecond);
assertThat(tSecondPin.get(1)).isEqualTo(dsFour);
assertThat(tFirstPin).hasSize(10);
@@ -624,7 +628,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
expected.add(dsNewType);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, getDistributionSetFilterBuilder().build()).getContent())
.findDistributionSetsByFilters(PAGE, getDistributionSetFilterBuilder().build()).getContent())
.hasSize(203).containsOnly(expected.toArray(new DistributionSet[0]));
DistributionSetFilterBuilder distributionSetFilterBuilder;
@@ -632,11 +636,11 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
// search for not deleted
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.TRUE);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(1);
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(1);
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(false);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent())
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent())
.hasSize(202);
// search for completed
@@ -648,61 +652,61 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(202)
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(202)
.containsOnly(expected.toArray(new DistributionSet[0]));
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.FALSE);
expected = new ArrayList<>();
expected.add(dsInComplete);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(1)
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(1)
.containsOnly(expected.toArray(new DistributionSet[0]));
// search for type
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(newType);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(1);
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(1);
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent())
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent())
.hasSize(202);
// search for text
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setSearchText("%test2");
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent())
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent())
.hasSize(100);
// search for tags
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
.setTagNames(Lists.newArrayList(dsTagA.getName()));
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent())
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent())
.hasSize(200);
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
.setTagNames(Lists.newArrayList(dsTagB.getName()));
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent())
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent())
.hasSize(100);
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
.setTagNames(Lists.newArrayList(dsTagA.getName(), dsTagB.getName()));
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent())
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent())
.hasSize(200);
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
.setTagNames(Lists.newArrayList(dsTagC.getName(), dsTagB.getName()));
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent())
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent())
.hasSize(100);
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
.setTagNames(Lists.newArrayList(dsTagC.getName()));
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
// combine deleted and complete
expected = new ArrayList<>();
@@ -713,14 +717,14 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
.setIsDeleted(Boolean.FALSE);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(201)
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(201)
.containsOnly(expected.toArray(new DistributionSet[0]));
expected = new ArrayList<>();
expected.add(dsInComplete);
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.FALSE);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(1)
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(1)
.containsOnly(expected.toArray(new DistributionSet[0]));
expected = new ArrayList<>();
@@ -728,13 +732,13 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
.setIsDeleted(Boolean.TRUE);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(1)
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(1)
.containsOnly(expected.toArray(new DistributionSet[0]));
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.TRUE)
.setIsComplete(Boolean.FALSE);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
// combine deleted and complete and type
expected = new ArrayList<>();
@@ -743,7 +747,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.FALSE)
.setIsComplete(Boolean.TRUE).setType(standardDsType);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(200)
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(200)
.containsOnly(expected.toArray(new DistributionSet[0]));
expected = new ArrayList<>();
@@ -751,19 +755,19 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
.setType(standardDsType).setIsDeleted(Boolean.TRUE);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(1)
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(1)
.containsOnly(expected.toArray(new DistributionSet[0]));
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.TRUE)
.setIsComplete(Boolean.FALSE).setType(standardDsType);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
expected = new ArrayList<>();
expected.add(dsNewType);
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setType(newType);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(1)
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(1)
.containsOnly(expected.toArray(new DistributionSet[0]));
// combine deleted and complete and type and text
@@ -772,23 +776,23 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
.setType(standardDsType).setSearchText("%test2");
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(100)
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(100)
.containsOnly(expected.toArray(new DistributionSet[0]));
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
.setIsDeleted(Boolean.TRUE).setType(standardDsType).setSearchText("%test2");
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType).setSearchText("%test2")
.setIsComplete(false).setIsDeleted(false);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(newType).setSearchText("%test2")
.setIsComplete(Boolean.TRUE).setIsDeleted(false);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
// combine deleted and complete and type and text and tag
expected = new ArrayList<>();
@@ -796,14 +800,14 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setType(standardDsType)
.setSearchText("%test2").setTagNames(Lists.newArrayList(dsTagA.getName()));
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(100)
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(100)
.containsOnly(expected.toArray(new DistributionSet[0]));
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType).setSearchText("%test2")
.setTagNames(Lists.newArrayList(dsTagA.getName())).setIsComplete(Boolean.FALSE)
.setIsDeleted(Boolean.FALSE);
assertThat(distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getContent()).hasSize(0);
}
@@ -816,7 +820,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
public void findDistributionSetsWithoutLazy() {
testdataFactory.createDistributionSets(20);
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true))
.hasSize(20);
}
@@ -832,7 +836,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
// not assigned so not marked as deleted but fully deleted
assertThat(distributionSetRepository.findAll()).hasSize(1);
assertThat(distributionSetManagement
.findDistributionSetsByDeletedAndOrCompleted(pageReq, Boolean.FALSE, Boolean.TRUE).getTotalElements())
.findDistributionSetsByDeletedAndOrCompleted(PAGE, Boolean.FALSE, Boolean.TRUE).getTotalElements())
.isEqualTo(1);
}
@@ -892,7 +896,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
// not assigned so not marked as deleted
assertThat(distributionSetRepository.findAll()).hasSize(4);
assertThat(distributionSetManagement
.findDistributionSetsByDeletedAndOrCompleted(pageReq, Boolean.FALSE, Boolean.TRUE).getTotalElements())
.findDistributionSetsByDeletedAndOrCompleted(PAGE, Boolean.FALSE, Boolean.TRUE).getTotalElements())
.isEqualTo(2);
}
@@ -926,7 +930,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
testdataFactory.createDistributionSet("test" + i);
}
final List<DistributionSet> foundDs = distributionSetManagement.findDistributionSetAllById(searchIds);
final List<DistributionSet> foundDs = distributionSetManagement.findDistributionSetsById(searchIds);
assertThat(foundDs).hasSize(3);

View File

@@ -0,0 +1,71 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository.jpa;
import static org.assertj.core.api.Assertions.assertThat;
import org.eclipse.hawkbit.repository.event.remote.RolloutDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutGroupCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutGroupUpdatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutUpdatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
import org.eclipse.hawkbit.repository.test.matcher.Expect;
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
import org.junit.Test;
import ru.yandex.qatools.allure.annotations.Description;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Stories;
@Features("Component Tests - Repository")
@Stories("Rollout Management")
public class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
@Test
@Description("Verifies that management get access reacts as specfied on calls for non existing entities by means "
+ "of Optional not present.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
public void nonExistingEntityAccessReturnsNotPresent() {
assertThat(rolloutGroupManagement.findRolloutGroupById(NOT_EXIST_IDL)).isNotPresent();
assertThat(rolloutGroupManagement.findRolloutGroupWithDetailedStatus(NOT_EXIST_IDL)).isNotPresent();
}
@Test
@Description("Verifies that management queries react as specfied on calls for non existing entities "
+ " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = RolloutDeletedEvent.class, count = 0),
@Expect(type = RolloutGroupCreatedEvent.class, count = 10),
@Expect(type = RolloutGroupUpdatedEvent.class, count = 10),
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@Expect(type = RolloutUpdatedEvent.class, count = 1),
@Expect(type = TargetCreatedEvent.class, count = 10) })
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
testdataFactory.createRollout("xxx");
verifyThrownExceptionBy(() -> rolloutGroupManagement.countRolloutGroupsByRolloutId(NOT_EXIST_IDL), "Rollout");
verifyThrownExceptionBy(() -> rolloutGroupManagement.countTargetsOfRolloutsGroup(NOT_EXIST_IDL),
"RolloutGroup");
verifyThrownExceptionBy(
() -> rolloutGroupManagement.findAllRolloutGroupsWithDetailedStatus(NOT_EXIST_IDL, PAGE), "Rollout");
verifyThrownExceptionBy(() -> rolloutGroupManagement.findAllTargetsWithActionStatus(PAGE, NOT_EXIST_IDL),
"RolloutGroup");
verifyThrownExceptionBy(() -> rolloutGroupManagement.findRolloutGroupsAll(NOT_EXIST_IDL, "name==*", PAGE),
"Rollout");
verifyThrownExceptionBy(() -> rolloutGroupManagement.findRolloutGroupTargets(NOT_EXIST_IDL, PAGE),
"RolloutGroup");
verifyThrownExceptionBy(() -> rolloutGroupManagement.findRolloutGroupTargets(NOT_EXIST_IDL, "name==*", PAGE),
"RolloutGroup");
}
}

View File

@@ -10,9 +10,9 @@ package org.eclipse.hawkbit.repository.jpa;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.fail;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -36,7 +36,6 @@ import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent;
import org.eclipse.hawkbit.repository.exception.ConstraintViolationException;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
import org.eclipse.hawkbit.repository.exception.RolloutIllegalStateException;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
@@ -103,7 +102,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
// verify that manually created action is still running and action
// created from rollout is finished
final List<Action> actionsByKnownTarget = deploymentManagement.findActionsByTarget(knownControllerId, pageReq)
final List<Action> actionsByKnownTarget = deploymentManagement.findActionsByTarget(knownControllerId, PAGE)
.getContent();
// should be 2 actions, one manually and one from the rollout
assertThat(actionsByKnownTarget).hasSize(2);
@@ -164,7 +163,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
// verify the split of the target and targetGroup
final Page<RolloutGroup> rolloutGroups = rolloutGroupManagement
.findRolloutGroupsByRolloutId(createdRollout.getId(), pageReq);
.findRolloutGroupsByRolloutId(createdRollout.getId(), PAGE);
// we have total of #amountTargetsForRollout in rollouts splitted in
// group size #groupSize
assertThat(rolloutGroups).hasSize(amountGroups);
@@ -279,7 +278,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
@Step("Finish three actions of the rollout group and delete two targets")
private void finishActionAndDeleteTargetsOfFirstRunningGroup(final Rollout createdRollout) {
// finish group one by finishing targets and deleting targets
final Slice<JpaAction> runningActionsSlice = actionRepository.findByRolloutIdAndStatus(pageReq,
final Slice<JpaAction> runningActionsSlice = actionRepository.findByRolloutIdAndStatus(PAGE,
createdRollout.getId(), Status.RUNNING);
final List<JpaAction> runningActions = Lists.newArrayList(runningActionsSlice.iterator());
finishAction(runningActions.get(0));
@@ -301,7 +300,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
@Step("Finish one action of the rollout group and delete four targets")
private void finishActionAndDeleteTargetsOfSecondRunningGroup(final Rollout createdRollout) {
final Slice<JpaAction> runningActionsSlice = actionRepository.findByRolloutIdAndStatus(pageReq,
final Slice<JpaAction> runningActionsSlice = actionRepository.findByRolloutIdAndStatus(PAGE,
createdRollout.getId(), Status.RUNNING);
final List<JpaAction> runningActions = Lists.newArrayList(runningActionsSlice.iterator());
finishAction(runningActions.get(0));
@@ -313,7 +312,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
@Step("Delete all targets of the rollout group")
private void deleteAllTargetsFromThirdGroup(final Rollout createdRollout) {
final Slice<JpaAction> runningActionsSlice = actionRepository.findByRolloutIdAndStatus(pageReq,
final Slice<JpaAction> runningActionsSlice = actionRepository.findByRolloutIdAndStatus(PAGE,
createdRollout.getId(), Status.SCHEDULED);
final List<JpaAction> runningActions = Lists.newArrayList(runningActionsSlice.iterator());
targetManagement.deleteTargets(Lists.newArrayList(runningActions.get(0).getTarget().getId(),
@@ -325,7 +324,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
private void verifyRolloutAndAllGroupsAreFinished(final Rollout createdRollout) {
rolloutManagement.handleRollouts();
final List<RolloutGroup> runningRolloutGroups = rolloutGroupManagement
.findRolloutGroupsByRolloutId(createdRollout.getId(), pageReq).getContent();
.findRolloutGroupsByRolloutId(createdRollout.getId(), PAGE).getContent();
assertThat(runningRolloutGroups.get(0).getStatus()).isEqualTo(RolloutGroupStatus.FINISHED);
assertThat(runningRolloutGroups.get(1).getStatus()).isEqualTo(RolloutGroupStatus.FINISHED);
assertThat(runningRolloutGroups.get(2).getStatus()).isEqualTo(RolloutGroupStatus.FINISHED);
@@ -589,7 +588,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
// round(5/2)=3 targets SCHEDULED (Group 3)
// round(2/1)=2 targets SCHEDULED (Group 4)
createdRollout = rolloutManagement.findRolloutById(createdRollout.getId()).get();
final List<RolloutGroup> rolloutGroups = createdRollout.getRolloutGroups();
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement
.findRolloutGroupsByRolloutId(createdRollout.getId(), PAGE).getContent();
Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.FINISHED, 2L);
@@ -628,9 +628,10 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
assertThat(runningActions.size()).isEqualTo(5);
// 5 targets are in the group and the DS has been assigned
final List<RolloutGroup> rolloutGroups = createdRollout.getRolloutGroups();
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement
.findRolloutGroupsByRolloutId(createdRollout.getId(), PAGE).getContent();
final Page<Target> targets = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(0).getId(),
pageReq);
PAGE);
final List<Target> targetList = targets.getContent();
assertThat(targetList.size()).isEqualTo(5);
@@ -742,7 +743,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.FINISHED, 9L);
validateRolloutActionStatus(rolloutTwo.getId(), expectedTargetCountStatus);
changeStatusForAllRunningActions(rolloutTwo, Status.FINISHED);
final Page<Target> targetPage = targetManagement.findTargetByUpdateStatus(pageReq, TargetUpdateStatus.IN_SYNC);
final Page<Target> targetPage = targetManagement.findTargetByUpdateStatus(PAGE, TargetUpdateStatus.IN_SYNC);
final List<Target> targetList = targetPage.getContent();
// 15 targets in finished/IN_SYNC status and same DS assigned
assertThat(targetList.size()).isEqualTo(amountTargetsForRollout);
@@ -767,7 +768,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
changeStatusForRunningActions(rolloutOne, Status.FINISHED, 3);
rolloutManagement.handleRollouts();
// verify: 40% error but 60% finished -> should move to next group
final List<RolloutGroup> rolloutGruops = rolloutOne.getRolloutGroups();
final List<RolloutGroup> rolloutGruops = rolloutGroupManagement
.findRolloutGroupsByRolloutId(rolloutOne.getId(), PAGE).getContent();
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 5L);
validateRolloutGroupActionStatus(rolloutGruops.get(1), expectedTargetCountStatus);
@@ -792,8 +794,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
rolloutManagement.handleRollouts();
// verify: 40% error and 60% finished -> should not move to next group
// because successCondition 80%
rolloutOne = rolloutManagement.findRolloutById(rolloutOne.getId()).get();
final List<RolloutGroup> rolloutGruops = rolloutOne.getRolloutGroups();
final List<RolloutGroup> rolloutGruops = rolloutGroupManagement
.findRolloutGroupsByRolloutId(rolloutOne.getId(), PAGE).getContent();
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.SCHEDULED, 5L);
validateRolloutGroupActionStatus(rolloutGruops.get(1), expectedTargetCountStatus);
@@ -1000,14 +1002,17 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
float percent = rolloutGroupManagement
.findRolloutGroupWithDetailedStatus(myRollout.getRolloutGroups().get(0).getId()).get()
.getTotalTargetCountStatus().getFinishedPercent();
.findRolloutGroupWithDetailedStatus(rolloutGroupManagement
.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE).getContent().get(0).getId())
.get().getTotalTargetCountStatus().getFinishedPercent();
assertThat(percent).isEqualTo(40);
changeStatusForRunningActions(myRollout, Status.FINISHED, 3);
rolloutManagement.handleRollouts();
percent = rolloutGroupManagement.findRolloutGroupWithDetailedStatus(myRollout.getRolloutGroups().get(0).getId())
percent = rolloutGroupManagement
.findRolloutGroupWithDetailedStatus(rolloutGroupManagement
.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE).getContent().get(0).getId())
.get().getTotalTargetCountStatus().getFinishedPercent();
assertThat(percent).isEqualTo(100);
@@ -1015,7 +1020,9 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
changeStatusForAllRunningActions(myRollout, Status.ERROR);
rolloutManagement.handleRollouts();
percent = rolloutGroupManagement.findRolloutGroupWithDetailedStatus(myRollout.getRolloutGroups().get(1).getId())
percent = rolloutGroupManagement
.findRolloutGroupWithDetailedStatus(rolloutGroupManagement
.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE).getContent().get(1).getId())
.get().getTotalTargetCountStatus().getFinishedPercent();
assertThat(percent).isEqualTo(80);
}
@@ -1043,7 +1050,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
rolloutManagement.handleRollouts();
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
final List<RolloutGroup> rolloutGroups = myRollout.getRolloutGroups();
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement
.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE).getContent();
Page<Target> targetPage = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(0).getId(),
rsqlParam, new OffsetBasedPageRequest(0, 100, new Sort(Direction.ASC, "controllerId")));
@@ -1075,13 +1083,10 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
final DistributionSet distributionSet = testdataFactory.createDistributionSet("dsFor" + rolloutName);
try {
testdataFactory.createRolloutByVariables(rolloutName, "desc", amountGroups, "id==notExisting",
distributionSet, successCondition, errorCondition);
fail("Was able to create a Rollout without targets.");
} catch (final ConstraintViolationException e) {
// OK
}
assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> testdataFactory.createRolloutByVariables(rolloutName, "desc", amountGroups,
"id==notExisting", distributionSet, successCondition, errorCondition))
.withMessageContaining("does not match any existing");
}
@@ -1100,14 +1105,10 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
testdataFactory.createRolloutByVariables(rolloutName, "desc", amountGroups, "id==dup-ro-*", distributionSet,
successCondition, errorCondition);
try {
testdataFactory.createRolloutByVariables(rolloutName, "desc", amountGroups, "id==dup-ro-*", distributionSet,
successCondition, errorCondition);
fail("Was able to create a duplicate Rollout.");
} catch (final EntityAlreadyExistsException e) {
// OK
}
assertThatExceptionOfType(EntityAlreadyExistsException.class)
.isThrownBy(() -> testdataFactory.createRolloutByVariables(rolloutName, "desc", amountGroups,
"id==dup-ro-*", distributionSet, successCondition, errorCondition))
.withMessageContaining("already exists in database");
}
@Test
@@ -1127,7 +1128,9 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
final List<RolloutGroup> groups = myRollout.getRolloutGroups();
final List<RolloutGroup> groups = rolloutGroupManagement
.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE).getContent();
assertThat(groups.get(0).getStatus()).isEqualTo(RolloutGroupStatus.READY);
assertThat(groups.get(0).getTotalTargets()).isEqualTo(1);
assertThat(groups.get(1).getStatus()).isEqualTo(RolloutGroupStatus.READY);
@@ -1282,7 +1285,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.CREATING);
for (final RolloutGroup group : myRollout.getRolloutGroups()) {
for (final RolloutGroup group : rolloutGroupManagement.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE)
.getContent()) {
assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.CREATING);
}
@@ -1297,7 +1301,9 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
assertThat(myRollout.getTotalTargets()).isEqualTo(amountTargetsInGroup1and2 + amountTargetsInGroup1);
final List<RolloutGroup> groups = myRollout.getRolloutGroups();
final List<RolloutGroup> groups = rolloutGroupManagement
.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE).getContent();
;
assertThat(groups.get(0).getStatus()).isEqualTo(RolloutGroupStatus.READY);
assertThat(groups.get(0).getTotalTargets()).isEqualTo(amountTargetsInGroup1);
@@ -1324,12 +1330,9 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
rolloutGroups.add(generateRolloutGroup(0, percentTargetsInGroup1, null));
rolloutGroups.add(generateRolloutGroup(1, percentTargetsInGroup2, null));
try {
rolloutManagement.createRollout(myRollout, rolloutGroups, conditions);
fail("Was able to create a Rollout with groups that are not addressing all targets");
} catch (final ConstraintViolationException e) {
// OK
}
assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> rolloutManagement.createRollout(myRollout, rolloutGroups, conditions))
.withMessageContaining("groups don't match");
}
@@ -1344,16 +1347,13 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
final RolloutGroupConditions conditions = new RolloutGroupConditionBuilder().withDefaults().build();
final RolloutCreate myRollout = generateTargetsAndRollout(rolloutName, amountTargetsForRollout);
final List<RolloutGroupCreate> rolloutGroups = new ArrayList<>(2);
rolloutGroups.add(generateRolloutGroup(0, percentTargetsInGroup1, null));
rolloutGroups.add(generateRolloutGroup(1, percentTargetsInGroup2, null));
final List<RolloutGroupCreate> rolloutGroups = Arrays.asList(
generateRolloutGroup(0, percentTargetsInGroup1, null),
generateRolloutGroup(1, percentTargetsInGroup2, null));
try {
rolloutManagement.createRollout(myRollout, rolloutGroups, conditions);
fail("Was able to create a Rollout with groups that have illegal percentages");
} catch (final ConstraintViolationException e) {
// OK
}
assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> rolloutManagement.createRollout(myRollout, rolloutGroups, conditions))
.withMessageContaining("percentage has to be between 1 and 100");
}
@@ -1367,59 +1367,12 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
final RolloutGroupConditions conditions = new RolloutGroupConditionBuilder().withDefaults().build();
final RolloutCreate myRollout = generateTargetsAndRollout(rolloutName, amountTargetsForRollout);
try {
rolloutManagement.createRollout(myRollout, illegalGroupAmount, conditions);
fail("Was able to create a Rollout with too many groups");
} catch (final ConstraintViolationException e) {
// OK
}
assertThatExceptionOfType(ConstraintViolationException.class)
.isThrownBy(() -> rolloutManagement.createRollout(myRollout, illegalGroupAmount, conditions))
.withMessageContaining("not be greater than " + quotaManagement.getMaxRolloutGroupsPerRollout());
}
@Test
@Description("Verify Exception when a Rollout groups are queried for rollout that does not exist.")
public void findRolloutGroupsForRolloutThatDoesNotExist() throws Exception {
try {
rolloutGroupManagement.findAllRolloutGroupsWithDetailedStatus(1234L, pageReq);
fail("Was able to get Rollout group for rollout that does not exist.");
} catch (final EntityNotFoundException e) {
// OK
}
}
@Test
@Description("Verify Exception when targets are queried for rollout group that does not exist.")
public void findRolloutGroupTargetsForGroupThatDoesNotExist() throws Exception {
try {
rolloutGroupManagement.findRolloutGroupTargets(1234L, pageReq);
fail("Was able to get Rollout group targets for rollout group that does not exist.");
} catch (final EntityNotFoundException e) {
// OK
}
}
@Test
@Description("Verify Exception when targets are queried for rollout group that does not exist.")
public void findRolloutGroupTargetWithActionsForGroupThatDoesNotExist() throws Exception {
try {
rolloutGroupManagement.findAllTargetsWithActionStatus(pageReq, 1234L);
fail("Was able to get Rollout group targets for rollout group that does not exist.");
} catch (final EntityNotFoundException e) {
// OK
}
}
@Test
@Description("Verify Exception when targets are counted for rollout group that does not exist.")
public void countRolloutGroupTargetWithActionsForGroupThatDoesNotExist() throws Exception {
try {
rolloutGroupManagement.countTargetsOfRolloutsGroup(1234L);
fail("Was able to count Rollout group targets for rollout group that does not exist.");
} catch (final EntityNotFoundException e) {
// OK
}
}
@Test
@Description("Verify the start of a Rollout does not work during creation phase.")
public void createAndStartRolloutDuringCreationFails() throws Exception {
@@ -1445,12 +1398,10 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.CREATING);
try {
rolloutManagement.startRollout(myRollout.getId());
fail("Was able to start a Rollout in CREATING status");
} catch (final RolloutIllegalStateException e) {
// OK
}
final Long rolloutId = myRollout.getId();
assertThatExceptionOfType(RolloutIllegalStateException.class)
.isThrownBy(() -> rolloutManagement.startRollout(rolloutId))
.withMessageContaining("can only be started in state ready");
}
@@ -1506,7 +1457,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
rolloutManagement.handleRollouts();
// verify we have running actions
assertThat(actionRepository.findByRolloutIdAndStatus(pageReq, createdRollout.getId(), Status.RUNNING)
assertThat(actionRepository.findByRolloutIdAndStatus(PAGE, createdRollout.getId(), Status.RUNNING)
.getNumberOfElements()).isEqualTo(2);
// test
@@ -1523,16 +1474,16 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
.updateRollout(entityFactory.rollout().update(createdRollout.getId()).description("test")))
.withMessageContaining("" + createdRollout.getId());
assertThat(rolloutManagement.findAll(pageReq, true).getContent()).hasSize(1);
assertThat(rolloutManagement.findAll(pageReq, false).getContent()).hasSize(0);
assertThat(rolloutGroupManagement.findAllRolloutGroupsWithDetailedStatus(createdRollout.getId(), pageReq)
assertThat(rolloutManagement.findAll(PAGE, true).getContent()).hasSize(1);
assertThat(rolloutManagement.findAll(PAGE, false).getContent()).hasSize(0);
assertThat(rolloutGroupManagement.findAllRolloutGroupsWithDetailedStatus(createdRollout.getId(), PAGE)
.getContent()).hasSize(amountGroups);
// verify that all scheduled actions are deleted
assertThat(actionRepository.findByRolloutIdAndStatus(pageReq, deletedRollout.getId(), Status.SCHEDULED)
assertThat(actionRepository.findByRolloutIdAndStatus(PAGE, deletedRollout.getId(), Status.SCHEDULED)
.getNumberOfElements()).isEqualTo(0);
// verify that all running actions keep running
assertThat(actionRepository.findByRolloutIdAndStatus(pageReq, deletedRollout.getId(), Status.RUNNING)
assertThat(actionRepository.findByRolloutIdAndStatus(PAGE, deletedRollout.getId(), Status.RUNNING)
.getNumberOfElements()).isEqualTo(2);
}

View File

@@ -112,7 +112,7 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
verifyThrownExceptionBy(() -> softwareManagement.deleteSoftwareModuleType(NOT_EXIST_IDL), "SoftwareModuleType");
verifyThrownExceptionBy(() -> softwareManagement.findSoftwareModuleByAssignedTo(pageReq, NOT_EXIST_IDL),
verifyThrownExceptionBy(() -> softwareManagement.findSoftwareModuleByAssignedTo(PAGE, NOT_EXIST_IDL),
"DistributionSet");
verifyThrownExceptionBy(
@@ -122,11 +122,12 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
verifyThrownExceptionBy(() -> softwareManagement.findSoftwareModuleMetadata(NOT_EXIST_IDL, NOT_EXIST_ID),
"SoftwareModule");
verifyThrownExceptionBy(() -> softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(NOT_EXIST_IDL),
verifyThrownExceptionBy(
() -> softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(PAGE, NOT_EXIST_IDL),
"SoftwareModule");
verifyThrownExceptionBy(() -> softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(NOT_EXIST_IDL,
"name==*", pageReq), "SoftwareModule");
verifyThrownExceptionBy(() -> softwareManagement.findSoftwareModulesByType(pageReq, NOT_EXIST_IDL),
"name==*", PAGE), "SoftwareModule");
verifyThrownExceptionBy(() -> softwareManagement.findSoftwareModulesByType(PAGE, NOT_EXIST_IDL),
"SoftwareModule");
verifyThrownExceptionBy(
@@ -241,29 +242,29 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
ds = (JpaDistributionSet) assignSet(target, ds).getDistributionSet();
// standard searches
assertThat(softwareManagement.findSoftwareModuleByFilters(pageReq, "poky", osType.getId()).getContent())
assertThat(softwareManagement.findSoftwareModuleByFilters(PAGE, "poky", osType.getId()).getContent())
.hasSize(1);
assertThat(softwareManagement.findSoftwareModuleByFilters(pageReq, "poky", osType.getId()).getContent().get(0))
assertThat(softwareManagement.findSoftwareModuleByFilters(PAGE, "poky", osType.getId()).getContent().get(0))
.isEqualTo(os);
assertThat(softwareManagement.findSoftwareModuleByFilters(pageReq, "oracle%", runtimeType.getId()).getContent())
assertThat(softwareManagement.findSoftwareModuleByFilters(PAGE, "oracle%", runtimeType.getId()).getContent())
.hasSize(1);
assertThat(softwareManagement.findSoftwareModuleByFilters(pageReq, "oracle%", runtimeType.getId()).getContent()
assertThat(softwareManagement.findSoftwareModuleByFilters(PAGE, "oracle%", runtimeType.getId()).getContent()
.get(0)).isEqualTo(jvm);
assertThat(softwareManagement.findSoftwareModuleByFilters(pageReq, "1.0.1", appType.getId()).getContent())
assertThat(softwareManagement.findSoftwareModuleByFilters(PAGE, "1.0.1", appType.getId()).getContent())
.hasSize(1);
assertThat(
softwareManagement.findSoftwareModuleByFilters(pageReq, "1.0.1", appType.getId()).getContent().get(0))
softwareManagement.findSoftwareModuleByFilters(PAGE, "1.0.1", appType.getId()).getContent().get(0))
.isEqualTo(ah);
assertThat(softwareManagement.findSoftwareModuleByFilters(pageReq, "1.0%", appType.getId()).getContent())
assertThat(softwareManagement.findSoftwareModuleByFilters(PAGE, "1.0%", appType.getId()).getContent())
.hasSize(2);
// no we search with on entity marked as deleted
softwareManagement.deleteSoftwareModule(
softwareModuleRepository.findByAssignedToAndType(pageReq, ds, appType).getContent().get(0).getId());
softwareModuleRepository.findByAssignedToAndType(PAGE, ds, appType).getContent().get(0).getId());
assertThat(softwareManagement.findSoftwareModuleByFilters(pageReq, "1.0%", appType.getId()).getContent())
assertThat(softwareManagement.findSoftwareModuleByFilters(PAGE, "1.0%", appType.getId()).getContent())
.hasSize(1);
assertThat(softwareManagement.findSoftwareModuleByFilters(pageReq, "1.0%", appType.getId()).getContent().get(0))
assertThat(softwareManagement.findSoftwareModuleByFilters(PAGE, "1.0%", appType.getId()).getContent().get(0))
.isEqualTo(ah);
}
@@ -272,7 +273,7 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).get().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.PENDING);
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(ds);
final Action action = actionRepository.findByTargetAndDistributionSet(pageReq, target, ds).getContent().get(0);
final Action action = actionRepository.findByTargetAndDistributionSet(PAGE, target, ds).getContent().get(0);
assertThat(action).isNotNull();
return action;
}
@@ -297,7 +298,7 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
softwareManagement.deleteSoftwareModule(testdataFactory.createSoftwareModuleOs("deleted").getId());
testdataFactory.createSoftwareModuleApp();
assertThat(softwareManagement.findSoftwareModulesByType(pageReq, osType.getId()).getContent())
assertThat(softwareManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent())
.as("Expected to find the following number of modules:").hasSize(2).as("with the following elements")
.contains(two, one);
}
@@ -319,18 +320,18 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
@Test
@Description("Tests the successfull deletion of software module types. Both unused (hard delete) and used ones (soft delete).")
public void deleteAssignedAndUnassignedSoftwareModuleTypes() {
assertThat(softwareManagement.findSoftwareModuleTypesAll(pageReq)).hasSize(3).contains(osType, runtimeType,
assertThat(softwareManagement.findSoftwareModuleTypesAll(PAGE)).hasSize(3).contains(osType, runtimeType,
appType);
SoftwareModuleType type = softwareManagement.createSoftwareModuleType(
entityFactory.softwareModuleType().create().key("bundle").name("OSGi Bundle"));
assertThat(softwareManagement.findSoftwareModuleTypesAll(pageReq)).hasSize(4).contains(osType, runtimeType,
assertThat(softwareManagement.findSoftwareModuleTypesAll(PAGE)).hasSize(4).contains(osType, runtimeType,
appType, type);
// delete unassigned
softwareManagement.deleteSoftwareModuleType(type.getId());
assertThat(softwareManagement.findSoftwareModuleTypesAll(pageReq)).hasSize(3).contains(osType, runtimeType,
assertThat(softwareManagement.findSoftwareModuleTypesAll(PAGE)).hasSize(3).contains(osType, runtimeType,
appType);
assertThat(softwareModuleTypeRepository.findAll()).hasSize(3).contains((JpaSoftwareModuleType) osType,
(JpaSoftwareModuleType) runtimeType, (JpaSoftwareModuleType) appType);
@@ -338,7 +339,7 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
type = softwareManagement.createSoftwareModuleType(
entityFactory.softwareModuleType().create().key("bundle2").name("OSGi Bundle2"));
assertThat(softwareManagement.findSoftwareModuleTypesAll(pageReq)).hasSize(4).contains(osType, runtimeType,
assertThat(softwareManagement.findSoftwareModuleTypesAll(PAGE)).hasSize(4).contains(osType, runtimeType,
appType, type);
softwareManagement.createSoftwareModule(
@@ -346,7 +347,7 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
// delete assigned
softwareManagement.deleteSoftwareModuleType(type.getId());
assertThat(softwareManagement.findSoftwareModuleTypesAll(pageReq)).hasSize(3).contains(osType, runtimeType,
assertThat(softwareManagement.findSoftwareModuleTypesAll(PAGE)).hasSize(3).contains(osType, runtimeType,
appType);
assertThat(softwareModuleTypeRepository.findAll()).hasSize(4).contains((JpaSoftwareModuleType) osType,
@@ -397,7 +398,7 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
// verify: assignedModule is marked as deleted
assignedModule = softwareManagement.findSoftwareModuleById(assignedModule.getId()).get();
assertTrue("The module should be flagged as deleted", assignedModule.isDeleted());
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0);
assertThat(softwareManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
assertThat(softwareModuleRepository.findAll()).hasSize(1);
// verify: binary data is deleted
@@ -437,7 +438,7 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
// verify: assignedModule is marked as deleted
assignedModule = softwareManagement.findSoftwareModuleById(assignedModule.getId()).get();
assertTrue("The found module should be flagged deleted", assignedModule.isDeleted());
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0);
assertThat(softwareManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
assertThat(softwareModuleRepository.findAll()).hasSize(1);
// verify: binary data is deleted
@@ -538,7 +539,7 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
assertThat(moduleY).isNotNull();
assertTrue("The module should be flagged deleted", moduleX.isDeleted());
assertTrue("The module should be flagged deleted", moduleY.isDeleted());
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0);
assertThat(softwareManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
assertThat(softwareModuleRepository.findAll()).hasSize(2);
// verify: binary data of artifact is deleted
@@ -621,21 +622,21 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
softwareManagement.deleteSoftwareModule(deleted.getId());
// with filter on name, version and module type
assertThat(softwareManagement.findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(pageReq,
assertThat(softwareManagement.findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(PAGE,
set.getId(), "%found%", testType.getId()).getContent())
.as("Found modules with given name, given module type and the assigned ones first")
.containsExactly(new AssignedSoftwareModule(one, true), new AssignedSoftwareModule(two, true),
new AssignedSoftwareModule(unassigned, false));
// with filter on module type only
assertThat(softwareManagement.findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(pageReq,
assertThat(softwareManagement.findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(PAGE,
set.getId(), null, testType.getId()).getContent())
.as("Found modules with given module type and the assigned ones first").containsExactly(
new AssignedSoftwareModule(differentName, true), new AssignedSoftwareModule(one, true),
new AssignedSoftwareModule(two, true), new AssignedSoftwareModule(unassigned, false));
// without any filter
assertThat(softwareManagement.findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(pageReq,
assertThat(softwareManagement.findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(PAGE,
set.getId(), null, null).getContent()).as("Found modules with the assigned ones first").containsExactly(
new AssignedSoftwareModule(differentName, true), new AssignedSoftwareModule(one, true),
new AssignedSoftwareModule(two, true), new AssignedSoftwareModule(four, true),
@@ -773,7 +774,7 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
.create().name("set").version("1").modules(Lists.newArrayList(one.getId(), deleted.getId())));
softwareManagement.deleteSoftwareModule(deleted.getId());
assertThat(softwareManagement.findSoftwareModuleByAssignedTo(pageReq, set.getId()).getContent())
assertThat(softwareManagement.findSoftwareModuleByAssignedTo(PAGE, set.getId()).getContent())
.as("Found this number of modules").hasSize(2);
}
@@ -882,13 +883,13 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
.createSoftwareModuleMetadata(ah.getId(), entityFactory.generateMetadata(knownKey1, knownValue1))
.getSoftwareModule();
assertThat(softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(ah.getId()))
.as("Contains the created metadata element")
.containsExactly(new JpaSoftwareModuleMetadata(knownKey1, ah, knownValue1));
assertThat(softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(new PageRequest(0, 100), ah.getId())
.getContent()).as("Contains the created metadata element")
.containsExactly(new JpaSoftwareModuleMetadata(knownKey1, ah, knownValue1));
softwareManagement.deleteSoftwareModuleMetadata(ah.getId(), knownKey1);
assertThat(softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(ah.getId()))
.as("Metadata elemenets are").isEmpty();
assertThat(softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(new PageRequest(0, 100), ah.getId())
.getContent()).as("Metadata elemenets are").isEmpty();
}
@Test

View File

@@ -33,11 +33,11 @@ public class SystemManagementTest extends AbstractJpaIntegrationTest {
@Test
@Description("Ensures that findTenants returns all tenants and not only restricted to the tenant which currently is logged in")
public void findTenantsReturnsAllTenantsNotOnlyWhichLoggedIn() throws Exception {
assertThat(systemManagement.findTenants()).hasSize(1);
assertThat(systemManagement.findTenants(PAGE).getContent()).hasSize(1);
createTestTenantsForSystemStatistics(2, 0, 0, 0);
assertThat(systemManagement.findTenants()).hasSize(3);
assertThat(systemManagement.findTenants(PAGE).getContent()).hasSize(3);
}
@Test

View File

@@ -19,9 +19,9 @@ import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdateEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdateEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdatedEvent;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
import org.eclipse.hawkbit.repository.model.DistributionSet;
@@ -64,16 +64,21 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
@Test
@Description("Verifies that management queries react as specfied on calls for non existing entities "
+ " by means of throwing EntityNotFoundException.")
@ExpectEvents({ @Expect(type = DistributionSetTagUpdateEvent.class, count = 0),
@Expect(type = TargetTagUpdateEvent.class, count = 0) })
@ExpectEvents({ @Expect(type = DistributionSetTagUpdatedEvent.class, count = 0),
@Expect(type = TargetTagUpdatedEvent.class, count = 0) })
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
verifyThrownExceptionBy(() -> tagManagement.deleteDistributionSetTag(NOT_EXIST_ID), "DistributionSetTag");
verifyThrownExceptionBy(() -> tagManagement.deleteTargetTag(NOT_EXIST_ID), "TargetTag");
verifyThrownExceptionBy(() -> tagManagement.findDistributionSetTagsByDistributionSet(PAGE, NOT_EXIST_IDL),
"DistributionSet");
verifyThrownExceptionBy(() -> tagManagement.updateDistributionSetTag(entityFactory.tag().update(NOT_EXIST_IDL)),
"DistributionSetTag");
verifyThrownExceptionBy(() -> tagManagement.updateTargetTag(entityFactory.tag().update(NOT_EXIST_IDL)),
"TargetTag");
verifyThrownExceptionBy(() -> tagManagement.findAllTargetTags(PAGE, NOT_EXIST_ID), "Target");
}
@Test
@@ -118,7 +123,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
assertEquals("filter works not correct",
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
.getTotalElements());
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
@@ -126,7 +131,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
assertEquals("filter works not correct",
dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
.getTotalElements());
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
@@ -134,13 +139,13 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
assertEquals("filter works not correct",
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
.getTotalElements());
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
.setTagNames(Lists.newArrayList(tagX.getName()));
assertEquals("filter works not correct", 0, distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements());
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
assertEquals("wrong tag size", 5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
@@ -157,20 +162,20 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
assertEquals("filter works not correct",
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
.getTotalElements());
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
.setTagNames(Lists.newArrayList(tagB.getName()));
assertEquals("filter works not correct", 0, distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements());
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
.setTagNames(Lists.newArrayList(tagC.getName()));
assertEquals("filter works not correct",
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
.getTotalElements());
}
@@ -193,7 +198,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
assertThat(result.getAssigned()).isEqualTo(20);
assertThat(result.getAssignedEntity()).containsAll(distributionSetManagement
.findDistributionSetsAll(groupA.stream().map(set -> set.getId()).collect(Collectors.toList())));
.findDistributionSetsById(groupA.stream().map(DistributionSet::getId).collect(Collectors.toList())));
assertThat(result.getUnassigned()).isEqualTo(0);
assertThat(result.getUnassignedEntity()).isEmpty();
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
@@ -203,7 +208,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
assertThat(result.getAssigned()).isEqualTo(20);
assertThat(result.getAssignedEntity()).containsAll(distributionSetManagement
.findDistributionSetsAll(groupB.stream().map(set -> set.getId()).collect(Collectors.toList())));
.findDistributionSetsById(groupB.stream().map(DistributionSet::getId).collect(Collectors.toList())));
assertThat(result.getUnassigned()).isEqualTo(0);
assertThat(result.getUnassignedEntity()).isEmpty();
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
@@ -214,8 +219,8 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
assertThat(result.getAssigned()).isEqualTo(0);
assertThat(result.getAssignedEntity()).isEmpty();
assertThat(result.getUnassigned()).isEqualTo(40);
assertThat(result.getUnassignedEntity()).containsAll(distributionSetManagement.findDistributionSetsAll(
concat(groupB, groupA).stream().map(set -> set.getId()).collect(Collectors.toList())));
assertThat(result.getUnassignedEntity()).containsAll(distributionSetManagement.findDistributionSetsById(
concat(groupB, groupA).stream().map(DistributionSet::getId).collect(Collectors.toList())));
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
}
@@ -234,7 +239,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
TargetTagAssignmentResult result = toggleTagAssignment(groupA, tag);
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
assertThat(result.getAssigned()).isEqualTo(20);
assertThat(result.getAssignedEntity()).containsAll(targetManagement.findTargetByControllerID(
assertThat(result.getAssignedEntity()).containsAll(targetManagement.findTargetsByControllerID(
groupA.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
assertThat(result.getUnassigned()).isEqualTo(0);
assertThat(result.getUnassignedEntity()).isEmpty();
@@ -244,7 +249,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
result = toggleTagAssignment(concat(groupA, groupB), tag);
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
assertThat(result.getAssigned()).isEqualTo(20);
assertThat(result.getAssignedEntity()).containsAll(targetManagement.findTargetByControllerID(
assertThat(result.getAssignedEntity()).containsAll(targetManagement.findTargetsByControllerID(
groupB.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
assertThat(result.getUnassigned()).isEqualTo(0);
assertThat(result.getUnassignedEntity()).isEmpty();
@@ -256,7 +261,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
assertThat(result.getAssigned()).isEqualTo(0);
assertThat(result.getAssignedEntity()).isEmpty();
assertThat(result.getUnassigned()).isEqualTo(40);
assertThat(result.getUnassignedEntity()).containsAll(targetManagement.findTargetByControllerID(
assertThat(result.getUnassignedEntity()).containsAll(targetManagement.findTargetsByControllerID(
concat(groupB, groupA).stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
assertThat(result.getTargetTag()).isEqualTo(tag);
@@ -300,7 +305,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
final TargetTag toDelete = tags.iterator().next();
for (final Target target : targetRepository.findAll()) {
assertThat(tagManagement.findAllTargetTags(pageReq, target.getControllerId()).getContent())
assertThat(tagManagement.findAllTargetTags(PAGE, target.getControllerId()).getContent())
.contains(toDelete);
}
@@ -309,7 +314,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
// check
for (final Target target : targetRepository.findAll()) {
assertThat(tagManagement.findAllTargetTags(pageReq, target.getControllerId()).getContent())
assertThat(tagManagement.findAllTargetTags(PAGE, target.getControllerId()).getContent())
.doesNotContain(toDelete);
}
assertThat(targetTagRepository.findOne(toDelete.getId())).as("No tag should be found").isNull();
@@ -365,8 +370,8 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
final DistributionSetTag toDelete = tags.iterator().next();
for (final DistributionSet set : distributionSetRepository.findAll()) {
assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).get().getTags())
.as("Wrong tag found").contains(toDelete);
assertThat(distributionSetRepository.findOne(set.getId()).getTags()).as("Wrong tag found")
.contains(toDelete);
}
// delete
@@ -374,10 +379,12 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
// check
assertThat(distributionSetTagRepository.findOne(toDelete.getId())).as("Deleted tag should be null").isNull();
assertThat(tagManagement.findAllDistributionSetTags()).as("Wrong size of tags after deletion").hasSize(19);
assertThat(tagManagement.findAllDistributionSetTags(PAGE).getContent())
.as("Wrong size of tags after deletion").hasSize(19);
for (final DistributionSet set : distributionSetRepository.findAll()) {
assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).get().getTags())
.as("Wrong found tags").doesNotContain(toDelete);
assertThat(distributionSetRepository.findOne(set.getId()).getTags()).as("Wrong found tags")
.doesNotContain(toDelete);
}
}
@@ -448,7 +455,8 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
tagManagement.updateDistributionSetTag(entityFactory.tag().update(savedAssigned.getId()).name("test123"));
// check data
assertThat(tagManagement.findAllDistributionSetTags()).as("Wrong size of ds tags").hasSize(tags.size());
assertThat(tagManagement.findAllDistributionSetTags(PAGE).getContent()).as("Wrong size of ds tags")
.hasSize(tags.size());
assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).as("Wrong ds tag found")
.isEqualTo("test123");
}
@@ -459,7 +467,8 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
final List<DistributionSetTag> tags = createDsSetsWithTags();
// test
assertThat(tagManagement.findAllDistributionSetTags()).as("Wrong size of tags").hasSize(tags.size());
assertThat(tagManagement.findAllDistributionSetTags(PAGE).getContent()).as("Wrong size of tags")
.hasSize(tags.size());
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags").hasSize(20);
}
@@ -479,6 +488,6 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
tags.forEach(tag -> toggleTagAssignment(sets, tag));
return tagManagement.findAllDistributionSetTags();
return tagManagement.findAllDistributionSetTags(PAGE).getContent();
}
}

View File

@@ -68,7 +68,7 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
verifyThrownExceptionBy(() -> targetFilterQueryManagement.deleteTargetFilterQuery(NOT_EXIST_IDL),
"TargetFilterQuery");
verifyThrownExceptionBy(() -> targetFilterQueryManagement.findTargetFilterQueryByAutoAssignDS(pageReq,
verifyThrownExceptionBy(() -> targetFilterQueryManagement.findTargetFilterQueryByAutoAssignDS(PAGE,
NOT_EXIST_IDL, "name==*"), "DistributionSet");
verifyThrownExceptionBy(

View File

@@ -107,11 +107,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
// get final updated version of targets
targAs = targetManagement
.findTargetByControllerID(targAs.stream().map(Target::getControllerId).collect(Collectors.toList()));
.findTargetsByControllerID(targAs.stream().map(Target::getControllerId).collect(Collectors.toList()));
targBs = targetManagement
.findTargetByControllerID(targBs.stream().map(Target::getControllerId).collect(Collectors.toList()));
.findTargetsByControllerID(targBs.stream().map(Target::getControllerId).collect(Collectors.toList()));
targCs = targetManagement
.findTargetByControllerID(targCs.stream().map(Target::getControllerId).collect(Collectors.toList()));
.findTargetsByControllerID(targCs.stream().map(Target::getControllerId).collect(Collectors.toList()));
// try to find several targets with different filter settings
verifyThat1TargetHasNameAndId("targ-A-special", targSpecialName.getControllerId());
@@ -123,14 +123,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
verifyThat0TargetsWithTagAndDescOrNameHasDS(targTagW, setA);
verifyThat0TargetsWithNameOrdescAndDSHaveTag(targTagX, setA);
verifyThat3TargetsHaveDSAssigned(setA,
targetManagement.findTargetByControllerID(Lists.newArrayList(assignedA, assignedB, assignedC)));
targetManagement.findTargetsByControllerID(Lists.newArrayList(assignedA, assignedB, assignedC)));
verifyThat1TargetWithDescOrNameHasDS(setA, targetManagement.findTargetByControllerID(assignedA).get());
List<Target> expected = concat(targAs, targBs, targCs, targDs);
expected.removeAll(
targetManagement.findTargetByControllerID(Lists.newArrayList(assignedA, assignedB, assignedC)));
targetManagement.findTargetsByControllerID(Lists.newArrayList(assignedA, assignedB, assignedC)));
verifyThat397TargetsAreInStatusUnknown(unknown, expected);
expected = concat(targBs, targCs);
expected.removeAll(targetManagement.findTargetByControllerID(Lists.newArrayList(assignedB, assignedC)));
expected.removeAll(targetManagement.findTargetsByControllerID(Lists.newArrayList(assignedB, assignedC)));
verifyThat198TargetsAreInStatusUnknownAndHaveGivenTags(targTagY, targTagW, unknown, expected);
verfyThat0TargetsAreInStatusUnknownAndHaveDSAssigned(setA, unknown);
expected = concat(targAs);
@@ -140,23 +140,23 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
expected.remove(targetManagement.findTargetByControllerID(assignedB).get());
verifyThat99TargetsWithGivenNameOrDescAndTagAreInStatusUnknown(targTagW, unknown, expected);
verifyThat3TargetsAreInStatusPending(pending,
targetManagement.findTargetByControllerID(Lists.newArrayList(assignedA, assignedB, assignedC)));
targetManagement.findTargetsByControllerID(Lists.newArrayList(assignedA, assignedB, assignedC)));
verifyThat3TargetsWithGivenDSAreInPending(setA, pending,
targetManagement.findTargetByControllerID(Lists.newArrayList(assignedA, assignedB, assignedC)));
targetManagement.findTargetsByControllerID(Lists.newArrayList(assignedA, assignedB, assignedC)));
verifyThat1TargetWithGivenNameOrDescAndDSIsInPending(setA, pending,
targetManagement.findTargetByControllerID(assignedA).get());
verifyThat1TargetWithGivenNameOrDescAndTagAndDSIsInPending(targTagW, setA, pending,
targetManagement.findTargetByControllerID(assignedB).get());
verifyThat2TargetsWithGivenTagAndDSIsInPending(targTagW, setA, pending,
targetManagement.findTargetByControllerID(Lists.newArrayList(assignedB, assignedC)));
targetManagement.findTargetsByControllerID(Lists.newArrayList(assignedB, assignedC)));
verifyThat2TargetsWithGivenTagAreInPending(targTagW, pending,
targetManagement.findTargetByControllerID(Lists.newArrayList(assignedB, assignedC)));
targetManagement.findTargetsByControllerID(Lists.newArrayList(assignedB, assignedC)));
verifyThat200targetsWithGivenTagAreInStatusPendingorUnknown(targTagW, both, concat(targBs, targCs));
verfiyThat1TargetAIsInStatusPendingAndHasDSInstalled(installedSet, pending,
targetManagement.findTargetByControllerID(installedC).get());
expected = concat(targBs, targCs);
expected.removeAll(targetManagement.findTargetByControllerID(Lists.newArrayList(assignedB, assignedC)));
expected.removeAll(targetManagement.findTargetsByControllerID(Lists.newArrayList(assignedB, assignedC)));
verifyThat198TargetsAreInStatusUnknownAndOverdue(unknown, expected);
}
@@ -165,14 +165,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final List<TargetUpdateStatus> pending, final Target expected) {
final String query = "updatestatus==pending and installedds.name==" + installedSet.getName();
assertThat(targetManagement
.findTargetByFilters(pageReq, pending, null, null, installedSet.getId(), Boolean.FALSE, new String[0])
.findTargetByFilters(PAGE, pending, null, null, installedSet.getId(), Boolean.FALSE, new String[0])
.getContent()).as("has number of elements").hasSize(1)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, null,
installedSet.getId(), Boolean.FALSE, new String[0])))
.as("and contains the following elements").containsExactly(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@@ -182,13 +182,13 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "(updatestatus==pending or updatestatus==unknown) and tag==" + targTagW.getName();
assertThat(targetManagement
.findTargetByFilters(pageReq, both, null, null, null, Boolean.FALSE, targTagW.getName()).getContent())
.findTargetByFilters(PAGE, both, null, null, null, Boolean.FALSE, targTagW.getName()).getContent())
.as("has number of elements").hasSize(200).as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(both, null, null, null,
Boolean.FALSE, targTagW.getName())))
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@Step
@@ -197,14 +197,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "updatestatus==pending and tag==" + targTagW.getName();
assertThat(targetManagement
.findTargetByFilters(pageReq, pending, null, null, null, Boolean.FALSE, targTagW.getName())
.findTargetByFilters(PAGE, pending, null, null, null, Boolean.FALSE, targTagW.getName())
.getContent()).as("has number of elements").hasSize(2)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, null, null,
Boolean.FALSE, targTagW.getName())))
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@Step
@@ -214,14 +214,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
+ setA.getName() + ") and tag==" + targTagW.getName();
assertThat(targetManagement
.findTargetByFilters(pageReq, pending, null, null, setA.getId(), Boolean.FALSE, targTagW.getName())
.findTargetByFilters(PAGE, pending, null, null, setA.getId(), Boolean.FALSE, targTagW.getName())
.getContent()).as("has number of elements").hasSize(2)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, null,
setA.getId(), Boolean.FALSE, targTagW.getName())))
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@Step
@@ -230,14 +230,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
+ setA.getName() + ") and (name==*targ-B* or description==*targ-B*) and tag==" + targTagW.getName();
assertThat(targetManagement.findTargetByFilters(pageReq, pending, null, "%targ-B%", setA.getId(), Boolean.FALSE,
assertThat(targetManagement.findTargetByFilters(PAGE, pending, null, "%targ-B%", setA.getId(), Boolean.FALSE,
targTagW.getName()).getContent()).as("has number of elements").hasSize(1)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, "%targ-B%",
setA.getId(), Boolean.FALSE, targTagW.getName())))
.as("and contains the following elements").containsExactly(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@Step
@@ -247,14 +247,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
+ setA.getName() + ") and (name==*targ-A* or description==*targ-A*)";
assertThat(targetManagement
.findTargetByFilters(pageReq, pending, null, "%targ-A%", setA.getId(), Boolean.FALSE, new String[0])
.findTargetByFilters(PAGE, pending, null, "%targ-A%", setA.getId(), Boolean.FALSE, new String[0])
.getContent()).as("has number of elements").hasSize(1)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, "%targ-A%",
setA.getId(), Boolean.FALSE, new String[0])))
.as("and contains the following elements").containsExactly(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@Step
@@ -264,14 +264,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
+ setA.getName() + ")";
assertThat(targetManagement
.findTargetByFilters(pageReq, pending, null, null, setA.getId(), Boolean.FALSE, new String[0])
.findTargetByFilters(PAGE, pending, null, null, setA.getId(), Boolean.FALSE, new String[0])
.getContent()).as("has number of elements").hasSize(3)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, null,
setA.getId(), Boolean.FALSE, new String[0])))
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@Step
@@ -280,13 +280,13 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "updatestatus==pending";
assertThat(targetManagement
.findTargetByFilters(pageReq, pending, null, null, null, Boolean.FALSE, new String[0]).getContent())
.findTargetByFilters(PAGE, pending, null, null, null, Boolean.FALSE, new String[0]).getContent())
.as("has number of elements").hasSize(3).as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(pending, null, null, null,
Boolean.FALSE, new String[0])))
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@Step
@@ -296,14 +296,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
+ targTagW.getName();
assertThat(targetManagement
.findTargetByFilters(pageReq, unknown, null, "%targ-B%", null, Boolean.FALSE, targTagW.getName())
.findTargetByFilters(PAGE, unknown, null, "%targ-B%", null, Boolean.FALSE, targTagW.getName())
.getContent()).as("has number of elements").hasSize(99)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, null, "%targ-B%",
null, Boolean.FALSE, targTagW.getName())))
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@Step
@@ -312,14 +312,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "updatestatus==unknown and (name==*targ-A* or description==*targ-A*)";
assertThat(targetManagement
.findTargetByFilters(pageReq, unknown, null, "%targ-A%", null, Boolean.FALSE, new String[0])
.findTargetByFilters(PAGE, unknown, null, "%targ-A%", null, Boolean.FALSE, new String[0])
.getContent()).as("has number of elements").hasSize(99)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, null, "%targ-A%",
null, Boolean.FALSE, new String[0])))
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@@ -330,13 +330,13 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
+ setA.getName() + ")";
assertThat(targetManagement
.findTargetByFilters(pageReq, unknown, null, null, setA.getId(), Boolean.FALSE, new String[0])
.findTargetByFilters(PAGE, unknown, null, null, setA.getId(), Boolean.FALSE, new String[0])
.getContent()).as("has number of elements").hasSize(0)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, null, null,
setA.getId(), Boolean.FALSE, new String[0])))
.as("and filter query returns the same result")
.hasSize(targetManagement.findTargetsAll(query, pageReq).getContent().size());
.hasSize(targetManagement.findTargetsAll(query, PAGE).getContent().size());
}
@Step
@@ -345,14 +345,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "updatestatus==unknown and (tag==" + targTagY.getName() + " or tag==" + targTagW.getName()
+ ")";
assertThat(targetManagement.findTargetByFilters(pageReq, unknown, null, null, null, Boolean.FALSE,
assertThat(targetManagement.findTargetByFilters(PAGE, unknown, null, null, null, Boolean.FALSE,
targTagY.getName(), targTagW.getName()).getContent()).as("has number of elements").hasSize(198)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, null, null, null,
Boolean.FALSE, targTagY.getName(), targTagW.getName())))
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@Step
@@ -361,13 +361,13 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "updatestatus==unknown";
assertThat(targetManagement
.findTargetByFilters(pageReq, unknown, null, null, null, Boolean.FALSE, new String[0]).getContent())
.findTargetByFilters(PAGE, unknown, null, null, null, Boolean.FALSE, new String[0]).getContent())
.as("has number of elements").hasSize(397).as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, null, null, null,
Boolean.FALSE, new String[0])))
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@@ -378,14 +378,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "lastcontrollerrequestat=le=${overdue_ts};updatestatus==UNKNOWN";
assertThat(targetManagement
.findTargetByFilters(pageReq, unknown, Boolean.TRUE, null, null, Boolean.FALSE, new String[0])
.findTargetByFilters(PAGE, unknown, Boolean.TRUE, null, null, Boolean.FALSE, new String[0])
.getContent()).as("has number of elements").hasSize(198)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, Boolean.TRUE, null,
null, Boolean.FALSE, new String[0])))
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@Step
@@ -394,14 +394,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
+ " or installedds.name==" + setA.getName() + ")";
assertThat(targetManagement
.findTargetByFilters(pageReq, null, null, "%targ-A%", setA.getId(), Boolean.FALSE, new String[0])
.findTargetByFilters(PAGE, null, null, "%targ-A%", setA.getId(), Boolean.FALSE, new String[0])
.getContent()).as("has number of elements").hasSize(1)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, "%targ-A%",
setA.getId(), Boolean.FALSE, new String[0])))
.as("and contains the following elements").containsExactly(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@@ -410,14 +410,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName();
assertThat(targetManagement
.findTargetByFilters(pageReq, null, null, null, setA.getId(), Boolean.FALSE, new String[0])
.findTargetByFilters(PAGE, null, null, null, setA.getId(), Boolean.FALSE, new String[0])
.getContent()).as("has number of elements").hasSize(3)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, null,
setA.getId(), Boolean.FALSE, new String[0])))
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@@ -426,13 +426,13 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "(name==*targ-C* or description==*targ-C*) and tag==" + targTagX.getName()
+ " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")";
assertThat(targetManagement
.findTargetByFilters(pageReq, null, null, "%targ-C%", setA.getId(), Boolean.FALSE, targTagX.getName())
.findTargetByFilters(PAGE, null, null, "%targ-C%", setA.getId(), Boolean.FALSE, targTagX.getName())
.getContent()).as("has number of elements").hasSize(0)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, "%targ-C%",
setA.getId(), Boolean.FALSE, targTagX.getName())))
.as("and filter query returns the same result")
.hasSize(targetManagement.findTargetsAll(query, pageReq).getContent().size());
.hasSize(targetManagement.findTargetsAll(query, PAGE).getContent().size());
}
@@ -441,13 +441,13 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "(name==*targ-A* or description==*targ-A*) and tag==" + targTagW.getName()
+ " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")";
assertThat(targetManagement
.findTargetByFilters(pageReq, null, null, "%targ-A%", setA.getId(), Boolean.FALSE, targTagW.getName())
.findTargetByFilters(PAGE, null, null, "%targ-A%", setA.getId(), Boolean.FALSE, targTagW.getName())
.getContent()).as("has number of elements").hasSize(0)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, "%targ-A%",
setA.getId(), Boolean.FALSE, targTagW.getName())))
.as("and filter query returns the same result")
.hasSize(targetManagement.findTargetsAll(query, pageReq).getContent().size());
.hasSize(targetManagement.findTargetsAll(query, PAGE).getContent().size());
}
@@ -457,24 +457,24 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "(name==*targ-c* or description==*targ-C*) and tag==" + targTagW.getName()
+ " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")";
assertThat(targetManagement
.findTargetByFilters(pageReq, null, null, "%targ-C%", setA.getId(), Boolean.FALSE, targTagW.getName())
.findTargetByFilters(PAGE, null, null, "%targ-C%", setA.getId(), Boolean.FALSE, targTagW.getName())
.getContent()).as("has number of elements").hasSize(1)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, "%targ-C%",
setA.getId(), Boolean.FALSE, targTagW.getName())))
.as("and contains the following elements").containsExactly(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@Step
private void verifyThat1TargetHasNameAndId(final String name, final String controllerId) {
assertThat(targetManagement.findTargetByFilters(pageReq, null, null, name, null, Boolean.FALSE).getContent())
assertThat(targetManagement.findTargetByFilters(PAGE, null, null, name, null, Boolean.FALSE).getContent())
.as("has number of elements").hasSize(1).as("that number is also returned by count query").hasSize(Ints
.saturatedCast(targetManagement.countTargetByFilters(null, null, name, null, Boolean.FALSE)));
assertThat(targetManagement.findTargetByFilters(pageReq, null, null, controllerId, null, Boolean.FALSE)
assertThat(targetManagement.findTargetByFilters(PAGE, null, null, controllerId, null, Boolean.FALSE)
.getContent()).as("has number of elements").hasSize(1).as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(
targetManagement.countTargetByFilters(null, null, controllerId, null, Boolean.FALSE)));
@@ -485,14 +485,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final TargetTag targTagW, final List<Target> expected) {
final String query = "(name==*targ-B* or description==*targ-B*) and (tag==" + targTagY.getName() + " or tag=="
+ targTagW.getName() + ")";
assertThat(targetManagement.findTargetByFilters(pageReq, null, null, "%targ-B%", null, Boolean.FALSE,
assertThat(targetManagement.findTargetByFilters(PAGE, null, null, "%targ-B%", null, Boolean.FALSE,
targTagY.getName(), targTagW.getName()).getContent()).as("has number of elements").hasSize(100)
.as("that number is also returned by count query")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, "%targ-B%", null,
Boolean.FALSE, targTagY.getName(), targTagW.getName())))
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@@ -507,26 +507,26 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
private void verifyThat200TargetsHaveTagD(final TargetTag targTagD, final List<Target> expected) {
final String query = "tag==" + targTagD.getName();
assertThat(targetManagement
.findTargetByFilters(pageReq, null, null, null, null, Boolean.FALSE, targTagD.getName()).getContent())
.findTargetByFilters(PAGE, null, null, null, null, Boolean.FALSE, targTagD.getName()).getContent())
.as("Expected number of results is").hasSize(200)
.as("and is expected number of results is equal to ")
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, null, null,
Boolean.FALSE, targTagD.getName())))
.as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result")
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(query, PAGE).getContent());
}
@Step
private void verifyThatRepositoryContains400Targets() {
assertThat(
targetManagement.findTargetByFilters(pageReq, null, null, null, null, null, new String[0]).getContent())
targetManagement.findTargetByFilters(PAGE, null, null, null, null, null, new String[0]).getContent())
.as("Overall we expect that many targets in the repository").hasSize(400)
.as("which is also reflected by repository count")
.hasSize(Ints.saturatedCast(targetManagement.countTargetsAll()))
.as("which is also reflected by call without specification")
.containsAll(targetManagement.findTargetsAll(pageReq).getContent());
.containsAll(targetManagement.findTargetsAll(PAGE).getContent());
}
@@ -546,7 +546,7 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
.sendUpdateActionStatusToTargets(targInstalled, Status.FINISHED, Collections.singletonList("installed"))
.stream().map(Action::getTarget).collect(Collectors.toList());
final Slice<Target> result = targetManagement.findTargetsAllOrderByLinkedDistributionSet(pageReq, ds.getId(),
final Slice<Target> result = targetManagement.findTargetsAllOrderByLinkedDistributionSet(PAGE, ds.getId(),
new FilterParams(null, null, null, null, Boolean.FALSE, new String[0]));
final Comparator<TenantAwareBaseEntity> byId = (e1, e2) -> Long.compare(e2.getId(), e1.getId());
@@ -594,9 +594,9 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
targInstalled = assignDistributionSet(ds, targInstalled).getAssignedEntity();
targInstalled = testdataFactory
.sendUpdateActionStatusToTargets(targInstalled, Status.FINISHED, Collections.singletonList("installed"))
.stream().map(action -> action.getTarget()).collect(Collectors.toList());
.stream().map(Action::getTarget).collect(Collectors.toList());
final Slice<Target> result = targetManagement.findTargetsAllOrderByLinkedDistributionSet(pageReq, ds.getId(),
final Slice<Target> result = targetManagement.findTargetsAllOrderByLinkedDistributionSet(PAGE, ds.getId(),
new FilterParams(null, null, Boolean.TRUE, null, Boolean.FALSE, new String[0]));
final Comparator<TenantAwareBaseEntity> byId = (e1, e2) -> Long.compare(e2.getId(), e1.getId());
@@ -627,10 +627,10 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
assignDistributionSet(assignedSet, assignedtargets);
// get final updated version of targets
assignedtargets = targetManagement.findTargetByControllerID(
assignedtargets = targetManagement.findTargetsByControllerID(
assignedtargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()));
assertThat(targetManagement.findTargetByAssignedDistributionSet(assignedSet.getId(), pageReq))
assertThat(targetManagement.findTargetByAssignedDistributionSet(assignedSet.getId(), PAGE))
.as("Contains the assigned targets").containsAll(assignedtargets)
.as("and that means the following expected amount").hasSize(10);
@@ -648,7 +648,7 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
assignDistributionSet(assignedSet, assignedTargets);
final List<Target> result = targetManagement
.findAllTargetsByTargetFilterQueryAndNonDS(pageReq, assignedSet.getId(), tfq.getQuery()).getContent();
.findAllTargetsByTargetFilterQueryAndNonDS(PAGE, assignedSet.getId(), tfq.getQuery()).getContent();
assertThat(result).as("count of targets").hasSize(unassignedTargets.size()).as("contains all targets")
.containsAll(unassignedTargets);
@@ -668,10 +668,10 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
assignDistributionSet(assignedSet, installedtargets);
// get final updated version of targets
installedtargets = targetManagement.findTargetByControllerID(
installedtargets = targetManagement.findTargetsByControllerID(
installedtargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()));
assertThat(targetManagement.findTargetByInstalledDistributionSet(installedSet.getId(), pageReq))
assertThat(targetManagement.findTargetByInstalledDistributionSet(installedSet.getId(), PAGE))
.as("Contains the assigned targets").containsAll(installedtargets)
.as("and that means the following expected amount").hasSize(10);

View File

@@ -84,6 +84,10 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
verifyThrownExceptionBy(() -> targetManagement.assignTag(Lists.newArrayList(NOT_EXIST_ID), tag.getId()),
"Target");
verifyThrownExceptionBy(() -> targetManagement.findTargetsByTag(PAGE, NOT_EXIST_IDL), "TargetTag");
verifyThrownExceptionBy(() -> targetManagement.findTargetsByTag(PAGE, "name==*", NOT_EXIST_IDL),
"TargetTag");
verifyThrownExceptionBy(() -> targetManagement.countTargetByAssignedDistributionSet(NOT_EXIST_IDL),
"DistributionSet");
verifyThrownExceptionBy(() -> targetManagement.countTargetByInstalledDistributionSet(NOT_EXIST_IDL),
@@ -99,21 +103,21 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
verifyThrownExceptionBy(() -> targetManagement.deleteTargets(Lists.newArrayList(NOT_EXIST_IDL)), "Target");
verifyThrownExceptionBy(
() -> targetManagement.findAllTargetsByTargetFilterQueryAndNonDS(pageReq, NOT_EXIST_IDL, "name==*"),
() -> targetManagement.findAllTargetsByTargetFilterQueryAndNonDS(PAGE, NOT_EXIST_IDL, "name==*"),
"DistributionSet");
verifyThrownExceptionBy(
() -> targetManagement.findAllTargetsInRolloutGroupWithoutAction(pageReq, NOT_EXIST_IDL),
() -> targetManagement.findAllTargetsInRolloutGroupWithoutAction(PAGE, NOT_EXIST_IDL),
"RolloutGroup");
verifyThrownExceptionBy(() -> targetManagement.findTargetByAssignedDistributionSet(NOT_EXIST_IDL, pageReq),
verifyThrownExceptionBy(() -> targetManagement.findTargetByAssignedDistributionSet(NOT_EXIST_IDL, PAGE),
"DistributionSet");
verifyThrownExceptionBy(
() -> targetManagement.findTargetByAssignedDistributionSet(NOT_EXIST_IDL, "name==*", pageReq),
() -> targetManagement.findTargetByAssignedDistributionSet(NOT_EXIST_IDL, "name==*", PAGE),
"DistributionSet");
verifyThrownExceptionBy(() -> targetManagement.findTargetByInstalledDistributionSet(NOT_EXIST_IDL, pageReq),
verifyThrownExceptionBy(() -> targetManagement.findTargetByInstalledDistributionSet(NOT_EXIST_IDL, PAGE),
"DistributionSet");
verifyThrownExceptionBy(
() -> targetManagement.findTargetByInstalledDistributionSet(NOT_EXIST_IDL, "name==*", pageReq),
() -> targetManagement.findTargetByInstalledDistributionSet(NOT_EXIST_IDL, "name==*", PAGE),
"DistributionSet");
verifyThrownExceptionBy(
@@ -122,7 +126,6 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
verifyThrownExceptionBy(
() -> targetManagement.toggleTagAssignment(Lists.newArrayList(NOT_EXIST_ID), tag.getName()), "Target");
verifyThrownExceptionBy(() -> targetManagement.unAssignAllTargetsByTag(NOT_EXIST_IDL), "TargetTag");
verifyThrownExceptionBy(() -> targetManagement.unAssignTag(NOT_EXIST_ID, tag.getId()), "Target");
verifyThrownExceptionBy(() -> targetManagement.unAssignTag(target.getControllerId(), NOT_EXIST_IDL),
"TargetTag");
@@ -255,7 +258,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
@Description("Ensures that targets can assigned and unassigned to a target tag. Not exists target will be ignored for the assignment.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 4),
@Expect(type = TargetTagCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 8) })
@Expect(type = TargetUpdatedEvent.class, count = 5) })
public void assignAndUnassignTargetsToTag() {
final List<String> assignTarget = new ArrayList<>();
assignTarget.add(targetManagement.createTarget(entityFactory.target().create().controllerId("targetId123"))
@@ -272,26 +275,24 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
final List<Target> assignedTargets = targetManagement.assignTag(assignTarget, targetTag.getId());
assertThat(assignedTargets.size()).as("Assigned targets are wrong").isEqualTo(4);
assignedTargets.forEach(target -> assertThat(
tagManagement.findAllTargetTags(pageReq, target.getControllerId()).getNumberOfElements()).isEqualTo(1));
tagManagement.findAllTargetTags(PAGE, target.getControllerId()).getNumberOfElements()).isEqualTo(1));
TargetTag findTargetTag = tagManagement.findTargetTag("Tag1").get();
assertThat(assignedTargets.size()).as("Assigned targets are wrong")
.isEqualTo(findTargetTag.getAssignedToTargets().size());
.isEqualTo(targetManagement.findTargetsByTag(PAGE, targetTag.getId()).getNumberOfElements());
final Target unAssignTarget = targetManagement.unAssignTag("targetId123", findTargetTag.getId());
assertThat(unAssignTarget.getControllerId()).as("Controller id is wrong").isEqualTo("targetId123");
assertThat(tagManagement.findAllTargetTags(pageReq, unAssignTarget.getControllerId())).as("Tag size is wrong")
assertThat(tagManagement.findAllTargetTags(PAGE, unAssignTarget.getControllerId())).as("Tag size is wrong")
.isEmpty();
findTargetTag = tagManagement.findTargetTag("Tag1").get();
assertThat(findTargetTag.getAssignedToTargets()).as("Assigned targets are wrong").hasSize(3);
assertThat(targetManagement.findTargetsByTag(PAGE, targetTag.getId())).as("Assigned targets are wrong")
.hasSize(3);
assertThat(targetManagement.findTargetsByTag(PAGE, "controllerId==targetId123", targetTag.getId()))
.as("Assigned targets are wrong").isEmpty();
assertThat(targetManagement.findTargetsByTag(PAGE, "controllerId==targetId1234", targetTag.getId()))
.as("Assigned targets are wrong").hasSize(1);
final List<Target> unAssignTargets = targetManagement.unAssignAllTargetsByTag(findTargetTag.getId());
findTargetTag = tagManagement.findTargetTag("Tag1").get();
assertThat(findTargetTag.getAssignedToTargets()).as("Unassigned targets are wrong").isEmpty();
assertThat(unAssignTargets).as("Unassigned targets are wrong").hasSize(3);
unAssignTargets.forEach(target -> assertThat(
tagManagement.findAllTargetTags(pageReq, unAssignTarget.getControllerId()).getNumberOfElements())
.isEqualTo(0));
}
@Test
@@ -426,7 +427,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
_target: for (final Target tl : targets) {
final Target t = targetManagement.findTargetByControllerID(tl.getControllerId()).get();
for (final Tag tt : tagManagement.findAllTargetTags(pageReq, tl.getControllerId())) {
for (final Tag tt : tagManagement.findAllTargetTags(PAGE, tl.getControllerId())) {
for (final Tag tag : tags) {
if (tag.getName().equals(tt.getName())) {
continue _target;
@@ -445,7 +446,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
final Target t = targetManagement.findTargetByControllerID(tl.getControllerId()).get();
for (final Tag tag : tags) {
for (final Tag tt : tagManagement.findAllTargetTags(pageReq, tl.getControllerId())) {
for (final Tag tt : tagManagement.findAllTargetTags(PAGE, tl.getControllerId())) {
if (tag.getName().equals(tt.getName())) {
fail("Target should have no tags");
}
@@ -577,15 +578,15 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
t2Tags.forEach(tag -> targetManagement.assignTag(Lists.newArrayList(t2.getControllerId()), tag.getId()));
final Target t11 = targetManagement.findTargetByControllerID(t1.getControllerId()).get();
assertThat(tagManagement.findAllTargetTags(pageReq, t11.getControllerId()).getContent()).as("Tag size is wrong")
assertThat(tagManagement.findAllTargetTags(PAGE, t11.getControllerId()).getContent()).as("Tag size is wrong")
.hasSize(noT1Tags).containsAll(t1Tags);
assertThat(tagManagement.findAllTargetTags(pageReq, t11.getControllerId()).getContent()).as("Tag size is wrong")
assertThat(tagManagement.findAllTargetTags(PAGE, t11.getControllerId()).getContent()).as("Tag size is wrong")
.hasSize(noT1Tags).doesNotContain(Iterables.toArray(t2Tags, TargetTag.class));
final Target t21 = targetManagement.findTargetByControllerID(t2.getControllerId()).get();
assertThat(tagManagement.findAllTargetTags(pageReq, t21.getControllerId()).getContent()).as("Tag size is wrong")
assertThat(tagManagement.findAllTargetTags(PAGE, t21.getControllerId()).getContent()).as("Tag size is wrong")
.hasSize(noT2Tags).containsAll(t2Tags);
assertThat(tagManagement.findAllTargetTags(pageReq, t21.getControllerId()).getContent()).as("Tag size is wrong")
assertThat(tagManagement.findAllTargetTags(PAGE, t21.getControllerId()).getContent()).as("Tag size is wrong")
.hasSize(noT2Tags).doesNotContain(Iterables.toArray(t1Tags, TargetTag.class));
}
@@ -731,7 +732,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
final String[] tagNames = null;
final List<Target> targetsListWithNoTag = targetManagement
.findTargetByFilters(pageReq, null, null, null, null, Boolean.TRUE, tagNames).getContent();
.findTargetByFilters(PAGE, null, null, null, null, Boolean.TRUE, tagNames).getContent();
assertThat(50L).as("Total targets").isEqualTo(targetManagement.countTargetsAll());
assertThat(25).as("Targets with no tag").isEqualTo(targetsListWithNoTag.size());
@@ -766,7 +767,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
testdataFactory.createTargets(25, "target-id-B", "first description");
final Page<Target> foundTargets = targetManagement.findTargetsAll(rsqlFilter, pageReq);
final Page<Target> foundTargets = targetManagement.findTargetsAll(rsqlFilter, PAGE);
assertThat(targetManagement.countTargetsAll()).as("Total targets").isEqualTo(50L);
assertThat(foundTargets.getTotalElements()).as("Targets in RSQL filter").isEqualTo(27L);
@@ -782,7 +783,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
testdataFactory.createTarget("test" + i);
}
final List<Target> foundDs = targetManagement.findTargetAllById(searchIds);
final List<Target> foundDs = targetManagement.findTargetsById(searchIds);
assertThat(foundDs).hasSize(3);

View File

@@ -145,7 +145,7 @@ public class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
final int count) {
final List<Long> targetIds = targets.stream().map(Target::getId).collect(Collectors.toList());
final Slice<Target> targetsAll = targetManagement.findTargetsAll(pageReq);
final Slice<Target> targetsAll = targetManagement.findTargetsAll(PAGE);
assertThat(targetsAll).as("Count of targets").hasSize(count);
for (final Target target : targetsAll) {

View File

@@ -40,7 +40,9 @@ public class RSQLRolloutGroupFields extends AbstractJpaIntegrationTest {
final DistributionSet dsA = testdataFactory.createDistributionSet("");
rollout = createRollout("rollout1", 4, dsA.getId(), "controllerId==rollout*");
rollout = rolloutManagement.findRolloutById(rollout.getId()).get();
this.rolloutGroupId = rollout.getRolloutGroups().get(0).getId();
this.rolloutGroupId = rolloutGroupManagement.findRolloutGroupsByRolloutId(rollout.getId(), PAGE).getContent()
.get(0).getId();
}
@Test

View File

@@ -25,7 +25,6 @@ import org.eclipse.hawkbit.repository.test.util.TestdataFactory;
import org.junit.Before;
import org.junit.Test;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import ru.yandex.qatools.allure.annotations.Description;
import ru.yandex.qatools.allure.annotations.Features;
@@ -181,7 +180,7 @@ public class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
}
private void assertRSQLQuery(final String rsqlParam, final long expcetedTargets) {
final Page<Target> findTargetPage = targetManagement.findTargetsAll(rsqlParam, new PageRequest(0, 100));
final Page<Target> findTargetPage = targetManagement.findTargetsAll(rsqlParam, PAGE);
final long countTargetsAll = findTargetPage.getTotalElements();
assertThat(findTargetPage).isNotNull();
assertThat(countTargetsAll).isEqualTo(expcetedTargets);

View File

@@ -73,7 +73,7 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
createTargetForTenant(controllerAnotherTenant, anotherTenant);
// find all targets for current tenant "mytenant"
final Slice<Target> findTargetsAll = targetManagement.findTargetsAll(pageReq);
final Slice<Target> findTargetsAll = targetManagement.findTargetsAll(PAGE);
// no target has been created for "mytenant"
assertThat(findTargetsAll).hasSize(0);
@@ -92,11 +92,12 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
final String controllerAnotherTenant = "anotherController";
createTargetForTenant(controllerAnotherTenant, anotherTenant);
assertThat(systemManagement.findTenants()).as("Expected number if tenants before deletion is").hasSize(3);
assertThat(systemManagement.findTenants(PAGE)).as("Expected number if tenants before deletion is")
.hasSize(3);
systemManagement.deleteTenant(anotherTenant);
assertThat(systemManagement.findTenants()).as("Expected number if tenants after deletion is").hasSize(2);
assertThat(systemManagement.findTenants(PAGE)).as("Expected number if tenants after deletion is").hasSize(2);
}
@Test
@@ -106,9 +107,9 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
// logged in tenant mytenant - check if tenant default data is
// autogenerated
assertThat(distributionSetManagement.findDistributionSetTypesAll(pageReq)).isEmpty();
assertThat(distributionSetManagement.findDistributionSetTypesAll(PAGE)).isEmpty();
assertThat(systemManagement.getTenantMetadata().getTenant().toUpperCase()).isEqualTo("mytenant".toUpperCase());
assertThat(distributionSetManagement.findDistributionSetTypesAll(pageReq)).isNotEmpty();
assertThat(distributionSetManagement.findDistributionSetTypesAll(PAGE)).isNotEmpty();
// check that the cache is not getting in the way, i.e. "bumlux" results
// in bumlux and not
@@ -174,7 +175,7 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
private Slice<Target> findTargetsForTenant(final String tenant) throws Exception {
return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant),
() -> targetManagement.findTargetsAll(pageReq));
() -> targetManagement.findTargetsAll(PAGE));
}
private void deleteTargetsForTenant(final String tenant, final Collection<Long> targetIds) throws Exception {
@@ -191,7 +192,7 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
private Page<DistributionSet> findDistributionSetForTenant(final String tenant) throws Exception {
return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant),
() -> distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true));
() -> distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true));
}
}