Merge remote-tracking branch 'eclipse/master' into harmonize-test-documentation

This commit is contained in:
Kai Zimmermann
2016-03-03 20:59:15 +01:00
118 changed files with 1623 additions and 3490 deletions

View File

@@ -54,7 +54,7 @@ public class MethodSecurityUtil {
if (!METHOD_SECURITY_EXCLUSION.contains(method.getName()) && !method.isSynthetic()
&& Modifier.isPublic(method.getModifiers())) {
final PreAuthorize annotation = method.getAnnotation(PreAuthorize.class);
assertThat(annotation).describedAs(
assertThat(annotation).as(
"The public method " + method.getName() + " is not annoated with @PreAuthorize, security leak?")
.isNotNull();
}

View File

@@ -150,14 +150,14 @@ public class ArtifactManagementTest extends AbstractIntegrationTestWithMongoDB {
ExternalArtifact result = artifactManagement.createExternalArtifact(provider, null, sm.getId());
assertNotNull(result);
assertNotNull("The result of an external artifact should not be null", result);
assertThat(externalArtifactRepository.findAll()).contains(result).hasSize(1);
assertThat(result.getSoftwareModule().getId()).isEqualTo(sm.getId());
assertThat(result.getUrl()).isEqualTo("https://fhghdfjgh/{version}/");
assertThat(result.getExternalArtifactProvider()).isEqualTo(provider);
result = artifactManagement.createExternalArtifact(provider, "/test", sm2.getId());
assertNotNull(result);
assertNotNull("The newly created external artifact should not be null", result);
assertThat(externalArtifactRepository.findAll()).contains(result).hasSize(2);
assertThat(result.getUrl()).isEqualTo("https://fhghdfjgh/test");
assertThat(result.getExternalArtifactProvider()).isEqualTo(provider);
@@ -176,7 +176,7 @@ public class ArtifactManagementTest extends AbstractIntegrationTestWithMongoDB {
"https://fhghdfjgh", "/{version}/");
final ExternalArtifact result = artifactManagement.createExternalArtifact(provider, null, sm.getId());
assertNotNull(result);
assertNotNull("The newly created external artifact should not be null", result);
assertThat(externalArtifactRepository.findAll()).contains(result).hasSize(1);
artifactManagement.deleteExternalArtifact(result.getId());
@@ -348,7 +348,7 @@ public class ArtifactManagementTest extends AbstractIntegrationTestWithMongoDB {
final LocalArtifact result = artifactManagement.createLocalArtifact(new ByteArrayInputStream(random),
sm.getId(), "file1", false);
assertTrue(IOUtils.contentEquals(new ByteArrayInputStream(random),
assertTrue("The stored binary matches the given binary", IOUtils.contentEquals(new ByteArrayInputStream(random),
artifactManagement.loadLocalArtifactBinary(result).getFileInputStream()));
}

View File

@@ -19,7 +19,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import org.eclipse.hawkbit.AbstractIntegrationTest;
import org.eclipse.hawkbit.Constants;
@@ -98,8 +97,9 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
final List<ActionWithStatusCount> findActionsWithStatusCountByTarget = deploymentManagement
.findActionsWithStatusCountByTargetOrderByIdDesc(testTarget.get(0));
assertThat(findActionsWithStatusCountByTarget).hasSize(1);
assertThat(findActionsWithStatusCountByTarget.get(0).getActionStatusCount()).isEqualTo(3L);
assertThat(findActionsWithStatusCountByTarget).as("wrong action size").hasSize(1);
assertThat(findActionsWithStatusCountByTarget.get(0).getActionStatusCount()).as("wrong action status size")
.isEqualTo(3L);
}
@Test
@@ -115,27 +115,32 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
final DistributionSetTag tag = tagManagement.createDistributionSetTag(new DistributionSetTag("Tag1"));
final List<DistributionSet> assignedDS = distributionSetManagement.assignTag(assignDS, tag);
assertThat(assignedDS.size()).isEqualTo(4);
assignedDS.forEach(ds -> assertThat(ds.getTags().size()).isEqualTo(1));
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));
DistributionSetTag findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1");
assertThat(assignedDS.size()).isEqualTo(findDistributionSetTag.getAssignedToDistributionSet().size());
assertThat(assignedDS.size()).as("assigned ds has wrong size")
.isEqualTo(findDistributionSetTag.getAssignedToDistributionSet().size());
assertThat(distributionSetManagement.unAssignTag(Long.valueOf(100), findDistributionSetTag)).isNull();
assertThat(distributionSetManagement.unAssignTag(Long.valueOf(100), findDistributionSetTag))
.as("unassign tag result should be null").isNull();
final DistributionSet unAssignDS = distributionSetManagement.unAssignTag(assignDS.get(0),
findDistributionSetTag);
assertThat(unAssignDS.getId()).isEqualTo(assignDS.get(0));
assertThat(unAssignDS.getTags().size()).isEqualTo(0);
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");
assertThat(findDistributionSetTag.getAssignedToDistributionSet().size()).isEqualTo(3);
assertThat(findDistributionSetTag.getAssignedToDistributionSet().size()).as("ds tag ds has wrong ds size")
.isEqualTo(3);
final List<DistributionSet> unAssignTargets = distributionSetManagement
.unAssignAllDistributionSetsByTag(findDistributionSetTag);
findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1");
assertThat(findDistributionSetTag.getAssignedToDistributionSet().size()).isEqualTo(0);
assertThat(unAssignTargets.size()).isEqualTo(3);
unAssignTargets.forEach(target -> assertThat(target.getTags().size()).isEqualTo(0));
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));
}
@Test
@@ -156,7 +161,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
targetManagement.findAllTargetIds().forEach(targetIdName -> {
assertThat(deploymentManagement.findActiveActionsByTarget(
targetManagement.findTargetByControllerID(targetIdName.getControllerId()))).hasSize(2);
targetManagement.findTargetByControllerID(targetIdName.getControllerId())))
.as("active action has wrong size").hasSize(2);
});
}
@@ -179,14 +185,14 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
// check initial status
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.UNKNOWN);
.as("target has update status").isEqualTo(TargetUpdateStatus.UNKNOWN);
// assign the two sets in a row
Action firstAction = assignSet(target, dsFirst);
Action secondAction = assignSet(target, dsSecond);
assertThat(actionRepository.findAll()).hasSize(2);
assertThat(actionStatusRepository.findAll()).hasSize(2);
assertThat(actionRepository.findAll()).as("wrong size of actions").hasSize(2);
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(2);
// we cancel second -> back to first
deploymentManagement.cancelAction(secondAction,
@@ -196,10 +202,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
secondAction.setStatus(Status.CANCELED);
controllerManagement.addCancelActionStatus(
new ActionStatus(secondAction, Status.CANCELED, System.currentTimeMillis()), secondAction);
assertThat(actionStatusRepository.findAll()).hasSize(4);
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsFirst);
assertThat(actionStatusRepository.findAll()).as("wrong size of actions status").hasSize(4);
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).as("wrong ds")
.isEqualTo(dsFirst);
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.PENDING);
.as("wrong update status").isEqualTo(TargetUpdateStatus.PENDING);
// we cancel first -> back to installed
deploymentManagement.cancelAction(firstAction,
@@ -209,11 +216,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
firstAction.setStatus(Status.CANCELED);
controllerManagement.addCancelActionStatus(
new ActionStatus(firstAction, Status.CANCELED, System.currentTimeMillis()), firstAction);
assertThat(actionStatusRepository.findAll()).hasSize(6);
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(6);
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet())
.isEqualTo(dsInstalled);
.as("wrong assigned ds").isEqualTo(dsInstalled);
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.IN_SYNC);
.as("wrong update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
}
@Test
@@ -235,14 +242,14 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
// check initial status
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.UNKNOWN);
.as("wrong update status").isEqualTo(TargetUpdateStatus.UNKNOWN);
// assign the two sets in a row
Action firstAction = assignSet(target, dsFirst);
Action secondAction = assignSet(target, dsSecond);
assertThat(actionRepository.findAll()).hasSize(2);
assertThat(actionStatusRepository.findAll()).hasSize(2);
assertThat(actionRepository.findAll()).as("wrong size of actions").hasSize(2);
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(2);
// we cancel first -> second is left
deploymentManagement.cancelAction(firstAction,
@@ -252,26 +259,28 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
firstAction.setStatus(Status.CANCELED);
controllerManagement.addCancelActionStatus(
new ActionStatus(firstAction, Status.CANCELED, System.currentTimeMillis()), firstAction);
assertThat(actionStatusRepository.findAll()).hasSize(4);
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsSecond);
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(4);
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet())
.as("wrong assigned ds").isEqualTo(dsSecond);
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.PENDING);
.as("wrong target update status").isEqualTo(TargetUpdateStatus.PENDING);
// we cancel second -> remain assigned until finished cancellation
deploymentManagement.cancelAction(secondAction,
targetManagement.findTargetByControllerID(target.getControllerId()));
secondAction = deploymentManagement.findActionWithDetails(secondAction.getId());
assertThat(actionStatusRepository.findAll()).hasSize(5);
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsSecond);
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(5);
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet())
.as("wrong assigned ds").isEqualTo(dsSecond);
// confirm cancellation
secondAction.setStatus(Status.CANCELED);
controllerManagement.addCancelActionStatus(
new ActionStatus(secondAction, Status.CANCELED, System.currentTimeMillis()), secondAction);
// cancelled success -> back to dsInstalled
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet())
.isEqualTo(dsInstalled);
.as("wrong installed ds").isEqualTo(dsInstalled);
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.IN_SYNC);
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
}
@Test
@@ -290,13 +299,13 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
// verify initial status
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.UNKNOWN);
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.UNKNOWN);
Action assigningAction = assignSet(target, ds);
// verify assignment
assertThat(actionRepository.findAll()).hasSize(1);
assertThat(actionStatusRepository.findAll()).hasSize(1);
assertThat(actionRepository.findAll()).as("wrong size of action").hasSize(1);
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(1);
target = targetManagement.findTargetByControllerID(target.getControllerId());
@@ -309,11 +318,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId());
// verify
assertThat(assigningAction.getStatus()).isEqualTo(Status.CANCELED);
assertThat(assigningAction.getStatus()).as("wrong size of status").isEqualTo(Status.CANCELED);
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet())
.isEqualTo(dsInstalled);
.as("wrong assigned ds").isEqualTo(dsInstalled);
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.IN_SYNC);
.as("wrong target update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
}
@Test
@@ -332,13 +341,13 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
// verify initial status
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.UNKNOWN);
.as("wrong update status").isEqualTo(TargetUpdateStatus.UNKNOWN);
final Action assigningAction = assignSet(target, ds);
// verify assignment
assertThat(actionRepository.findAll()).hasSize(1);
assertThat(actionStatusRepository.findAll()).hasSize(1);
assertThat(actionRepository.findAll()).as("wrong size of action").hasSize(1);
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(1);
// force quit assignment
try {
@@ -353,11 +362,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
deploymentManagement.assignDistributionSet(ds.getId(), new String[] { target.getControllerId() });
assertThat(
targetManagement.findTargetByControllerID(target.getControllerId()).getTargetInfo().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.PENDING);
.as("wrong update status").isEqualTo(TargetUpdateStatus.PENDING);
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getAssignedDistributionSet())
.isEqualTo(ds);
.as("wrong assigned ds").isEqualTo(ds);
final Action action = actionRepository.findByTargetAndDistributionSet(pageReq, target, ds).getContent().get(0);
assertThat(action).isNotNull();
assertThat(action).as("action should not be null").isNotNull();
return action;
}
@@ -389,26 +398,30 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
deploymentManagement.assignDistributionSet(ds, savedDeployedTargets);
// verify that one Action for each assignDistributionSet
assertThat(actionRepository.findAll(pageReq).getNumberOfElements()).isEqualTo(20);
assertThat(actionRepository.findAll(pageReq).getNumberOfElements()).as("wrong size of actions").isEqualTo(20);
final Iterable<Target> allFoundTargets = targetManagement.findTargetsAll(pageReq).getContent();
assertThat(allFoundTargets).containsAll(savedDeployedTargets).containsAll(savedNakedTargets);
assertThat(savedDeployedTargets).doesNotContain(Iterables.toArray(savedNakedTargets, Target.class));
assertThat(savedNakedTargets).doesNotContain(Iterables.toArray(savedDeployedTargets, Target.class));
assertThat(allFoundTargets).as("founded targets are wrong").containsAll(savedDeployedTargets)
.containsAll(savedNakedTargets);
assertThat(savedDeployedTargets).as("saved target are wrong")
.doesNotContain(Iterables.toArray(savedNakedTargets, Target.class));
assertThat(savedNakedTargets).as("saved target are wrong")
.doesNotContain(Iterables.toArray(savedDeployedTargets, Target.class));
for (final Target myt : savedNakedTargets) {
final Target t = targetManagement.findTargetByControllerID(myt.getControllerId());
assertThat(deploymentManagement.findActionsByTarget(t)).isEmpty();
assertThat(deploymentManagement.findActionsByTarget(t)).as("action should be empty").isEmpty();
}
for (final Target myt : savedDeployedTargets) {
final Target t = targetManagement.findTargetByControllerID(myt.getControllerId());
final List<Action> activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(t);
assertThat(activeActionsByTarget).isNotEmpty();
assertThat(t.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
assertThat(activeActionsByTarget).as("action should not be empty").isNotEmpty();
assertThat(t.getTargetInfo().getUpdateStatus()).as("wrong target update status")
.isEqualTo(TargetUpdateStatus.PENDING);
for (final Action ua : activeActionsByTarget) {
assertThat(ua.getDistributionSet()).isEqualTo(ds);
assertThat(ua.getDistributionSet()).as("action has wrong ds").isEqualTo(ds);
}
}
@@ -447,12 +460,13 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
// give some chance to receive events asynchronously
Thread.sleep(300);
final List<TargetAssignDistributionSetEvent> events = eventHandlerMock.getEvents(1, TimeUnit.MILLISECONDS);
assertThat(events).isEmpty();
assertThat(events).as("events should be empty").isEmpty();
final EventHandlerMock eventHandlerMockAfterCompletionOfDs = new EventHandlerMock(10);
eventBus.register(eventHandlerMockAfterCompletionOfDs);
assertThat(deploymentManagement.assignDistributionSet(nowComplete, targets).getAssigned()).isEqualTo(10);
assertThat(deploymentManagement.assignDistributionSet(nowComplete, targets).getAssigned())
.as("assign ds doesn't work").isEqualTo(10);
assertTargetAssignDistributionSetEvents(targets, nowComplete,
eventHandlerMockAfterCompletionOfDs.getEvents(10, TimeUnit.SECONDS));
}
@@ -492,7 +506,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
// retrieving all Actions created by the assignDistributionSet call
final Page<Action> page = actionRepository.findAll(pageReq);
// and verify the number
assertThat(page.getTotalElements()).isEqualTo(noOfDeployedTargets * noOfDistributionSets);
assertThat(page.getTotalElements()).as("wrong size of actions")
.isEqualTo(noOfDeployedTargets * noOfDistributionSets);
// only records retrieved from the DB can be evaluated to be sure that
// all fields are
@@ -503,17 +518,20 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
final Iterable<Target> undeployedTargetsFromDB = targetRepository.findAll(undeployedTargetIDs);
// test that number of Targets
assertThat(allFoundTargets.spliterator().getExactSizeIfKnown())
assertThat(allFoundTargets.spliterator().getExactSizeIfKnown()).as("number of target is wrong")
.isEqualTo(deployedTargetsFromDB.spliterator().getExactSizeIfKnown()
+ undeployedTargetsFromDB.spliterator().getExactSizeIfKnown());
assertThat(deployedTargetsFromDB.spliterator().getExactSizeIfKnown()).isEqualTo(noOfDeployedTargets);
assertThat(undeployedTargetsFromDB.spliterator().getExactSizeIfKnown()).isEqualTo(noOfUndeployedTargets);
assertThat(deployedTargetsFromDB.spliterator().getExactSizeIfKnown()).as("number of target is wrong")
.isEqualTo(noOfDeployedTargets);
assertThat(undeployedTargetsFromDB.spliterator().getExactSizeIfKnown()).as("number of target is wrong")
.isEqualTo(noOfUndeployedTargets);
// test the content of different lists
assertThat(allFoundTargets).containsAll(deployedTargetsFromDB).containsAll(undeployedTargetsFromDB);
assertThat(deployedTargetsFromDB).containsAll(savedDeployedTargets)
assertThat(allFoundTargets).as("content of founded target is wrong").containsAll(deployedTargetsFromDB)
.containsAll(undeployedTargetsFromDB);
assertThat(deployedTargetsFromDB).as("content of deployed target is wrong").containsAll(savedDeployedTargets)
.doesNotContain(Iterables.toArray(undeployedTargetsFromDB, Target.class));
assertThat(undeployedTargetsFromDB).containsAll(savedNakedTargets)
assertThat(undeployedTargetsFromDB).as("content of undeployed target is wrong").containsAll(savedNakedTargets)
.doesNotContain(Iterables.toArray(deployedTargetsFromDB, Target.class));
// For each of the 4 targets 1 distribution sets gets assigned
@@ -541,42 +559,42 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
final DistributionSet dsC = deployResWithDsC.getDistributionSets().get(0);
// retrieving the UpdateActions created by the assignments
final Action updActA = actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(0);
final Action updActB = actionRepository.findByDistributionSet(pageRequest, dsB).getContent().get(0);
final Action updActC = actionRepository.findByDistributionSet(pageRequest, dsC).getContent().get(0);
actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(0);
actionRepository.findByDistributionSet(pageRequest, dsB).getContent().get(0);
actionRepository.findByDistributionSet(pageRequest, dsC).getContent().get(0);
// verifying the correctness of the assignments
for (final Target t : deployResWithDsA.getDeployedTargets()) {
assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsA.getId());
assertThat(t.getAssignedDistributionSet().getId()).as("assignment is not correct").isEqualTo(dsA.getId());
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
.getInstalledDistributionSet()).isNull();
.getInstalledDistributionSet()).as("installed ds should be null").isNull();
}
for (final Target t : deployResWithDsB.getDeployedTargets()) {
assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsB.getId());
assertThat(t.getAssignedDistributionSet().getId()).as("assigned ds is wrong").isEqualTo(dsB.getId());
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
.getInstalledDistributionSet()).isNull();
.getInstalledDistributionSet()).as("installed ds should be null").isNull();
}
for (final Target t : deployResWithDsC.getDeployedTargets()) {
assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsC.getId());
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
.getInstalledDistributionSet()).isNull();
.getInstalledDistributionSet()).as("installed ds should not be null").isNull();
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.PENDING);
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.PENDING);
}
final List<Target> updatedTsDsA = sendUpdateActionStatusToTargets(dsA, deployResWithDsA.getDeployedTargets(),
Status.FINISHED, new String[] { "alles gut" });
// verify, that dsA is deployed correctly
assertThat(updatedTsDsA).isEqualTo(deployResWithDsA.getDeployedTargets());
assertThat(updatedTsDsA).as("ds is not deployed correctly").isEqualTo(deployResWithDsA.getDeployedTargets());
for (final Target t_ : updatedTsDsA) {
final Target t = targetManagement.findTargetByControllerID(t_.getControllerId());
assertThat(t.getAssignedDistributionSet()).isEqualTo(dsA);
assertThat(t.getAssignedDistributionSet()).as("assigned ds is wrong").isEqualTo(dsA);
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
.getInstalledDistributionSet()).isEqualTo(dsA);
.getInstalledDistributionSet()).as("installed ds is wrong").isEqualTo(dsA);
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.IN_SYNC);
assertThat(deploymentManagement.findActiveActionsByTarget(t)).hasSize(0);
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
assertThat(deploymentManagement.findActiveActionsByTarget(t)).as("no actions should be active").hasSize(0);
}
// deploy dsA to the target which already have dsB deployed -> must
@@ -585,18 +603,18 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
// UpdateAction for dsA
final Iterable<Target> deployed2DS = deploymentManagement
.assignDistributionSet(dsA, deployResWithDsB.getDeployedTargets()).getAssignedTargets();
final Action updActA2 = actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(1);
actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(1);
assertThat(deployed2DS).containsAll(deployResWithDsB.getDeployedTargets());
assertThat(deployed2DS).hasSameSizeAs(deployResWithDsB.getDeployedTargets());
assertThat(deployed2DS).as("deployed ds is wrong").containsAll(deployResWithDsB.getDeployedTargets());
assertThat(deployed2DS).as("deployed ds is wrong").hasSameSizeAs(deployResWithDsB.getDeployedTargets());
for (final Target t_ : deployed2DS) {
final Target t = targetManagement.findTargetByControllerID(t_.getControllerId());
assertThat(t.getAssignedDistributionSet()).isEqualTo(dsA);
assertThat(t.getAssignedDistributionSet()).as("assigned ds is wrong").isEqualTo(dsA);
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo()
.getInstalledDistributionSet()).isNull();
.getInstalledDistributionSet()).as("installed ds should be null").isNull();
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.PENDING);
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.PENDING);
}
}
@@ -629,22 +647,22 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
distributionSetManagement.deleteDistributionSet(dsA.getId());
dsA = distributionSetManagement.findDistributionSetById(dsA.getId());
assertThat(dsA).isNull();
assertThat(dsA).as("ds should be null").isNull();
// // verify that the ds is not physically deleted
for (final DistributionSet ds : deploymentResult.getDistributionSets()) {
distributionSetManagement.deleteDistributionSet(ds.getId());
final DistributionSet foundDS = distributionSetManagement.findDistributionSetById(ds.getId());
assertThat(foundDS).isNotNull();
assertThat(foundDS.isDeleted()).isTrue();
assertThat(foundDS).as("founded should not be null").isNotNull();
assertThat(foundDS.isDeleted()).as("founded ds should be deleted").isTrue();
}
// verify that deleted attribute is used correctly
List<DistributionSet> allFoundDS = distributionSetManagement.findDistributionSetsAll(pageReq, false, true)
.getContent();
assertThat(allFoundDS.size()).isEqualTo(0);
assertThat(allFoundDS.size()).as("no ds should be founded").isEqualTo(0);
allFoundDS = distributionSetManagement.findDistributionSetsAll(pageRequest, true, true).getContent();
assertThat(allFoundDS).hasSize(noOfDistributionSets);
assertThat(allFoundDS).as("wrong size of founded ds").hasSize(noOfDistributionSets);
for (final DistributionSet ds : deploymentResult.getDistributionSets()) {
sendUpdateActionStatusToTargets(ds, deploymentResult.getDeployedTargets(), Status.FINISHED,
@@ -658,9 +676,9 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
// successfully and no activeAction is referring to created distribution
// sets
allFoundDS = distributionSetManagement.findDistributionSetsAll(pageRequest, false, true).getContent();
assertThat(allFoundDS.size()).isEqualTo(0);
assertThat(allFoundDS.size()).as("no ds should be founded").isEqualTo(0);
allFoundDS = distributionSetManagement.findDistributionSetsAll(pageRequest, true, true).getContent();
assertThat(allFoundDS).hasSize(noOfDistributionSets);
assertThat(allFoundDS).as("size of founded ds is wrong").hasSize(noOfDistributionSets);
}
@@ -684,15 +702,15 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
"blabla alles gut");
}
assertThat(targetManagement.countTargetsAll()).isNotZero();
assertThat(actionStatusRepository.count()).isNotZero();
assertThat(targetManagement.countTargetsAll()).as("size of targets is wrong").isNotZero();
assertThat(actionStatusRepository.count()).as("size of action status is wrong").isNotZero();
targetManagement
.deleteTargets(deploymentResult.getUndeployedTargetIDs().toArray(new Long[noOfUndeployedTargets]));
targetManagement.deleteTargets(deploymentResult.getDeployedTargetIDs().toArray(new Long[noOfDeployedTargets]));
assertThat(targetManagement.countTargetsAll()).isZero();
assertThat(actionStatusRepository.count()).isZero();
assertThat(targetManagement.countTargetsAll()).as("size of targets should be zero").isZero();
assertThat(actionStatusRepository.count()).as("size of action status is wrong").isZero();
}
private List<Target> sendUpdateActionStatusToTargets(final DistributionSet dsA, final Iterable<Target> targs,
@@ -743,16 +761,17 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
// checking the revisions of the created entities
// verifying that the revision of the object and the revision within the
// DB has not changed
assertThat(dsA.getOptLockRevision()).isEqualTo(
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong").isEqualTo(
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).getOptLockRevision());
// verifying that the assignment is correct
assertEquals(1, deploymentManagement.findActiveActionsByTarget(targ).size());
assertEquals(1, deploymentManagement.findActionsByTarget(targ).size());
assertEquals(TargetUpdateStatus.PENDING, targ.getTargetInfo().getUpdateStatus());
assertEquals(dsA, targ.getAssignedDistributionSet());
assertEquals(dsA, deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet());
assertNull(targ.getTargetInfo().getInstalledDistributionSet());
assertEquals("Active target actions are wrong", 1, deploymentManagement.findActiveActionsByTarget(targ).size());
assertEquals("Target actions are wrong", 1, deploymentManagement.findActionsByTarget(targ).size());
assertEquals("Target status is wrong", TargetUpdateStatus.PENDING, targ.getTargetInfo().getUpdateStatus());
assertEquals("Assigned ds is wrong", dsA, targ.getAssignedDistributionSet());
assertEquals("Active ds is wrong", dsA,
deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet());
assertNull("Installed ds should be null", targ.getTargetInfo().getInstalledDistributionSet());
final Page<Action> updAct = actionRepository.findByDistributionSet(pageReq, dsA);
final Action action = updAct.getContent().get(0);
@@ -763,12 +782,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
targ = targetManagement.findTargetByControllerID(targ.getControllerId());
assertEquals(0, deploymentManagement.findActiveActionsByTarget(targ).size());
// try {
assertEquals(1, deploymentManagement.findInActiveActionsByTarget(targ).size());
// }
// catch( final LazyInitializationException ex ) {
//
// }
assertEquals(TargetUpdateStatus.IN_SYNC, targ.getTargetInfo().getUpdateStatus());
assertEquals(dsA, targ.getAssignedDistributionSet());
assertEquals(dsA, targ.getTargetInfo().getInstalledDistributionSet());
@@ -778,13 +793,15 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
targ = targs.iterator().next();
assertEquals(1, deploymentManagement.findActiveActionsByTarget(targ).size());
assertEquals(TargetUpdateStatus.PENDING,
assertEquals("active actions are wrong", 1, deploymentManagement.findActiveActionsByTarget(targ).size());
assertEquals("target status is wrong", TargetUpdateStatus.PENDING,
targetManagement.findTargetByControllerID(targ.getControllerId()).getTargetInfo().getUpdateStatus());
assertEquals(dsB, targ.getAssignedDistributionSet());
assertEquals(dsA.getId(), targetManagement.findTargetByControllerIDWithDetails(targ.getControllerId())
.getTargetInfo().getInstalledDistributionSet().getId());
assertEquals(dsB, deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet());
assertEquals("Installed ds is wrong", dsA.getId(),
targetManagement.findTargetByControllerIDWithDetails(targ.getControllerId()).getTargetInfo()
.getInstalledDistributionSet().getId());
assertEquals("Active ds is wrong", dsB,
deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet());
}
@@ -794,12 +811,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
public void checkThatDsRevisionsIsNotChangedWithTargetAssignment() {
final DistributionSet dsA = TestDataUtil.generateDistributionSet("a", softwareManagement,
distributionSetManagement);
final DistributionSet dsB = TestDataUtil.generateDistributionSet("b", softwareManagement,
distributionSetManagement);
TestDataUtil.generateDistributionSet("b", softwareManagement, distributionSetManagement);
Target targ = targetManagement
.createTarget(TestDataUtil.buildTargetFixture("target-id-A", "first description"));
assertThat(dsA.getOptLockRevision()).isEqualTo(
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong").isEqualTo(
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).getOptLockRevision());
final List<Target> targs = new ArrayList<Target>();
@@ -807,7 +823,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
final Iterable<Target> savedTargs = deploymentManagement.assignDistributionSet(dsA, targs).getAssignedTargets();
targ = savedTargs.iterator().next();
assertThat(dsA.getOptLockRevision()).isEqualTo(
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong").isEqualTo(
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).getOptLockRevision());
}
@@ -824,14 +840,14 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0));
// verify preparation
Action findAction = deploymentManagement.findAction(action.getId());
assertThat(findAction.getActionType()).isEqualTo(ActionType.SOFT);
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.SOFT);
// test
deploymentManagement.forceTargetAction(action.getId());
// verify test
findAction = deploymentManagement.findAction(action.getId());
assertThat(findAction.getActionType()).isEqualTo(ActionType.FORCED);
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED);
}
@Test
@@ -847,15 +863,15 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0));
// verify perparation
Action findAction = deploymentManagement.findAction(action.getId());
assertThat(findAction.getActionType()).isEqualTo(ActionType.FORCED);
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED);
// test
final Action forceTargetAction = deploymentManagement.forceTargetAction(action.getId());
// verify test
assertThat(forceTargetAction.getActionType()).isEqualTo(ActionType.FORCED);
assertThat(forceTargetAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED);
findAction = deploymentManagement.findAction(action.getId());
assertThat(findAction.getActionType()).isEqualTo(ActionType.FORCED);
assertThat(findAction.getActionType()).as("action type is wrong").isEqualTo(ActionType.FORCED);
}
/**
@@ -917,14 +933,14 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
if (event.getControllerId().equals(myt.getControllerId())) {
found = true;
final List<Action> activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(myt);
assertThat(activeActionsByTarget).isNotEmpty();
assertThat(event.getActionId()).isEqualTo(activeActionsByTarget.get(0).getId())
.as("Action id in database and event do not match");
assertThat(event.getSoftwareModules())
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());
assertThat(event.getSoftwareModules()).as("softwaremodule size is not correct")
.containsOnly(ds.getModules().toArray(new SoftwareModule[ds.getModules().size()]));
}
}
assertThat(found).isTrue().as("No event found for controller " + myt.getControllerId());
assertThat(found).as("No event found for controller " + myt.getControllerId()).isTrue();
}
}
@@ -943,42 +959,19 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
private final List<Target> deployedTargets = new ArrayList<Target>();
private final List<DistributionSet> distributionSets = new ArrayList<DistributionSet>();
private final String undeployedTargetPrefix;
private final String deployedTargetPrefix;
private final String distributionSetPrefix;
public DeploymentResult(final Iterable<Target> deployedTs, final Iterable<Target> undeployedTs,
final Iterable<DistributionSet> dss, final String deployedTargetPrefix,
final String undeployedTargetPrefix, final String distributionSetPrefix) {
this.undeployedTargetPrefix = undeployedTargetPrefix;
this.deployedTargetPrefix = deployedTargetPrefix;
this.distributionSetPrefix = distributionSetPrefix;
Iterables.addAll(deployedTargets, deployedTs);
Iterables.addAll(undeployedTargets, undeployedTs);
Iterables.addAll(distributionSets, dss);
deployedTargets.forEach(new Consumer<Target>() {
@Override
public void accept(final Target t) {
deployedTargetIDs.add(t.getId());
}
});
deployedTargets.forEach(t -> deployedTargetIDs.add(t.getId()));
undeployedTargets.forEach(new Consumer<Target>() {
@Override
public void accept(final Target t) {
undeployedTargetIDs.add(t.getId());
}
});
undeployedTargets.forEach(t -> undeployedTargetIDs.add(t.getId()));
distributionSets.forEach(new Consumer<DistributionSet>() {
@Override
public void accept(final DistributionSet ds) {
distributionSetIDs.add(ds.getId());
}
});
distributionSets.forEach(ds -> distributionSetIDs.add(ds.getId()));
}
@@ -1017,27 +1010,6 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
return deployedTargets;
}
/**
* @return the noOfUndeployedTargets
*/
public int getNoOfUndeployedTargets() {
return undeployedTargetIDs.size();
}
/**
* @return the noOfDeployedTargets
*/
public int getNoOfDeployedTargets() {
return deployedTargetIDs.size();
}
/**
* @return the noOfDistributionSets
*/
public int getNoOfDistributionSets() {
return distributionSets.size();
}
/**
* @return the undeployedTargetIDs
*/
@@ -1045,26 +1017,6 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
return undeployedTargetIDs;
}
/**
* @return the undeployedTargetPrefix
*/
public String getUndeployedTargetPrefix() {
return undeployedTargetPrefix;
}
/**
* @return the deployedTargetPrefix
*/
public String getDeployedTargetPrefix() {
return deployedTargetPrefix;
}
/**
* @return the distributionSetPrefix
*/
public String getDistributionSetPrefix() {
return distributionSetPrefix;
}
}
private static class EventHandlerMock {
@@ -1089,9 +1041,9 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
latch.await(timeout, unit);
final List<TargetAssignDistributionSetEvent> handledEvents = new LinkedList<TargetAssignDistributionSetEvent>(
events);
assertThat(handledEvents).hasSize(expectedNumberOfEvents)
.as("Did not receive the expected amount of events (" + expectedNumberOfEvents
+ ") within timeout. Received events are " + handledEvents);
assertThat(handledEvents).as("Did not receive the expected amount of events (" + expectedNumberOfEvents
+ ") within timeout. Received events are " + handledEvents).hasSize(expectedNumberOfEvents);
return handledEvents;
}
}
@@ -1117,9 +1069,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
throws InterruptedException {
latch.await(timeout, unit);
final List<CancelTargetAssignmentEvent> handledEvents = new LinkedList<CancelTargetAssignmentEvent>(events);
assertThat(handledEvents).hasSize(expectedNumberOfEvents)
.as("Did not receive the expected amount of events (" + expectedNumberOfEvents
+ ") within timeout. Received events are " + handledEvents);
assertThat(handledEvents).as("Did not receive the expected amount of events (" + expectedNumberOfEvents
+ ") within timeout. Received events are " + handledEvents).hasSize(expectedNumberOfEvents);
return handledEvents;
}
}

View File

@@ -18,7 +18,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.AbstractIntegrationTest;
@@ -96,7 +95,8 @@ public class ReportManagementTest extends AbstractIntegrationTest {
// +1 because we go back #maxMonthBackAmountReportTargets but in the
// report the current month
// is included for sure, so from this month we go back
assertThat(targetsCreatedOverPeriod.getData()).hasSize(maxMonthBackAmountReportTargets + 1);
assertThat(targetsCreatedOverPeriod.getData()).as("created over period has wrong size")
.hasSize(maxMonthBackAmountReportTargets + 1);
for (final DataReportSeriesItem<LocalDate> reportItem : targetsCreatedOverPeriod.getData()) {
// only one target is created for each month
assertThat(reportItem.getData().intValue()).as("Target for each month").isEqualTo(1);
@@ -147,10 +147,11 @@ public class ReportManagementTest extends AbstractIntegrationTest {
// +1 because we go back #maxMonthBackAmountReportTargets but in the
// report the current month
// is included for sure, so from this month we go back
assertThat(feedbackReceivedOverTime.getData()).hasSize(maxMonthBackAmountReportTargets + 1);
assertThat(feedbackReceivedOverTime.getData()).as("feedback receiver has wrong data size")
.hasSize(maxMonthBackAmountReportTargets + 1);
for (final DataReportSeriesItem<LocalDate> reportItem : feedbackReceivedOverTime.getData()) {
// only one target feedback is created for each month
assertThat(reportItem.getData().intValue()).isEqualTo(1);
assertThat(reportItem.getData().intValue()).as("data size is wrong").isEqualTo(1);
}
// check cache evict
@@ -165,7 +166,7 @@ public class ReportManagementTest extends AbstractIntegrationTest {
}
feedbackReceivedOverTime = reportManagement.feedbackReceivedOverTime(DateTypes.perMonth(), from, to);
for (final DataReportSeriesItem<LocalDate> reportItem : feedbackReceivedOverTime.getData()) {
assertThat(reportItem.getData().intValue()).isEqualTo(2);
assertThat(reportItem.getData().intValue()).as("report item has wrong data size").isEqualTo(2);
}
}
@@ -227,12 +228,12 @@ public class ReportManagementTest extends AbstractIntegrationTest {
.isEqualTo(3L);
final DataReportSeriesItem<String>[] outerData = innerOuterDataReportSeries.getOuterSeries().getData();
assertThat(Arrays.stream(outerData).map(DataReportSeriesItem::getType).collect(Collectors.toList()))
.contains("0.0.0", "0.0.1");
.as("versio item contains wrong version").contains("0.0.0", "0.0.1");
} else if (dataReportSeriesItem.getType().equals("ds2")) {
assertThat(dataReportSeriesItem.getData()).as("Version/Item type of DistributionSet 2 in statistics")
.isEqualTo(1L);
final DataReportSeriesItem<String>[] outerData = innerOuterDataReportSeries.getOuterSeries().getData();
assertThat(outerData).hasSize(1);
assertThat(outerData).as("Version/Item type has wrong size").hasSize(1);
assertThat(outerData[0].getType()).as("Version/Item type of DistributionSet 2 in statistics")
.isEqualTo("0.0.2");
} else if (dataReportSeriesItem.getType().equals("ds3")) {
@@ -240,7 +241,7 @@ public class ReportManagementTest extends AbstractIntegrationTest {
assertThat(dataReportSeriesItem.getData()).as("Version/Item type of DistributionSet 3 in statistics")
.isEqualTo(0L);
final DataReportSeriesItem<String>[] outerData = innerOuterDataReportSeries.getOuterSeries().getData();
assertThat(outerData).hasSize(1);
assertThat(outerData).as("Version/Item type has wrong size").hasSize(1);
assertThat(outerData[0].getType()).as("Version/Item type of DistributionSet 3 in statistics")
.isEqualTo("0.0.3");
} else {
@@ -395,13 +396,13 @@ public class ReportManagementTest extends AbstractIntegrationTest {
final DataReportSeriesItem<String>[] outerData = innerOuterDataReportSeries.getOuterSeries().getData();
assertThat(Arrays.stream(outerData).map(DataReportSeriesItem::getType).collect(Collectors.toList()))
.contains("0.0.0", "0.0.1");
.as("Out series contains wrong version").contains("0.0.0", "0.0.1");
} else if (dataReportSeriesItem.getType().equals("ds2")) {
assertThat(dataReportSeriesItem.getData()).as("Total count of DistributionSet 2 in statistics")
.isEqualTo(1L);
final DataReportSeriesItem<String>[] outerData = innerOuterDataReportSeries.getOuterSeries().getData();
assertThat(outerData).hasSize(1);
assertThat(outerData).as("out series has wrong size").hasSize(1);
assertThat(outerData[0].getType()).as("Version/Item type of DistributionSet 2 in statistics")
.isEqualTo("0.0.2");
@@ -409,7 +410,7 @@ public class ReportManagementTest extends AbstractIntegrationTest {
assertThat(dataReportSeriesItem.getData()).as("Total count of DistributionSet 3 in statistics")
.isEqualTo(0L);
final DataReportSeriesItem<String>[] outerData = innerOuterDataReportSeries.getOuterSeries().getData();
assertThat(outerData).hasSize(1);
assertThat(outerData).as("out series has wrong size").hasSize(1);
assertThat(outerData[0].getType()).as("Version/Item type of DistributionSet 3 in statistics")
.isEqualTo("0.0.3");
} else {
@@ -487,33 +488,26 @@ public class ReportManagementTest extends AbstractIntegrationTest {
final int targetCreateAmount = 10;
// create targets for another tenant
securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", "anotherTenant"), new Callable<Void>() {
@Override
public Void call() throws Exception {
for (int index = 0; index < targetCreateAmount; index++) {
targetManagement.createTarget(new Target("t" + index));
}
return null;
securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", "anotherTenant"), () -> {
for (int index = 0; index < targetCreateAmount; index++) {
targetManagement.createTarget(new Target("t" + index));
}
return null;
});
// ensure targets has been created for 'anotherTenant'
final Slice<Target> targetsForAnotherTenant = securityRule.runAs(
WithSpringAuthorityRule.withUserAndTenant("user", "anotherTenant"), new Callable<Slice<Target>>() {
@Override
public Slice<Target> call() throws Exception {
return targetManagement.findTargetsAll(new PageRequest(0, 1000));
}
});
assertThat(targetsForAnotherTenant).hasSize(targetCreateAmount);
WithSpringAuthorityRule.withUserAndTenant("user", "anotherTenant"),
() -> targetManagement.findTargetsAll(new PageRequest(0, 1000)));
assertThat(targetsForAnotherTenant).as("targets has wrong size").hasSize(targetCreateAmount);
final LocalDateTime to = LocalDateTime.now();
final LocalDateTime from = to.minusMonths(targetCreateAmount);
// now retrieve the report for the 'mytenant'
final DataReportSeries<LocalDate> targetsCreatedOverPeriod = reportManagement
.targetsCreatedOverPeriod(DateTypes.perMonth(), from, to);
// final no targets should final be created for this tenant
assertThat(targetsCreatedOverPeriod.getData()).hasSize(0);
assertThat(targetsCreatedOverPeriod.getData()).as("final no targets should final be created for this tenant")
.hasSize(0);
}

View File

@@ -159,10 +159,10 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
public void hardDeleteOfNotAssignedArtifact() {
// [STEP1]: Create SoftwareModuleX with Artifacts
SoftwareModule unassignedModule = createSoftwareModuleWithArtifacts(osType, "moduleX", "3.0.2", 2);
Iterator<Artifact> artifactsIt = unassignedModule.getArtifacts().iterator();
Artifact artifact1 = artifactsIt.next();
Artifact artifact2 = artifactsIt.next();
final SoftwareModule unassignedModule = createSoftwareModuleWithArtifacts(osType, "moduleX", "3.0.2", 2);
final Iterator<Artifact> artifactsIt = unassignedModule.getArtifacts().iterator();
final Artifact artifact1 = artifactsIt.next();
final Artifact artifact2 = artifactsIt.next();
// [STEP2]: Delete unassigned SoftwareModule
softwareManagement.deleteSoftwareModule(unassignedModule);
@@ -185,7 +185,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
public void softDeleteOfAssignedArtifact() {
// Init DistributionSet
DistributionSet disSet = distributionSetManagement
final DistributionSet disSet = distributionSetManagement
.createDistributionSet(new DistributionSet("ds1", "v1.0", "test ds", standardDsType, null));
// [STEP1]: Create SoftwareModuleX with ArtifactX
@@ -200,14 +200,14 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
// [VERIFY EXPECTED RESULT]:
// verify: assignedModule is marked as deleted
assignedModule = softwareManagement.findSoftwareModuleById(assignedModule.getId());
assertTrue(assignedModule.isDeleted());
assertTrue("The module should be flagged as deleted", assignedModule.isDeleted());
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0);
assertThat(softwareModuleRepository.findAll()).hasSize(1);
// verify: binary data is deleted
Iterator<Artifact> artifactsIt = assignedModule.getArtifacts().iterator();
Artifact artifact1 = artifactsIt.next();
Artifact artifact2 = artifactsIt.next();
final Iterator<Artifact> artifactsIt = assignedModule.getArtifacts().iterator();
final Artifact artifact1 = artifactsIt.next();
final Artifact artifact2 = artifactsIt.next();
assertArtfiactNull(artifact1, artifact2);
// verify: artifact meta data is still available
@@ -221,7 +221,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
// Init target and DistributionSet
final Target target = targetManagement.createTarget(new Target("test123"));
DistributionSet disSet = distributionSetManagement
final DistributionSet disSet = distributionSetManagement
.createDistributionSet(new DistributionSet("ds1", "v1.0", "test ds", standardDsType, null));
// [STEP1]: Create SoftwareModuleX and include the new ArtifactX
@@ -242,14 +242,14 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
// [VERIFY EXPECTED RESULT]:
// verify: assignedModule is marked as deleted
assignedModule = softwareManagement.findSoftwareModuleById(assignedModule.getId());
assertTrue(assignedModule.isDeleted());
assertTrue("The found module should be flagged deleted", assignedModule.isDeleted());
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0);
assertThat(softwareModuleRepository.findAll()).hasSize(1);
// verify: binary data is deleted
Iterator<Artifact> artifactsIt = assignedModule.getArtifacts().iterator();
Artifact artifact1 = artifactsIt.next();
Artifact artifact2 = artifactsIt.next();
final Iterator<Artifact> artifactsIt = assignedModule.getArtifacts().iterator();
final Artifact artifact1 = artifactsIt.next();
final Artifact artifact2 = artifactsIt.next();
assertArtfiactNull(artifact1, artifact2);
// verify: artifact meta data is still available
@@ -265,7 +265,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
assertThat(operations.find(new Query())).hasSize(0);
// Init artifact binary data, target and DistributionSets
byte[] source = RandomUtils.nextBytes(1024);
final byte[] source = RandomUtils.nextBytes(1024);
// [STEP1]: Create SoftwareModuleX and add a new ArtifactX
SoftwareModule moduleX = createSoftwareModuleWithArtifacts(osType, "modulex", "v1.0", 0);
@@ -273,7 +273,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
// [STEP2]: Create newArtifactX and add it to SoftwareModuleX
artifactManagement.createLocalArtifact(new ByteArrayInputStream(source), moduleX.getId(), "artifactx", false);
moduleX = softwareManagement.findSoftwareModuleWithDetails(moduleX.getId());
Artifact artifactX = moduleX.getArtifacts().iterator().next();
final Artifact artifactX = moduleX.getArtifacts().iterator().next();
// [STEP3]: Create SoftwareModuleY and add the same ArtifactX
SoftwareModule moduleY = createSoftwareModuleWithArtifacts(osType, "moduley", "v1.0", 0);
@@ -281,7 +281,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
// [STEP4]: Assign the same ArtifactX to SoftwareModuleY
artifactManagement.createLocalArtifact(new ByteArrayInputStream(source), moduleY.getId(), "artifactx", false);
moduleY = softwareManagement.findSoftwareModuleWithDetails(moduleY.getId());
Artifact artifactY = moduleY.getArtifacts().iterator().next();
final Artifact artifactY = moduleY.getArtifacts().iterator().next();
// verify: that only one entry was created in mongoDB
assertThat(operations.find(new Query())).hasSize(1);
@@ -325,14 +325,14 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
artifactManagement.createLocalArtifact(new ByteArrayInputStream(source), moduleX.getId(), "artifactx", false);
moduleX = softwareManagement.findSoftwareModuleWithDetails(moduleX.getId());
Artifact artifactX = moduleX.getArtifacts().iterator().next();
final Artifact artifactX = moduleX.getArtifacts().iterator().next();
// [STEP2]: Create SoftwareModuleY and add the same ArtifactX
SoftwareModule moduleY = createSoftwareModuleWithArtifacts(osType, "moduley", "v1.0", 0);
artifactManagement.createLocalArtifact(new ByteArrayInputStream(source), moduleY.getId(), "artifactx", false);
moduleY = softwareManagement.findSoftwareModuleWithDetails(moduleY.getId());
Artifact artifactY = moduleY.getArtifacts().iterator().next();
final Artifact artifactY = moduleY.getArtifacts().iterator().next();
// verify: that only one entry was created in mongoDB
assertThat(operations.find(new Query())).hasSize(1);
@@ -358,8 +358,8 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
// verify: SoftwareModuleX and SofwtareModule are marked as deleted
assertThat(moduleX).isNotNull();
assertThat(moduleY).isNotNull();
assertTrue(moduleX.isDeleted());
assertTrue(moduleY.isDeleted());
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(softwareModuleRepository.findAll()).hasSize(2);
@@ -370,10 +370,10 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
assertThat(artifactRepository.findOne(artifactY.getId())).isNotNull();
}
private SoftwareModule createSoftwareModuleWithArtifacts(SoftwareModuleType type, String name, String version,
int numberArtifacts) {
private SoftwareModule createSoftwareModuleWithArtifacts(final SoftwareModuleType type, final String name,
final String version, final int numberArtifacts) {
long countSoftwareModule = softwareModuleRepository.count();
final long countSoftwareModule = softwareModuleRepository.count();
// create SoftwareModule
SoftwareModule softwareModule = softwareManagement
@@ -388,7 +388,7 @@ public class SoftwareManagementTest extends AbstractIntegrationTestWithMongoDB {
softwareModule = softwareManagement.findSoftwareModuleWithDetails(softwareModule.getId());
assertThat(softwareModuleRepository.findAll()).hasSize((int) countSoftwareModule + 1);
List<Artifact> artifacts = softwareModule.getArtifacts();
final List<Artifact> artifacts = softwareModule.getArtifacts();
assertThat(artifacts).hasSize(numberArtifacts);
if (numberArtifacts != 0) {

View File

@@ -96,24 +96,26 @@ public class TargetManagementTest extends AbstractIntegrationTest {
final TargetTag targetTag = tagManagement.createTargetTag(new TargetTag("Tag1"));
final List<Target> assignedTargets = targetManagement.assignTag(assignTarget, targetTag);
assertThat(assignedTargets.size()).isEqualTo(4);
assertThat(assignedTargets.size()).as("Assigned targets are wrong").isEqualTo(4);
assignedTargets.forEach(target -> assertThat(target.getTags().size()).isEqualTo(1));
TargetTag findTargetTag = tagManagement.findTargetTag("Tag1");
assertThat(assignedTargets.size()).isEqualTo(findTargetTag.getAssignedToTargets().size());
assertThat(assignedTargets.size()).as("Assigned targets are wrong")
.isEqualTo(findTargetTag.getAssignedToTargets().size());
assertThat(targetManagement.unAssignTag("NotExist", findTargetTag)).isNull();
assertThat(targetManagement.unAssignTag("NotExist", findTargetTag)).as("Unassign target does not work")
.isNull();
final Target unAssignTarget = targetManagement.unAssignTag("targetId123", findTargetTag);
assertThat(unAssignTarget.getControllerId()).isEqualTo("targetId123");
assertThat(unAssignTarget.getTags().size()).isEqualTo(0);
assertThat(unAssignTarget.getControllerId()).as("Controller id is wrong").isEqualTo("targetId123");
assertThat(unAssignTarget.getTags()).as("Tag size is wrong").isEmpty();
findTargetTag = tagManagement.findTargetTag("Tag1");
assertThat(findTargetTag.getAssignedToTargets().size()).isEqualTo(3);
assertThat(findTargetTag.getAssignedToTargets()).as("Assigned targets are wrong").hasSize(3);
final List<Target> unAssignTargets = targetManagement.unAssignAllTargetsByTag(findTargetTag);
findTargetTag = tagManagement.findTargetTag("Tag1");
assertThat(findTargetTag.getAssignedToTargets().size()).isEqualTo(0);
assertThat(unAssignTargets.size()).isEqualTo(3);
assertThat(findTargetTag.getAssignedToTargets()).as("Unassigned targets are wrong").isEmpty();
assertThat(unAssignTargets).as("Unassigned targets are wrong").hasSize(3);
unAssignTargets.forEach(target -> assertThat(target.getTags().size()).isEqualTo(0));
}
@@ -121,14 +123,14 @@ public class TargetManagementTest extends AbstractIntegrationTest {
@Description("Ensures that targets can deleted e.g. test all cascades")
public void deleteAndCreateTargets() {
Target target = targetManagement.createTarget(new Target("targetId123"));
assertThat(targetManagement.countTargetsAll()).isEqualTo(1);
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(1);
targetManagement.deleteTargets(target.getId());
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(0);
target = createTargetWithAttributes("4711");
assertThat(targetManagement.countTargetsAll()).isEqualTo(1);
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(1);
targetManagement.deleteTargets(target.getId());
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(0);
final List<Long> targets = new ArrayList<Long>();
for (int i = 0; i < 5; i++) {
@@ -136,9 +138,9 @@ public class TargetManagementTest extends AbstractIntegrationTest {
targets.add(target.getId());
targets.add(createTargetWithAttributes("" + (i * i + 1000)).getId());
}
assertThat(targetManagement.countTargetsAll()).isEqualTo(10);
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(10);
targetManagement.deleteTargets(targets.toArray(new Long[targets.size()]));
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(0);
}
private Target createTargetWithAttributes(final String controllerId) {
@@ -150,7 +152,8 @@ public class TargetManagementTest extends AbstractIntegrationTest {
target = controllerManagament.updateControllerAttributes(controllerId, testData);
target = targetManagement.findTargetByControllerIDWithDetails(controllerId);
assertThat(target.getTargetInfo().getControllerAttributes()).isEqualTo(testData);
assertThat(target.getTargetInfo().getControllerAttributes()).as("Controller Attributes are wrong")
.isEqualTo(testData);
return target;
}
@@ -162,10 +165,14 @@ public class TargetManagementTest extends AbstractIntegrationTest {
final DistributionSet set2 = TestDataUtil.generateDistributionSet("test2", softwareManagement,
distributionSetManagement);
assertThat(targetManagement.countTargetByAssignedDistributionSet(set.getId())).isEqualTo(0);
assertThat(targetManagement.countTargetByInstalledDistributionSet(set.getId())).isEqualTo(0);
assertThat(targetManagement.countTargetByAssignedDistributionSet(set2.getId())).isEqualTo(0);
assertThat(targetManagement.countTargetByInstalledDistributionSet(set2.getId())).isEqualTo(0);
assertThat(targetManagement.countTargetByAssignedDistributionSet(set.getId())).as("Target count is wrong")
.isEqualTo(0);
assertThat(targetManagement.countTargetByInstalledDistributionSet(set.getId())).as("Target count is wrong")
.isEqualTo(0);
assertThat(targetManagement.countTargetByAssignedDistributionSet(set2.getId())).as("Target count is wrong")
.isEqualTo(0);
assertThat(targetManagement.countTargetByInstalledDistributionSet(set2.getId())).as("Target count is wrong")
.isEqualTo(0);
Target target = createTargetWithAttributes("4711");
@@ -183,13 +190,19 @@ public class TargetManagementTest extends AbstractIntegrationTest {
target = targetManagement.findTargetByControllerIDWithDetails("4711");
// read data
assertThat(targetManagement.countTargetByAssignedDistributionSet(set.getId())).isEqualTo(0);
assertThat(targetManagement.countTargetByInstalledDistributionSet(set.getId())).isEqualTo(1);
assertThat(targetManagement.countTargetByAssignedDistributionSet(set2.getId())).isEqualTo(1);
assertThat(targetManagement.countTargetByInstalledDistributionSet(set2.getId())).isEqualTo(0);
assertThat(target.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
assertThat(target.getAssignedDistributionSet()).isEqualTo(set2);
assertThat(target.getTargetInfo().getInstalledDistributionSet().getId()).isEqualTo(set.getId());
assertThat(targetManagement.countTargetByAssignedDistributionSet(set.getId())).as("Target count is wrong")
.isEqualTo(0);
assertThat(targetManagement.countTargetByInstalledDistributionSet(set.getId())).as("Target count is wrong")
.isEqualTo(1);
assertThat(targetManagement.countTargetByAssignedDistributionSet(set2.getId())).as("Target count is wrong")
.isEqualTo(1);
assertThat(targetManagement.countTargetByInstalledDistributionSet(set2.getId())).as("Target count is wrong")
.isEqualTo(0);
assertThat(target.getTargetInfo().getLastTargetQuery()).as("Target query is not work")
.isGreaterThanOrEqualTo(current);
assertThat(target.getAssignedDistributionSet()).as("Assigned ds size is wrong").isEqualTo(set2);
assertThat(target.getTargetInfo().getInstalledDistributionSet().getId()).as("Installed ds is wrong")
.isEqualTo(set.getId());
}
@@ -373,8 +386,7 @@ public class TargetManagementTest extends AbstractIntegrationTest {
assertThat(firstSaved.spliterator().getExactSizeIfKnown() - nr2Del).as("Size of splited list")
.isEqualTo(allFound.spliterator().getExactSizeIfKnown());
// verify that all undeleted are still found
assertThat(allFound).doesNotContain(deletedTargets);
assertThat(allFound).as("Not all undeleted found").doesNotContain(deletedTargets);
}
@Test
@@ -404,7 +416,7 @@ public class TargetManagementTest extends AbstractIntegrationTest {
targetInfo = targetInfoRepository.save(targetInfo);
}
final Query qry = entityManager.createNativeQuery("select * from sp_target_attributes ta");
final List result = qry.getResultList();
final List<?> result = qry.getResultList();
assertThat(attribs.size() * ts.spliterator().getExactSizeIfKnown()).as("Amount of all target attributes")
.isEqualTo(result.size());
@@ -467,7 +479,8 @@ public class TargetManagementTest extends AbstractIntegrationTest {
final Target tNoAttrib = targetManagement.findTargetByControllerID(tNoAttribl.getControllerId());
if (tNoAttrib.getControllerId().equals(target.getControllerId())) {
assertThat(target.getTargetInfo().getControllerAttributes()).isEmpty();
assertThat(target.getTargetInfo().getControllerAttributes())
.as("Controller attributes should be empty").isEmpty();
continue restTarget_;
}
}
@@ -479,7 +492,7 @@ public class TargetManagementTest extends AbstractIntegrationTest {
if (tNoAttrib.getControllerId().equals(target.getControllerId())) {
assertThat(target.getTargetInfo().getControllerAttributes().keySet().toArray())
.doesNotContain(attribs2Del.toArray());
.as("Controller attributes are wrong").doesNotContain(attribs2Del.toArray());
continue restTarget_;
}
}
@@ -504,12 +517,14 @@ public class TargetManagementTest extends AbstractIntegrationTest {
t2 = targetManagement.createTarget(t2);
t1 = targetManagement.findTargetByControllerID(t1.getControllerId());
assertThat(t1.getTags()).hasSize(noT1Tags).containsAll(t1Tags);
assertThat(t1.getTags()).hasSize(noT1Tags).doesNotContain(Iterables.toArray(t2Tags, TargetTag.class));
assertThat(t1.getTags()).as("Tag size is wrong").hasSize(noT1Tags).containsAll(t1Tags);
assertThat(t1.getTags()).as("Tag size is wrong").hasSize(noT1Tags)
.doesNotContain(Iterables.toArray(t2Tags, TargetTag.class));
t2 = targetManagement.findTargetByControllerID(t2.getControllerId());
assertThat(t2.getTags()).hasSize(noT2Tags).containsAll(t2Tags);
assertThat(t2.getTags()).hasSize(noT2Tags).doesNotContain(Iterables.toArray(t1Tags, TargetTag.class));
assertThat(t2.getTags()).as("Tag size is wrong").hasSize(noT2Tags).containsAll(t2Tags);
assertThat(t2.getTags()).as("Tag size is wrong").hasSize(noT2Tags)
.doesNotContain(Iterables.toArray(t1Tags, TargetTag.class));
}
@Test
@@ -531,7 +546,7 @@ public class TargetManagementTest extends AbstractIntegrationTest {
final TargetTag tagA = tagManagement.createTargetTag(new TargetTag("A"));
final TargetTag tagB = tagManagement.createTargetTag(new TargetTag("B"));
final TargetTag tagC = tagManagement.createTargetTag(new TargetTag("C"));
final TargetTag tagX = tagManagement.createTargetTag(new TargetTag("X"));
tagManagement.createTargetTag(new TargetTag("X"));
// doing different assignments
targetManagement.toggleTagAssignment(tagATargets, tagA);
@@ -545,7 +560,8 @@ public class TargetManagementTest extends AbstractIntegrationTest {
targetManagement.toggleTagAssignment(tagABCTargets, tagB);
targetManagement.toggleTagAssignment(tagABCTargets, tagC);
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "X")).isEqualTo(0);
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "X"))
.as("Target count is wrong").isEqualTo(0);
// search for targets with tag tagA
final List<Target> targetWithTagA = new ArrayList<Target>();
@@ -575,11 +591,11 @@ public class TargetManagementTest extends AbstractIntegrationTest {
// check again target lists refreshed from DB
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "A"))
.isEqualTo(targetWithTagA.size());
.as("Target count is wrong").isEqualTo(targetWithTagA.size());
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "B"))
.isEqualTo(targetWithTagB.size());
.as("Target count is wrong").isEqualTo(targetWithTagB.size());
assertThat(targetManagement.countTargetByFilters(null, null, null, Boolean.FALSE, "C"))
.isEqualTo(targetWithTagC.size());
.as("Target count is wrong").isEqualTo(targetWithTagC.size());
}
@Test
@@ -656,14 +672,15 @@ public class TargetManagementTest extends AbstractIntegrationTest {
targetManagement.toggleTagAssignment(targAs, targTagA);
assertThat(targetManagement.findTargetsByControllerIDsWithTags(
targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList()))).hasSize(25);
targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList())))
.as("Target count is wrong").hasSize(25);
// no lazy loading exception and tag correctly assigned
assertThat(targetManagement
.findTargetsByControllerIDsWithTags(
targAs.stream().map(target -> target.getControllerId()).collect(Collectors.toList()))
.stream().map(target -> target.getTags().contains(targTagA)).collect(Collectors.toList()))
.containsOnly(true);
.as("Tags not correctly assigned").containsOnly(true);
}
@Test
@@ -678,7 +695,7 @@ public class TargetManagementTest extends AbstractIntegrationTest {
final List<String> findAllTargetIds = findAllTargetIdNames.stream().map(TargetIdName::getControllerId)
.collect(Collectors.toList());
assertThat(findAllTargetIds).containsOnly(createdTargetIds);
assertThat(findAllTargetIds).as("Target list has wrong content").containsOnly(createdTargetIds);
}
@Test

View File

@@ -72,7 +72,7 @@ public class RSQLActionFieldsTest extends AbstractIntegrationTest {
try {
assertRSQLQuery(ActionFields.STATUS.name() + "==true", 5);
fail();
fail("Missing expected RSQLParameterUnsupportedFieldException because status cannot be compared with 'true'");
} catch (final RSQLParameterUnsupportedFieldException e) {
}
}

View File

@@ -140,7 +140,7 @@ public class RSQLDistributionSetFieldTest extends AbstractIntegrationTest {
final Page<DistributionSet> find = distributionSetManagement.findDistributionSetsAll(
RSQLUtility.parse(rsqlParam, DistributionSetFields.class), new PageRequest(0, 100), false);
final long countAll = find.getTotalElements();
assertThat(find).isNotNull();
assertThat(countAll).isEqualTo(excpectedEntity);
assertThat(find).as("Founded entity is should not be null").isNotNull();
assertThat(countAll).as("Founded entity size is wrong").isEqualTo(excpectedEntity);
}
}

View File

@@ -63,7 +63,7 @@ public class RSQLUtilityTest {
try {
RSQLUtility.parse(wrongRSQL, SoftwareModuleFields.class).toPredicate(baseSoftwareModuleRootMock,
criteriaQueryMock, criteriaBuilderMock);
fail();
fail("Missing expected RSQLParameterSyntaxException because of wrong RSQL syntax");
} catch (final RSQLParameterSyntaxException e) {
}
}
@@ -75,7 +75,7 @@ public class RSQLUtilityTest {
try {
RSQLUtility.parse(wrongRSQL, SoftwareModuleFields.class).toPredicate(baseSoftwareModuleRootMock,
criteriaQueryMock, criteriaBuilderMock);
fail();
fail("Missing an expected RSQLParameterUnsupportedFieldException because of unknown RSQL field");
} catch (final RSQLParameterUnsupportedFieldException e) {
}
@@ -87,7 +87,7 @@ public class RSQLUtilityTest {
try {
RSQLUtility.parse(wrongRSQL, TargetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock,
criteriaBuilderMock);
fail();
fail("Missing expected RSQLParameterSyntaxException because of wrong RSQL syntax");
} catch (final RSQLParameterUnsupportedFieldException e) {
}
@@ -95,7 +95,7 @@ public class RSQLUtilityTest {
try {
RSQLUtility.parse(wrongRSQL, TargetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock,
criteriaBuilderMock);
fail();
fail("Missing expected RSQLParameterSyntaxException because of wrong RSQL syntax");
} catch (final RSQLParameterUnsupportedFieldException e) {
}
@@ -103,7 +103,7 @@ public class RSQLUtilityTest {
try {
RSQLUtility.parse(wrongRSQL, DistributionSetFields.class).toPredicate(baseSoftwareModuleRootMock,
criteriaQueryMock, criteriaBuilderMock);
fail();
fail("Missing expected RSQLParameterSyntaxException because of wrong RSQL syntax");
} catch (final RSQLParameterUnsupportedFieldException e) {
}
@@ -115,7 +115,7 @@ public class RSQLUtilityTest {
try {
RSQLUtility.parse(wrongRSQL, TargetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock,
criteriaBuilderMock);
fail();
fail("Missing expected RSQLParameterSyntaxException because of wrong RSQL syntax");
} catch (final RSQLParameterUnsupportedFieldException e) {
}
@@ -123,7 +123,7 @@ public class RSQLUtilityTest {
try {
RSQLUtility.parse(wrongRSQL, TargetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock,
criteriaBuilderMock);
fail();
fail("Missing expected RSQLParameterSyntaxException because of wrong RSQL syntax");
} catch (final RSQLParameterUnsupportedFieldException e) {
}
@@ -131,7 +131,7 @@ public class RSQLUtilityTest {
try {
RSQLUtility.parse(wrongRSQL, TargetFields.class).toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock,
criteriaBuilderMock);
fail();
fail("Missing expected RSQLParameterSyntaxException because of wrong RSQL syntax");
} catch (final RSQLParameterUnsupportedFieldException e) {
}
}