Complete repository refactoring - method renaming (#575)
* Split Tag management Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Repo method naming schame applied. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * findAll returns slice instead of page. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Complete javadoc. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Allow null values again. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Readability improvements. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Forgot a method. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fixed broken completed filter. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -30,7 +30,7 @@ public class DistributionSetCreatedEventTest extends AbstractRemoteEntityEventTe
|
||||
|
||||
@Override
|
||||
protected DistributionSet createEntity() {
|
||||
return distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create()
|
||||
return distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("incomplete").version("2").description("incomplete").type("os"));
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class DistributionSetTagEventTest extends AbstractRemoteEntityEventTest<D
|
||||
|
||||
@Override
|
||||
protected DistributionSetTag createEntity() {
|
||||
return tagManagement.createDistributionSetTag(entityFactory.tag().create().name("tag1"));
|
||||
return distributionSetTagManagement.create(entityFactory.tag().create().name("tag1"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DistributionSetUpdatedEventTest extends AbstractRemoteEntityEventTe
|
||||
|
||||
@Override
|
||||
protected DistributionSet createEntity() {
|
||||
return distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create()
|
||||
return distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("incomplete").version("2").description("incomplete").type("os"));
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,10 @@ public class RolloutEventTest extends AbstractRemoteEntityEventTest<Rollout> {
|
||||
@Override
|
||||
protected Rollout createEntity() {
|
||||
testdataFactory.createTarget("12345");
|
||||
final DistributionSet ds = distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
final DistributionSet ds = distributionSetManagement.create(entityFactory.distributionSet()
|
||||
.create().name("incomplete").version("2").description("incomplete").type("os"));
|
||||
|
||||
return rolloutManagement.createRollout(
|
||||
return rolloutManagement.create(
|
||||
entityFactory.rollout().create().name("exampleRollout").targetFilterQuery("controllerId==*").set(ds),
|
||||
10, new RolloutGroupConditionBuilder().withDefaults()
|
||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
|
||||
|
||||
@@ -91,15 +91,15 @@ public class RolloutGroupEventTest extends AbstractRemoteEntityEventTest<Rollout
|
||||
protected RolloutGroup createEntity() {
|
||||
testdataFactory.createTarget(UUID.randomUUID().toString());
|
||||
|
||||
final DistributionSet ds = distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
final DistributionSet ds = distributionSetManagement.create(entityFactory.distributionSet()
|
||||
.create().name("incomplete").version("2").description("incomplete").type("os"));
|
||||
|
||||
final Rollout entity = rolloutManagement.createRollout(
|
||||
final Rollout entity = rolloutManagement.create(
|
||||
entityFactory.rollout().create().name("exampleRollout").targetFilterQuery("controllerId==*").set(ds),
|
||||
10, new RolloutGroupConditionBuilder().withDefaults()
|
||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
|
||||
|
||||
return rolloutGroupManagement.findRolloutGroupsByRolloutId(entity.getId(), PAGE).getContent().get(0);
|
||||
return rolloutGroupManagement.findByRollout(PAGE, entity.getId()).getContent().get(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class TargetTagEventTest extends AbstractRemoteEntityEventTest<TargetTag>
|
||||
|
||||
@Override
|
||||
protected TargetTag createEntity() {
|
||||
return tagManagement.createTargetTag(entityFactory.tag().create().name("tag1"));
|
||||
return targetTagManagement.create(entityFactory.tag().create().name("tag1"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,11 +53,11 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
final SoftwareModule module = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
assertThat(artifactManagement.findArtifact(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(artifactManagement.findByFilenameAndSoftwareModule(NOT_EXIST_ID, module.getId()).isPresent())
|
||||
assertThat(artifactManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(artifactManagement.getByFilenameAndSoftwareModule(NOT_EXIST_ID, module.getId()).isPresent())
|
||||
.isFalse();
|
||||
|
||||
assertThat(artifactManagement.findFirstArtifactBySHA1(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(artifactManagement.findFirstBySHA1(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(artifactManagement.loadArtifactBinary(NOT_EXIST_ID)).isNotPresent();
|
||||
}
|
||||
|
||||
@@ -67,20 +67,20 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
@ExpectEvents({ @Expect(type = SoftwareModuleDeletedEvent.class, count = 0) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() throws URISyntaxException {
|
||||
|
||||
verifyThrownExceptionBy(() -> artifactManagement.createArtifact(IOUtils.toInputStream("test", "UTF-8"),
|
||||
verifyThrownExceptionBy(() -> artifactManagement.create(IOUtils.toInputStream("test", "UTF-8"),
|
||||
NOT_EXIST_IDL, "xxx", null, null, false, null), "SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> artifactManagement.createArtifact(IOUtils.toInputStream("test", "UTF-8"), 1234L, "xxx", false),
|
||||
() -> artifactManagement.create(IOUtils.toInputStream("test", "UTF-8"), 1234L, "xxx", false),
|
||||
"SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(() -> artifactManagement.deleteArtifact(NOT_EXIST_IDL), "Artifact");
|
||||
verifyThrownExceptionBy(() -> artifactManagement.delete(NOT_EXIST_IDL), "Artifact");
|
||||
|
||||
verifyThrownExceptionBy(() -> artifactManagement.findArtifactBySoftwareModule(PAGE, NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> artifactManagement.findBySoftwareModule(PAGE, NOT_EXIST_IDL),
|
||||
"SoftwareModule");
|
||||
assertThat(artifactManagement.findArtifactByFilename(NOT_EXIST_ID).isPresent()).isFalse();
|
||||
assertThat(artifactManagement.getByFilename(NOT_EXIST_ID).isPresent()).isFalse();
|
||||
|
||||
verifyThrownExceptionBy(() -> artifactManagement.findByFilenameAndSoftwareModule("xxx", NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> artifactManagement.getByFilenameAndSoftwareModule("xxx", NOT_EXIST_IDL),
|
||||
"SoftwareModule");
|
||||
}
|
||||
|
||||
@@ -102,11 +102,11 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
|
||||
final Artifact result = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1",
|
||||
final Artifact result = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file1",
|
||||
false);
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file11", false);
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file12", false);
|
||||
final Artifact result2 = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm2.getId(),
|
||||
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file11", false);
|
||||
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file12", false);
|
||||
final Artifact result2 = artifactManagement.create(new ByteArrayInputStream(random), sm2.getId(),
|
||||
"file2", false);
|
||||
|
||||
assertThat(result).isInstanceOf(Artifact.class);
|
||||
@@ -117,15 +117,15 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(result).isNotEqualTo(result2);
|
||||
assertThat(((JpaArtifact) result).getSha1Hash()).isEqualTo(((JpaArtifact) result2).getSha1Hash());
|
||||
|
||||
assertThat(artifactManagement.findArtifactByFilename("file1").get().getSha1Hash())
|
||||
assertThat(artifactManagement.getByFilename("file1").get().getSha1Hash())
|
||||
.isEqualTo(HashGeneratorUtils.generateSHA1(random));
|
||||
assertThat(artifactManagement.findArtifactByFilename("file1").get().getMd5Hash())
|
||||
assertThat(artifactManagement.getByFilename("file1").get().getMd5Hash())
|
||||
.isEqualTo(HashGeneratorUtils.generateMD5(random));
|
||||
|
||||
assertThat(artifactRepository.findAll()).hasSize(4);
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(3);
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts()).hasSize(3);
|
||||
assertThat(softwareModuleManagement.get(sm.getId()).get().getArtifacts()).hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -136,7 +136,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
||||
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
||||
assertThat(artifactRepository.findAll()).hasSize(1);
|
||||
|
||||
softwareModuleRepository.deleteAll();
|
||||
@@ -145,7 +145,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.eclipse.hawkbit.repository.ArtifactManagement#deleteArtifact(java.lang.Long)}
|
||||
* {@link org.eclipse.hawkbit.repository.ArtifactManagement#delete(java.lang.Long)}
|
||||
* .
|
||||
*
|
||||
* @throws IOException
|
||||
@@ -162,9 +162,9 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
assertThat(artifactRepository.findAll()).isEmpty();
|
||||
|
||||
final Artifact result = artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), sm.getId(),
|
||||
final Artifact result = artifactManagement.create(new RandomGeneratedInputStream(5 * 1024), sm.getId(),
|
||||
"file1", false);
|
||||
final Artifact result2 = artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024),
|
||||
final Artifact result2 = artifactManagement.create(new RandomGeneratedInputStream(5 * 1024),
|
||||
sm2.getId(), "file2", false);
|
||||
|
||||
assertThat(artifactRepository.findAll()).hasSize(2);
|
||||
@@ -178,14 +178,14 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result2.getSha1Hash()))
|
||||
.isNotNull();
|
||||
|
||||
artifactManagement.deleteArtifact(result.getId());
|
||||
artifactManagement.delete(result.getId());
|
||||
|
||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
||||
.isNull();
|
||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result2.getSha1Hash()))
|
||||
.isNotNull();
|
||||
|
||||
artifactManagement.deleteArtifact(result2.getId());
|
||||
artifactManagement.delete(result2.getId());
|
||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result2.getSha1Hash()))
|
||||
.isNull();
|
||||
|
||||
@@ -204,9 +204,9 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
|
||||
final Artifact result = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1",
|
||||
final Artifact result = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file1",
|
||||
false);
|
||||
final Artifact result2 = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm2.getId(),
|
||||
final Artifact result2 = artifactManagement.create(new ByteArrayInputStream(random), sm2.getId(),
|
||||
"file2", false);
|
||||
|
||||
assertThat(artifactRepository.findAll()).hasSize(2);
|
||||
@@ -216,11 +216,11 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
||||
.isNotNull();
|
||||
artifactManagement.deleteArtifact(result.getId());
|
||||
artifactManagement.delete(result.getId());
|
||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
||||
.isNotNull();
|
||||
|
||||
artifactManagement.deleteArtifact(result2.getId());
|
||||
artifactManagement.delete(result2.getId());
|
||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
||||
.isNull();
|
||||
}
|
||||
@@ -228,10 +228,10 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Loads an local artifact based on given ID.")
|
||||
public void findArtifact() throws NoSuchAlgorithmException, IOException {
|
||||
final Artifact result = artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024),
|
||||
final Artifact result = artifactManagement.create(new RandomGeneratedInputStream(5 * 1024),
|
||||
testdataFactory.createSoftwareModuleOs().getId(), "file1", false);
|
||||
|
||||
assertThat(artifactManagement.findArtifact(result.getId()).get()).isEqualTo(result);
|
||||
assertThat(artifactManagement.get(result.getId()).get()).isEqualTo(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -239,7 +239,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void loadStreamOfArtifact() throws NoSuchAlgorithmException, IOException {
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
|
||||
final Artifact result = artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
||||
final Artifact result = artifactManagement.create(new ByteArrayInputStream(random),
|
||||
testdataFactory.createSoftwareModuleOs().getId(), "file1", false);
|
||||
|
||||
try (InputStream fileInputStream = artifactManagement.loadArtifactBinary(result.getSha1Hash()).get()
|
||||
@@ -266,11 +266,11 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void findArtifactBySoftwareModule() {
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
assertThat(artifactManagement.findArtifactBySoftwareModule(PAGE, sm.getId())).isEmpty();
|
||||
assertThat(artifactManagement.findBySoftwareModule(PAGE, sm.getId())).isEmpty();
|
||||
|
||||
artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file1", false);
|
||||
artifactManagement.create(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file1", false);
|
||||
|
||||
assertThat(artifactManagement.findArtifactBySoftwareModule(PAGE, sm.getId())).hasSize(1);
|
||||
assertThat(artifactManagement.findBySoftwareModule(PAGE, sm.getId())).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -278,12 +278,12 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void findByFilenameAndSoftwareModule() {
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
assertThat(artifactManagement.findByFilenameAndSoftwareModule("file1", sm.getId())).isNotPresent();
|
||||
assertThat(artifactManagement.getByFilenameAndSoftwareModule("file1", sm.getId())).isNotPresent();
|
||||
|
||||
artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file1", false);
|
||||
artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file2", false);
|
||||
artifactManagement.create(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file1", false);
|
||||
artifactManagement.create(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file2", false);
|
||||
|
||||
assertThat(artifactManagement.findByFilenameAndSoftwareModule("file1", sm.getId())).isPresent();
|
||||
assertThat(artifactManagement.getByFilenameAndSoftwareModule("file1", sm.getId())).isPresent();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule module = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
assertThat(controllerManagement.findActionWithDetails(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(controllerManagement.findByControllerId(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(controllerManagement.findByTargetId(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(controllerManagement.getByControllerId(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(controllerManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(controllerManagement.getActionForDownloadByTargetAndSoftwareModule(target.getControllerId(),
|
||||
module.getId())).isNotPresent();
|
||||
|
||||
@@ -308,8 +308,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Long dsId = testdataFactory.createDistributionSet().getId();
|
||||
testdataFactory.createTarget();
|
||||
assignDistributionSet(dsId, TestdataFactory.DEFAULT_CONTROLLER_ID);
|
||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
||||
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
return deploymentManagement.findActiveActionsByTarget(PAGE, TestdataFactory.DEFAULT_CONTROLLER_ID).getContent()
|
||||
.get(0).getId();
|
||||
@@ -364,7 +364,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void assertActionStatus(final Long actionId, final String controllerId,
|
||||
final TargetUpdateStatus expectedTargetUpdateStatus, final Action.Status expectedActionActionStatus,
|
||||
final Action.Status expectedActionStatus, final boolean actionActive) {
|
||||
final TargetUpdateStatus targetStatus = targetManagement.findTargetByControllerID(controllerId).get()
|
||||
final TargetUpdateStatus targetStatus = targetManagement.getByControllerID(controllerId).get()
|
||||
.getUpdateStatus();
|
||||
assertThat(targetStatus).isEqualTo(expectedTargetUpdateStatus);
|
||||
final Action action = deploymentManagement.findAction(actionId).get();
|
||||
@@ -396,9 +396,9 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
Target savedTarget = testdataFactory.createTarget();
|
||||
|
||||
// create two artifacts with identical SHA1 hash
|
||||
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
||||
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random),
|
||||
ds.findFirstModuleByType(osType).get().getId(), "file1", false);
|
||||
final Artifact artifact2 = artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
||||
final Artifact artifact2 = artifactManagement.create(new ByteArrayInputStream(random),
|
||||
ds2.findFirstModuleByType(osType).get().getId(), "file1", false);
|
||||
assertThat(artifact.getSha1Hash()).isEqualTo(artifact2.getSha1Hash());
|
||||
|
||||
@@ -531,8 +531,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
entityFactory.actionStatus().create(action.getId()).status(Action.Status.RUNNING));
|
||||
|
||||
// nothing changed as "feedback after close" is disabled
|
||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
||||
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
|
||||
assertThat(actionStatusRepository.count()).isEqualTo(3);
|
||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, action.getId()).getNumberOfElements())
|
||||
@@ -556,8 +556,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
entityFactory.actionStatus().create(action.getId()).status(Action.Status.RUNNING));
|
||||
|
||||
// nothing changed as "feedback after close" is disabled
|
||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
||||
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
|
||||
// however, additional action status has been stored
|
||||
assertThat(actionStatusRepository.findAll(PAGE).getNumberOfElements()).isEqualTo(4);
|
||||
@@ -581,7 +581,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
});
|
||||
|
||||
// verify that audit information has not changed
|
||||
final Target targetVerify = targetManagement.findTargetByControllerID(controllerId).get();
|
||||
final Target targetVerify = targetManagement.getByControllerID(controllerId).get();
|
||||
assertThat(targetVerify.getCreatedBy()).isEqualTo(target.getCreatedBy());
|
||||
assertThat(targetVerify.getCreatedAt()).isEqualTo(target.getCreatedAt());
|
||||
assertThat(targetVerify.getLastModifiedBy()).isEqualTo(target.getLastModifiedBy());
|
||||
|
||||
@@ -40,6 +40,8 @@ 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.jpa.specifications.DistributionSetSpecification;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.SpecificationsBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
@@ -223,8 +225,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
// not exists
|
||||
assignDS.add(100L);
|
||||
|
||||
final DistributionSetTag tag = tagManagement
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("Tag1"));
|
||||
final DistributionSetTag tag = distributionSetTagManagement.create(entityFactory.tag().create().name("Tag1"));
|
||||
|
||||
assertThatExceptionOfType(EntityNotFoundException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.assignTag(assignDS, tag.getId()))
|
||||
@@ -271,8 +272,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet dsInstalled = action.getDistributionSet();
|
||||
|
||||
// check initial status
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
||||
.as("target has update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("target has update status")
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
|
||||
// assign the two sets in a row
|
||||
JpaAction firstAction = assignSet(target, dsFirst);
|
||||
@@ -289,7 +290,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
entityFactory.actionStatus().create(secondAction.getId()).status(Status.CANCELED));
|
||||
assertThat(actionStatusRepository.findAll()).as("wrong size of actions status").hasSize(7);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong ds").isEqualTo(dsFirst);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
// we cancel first -> back to installed
|
||||
@@ -301,7 +302,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(9);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong assigned ds")
|
||||
.isEqualTo(dsInstalled);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
}
|
||||
|
||||
@@ -317,7 +318,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet dsInstalled = action.getDistributionSet();
|
||||
|
||||
// check initial status
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
|
||||
// assign the two sets in a row
|
||||
@@ -336,8 +337,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(7);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong assigned ds")
|
||||
.isEqualTo(dsSecond);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
||||
.as("wrong target update status").isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong target update status")
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
// we cancel second -> remain assigned until finished cancellation
|
||||
deploymentManagement.cancelAction(secondAction.getId());
|
||||
@@ -351,7 +352,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
// cancelled success -> back to dsInstalled
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong installed ds")
|
||||
.isEqualTo(dsInstalled);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus())
|
||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
}
|
||||
|
||||
@@ -365,7 +366,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("newDS", true);
|
||||
|
||||
// verify initial status
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus())
|
||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
|
||||
Action assigningAction = assignSet(target, ds);
|
||||
@@ -386,8 +387,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(assigningAction.getStatus()).as("wrong size of status").isEqualTo(Status.CANCELED);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong assigned ds")
|
||||
.isEqualTo(dsInstalled);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
||||
.as("wrong target update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong target update status")
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -399,7 +400,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("newDS", true);
|
||||
|
||||
// verify initial status
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
|
||||
final Action assigningAction = assignSet(target, ds);
|
||||
@@ -418,7 +419,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private JpaAction assignSet(final Target target, final DistributionSet ds) {
|
||||
assignDistributionSet(ds.getId(), target.getControllerId());
|
||||
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).get().getUpdateStatus())
|
||||
assertThat(targetManagement.getByControllerID(target.getControllerId()).get().getUpdateStatus())
|
||||
.as("wrong update status").isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get())
|
||||
.as("wrong assigned ds").isEqualTo(ds);
|
||||
@@ -450,9 +451,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
.getAssignedEntity();
|
||||
assertThat(actionRepository.count()).isEqualTo(20);
|
||||
|
||||
assertThat(targetManagement.findTargetByInstalledDistributionSet(ds.getId(), PAGE).getContent())
|
||||
.containsAll(targets).hasSize(10)
|
||||
.containsAll(targetManagement.findTargetByAssignedDistributionSet(ds.getId(), PAGE))
|
||||
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, ds.getId()).getContent()).containsAll(targets)
|
||||
.hasSize(10).containsAll(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId()))
|
||||
.as("InstallationDate set").allMatch(target -> target.getInstallationDate() >= current)
|
||||
.as("TargetUpdateStatus IN_SYNC")
|
||||
.allMatch(target -> TargetUpdateStatus.IN_SYNC.equals(target.getUpdateStatus()))
|
||||
@@ -486,10 +486,10 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
// verify that one Action for each assignDistributionSet
|
||||
assertThat(actionRepository.findAll(PAGE).getNumberOfElements()).as("wrong size of actions").isEqualTo(20);
|
||||
|
||||
final Iterable<Target> allFoundTargets = targetManagement.findTargetsAll(PAGE).getContent();
|
||||
final Iterable<Target> allFoundTargets = targetManagement.findAll(PAGE).getContent();
|
||||
|
||||
// get final updated version of targets
|
||||
savedDeployedTargets = targetManagement.findTargetsByControllerID(
|
||||
savedDeployedTargets = targetManagement.getByControllerID(
|
||||
savedDeployedTargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()));
|
||||
|
||||
assertThat(allFoundTargets).as("founded targets are wrong").containsAll(savedDeployedTargets)
|
||||
@@ -500,13 +500,13 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
.doesNotContain(Iterables.toArray(savedDeployedTargets, Target.class));
|
||||
|
||||
for (final Target myt : savedNakedTargets) {
|
||||
final Target t = targetManagement.findTargetByControllerID(myt.getControllerId()).get();
|
||||
final Target t = targetManagement.getByControllerID(myt.getControllerId()).get();
|
||||
assertThat(deploymentManagement.countActionsByTarget(t.getControllerId())).as("action should be empty")
|
||||
.isEqualTo(0L);
|
||||
}
|
||||
|
||||
for (final Target myt : savedDeployedTargets) {
|
||||
final Target t = targetManagement.findTargetByControllerID(myt.getControllerId()).get();
|
||||
final Target t = targetManagement.getByControllerID(myt.getControllerId()).get();
|
||||
final List<Action> activeActionsByTarget = deploymentManagement
|
||||
.findActiveActionsByTarget(PAGE, t.getControllerId()).getContent();
|
||||
assertThat(activeActionsByTarget).as("action should not be empty").isNotEmpty();
|
||||
@@ -531,9 +531,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
||||
final SoftwareModule os = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final DistributionSet incomplete = distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("incomplete").version("v1")
|
||||
.type(standardDsType).modules(Arrays.asList(ah.getId())));
|
||||
final DistributionSet incomplete = distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("incomplete").version("v1").type(standardDsType).modules(Arrays.asList(ah.getId())));
|
||||
|
||||
try {
|
||||
assignDistributionSet(incomplete, targets);
|
||||
@@ -664,7 +663,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
.isEqualTo(dsC.getId());
|
||||
assertThat(deploymentManagement.getInstalledDistributionSet(t.getControllerId()))
|
||||
.as("installed ds should not be null").isNotPresent();
|
||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||
assertThat(targetManagement.getByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.PENDING);
|
||||
}
|
||||
|
||||
@@ -675,12 +674,12 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// verify, that dsA is deployed correctly
|
||||
for (final Target t_ : updatedTsDsA) {
|
||||
final Target t = targetManagement.findTargetByControllerID(t_.getControllerId()).get();
|
||||
final Target t = targetManagement.getByControllerID(t_.getControllerId()).get();
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet(t.getControllerId()).get())
|
||||
.as("assigned ds is wrong").isEqualTo(dsA);
|
||||
assertThat(deploymentManagement.getInstalledDistributionSet(t.getControllerId()).get())
|
||||
.as("installed ds is wrong").isEqualTo(dsA);
|
||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||
assertThat(targetManagement.getByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, t.getControllerId()))
|
||||
.as("no actions should be active").hasSize(0);
|
||||
@@ -695,19 +694,19 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
actionRepository.findByDistributionSetId(pageRequest, dsA.getId()).getContent().get(1);
|
||||
|
||||
// get final updated version of targets
|
||||
final List<Target> deployResWithDsBTargets = targetManagement.findTargetsByControllerID(deployResWithDsB
|
||||
final List<Target> deployResWithDsBTargets = targetManagement.getByControllerID(deployResWithDsB
|
||||
.getDeployedTargets().stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
|
||||
assertThat(deployed2DS).as("deployed ds is wrong").containsAll(deployResWithDsBTargets);
|
||||
assertThat(deployed2DS).as("deployed ds is wrong").hasSameSizeAs(deployResWithDsBTargets);
|
||||
|
||||
for (final Target t_ : deployed2DS) {
|
||||
final Target t = targetManagement.findTargetByControllerID(t_.getControllerId()).get();
|
||||
final Target t = targetManagement.getByControllerID(t_.getControllerId()).get();
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet(t.getControllerId()).get())
|
||||
.as("assigned ds is wrong").isEqualTo(dsA);
|
||||
assertThat(deploymentManagement.getInstalledDistributionSet(t.getControllerId()))
|
||||
.as("installed ds should be null").isNotPresent();
|
||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||
assertThat(targetManagement.getByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
}
|
||||
@@ -739,42 +738,41 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(dsA.getId());
|
||||
distributionSetManagement.delete(dsA.getId());
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetById(dsA.getId())).isNotPresent();
|
||||
assertThat(distributionSetManagement.get(dsA.getId())).isNotPresent();
|
||||
|
||||
// // 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()).get();
|
||||
distributionSetManagement.delete(ds.getId());
|
||||
final DistributionSet foundDS = distributionSetManagement.get(ds.getId()).get();
|
||||
assertThat(foundDS).as("founded should not be null").isNotNull();
|
||||
assertThat(foundDS.isDeleted()).as("found ds should be deleted").isTrue();
|
||||
}
|
||||
|
||||
// verify that deleted attribute is used correctly
|
||||
List<DistributionSet> allFoundDS = distributionSetManagement
|
||||
.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true).getContent();
|
||||
List<DistributionSet> allFoundDS = distributionSetManagement.findByCompleted(PAGE, true).getContent();
|
||||
assertThat(allFoundDS.size()).as("no ds should be founded").isEqualTo(0);
|
||||
allFoundDS = distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageRequest, true, true)
|
||||
.getContent();
|
||||
assertThat(allFoundDS).as("wrong size of founded ds").hasSize(noOfDistributionSets);
|
||||
|
||||
assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays
|
||||
.asList(DistributionSetSpecification.isDeleted(true), DistributionSetSpecification.isCompleted(true))),
|
||||
PAGE).getContent()).as("wrong size of founded ds").hasSize(noOfDistributionSets);
|
||||
|
||||
for (final DistributionSet ds : deploymentResult.getDistributionSets()) {
|
||||
testdataFactory.sendUpdateActionStatusToTargets(deploymentResult.getDeployedTargets(), Status.FINISHED,
|
||||
Collections.singletonList("blabla alles gut"));
|
||||
}
|
||||
// try to delete again
|
||||
distributionSetManagement.deleteDistributionSet(deploymentResult.getDistributionSetIDs());
|
||||
distributionSetManagement.delete(deploymentResult.getDistributionSetIDs());
|
||||
// verify that the result is the same, even though distributionSet dsA
|
||||
// has been installed
|
||||
// successfully and no activeAction is referring to created distribution
|
||||
// sets
|
||||
allFoundDS = distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageRequest, false, true)
|
||||
.getContent();
|
||||
allFoundDS = distributionSetManagement.findByCompleted(pageRequest, true).getContent();
|
||||
assertThat(allFoundDS.size()).as("no ds should be founded").isEqualTo(0);
|
||||
allFoundDS = distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageRequest, true, true)
|
||||
.getContent();
|
||||
assertThat(allFoundDS).as("size of founded ds is wrong").hasSize(noOfDistributionSets);
|
||||
assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays
|
||||
.asList(DistributionSetSpecification.isDeleted(true), DistributionSetSpecification.isCompleted(true))),
|
||||
PAGE).getContent()).as("wrong size of founded ds").hasSize(noOfDistributionSets);
|
||||
|
||||
}
|
||||
|
||||
@@ -798,13 +796,13 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
Collections.singletonList("blabla alles gut"));
|
||||
}
|
||||
|
||||
assertThat(targetManagement.countTargetsAll()).as("size of targets is wrong").isNotZero();
|
||||
assertThat(targetManagement.count()).as("size of targets is wrong").isNotZero();
|
||||
assertThat(actionStatusRepository.count()).as("size of action status is wrong").isNotZero();
|
||||
|
||||
targetManagement.deleteTargets(deploymentResult.getUndeployedTargetIDs());
|
||||
targetManagement.deleteTargets(deploymentResult.getDeployedTargetIDs());
|
||||
targetManagement.delete(deploymentResult.getUndeployedTargetIDs());
|
||||
targetManagement.delete(deploymentResult.getDeployedTargetIDs());
|
||||
|
||||
assertThat(targetManagement.countTargetsAll()).as("size of targets should be zero").isZero();
|
||||
assertThat(targetManagement.count()).as("size of targets should be zero").isZero();
|
||||
assertThat(actionStatusRepository.count()).as("size of action status is wrong").isZero();
|
||||
}
|
||||
|
||||
@@ -818,13 +816,13 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// doing the assignment
|
||||
targs = assignDistributionSet(dsA, targs).getAssignedEntity();
|
||||
Target targ = targetManagement.findTargetByControllerID(targs.iterator().next().getControllerId()).get();
|
||||
Target targ = targetManagement.getByControllerID(targs.iterator().next().getControllerId()).get();
|
||||
|
||||
// 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()).as("lock revision is wrong").isEqualTo(
|
||||
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong")
|
||||
.isEqualTo(distributionSetManagement.getWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||
|
||||
// verifying that the assignment is correct
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements())
|
||||
@@ -843,7 +841,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
controllerManagement.addUpdateActionStatus(
|
||||
entityFactory.actionStatus().create(updAct.getContent().get(0).getId()).status(Status.FINISHED));
|
||||
|
||||
targ = targetManagement.findTargetByControllerID(targ.getControllerId()).get();
|
||||
targ = targetManagement.getByControllerID(targ.getControllerId()).get();
|
||||
|
||||
assertEquals("active target actions are wrong", 0,
|
||||
deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements());
|
||||
@@ -863,7 +861,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertEquals("active actions are wrong", 1,
|
||||
deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements());
|
||||
assertEquals("target status is wrong", TargetUpdateStatus.PENDING,
|
||||
targetManagement.findTargetByControllerID(targ.getControllerId()).get().getUpdateStatus());
|
||||
targetManagement.getByControllerID(targ.getControllerId()).get().getUpdateStatus());
|
||||
assertEquals("wrong assigned ds", dsB,
|
||||
deploymentManagement.getAssignedDistributionSet(targ.getControllerId()).get());
|
||||
assertEquals("Installed ds is wrong", dsA.getId(),
|
||||
@@ -881,13 +879,13 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createDistributionSet("b");
|
||||
final Target targ = testdataFactory.createTarget("target-id-A");
|
||||
|
||||
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong").isEqualTo(
|
||||
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong")
|
||||
.isEqualTo(distributionSetManagement.getWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||
|
||||
assignDistributionSet(dsA, Arrays.asList(targ));
|
||||
|
||||
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong").isEqualTo(
|
||||
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong")
|
||||
.isEqualTo(distributionSetManagement.getWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1004,9 +1002,9 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(event.getActionId()).as("Action id in database and event do not match")
|
||||
.isEqualTo(activeActionsByTarget.get(0).getId());
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetById(event.getDistributionSetId()).get()
|
||||
.getModules()).as("softwaremodule size is not correct")
|
||||
.containsOnly(ds.getModules().toArray(new SoftwareModule[ds.getModules().size()]));
|
||||
assertThat(distributionSetManagement.get(event.getDistributionSetId()).get().getModules())
|
||||
.as("softwaremodule size is not correct")
|
||||
.containsOnly(ds.getModules().toArray(new SoftwareModule[ds.getModules().size()]));
|
||||
}
|
||||
}
|
||||
assertThat(found).as("No event found for controller " + myt.getControllerId()).isTrue();
|
||||
|
||||
@@ -73,11 +73,10 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
final DistributionSet set = testdataFactory.createDistributionSet();
|
||||
assertThat(distributionSetManagement.findDistributionSetById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetManagement.findDistributionSetByNameAndVersion(NOT_EXIST_ID, NOT_EXIST_ID))
|
||||
.isNotPresent();
|
||||
assertThat(distributionSetManagement.findDistributionSetMetadata(set.getId(), NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetManagement.getWithDetails(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetManagement.getByNameAndVersion(NOT_EXIST_ID, NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetManagement.getMetaDataByDistributionSetId(set.getId(), NOT_EXIST_ID)).isNotPresent();
|
||||
|
||||
}
|
||||
|
||||
@@ -99,6 +98,8 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
() -> distributionSetManagement.assignSoftwareModules(set.getId(), Arrays.asList(NOT_EXIST_IDL)),
|
||||
"SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.countByTypeId(NOT_EXIST_IDL), "DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.unassignSoftwareModule(NOT_EXIST_IDL, module.getId()),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.unassignSoftwareModule(set.getId(), NOT_EXIST_IDL),
|
||||
@@ -110,10 +111,8 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.assignTag(Arrays.asList(NOT_EXIST_IDL), dsTag.getId()),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findDistributionSetsByTag(PAGE, NOT_EXIST_IDL),
|
||||
"DistributionSetTag");
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetManagement.findDistributionSetsByTag(PAGE, "name==*", NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findByTag(PAGE, NOT_EXIST_IDL), "DistributionSetTag");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findByRsqlAndTag(PAGE, "name==*", NOT_EXIST_IDL),
|
||||
"DistributionSetTag");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
@@ -131,47 +130,44 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("xxx").type(NOT_EXIST_ID)),
|
||||
.create(entityFactory.distributionSet().create().name("xxx").type(NOT_EXIST_ID)),
|
||||
"DistributionSetType");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.createDistributionSetMetadata(NOT_EXIST_IDL,
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.createMetaData(NOT_EXIST_IDL,
|
||||
Arrays.asList(entityFactory.generateMetadata("123", "123"))), "DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.deleteDistributionSet(Arrays.asList(NOT_EXIST_IDL)),
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.delete(Arrays.asList(NOT_EXIST_IDL)),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.deleteDistributionSet(NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.delete(NOT_EXIST_IDL), "DistributionSet");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.deleteMetaData(NOT_EXIST_IDL, "xxx"),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.deleteDistributionSetMetadata(NOT_EXIST_IDL, "xxx"),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetManagement.deleteDistributionSetMetadata(set.getId(), NOT_EXIST_ID),
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.deleteMetaData(set.getId(), NOT_EXIST_ID),
|
||||
"DistributionSetMetadata");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findDistributionSetByAction(NOT_EXIST_IDL), "Action");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.getByAction(NOT_EXIST_IDL), "Action");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findDistributionSetMetadata(NOT_EXIST_IDL, "xxx"),
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.getMetaDataByDistributionSetId(NOT_EXIST_IDL, "xxx"),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findMetaDataByDistributionSetId(PAGE, NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetManagement.findDistributionSetMetadataByDistributionSetId(NOT_EXIST_IDL, PAGE),
|
||||
() -> distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement
|
||||
.findDistributionSetMetadataByDistributionSetId(NOT_EXIST_IDL, "name==*", PAGE), "DistributionSet");
|
||||
|
||||
assertThatThrownBy(() -> distributionSetManagement.isDistributionSetInUse(NOT_EXIST_IDL))
|
||||
assertThatThrownBy(() -> distributionSetManagement.isInUse(NOT_EXIST_IDL))
|
||||
.isInstanceOf(EntityNotFoundException.class).hasMessageContaining(NOT_EXIST_ID)
|
||||
.hasMessageContaining("DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(NOT_EXIST_IDL)),
|
||||
() -> distributionSetManagement.update(entityFactory.distributionSet().update(NOT_EXIST_IDL)),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.updateDistributionSetMetadata(NOT_EXIST_IDL,
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.updateMetaData(NOT_EXIST_IDL,
|
||||
entityFactory.generateMetadata("xxx", "xxx")), "DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.updateDistributionSetMetadata(set.getId(),
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.updateMetaData(set.getId(),
|
||||
entityFactory.generateMetadata(NOT_EXIST_ID, "xxx")), "DistributionSetMetadata");
|
||||
}
|
||||
|
||||
@@ -192,13 +188,13 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createAndUpdateDistributionSetWithInvalidDescription(final DistributionSet set) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
.create().name("a").version("a").description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a")
|
||||
.version("a").description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("entity with too long description should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
||||
.update(set.getId()).description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||
.description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("entity with too long description should not be updated");
|
||||
|
||||
}
|
||||
@@ -207,23 +203,21 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createAndUpdateDistributionSetWithInvalidName(final DistributionSet set) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
.create().version("a").name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().version("a")
|
||||
.name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("entity with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||
() -> distributionSetManagement.create(entityFactory.distributionSet().create().version("a").name("")))
|
||||
.as("entity with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().version("a").name("")))
|
||||
.as("entity with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
||||
.update(set.getId()).name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||
.name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("entity with too long name should not be updated");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(set.getId()).name("")))
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||
() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId()).name("")))
|
||||
.as("entity with too short name should not be updated");
|
||||
|
||||
}
|
||||
@@ -232,23 +226,21 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createAndUpdateDistributionSetWithInvalidVersion(final DistributionSet set) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
.create().name("a").version(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a")
|
||||
.version(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("entity with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||
() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a").version("")))
|
||||
.as("entity with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("a").version("")))
|
||||
.as("entity with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
||||
.update(set.getId()).version(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||
.version(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("entity with too long name should not be updated");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(set.getId()).version("")))
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||
() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId()).version("")))
|
||||
.as("entity with too short name should not be updated");
|
||||
|
||||
}
|
||||
@@ -266,7 +258,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Verifies that a DS is of default type if not specified explicitly at creation time.")
|
||||
public void createDistributionSetWithImplicitType() {
|
||||
final DistributionSet set = distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("newtypesoft").version("1"));
|
||||
.create(entityFactory.distributionSet().create().name("newtypesoft").version("1"));
|
||||
|
||||
assertThat(set.getType()).as("Type should be equal to default type of tenant")
|
||||
.isEqualTo(systemManagement.getTenantMetadata().getDefaultDsType());
|
||||
@@ -276,11 +268,10 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Verifies that a DS cannot be created if another DS with same name and version exists.")
|
||||
public void createDistributionSetWithDuplicateNameAndVersionFails() {
|
||||
distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("newtypesoft").version("1"));
|
||||
distributionSetManagement.create(entityFactory.distributionSet().create().name("newtypesoft").version("1"));
|
||||
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class).isThrownBy(() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("newtypesoft").version("1")));
|
||||
.create(entityFactory.distributionSet().create().name("newtypesoft").version("1")));
|
||||
|
||||
}
|
||||
|
||||
@@ -293,7 +284,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
creates.add(entityFactory.distributionSet().create().name("newtypesoft" + i).version("1" + i));
|
||||
}
|
||||
|
||||
final List<DistributionSet> sets = distributionSetManagement.createDistributionSets(creates);
|
||||
final List<DistributionSet> sets = distributionSetManagement.create(creates);
|
||||
|
||||
assertThat(sets).as("Type should be equal to default type of tenant").are(new Condition<DistributionSet>() {
|
||||
@Override
|
||||
@@ -330,33 +321,30 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
assignDS.add(testdataFactory.createDistributionSet("DS" + i, "1.0", Collections.emptyList()).getId());
|
||||
}
|
||||
|
||||
final DistributionSetTag tag = tagManagement
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("Tag1"));
|
||||
final DistributionSetTag tag = distributionSetTagManagement.create(entityFactory.tag().create().name("Tag1"));
|
||||
|
||||
final List<DistributionSet> assignedDS = distributionSetManagement.assignTag(assignDS, tag.getId());
|
||||
assertThat(assignedDS.size()).as("assigned ds has wrong size").isEqualTo(4);
|
||||
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();
|
||||
DistributionSetTag findDistributionSetTag = distributionSetTagManagement.getByName("Tag1").get();
|
||||
|
||||
assertThat(assignedDS.size()).as("assigned ds has wrong size").isEqualTo(
|
||||
distributionSetManagement.findDistributionSetsByTag(PAGE, tag.getId()).getNumberOfElements());
|
||||
assertThat(assignedDS.size()).as("assigned ds has wrong size")
|
||||
.isEqualTo(distributionSetManagement.findByTag(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(distributionSetManagement.findDistributionSetsByTag(PAGE, tag.getId()).getNumberOfElements())
|
||||
findDistributionSetTag = distributionSetTagManagement.getByName("Tag1").get();
|
||||
assertThat(distributionSetManagement.findByTag(PAGE, tag.getId()).getNumberOfElements())
|
||||
.as("ds tag ds has wrong ds size").isEqualTo(3);
|
||||
|
||||
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);
|
||||
assertThat(distributionSetManagement.findByRsqlAndTag(PAGE, "name==" + unAssignDS.getName(), tag.getId())
|
||||
.getNumberOfElements()).as("ds tag ds has wrong ds size").isEqualTo(0);
|
||||
assertThat(distributionSetManagement.findByRsqlAndTag(PAGE, "name!=" + unAssignDS.getName(), tag.getId())
|
||||
.getNumberOfElements()).as("ds tag ds has wrong ds size").isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -375,7 +363,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// assign target
|
||||
assignDistributionSet(ds.getId(), target.getControllerId());
|
||||
ds = distributionSetManagement.findDistributionSetByIdWithDetails(ds.getId()).get();
|
||||
ds = distributionSetManagement.getWithDetails(ds.getId()).get();
|
||||
|
||||
final Long dsId = ds.getId();
|
||||
// not allowed as it is assigned now
|
||||
@@ -392,14 +380,13 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Ensures that it is not possible to add a software module that is not defined of the DS's type.")
|
||||
public void updateDistributionSetUnsupportedModuleFails() {
|
||||
final DistributionSet set = distributionSetManagement
|
||||
.createDistributionSet(
|
||||
entityFactory.distributionSet().create().name("agent-hub2").version("1.0.5")
|
||||
.type(distributionSetTypeManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create()
|
||||
.key("test").name("test").mandatory(Arrays.asList(osType.getId())))
|
||||
.getKey()));
|
||||
.create(entityFactory.distributionSet().create().name("agent-hub2")
|
||||
.version(
|
||||
"1.0.5")
|
||||
.type(distributionSetTypeManagement.create(entityFactory.distributionSetType().create()
|
||||
.key("test").name("test").mandatory(Arrays.asList(osType.getId()))).getKey()));
|
||||
|
||||
final SoftwareModule module = softwareModuleManagement.createSoftwareModule(
|
||||
final SoftwareModule module = softwareModuleManagement.create(
|
||||
entityFactory.softwareModule().create().name("agent-hub2").version("1.0.5").type(appType.getKey()));
|
||||
|
||||
// update data
|
||||
@@ -418,19 +405,18 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
// update data
|
||||
// legal update of module addition
|
||||
distributionSetManagement.assignSoftwareModules(ds.getId(), Sets.newHashSet(os.getId()));
|
||||
ds = distributionSetManagement.findDistributionSetByIdWithDetails(ds.getId()).get();
|
||||
ds = distributionSetManagement.getWithDetails(ds.getId()).get();
|
||||
assertThat(ds.findFirstModuleByType(osType).get()).isEqualTo(os);
|
||||
|
||||
// legal update of module removal
|
||||
distributionSetManagement.unassignSoftwareModule(ds.getId(), ds.findFirstModuleByType(appType).get().getId());
|
||||
ds = distributionSetManagement.findDistributionSetByIdWithDetails(ds.getId()).get();
|
||||
ds = distributionSetManagement.getWithDetails(ds.getId()).get();
|
||||
assertThat(ds.findFirstModuleByType(appType).isPresent()).isFalse();
|
||||
|
||||
// Update description
|
||||
distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(ds.getId()).name("a new name")
|
||||
.description("a new description").version("a new version").requiredMigrationStep(true));
|
||||
ds = distributionSetManagement.findDistributionSetByIdWithDetails(ds.getId()).get();
|
||||
distributionSetManagement.update(entityFactory.distributionSet().update(ds.getId()).name("a new name")
|
||||
.description("a new description").version("a new version").requiredMigrationStep(true));
|
||||
ds = distributionSetManagement.getWithDetails(ds.getId()).get();
|
||||
assertThat(ds.getDescription()).isEqualTo("a new description");
|
||||
assertThat(ds.getName()).isEqualTo("a new name");
|
||||
assertThat(ds.getVersion()).isEqualTo("a new version");
|
||||
@@ -453,18 +439,18 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
// create an DS meta data entry
|
||||
createDistributionSetMetadata(ds.getId(), new JpaDistributionSetMetadata(knownKey, ds, knownValue));
|
||||
|
||||
DistributionSet changedLockRevisionDS = distributionSetManagement.findDistributionSetById(ds.getId()).get();
|
||||
DistributionSet changedLockRevisionDS = distributionSetManagement.get(ds.getId()).get();
|
||||
assertThat(changedLockRevisionDS.getOptLockRevision()).isEqualTo(2);
|
||||
|
||||
Thread.sleep(100);
|
||||
|
||||
// update the DS metadata
|
||||
final JpaDistributionSetMetadata updated = (JpaDistributionSetMetadata) distributionSetManagement
|
||||
.updateDistributionSetMetadata(ds.getId(), entityFactory.generateMetadata(knownKey, knownUpdateValue));
|
||||
.updateMetaData(ds.getId(), entityFactory.generateMetadata(knownKey, knownUpdateValue));
|
||||
// we are updating the sw meta data so also modifying the base software
|
||||
// module so opt lock
|
||||
// revision must be three
|
||||
changedLockRevisionDS = distributionSetManagement.findDistributionSetById(ds.getId()).get();
|
||||
changedLockRevisionDS = distributionSetManagement.get(ds.getId()).get();
|
||||
assertThat(changedLockRevisionDS.getOptLockRevision()).isEqualTo(3);
|
||||
assertThat(changedLockRevisionDS.getLastModifiedAt()).isGreaterThan(0L);
|
||||
|
||||
@@ -505,15 +491,19 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
.setIsDeleted(false).setIsComplete(true).setSelectDSWithNoTag(Boolean.FALSE);
|
||||
|
||||
// target first only has an assigned DS-three so check order correct
|
||||
final List<DistributionSet> tFirstPin = distributionSetManagement.findDistributionSetsAllOrderedByLinkTarget(
|
||||
PAGE, distributionSetFilterBuilder, tFirst.getControllerId()).getContent();
|
||||
final List<DistributionSet> tFirstPin = distributionSetManagement
|
||||
.findByFilterAndAssignedInstalledDsOrderedByLinkTarget(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(
|
||||
PAGE, distributionSetFilterBuilder, tSecond.getControllerId()).getContent();
|
||||
final List<DistributionSet> tSecondPin = distributionSetManagement
|
||||
.findByFilterAndAssignedInstalledDsOrderedByLinkTarget(PAGE, distributionSetFilterBuilder,
|
||||
tSecond.getControllerId())
|
||||
.getContent();
|
||||
assertThat(tSecondPin.get(0)).isEqualTo(dsSecond);
|
||||
assertThat(tSecondPin.get(1)).isEqualTo(dsFour);
|
||||
assertThat(tFirstPin).hasSize(10);
|
||||
@@ -522,35 +512,35 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("searches for distribution sets based on the various filter options, e.g. name, version, desc., tags.")
|
||||
public void searchDistributionSetsOnFilters() {
|
||||
DistributionSetTag dsTagA = tagManagement
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-A"));
|
||||
final DistributionSetTag dsTagB = tagManagement
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-B"));
|
||||
final DistributionSetTag dsTagC = tagManagement
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-C"));
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-D"));
|
||||
DistributionSetTag dsTagA = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("DistributionSetTag-A"));
|
||||
final DistributionSetTag dsTagB = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("DistributionSetTag-B"));
|
||||
final DistributionSetTag dsTagC = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("DistributionSetTag-C"));
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("DistributionSetTag-D"));
|
||||
|
||||
List<DistributionSet> ds5Group1 = testdataFactory.createDistributionSets("", 5);
|
||||
List<DistributionSet> dsGroup2 = testdataFactory.createDistributionSets("test2", 5);
|
||||
DistributionSet dsDeleted = testdataFactory.createDistributionSet("deleted");
|
||||
final DistributionSet dsInComplete = distributionSetManagement.createDistributionSet(entityFactory
|
||||
.distributionSet().create().name("notcomplete").version("1").type(standardDsType.getKey()));
|
||||
final DistributionSet dsInComplete = distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("notcomplete").version("1").type(standardDsType.getKey()));
|
||||
|
||||
DistributionSetType newType = distributionSetTypeManagement.createDistributionSetType(
|
||||
entityFactory.distributionSetType().create().key("foo").name("bar").description("test"));
|
||||
DistributionSetType newType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("foo").name("bar").description("test"));
|
||||
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(newType.getId(),
|
||||
Arrays.asList(osType.getId()));
|
||||
newType = distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(newType.getId(),
|
||||
Arrays.asList(appType.getId(), runtimeType.getId()));
|
||||
|
||||
final DistributionSet dsNewType = distributionSetManagement.createDistributionSet(
|
||||
final DistributionSet dsNewType = distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name("newtype").version("1").type(newType.getKey()).modules(
|
||||
dsDeleted.getModules().stream().map(SoftwareModule::getId).collect(Collectors.toList())));
|
||||
|
||||
assignDistributionSet(dsDeleted, testdataFactory.createTargets(5));
|
||||
distributionSetManagement.deleteDistributionSet(dsDeleted.getId());
|
||||
dsDeleted = distributionSetManagement.findDistributionSetById(dsDeleted.getId()).get();
|
||||
distributionSetManagement.delete(dsDeleted.getId());
|
||||
dsDeleted = distributionSetManagement.get(dsDeleted.getId()).get();
|
||||
|
||||
ds5Group1 = toggleTagAssignment(ds5Group1, dsTagA).getAssignedEntity();
|
||||
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName()).get();
|
||||
@@ -571,18 +561,18 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
expected.add(dsNewType);
|
||||
|
||||
assertThat(distributionSetManagement
|
||||
.findDistributionSetsByFilters(PAGE, getDistributionSetFilterBuilder().build()).getContent())
|
||||
.hasSize(13).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
.findByDistributionSetFilter(PAGE, getDistributionSetFilterBuilder().build()).getContent()).hasSize(13)
|
||||
.containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
DistributionSetFilterBuilder distributionSetFilterBuilder;
|
||||
|
||||
// search for not deleted
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.TRUE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(false);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(12);
|
||||
|
||||
// search for completed
|
||||
@@ -593,50 +583,50 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
expected.add(dsNewType);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(12).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.FALSE);
|
||||
expected = new ArrayList<>();
|
||||
expected.add(dsInComplete);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
// search for type
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(newType);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(12);
|
||||
|
||||
// search for text
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setSearchText("%test2");
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(5);
|
||||
|
||||
// search for tags
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagA.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(10);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagB.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(5);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
|
||||
.setTagNames(Arrays.asList(dsTagA.getName(), dsTagB.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(10);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
|
||||
.setTagNames(Arrays.asList(dsTagC.getName(), dsTagB.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(5);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagC.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
// combine deleted and complete
|
||||
@@ -647,23 +637,23 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setIsDeleted(Boolean.FALSE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(11).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
expected = Arrays.asList(dsInComplete);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.FALSE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
expected = Arrays.asList(dsDeleted);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setIsDeleted(Boolean.TRUE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.TRUE)
|
||||
.setIsComplete(Boolean.FALSE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
// combine deleted and complete and type
|
||||
@@ -672,57 +662,57 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
expected.addAll(dsGroup2);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.FALSE)
|
||||
.setIsComplete(Boolean.TRUE).setType(standardDsType);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(10).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
expected = Arrays.asList(dsDeleted);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setType(standardDsType).setIsDeleted(Boolean.TRUE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(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(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
expected = Arrays.asList(dsNewType);
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setType(newType);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
// combine deleted and complete and type and text
|
||||
expected = dsGroup2;
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setType(standardDsType).setSearchText("%test2");
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(5).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setIsDeleted(Boolean.TRUE).setType(standardDsType).setSearchText("%test2");
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType).setSearchText("%test2")
|
||||
.setIsComplete(false).setIsDeleted(false);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(newType).setSearchText("%test2")
|
||||
.setIsComplete(Boolean.TRUE).setIsDeleted(false);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
// combine deleted and complete and type and text and tag
|
||||
expected = dsGroup2;
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setType(standardDsType)
|
||||
.setSearchText("%test2").setTagNames(Arrays.asList(dsTagA.getName()));
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(5).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType).setSearchText("%test2")
|
||||
.setTagNames(Arrays.asList(dsTagA.getName())).setIsComplete(Boolean.FALSE).setIsDeleted(Boolean.FALSE);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getContent()).hasSize(0);
|
||||
|
||||
}
|
||||
@@ -736,8 +726,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void findDistributionSetsWithoutLazy() {
|
||||
testdataFactory.createDistributionSets(20);
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true))
|
||||
.hasSize(20);
|
||||
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(20);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -748,12 +737,10 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// delete a ds
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(2);
|
||||
distributionSetManagement.deleteDistributionSet(ds1.getId());
|
||||
distributionSetManagement.delete(ds1.getId());
|
||||
// not assigned so not marked as deleted but fully deleted
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(1);
|
||||
assertThat(distributionSetManagement
|
||||
.findDistributionSetsByDeletedAndOrCompleted(PAGE, Boolean.FALSE, Boolean.TRUE).getTotalElements())
|
||||
.isEqualTo(1);
|
||||
assertThat(distributionSetManagement.findByCompleted(PAGE, true).getTotalElements()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -776,10 +763,10 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
final Page<DistributionSetMetadata> metadataOfDs1 = distributionSetManagement
|
||||
.findDistributionSetMetadataByDistributionSetId(ds1.getId(), new PageRequest(0, 100));
|
||||
.findMetaDataByDistributionSetId(new PageRequest(0, 100), ds1.getId());
|
||||
|
||||
final Page<DistributionSetMetadata> metadataOfDs2 = distributionSetManagement
|
||||
.findDistributionSetMetadataByDistributionSetId(ds2.getId(), new PageRequest(0, 100));
|
||||
.findMetaDataByDistributionSetId(new PageRequest(0, 100), ds2.getId());
|
||||
|
||||
assertThat(metadataOfDs1.getNumberOfElements()).isEqualTo(10);
|
||||
assertThat(metadataOfDs1.getTotalElements()).isEqualTo(10);
|
||||
@@ -806,14 +793,11 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// delete assigned ds
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
||||
distributionSetManagement
|
||||
.deleteDistributionSet(Arrays.asList(dsToTargetAssigned.getId(), dsToRolloutAssigned.getId()));
|
||||
distributionSetManagement.delete(Arrays.asList(dsToTargetAssigned.getId(), dsToRolloutAssigned.getId()));
|
||||
|
||||
// not assigned so not marked as deleted
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
||||
assertThat(distributionSetManagement
|
||||
.findDistributionSetsByDeletedAndOrCompleted(PAGE, Boolean.FALSE, Boolean.TRUE).getTotalElements())
|
||||
.isEqualTo(2);
|
||||
assertThat(distributionSetManagement.findByCompleted(PAGE, true).getTotalElements()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -846,7 +830,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createDistributionSet("test" + i);
|
||||
}
|
||||
|
||||
final List<DistributionSet> foundDs = distributionSetManagement.findDistributionSetsById(searchIds);
|
||||
final List<DistributionSet> foundDs = distributionSetManagement.get(searchIds);
|
||||
|
||||
assertThat(foundDs).hasSize(3);
|
||||
|
||||
|
||||
@@ -18,20 +18,16 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
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.TargetTagUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.Tag;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.test.matcher.Expect;
|
||||
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
|
||||
import org.junit.Test;
|
||||
@@ -41,22 +37,20 @@ import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
/**
|
||||
* Test class for {@link TagManagement}.
|
||||
* {@link DistributionSetTagManagement} tests.
|
||||
*
|
||||
*/
|
||||
@Features("Component Tests - Repository")
|
||||
@Stories("Tag Management")
|
||||
public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Stories("DistributionSet Tag Management")
|
||||
public class DistributionSetTagManagementTest 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(tagManagement.findDistributionSetTag(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(tagManagement.findDistributionSetTagById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(tagManagement.findTargetTag(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(tagManagement.findTargetTagById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetTagManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetTagManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -65,18 +59,16 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
@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(() -> distributionSetTagManagement.delete(NOT_EXIST_ID),
|
||||
"DistributionSetTag");
|
||||
|
||||
verifyThrownExceptionBy(() -> tagManagement.findDistributionSetTagsByDistributionSet(PAGE, NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetTagManagement.findByDistributionSet(PAGE, NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> tagManagement.updateDistributionSetTag(entityFactory.tag().update(NOT_EXIST_IDL)),
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetTagManagement.update(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
|
||||
@@ -90,28 +82,33 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Collection<DistributionSet> dsBCs = testdataFactory.createDistributionSets("DS-BC", 13);
|
||||
final Collection<DistributionSet> dsABCs = testdataFactory.createDistributionSets("DS-ABC", 9);
|
||||
|
||||
final DistributionSetTag tagA = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("A"));
|
||||
final DistributionSetTag tagB = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("B"));
|
||||
final DistributionSetTag tagC = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("C"));
|
||||
final DistributionSetTag tagX = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("X"));
|
||||
final DistributionSetTag tagY = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("Y"));
|
||||
final DistributionSetTag tagA = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("A"));
|
||||
final DistributionSetTag tagB = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("B"));
|
||||
final DistributionSetTag tagC = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("C"));
|
||||
final DistributionSetTag tagX = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("X"));
|
||||
final DistributionSetTag tagY = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("Y"));
|
||||
|
||||
toggleTagAssignment(dsAs, tagA);
|
||||
toggleTagAssignment(dsBs, tagB);
|
||||
toggleTagAssignment(dsCs, tagC);
|
||||
|
||||
toggleTagAssignment(dsABs, tagManagement.findDistributionSetTag(tagA.getName()).get());
|
||||
toggleTagAssignment(dsABs, tagManagement.findDistributionSetTag(tagB.getName()).get());
|
||||
toggleTagAssignment(dsABs, distributionSetTagManagement.getByName(tagA.getName()).get());
|
||||
toggleTagAssignment(dsABs, distributionSetTagManagement.getByName(tagB.getName()).get());
|
||||
|
||||
toggleTagAssignment(dsACs, tagManagement.findDistributionSetTag(tagA.getName()).get());
|
||||
toggleTagAssignment(dsACs, tagManagement.findDistributionSetTag(tagC.getName()).get());
|
||||
toggleTagAssignment(dsACs, distributionSetTagManagement.getByName(tagA.getName()).get());
|
||||
toggleTagAssignment(dsACs, distributionSetTagManagement.getByName(tagC.getName()).get());
|
||||
|
||||
toggleTagAssignment(dsBCs, tagManagement.findDistributionSetTag(tagB.getName()).get());
|
||||
toggleTagAssignment(dsBCs, tagManagement.findDistributionSetTag(tagC.getName()).get());
|
||||
toggleTagAssignment(dsBCs, distributionSetTagManagement.getByName(tagB.getName()).get());
|
||||
toggleTagAssignment(dsBCs, distributionSetTagManagement.getByName(tagC.getName()).get());
|
||||
|
||||
toggleTagAssignment(dsABCs, tagManagement.findDistributionSetTag(tagA.getName()).get());
|
||||
toggleTagAssignment(dsABCs, tagManagement.findDistributionSetTag(tagB.getName()).get());
|
||||
toggleTagAssignment(dsABCs, tagManagement.findDistributionSetTag(tagC.getName()).get());
|
||||
toggleTagAssignment(dsABCs, distributionSetTagManagement.getByName(tagA.getName()).get());
|
||||
toggleTagAssignment(dsABCs, distributionSetTagManagement.getByName(tagB.getName()).get());
|
||||
toggleTagAssignment(dsABCs, distributionSetTagManagement.getByName(tagC.getName()).get());
|
||||
|
||||
DistributionSetFilterBuilder distributionSetFilterBuilder;
|
||||
|
||||
@@ -121,7 +118,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(PAGE, distributionSetFilterBuilder.build())
|
||||
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
@@ -129,7 +126,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(PAGE, distributionSetFilterBuilder.build())
|
||||
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
@@ -137,22 +134,22 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertEquals("filter works not correct",
|
||||
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
.setTagNames(Arrays.asList(tagX.getName()));
|
||||
assertEquals("filter works not correct", 0, distributionSetManagement
|
||||
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
|
||||
.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
|
||||
|
||||
assertEquals("wrong tag size", 5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
|
||||
tagManagement.deleteDistributionSetTag(tagY.getName());
|
||||
distributionSetTagManagement.delete(tagY.getName());
|
||||
assertEquals("wrong tag size", 4, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
tagManagement.deleteDistributionSetTag(tagX.getName());
|
||||
distributionSetTagManagement.delete(tagX.getName());
|
||||
assertEquals("wrong tag size", 3, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
|
||||
tagManagement.deleteDistributionSetTag(tagB.getName());
|
||||
distributionSetTagManagement.delete(tagB.getName());
|
||||
assertEquals("wrong tag size", 2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
@@ -160,27 +157,23 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertEquals("filter works not correct",
|
||||
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setTagNames(Arrays.asList(tagB.getName()));
|
||||
assertEquals("filter works not correct", 0, distributionSetManagement
|
||||
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
|
||||
.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setTagNames(Arrays.asList(tagC.getName()));
|
||||
assertEquals("filter works not correct",
|
||||
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
||||
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
}
|
||||
|
||||
private DistributionSetFilterBuilder getDistributionSetFilterBuilder() {
|
||||
return new DistributionSetFilterBuilder();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies the toogle mechanism by means on assigning tag if at least on DS in the list does not have"
|
||||
+ "the tag yet. Unassign if all of them have the tag already.")
|
||||
@@ -188,15 +181,15 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Collection<DistributionSet> groupA = testdataFactory.createDistributionSets(20);
|
||||
final Collection<DistributionSet> groupB = testdataFactory.createDistributionSets("unassigned", 20);
|
||||
|
||||
final DistributionSetTag tag = tagManagement
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
||||
final DistributionSetTag tag = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
||||
|
||||
// toggle A only -> A is now assigned
|
||||
DistributionSetTagAssignmentResult result = toggleTagAssignment(groupA, tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(distributionSetManagement
|
||||
.findDistributionSetsById(groupA.stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
||||
.get(groupA.stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
||||
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
||||
@@ -206,7 +199,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(distributionSetManagement
|
||||
.findDistributionSetsById(groupB.stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
||||
.get(groupB.stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
||||
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
||||
@@ -217,147 +210,24 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(result.getAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssignedEntity()).isEmpty();
|
||||
assertThat(result.getUnassigned()).isEqualTo(40);
|
||||
assertThat(result.getUnassignedEntity()).containsAll(distributionSetManagement.findDistributionSetsById(
|
||||
assertThat(result.getUnassignedEntity()).containsAll(distributionSetManagement.get(
|
||||
concat(groupB, groupA).stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
||||
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies the toogle mechanism by means on assigning tag if at least on target in the list does not have"
|
||||
+ "the tag yet. Unassign if all of them have the tag already.")
|
||||
public void assignAndUnassignTargetTags() {
|
||||
final List<Target> groupA = testdataFactory.createTargets(20);
|
||||
final List<Target> groupB = testdataFactory.createTargets(20, "groupb", "groupb");
|
||||
|
||||
final TargetTag tag = tagManagement
|
||||
.createTargetTag(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
||||
|
||||
// toggle A only -> A is now assigned
|
||||
TargetTagAssignmentResult result = toggleTagAssignment(groupA, tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(targetManagement.findTargetsByControllerID(
|
||||
groupA.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||
|
||||
// toggle A+B -> A is still assigned and B is assigned as well
|
||||
result = toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(targetManagement.findTargetsByControllerID(
|
||||
groupB.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||
|
||||
// toggle A+B -> both unassigned
|
||||
result = toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssignedEntity()).isEmpty();
|
||||
assertThat(result.getUnassigned()).isEqualTo(40);
|
||||
assertThat(result.getUnassignedEntity()).containsAll(targetManagement.findTargetsByControllerID(
|
||||
concat(groupB, groupA).stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
private final <T> Collection<T> concat(final Collection<T>... targets) {
|
||||
final List<T> result = new ArrayList<>();
|
||||
Arrays.asList(targets).forEach(result::addAll);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that all tags are retrieved through repository.")
|
||||
public void findAllTargetTags() {
|
||||
final List<JpaTargetTag> tags = createTargetsWithTags();
|
||||
|
||||
assertThat(targetTagRepository.findAll()).isEqualTo(targetTagRepository.findAll()).isEqualTo(tags)
|
||||
.as("Wrong tag size").hasSize(20);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a created tag is persisted in the repository as defined.")
|
||||
public void createTargetTag() {
|
||||
final Tag tag = tagManagement
|
||||
.createTargetTag(entityFactory.tag().create().name("kai1").description("kai2").colour("colour"));
|
||||
|
||||
assertThat(targetTagRepository.findByNameEquals("kai1").get().getDescription()).as("wrong tag ed")
|
||||
.isEqualTo("kai2");
|
||||
assertThat(tagManagement.findTargetTag("kai1").get().getColour()).as("wrong tag found").isEqualTo("colour");
|
||||
assertThat(tagManagement.findTargetTagById(tag.getId()).get().getColour()).as("wrong tag found")
|
||||
.isEqualTo("colour");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a deleted tag is removed from the repository as defined.")
|
||||
public void deleteTargetTags() {
|
||||
|
||||
// create test data
|
||||
final Iterable<JpaTargetTag> tags = createTargetsWithTags();
|
||||
final TargetTag toDelete = tags.iterator().next();
|
||||
|
||||
for (final Target target : targetRepository.findAll()) {
|
||||
assertThat(tagManagement.findAllTargetTags(PAGE, target.getControllerId()).getContent())
|
||||
.contains(toDelete);
|
||||
}
|
||||
|
||||
// delete
|
||||
tagManagement.deleteTargetTag(toDelete.getName());
|
||||
|
||||
// check
|
||||
for (final Target target : targetRepository.findAll()) {
|
||||
assertThat(tagManagement.findAllTargetTags(PAGE, target.getControllerId()).getContent())
|
||||
.doesNotContain(toDelete);
|
||||
}
|
||||
assertThat(targetTagRepository.findOne(toDelete.getId())).as("No tag should be found").isNull();
|
||||
assertThat(targetTagRepository.findAll()).as("Wrong target tag size").hasSize(19);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the name update of a target tag.")
|
||||
public void updateTargetTag() {
|
||||
final List<JpaTargetTag> tags = createTargetsWithTags();
|
||||
|
||||
// change data
|
||||
final TargetTag savedAssigned = tags.iterator().next();
|
||||
|
||||
// persist
|
||||
tagManagement.updateTargetTag(entityFactory.tag().update(savedAssigned.getId()).name("test123"));
|
||||
|
||||
// check data
|
||||
assertThat(targetTagRepository.findAll()).as("Wrong target tag size").hasSize(tags.size());
|
||||
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getName()).as("wrong target tag is saved")
|
||||
.isEqualTo("test123");
|
||||
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getOptLockRevision())
|
||||
.as("wrong target tag is saved").isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a created tag is persisted in the repository as defined.")
|
||||
public void createDistributionSetTag() {
|
||||
final Tag tag = tagManagement.createDistributionSetTag(
|
||||
final Tag tag = distributionSetTagManagement.create(
|
||||
entityFactory.tag().create().name("kai1").description("kai2").colour("colour"));
|
||||
|
||||
assertThat(distributionSetTagRepository.findByNameEquals("kai1").get().getDescription()).as("wrong tag found")
|
||||
.isEqualTo("kai2");
|
||||
assertThat(tagManagement.findDistributionSetTag("kai1").get().getColour()).as("wrong tag found")
|
||||
assertThat(distributionSetTagManagement.getByName("kai1").get().getColour()).as("wrong tag found")
|
||||
.isEqualTo("colour");
|
||||
assertThat(tagManagement.findDistributionSetTagById(tag.getId()).get().getColour()).as("wrong tag found")
|
||||
.isEqualTo("colour");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a created tags are persisted in the repository as defined.")
|
||||
public void createDistributionSetTags() {
|
||||
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
||||
|
||||
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags created").hasSize(tags.size());
|
||||
assertThat(distributionSetTagManagement.get(tag.getId()).get().getColour())
|
||||
.as("wrong tag found").isEqualTo("colour");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -373,11 +243,11 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
// delete
|
||||
tagManagement.deleteDistributionSetTag(tags.iterator().next().getName());
|
||||
distributionSetTagManagement.delete(tags.iterator().next().getName());
|
||||
|
||||
// check
|
||||
assertThat(distributionSetTagRepository.findOne(toDelete.getId())).as("Deleted tag should be null").isNull();
|
||||
assertThat(tagManagement.findAllDistributionSetTags(PAGE).getContent())
|
||||
assertThat(distributionSetTagManagement.findAll(PAGE).getContent())
|
||||
.as("Wrong size of tags after deletion").hasSize(19);
|
||||
|
||||
for (final DistributionSet set : distributionSetRepository.findAll()) {
|
||||
@@ -386,39 +256,12 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
|
||||
public void failedDuplicateTargetTagNameException() {
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("A"));
|
||||
|
||||
try {
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("A"));
|
||||
fail("should not have worked as tag already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
|
||||
public void failedDuplicateTargetTagNameExceptionAfterUpdate() {
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("A"));
|
||||
final TargetTag tag = tagManagement.createTargetTag(entityFactory.tag().create().name("B"));
|
||||
|
||||
try {
|
||||
tagManagement.updateTargetTag(entityFactory.tag().update(tag.getId()).name("A"));
|
||||
fail("should not have worked as tag already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
|
||||
public void failedDuplicateDsTagNameException() {
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("A"));
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
try {
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("A"));
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
fail("should not have worked as tag already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
@@ -428,11 +271,12 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
|
||||
public void failedDuplicateDsTagNameExceptionAfterUpdate() {
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("A"));
|
||||
final DistributionSetTag tag = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("B"));
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
final DistributionSetTag tag = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("B"));
|
||||
|
||||
try {
|
||||
tagManagement.updateDistributionSetTag(entityFactory.tag().update(tag.getId()).name("A"));
|
||||
distributionSetTagManagement.update(entityFactory.tag().update(tag.getId()).name("A"));
|
||||
fail("should not have worked as tag already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
@@ -450,11 +294,12 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSetTag savedAssigned = tags.iterator().next();
|
||||
|
||||
// persist
|
||||
tagManagement.updateDistributionSetTag(entityFactory.tag().update(savedAssigned.getId()).name("test123"));
|
||||
distributionSetTagManagement
|
||||
.update(entityFactory.tag().update(savedAssigned.getId()).name("test123"));
|
||||
|
||||
// check data
|
||||
assertThat(tagManagement.findAllDistributionSetTags(PAGE).getContent()).as("Wrong size of ds tags")
|
||||
.hasSize(tags.size());
|
||||
assertThat(distributionSetTagManagement.findAll(PAGE).getContent())
|
||||
.as("Wrong size of ds tags").hasSize(tags.size());
|
||||
assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).as("Wrong ds tag found")
|
||||
.isEqualTo("test123");
|
||||
}
|
||||
@@ -465,18 +310,17 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
||||
|
||||
// test
|
||||
assertThat(tagManagement.findAllDistributionSetTags(PAGE).getContent()).as("Wrong size of tags")
|
||||
assertThat(distributionSetTagManagement.findAll(PAGE).getContent()).as("Wrong size of tags")
|
||||
.hasSize(tags.size());
|
||||
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags").hasSize(20);
|
||||
}
|
||||
|
||||
private List<JpaTargetTag> createTargetsWithTags() {
|
||||
final List<Target> targets = testdataFactory.createTargets(20);
|
||||
final Iterable<TargetTag> tags = testdataFactory.createTargetTags(20, "");
|
||||
@Test
|
||||
@Description("Ensures that a created tags are persisted in the repository as defined.")
|
||||
public void createDistributionSetTags() {
|
||||
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
||||
|
||||
tags.forEach(tag -> toggleTagAssignment(targets, tag));
|
||||
|
||||
return targetTagRepository.findAll();
|
||||
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags created").hasSize(tags.size());
|
||||
}
|
||||
|
||||
private List<DistributionSetTag> createDsSetsWithTags() {
|
||||
@@ -486,6 +330,18 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
tags.forEach(tag -> toggleTagAssignment(sets, tag));
|
||||
|
||||
return tagManagement.findAllDistributionSetTags(PAGE).getContent();
|
||||
return distributionSetTagManagement.findAll(PAGE).getContent();
|
||||
}
|
||||
|
||||
private DistributionSetFilterBuilder getDistributionSetFilterBuilder() {
|
||||
return new DistributionSetFilterBuilder();
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
private final <T> Collection<T> concat(final Collection<T>... targets) {
|
||||
final List<T> result = new ArrayList<>();
|
||||
Arrays.asList(targets).forEach(result::addAll);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,9 +48,9 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
+ "of Optional not present.")
|
||||
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 0) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.getByKey(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,15 +71,10 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
testdataFactory.findOrCreateDistributionSetType("xxx", "xxx").getId(), Arrays.asList(NOT_EXIST_IDL)),
|
||||
"SoftwareModuleType");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetTypeManagement.countDistributionSetsByType(NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetTypeManagement.deleteDistributionSetType(NOT_EXIST_IDL),
|
||||
"DistributionSetType");
|
||||
verifyThrownExceptionBy(() -> distributionSetTypeManagement.delete(NOT_EXIST_IDL), "DistributionSetType");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetTypeManagement
|
||||
.updateDistributionSetType(entityFactory.distributionSetType().update(NOT_EXIST_IDL)),
|
||||
() -> distributionSetTypeManagement.update(entityFactory.distributionSetType().update(NOT_EXIST_IDL)),
|
||||
"DistributionSet");
|
||||
}
|
||||
|
||||
@@ -100,12 +95,12 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
private void createAndUpdateDistributionSetWithInvalidDescription(final DistributionSet set) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet()
|
||||
.create().name("a").version("a").description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("set with too long description should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet()
|
||||
.update(set.getId()).description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("set with too long description should not be updated");
|
||||
|
||||
@@ -115,28 +110,28 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
private void createAndUpdateDistributionSetWithInvalidName(final DistributionSet set) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet()
|
||||
.create().version("a").name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("set with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().version("a").name("")))
|
||||
.create(entityFactory.distributionSet().create().version("a").name("")))
|
||||
.as("set with too short name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().version("a").name(null)))
|
||||
.create(entityFactory.distributionSet().create().version("a").name(null)))
|
||||
.as("set with null name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet()
|
||||
.update(set.getId()).name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("set with too long name should not be updated");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(set.getId()).name("")))
|
||||
.update(entityFactory.distributionSet().update(set.getId()).name("")))
|
||||
.as("set with too short name should not be updated");
|
||||
}
|
||||
|
||||
@@ -144,85 +139,80 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
private void createAndUpdateDistributionSetWithInvalidVersion(final DistributionSet set) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet()
|
||||
.create().name("a").version(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("set with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("a").version("")))
|
||||
.create(entityFactory.distributionSet().create().name("a").version("")))
|
||||
.as("set with too short name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("a").version(null)))
|
||||
.create(entityFactory.distributionSet().create().name("a").version(null)))
|
||||
.as("set with null name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet()
|
||||
.update(set.getId()).version(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("set with too long name should not be updated");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(set.getId()).version("")))
|
||||
.update(entityFactory.distributionSet().update(set.getId()).version("")))
|
||||
.as("set with too short name should not be updated");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the successfull module update of unused distribution set type which is in fact allowed.")
|
||||
public void updateUnassignedDistributionSetTypeModules() {
|
||||
final DistributionSetType updatableType = distributionSetTypeManagement.createDistributionSetType(
|
||||
entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get()
|
||||
.getMandatoryModuleTypes()).isEmpty();
|
||||
final DistributionSetType updatableType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
|
||||
// add OS
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(),
|
||||
Sets.newHashSet(osType.getId()));
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get()
|
||||
.getMandatoryModuleTypes()).containsOnly(osType);
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
|
||||
.containsOnly(osType);
|
||||
|
||||
// add JVM
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(),
|
||||
Sets.newHashSet(runtimeType.getId()));
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get()
|
||||
.getMandatoryModuleTypes()).containsOnly(osType, runtimeType);
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
|
||||
.containsOnly(osType, runtimeType);
|
||||
|
||||
// remove OS
|
||||
distributionSetTypeManagement.unassignSoftwareModuleType(updatableType.getId(), osType.getId());
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get()
|
||||
.getMandatoryModuleTypes()).containsOnly(runtimeType);
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
|
||||
.containsOnly(runtimeType);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the successfull update of used distribution set type meta data which is in fact allowed.")
|
||||
public void updateAssignedDistributionSetTypeMetaData() {
|
||||
final DistributionSetType nonUpdatableType = distributionSetTypeManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("updatableType")
|
||||
.name("to be deleted").colour("test123"));
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get()
|
||||
.getMandatoryModuleTypes()).isEmpty();
|
||||
distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create().name("newtypesoft")
|
||||
final DistributionSetType nonUpdatableType = distributionSetTypeManagement.create(entityFactory
|
||||
.distributionSetType().create().key("updatableType").name("to be deleted").colour("test123"));
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
distributionSetManagement.create(entityFactory.distributionSet().create().name("newtypesoft")
|
||||
.version("1").type(nonUpdatableType.getKey()));
|
||||
|
||||
distributionSetTypeManagement.updateDistributionSetType(
|
||||
distributionSetTypeManagement.update(
|
||||
entityFactory.distributionSetType().update(nonUpdatableType.getId()).description("a new description"));
|
||||
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get().getDescription())
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getDescription())
|
||||
.isEqualTo("a new description");
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get().getColour())
|
||||
.isEqualTo("test123");
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getColour()).isEqualTo("test123");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the unsuccessfull update of used distribution set type (module addition).")
|
||||
public void addModuleToAssignedDistributionSetTypeFails() {
|
||||
final DistributionSetType nonUpdatableType = distributionSetTypeManagement.createDistributionSetType(
|
||||
entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get()
|
||||
.getMandatoryModuleTypes()).isEmpty();
|
||||
distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create().name("newtypesoft")
|
||||
final DistributionSetType nonUpdatableType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
distributionSetManagement.create(entityFactory.distributionSet().create().name("newtypesoft")
|
||||
.version("1").type(nonUpdatableType.getKey()));
|
||||
|
||||
assertThatThrownBy(() -> distributionSetTypeManagement
|
||||
@@ -233,14 +223,13 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
@Test
|
||||
@Description("Tests the unsuccessfull update of used distribution set type (module removal).")
|
||||
public void removeModuleToAssignedDistributionSetTypeFails() {
|
||||
DistributionSetType nonUpdatableType = distributionSetTypeManagement.createDistributionSetType(
|
||||
entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("updatableType").get()
|
||||
.getMandatoryModuleTypes()).isEmpty();
|
||||
DistributionSetType nonUpdatableType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
|
||||
nonUpdatableType = distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(nonUpdatableType.getId(),
|
||||
Sets.newHashSet(osType.getId()));
|
||||
distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create().name("newtypesoft")
|
||||
distributionSetManagement.create(entityFactory.distributionSet().create().name("newtypesoft")
|
||||
.version("1").type(nonUpdatableType.getKey()));
|
||||
|
||||
final Long typeId = nonUpdatableType.getId();
|
||||
@@ -252,11 +241,10 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
@Description("Tests the successfull deletion of unused (hard delete) distribution set types.")
|
||||
public void deleteUnassignedDistributionSetType() {
|
||||
final JpaDistributionSetType hardDelete = (JpaDistributionSetType) distributionSetTypeManagement
|
||||
.createDistributionSetType(
|
||||
entityFactory.distributionSetType().create().key("delete").name("to be deleted"));
|
||||
.create(entityFactory.distributionSetType().create().key("delete").name("to be deleted"));
|
||||
|
||||
assertThat(distributionSetTypeRepository.findAll()).contains(hardDelete);
|
||||
distributionSetTypeManagement.deleteDistributionSetType(hardDelete.getId());
|
||||
distributionSetTypeManagement.delete(hardDelete.getId());
|
||||
|
||||
assertThat(distributionSetTypeRepository.findAll()).doesNotContain(hardDelete);
|
||||
}
|
||||
@@ -265,16 +253,14 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
@Description("Tests the successfull deletion of used (soft delete) distribution set types.")
|
||||
public void deleteAssignedDistributionSetType() {
|
||||
final JpaDistributionSetType softDelete = (JpaDistributionSetType) distributionSetTypeManagement
|
||||
.createDistributionSetType(
|
||||
entityFactory.distributionSetType().create().key("softdeleted").name("to be deleted"));
|
||||
.create(entityFactory.distributionSetType().create().key("softdeleted").name("to be deleted"));
|
||||
|
||||
assertThat(distributionSetTypeRepository.findAll()).contains(softDelete);
|
||||
distributionSetManagement.createDistributionSet(
|
||||
distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name("softdeleted").version("1").type(softDelete.getKey()));
|
||||
|
||||
distributionSetTypeManagement.deleteDistributionSetType(softDelete.getId());
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypeByKey("softdeleted").get().isDeleted())
|
||||
.isEqualTo(true);
|
||||
distributionSetTypeManagement.delete(softDelete.getId());
|
||||
assertThat(distributionSetTypeManagement.getByKey("softdeleted").get().isDeleted()).isEqualTo(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ public class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
|
||||
+ "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();
|
||||
assertThat(rolloutGroupManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(rolloutGroupManagement.getWithDetailedStatus(NOT_EXIST_IDL)).isNotPresent();
|
||||
|
||||
}
|
||||
|
||||
@@ -52,19 +52,19 @@ public class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
testdataFactory.createRollout("xxx");
|
||||
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.countRolloutGroupsByRolloutId(NOT_EXIST_IDL), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.countByRollout(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),
|
||||
() -> rolloutGroupManagement.findByRolloutWithDetailedStatus(PAGE, NOT_EXIST_IDL), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findAllTargetsOfRolloutGroupWithActionStatus(PAGE, NOT_EXIST_IDL),
|
||||
"RolloutGroup");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findRolloutGroupsAll(NOT_EXIST_IDL, "name==*", PAGE),
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findByRolloutAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"Rollout");
|
||||
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findRolloutGroupTargets(NOT_EXIST_IDL, PAGE),
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findTargetsOfRolloutGroup(PAGE, NOT_EXIST_IDL),
|
||||
"RolloutGroup");
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findRolloutGroupTargets(NOT_EXIST_IDL, "name==*", PAGE),
|
||||
verifyThrownExceptionBy(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"RolloutGroup");
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
// start rollout
|
||||
final Rollout rollout = testdataFactory.createRolloutByVariables("rolloutNotCancelRunningAction", "description",
|
||||
1, "name==*", knownDistributionSet, "50", "5");
|
||||
rolloutManagement.startRollout(rollout.getId());
|
||||
rolloutManagement.start(rollout.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
// verify that manually created action is still running and action
|
||||
@@ -124,9 +124,9 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
+ "of Optional not present.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(rolloutManagement.findRolloutById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(rolloutManagement.findRolloutByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(rolloutManagement.findRolloutWithDetailedStatus(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(rolloutManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(rolloutManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(rolloutManagement.getWithDetailedStatus(NOT_EXIST_IDL)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -142,13 +142,13 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
testdataFactory.createRollout("xxx");
|
||||
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.deleteRollout(NOT_EXIST_IDL), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.delete(NOT_EXIST_IDL), "Rollout");
|
||||
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.pauseRollout(NOT_EXIST_IDL), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.resumeRollout(NOT_EXIST_IDL), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.startRollout(NOT_EXIST_IDL), "Rollout");
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.start(NOT_EXIST_IDL), "Rollout");
|
||||
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.updateRollout(entityFactory.rollout().update(NOT_EXIST_IDL)),
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.update(entityFactory.rollout().update(NOT_EXIST_IDL)),
|
||||
"Rollout");
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// verify the split of the target and targetGroup
|
||||
final Page<RolloutGroup> rolloutGroups = rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(createdRollout.getId(), PAGE);
|
||||
.findByRollout(PAGE, createdRollout.getId());
|
||||
// we have total of #amountTargetsForRollout in rollouts splitted in
|
||||
// group size #groupSize
|
||||
assertThat(rolloutGroups).hasSize(amountGroups);
|
||||
@@ -183,13 +183,13 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
successCondition, errorCondition);
|
||||
|
||||
// verify first group is running
|
||||
final RolloutGroup firstGroup = rolloutGroupManagement.findRolloutGroupsByRolloutId(createdRollout.getId(),
|
||||
new OffsetBasedPageRequest(0, 1, new Sort(Direction.ASC, "id"))).getContent().get(0);
|
||||
final RolloutGroup firstGroup = rolloutGroupManagement.findByRollout(new OffsetBasedPageRequest(0, 1, new Sort(Direction.ASC, "id")),
|
||||
createdRollout.getId()).getContent().get(0);
|
||||
assertThat(firstGroup.getStatus()).isEqualTo(RolloutGroupStatus.RUNNING);
|
||||
|
||||
// verify other groups are scheduled
|
||||
final List<RolloutGroup> scheduledGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(1, 100, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> scheduledGroups = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(1, 100, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
scheduledGroups.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.SCHEDULED)
|
||||
.as("group which should be in scheduled state is in " + group.getStatus() + " state"));
|
||||
// verify that the first group actions has been started and are in state
|
||||
@@ -224,15 +224,15 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
// verify that now the first and the second group are in running state
|
||||
final List<RolloutGroup> runningRolloutGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(0, 2, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> runningRolloutGroups = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(0, 2, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
runningRolloutGroups.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.RUNNING)
|
||||
.as("group should be in running state because it should be started but it is in " + group.getStatus()
|
||||
+ " state"));
|
||||
|
||||
// verify that the other groups are still in schedule state
|
||||
final List<RolloutGroup> scheduledRolloutGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(2, 10, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> scheduledRolloutGroups = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(2, 10, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
scheduledRolloutGroups.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.SCHEDULED)
|
||||
.as("group should be in scheduled state because it should not be started but it is in "
|
||||
+ group.getStatus() + " state"));
|
||||
@@ -269,12 +269,12 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final Rollout createdRollout = createSimpleTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout,
|
||||
amountOtherTargets, amountGroups, successCondition, errorCondition);
|
||||
rolloutManagement.startRollout(createdRollout.getId());
|
||||
rolloutManagement.start(createdRollout.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
return rolloutManagement.findRolloutById(createdRollout.getId()).get();
|
||||
return rolloutManagement.get(createdRollout.getId()).get();
|
||||
}
|
||||
|
||||
@Step("Finish three actions of the rollout group and delete two targets")
|
||||
@@ -286,15 +286,15 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
finishAction(runningActions.get(0));
|
||||
finishAction(runningActions.get(1));
|
||||
finishAction(runningActions.get(2));
|
||||
targetManagement.deleteTargets(
|
||||
targetManagement.delete(
|
||||
Arrays.asList(runningActions.get(3).getTarget().getId(), runningActions.get(4).getTarget().getId()));
|
||||
}
|
||||
|
||||
@Step("Check the status of the rollout groups, second group should be in running status")
|
||||
private void checkSecondGroupStatusIsRunning(final Rollout createdRollout) {
|
||||
rolloutManagement.handleRollouts();
|
||||
final List<RolloutGroup> runningRolloutGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(0, 10, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> runningRolloutGroups = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(0, 10, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
assertThat(runningRolloutGroups.get(0).getStatus()).isEqualTo(RolloutGroupStatus.FINISHED);
|
||||
assertThat(runningRolloutGroups.get(1).getStatus()).isEqualTo(RolloutGroupStatus.RUNNING);
|
||||
assertThat(runningRolloutGroups.get(2).getStatus()).isEqualTo(RolloutGroupStatus.SCHEDULED);
|
||||
@@ -306,7 +306,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
createdRollout.getId(), Status.RUNNING);
|
||||
final List<JpaAction> runningActions = runningActionsSlice.getContent();
|
||||
finishAction(runningActions.get(0));
|
||||
targetManagement.deleteTargets(
|
||||
targetManagement.delete(
|
||||
Arrays.asList(runningActions.get(1).getTarget().getId(), runningActions.get(2).getTarget().getId(),
|
||||
runningActions.get(3).getTarget().getId(), runningActions.get(4).getTarget().getId()));
|
||||
|
||||
@@ -317,7 +317,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Slice<JpaAction> runningActionsSlice = actionRepository.findByRolloutIdAndStatus(PAGE,
|
||||
createdRollout.getId(), Status.SCHEDULED);
|
||||
final List<JpaAction> runningActions = runningActionsSlice.getContent();
|
||||
targetManagement.deleteTargets(Arrays.asList(runningActions.get(0).getTarget().getId(),
|
||||
targetManagement.delete(Arrays.asList(runningActions.get(0).getTarget().getId(),
|
||||
runningActions.get(1).getTarget().getId(), runningActions.get(2).getTarget().getId(),
|
||||
runningActions.get(3).getTarget().getId(), runningActions.get(4).getTarget().getId()));
|
||||
}
|
||||
@@ -326,11 +326,11 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void verifyRolloutAndAllGroupsAreFinished(final Rollout createdRollout) {
|
||||
rolloutManagement.handleRollouts();
|
||||
final List<RolloutGroup> runningRolloutGroups = rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(createdRollout.getId(), PAGE).getContent();
|
||||
.findByRollout(PAGE, createdRollout.getId()).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);
|
||||
assertThat(rolloutManagement.findRolloutById(createdRollout.getId()).get().getStatus())
|
||||
assertThat(rolloutManagement.get(createdRollout.getId()).get().getStatus())
|
||||
.isEqualTo(RolloutStatus.FINISHED);
|
||||
|
||||
}
|
||||
@@ -365,19 +365,19 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
// and should execute the error action
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
final Rollout rollout = rolloutManagement.findRolloutById(createdRollout.getId()).get();
|
||||
final Rollout rollout = rolloutManagement.get(createdRollout.getId()).get();
|
||||
// the rollout itself should be in paused based on the error action
|
||||
assertThat(rollout.getStatus()).isEqualTo(RolloutStatus.PAUSED);
|
||||
|
||||
// the first rollout group should be in error state
|
||||
final List<RolloutGroup> errorGroup = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(0, 1, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> errorGroup = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(0, 1, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
assertThat(errorGroup).hasSize(1);
|
||||
assertThat(errorGroup.get(0).getStatus()).isEqualTo(RolloutGroupStatus.ERROR);
|
||||
|
||||
// all other groups should still be in scheduled state
|
||||
final List<RolloutGroup> scheduleGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(1, 100, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> scheduleGroups = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(1, 100, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
scheduleGroups.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.SCHEDULED));
|
||||
}
|
||||
|
||||
@@ -405,28 +405,28 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
// and should execute the error action
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
final Rollout rollout = rolloutManagement.findRolloutById(createdRollout.getId()).get();
|
||||
final Rollout rollout = rolloutManagement.get(createdRollout.getId()).get();
|
||||
// the rollout itself should be in paused based on the error action
|
||||
assertThat(rollout.getStatus()).isEqualTo(RolloutStatus.PAUSED);
|
||||
|
||||
// all other groups should still be in scheduled state
|
||||
final List<RolloutGroup> scheduleGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(1, 100, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> scheduleGroups = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(1, 100, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
scheduleGroups.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.SCHEDULED));
|
||||
|
||||
// resume the rollout again after it gets paused by error action
|
||||
rolloutManagement.resumeRollout(createdRollout.getId());
|
||||
|
||||
// the rollout should be running again
|
||||
assertThat(rolloutManagement.findRolloutById(createdRollout.getId()).get().getStatus())
|
||||
assertThat(rolloutManagement.get(createdRollout.getId()).get().getStatus())
|
||||
.isEqualTo(RolloutStatus.RUNNING);
|
||||
|
||||
// checking rollouts again
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
// next group should be running again after resuming the rollout
|
||||
final List<RolloutGroup> resumedGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(
|
||||
createdRollout.getId(), new OffsetBasedPageRequest(1, 1, new Sort(Direction.ASC, "id"))).getContent();
|
||||
final List<RolloutGroup> resumedGroups = rolloutGroupManagement.findByRollout(
|
||||
new OffsetBasedPageRequest(1, 1, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent();
|
||||
assertThat(resumedGroups).hasSize(1);
|
||||
assertThat(resumedGroups.get(0).getStatus()).isEqualTo(RolloutGroupStatus.RUNNING);
|
||||
}
|
||||
@@ -451,7 +451,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutManagement.handleRollouts();
|
||||
// finish running actions, 2 actions should be finished
|
||||
assertThat(changeStatusForAllRunningActions(createdRollout, Status.FINISHED)).isEqualTo(2);
|
||||
assertThat(rolloutManagement.findRolloutById(createdRollout.getId()).get().getStatus())
|
||||
assertThat(rolloutManagement.get(createdRollout.getId()).get().getStatus())
|
||||
.isEqualTo(RolloutStatus.RUNNING);
|
||||
|
||||
}
|
||||
@@ -461,12 +461,12 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// verify all groups are in finished state
|
||||
rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(createdRollout.getId(),
|
||||
new OffsetBasedPageRequest(0, 100, new Sort(Direction.ASC, "id")))
|
||||
.findByRollout(new OffsetBasedPageRequest(0, 100, new Sort(Direction.ASC, "id")),
|
||||
createdRollout.getId())
|
||||
.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.FINISHED));
|
||||
|
||||
// verify that rollout itself is in finished state
|
||||
final Rollout findRolloutById = rolloutManagement.findRolloutById(createdRollout.getId()).get();
|
||||
final Rollout findRolloutById = rolloutManagement.get(createdRollout.getId()).get();
|
||||
assertThat(findRolloutById.getStatus()).isEqualTo(RolloutStatus.FINISHED);
|
||||
}
|
||||
|
||||
@@ -487,7 +487,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
validationMap.put(TotalTargetCountStatus.Status.NOTSTARTED, 8L);
|
||||
validateRolloutActionStatus(createdRollout.getId(), validationMap);
|
||||
|
||||
rolloutManagement.startRollout(createdRollout.getId());
|
||||
rolloutManagement.start(createdRollout.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
@@ -550,7 +550,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
validationMap.put(TotalTargetCountStatus.Status.NOTSTARTED, 8L);
|
||||
validateRolloutActionStatus(createdRollout.getId(), validationMap);
|
||||
|
||||
rolloutManagement.startRollout(createdRollout.getId());
|
||||
rolloutManagement.start(createdRollout.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
@@ -589,9 +589,9 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
// round(7/3)=2 targets running (Group 3)
|
||||
// round(5/2)=3 targets SCHEDULED (Group 3)
|
||||
// round(2/1)=2 targets SCHEDULED (Group 4)
|
||||
createdRollout = rolloutManagement.findRolloutById(createdRollout.getId()).get();
|
||||
createdRollout = rolloutManagement.get(createdRollout.getId()).get();
|
||||
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(createdRollout.getId(), PAGE).getContent();
|
||||
.findByRollout(PAGE, createdRollout.getId()).getContent();
|
||||
|
||||
Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.FINISHED, 2L);
|
||||
@@ -624,15 +624,15 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
successCondition, errorCondition);
|
||||
final DistributionSet ds = createdRollout.getDistributionSet();
|
||||
|
||||
createdRollout = rolloutManagement.findRolloutById(createdRollout.getId()).get();
|
||||
createdRollout = rolloutManagement.get(createdRollout.getId()).get();
|
||||
// 5 targets are running
|
||||
final List<Action> runningActions = findActionsByRolloutAndStatus(createdRollout, Status.RUNNING);
|
||||
assertThat(runningActions.size()).isEqualTo(5);
|
||||
|
||||
// 5 targets are in the group and the DS has been assigned
|
||||
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(createdRollout.getId(), PAGE).getContent();
|
||||
final Page<Target> targets = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(0).getId(), PAGE);
|
||||
.findByRollout(PAGE, createdRollout.getId()).getContent();
|
||||
final Page<Target> targets = rolloutGroupManagement.findTargetsOfRolloutGroup(PAGE, rolloutGroups.get(0).getId());
|
||||
final List<Target> targetList = targets.getContent();
|
||||
assertThat(targetList.size()).isEqualTo(5);
|
||||
|
||||
@@ -665,7 +665,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
Rollout rolloutOne = createAndStartRollout(amountTargetsForRollout, amountOtherTargets, amountGroups,
|
||||
successCondition, errorCondition);
|
||||
|
||||
rolloutOne = rolloutManagement.findRolloutById(rolloutOne.getId()).get();
|
||||
rolloutOne = rolloutManagement.get(rolloutOne.getId()).get();
|
||||
|
||||
final DistributionSet dsForRolloutTwo = testdataFactory.createDistributionSet("dsForRolloutTwo");
|
||||
|
||||
@@ -680,7 +680,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.SCHEDULED, 5L);
|
||||
validateRolloutActionStatus(rolloutOne.getId(), expectedTargetCountStatus);
|
||||
|
||||
rolloutManagement.startRollout(rolloutTwo.getId());
|
||||
rolloutManagement.start(rolloutTwo.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
@@ -707,7 +707,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
successCondition, errorCondition);
|
||||
final DistributionSet distributionSet = rolloutOne.getDistributionSet();
|
||||
|
||||
rolloutOne = rolloutManagement.findRolloutById(rolloutOne.getId()).get();
|
||||
rolloutOne = rolloutManagement.get(rolloutOne.getId()).get();
|
||||
changeStatusForRunningActions(rolloutOne, Status.ERROR, 2);
|
||||
changeStatusForRunningActions(rolloutOne, Status.FINISHED, 3);
|
||||
rolloutManagement.handleRollouts();
|
||||
@@ -724,7 +724,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.ERROR, 6L);
|
||||
validateRolloutActionStatus(rolloutOne.getId(), expectedTargetCountStatus);
|
||||
// rollout is finished
|
||||
rolloutOne = rolloutManagement.findRolloutById(rolloutOne.getId()).get();
|
||||
rolloutOne = rolloutManagement.get(rolloutOne.getId()).get();
|
||||
assertThat(rolloutOne.getStatus()).isEqualTo(RolloutStatus.FINISHED);
|
||||
|
||||
final int amountGroupsForRolloutTwo = 1;
|
||||
@@ -732,19 +732,19 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
"This is the description for rollout two", amountGroupsForRolloutTwo, "controllerId==rollout-*",
|
||||
distributionSet, "50", "80");
|
||||
|
||||
rolloutManagement.startRollout(rolloutTwo.getId());
|
||||
rolloutManagement.start(rolloutTwo.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
rolloutTwo = rolloutManagement.findRolloutById(rolloutTwo.getId()).get();
|
||||
rolloutTwo = rolloutManagement.get(rolloutTwo.getId()).get();
|
||||
// 6 error targets are now running
|
||||
expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 6L);
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.FINISHED, 9L);
|
||||
validateRolloutActionStatus(rolloutTwo.getId(), expectedTargetCountStatus);
|
||||
changeStatusForAllRunningActions(rolloutTwo, Status.FINISHED);
|
||||
final Page<Target> targetPage = targetManagement.findTargetByUpdateStatus(PAGE, TargetUpdateStatus.IN_SYNC);
|
||||
final Page<Target> targetPage = targetManagement.findByUpdateStatus(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);
|
||||
@@ -764,13 +764,13 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
Rollout rolloutOne = createAndStartRollout(amountTargetsForRollout, amountOtherTargets, amountGroups,
|
||||
successCondition, errorCondition);
|
||||
|
||||
rolloutOne = rolloutManagement.findRolloutById(rolloutOne.getId()).get();
|
||||
rolloutOne = rolloutManagement.get(rolloutOne.getId()).get();
|
||||
changeStatusForRunningActions(rolloutOne, Status.ERROR, 2);
|
||||
changeStatusForRunningActions(rolloutOne, Status.FINISHED, 3);
|
||||
rolloutManagement.handleRollouts();
|
||||
// verify: 40% error but 60% finished -> should move to next group
|
||||
final List<RolloutGroup> rolloutGruops = rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(rolloutOne.getId(), PAGE).getContent();
|
||||
.findByRollout(PAGE, rolloutOne.getId()).getContent();
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 5L);
|
||||
validateRolloutGroupActionStatus(rolloutGruops.get(1), expectedTargetCountStatus);
|
||||
@@ -789,14 +789,14 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
Rollout rolloutOne = createAndStartRollout(amountTargetsForRollout, amountOtherTargets, amountGroups,
|
||||
successCondition, errorCondition);
|
||||
|
||||
rolloutOne = rolloutManagement.findRolloutById(rolloutOne.getId()).get();
|
||||
rolloutOne = rolloutManagement.get(rolloutOne.getId()).get();
|
||||
changeStatusForRunningActions(rolloutOne, Status.ERROR, 2);
|
||||
changeStatusForRunningActions(rolloutOne, Status.FINISHED, 3);
|
||||
rolloutManagement.handleRollouts();
|
||||
// verify: 40% error and 60% finished -> should not move to next group
|
||||
// because successCondition 80%
|
||||
final List<RolloutGroup> rolloutGruops = rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(rolloutOne.getId(), PAGE).getContent();
|
||||
.findByRollout(PAGE, rolloutOne.getId()).getContent();
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.SCHEDULED, 5L);
|
||||
validateRolloutGroupActionStatus(rolloutGruops.get(1), expectedTargetCountStatus);
|
||||
@@ -814,12 +814,12 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
Rollout rolloutOne = createAndStartRollout(amountTargetsForRollout, amountOtherTargets, amountGroups,
|
||||
successCondition, errorCondition);
|
||||
|
||||
rolloutOne = rolloutManagement.findRolloutById(rolloutOne.getId()).get();
|
||||
rolloutOne = rolloutManagement.get(rolloutOne.getId()).get();
|
||||
changeStatusForRunningActions(rolloutOne, Status.ERROR, 2);
|
||||
changeStatusForRunningActions(rolloutOne, Status.FINISHED, 3);
|
||||
rolloutManagement.handleRollouts();
|
||||
// verify: 40% error -> should pause because errorCondition is 20%
|
||||
rolloutOne = rolloutManagement.findRolloutById(rolloutOne.getId()).get();
|
||||
rolloutOne = rolloutManagement.get(rolloutOne.getId()).get();
|
||||
assertThat(RolloutStatus.PAUSED).isEqualTo(rolloutOne.getStatus());
|
||||
}
|
||||
|
||||
@@ -833,14 +833,14 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final String errorCondition = "20";
|
||||
final Rollout rolloutA = createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout, amountGroups,
|
||||
successCondition, errorCondition, "RolloutA", "RolloutA");
|
||||
rolloutManagement.startRollout(rolloutA.getId());
|
||||
rolloutManagement.start(rolloutA.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
final int amountTargetsForRollout2 = 10;
|
||||
final int amountGroups2 = 2;
|
||||
final Rollout rolloutB = createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout2, amountGroups2,
|
||||
successCondition, errorCondition, "RolloutB", "RolloutB");
|
||||
rolloutManagement.startRollout(rolloutB.getId());
|
||||
rolloutManagement.start(rolloutB.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
changeStatusForAllRunningActions(rolloutB, Status.FINISHED);
|
||||
@@ -850,7 +850,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final int amountGroups3 = 2;
|
||||
final Rollout rolloutC = createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout3, amountGroups3,
|
||||
successCondition, errorCondition, "RolloutC", "RolloutC");
|
||||
rolloutManagement.startRollout(rolloutC.getId());
|
||||
rolloutManagement.start(rolloutC.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
changeStatusForAllRunningActions(rolloutC, Status.ERROR);
|
||||
@@ -860,7 +860,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final int amountGroups4 = 3;
|
||||
final Rollout rolloutD = createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout4, amountGroups4,
|
||||
successCondition, errorCondition, "RolloutD", "RolloutD");
|
||||
rolloutManagement.startRollout(rolloutD.getId());
|
||||
rolloutManagement.start(rolloutD.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
changeStatusForRunningActions(rolloutD, Status.ERROR, 1);
|
||||
@@ -868,7 +868,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
changeStatusForAllRunningActions(rolloutD, Status.FINISHED);
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
final Page<Rollout> rolloutPage = rolloutManagement.findAllRolloutsWithDetailedStatus(
|
||||
final Page<Rollout> rolloutPage = rolloutManagement.findAllWithDetailedStatus(
|
||||
new OffsetBasedPageRequest(0, 100, new Sort(Direction.ASC, "name")), false);
|
||||
final List<Rollout> rolloutList = rolloutPage.getContent();
|
||||
|
||||
@@ -911,7 +911,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout, amountGroups, successCondition,
|
||||
errorCondition, "Rollout" + i, "Rollout" + i);
|
||||
}
|
||||
final Long count = rolloutManagement.countRolloutsAll();
|
||||
final Long count = rolloutManagement.count();
|
||||
assertThat(count).isEqualTo(10L);
|
||||
}
|
||||
|
||||
@@ -932,7 +932,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
errorCondition, "SomethingElse" + i, "SomethingElse" + i);
|
||||
}
|
||||
|
||||
final Long count = rolloutManagement.countRolloutsAllByFilters("Rollout%");
|
||||
final Long count = rolloutManagement.countByFilters("Rollout%");
|
||||
assertThat(count).isEqualTo(5L);
|
||||
|
||||
}
|
||||
@@ -954,7 +954,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
errorCondition, "SomethingElse" + i, "SomethingElse" + i);
|
||||
}
|
||||
|
||||
final Slice<Rollout> rollout = rolloutManagement.findRolloutWithDetailedStatusByFilters(
|
||||
final Slice<Rollout> rollout = rolloutManagement.findByFiltersWithDetailedStatus(
|
||||
new OffsetBasedPageRequest(0, 100, new Sort(Direction.ASC, "name")), "Rollout%", false);
|
||||
final List<Rollout> rolloutList = rollout.getContent();
|
||||
assertThat(rolloutList.size()).isEqualTo(5);
|
||||
@@ -977,7 +977,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Rollout rolloutCreated = createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout,
|
||||
amountGroups, successCondition, errorCondition, rolloutName, "RolloutA");
|
||||
|
||||
final Rollout rolloutFound = rolloutManagement.findRolloutByName(rolloutName).get();
|
||||
final Rollout rolloutFound = rolloutManagement.getByName(rolloutName).get();
|
||||
assertThat(rolloutCreated).isEqualTo(rolloutFound);
|
||||
|
||||
}
|
||||
@@ -993,18 +993,18 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final String rolloutName = "MyRollout";
|
||||
Rollout myRollout = createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout, amountGroups,
|
||||
successCondition, errorCondition, rolloutName, rolloutName);
|
||||
rolloutManagement.startRollout(myRollout.getId());
|
||||
rolloutManagement.start(myRollout.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
changeStatusForRunningActions(myRollout, Status.FINISHED, 2);
|
||||
rolloutManagement.handleRollouts();
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
|
||||
float percent = rolloutGroupManagement
|
||||
.findRolloutGroupWithDetailedStatus(rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE).getContent().get(0).getId())
|
||||
.getWithDetailedStatus(rolloutGroupManagement
|
||||
.findByRollout(PAGE, myRollout.getId()).getContent().get(0).getId())
|
||||
.get().getTotalTargetCountStatus().getFinishedPercent();
|
||||
assertThat(percent).isEqualTo(40);
|
||||
|
||||
@@ -1012,8 +1012,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
percent = rolloutGroupManagement
|
||||
.findRolloutGroupWithDetailedStatus(rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE).getContent().get(0).getId())
|
||||
.getWithDetailedStatus(rolloutGroupManagement
|
||||
.findByRollout(PAGE, myRollout.getId()).getContent().get(0).getId())
|
||||
.get().getTotalTargetCountStatus().getFinishedPercent();
|
||||
assertThat(percent).isEqualTo(100);
|
||||
|
||||
@@ -1022,8 +1022,8 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
percent = rolloutGroupManagement
|
||||
.findRolloutGroupWithDetailedStatus(rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE).getContent().get(1).getId())
|
||||
.getWithDetailedStatus(rolloutGroupManagement
|
||||
.findByRollout(PAGE, myRollout.getId()).getContent().get(1).getId())
|
||||
.get().getTotalTargetCountStatus().getFinishedPercent();
|
||||
assertThat(percent).isEqualTo(80);
|
||||
}
|
||||
@@ -1045,7 +1045,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final String rsqlParam = "controllerId==*MyRoll*";
|
||||
|
||||
rolloutManagement.startRollout(myRollout.getId());
|
||||
rolloutManagement.start(myRollout.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
@@ -1053,26 +1053,26 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Condition<String> targetBelongsInRollout = new Condition<>(s -> s.startsWith(rolloutName),
|
||||
"Target belongs into rollout");
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement
|
||||
.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE).getContent();
|
||||
.findByRollout(PAGE, myRollout.getId()).getContent();
|
||||
|
||||
Page<Target> targetPage = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(0).getId(),
|
||||
rsqlParam, new OffsetBasedPageRequest(0, 100));
|
||||
Page<Target> targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(new OffsetBasedPageRequest(0, 100),
|
||||
rolloutGroups.get(0).getId(), rsqlParam);
|
||||
final List<Target> targetlistGroup1 = targetPage.getContent();
|
||||
assertThat(targetlistGroup1.size()).isEqualTo(5);
|
||||
assertThat(targetlistGroup1.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
||||
.are(targetBelongsInRollout);
|
||||
|
||||
targetPage = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(1).getId(), rsqlParam,
|
||||
new OffsetBasedPageRequest(0, 100));
|
||||
targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(new OffsetBasedPageRequest(0, 100), rolloutGroups.get(1).getId(),
|
||||
rsqlParam);
|
||||
final List<Target> targetlistGroup2 = targetPage.getContent();
|
||||
assertThat(targetlistGroup2.size()).isEqualTo(5);
|
||||
assertThat(targetlistGroup2.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
||||
.are(targetBelongsInRollout);
|
||||
|
||||
targetPage = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(2).getId(), rsqlParam,
|
||||
new OffsetBasedPageRequest(0, 100));
|
||||
targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(new OffsetBasedPageRequest(0, 100), rolloutGroups.get(2).getId(),
|
||||
rsqlParam);
|
||||
final List<Target> targetlistGroup3 = targetPage.getContent();
|
||||
assertThat(targetlistGroup3.size()).isEqualTo(5);
|
||||
assertThat(targetlistGroup3.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
||||
@@ -1135,7 +1135,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
|
||||
|
||||
final List<RolloutGroup> groups = rolloutGroupManagement.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE)
|
||||
final List<RolloutGroup> groups = rolloutGroupManagement.findByRollout(PAGE, myRollout.getId())
|
||||
.getContent();
|
||||
|
||||
assertThat(groups.get(0).getStatus()).isEqualTo(RolloutGroupStatus.READY);
|
||||
@@ -1149,7 +1149,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(groups.get(4).getStatus()).isEqualTo(RolloutGroupStatus.READY);
|
||||
assertThat(groups.get(4).getTotalTargets()).isEqualTo(0);
|
||||
|
||||
rolloutManagement.startRollout(myRollout.getId());
|
||||
rolloutManagement.start(myRollout.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
@@ -1159,7 +1159,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(MultipleInvokeHelper.doWithTimeout(new RolloutStatusCallable(myRollout.getId()),
|
||||
conditionRolloutStatus, 15000, 500)).as("Rollout status").isNotNull();
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.RUNNING);
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 1L);
|
||||
@@ -1188,10 +1188,10 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
|
||||
|
||||
rolloutManagement.startRollout(myRollout.getId());
|
||||
rolloutManagement.start(myRollout.getId());
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
rolloutManagement.handleRollouts();
|
||||
@@ -1201,7 +1201,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(MultipleInvokeHelper.doWithTimeout(new RolloutStatusCallable(myRollout.getId()),
|
||||
conditionRolloutTargetCount, 15000, 500)).as("Rollout status").isNotNull();
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.RUNNING);
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 10L);
|
||||
@@ -1228,20 +1228,20 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
|
||||
|
||||
// schedule rollout auto start into the future
|
||||
rolloutManagement.updateRollout(
|
||||
rolloutManagement.update(
|
||||
entityFactory.rollout().update(myRollout.getId()).startAt(System.currentTimeMillis() + 60000));
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
// rollout should not have been started
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
|
||||
|
||||
// schedule to now
|
||||
rolloutManagement
|
||||
.updateRollout(entityFactory.rollout().update(myRollout.getId()).startAt(System.currentTimeMillis()));
|
||||
.update(entityFactory.rollout().update(myRollout.getId()).startAt(System.currentTimeMillis()));
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.STARTING);
|
||||
|
||||
// Run here, because scheduler is disabled during tests
|
||||
@@ -1252,7 +1252,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(MultipleInvokeHelper.doWithTimeout(new RolloutStatusCallable(myRollout.getId()),
|
||||
conditionRolloutTargetCount, 15000, 500)).as("Rollout status").isNotNull();
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.RUNNING);
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
|
||||
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 10L);
|
||||
@@ -1288,11 +1288,11 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutGroups.add(generateRolloutGroup(1, percentTargetsInGroup2, null));
|
||||
rolloutGroups.add(generateRolloutGroup(2, percentTargetsInGroup3, null));
|
||||
|
||||
Rollout myRollout = rolloutManagement.createRollout(rolloutcreate, rolloutGroups, conditions);
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
Rollout myRollout = rolloutManagement.create(rolloutcreate, rolloutGroups, conditions);
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.CREATING);
|
||||
for (final RolloutGroup group : rolloutGroupManagement.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE)
|
||||
for (final RolloutGroup group : rolloutGroupManagement.findByRollout(PAGE, myRollout.getId())
|
||||
.getContent()) {
|
||||
assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.CREATING);
|
||||
}
|
||||
@@ -1304,11 +1304,11 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
|
||||
assertThat(myRollout.getTotalTargets()).isEqualTo(amountTargetsInGroup1and2 + amountTargetsInGroup1);
|
||||
|
||||
final List<RolloutGroup> groups = rolloutGroupManagement.findRolloutGroupsByRolloutId(myRollout.getId(), PAGE)
|
||||
final List<RolloutGroup> groups = rolloutGroupManagement.findByRollout(PAGE, myRollout.getId())
|
||||
.getContent();
|
||||
;
|
||||
assertThat(groups.get(0).getStatus()).isEqualTo(RolloutGroupStatus.READY);
|
||||
@@ -1338,7 +1338,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutGroups.add(generateRolloutGroup(1, percentTargetsInGroup2, null));
|
||||
|
||||
assertThatExceptionOfType(ValidationException.class)
|
||||
.isThrownBy(() -> rolloutManagement.createRollout(myRollout, rolloutGroups, conditions))
|
||||
.isThrownBy(() -> rolloutManagement.create(myRollout, rolloutGroups, conditions))
|
||||
.withMessageContaining("groups don't match");
|
||||
|
||||
}
|
||||
@@ -1359,7 +1359,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
generateRolloutGroup(1, percentTargetsInGroup2, null));
|
||||
|
||||
assertThatExceptionOfType(ValidationException.class)
|
||||
.isThrownBy(() -> rolloutManagement.createRollout(myRollout, rolloutGroups, conditions))
|
||||
.isThrownBy(() -> rolloutManagement.create(myRollout, rolloutGroups, conditions))
|
||||
.withMessageContaining("percentage has to be between 1 and 100");
|
||||
|
||||
}
|
||||
@@ -1375,7 +1375,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final RolloutCreate myRollout = generateTargetsAndRollout(rolloutName, amountTargetsForRollout);
|
||||
|
||||
assertThatExceptionOfType(ValidationException.class)
|
||||
.isThrownBy(() -> rolloutManagement.createRollout(myRollout, illegalGroupAmount, conditions))
|
||||
.isThrownBy(() -> rolloutManagement.create(myRollout, illegalGroupAmount, conditions))
|
||||
.withMessageContaining("not be greater than " + quotaManagement.getMaxRolloutGroupsPerRollout());
|
||||
|
||||
}
|
||||
@@ -1400,14 +1400,14 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
.description("some description").targetFilterQuery("id==" + targetPrefixName + "-*")
|
||||
.set(distributionSet);
|
||||
|
||||
Rollout myRollout = rolloutManagement.createRollout(rolloutToCreate, amountGroups, conditions);
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId()).get();
|
||||
Rollout myRollout = rolloutManagement.create(rolloutToCreate, amountGroups, conditions);
|
||||
myRollout = rolloutManagement.get(myRollout.getId()).get();
|
||||
|
||||
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.CREATING);
|
||||
|
||||
final Long rolloutId = myRollout.getId();
|
||||
assertThatExceptionOfType(RolloutIllegalStateException.class)
|
||||
.isThrownBy(() -> rolloutManagement.startRollout(rolloutId))
|
||||
.isThrownBy(() -> rolloutManagement.start(rolloutId))
|
||||
.withMessageContaining("can only be started in state ready");
|
||||
|
||||
}
|
||||
@@ -1430,7 +1430,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
amountOtherTargets, amountGroups, successCondition, errorCondition);
|
||||
|
||||
// test
|
||||
rolloutManagement.deleteRollout(createdRollout.getId());
|
||||
rolloutManagement.delete(createdRollout.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
// verify
|
||||
@@ -1462,7 +1462,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// start the rollout, so it has active running actions and a group which
|
||||
// has been started
|
||||
rolloutManagement.startRollout(createdRollout.getId());
|
||||
rolloutManagement.start(createdRollout.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
// verify we have running actions
|
||||
@@ -1470,7 +1470,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
.getNumberOfElements()).isEqualTo(2);
|
||||
|
||||
// test
|
||||
rolloutManagement.deleteRollout(createdRollout.getId());
|
||||
rolloutManagement.delete(createdRollout.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
// verify
|
||||
@@ -1480,12 +1480,12 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(deletedRollout.getStatus()).isEqualTo(RolloutStatus.DELETED);
|
||||
assertThatExceptionOfType(EntityReadOnlyException.class)
|
||||
.isThrownBy(() -> rolloutManagement
|
||||
.updateRollout(entityFactory.rollout().update(createdRollout.getId()).description("test")))
|
||||
.update(entityFactory.rollout().update(createdRollout.getId()).description("test")))
|
||||
.withMessageContaining("" + createdRollout.getId());
|
||||
|
||||
assertThat(rolloutManagement.findAll(PAGE, true).getContent()).hasSize(1);
|
||||
assertThat(rolloutManagement.findAll(PAGE, false).getContent()).hasSize(0);
|
||||
assertThat(rolloutGroupManagement.findAllRolloutGroupsWithDetailedStatus(createdRollout.getId(), PAGE)
|
||||
assertThat(rolloutGroupManagement.findByRolloutWithDetailedStatus(PAGE, createdRollout.getId())
|
||||
.getContent()).hasSize(amountGroups);
|
||||
|
||||
// verify that all scheduled actions are deleted
|
||||
@@ -1517,13 +1517,13 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void validateRolloutGroupActionStatus(final RolloutGroup rolloutGroup,
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus) {
|
||||
final RolloutGroup rolloutGroupWithDetail = rolloutGroupManagement
|
||||
.findRolloutGroupWithDetailedStatus(rolloutGroup.getId()).get();
|
||||
.getWithDetailedStatus(rolloutGroup.getId()).get();
|
||||
validateStatus(rolloutGroupWithDetail.getTotalTargetCountStatus(), expectedTargetCountStatus);
|
||||
}
|
||||
|
||||
private void validateRolloutActionStatus(final Long rolloutId,
|
||||
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus) {
|
||||
final Rollout rolloutWithDetail = rolloutManagement.findRolloutWithDetailedStatus(rolloutId).get();
|
||||
final Rollout rolloutWithDetail = rolloutManagement.getWithDetailedStatus(rolloutId).get();
|
||||
validateStatus(rolloutWithDetail.getTotalTargetCountStatus(), expectedTargetCountStatus);
|
||||
}
|
||||
|
||||
@@ -1608,7 +1608,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Override
|
||||
public RolloutStatus call() throws Exception {
|
||||
|
||||
final Rollout myRollout = rolloutManagement.findRolloutById(rolloutId).get();
|
||||
final Rollout myRollout = rolloutManagement.get(rolloutId).get();
|
||||
return myRollout.getStatus();
|
||||
|
||||
}
|
||||
|
||||
@@ -60,13 +60,12 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
final SoftwareModule module = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleById(1234L)).isNotPresent();
|
||||
assertThat(softwareModuleManagement.get(1234L)).isNotPresent();
|
||||
|
||||
assertThat(
|
||||
softwareModuleManagement.findSoftwareModuleByNameAndVersion(NOT_EXIST_ID, NOT_EXIST_ID, osType.getId()))
|
||||
.isNotPresent();
|
||||
assertThat(softwareModuleManagement.getByNameAndVersionAndType(NOT_EXIST_ID, NOT_EXIST_ID, osType.getId()))
|
||||
.isNotPresent();
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleMetadata(module.getId(), NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(module.getId(), NOT_EXIST_ID)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -77,53 +76,49 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule module = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.createSoftwareModule(
|
||||
Arrays.asList(entityFactory.softwareModule().create().name("xxx").type(NOT_EXIST_ID))),
|
||||
() -> softwareModuleManagement
|
||||
.create(Arrays.asList(entityFactory.softwareModule().create().name("xxx").type(NOT_EXIST_ID))),
|
||||
"SoftwareModuleType");
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement
|
||||
.createSoftwareModule(entityFactory.softwareModule().create().name("xxx").type(NOT_EXIST_ID)),
|
||||
.create(entityFactory.softwareModule().create().name("xxx").type(NOT_EXIST_ID)),
|
||||
"SoftwareModuleType");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.createSoftwareModuleMetadata(NOT_EXIST_IDL,
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.createMetaData(NOT_EXIST_IDL,
|
||||
entityFactory.generateMetadata("xxx", "xxx")), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.createSoftwareModuleMetadata(NOT_EXIST_IDL,
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.createMetaData(NOT_EXIST_IDL,
|
||||
Arrays.asList(entityFactory.generateMetadata("xxx", "xxx"))), "SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.deleteSoftwareModule(NOT_EXIST_IDL), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.deleteSoftwareModules(Arrays.asList(NOT_EXIST_IDL)),
|
||||
"SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.deleteSoftwareModuleMetadata(NOT_EXIST_IDL, "xxx"),
|
||||
"SoftwareModule");
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.deleteSoftwareModuleMetadata(module.getId(), NOT_EXIST_ID),
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.delete(NOT_EXIST_IDL), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.delete(Arrays.asList(NOT_EXIST_IDL)), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.deleteMetaData(NOT_EXIST_IDL, "xxx"), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.deleteMetaData(module.getId(), NOT_EXIST_ID),
|
||||
"SoftwareModuleMetadata");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.updateSoftwareModuleMetadata(NOT_EXIST_IDL,
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.updateMetaData(NOT_EXIST_IDL,
|
||||
entityFactory.generateMetadata("xxx", "xxx")), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.updateSoftwareModuleMetadata(module.getId(),
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.updateMetaData(module.getId(),
|
||||
entityFactory.generateMetadata(NOT_EXIST_ID, "xxx")), "SoftwareModuleMetadata");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findSoftwareModuleByAssignedTo(PAGE, NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findByAssignedTo(PAGE, NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.findSoftwareModuleByNameAndVersion("xxx", "xxx", NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.getByNameAndVersionAndType("xxx", "xxx", NOT_EXIST_IDL),
|
||||
"SoftwareModuleType");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findSoftwareModuleMetadata(NOT_EXIST_IDL, NOT_EXIST_ID),
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.getMetaDataBySoftwareModuleId(NOT_EXIST_IDL, NOT_EXIST_ID),
|
||||
"SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findMetaDataBySoftwareModuleId(PAGE, NOT_EXIST_IDL),
|
||||
"SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findMetaDataByRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findByType(PAGE, NOT_EXIST_IDL), "SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.findSoftwareModuleMetadataBySoftwareModuleId(PAGE, NOT_EXIST_IDL),
|
||||
() -> softwareModuleManagement.update(entityFactory.softwareModule().update(NOT_EXIST_IDL)),
|
||||
"SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement
|
||||
.findSoftwareModuleMetadataBySoftwareModuleId(NOT_EXIST_IDL, "name==*", PAGE), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findSoftwareModulesByType(PAGE, NOT_EXIST_IDL),
|
||||
"SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement
|
||||
.updateSoftwareModule(entityFactory.softwareModule().update(NOT_EXIST_IDL)), "SoftwareModule");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -132,7 +127,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final SoftwareModule updated = softwareModuleManagement
|
||||
.updateSoftwareModule(entityFactory.softwareModule().update(ah.getId()));
|
||||
.update(entityFactory.softwareModule().update(ah.getId()));
|
||||
|
||||
assertThat(updated.getOptLockRevision())
|
||||
.as("Expected version number of updated entitity to be equal to created version")
|
||||
@@ -144,8 +139,8 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void updateSoftareModuleFieldsToNewValue() {
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
final SoftwareModule updated = softwareModuleManagement.updateSoftwareModule(
|
||||
entityFactory.softwareModule().update(ah.getId()).description("changed").vendor("changed"));
|
||||
final SoftwareModule updated = softwareModuleManagement
|
||||
.update(entityFactory.softwareModule().update(ah.getId()).description("changed").vendor("changed"));
|
||||
|
||||
assertThat(updated.getOptLockRevision()).as("Expected version number of updated entitity is")
|
||||
.isEqualTo(ah.getOptLockRevision() + 1);
|
||||
@@ -168,54 +163,47 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("searched for software modules based on the various filter options, e.g. name,desc,type, version.")
|
||||
public void findSoftwareModuleByFilters() {
|
||||
final SoftwareModule ah = softwareModuleManagement.createSoftwareModule(
|
||||
entityFactory.softwareModule().create().type(appType).name("agent-hub").version("1.0.1"));
|
||||
final SoftwareModule jvm = softwareModuleManagement.createSoftwareModule(
|
||||
entityFactory.softwareModule().create().type(runtimeType).name("oracle-jre").version("1.7.2"));
|
||||
final SoftwareModule os = softwareModuleManagement.createSoftwareModule(
|
||||
entityFactory.softwareModule().create().type(osType).name("poky").version("3.0.2"));
|
||||
final SoftwareModule ah = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(appType).name("agent-hub").version("1.0.1"));
|
||||
final SoftwareModule jvm = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(runtimeType).name("oracle-jre").version("1.7.2"));
|
||||
final SoftwareModule os = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(osType).name("poky").version("3.0.2"));
|
||||
|
||||
final SoftwareModule ah2 = softwareModuleManagement.createSoftwareModule(
|
||||
entityFactory.softwareModule().create().type(appType).name("agent-hub").version("1.0.2"));
|
||||
final SoftwareModule ah2 = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(appType).name("agent-hub").version("1.0.2"));
|
||||
JpaDistributionSet ds = (JpaDistributionSet) distributionSetManagement
|
||||
.createDistributionSet(entityFactory.distributionSet().create().name("ds-1").version("1.0.1")
|
||||
.type(standardDsType).modules(Arrays.asList(os.getId(), jvm.getId(), ah2.getId())));
|
||||
.create(entityFactory.distributionSet().create().name("ds-1").version("1.0.1").type(standardDsType)
|
||||
.modules(Arrays.asList(os.getId(), jvm.getId(), ah2.getId())));
|
||||
|
||||
final JpaTarget target = (JpaTarget) testdataFactory.createTarget();
|
||||
ds = (JpaDistributionSet) assignSet(target, ds).getDistributionSet();
|
||||
|
||||
// standard searches
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "poky", osType.getId()).getContent())
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "poky", osType.getId()).getContent()).hasSize(1);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "poky", osType.getId()).getContent().get(0))
|
||||
.isEqualTo(os);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "oracle%", runtimeType.getId()).getContent())
|
||||
.hasSize(1);
|
||||
assertThat(
|
||||
softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "poky", osType.getId()).getContent().get(0))
|
||||
.isEqualTo(os);
|
||||
assertThat(
|
||||
softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "oracle%", runtimeType.getId()).getContent())
|
||||
.hasSize(1);
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "oracle%", runtimeType.getId())
|
||||
.getContent().get(0)).isEqualTo(jvm);
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "1.0.1", appType.getId()).getContent())
|
||||
.hasSize(1);
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "1.0.1", appType.getId()).getContent()
|
||||
.get(0)).isEqualTo(ah);
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "1.0%", appType.getId()).getContent())
|
||||
.hasSize(2);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "oracle%", runtimeType.getId()).getContent().get(0))
|
||||
.isEqualTo(jvm);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "1.0.1", appType.getId()).getContent()).hasSize(1);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "1.0.1", appType.getId()).getContent().get(0))
|
||||
.isEqualTo(ah);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "1.0%", appType.getId()).getContent()).hasSize(2);
|
||||
|
||||
// no we search with on entity marked as deleted
|
||||
softwareModuleManagement.deleteSoftwareModule(
|
||||
softwareModuleManagement.delete(
|
||||
softwareModuleRepository.findByAssignedToAndType(PAGE, ds, appType).getContent().get(0).getId());
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "1.0%", appType.getId()).getContent())
|
||||
.hasSize(1);
|
||||
assertThat(
|
||||
softwareModuleManagement.findSoftwareModuleByFilters(PAGE, "1.0%", appType.getId()).getContent().get(0))
|
||||
.isEqualTo(ah);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "1.0%", appType.getId()).getContent()).hasSize(1);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "1.0%", appType.getId()).getContent().get(0))
|
||||
.isEqualTo(ah);
|
||||
}
|
||||
|
||||
private Action assignSet(final JpaTarget target, final JpaDistributionSet ds) {
|
||||
assignDistributionSet(ds.getId(), target.getControllerId());
|
||||
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).get().getUpdateStatus())
|
||||
assertThat(targetManagement.getByControllerID(target.getControllerId()).get().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(ds);
|
||||
final Action action = actionRepository.findByTargetAndDistributionSet(PAGE, target, ds).getContent().get(0);
|
||||
@@ -230,7 +218,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final List<Long> modules = Arrays.asList(testdataFactory.createSoftwareModuleOs().getId(),
|
||||
testdataFactory.createSoftwareModuleApp().getId(), 624355263L);
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModulesById(modules)).hasSize(2);
|
||||
assertThat(softwareModuleManagement.get(modules)).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -240,10 +228,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule one = testdataFactory.createSoftwareModuleOs("one");
|
||||
final SoftwareModule two = testdataFactory.createSoftwareModuleOs("two");
|
||||
// ignored
|
||||
softwareModuleManagement.deleteSoftwareModule(testdataFactory.createSoftwareModuleOs("deleted").getId());
|
||||
softwareModuleManagement.delete(testdataFactory.createSoftwareModuleOs("deleted").getId());
|
||||
testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent())
|
||||
assertThat(softwareModuleManagement.findByType(PAGE, osType.getId()).getContent())
|
||||
.as("Expected to find the following number of modules:").hasSize(2).as("with the following elements")
|
||||
.contains(two, one);
|
||||
}
|
||||
@@ -256,10 +244,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createSoftwareModuleOs("two");
|
||||
final SoftwareModule deleted = testdataFactory.createSoftwareModuleOs("deleted");
|
||||
// ignored
|
||||
softwareModuleManagement.deleteSoftwareModule(deleted.getId());
|
||||
softwareModuleManagement.delete(deleted.getId());
|
||||
|
||||
assertThat(softwareModuleManagement.countSoftwareModulesAll())
|
||||
.as("Expected to find the following number of modules:").isEqualTo(2);
|
||||
assertThat(softwareModuleManagement.count()).as("Expected to find the following number of modules:")
|
||||
.isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -273,12 +261,12 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Artifact artifact2 = artifactsIt.next();
|
||||
|
||||
// [STEP2]: Delete unassigned SoftwareModule
|
||||
softwareModuleManagement.deleteSoftwareModule(unassignedModule.getId());
|
||||
softwareModuleManagement.delete(unassignedModule.getId());
|
||||
|
||||
// [VERIFY EXPECTED RESULT]:
|
||||
// verify: SoftwareModule is deleted
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(0);
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleById(unassignedModule.getId())).isNotPresent();
|
||||
assertThat(softwareModuleManagement.get(unassignedModule.getId())).isNotPresent();
|
||||
|
||||
// verify: binary data of artifact is deleted
|
||||
assertArtfiactNull(artifact1, artifact2);
|
||||
@@ -299,13 +287,13 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createDistributionSet(Sets.newHashSet(assignedModule));
|
||||
|
||||
// [STEP3]: Delete the assigned SoftwareModule
|
||||
softwareModuleManagement.deleteSoftwareModule(assignedModule.getId());
|
||||
softwareModuleManagement.delete(assignedModule.getId());
|
||||
|
||||
// [VERIFY EXPECTED RESULT]:
|
||||
// verify: assignedModule is marked as deleted
|
||||
assignedModule = softwareModuleManagement.findSoftwareModuleById(assignedModule.getId()).get();
|
||||
assignedModule = softwareModuleManagement.get(assignedModule.getId()).get();
|
||||
assertTrue("The module should be flagged as deleted", assignedModule.isDeleted());
|
||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(1);
|
||||
|
||||
// verify: binary data is deleted
|
||||
@@ -336,16 +324,16 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
assignDistributionSet(disSet, Arrays.asList(target));
|
||||
|
||||
// [STEP4]: Delete the DistributionSet
|
||||
distributionSetManagement.deleteDistributionSet(disSet.getId());
|
||||
distributionSetManagement.delete(disSet.getId());
|
||||
|
||||
// [STEP5]: Delete the assigned SoftwareModule
|
||||
softwareModuleManagement.deleteSoftwareModule(assignedModule.getId());
|
||||
softwareModuleManagement.delete(assignedModule.getId());
|
||||
|
||||
// [VERIFY EXPECTED RESULT]:
|
||||
// verify: assignedModule is marked as deleted
|
||||
assignedModule = softwareModuleManagement.findSoftwareModuleById(assignedModule.getId()).get();
|
||||
assignedModule = softwareModuleManagement.get(assignedModule.getId()).get();
|
||||
assertTrue("The found module should be flagged deleted", assignedModule.isDeleted());
|
||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(1);
|
||||
|
||||
// verify: binary data is deleted
|
||||
@@ -370,26 +358,26 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
SoftwareModule moduleX = createSoftwareModuleWithArtifacts(osType, "modulex", "v1.0", 0);
|
||||
|
||||
// [STEP2]: Create newArtifactX and add it to SoftwareModuleX
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(source), moduleX.getId(), "artifactx", false);
|
||||
moduleX = softwareModuleManagement.findSoftwareModuleById(moduleX.getId()).get();
|
||||
artifactManagement.create(new ByteArrayInputStream(source), moduleX.getId(), "artifactx", false);
|
||||
moduleX = softwareModuleManagement.get(moduleX.getId()).get();
|
||||
final Artifact artifactX = moduleX.getArtifacts().iterator().next();
|
||||
|
||||
// [STEP3]: Create SoftwareModuleY and add the same ArtifactX
|
||||
SoftwareModule moduleY = createSoftwareModuleWithArtifacts(osType, "moduley", "v1.0", 0);
|
||||
|
||||
// [STEP4]: Assign the same ArtifactX to SoftwareModuleY
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(source), moduleY.getId(), "artifactx", false);
|
||||
moduleY = softwareModuleManagement.findSoftwareModuleById(moduleY.getId()).get();
|
||||
artifactManagement.create(new ByteArrayInputStream(source), moduleY.getId(), "artifactx", false);
|
||||
moduleY = softwareModuleManagement.get(moduleY.getId()).get();
|
||||
final Artifact artifactY = moduleY.getArtifacts().iterator().next();
|
||||
|
||||
// [STEP5]: Delete SoftwareModuleX
|
||||
softwareModuleManagement.deleteSoftwareModule(moduleX.getId());
|
||||
softwareModuleManagement.delete(moduleX.getId());
|
||||
|
||||
// [VERIFY EXPECTED RESULT]:
|
||||
// verify: SoftwareModuleX is deleted, and ModuelY still exists
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(1);
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleById(moduleX.getId())).isNotPresent();
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleById(moduleY.getId())).isPresent();
|
||||
assertThat(softwareModuleManagement.get(moduleX.getId())).isNotPresent();
|
||||
assertThat(softwareModuleManagement.get(moduleY.getId())).isPresent();
|
||||
|
||||
// verify: binary data of artifact is not deleted
|
||||
assertArtfiactNotNull(artifactY);
|
||||
@@ -412,15 +400,15 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
// [STEP1]: Create SoftwareModuleX and add a new ArtifactX
|
||||
SoftwareModule moduleX = createSoftwareModuleWithArtifacts(osType, "modulex", "v1.0", 0);
|
||||
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(source), moduleX.getId(), "artifactx", false);
|
||||
moduleX = softwareModuleManagement.findSoftwareModuleById(moduleX.getId()).get();
|
||||
artifactManagement.create(new ByteArrayInputStream(source), moduleX.getId(), "artifactx", false);
|
||||
moduleX = softwareModuleManagement.get(moduleX.getId()).get();
|
||||
final Artifact artifactX = moduleX.getArtifacts().iterator().next();
|
||||
|
||||
// [STEP2]: Create SoftwareModuleY and add the same ArtifactX
|
||||
SoftwareModule moduleY = createSoftwareModuleWithArtifacts(osType, "moduley", "v1.0", 0);
|
||||
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(source), moduleY.getId(), "artifactx", false);
|
||||
moduleY = softwareModuleManagement.findSoftwareModuleById(moduleY.getId()).get();
|
||||
artifactManagement.create(new ByteArrayInputStream(source), moduleY.getId(), "artifactx", false);
|
||||
moduleY = softwareModuleManagement.get(moduleY.getId()).get();
|
||||
final Artifact artifactY = moduleY.getArtifacts().iterator().next();
|
||||
|
||||
// [STEP3]: Assign SoftwareModuleX to DistributionSetX and to target
|
||||
@@ -432,21 +420,21 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
assignDistributionSet(disSetY, Arrays.asList(target));
|
||||
|
||||
// [STEP5]: Delete SoftwareModuleX
|
||||
softwareModuleManagement.deleteSoftwareModule(moduleX.getId());
|
||||
softwareModuleManagement.delete(moduleX.getId());
|
||||
|
||||
// [STEP6]: Delete SoftwareModuleY
|
||||
softwareModuleManagement.deleteSoftwareModule(moduleY.getId());
|
||||
softwareModuleManagement.delete(moduleY.getId());
|
||||
|
||||
// [VERIFY EXPECTED RESULT]:
|
||||
moduleX = softwareModuleManagement.findSoftwareModuleById(moduleX.getId()).get();
|
||||
moduleY = softwareModuleManagement.findSoftwareModuleById(moduleY.getId()).get();
|
||||
moduleX = softwareModuleManagement.get(moduleX.getId()).get();
|
||||
moduleY = softwareModuleManagement.get(moduleY.getId()).get();
|
||||
|
||||
// verify: SoftwareModuleX and SofwtareModule are marked as deleted
|
||||
assertThat(moduleX).isNotNull();
|
||||
assertThat(moduleY).isNotNull();
|
||||
assertTrue("The module should be flagged deleted", moduleX.isDeleted());
|
||||
assertTrue("The module should be flagged deleted", moduleY.isDeleted());
|
||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(2);
|
||||
|
||||
// verify: binary data of artifact is deleted
|
||||
@@ -462,16 +450,16 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final long countSoftwareModule = softwareModuleRepository.count();
|
||||
|
||||
// create SoftwareModule
|
||||
SoftwareModule softwareModule = softwareModuleManagement.createSoftwareModule(entityFactory.softwareModule()
|
||||
.create().type(type).name(name).version(version).description("description of artifact " + name));
|
||||
SoftwareModule softwareModule = softwareModuleManagement.create(entityFactory.softwareModule().create()
|
||||
.type(type).name(name).version(version).description("description of artifact " + name));
|
||||
|
||||
for (int i = 0; i < numberArtifacts; i++) {
|
||||
artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), softwareModule.getId(),
|
||||
artifactManagement.create(new RandomGeneratedInputStream(5 * 1024), softwareModule.getId(),
|
||||
"file" + (i + 1), false);
|
||||
}
|
||||
|
||||
// Verify correct Creation of SoftwareModule and corresponding artifacts
|
||||
softwareModule = softwareModuleManagement.findSoftwareModuleById(softwareModule.getId()).get();
|
||||
softwareModule = softwareModuleManagement.get(softwareModule.getId()).get();
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize((int) countSoftwareModule + 1);
|
||||
|
||||
final List<Artifact> artifacts = softwareModule.getArtifacts();
|
||||
@@ -505,10 +493,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Test verfies that results are returned based on given filter parameters and in the specified order.")
|
||||
public void findSoftwareModuleOrderByDistributionModuleNameAscModuleVersionAsc() {
|
||||
// test meta data
|
||||
final SoftwareModuleType testType = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
entityFactory.softwareModuleType().create().key("thetype").name("thename").maxAssignments(100));
|
||||
final SoftwareModuleType testType = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("thetype").name("thename").maxAssignments(100));
|
||||
DistributionSetType testDsType = distributionSetTypeManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("key").name("name"));
|
||||
.create(entityFactory.distributionSetType().create().key("key").name("name"));
|
||||
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(testDsType.getId(),
|
||||
Arrays.asList(osType.getId()));
|
||||
@@ -525,28 +513,28 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule deleted = testdataFactory.createSoftwareModule("thetype", "deleted");
|
||||
final SoftwareModule four = testdataFactory.createSoftwareModuleOs("e");
|
||||
|
||||
final DistributionSet set = distributionSetManagement.createDistributionSet(
|
||||
entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(Lists
|
||||
final DistributionSet set = distributionSetManagement
|
||||
.create(entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(Lists
|
||||
.newArrayList(one.getId(), two.getId(), deleted.getId(), four.getId(), differentName.getId())));
|
||||
softwareModuleManagement.deleteSoftwareModule(deleted.getId());
|
||||
softwareModuleManagement.delete(deleted.getId());
|
||||
|
||||
// with filter on name, version and module type
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(PAGE,
|
||||
assertThat(softwareModuleManagement.findAllOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(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(softwareModuleManagement.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));
|
||||
assertThat(softwareModuleManagement
|
||||
.findAllOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(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(softwareModuleManagement
|
||||
.findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(PAGE, set.getId(), null, null)
|
||||
.findAllOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(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),
|
||||
@@ -557,10 +545,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Checks that number of modules is returned as expected based on given filters.")
|
||||
public void countSoftwareModuleByFilters() {
|
||||
// test meta data
|
||||
final SoftwareModuleType testType = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
entityFactory.softwareModuleType().create().key("thetype").name("thename").maxAssignments(100));
|
||||
final SoftwareModuleType testType = softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("thetype").name("thename").maxAssignments(100));
|
||||
DistributionSetType testDsType = distributionSetTypeManagement
|
||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("key").name("name"));
|
||||
.create(entityFactory.distributionSetType().create().key("key").name("name"));
|
||||
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(testDsType.getId(),
|
||||
Arrays.asList(osType.getId()));
|
||||
@@ -577,17 +565,17 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule deleted = testdataFactory.createSoftwareModule("thetype", "deleted");
|
||||
final SoftwareModule four = testdataFactory.createSoftwareModuleOs("e");
|
||||
|
||||
distributionSetManagement.createDistributionSet(
|
||||
entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(Lists
|
||||
distributionSetManagement
|
||||
.create(entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(Lists
|
||||
.newArrayList(one.getId(), two.getId(), deleted.getId(), four.getId(), differentName.getId())));
|
||||
softwareModuleManagement.deleteSoftwareModule(deleted.getId());
|
||||
softwareModuleManagement.delete(deleted.getId());
|
||||
|
||||
// test
|
||||
assertThat(softwareModuleManagement.countSoftwareModuleByFilters("%found%", testType.getId()))
|
||||
assertThat(softwareModuleManagement.countByTextAndType("%found%", testType.getId()))
|
||||
.as("Number of modules with given name or version and type").isEqualTo(3);
|
||||
assertThat(softwareModuleManagement.countSoftwareModuleByFilters(null, testType.getId()))
|
||||
assertThat(softwareModuleManagement.countByTextAndType(null, testType.getId()))
|
||||
.as("Number of modules with given type").isEqualTo(4);
|
||||
assertThat(softwareModuleManagement.countSoftwareModuleByFilters(null, null)).as("Number of modules overall")
|
||||
assertThat(softwareModuleManagement.countByTextAndType(null, null)).as("Number of modules overall")
|
||||
.isEqualTo(5);
|
||||
}
|
||||
|
||||
@@ -599,9 +587,9 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
// one soft deleted
|
||||
final SoftwareModule deleted = testdataFactory.createSoftwareModuleApp();
|
||||
testdataFactory.createDistributionSet(Arrays.asList(deleted));
|
||||
softwareModuleManagement.deleteSoftwareModule(deleted.getId());
|
||||
softwareModuleManagement.delete(deleted.getId());
|
||||
|
||||
assertThat(softwareModuleManagement.countSoftwareModulesAll()).as("Number of undeleted modules").isEqualTo(1);
|
||||
assertThat(softwareModuleManagement.count()).as("Number of undeleted modules").isEqualTo(1);
|
||||
assertThat(softwareModuleRepository.count()).as("Number of all modules").isEqualTo(2);
|
||||
}
|
||||
|
||||
@@ -614,11 +602,11 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// one soft deleted
|
||||
final SoftwareModule deleted = testdataFactory.createSoftwareModuleApp();
|
||||
final DistributionSet set = distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
.create().name("set").version("1").modules(Arrays.asList(one.getId(), deleted.getId())));
|
||||
softwareModuleManagement.deleteSoftwareModule(deleted.getId());
|
||||
final DistributionSet set = distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("set").version("1").modules(Arrays.asList(one.getId(), deleted.getId())));
|
||||
softwareModuleManagement.delete(deleted.getId());
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleByAssignedTo(PAGE, set.getId()).getContent())
|
||||
assertThat(softwareModuleManagement.findByAssignedTo(PAGE, set.getId()).getContent())
|
||||
.as("Found this number of modules").hasSize(2);
|
||||
}
|
||||
|
||||
@@ -640,11 +628,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final SoftwareModuleMetadata swMetadata2 = new JpaSoftwareModuleMetadata(knownKey2, ah, knownValue2);
|
||||
|
||||
final List<SoftwareModuleMetadata> softwareModuleMetadata = softwareModuleManagement
|
||||
.createSoftwareModuleMetadata(ah.getId(), Arrays.asList(swMetadata1, swMetadata2));
|
||||
final List<SoftwareModuleMetadata> softwareModuleMetadata = softwareModuleManagement.createMetaData(ah.getId(),
|
||||
Arrays.asList(swMetadata1, swMetadata2));
|
||||
|
||||
final SoftwareModule changedLockRevisionModule = softwareModuleManagement.findSoftwareModuleById(ah.getId())
|
||||
.get();
|
||||
final SoftwareModule changedLockRevisionModule = softwareModuleManagement.get(ah.getId()).get();
|
||||
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(2);
|
||||
|
||||
assertThat(softwareModuleMetadata).hasSize(2);
|
||||
@@ -664,12 +651,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
softwareModuleManagement.createSoftwareModuleMetadata(ah.getId(),
|
||||
entityFactory.generateMetadata(knownKey1, knownValue1));
|
||||
softwareModuleManagement.createMetaData(ah.getId(), entityFactory.generateMetadata(knownKey1, knownValue1));
|
||||
|
||||
try {
|
||||
softwareModuleManagement.createSoftwareModuleMetadata(ah.getId(),
|
||||
entityFactory.generateMetadata(knownKey1, knownValue2));
|
||||
softwareModuleManagement.createMetaData(ah.getId(), entityFactory.generateMetadata(knownKey1, knownValue2));
|
||||
fail("should not have worked as module metadata already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
@@ -690,24 +675,23 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(ah.getOptLockRevision()).isEqualTo(1);
|
||||
|
||||
// create an software module meta data entry
|
||||
final List<SoftwareModuleMetadata> softwareModuleMetadata = softwareModuleManagement
|
||||
.createSoftwareModuleMetadata(ah.getId(),
|
||||
Collections.singleton(entityFactory.generateMetadata(knownKey, knownValue)));
|
||||
final List<SoftwareModuleMetadata> softwareModuleMetadata = softwareModuleManagement.createMetaData(ah.getId(),
|
||||
Collections.singleton(entityFactory.generateMetadata(knownKey, knownValue)));
|
||||
assertThat(softwareModuleMetadata).hasSize(1);
|
||||
// base software module should have now the opt lock revision one
|
||||
// because we are modifying the
|
||||
// base software module
|
||||
SoftwareModule changedLockRevisionModule = softwareModuleManagement.findSoftwareModuleById(ah.getId()).get();
|
||||
SoftwareModule changedLockRevisionModule = softwareModuleManagement.get(ah.getId()).get();
|
||||
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(2);
|
||||
|
||||
// update the software module metadata
|
||||
Thread.sleep(100);
|
||||
final SoftwareModuleMetadata updated = softwareModuleManagement.updateSoftwareModuleMetadata(ah.getId(),
|
||||
final SoftwareModuleMetadata updated = softwareModuleManagement.updateMetaData(ah.getId(),
|
||||
entityFactory.generateMetadata(knownKey, knownUpdateValue));
|
||||
// we are updating the sw meta data so also modiying the base software
|
||||
// module so opt lock
|
||||
// revision must be two
|
||||
changedLockRevisionModule = softwareModuleManagement.findSoftwareModuleById(ah.getId()).get();
|
||||
changedLockRevisionModule = softwareModuleManagement.get(ah.getId()).get();
|
||||
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(3);
|
||||
|
||||
// verify updated meta data contains the updated value
|
||||
@@ -725,19 +709,16 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
ah = softwareModuleManagement
|
||||
.createSoftwareModuleMetadata(ah.getId(), entityFactory.generateMetadata(knownKey1, knownValue1))
|
||||
ah = softwareModuleManagement.createMetaData(ah.getId(), entityFactory.generateMetadata(knownKey1, knownValue1))
|
||||
.getSoftwareModule();
|
||||
|
||||
assertThat(softwareModuleManagement
|
||||
.findSoftwareModuleMetadataBySoftwareModuleId(new PageRequest(0, 100), ah.getId()).getContent())
|
||||
.as("Contains the created metadata element")
|
||||
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(new PageRequest(0, 10), ah.getId())
|
||||
.getContent()).as("Contains the created metadata element")
|
||||
.containsExactly(new JpaSoftwareModuleMetadata(knownKey1, ah, knownValue1));
|
||||
|
||||
softwareModuleManagement.deleteSoftwareModuleMetadata(ah.getId(), knownKey1);
|
||||
assertThat(softwareModuleManagement
|
||||
.findSoftwareModuleMetadataBySoftwareModuleId(new PageRequest(0, 100), ah.getId()).getContent())
|
||||
.as("Metadata elemenets are").isEmpty();
|
||||
softwareModuleManagement.deleteMetaData(ah.getId(), knownKey1);
|
||||
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(new PageRequest(0, 10), ah.getId())
|
||||
.getContent()).as("Metadata elemenets are").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -748,11 +729,10 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
ah = softwareModuleManagement
|
||||
.createSoftwareModuleMetadata(ah.getId(), entityFactory.generateMetadata(knownKey1, knownValue1))
|
||||
ah = softwareModuleManagement.createMetaData(ah.getId(), entityFactory.generateMetadata(knownKey1, knownValue1))
|
||||
.getSoftwareModule();
|
||||
|
||||
assertThat(softwareModuleManagement.findSoftwareModuleMetadata(ah.getId(), "doesnotexist")).isNotPresent();
|
||||
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(ah.getId(), "doesnotexist")).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -764,20 +744,22 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
SoftwareModule sw2 = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
for (int index = 0; index < 10; index++) {
|
||||
sw1 = softwareModuleManagement.createSoftwareModuleMetadata(sw1.getId(),
|
||||
entityFactory.generateMetadata("key" + index, "value" + index)).getSoftwareModule();
|
||||
sw1 = softwareModuleManagement
|
||||
.createMetaData(sw1.getId(), entityFactory.generateMetadata("key" + index, "value" + index))
|
||||
.getSoftwareModule();
|
||||
}
|
||||
|
||||
for (int index = 0; index < 20; index++) {
|
||||
sw2 = softwareModuleManagement.createSoftwareModuleMetadata(sw2.getId(),
|
||||
new JpaSoftwareModuleMetadata("key" + index, sw2, "value" + index)).getSoftwareModule();
|
||||
sw2 = softwareModuleManagement
|
||||
.createMetaData(sw2.getId(), new JpaSoftwareModuleMetadata("key" + index, sw2, "value" + index))
|
||||
.getSoftwareModule();
|
||||
}
|
||||
|
||||
final Page<SoftwareModuleMetadata> metadataOfSw1 = softwareModuleManagement
|
||||
.findSoftwareModuleMetadataBySoftwareModuleId(sw1.getId(), new PageRequest(0, 100));
|
||||
.findMetaDataBySoftwareModuleId(new PageRequest(0, 100), sw1.getId());
|
||||
|
||||
final Page<SoftwareModuleMetadata> metadataOfSw2 = softwareModuleManagement
|
||||
.findSoftwareModuleMetadataBySoftwareModuleId(sw2.getId(), new PageRequest(0, 100));
|
||||
.findMetaDataBySoftwareModuleId(new PageRequest(0, 100), sw2.getId());
|
||||
|
||||
assertThat(metadataOfSw1.getNumberOfElements()).isEqualTo(10);
|
||||
assertThat(metadataOfSw1.getTotalElements()).isEqualTo(10);
|
||||
|
||||
@@ -39,9 +39,9 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 0) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypeById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypeByKey(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypeByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(softwareModuleTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(softwareModuleTypeManagement.getByKey(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(softwareModuleTypeManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -49,23 +49,23 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
+ " by means of throwing EntityNotFoundException.")
|
||||
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 0) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
verifyThrownExceptionBy(() -> softwareModuleTypeManagement.deleteSoftwareModuleType(NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> softwareModuleTypeManagement.delete(NOT_EXIST_IDL),
|
||||
"SoftwareModuleType");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleTypeManagement
|
||||
.updateSoftwareModuleType(entityFactory.softwareModuleType().update(1234L)),
|
||||
.update(entityFactory.softwareModuleType().update(1234L)),
|
||||
"SoftwareModuleType");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Calling update without changing fields results in no recorded change in the repository including unchanged audit fields.")
|
||||
public void updateNothingResultsInUnchangedRepositoryForType() {
|
||||
final SoftwareModuleType created = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
final SoftwareModuleType created = softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("test-key").name("test-name"));
|
||||
|
||||
final SoftwareModuleType updated = softwareModuleTypeManagement
|
||||
.updateSoftwareModuleType(entityFactory.softwareModuleType().update(created.getId()));
|
||||
.update(entityFactory.softwareModuleType().update(created.getId()));
|
||||
|
||||
assertThat(updated.getOptLockRevision())
|
||||
.as("Expected version number of updated entitity to be equal to created version")
|
||||
@@ -75,10 +75,10 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
@Test
|
||||
@Description("Calling update for changed fields results in change in the repository.")
|
||||
public void updateSoftareModuleTypeFieldsToNewValue() {
|
||||
final SoftwareModuleType created = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
final SoftwareModuleType created = softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("test-key").name("test-name"));
|
||||
|
||||
final SoftwareModuleType updated = softwareModuleTypeManagement.updateSoftwareModuleType(
|
||||
final SoftwareModuleType updated = softwareModuleTypeManagement.update(
|
||||
entityFactory.softwareModuleType().update(created.getId()).description("changed").colour("changed"));
|
||||
|
||||
assertThat(updated.getOptLockRevision()).as("Expected version number of updated entitity is")
|
||||
@@ -94,9 +94,9 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
entityFactory.softwareModuleType().create().key("test-key").name("test-name"),
|
||||
entityFactory.softwareModuleType().create().key("test-key2").name("test-name2"));
|
||||
|
||||
softwareModuleTypeManagement.createSoftwareModuleType(created);
|
||||
softwareModuleTypeManagement.create(created);
|
||||
try {
|
||||
softwareModuleTypeManagement.createSoftwareModuleType(created);
|
||||
softwareModuleTypeManagement.create(created);
|
||||
fail("Should not have worked as module already exists.");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
@@ -106,34 +106,34 @@ public class SoftwareModuleTypeManagementTest 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(softwareModuleTypeManagement.findSoftwareModuleTypesAll(PAGE)).hasSize(3).contains(osType,
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType,
|
||||
runtimeType, appType);
|
||||
|
||||
SoftwareModuleType type = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
SoftwareModuleType type = softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("bundle").name("OSGi Bundle"));
|
||||
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypesAll(PAGE)).hasSize(4).contains(osType,
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType,
|
||||
runtimeType, appType, type);
|
||||
|
||||
// delete unassigned
|
||||
softwareModuleTypeManagement.deleteSoftwareModuleType(type.getId());
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypesAll(PAGE)).hasSize(3).contains(osType,
|
||||
softwareModuleTypeManagement.delete(type.getId());
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType,
|
||||
runtimeType, appType);
|
||||
assertThat(softwareModuleTypeRepository.findAll()).hasSize(3).contains((JpaSoftwareModuleType) osType,
|
||||
(JpaSoftwareModuleType) runtimeType, (JpaSoftwareModuleType) appType);
|
||||
|
||||
type = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
type = softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("bundle2").name("OSGi Bundle2"));
|
||||
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypesAll(PAGE)).hasSize(4).contains(osType,
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(4).contains(osType,
|
||||
runtimeType, appType, type);
|
||||
|
||||
softwareModuleManagement.createSoftwareModule(
|
||||
softwareModuleManagement.create(
|
||||
entityFactory.softwareModule().create().type(type).name("Test SM").version("1.0"));
|
||||
|
||||
// delete assigned
|
||||
softwareModuleTypeManagement.deleteSoftwareModuleType(type.getId());
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypesAll(PAGE)).hasSize(3).contains(osType,
|
||||
softwareModuleTypeManagement.delete(type.getId());
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType,
|
||||
runtimeType, appType);
|
||||
|
||||
assertThat(softwareModuleTypeRepository.findAll()).hasSize(4).contains((JpaSoftwareModuleType) osType,
|
||||
@@ -146,11 +146,11 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
public void findSoftwareModuleTypeByName() {
|
||||
testdataFactory.createSoftwareModuleOs();
|
||||
final SoftwareModuleType found = softwareModuleTypeManagement
|
||||
.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("thetype2").name("anothername"));
|
||||
|
||||
assertThat(softwareModuleTypeManagement.findSoftwareModuleTypeByName("thename").get())
|
||||
assertThat(softwareModuleTypeManagement.getByName("thename").get())
|
||||
.as("Type with given name").isEqualTo(found);
|
||||
}
|
||||
|
||||
@@ -158,9 +158,9 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Verfies that it is not possible to create a type that alrady exists.")
|
||||
public void createSoftwareModuleTypeFailsWithExistingEntity() {
|
||||
softwareModuleTypeManagement
|
||||
.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
try {
|
||||
softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
fail("should not have worked as module type already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
@@ -173,9 +173,9 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Verfies that it is not possible to create a list of types where one already exists.")
|
||||
public void createSoftwareModuleTypesFailsWithExistingEntity() {
|
||||
softwareModuleTypeManagement
|
||||
.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
|
||||
try {
|
||||
softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
softwareModuleTypeManagement.create(
|
||||
Arrays.asList(entityFactory.softwareModuleType().create().key("thetype").name("thename"),
|
||||
entityFactory.softwareModuleType().create().key("anothertype").name("anothername")));
|
||||
fail("should not have worked as module type already exists");
|
||||
@@ -188,7 +188,7 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Verifies that the creation of a softwareModuleType is failing because of invalid max assignment")
|
||||
public void createSoftwareModuleTypesFailsWithInvalidMaxAssignment() {
|
||||
try {
|
||||
softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("type").name("name").maxAssignments(0));
|
||||
fail("should not have worked as max assignment is invalid. Should be greater than 0.");
|
||||
} catch (final ConstraintViolationException e) {
|
||||
@@ -199,12 +199,12 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
@Test
|
||||
@Description("Verfies that multiple types are created as requested.")
|
||||
public void createMultipleSoftwareModuleTypes() {
|
||||
final List<SoftwareModuleType> created = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
final List<SoftwareModuleType> created = softwareModuleTypeManagement.create(
|
||||
Arrays.asList(entityFactory.softwareModuleType().create().key("thetype").name("thename"),
|
||||
entityFactory.softwareModuleType().create().key("thetype2").name("thename2")));
|
||||
|
||||
assertThat(created.size()).as("Number of created types").isEqualTo(2);
|
||||
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).as("Number of types in repository")
|
||||
assertThat(softwareModuleTypeManagement.count()).as("Number of types in repository")
|
||||
.isEqualTo(5);
|
||||
}
|
||||
|
||||
|
||||
@@ -134,14 +134,14 @@ public class SystemManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createTestArtifact(final byte[] random) {
|
||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
||||
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
||||
}
|
||||
|
||||
private void createDeletedTestArtifact(final byte[] random) {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("deleted garbage", true);
|
||||
ds.getModules().stream().forEach(module -> {
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), module.getId(), "file1", false);
|
||||
softwareModuleManagement.deleteSoftwareModule(module.getId());
|
||||
artifactManagement.create(new ByteArrayInputStream(random), module.getId(), "file1", false);
|
||||
softwareModuleManagement.delete(module.getId());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
+ "of Optional not present.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(targetFilterQueryManagement.findTargetFilterQueryById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(targetFilterQueryManagement.findTargetFilterQueryByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(targetFilterQueryManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(targetFilterQueryManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -62,50 +62,51 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
final DistributionSet set = testdataFactory.createDistributionSet();
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name("test filter").query("name==PendingTargets001"));
|
||||
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement.deleteTargetFilterQuery(NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement.delete(NOT_EXIST_IDL),
|
||||
"TargetFilterQuery");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement.findTargetFilterQueryByAutoAssignDS(PAGE,
|
||||
NOT_EXIST_IDL, "name==*"), "DistributionSet");
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetFilterQueryManagement
|
||||
.updateTargetFilterQuery(entityFactory.targetFilterQuery().update(NOT_EXIST_IDL)),
|
||||
.update(entityFactory.targetFilterQuery().update(NOT_EXIST_IDL)),
|
||||
"TargetFilterQuery");
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement
|
||||
.updateTargetFilterQueryAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL), "DistributionSet");
|
||||
.updateAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL), "DistributionSet");
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(1234L, set.getId()),
|
||||
() -> targetFilterQueryManagement.updateAutoAssignDS(1234L, set.getId()),
|
||||
"TargetFilterQuery");
|
||||
verifyThrownExceptionBy(() -> targetFilterQueryManagement
|
||||
.updateTargetFilterQueryAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL), "DistributionSet");
|
||||
.updateAutoAssignDS(targetFilterQuery.getId(), NOT_EXIST_IDL), "DistributionSet");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Test creation of target filter query.")
|
||||
public void createTargetFilterQuery() {
|
||||
final String filterName = "new target filter";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
assertEquals("Retrieved newly created custom target filter", targetFilterQuery,
|
||||
targetFilterQueryManagement.findTargetFilterQueryByName(filterName).get());
|
||||
targetFilterQueryManagement.getByName(filterName).get());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Test searching a target filter query.")
|
||||
public void searchTargetFilterQuery() {
|
||||
final String filterName = "targetFilterQueryName";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name("someOtherFilter").query("name==PendingTargets002"));
|
||||
|
||||
final List<TargetFilterQuery> results = targetFilterQueryManagement
|
||||
.findTargetFilterQueryByFilter(new PageRequest(0, 10), "name==" + filterName).getContent();
|
||||
.findByRsql(new PageRequest(0, 10), "name==" + filterName).getContent();
|
||||
assertEquals("Search result should have 1 result", 1, results.size());
|
||||
assertEquals("Retrieved newly created custom target filter", targetFilterQuery, results.get(0));
|
||||
}
|
||||
@@ -114,7 +115,7 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test searching a target filter query with an invalid filter.")
|
||||
public void searchTargetFilterQueryInvalidField() {
|
||||
// Should throw an exception
|
||||
targetFilterQueryManagement.findTargetFilterQueryByFilter(new PageRequest(0, 10), "unknownField==testValue")
|
||||
targetFilterQueryManagement.findByRsql(new PageRequest(0, 10), "unknownField==testValue")
|
||||
.getContent();
|
||||
|
||||
}
|
||||
@@ -123,11 +124,11 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Checks if the EntityAlreadyExistsException is thrown if a targetfilterquery with the same name are created more than once.")
|
||||
public void createDuplicateTargetFilterQuery() {
|
||||
final String filterName = "new target filter duplicate";
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
try {
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
fail("should not have worked as query already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
@@ -139,11 +140,11 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test deletion of target filter query.")
|
||||
public void deleteTargetFilterQuery() {
|
||||
final String filterName = "delete_target_filter_query";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
targetFilterQueryManagement.deleteTargetFilterQuery(targetFilterQuery.getId());
|
||||
targetFilterQueryManagement.delete(targetFilterQuery.getId());
|
||||
assertFalse("Returns null as the target filter is deleted",
|
||||
targetFilterQueryManagement.findTargetFilterQueryById(targetFilterQuery.getId()).isPresent());
|
||||
targetFilterQueryManagement.get(targetFilterQuery.getId()).isPresent());
|
||||
|
||||
}
|
||||
|
||||
@@ -151,14 +152,14 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test updation of target filter query.")
|
||||
public void updateTargetFilterQuery() {
|
||||
final String filterName = "target_filter_01";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
final String newQuery = "status==UNKNOWN";
|
||||
targetFilterQueryManagement.updateTargetFilterQuery(
|
||||
targetFilterQueryManagement.update(
|
||||
entityFactory.targetFilterQuery().update(targetFilterQuery.getId()).query(newQuery));
|
||||
assertEquals("Returns updated target filter query", newQuery,
|
||||
targetFilterQueryManagement.findTargetFilterQueryByName(filterName).get().getQuery());
|
||||
targetFilterQueryManagement.getByName(filterName).get().getQuery());
|
||||
|
||||
}
|
||||
|
||||
@@ -166,15 +167,15 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test assigning a distribution set")
|
||||
public void assignDistributionSet() {
|
||||
final String filterName = "target_filter_02";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(targetFilterQuery.getId(),
|
||||
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(),
|
||||
distributionSet.getId());
|
||||
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement.findTargetFilterQueryByName(filterName).get();
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
|
||||
assertEquals("Returns correct distribution set", distributionSet, tfq.getAutoAssignDistributionSet());
|
||||
|
||||
@@ -184,22 +185,22 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
@Description("Test removing distribution set while it has a relation to a target filter query")
|
||||
public void removeAssignDistributionSet() {
|
||||
final String filterName = "target_filter_03";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(targetFilterQuery.getId(),
|
||||
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(),
|
||||
distributionSet.getId());
|
||||
|
||||
// Check if target filter query is there
|
||||
TargetFilterQuery tfq = targetFilterQueryManagement.findTargetFilterQueryByName(filterName).get();
|
||||
TargetFilterQuery tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
assertEquals("Returns correct distribution set", distributionSet, tfq.getAutoAssignDistributionSet());
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(distributionSet.getId());
|
||||
distributionSetManagement.delete(distributionSet.getId());
|
||||
|
||||
// Check if auto assign distribution set is null
|
||||
tfq = targetFilterQueryManagement.findTargetFilterQueryByName(filterName).get();
|
||||
tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
assertNotNull("Returns target filter query", tfq);
|
||||
assertNull("Returns distribution set as null", tfq.getAutoAssignDistributionSet());
|
||||
|
||||
@@ -216,23 +217,23 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
// later step
|
||||
assignDistributionSet(distributionSet.getId(), target.getControllerId());
|
||||
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(targetFilterQueryManagement
|
||||
.createTargetFilterQuery(
|
||||
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQueryManagement
|
||||
.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"))
|
||||
.getId(), distributionSet.getId());
|
||||
|
||||
// Check if target filter query is there with the distribution set
|
||||
TargetFilterQuery tfq = targetFilterQueryManagement.findTargetFilterQueryByName(filterName).get();
|
||||
TargetFilterQuery tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
assertEquals("Returns correct distribution set", distributionSet, tfq.getAutoAssignDistributionSet());
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(distributionSet.getId());
|
||||
distributionSetManagement.delete(distributionSet.getId());
|
||||
|
||||
// Check if distribution set is still in the database with deleted flag
|
||||
assertTrue("Distribution set should be deleted",
|
||||
distributionSetManagement.findDistributionSetById(distributionSet.getId()).get().isDeleted());
|
||||
distributionSetManagement.get(distributionSet.getId()).get().isDeleted());
|
||||
|
||||
// Check if auto assign distribution set is null
|
||||
tfq = targetFilterQueryManagement.findTargetFilterQueryByName(filterName).get();
|
||||
tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
assertNotNull("Returns target filter query", tfq);
|
||||
assertNull("Returns distribution set as null", tfq.getAutoAssignDistributionSet());
|
||||
|
||||
@@ -244,40 +245,40 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
|
||||
final String filterName = "d";
|
||||
|
||||
assertEquals(0L, targetFilterQueryManagement.countAllTargetFilterQuery().longValue());
|
||||
assertEquals(0L, targetFilterQueryManagement.count());
|
||||
|
||||
targetFilterQueryManagement
|
||||
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name("a").query("name==*"));
|
||||
.create(entityFactory.targetFilterQuery().create().name("a").query("name==*"));
|
||||
targetFilterQueryManagement
|
||||
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name("b").query("name==*"));
|
||||
.create(entityFactory.targetFilterQuery().create().name("b").query("name==*"));
|
||||
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet();
|
||||
final DistributionSet distributionSet2 = testdataFactory.createDistributionSet("2");
|
||||
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement
|
||||
.updateTargetFilterQueryAutoAssignDS(
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
.updateAutoAssignDS(
|
||||
targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name("c").query("name==x")).getId(),
|
||||
distributionSet.getId());
|
||||
|
||||
final TargetFilterQuery tfq2 = targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(
|
||||
targetFilterQueryManagement.createTargetFilterQuery(
|
||||
final TargetFilterQuery tfq2 = targetFilterQueryManagement.updateAutoAssignDS(
|
||||
targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==z*")).getId(),
|
||||
distributionSet2.getId());
|
||||
|
||||
assertEquals(4L, targetFilterQueryManagement.countAllTargetFilterQuery().longValue());
|
||||
assertEquals(4L, targetFilterQueryManagement.count());
|
||||
|
||||
// check if find works
|
||||
Page<TargetFilterQuery> tfqList = targetFilterQueryManagement
|
||||
.findTargetFilterQueryByAutoAssignDS(new PageRequest(0, 500), distributionSet.getId(), null);
|
||||
.findByAutoAssignDSAndRsql(new PageRequest(0, 500), distributionSet.getId(), null);
|
||||
assertThat(1L).as("Target filter query").isEqualTo(tfqList.getTotalElements());
|
||||
|
||||
assertEquals("Returns correct target filter query", tfq.getId(), tfqList.iterator().next().getId());
|
||||
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(tfq2.getId(), distributionSet.getId());
|
||||
targetFilterQueryManagement.updateAutoAssignDS(tfq2.getId(), distributionSet.getId());
|
||||
|
||||
// check if find works for two
|
||||
tfqList = targetFilterQueryManagement.findTargetFilterQueryByAutoAssignDS(new PageRequest(0, 500),
|
||||
tfqList = targetFilterQueryManagement.findByAutoAssignDSAndRsql(new PageRequest(0, 500),
|
||||
distributionSet.getId(), null);
|
||||
assertThat(2L).as("Target filter query count").isEqualTo(tfqList.getTotalElements());
|
||||
Iterator<TargetFilterQuery> iterator = tfqList.iterator();
|
||||
@@ -285,14 +286,14 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
assertEquals("Returns correct target filter query 2", tfq2.getId(), iterator.next().getId());
|
||||
|
||||
// check if find works with name filter
|
||||
tfqList = targetFilterQueryManagement.findTargetFilterQueryByAutoAssignDS(new PageRequest(0, 500),
|
||||
tfqList = targetFilterQueryManagement.findByAutoAssignDSAndRsql(new PageRequest(0, 500),
|
||||
distributionSet.getId(), "name==" + filterName);
|
||||
assertThat(1L).as("Target filter query count").isEqualTo(tfqList.getTotalElements());
|
||||
|
||||
assertEquals("Returns correct target filter query", tfq2.getId(), tfqList.iterator().next().getId());
|
||||
|
||||
// check if find works for all with auto assign DS
|
||||
tfqList = targetFilterQueryManagement.findTargetFilterQueryWithAutoAssignDS(new PageRequest(0, 500));
|
||||
tfqList = targetFilterQueryManagement.findWithAutoAssignDS(new PageRequest(0, 500));
|
||||
assertThat(2L).as("Target filter query count").isEqualTo(tfqList.getTotalElements());
|
||||
iterator = tfqList.iterator();
|
||||
assertEquals("Returns correct target filter query 1", tfq.getId(), iterator.next().getId());
|
||||
|
||||
@@ -47,10 +47,10 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
+ "That includes both the test itself, as a count operation with the same filters "
|
||||
+ "and query definitions by RSQL (named and un-named).")
|
||||
public void targetSearchWithVariousFilterCombinations() {
|
||||
final TargetTag targTagX = tagManagement.createTargetTag(entityFactory.tag().create().name("TargTag-X"));
|
||||
final TargetTag targTagY = tagManagement.createTargetTag(entityFactory.tag().create().name("TargTag-Y"));
|
||||
final TargetTag targTagZ = tagManagement.createTargetTag(entityFactory.tag().create().name("TargTag-Z"));
|
||||
final TargetTag targTagW = tagManagement.createTargetTag(entityFactory.tag().create().name("TargTag-W"));
|
||||
final TargetTag targTagX = targetTagManagement.create(entityFactory.tag().create().name("TargTag-X"));
|
||||
final TargetTag targTagY = targetTagManagement.create(entityFactory.tag().create().name("TargTag-Y"));
|
||||
final TargetTag targTagZ = targetTagManagement.create(entityFactory.tag().create().name("TargTag-Z"));
|
||||
final TargetTag targTagW = targetTagManagement.create(entityFactory.tag().create().name("TargTag-W"));
|
||||
|
||||
final DistributionSet setA = testdataFactory.createDistributionSet("");
|
||||
|
||||
@@ -66,7 +66,7 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
targAs = toggleTagAssignment(targAs, targTagX).getAssignedEntity();
|
||||
|
||||
final Target targSpecialName = targetManagement
|
||||
.updateTarget(entityFactory.target().update(targAs.get(0).getControllerId()).name("targ-A-special"));
|
||||
.update(entityFactory.target().update(targAs.get(0).getControllerId()).name("targ-A-special"));
|
||||
|
||||
final String targetDsBIdPref = "targ-B";
|
||||
List<Target> targBs = testdataFactory.createTargets(100, targetDsBIdPref,
|
||||
@@ -102,61 +102,58 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final List<TargetUpdateStatus> unknown = Arrays.asList(TargetUpdateStatus.UNKNOWN);
|
||||
final List<TargetUpdateStatus> pending = Arrays.asList(TargetUpdateStatus.PENDING);
|
||||
final List<TargetUpdateStatus> both = Arrays.asList(TargetUpdateStatus.UNKNOWN,
|
||||
TargetUpdateStatus.PENDING);
|
||||
final List<TargetUpdateStatus> both = Arrays.asList(TargetUpdateStatus.UNKNOWN, TargetUpdateStatus.PENDING);
|
||||
|
||||
// get final updated version of targets
|
||||
targAs = targetManagement
|
||||
.findTargetsByControllerID(targAs.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
.getByControllerID(targAs.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
targBs = targetManagement
|
||||
.findTargetsByControllerID(targBs.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
.getByControllerID(targBs.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
targCs = targetManagement
|
||||
.findTargetsByControllerID(targCs.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
.getByControllerID(targCs.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
|
||||
// try to find several targets with different filter settings
|
||||
verifyThat1TargetHasNameAndId("targ-A-special", targSpecialName.getControllerId());
|
||||
verifyThatRepositoryContains400Targets();
|
||||
verifyThat200TargetsHaveTagD(targTagW, concat(targBs, targCs));
|
||||
verifyThat100TargetsContainsGivenTextAndHaveTagAssigned(targTagY, targTagW, targBs);
|
||||
verifyThat1TargetHasTagHasDescOrNameAndDs(targTagW, setA,
|
||||
targetManagement.findTargetByControllerID(assignedC).get());
|
||||
verifyThat1TargetHasTagHasDescOrNameAndDs(targTagW, setA, targetManagement.getByControllerID(assignedC).get());
|
||||
verifyThat0TargetsWithTagAndDescOrNameHasDS(targTagW, setA);
|
||||
verifyThat0TargetsWithNameOrdescAndDSHaveTag(targTagX, setA);
|
||||
verifyThat3TargetsHaveDSAssigned(setA,
|
||||
targetManagement.findTargetsByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
verifyThat1TargetWithDescOrNameHasDS(setA, targetManagement.findTargetByControllerID(assignedA).get());
|
||||
targetManagement.getByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
verifyThat1TargetWithDescOrNameHasDS(setA, targetManagement.getByControllerID(assignedA).get());
|
||||
List<Target> expected = concat(targAs, targBs, targCs, targDs);
|
||||
expected.removeAll(
|
||||
targetManagement.findTargetsByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
expected.removeAll(targetManagement.getByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
verifyThat397TargetsAreInStatusUnknown(unknown, expected);
|
||||
expected = concat(targBs, targCs);
|
||||
expected.removeAll(targetManagement.findTargetsByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
expected.removeAll(targetManagement.getByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
verifyThat198TargetsAreInStatusUnknownAndHaveGivenTags(targTagY, targTagW, unknown, expected);
|
||||
verfyThat0TargetsAreInStatusUnknownAndHaveDSAssigned(setA, unknown);
|
||||
expected = concat(targAs);
|
||||
expected.remove(targetManagement.findTargetByControllerID(assignedA).get());
|
||||
expected.remove(targetManagement.getByControllerID(assignedA).get());
|
||||
verifyThat99TargetsWithNameOrDescriptionAreInGivenStatus(unknown, expected);
|
||||
expected = concat(targBs);
|
||||
expected.remove(targetManagement.findTargetByControllerID(assignedB).get());
|
||||
expected.remove(targetManagement.getByControllerID(assignedB).get());
|
||||
verifyThat99TargetsWithGivenNameOrDescAndTagAreInStatusUnknown(targTagW, unknown, expected);
|
||||
verifyThat3TargetsAreInStatusPending(pending,
|
||||
targetManagement.findTargetsByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
targetManagement.getByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
verifyThat3TargetsWithGivenDSAreInPending(setA, pending,
|
||||
targetManagement.findTargetsByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
targetManagement.getByControllerID(Arrays.asList(assignedA, assignedB, assignedC)));
|
||||
verifyThat1TargetWithGivenNameOrDescAndDSIsInPending(setA, pending,
|
||||
targetManagement.findTargetByControllerID(assignedA).get());
|
||||
targetManagement.getByControllerID(assignedA).get());
|
||||
verifyThat1TargetWithGivenNameOrDescAndTagAndDSIsInPending(targTagW, setA, pending,
|
||||
targetManagement.findTargetByControllerID(assignedB).get());
|
||||
targetManagement.getByControllerID(assignedB).get());
|
||||
verifyThat2TargetsWithGivenTagAndDSIsInPending(targTagW, setA, pending,
|
||||
targetManagement.findTargetsByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
targetManagement.getByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
verifyThat2TargetsWithGivenTagAreInPending(targTagW, pending,
|
||||
targetManagement.findTargetsByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
targetManagement.getByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
verifyThat200targetsWithGivenTagAreInStatusPendingorUnknown(targTagW, both, concat(targBs, targCs));
|
||||
verfiyThat1TargetAIsInStatusPendingAndHasDSInstalled(installedSet, pending,
|
||||
targetManagement.findTargetByControllerID(installedC).get());
|
||||
targetManagement.getByControllerID(installedC).get());
|
||||
|
||||
expected = concat(targBs, targCs);
|
||||
expected.removeAll(targetManagement.findTargetsByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
expected.removeAll(targetManagement.getByControllerID(Arrays.asList(assignedB, assignedC)));
|
||||
verifyThat198TargetsAreInStatusUnknownAndOverdue(unknown, expected);
|
||||
}
|
||||
|
||||
@@ -165,14 +162,15 @@ 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(PAGE, pending, null, null, installedSet.getId(), Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(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,
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@@ -182,13 +180,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "(updatestatus==pending or updatestatus==unknown) and tag==" + targTagW.getName();
|
||||
|
||||
assertThat(targetManagement
|
||||
.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,
|
||||
.findByFilters(PAGE, new FilterParams(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.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -197,14 +196,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==pending and tag==" + targTagW.getName();
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, pending, null, null, null, Boolean.FALSE, targTagW.getName())
|
||||
.findByFilters(PAGE, new FilterParams(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,
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -214,14 +213,15 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
+ setA.getName() + ") and tag==" + targTagW.getName();
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, pending, null, null, setA.getId(), Boolean.FALSE, targTagW.getName())
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(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())))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -230,14 +230,16 @@ 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(PAGE, pending, null, "%targ-B%", setA.getId(), Boolean.FALSE,
|
||||
targTagW.getName()).getContent()).as("has number of elements").hasSize(1)
|
||||
assertThat(targetManagement
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(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%",
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -247,14 +249,15 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
+ setA.getName() + ") and (name==*targ-A* or description==*targ-A*)";
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, pending, null, "%targ-A%", setA.getId(), Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(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%",
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -264,14 +267,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
+ setA.getName() + ")";
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, pending, null, null, setA.getId(), Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE, new FilterParams(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])))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -280,13 +283,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==pending";
|
||||
|
||||
assertThat(targetManagement
|
||||
.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,
|
||||
.findByFilters(PAGE, new FilterParams(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.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -296,14 +300,15 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
+ targTagW.getName();
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, unknown, null, "%targ-B%", null, Boolean.FALSE, targTagW.getName())
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(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())))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -312,14 +317,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==unknown and (name==*targ-A* or description==*targ-A*)";
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, unknown, null, "%targ-A%", null, Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE, new FilterParams(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])))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@@ -330,13 +335,13 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
+ setA.getName() + ")";
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, unknown, null, null, setA.getId(), Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE, new FilterParams(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])))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(unknown, null, null, setA.getId(),
|
||||
Boolean.FALSE, new String[0])))
|
||||
.as("and filter query returns the same result")
|
||||
.hasSize(targetManagement.findTargetsAll(query, PAGE).getContent().size());
|
||||
.hasSize(targetManagement.findByRsql(PAGE, query).getContent().size());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -345,14 +350,15 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==unknown and (tag==" + targTagY.getName() + " or tag==" + targTagW.getName()
|
||||
+ ")";
|
||||
|
||||
assertThat(targetManagement.findTargetByFilters(PAGE, unknown, null, null, null, Boolean.FALSE,
|
||||
targTagY.getName(), targTagW.getName()).getContent()).as("has number of elements").hasSize(198)
|
||||
assertThat(targetManagement.findByFilters(PAGE,
|
||||
new FilterParams(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,
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -361,13 +367,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "updatestatus==unknown";
|
||||
|
||||
assertThat(targetManagement
|
||||
.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,
|
||||
.findByFilters(PAGE, new FilterParams(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.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@@ -378,14 +385,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "lastcontrollerrequestat=le=${overdue_ts};updatestatus==UNKNOWN";
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, unknown, Boolean.TRUE, null, null, Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE, new FilterParams(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])))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -394,14 +401,15 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
+ " or installedds.name==" + setA.getName() + ")";
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, null, null, "%targ-A%", setA.getId(), Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(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%",
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@@ -410,14 +418,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String query = "assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName();
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, null, null, null, setA.getId(), Boolean.FALSE, new String[0])
|
||||
.findByFilters(PAGE, new FilterParams(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])))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@@ -426,13 +434,14 @@ 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(PAGE, null, null, "%targ-C%", setA.getId(), Boolean.FALSE, targTagX.getName())
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(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%",
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(null, null, "%targ-C%",
|
||||
setA.getId(), Boolean.FALSE, targTagX.getName())))
|
||||
.as("and filter query returns the same result")
|
||||
.hasSize(targetManagement.findTargetsAll(query, PAGE).getContent().size());
|
||||
.hasSize(targetManagement.findByRsql(PAGE, query).getContent().size());
|
||||
|
||||
}
|
||||
|
||||
@@ -441,13 +450,14 @@ 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(PAGE, null, null, "%targ-A%", setA.getId(), Boolean.FALSE, targTagW.getName())
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(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%",
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(null, null, "%targ-A%",
|
||||
setA.getId(), Boolean.FALSE, targTagW.getName())))
|
||||
.as("and filter query returns the same result")
|
||||
.hasSize(targetManagement.findTargetsAll(query, PAGE).getContent().size());
|
||||
.hasSize(targetManagement.findByRsql(PAGE, query).getContent().size());
|
||||
|
||||
}
|
||||
|
||||
@@ -457,27 +467,29 @@ 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(PAGE, null, null, "%targ-C%", setA.getId(), Boolean.FALSE, targTagW.getName())
|
||||
.findByFilters(PAGE,
|
||||
new FilterParams(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%",
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@Step
|
||||
private void verifyThat1TargetHasNameAndId(final String name, final String controllerId) {
|
||||
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.findByFilters(PAGE, new FilterParams(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.countByFilters(null, null, name, null, Boolean.FALSE)));
|
||||
|
||||
assertThat(targetManagement.findTargetByFilters(PAGE, null, null, controllerId, null, Boolean.FALSE)
|
||||
assertThat(targetManagement.findByFilters(PAGE, new FilterParams(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)));
|
||||
targetManagement.countByFilters(null, null, controllerId, null, Boolean.FALSE)));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -485,14 +497,15 @@ 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(PAGE, null, null, "%targ-B%", null, Boolean.FALSE,
|
||||
targTagY.getName(), targTagW.getName()).getContent()).as("has number of elements").hasSize(100)
|
||||
assertThat(targetManagement.findByFilters(PAGE,
|
||||
new FilterParams(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,
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@@ -507,26 +520,25 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
private void verifyThat200TargetsHaveTagD(final TargetTag targTagD, final List<Target> expected) {
|
||||
final String query = "tag==" + targTagD.getName();
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(PAGE, null, null, null, null, Boolean.FALSE, targTagD.getName()).getContent())
|
||||
.as("Expected number of results is").hasSize(200)
|
||||
.findByFilters(PAGE, new FilterParams(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,
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countByFilters(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, PAGE).getContent());
|
||||
.containsAll(targetManagement.findByRsql(PAGE, query).getContent());
|
||||
|
||||
}
|
||||
|
||||
@Step
|
||||
private void verifyThatRepositoryContains400Targets() {
|
||||
assertThat(
|
||||
targetManagement.findTargetByFilters(PAGE, null, null, null, null, null, new String[0]).getContent())
|
||||
.as("Overall we expect that many targets in the repository").hasSize(400)
|
||||
assertThat(targetManagement.findByFilters(PAGE, new FilterParams(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()))
|
||||
.hasSize(Ints.saturatedCast(targetManagement.count()))
|
||||
.as("which is also reflected by call without specification")
|
||||
.containsAll(targetManagement.findTargetsAll(PAGE).getContent());
|
||||
.containsAll(targetManagement.findAll(PAGE).getContent());
|
||||
|
||||
}
|
||||
|
||||
@@ -546,7 +558,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(PAGE, ds.getId(),
|
||||
final Slice<Target> result = targetManagement.findByFilterOrderByLinkedDistributionSet(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());
|
||||
@@ -580,11 +592,11 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
List<Target> targInstalled = Lists.newArrayListWithExpectedSize(overdueMix.length);
|
||||
|
||||
for (int i = 0; i < overdueMix.length; i++) {
|
||||
notAssigned.add(targetManagement.createTarget(
|
||||
entityFactory.target().create().controllerId("not" + i).lastTargetQuery(overdueMix[i])));
|
||||
targAssigned.add(targetManagement.createTarget(
|
||||
notAssigned.add(targetManagement
|
||||
.create(entityFactory.target().create().controllerId("not" + i).lastTargetQuery(overdueMix[i])));
|
||||
targAssigned.add(targetManagement.create(
|
||||
entityFactory.target().create().controllerId("assigned" + i).lastTargetQuery(overdueMix[i])));
|
||||
targInstalled.add(targetManagement.createTarget(
|
||||
targInstalled.add(targetManagement.create(
|
||||
entityFactory.target().create().controllerId("installed" + i).lastTargetQuery(overdueMix[i])));
|
||||
}
|
||||
|
||||
@@ -596,8 +608,8 @@ 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(PAGE, ds.getId(),
|
||||
new FilterParams(null, null, Boolean.TRUE, null, Boolean.FALSE, new String[0]));
|
||||
final Slice<Target> result = targetManagement.findByFilterOrderByLinkedDistributionSet(PAGE, ds.getId(),
|
||||
new FilterParams(null, Boolean.TRUE, null, null, Boolean.FALSE, new String[0]));
|
||||
|
||||
final Comparator<TenantAwareBaseEntity> byId = (e1, e2) -> Long.compare(e2.getId(), e1.getId());
|
||||
|
||||
@@ -627,10 +639,10 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
assignDistributionSet(assignedSet, assignedtargets);
|
||||
|
||||
// get final updated version of targets
|
||||
assignedtargets = targetManagement.findTargetsByControllerID(
|
||||
assignedtargets = targetManagement.getByControllerID(
|
||||
assignedtargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()));
|
||||
|
||||
assertThat(targetManagement.findTargetByAssignedDistributionSet(assignedSet.getId(), PAGE))
|
||||
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, assignedSet.getId()))
|
||||
.as("Contains the assigned targets").containsAll(assignedtargets)
|
||||
.as("and that means the following expected amount").hasSize(10);
|
||||
|
||||
@@ -641,14 +653,14 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
public void findTargetWithoutAssignedDistributionSet() {
|
||||
final DistributionSet assignedSet = testdataFactory.createDistributionSet("");
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement
|
||||
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name("tfq").query("name==*"));
|
||||
.create(entityFactory.targetFilterQuery().create().name("tfq").query("name==*"));
|
||||
final List<Target> unassignedTargets = testdataFactory.createTargets(12, "unassigned", "unassigned");
|
||||
final List<Target> assignedTargets = testdataFactory.createTargets(10, "assigned", "assigned");
|
||||
|
||||
assignDistributionSet(assignedSet, assignedTargets);
|
||||
|
||||
final List<Target> result = targetManagement
|
||||
.findAllTargetsByTargetFilterQueryAndNonDS(PAGE, assignedSet.getId(), tfq.getQuery()).getContent();
|
||||
.findByTargetFilterQueryAndNonDS(PAGE, assignedSet.getId(), tfq.getQuery()).getContent();
|
||||
assertThat(result).as("count of targets").hasSize(unassignedTargets.size()).as("contains all targets")
|
||||
.containsAll(unassignedTargets);
|
||||
|
||||
@@ -668,10 +680,10 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
assignDistributionSet(assignedSet, installedtargets);
|
||||
|
||||
// get final updated version of targets
|
||||
installedtargets = targetManagement.findTargetsByControllerID(
|
||||
installedtargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()));
|
||||
installedtargets = targetManagement
|
||||
.getByControllerID(installedtargets.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||
|
||||
assertThat(targetManagement.findTargetByInstalledDistributionSet(installedSet.getId(), PAGE))
|
||||
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, installedSet.getId()))
|
||||
.as("Contains the assigned targets").containsAll(installedtargets)
|
||||
.as("and that means the following expected amount").hasSize(10);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import javax.validation.ConstraintViolationException;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.FilterParams;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent;
|
||||
@@ -71,8 +72,8 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
+ "of Optional not present.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(targetManagement.findTargetByControllerID(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(targetManagement.findTargetById(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(targetManagement.getByControllerID(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(targetManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,45 +82,42 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetTagCreatedEvent.class, count = 1) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
final TargetTag tag = tagManagement.createTargetTag(entityFactory.tag().create().name("A"));
|
||||
final TargetTag tag = targetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
final Target target = testdataFactory.createTarget();
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetManagement.assignTag(Arrays.asList(target.getControllerId()), NOT_EXIST_IDL), "TargetTag");
|
||||
verifyThrownExceptionBy(() -> targetManagement.assignTag(Arrays.asList(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.findByTag(PAGE, NOT_EXIST_IDL), "TargetTag");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByRsqlAndTag(PAGE, "name==*", NOT_EXIST_IDL), "TargetTag");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetManagement.countTargetByAssignedDistributionSet(NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> targetManagement.countByAssignedDistributionSet(NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(() -> targetManagement.countTargetByInstalledDistributionSet(NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> targetManagement.countByInstalledDistributionSet(NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetManagement.countTargetByTargetFilterQuery(NOT_EXIST_IDL),
|
||||
"TargetFilterQuery");
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetManagement.countTargetsByTargetFilterQueryAndNonDS(NOT_EXIST_IDL, "name==*"),
|
||||
verifyThrownExceptionBy(() -> targetManagement.countByTargetFilterQuery(NOT_EXIST_IDL), "TargetFilterQuery");
|
||||
verifyThrownExceptionBy(() -> targetManagement.countByRsqlAndNonDS(NOT_EXIST_IDL, "name==*"),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetManagement.deleteTarget(NOT_EXIST_ID), "Target");
|
||||
verifyThrownExceptionBy(() -> targetManagement.deleteTargets(Arrays.asList(NOT_EXIST_IDL)), "Target");
|
||||
verifyThrownExceptionBy(() -> targetManagement.deleteByControllerID(NOT_EXIST_ID), "Target");
|
||||
verifyThrownExceptionBy(() -> targetManagement.delete(Arrays.asList(NOT_EXIST_IDL)), "Target");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetManagement.findAllTargetsByTargetFilterQueryAndNonDS(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByTargetFilterQueryAndNonDS(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findAllTargetsInRolloutGroupWithoutAction(PAGE, NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByInRolloutGroupWithoutAction(PAGE, NOT_EXIST_IDL),
|
||||
"RolloutGroup");
|
||||
verifyThrownExceptionBy(() -> targetManagement.findTargetByAssignedDistributionSet(NOT_EXIST_IDL, PAGE),
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByAssignedDistributionSet(PAGE, NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetManagement.findTargetByAssignedDistributionSet(NOT_EXIST_IDL, "name==*", PAGE),
|
||||
() -> targetManagement.findByAssignedDistributionSetAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetManagement.findTargetByInstalledDistributionSet(NOT_EXIST_IDL, PAGE),
|
||||
verifyThrownExceptionBy(() -> targetManagement.findByInstalledDistributionSet(PAGE, NOT_EXIST_IDL),
|
||||
"DistributionSet");
|
||||
verifyThrownExceptionBy(
|
||||
() -> targetManagement.findTargetByInstalledDistributionSet(NOT_EXIST_IDL, "name==*", PAGE),
|
||||
() -> targetManagement.findByInstalledDistributionSetAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
@@ -131,16 +129,15 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
verifyThrownExceptionBy(() -> targetManagement.unAssignTag(NOT_EXIST_ID, tag.getId()), "Target");
|
||||
verifyThrownExceptionBy(() -> targetManagement.unAssignTag(target.getControllerId(), NOT_EXIST_IDL),
|
||||
"TargetTag");
|
||||
verifyThrownExceptionBy(() -> targetManagement.updateTarget(entityFactory.target().update(NOT_EXIST_ID)),
|
||||
"Target");
|
||||
verifyThrownExceptionBy(() -> targetManagement.update(entityFactory.target().update(NOT_EXIST_ID)), "Target");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that retrieving the target security is only permitted with the necessary permissions.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
|
||||
public void getTargetSecurityTokenOnlyWithCorrectPermission() throws Exception {
|
||||
final Target createdTarget = targetManagement.createTarget(
|
||||
entityFactory.target().create().controllerId("targetWithSecurityToken").securityToken("token"));
|
||||
final Target createdTarget = targetManagement
|
||||
.create(entityFactory.target().create().controllerId("targetWithSecurityToken").securityToken("token"));
|
||||
|
||||
// retrieve security token only with READ_TARGET_SEC_TOKEN permission
|
||||
final String securityTokenWithReadPermission = securityRule.runAs(WithSpringAuthorityRule
|
||||
@@ -172,7 +169,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
public void createTargetForTenantWhichDoesNotExistThrowsTenantNotExistException() {
|
||||
try {
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId("targetId123"));
|
||||
targetManagement.create(entityFactory.target().create().controllerId("targetId123"));
|
||||
fail("should not be possible as the tenant does not exist");
|
||||
} catch (final TenantNotExistException e) {
|
||||
// ok
|
||||
@@ -183,10 +180,10 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Verify that a target with same controller ID than another device cannot be created.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
|
||||
public void createTargetThatViolatesUniqueConstraintFails() {
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId("123"));
|
||||
targetManagement.create(entityFactory.target().create().controllerId("123"));
|
||||
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("123")));
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("123")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -207,12 +204,12 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createAndUpdateTargetWithInvalidDescription(final Target target) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("a")
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("a")
|
||||
.description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("target with too long description should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.updateTarget(entityFactory.target().update(target.getControllerId())
|
||||
.isThrownBy(() -> targetManagement.update(entityFactory.target().update(target.getControllerId())
|
||||
.description(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("target with too long description should not be updated");
|
||||
|
||||
@@ -222,17 +219,18 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createAndUpdateTargetWithInvalidName(final Target target) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("a")
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("a")
|
||||
.name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("target with too long name should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.updateTarget(entityFactory.target().update(target.getControllerId())
|
||||
.isThrownBy(() -> targetManagement.update(entityFactory.target().update(target.getControllerId())
|
||||
.name(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("target with too long name should not be updated");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||
() -> targetManagement.updateTarget(entityFactory.target().update(target.getControllerId()).name("")))
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(
|
||||
() -> targetManagement.update(entityFactory.target().update(target.getControllerId()).name("")))
|
||||
.as("target with too short name should not be updated");
|
||||
|
||||
}
|
||||
@@ -241,18 +239,18 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createAndUpdateTargetWithInvalidSecurityToken(final Target target) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("a")
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("a")
|
||||
.securityToken(RandomStringUtils.randomAlphanumeric(129))))
|
||||
.as("target with too long token should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.updateTarget(entityFactory.target().update(target.getControllerId())
|
||||
.isThrownBy(() -> targetManagement.update(entityFactory.target().update(target.getControllerId())
|
||||
.securityToken(RandomStringUtils.randomAlphanumeric(129))))
|
||||
.as("target with too long token should not be updated");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement
|
||||
.updateTarget(entityFactory.target().update(target.getControllerId()).securityToken("")))
|
||||
.update(entityFactory.target().update(target.getControllerId()).securityToken("")))
|
||||
.as("target with too short token should not be updated");
|
||||
}
|
||||
|
||||
@@ -260,12 +258,12 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createAndUpdateTargetWithInvalidAddress(final Target target) {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("a")
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("a")
|
||||
.address(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("target with too long address should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.updateTarget(entityFactory.target().update(target.getControllerId())
|
||||
.isThrownBy(() -> targetManagement.update(entityFactory.target().update(target.getControllerId())
|
||||
.address(RandomStringUtils.randomAlphanumeric(513))))
|
||||
.as("target with too long address should not be updated");
|
||||
}
|
||||
@@ -273,41 +271,40 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Step
|
||||
private void createTargetWithInvalidControllerId() {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("")))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("")))
|
||||
.as("target with empty controller id should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId(null)))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId(null)))
|
||||
.as("target with null controller id should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(
|
||||
entityFactory.target().create().controllerId(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.isThrownBy(() -> targetManagement
|
||||
.create(entityFactory.target().create().controllerId(RandomStringUtils.randomAlphanumeric(65))))
|
||||
.as("target with too long controller id should not be created");
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId(" ")))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId(" ")))
|
||||
.as(WHITESPACE_ERROR);
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId(" a")))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId(" a")))
|
||||
.as(WHITESPACE_ERROR);
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("a ")))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("a ")))
|
||||
.as(WHITESPACE_ERROR);
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId("a b")))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("a b")))
|
||||
.as(WHITESPACE_ERROR);
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(() -> targetManagement.createTarget(entityFactory.target().create().controllerId(" ")))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId(" ")))
|
||||
.as(WHITESPACE_ERROR);
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.isThrownBy(
|
||||
() -> targetManagement.createTarget(entityFactory.target().create().controllerId("aaa bbb")))
|
||||
.isThrownBy(() -> targetManagement.create(entityFactory.target().create().controllerId("aaa bbb")))
|
||||
.as(WHITESPACE_ERROR);
|
||||
|
||||
}
|
||||
@@ -319,36 +316,36 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 5) })
|
||||
public void assignAndUnassignTargetsToTag() {
|
||||
final List<String> assignTarget = new ArrayList<>();
|
||||
assignTarget.add(targetManagement.createTarget(entityFactory.target().create().controllerId("targetId123"))
|
||||
assignTarget.add(
|
||||
targetManagement.create(entityFactory.target().create().controllerId("targetId123")).getControllerId());
|
||||
assignTarget.add(targetManagement.create(entityFactory.target().create().controllerId("targetId1234"))
|
||||
.getControllerId());
|
||||
assignTarget.add(targetManagement.createTarget(entityFactory.target().create().controllerId("targetId1234"))
|
||||
assignTarget.add(targetManagement.create(entityFactory.target().create().controllerId("targetId1235"))
|
||||
.getControllerId());
|
||||
assignTarget.add(targetManagement.createTarget(entityFactory.target().create().controllerId("targetId1235"))
|
||||
.getControllerId());
|
||||
assignTarget.add(targetManagement.createTarget(entityFactory.target().create().controllerId("targetId1236"))
|
||||
assignTarget.add(targetManagement.create(entityFactory.target().create().controllerId("targetId1236"))
|
||||
.getControllerId());
|
||||
|
||||
final TargetTag targetTag = tagManagement.createTargetTag(entityFactory.tag().create().name("Tag1"));
|
||||
final TargetTag targetTag = targetTagManagement.create(entityFactory.tag().create().name("Tag1"));
|
||||
|
||||
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(PAGE, target.getControllerId()).getNumberOfElements()).isEqualTo(1));
|
||||
targetTagManagement.findByTarget(PAGE, target.getControllerId()).getNumberOfElements())
|
||||
.isEqualTo(1));
|
||||
|
||||
TargetTag findTargetTag = tagManagement.findTargetTag("Tag1").get();
|
||||
TargetTag findTargetTag = targetTagManagement.getByName("Tag1").get();
|
||||
assertThat(assignedTargets.size()).as("Assigned targets are wrong")
|
||||
.isEqualTo(targetManagement.findTargetsByTag(PAGE, targetTag.getId()).getNumberOfElements());
|
||||
.isEqualTo(targetManagement.findByTag(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(PAGE, unAssignTarget.getControllerId())).as("Tag size is wrong")
|
||||
.isEmpty();
|
||||
findTargetTag = tagManagement.findTargetTag("Tag1").get();
|
||||
assertThat(targetManagement.findTargetsByTag(PAGE, targetTag.getId())).as("Assigned targets are wrong")
|
||||
.hasSize(3);
|
||||
assertThat(targetManagement.findTargetsByTag(PAGE, "controllerId==targetId123", targetTag.getId()))
|
||||
assertThat(targetTagManagement.findByTarget(PAGE, unAssignTarget.getControllerId()))
|
||||
.as("Tag size is wrong").isEmpty();
|
||||
findTargetTag = targetTagManagement.getByName("Tag1").get();
|
||||
assertThat(targetManagement.findByTag(PAGE, targetTag.getId())).as("Assigned targets are wrong").hasSize(3);
|
||||
assertThat(targetManagement.findByRsqlAndTag(PAGE, "controllerId==targetId123", targetTag.getId()))
|
||||
.as("Assigned targets are wrong").isEmpty();
|
||||
assertThat(targetManagement.findTargetsByTag(PAGE, "controllerId==targetId1234", targetTag.getId()))
|
||||
assertThat(targetManagement.findByRsqlAndTag(PAGE, "controllerId==targetId1234", targetTag.getId()))
|
||||
.as("Assigned targets are wrong").hasSize(1);
|
||||
|
||||
}
|
||||
@@ -358,32 +355,32 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 12),
|
||||
@Expect(type = TargetDeletedEvent.class, count = 12), @Expect(type = TargetUpdatedEvent.class, count = 6) })
|
||||
public void deleteAndCreateTargets() {
|
||||
Target target = targetManagement.createTarget(entityFactory.target().create().controllerId("targetId123"));
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(1);
|
||||
targetManagement.deleteTargets(Arrays.asList(target.getId()));
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(0);
|
||||
Target target = targetManagement.create(entityFactory.target().create().controllerId("targetId123"));
|
||||
assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(1);
|
||||
targetManagement.delete(Arrays.asList(target.getId()));
|
||||
assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(0);
|
||||
|
||||
target = createTargetWithAttributes("4711");
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(1);
|
||||
targetManagement.deleteTargets(Arrays.asList(target.getId()));
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(0);
|
||||
assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(1);
|
||||
targetManagement.delete(Arrays.asList(target.getId()));
|
||||
assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(0);
|
||||
|
||||
final List<Long> targets = new ArrayList<>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
target = targetManagement.createTarget(entityFactory.target().create().controllerId("" + i));
|
||||
target = targetManagement.create(entityFactory.target().create().controllerId("" + i));
|
||||
targets.add(target.getId());
|
||||
targets.add(createTargetWithAttributes("" + (i * i + 1000)).getId());
|
||||
}
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(10);
|
||||
targetManagement.deleteTargets(targets);
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(0);
|
||||
assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(10);
|
||||
targetManagement.delete(targets);
|
||||
assertThat(targetManagement.count()).as("target count is wrong").isEqualTo(0);
|
||||
}
|
||||
|
||||
private Target createTargetWithAttributes(final String controllerId) {
|
||||
final Map<String, String> testData = new HashMap<>();
|
||||
testData.put("test1", "testdata1");
|
||||
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId(controllerId));
|
||||
targetManagement.create(entityFactory.target().create().controllerId(controllerId));
|
||||
final Target target = controllerManagement.updateControllerAttributes(controllerId, testData);
|
||||
|
||||
assertThat(targetManagement.getControllerAttributes(controllerId)).as("Controller Attributes are wrong")
|
||||
@@ -403,13 +400,13 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("test");
|
||||
final DistributionSet set2 = testdataFactory.createDistributionSet("test2");
|
||||
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByAssignedDistributionSet(set.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByInstalledDistributionSet(set.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByAssignedDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByInstalledDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
|
||||
Target target = createTargetWithAttributes("4711");
|
||||
@@ -423,16 +420,16 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
entityFactory.actionStatus().create(result.getActions().get(0)).status(Status.FINISHED));
|
||||
assignDistributionSet(set2.getId(), "4711");
|
||||
|
||||
target = targetManagement.findTargetByControllerID("4711").get();
|
||||
target = targetManagement.getByControllerID("4711").get();
|
||||
// read data
|
||||
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByAssignedDistributionSet(set.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByInstalledDistributionSet(set.getId())).as("Target count is wrong")
|
||||
.isEqualTo(1);
|
||||
assertThat(targetManagement.countTargetByAssignedDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByAssignedDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
.isEqualTo(1);
|
||||
assertThat(targetManagement.countTargetByInstalledDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
assertThat(targetManagement.countByInstalledDistributionSet(set2.getId())).as("Target count is wrong")
|
||||
.isEqualTo(0);
|
||||
assertThat(target.getLastTargetQuery()).as("Target query is not work").isGreaterThanOrEqualTo(current);
|
||||
assertThat(deploymentManagement.getAssignedDistributionSet("4711").get()).as("Assigned ds size is wrong")
|
||||
@@ -458,9 +455,9 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Checks if the EntityAlreadyExistsException is thrown if a single target with the same controller ID are created twice.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) })
|
||||
public void createTargetDuplicate() {
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId("4711"));
|
||||
targetManagement.create(entityFactory.target().create().controllerId("4711"));
|
||||
try {
|
||||
targetManagement.createTarget(entityFactory.target().create().controllerId("4711"));
|
||||
targetManagement.create(entityFactory.target().create().controllerId("4711"));
|
||||
fail("Target already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
}
|
||||
@@ -484,7 +481,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
private void checkTargetHasTags(final boolean strict, final Iterable<Target> targets, final TargetTag... tags) {
|
||||
_target: for (final Target tl : targets) {
|
||||
for (final Tag tt : tagManagement.findAllTargetTags(PAGE, tl.getControllerId())) {
|
||||
for (final Tag tt : targetTagManagement.findByTarget(PAGE, tl.getControllerId())) {
|
||||
for (final Tag tag : tags) {
|
||||
if (tag.getName().equals(tt.getName())) {
|
||||
continue _target;
|
||||
@@ -500,10 +497,10 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private void checkTargetHasNotTags(final Iterable<Target> targets, final TargetTag... tags) {
|
||||
for (final Target tl : targets) {
|
||||
targetManagement.findTargetByControllerID(tl.getControllerId()).get();
|
||||
targetManagement.getByControllerID(tl.getControllerId()).get();
|
||||
|
||||
for (final Tag tag : tags) {
|
||||
for (final Tag tt : tagManagement.findAllTargetTags(PAGE, tl.getControllerId())) {
|
||||
for (final Tag tt : targetTagManagement.findByTarget(PAGE, tl.getControllerId())) {
|
||||
if (tag.getName().equals(tt.getName())) {
|
||||
fail("Target should have no tags");
|
||||
}
|
||||
@@ -531,7 +528,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertNotNull("The lastModifiedAt attribut of the target should no be null", savedTarget.getLastModifiedAt());
|
||||
|
||||
Thread.sleep(1);
|
||||
savedTarget = targetManagement.updateTarget(
|
||||
savedTarget = targetManagement.update(
|
||||
entityFactory.target().update(savedTarget.getControllerId()).description("changed description"));
|
||||
assertNotNull("The lastModifiedAt attribute of the target should not be null", savedTarget.getLastModifiedAt());
|
||||
assertThat(createdAt).as("CreatedAt compared with saved modifiedAt")
|
||||
@@ -540,7 +537,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
.isNotEqualTo(savedTarget.getLastModifiedAt());
|
||||
modifiedAt = savedTarget.getLastModifiedAt();
|
||||
|
||||
final Target foundTarget = targetManagement.findTargetByControllerID(savedTarget.getControllerId()).get();
|
||||
final Target foundTarget = targetManagement.getByControllerID(savedTarget.getControllerId()).get();
|
||||
assertNotNull("The target should not be null", foundTarget);
|
||||
assertThat(myCtrlID).as("ControllerId compared with saved controllerId")
|
||||
.isEqualTo(foundTarget.getControllerId());
|
||||
@@ -572,7 +569,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
// change the objects and save to again to trigger a change on
|
||||
// lastModifiedAt
|
||||
firstList = firstList.stream()
|
||||
.map(t -> targetManagement.updateTarget(
|
||||
.map(t -> targetManagement.update(
|
||||
entityFactory.target().update(t.getControllerId()).name(t.getName().concat("\tchanged"))))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -600,16 +597,16 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
targetManagement.deleteTarget(extra.getControllerId());
|
||||
targetManagement.deleteByControllerID(extra.getControllerId());
|
||||
|
||||
final int numberToDelete = 50;
|
||||
final Collection<Target> targetsToDelete = firstList.subList(0, numberToDelete);
|
||||
final Target[] deletedTargets = Iterables.toArray(targetsToDelete, Target.class);
|
||||
final List<Long> targetsIdsToDelete = targetsToDelete.stream().map(Target::getId).collect(Collectors.toList());
|
||||
|
||||
targetManagement.deleteTargets(targetsIdsToDelete);
|
||||
targetManagement.delete(targetsIdsToDelete);
|
||||
|
||||
final List<Target> targetsLeft = targetManagement.findTargetsAll(new PageRequest(0, 200)).getContent();
|
||||
final List<Target> targetsLeft = targetManagement.findAll(new PageRequest(0, 200)).getContent();
|
||||
assertThat(firstList.spliterator().getExactSizeIfKnown() - numberToDelete).as("Size of splited list")
|
||||
.isEqualTo(targetsLeft.spliterator().getExactSizeIfKnown());
|
||||
|
||||
@@ -633,17 +630,17 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
final List<TargetTag> t2Tags = testdataFactory.createTargetTags(noT2Tags, "tag2");
|
||||
t2Tags.forEach(tag -> targetManagement.assignTag(Arrays.asList(t2.getControllerId()), tag.getId()));
|
||||
|
||||
final Target t11 = targetManagement.findTargetByControllerID(t1.getControllerId()).get();
|
||||
assertThat(tagManagement.findAllTargetTags(PAGE, t11.getControllerId()).getContent()).as("Tag size is wrong")
|
||||
.hasSize(noT1Tags).containsAll(t1Tags);
|
||||
assertThat(tagManagement.findAllTargetTags(PAGE, t11.getControllerId()).getContent()).as("Tag size is wrong")
|
||||
.hasSize(noT1Tags).doesNotContain(Iterables.toArray(t2Tags, TargetTag.class));
|
||||
final Target t11 = targetManagement.getByControllerID(t1.getControllerId()).get();
|
||||
assertThat(targetTagManagement.findByTarget(PAGE, t11.getControllerId()).getContent())
|
||||
.as("Tag size is wrong").hasSize(noT1Tags).containsAll(t1Tags);
|
||||
assertThat(targetTagManagement.findByTarget(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(PAGE, t21.getControllerId()).getContent()).as("Tag size is wrong")
|
||||
.hasSize(noT2Tags).containsAll(t2Tags);
|
||||
assertThat(tagManagement.findAllTargetTags(PAGE, t21.getControllerId()).getContent()).as("Tag size is wrong")
|
||||
.hasSize(noT2Tags).doesNotContain(Iterables.toArray(t1Tags, TargetTag.class));
|
||||
final Target t21 = targetManagement.getByControllerID(t2.getControllerId()).get();
|
||||
assertThat(targetTagManagement.findByTarget(PAGE, t21.getControllerId()).getContent())
|
||||
.as("Tag size is wrong").hasSize(noT2Tags).containsAll(t2Tags);
|
||||
assertThat(targetTagManagement.findByTarget(PAGE, t21.getControllerId()).getContent())
|
||||
.as("Tag size is wrong").hasSize(noT2Tags).doesNotContain(Iterables.toArray(t1Tags, TargetTag.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -660,10 +657,10 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final List<Target> tagABCTargets = testdataFactory.createTargets(10, "tagABCTargets", "first description");
|
||||
|
||||
final TargetTag tagA = tagManagement.createTargetTag(entityFactory.tag().create().name("A"));
|
||||
final TargetTag tagB = tagManagement.createTargetTag(entityFactory.tag().create().name("B"));
|
||||
final TargetTag tagC = tagManagement.createTargetTag(entityFactory.tag().create().name("C"));
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("X"));
|
||||
final TargetTag tagA = targetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
final TargetTag tagB = targetTagManagement.create(entityFactory.tag().create().name("B"));
|
||||
final TargetTag tagC = targetTagManagement.create(entityFactory.tag().create().name("C"));
|
||||
targetTagManagement.create(entityFactory.tag().create().name("X"));
|
||||
|
||||
// doing different assignments
|
||||
toggleTagAssignment(tagATargets, tagA);
|
||||
@@ -677,7 +674,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
toggleTagAssignment(tagABCTargets, tagB);
|
||||
toggleTagAssignment(tagABCTargets, tagC);
|
||||
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, null, Boolean.FALSE, "X"))
|
||||
assertThat(targetManagement.countByFilters(null, null, null, null, Boolean.FALSE, "X"))
|
||||
.as("Target count is wrong").isEqualTo(0);
|
||||
|
||||
// search for targets with tag tagA
|
||||
@@ -707,11 +704,11 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
checkTargetHasNotTags(tagCTargets, tagA, tagB);
|
||||
|
||||
// check again target lists refreshed from DB
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, null, Boolean.FALSE, "A"))
|
||||
assertThat(targetManagement.countByFilters(null, null, null, null, Boolean.FALSE, "A"))
|
||||
.as("Target count is wrong").isEqualTo(targetWithTagA.size());
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, null, Boolean.FALSE, "B"))
|
||||
assertThat(targetManagement.countByFilters(null, null, null, null, Boolean.FALSE, "B"))
|
||||
.as("Target count is wrong").isEqualTo(targetWithTagB.size());
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, null, Boolean.FALSE, "C"))
|
||||
assertThat(targetManagement.countByFilters(null, null, null, null, Boolean.FALSE, "C"))
|
||||
.as("Target count is wrong").isEqualTo(targetWithTagC.size());
|
||||
}
|
||||
|
||||
@@ -721,9 +718,9 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = TargetCreatedEvent.class, count = 109),
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 227) })
|
||||
public void targetTagBulkUnassignments() {
|
||||
final TargetTag targTagA = tagManagement.createTargetTag(entityFactory.tag().create().name("Targ-A-Tag"));
|
||||
final TargetTag targTagB = tagManagement.createTargetTag(entityFactory.tag().create().name("Targ-B-Tag"));
|
||||
final TargetTag targTagC = tagManagement.createTargetTag(entityFactory.tag().create().name("Targ-C-Tag"));
|
||||
final TargetTag targTagA = targetTagManagement.create(entityFactory.tag().create().name("Targ-A-Tag"));
|
||||
final TargetTag targTagB = targetTagManagement.create(entityFactory.tag().create().name("Targ-B-Tag"));
|
||||
final TargetTag targTagC = targetTagManagement.create(entityFactory.tag().create().name("Targ-C-Tag"));
|
||||
|
||||
final List<Target> targAs = testdataFactory.createTargets(25, "target-id-A", "first description");
|
||||
final List<Target> targBs = testdataFactory.createTargets(20, "target-id-B", "first description");
|
||||
@@ -780,7 +777,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = TargetUpdatedEvent.class, count = 25) })
|
||||
public void findTargetsWithNoTag() {
|
||||
|
||||
final TargetTag targTagA = tagManagement.createTargetTag(entityFactory.tag().create().name("Targ-A-Tag"));
|
||||
final TargetTag targTagA = targetTagManagement.create(entityFactory.tag().create().name("Targ-A-Tag"));
|
||||
final List<Target> targAs = testdataFactory.createTargets(25, "target-id-A", "first description");
|
||||
toggleTagAssignment(targAs, targTagA);
|
||||
|
||||
@@ -788,9 +785,9 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final String[] tagNames = null;
|
||||
final List<Target> targetsListWithNoTag = targetManagement
|
||||
.findTargetByFilters(PAGE, null, null, null, null, Boolean.TRUE, tagNames).getContent();
|
||||
.findByFilters(PAGE, new FilterParams(null, null, null, null, Boolean.TRUE, tagNames)).getContent();
|
||||
|
||||
assertThat(50L).as("Total targets").isEqualTo(targetManagement.countTargetsAll());
|
||||
assertThat(50L).as("Total targets").isEqualTo(targetManagement.count());
|
||||
assertThat(25).as("Targets with no tag").isEqualTo(targetsListWithNoTag.size());
|
||||
|
||||
}
|
||||
@@ -804,8 +801,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
controllerManagement.findOrRegisterTargetIfItDoesNotexist(knownTargetControllerId, new URI("http://127.0.0.1"));
|
||||
|
||||
securityRule.runAs(WithSpringAuthorityRule.withUser("bumlux", "READ_TARGET"), () -> {
|
||||
final Target findTargetByControllerID = targetManagement.findTargetByControllerID(knownTargetControllerId)
|
||||
.get();
|
||||
final Target findTargetByControllerID = targetManagement.getByControllerID(knownTargetControllerId).get();
|
||||
assertThat(findTargetByControllerID).isNotNull();
|
||||
assertThat(findTargetByControllerID.getPollStatus()).isNotNull();
|
||||
return null;
|
||||
@@ -817,16 +813,16 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Test that RSQL filter finds targets with tags or specific ids.")
|
||||
public void findTargetsWithTagOrId() {
|
||||
final String rsqlFilter = "tag==Targ-A-Tag,id==target-id-B-00001,id==target-id-B-00008";
|
||||
final TargetTag targTagA = tagManagement.createTargetTag(entityFactory.tag().create().name("Targ-A-Tag"));
|
||||
final TargetTag targTagA = targetTagManagement.create(entityFactory.tag().create().name("Targ-A-Tag"));
|
||||
final List<String> targAs = testdataFactory.createTargets(25, "target-id-A", "first description").stream()
|
||||
.map(Target::getControllerId).collect(Collectors.toList());
|
||||
targetManagement.toggleTagAssignment(targAs, targTagA.getName());
|
||||
|
||||
testdataFactory.createTargets(25, "target-id-B", "first description");
|
||||
|
||||
final Page<Target> foundTargets = targetManagement.findTargetsAll(rsqlFilter, PAGE);
|
||||
final Page<Target> foundTargets = targetManagement.findByRsql(PAGE, rsqlFilter);
|
||||
|
||||
assertThat(targetManagement.countTargetsAll()).as("Total targets").isEqualTo(50L);
|
||||
assertThat(targetManagement.count()).as("Total targets").isEqualTo(50L);
|
||||
assertThat(foundTargets.getTotalElements()).as("Targets in RSQL filter").isEqualTo(27L);
|
||||
}
|
||||
|
||||
@@ -840,7 +836,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createTarget("test" + i);
|
||||
}
|
||||
|
||||
final List<Target> foundDs = targetManagement.findTargetsById(searchIds);
|
||||
final List<Target> foundDs = targetManagement.get(searchIds);
|
||||
|
||||
assertThat(foundDs).hasSize(3);
|
||||
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
/**
|
||||
* 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 static org.junit.Assert.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||
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.TargetTagUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.Tag;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Test class for {@link TargetTagManagement}.
|
||||
*
|
||||
*/
|
||||
@Features("Component Tests - Repository")
|
||||
@Stories("Target Tag Management")
|
||||
public class TargetTagManagementTest 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(targetTagManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(targetTagManagement.get(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 = DistributionSetTagUpdatedEvent.class, count = 0),
|
||||
@Expect(type = TargetTagUpdatedEvent.class, count = 0) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
verifyThrownExceptionBy(() -> targetTagManagement.delete(NOT_EXIST_ID), "TargetTag");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetTagManagement.update(entityFactory.tag().update(NOT_EXIST_IDL)),
|
||||
"TargetTag");
|
||||
|
||||
verifyThrownExceptionBy(() -> targetTagManagement.findByTarget(PAGE, NOT_EXIST_ID), "Target");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies the toogle mechanism by means on assigning tag if at least on target in the list does not have"
|
||||
+ "the tag yet. Unassign if all of them have the tag already.")
|
||||
public void assignAndUnassignTargetTags() {
|
||||
final List<Target> groupA = testdataFactory.createTargets(20);
|
||||
final List<Target> groupB = testdataFactory.createTargets(20, "groupb", "groupb");
|
||||
|
||||
final TargetTag tag = targetTagManagement
|
||||
.create(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
||||
|
||||
// toggle A only -> A is now assigned
|
||||
TargetTagAssignmentResult result = toggleTagAssignment(groupA, tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(targetManagement.getByControllerID(
|
||||
groupA.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||
|
||||
// toggle A+B -> A is still assigned and B is assigned as well
|
||||
result = toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(targetManagement.getByControllerID(
|
||||
groupB.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||
|
||||
// toggle A+B -> both unassigned
|
||||
result = toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssignedEntity()).isEmpty();
|
||||
assertThat(result.getUnassigned()).isEqualTo(40);
|
||||
assertThat(result.getUnassignedEntity()).containsAll(targetManagement.getByControllerID(
|
||||
concat(groupB, groupA).stream().map(Target::getControllerId).collect(Collectors.toList())));
|
||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
private final <T> Collection<T> concat(final Collection<T>... targets) {
|
||||
final List<T> result = new ArrayList<>();
|
||||
Arrays.asList(targets).forEach(result::addAll);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that all tags are retrieved through repository.")
|
||||
public void findAllTargetTags() {
|
||||
final List<JpaTargetTag> tags = createTargetsWithTags();
|
||||
|
||||
assertThat(targetTagRepository.findAll()).isEqualTo(targetTagRepository.findAll()).isEqualTo(tags)
|
||||
.as("Wrong tag size").hasSize(20);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a created tag is persisted in the repository as defined.")
|
||||
public void createTargetTag() {
|
||||
final Tag tag = targetTagManagement
|
||||
.create(entityFactory.tag().create().name("kai1").description("kai2").colour("colour"));
|
||||
|
||||
assertThat(targetTagRepository.findByNameEquals("kai1").get().getDescription()).as("wrong tag ed")
|
||||
.isEqualTo("kai2");
|
||||
assertThat(targetTagManagement.getByName("kai1").get().getColour()).as("wrong tag found")
|
||||
.isEqualTo("colour");
|
||||
assertThat(targetTagManagement.get(tag.getId()).get().getColour()).as("wrong tag found")
|
||||
.isEqualTo("colour");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a deleted tag is removed from the repository as defined.")
|
||||
public void deleteTargetTags() {
|
||||
|
||||
// create test data
|
||||
final Iterable<JpaTargetTag> tags = createTargetsWithTags();
|
||||
final TargetTag toDelete = tags.iterator().next();
|
||||
|
||||
for (final Target target : targetRepository.findAll()) {
|
||||
assertThat(targetTagManagement.findByTarget(PAGE, target.getControllerId()).getContent())
|
||||
.contains(toDelete);
|
||||
}
|
||||
|
||||
// delete
|
||||
targetTagManagement.delete(toDelete.getName());
|
||||
|
||||
// check
|
||||
for (final Target target : targetRepository.findAll()) {
|
||||
assertThat(targetTagManagement.findByTarget(PAGE, target.getControllerId()).getContent())
|
||||
.doesNotContain(toDelete);
|
||||
}
|
||||
assertThat(targetTagRepository.findOne(toDelete.getId())).as("No tag should be found").isNull();
|
||||
assertThat(targetTagRepository.findAll()).as("Wrong target tag size").hasSize(19);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the name update of a target tag.")
|
||||
public void updateTargetTag() {
|
||||
final List<JpaTargetTag> tags = createTargetsWithTags();
|
||||
|
||||
// change data
|
||||
final TargetTag savedAssigned = tags.iterator().next();
|
||||
|
||||
// persist
|
||||
targetTagManagement.update(entityFactory.tag().update(savedAssigned.getId()).name("test123"));
|
||||
|
||||
// check data
|
||||
assertThat(targetTagRepository.findAll()).as("Wrong target tag size").hasSize(tags.size());
|
||||
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getName()).as("wrong target tag is saved")
|
||||
.isEqualTo("test123");
|
||||
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getOptLockRevision())
|
||||
.as("wrong target tag is saved").isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
|
||||
public void failedDuplicateTargetTagNameException() {
|
||||
targetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
|
||||
try {
|
||||
targetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
fail("should not have worked as tag already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
|
||||
public void failedDuplicateTargetTagNameExceptionAfterUpdate() {
|
||||
targetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
final TargetTag tag = targetTagManagement.create(entityFactory.tag().create().name("B"));
|
||||
|
||||
try {
|
||||
targetTagManagement.update(entityFactory.tag().update(tag.getId()).name("A"));
|
||||
fail("should not have worked as tag already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private List<JpaTargetTag> createTargetsWithTags() {
|
||||
final List<Target> targets = testdataFactory.createTargets(20);
|
||||
final Iterable<TargetTag> tags = testdataFactory.createTargetTags(20, "");
|
||||
|
||||
tags.forEach(tag -> toggleTagAssignment(targets, tag));
|
||||
|
||||
return targetTagRepository.findAll();
|
||||
}
|
||||
}
|
||||
@@ -49,8 +49,8 @@ public class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// target filter query that matches all targets
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name("filterA").query("name==*"));
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(targetFilterQuery.getId(), setA.getId());
|
||||
.create(entityFactory.targetFilterQuery().create().name("filterA").query("name==*"));
|
||||
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQuery.getId(), setA.getId());
|
||||
|
||||
final String targetDsAIdPref = "targ";
|
||||
final List<Target> targets = testdataFactory.createTargets(100, targetDsAIdPref,
|
||||
@@ -72,7 +72,7 @@ public class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
|
||||
verifyThatTargetsHaveDistributionSetAssignment(setB, targets.subList(10, 20), targetsCount);
|
||||
|
||||
// Count the number of targets that will be assigned with setA
|
||||
assertThat(targetManagement.countTargetsByTargetFilterQueryAndNonDS(setA.getId(), targetFilterQuery.getQuery()))
|
||||
assertThat(targetManagement.countByRsqlAndNonDS(setA.getId(), targetFilterQuery.getQuery()))
|
||||
.isEqualTo(90);
|
||||
|
||||
// Run the check
|
||||
@@ -90,7 +90,7 @@ public class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
|
||||
public void checkAutoAssignWithFailures() {
|
||||
|
||||
// incomplete distribution set that will be assigned
|
||||
final DistributionSet setF = distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
||||
final DistributionSet setF = distributionSetManagement.create(entityFactory.distributionSet()
|
||||
.create().name("dsA").version("1").type(testdataFactory.findOrCreateDefaultTestDsType()));
|
||||
final DistributionSet setA = testdataFactory.createDistributionSet("dsA");
|
||||
final DistributionSet setB = testdataFactory.createDistributionSet("dsB");
|
||||
@@ -100,14 +100,14 @@ public class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// target filter query that matches first bunch of targets, that should
|
||||
// fail
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(
|
||||
targetFilterQueryManagement.createTargetFilterQuery(entityFactory.targetFilterQuery().create()
|
||||
targetFilterQueryManagement.updateAutoAssignDS(
|
||||
targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create()
|
||||
.name("filterA").query("id==" + targetDsFIdPref + "*")).getId(),
|
||||
setF.getId());
|
||||
|
||||
// target filter query that matches failed bunch of targets
|
||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(
|
||||
targetFilterQueryManagement.createTargetFilterQuery(entityFactory.targetFilterQuery().create()
|
||||
targetFilterQueryManagement.updateAutoAssignDS(
|
||||
targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create()
|
||||
.name("filterB").query("id==" + targetDsAIdPref + "*")).getId(),
|
||||
setA.getId());
|
||||
|
||||
@@ -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(PAGE);
|
||||
final Slice<Target> targetsAll = targetManagement.findAll(PAGE);
|
||||
assertThat(targetsAll).as("Count of targets").hasSize(count);
|
||||
|
||||
for (final Target target : targetsAll) {
|
||||
|
||||
@@ -69,8 +69,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Verifies that the target update event is published when a target has been updated")
|
||||
public void targetUpdateEventIsPublished() throws InterruptedException {
|
||||
final Target createdTarget = testdataFactory.createTarget("12345");
|
||||
targetManagement
|
||||
.updateTarget(entityFactory.target().update(createdTarget.getControllerId()).name("updateName"));
|
||||
targetManagement.update(entityFactory.target().update(createdTarget.getControllerId()).name("updateName"));
|
||||
|
||||
final TargetUpdatedEvent targetUpdatedEvent = eventListener.waitForEvent(TargetUpdatedEvent.class);
|
||||
assertThat(targetUpdatedEvent).isNotNull();
|
||||
@@ -82,7 +81,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
public void targetDeletedEventIsPublished() throws InterruptedException {
|
||||
final Target createdTarget = testdataFactory.createTarget("12345");
|
||||
|
||||
targetManagement.deleteTarget("12345");
|
||||
targetManagement.deleteByControllerID("12345");
|
||||
|
||||
final TargetDeletedEvent targetDeletedEvent = eventListener.waitForEvent(TargetDeletedEvent.class);
|
||||
assertThat(targetDeletedEvent).isNotNull();
|
||||
@@ -104,7 +103,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
final Rollout createdRollout = testdataFactory.createRolloutByVariables(rolloutName, "desc", amountGroups,
|
||||
"controllerId==" + targetPrefixName + "-*", distributionSet, successCondition, errorCondition);
|
||||
|
||||
rolloutManagement.deleteRollout(createdRollout.getId());
|
||||
rolloutManagement.delete(createdRollout.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
|
||||
final RolloutDeletedEvent rolloutDeletedEvent = eventListener.waitForEvent(RolloutDeletedEvent.class);
|
||||
@@ -128,7 +127,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
public void distributionSetDeletedEventIsPublished() throws InterruptedException {
|
||||
final DistributionSet createDistributionSet = testdataFactory.createDistributionSet();
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(createDistributionSet.getId());
|
||||
distributionSetManagement.delete(createDistributionSet.getId());
|
||||
|
||||
final DistributionSetDeletedEvent dsDeletedEvent = eventListener
|
||||
.waitForEvent(DistributionSetDeletedEvent.class);
|
||||
@@ -152,7 +151,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
public void softwareModuleUpdateEventIsPublished() throws InterruptedException {
|
||||
final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp();
|
||||
softwareModuleManagement
|
||||
.updateSoftwareModule(entityFactory.softwareModule().update(softwareModule.getId()).description("New"));
|
||||
.update(entityFactory.softwareModule().update(softwareModule.getId()).description("New"));
|
||||
|
||||
final SoftwareModuleUpdatedEvent softwareModuleUpdatedEvent = eventListener
|
||||
.waitForEvent(SoftwareModuleUpdatedEvent.class);
|
||||
@@ -164,7 +163,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Verifies that the software module deleted event is published when a software module has been deleted")
|
||||
public void softwareModuleDeletedEventIsPublished() throws InterruptedException {
|
||||
final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp();
|
||||
softwareModuleManagement.deleteSoftwareModule(softwareModule.getId());
|
||||
softwareModuleManagement.delete(softwareModule.getId());
|
||||
|
||||
final SoftwareModuleDeletedEvent softwareModuleDeletedEvent = eventListener
|
||||
.waitForEvent(SoftwareModuleDeletedEvent.class);
|
||||
|
||||
@@ -54,8 +54,7 @@ public class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final Target targetToBeCreated = testdataFactory.createTarget("targetToBeCreated");
|
||||
|
||||
final Target loadedTarget = targetManagement.findTargetByControllerID(targetToBeCreated.getControllerId())
|
||||
.get();
|
||||
final Target loadedTarget = targetManagement.getByControllerID(targetToBeCreated.getControllerId()).get();
|
||||
assertThat(postLoadEntityListener.getEntity()).isNotNull();
|
||||
assertThat(postLoadEntityListener.getEntity()).isEqualTo(loadedTarget);
|
||||
}
|
||||
@@ -95,7 +94,7 @@ public class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest {
|
||||
Target updateTarget = addListenerAndCreateTarget(entityInterceptor, "targetToBeCreated");
|
||||
|
||||
updateTarget = targetManagement
|
||||
.updateTarget(entityFactory.target().update(updateTarget.getControllerId()).name("New"));
|
||||
.update(entityFactory.target().update(updateTarget.getControllerId()).name("New"));
|
||||
|
||||
assertThat(entityInterceptor.getEntity()).isNotNull();
|
||||
assertThat(entityInterceptor.getEntity()).isEqualTo(updateTarget);
|
||||
@@ -104,9 +103,9 @@ public class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest {
|
||||
private void executeDeleteAndAssertCallbackResult(final AbstractEntityListener entityInterceptor) {
|
||||
EntityInterceptorHolder.getInstance().getEntityInterceptors().add(entityInterceptor);
|
||||
final SoftwareModuleType type = softwareModuleTypeManagement
|
||||
.createSoftwareModuleType(entityFactory.softwareModuleType().create().name("test").key("test"));
|
||||
.create(entityFactory.softwareModuleType().create().name("test").key("test"));
|
||||
|
||||
softwareModuleTypeManagement.deleteSoftwareModuleType(type.getId());
|
||||
softwareModuleTypeManagement.delete(type.getId());
|
||||
assertThat(entityInterceptor.getEntity()).isNotNull();
|
||||
assertThat(entityInterceptor.getEntity()).isEqualTo(type);
|
||||
}
|
||||
|
||||
@@ -56,11 +56,11 @@ public class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Verfies that updated entities are not equal.")
|
||||
public void changedEntitiesAreNotEqual() {
|
||||
final SoftwareModuleType type = softwareModuleTypeManagement
|
||||
.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("test").name("test"));
|
||||
.create(entityFactory.softwareModuleType().create().key("test").name("test"));
|
||||
assertThat(type).as("persited entity is not equal to regular object")
|
||||
.isNotEqualTo(entityFactory.softwareModuleType().create().key("test").name("test").build());
|
||||
|
||||
final SoftwareModuleType updated = softwareModuleTypeManagement.updateSoftwareModuleType(
|
||||
final SoftwareModuleType updated = softwareModuleTypeManagement.update(
|
||||
entityFactory.softwareModuleType().update(type.getId()).description("another"));
|
||||
assertThat(type).as("Changed entity is not equal to the previous version").isNotEqualTo(updated);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Verify that no proxy of the entity manager has an influence on the equals or hashcode result.")
|
||||
public void managedEntityIsEqualToUnamangedObjectWithSameKey() {
|
||||
final SoftwareModuleType type = softwareModuleTypeManagement.createSoftwareModuleType(
|
||||
final SoftwareModuleType type = softwareModuleTypeManagement.create(
|
||||
entityFactory.softwareModuleType().create().key("test").name("test").description("test"));
|
||||
|
||||
final JpaSoftwareModuleType mock = new JpaSoftwareModuleType("test", "test", "test", 1);
|
||||
|
||||
@@ -40,7 +40,7 @@ public class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
|
||||
public void setupBeforeTest() {
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("daA");
|
||||
target = (JpaTarget) targetManagement
|
||||
.createTarget(entityFactory.target().create().controllerId("targetId123").description("targetId123"));
|
||||
.create(entityFactory.target().create().controllerId("targetId123").description("targetId123"));
|
||||
action = new JpaAction();
|
||||
action.setActionType(ActionType.SOFT);
|
||||
action.setDistributionSet(dsA);
|
||||
|
||||
@@ -36,21 +36,19 @@ public class RSQLDistributionSetFieldTest extends AbstractJpaIntegrationTest {
|
||||
public void seuptBeforeTest() {
|
||||
|
||||
DistributionSet ds = testdataFactory.createDistributionSet("DS");
|
||||
ds = distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(ds.getId()).description("DS"));
|
||||
ds = distributionSetManagement.update(entityFactory.distributionSet().update(ds.getId()).description("DS"));
|
||||
createDistributionSetMetadata(ds.getId(), entityFactory.generateMetadata("metaKey", "metaValue"));
|
||||
|
||||
DistributionSet ds2 = testdataFactory.createDistributionSets("NewDS", 3).get(0);
|
||||
|
||||
ds2 = distributionSetManagement
|
||||
.updateDistributionSet(entityFactory.distributionSet().update(ds2.getId()).description("DS%"));
|
||||
ds2 = distributionSetManagement.update(entityFactory.distributionSet().update(ds2.getId()).description("DS%"));
|
||||
createDistributionSetMetadata(ds2.getId(), entityFactory.generateMetadata("metaKey", "value"));
|
||||
|
||||
final DistributionSetTag targetTag = tagManagement
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("Tag1"));
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("Tag2"));
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("Tag3"));
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("Tag4"));
|
||||
final DistributionSetTag targetTag = distributionSetTagManagement
|
||||
.create(entityFactory.tag().create().name("Tag1"));
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("Tag2"));
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("Tag3"));
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("Tag4"));
|
||||
|
||||
distributionSetManagement.assignTag(Arrays.asList(ds.getId(), ds2.getId()), targetTag.getId());
|
||||
}
|
||||
@@ -138,8 +136,7 @@ public class RSQLDistributionSetFieldTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {
|
||||
final Page<DistributionSet> find = distributionSetManagement.findDistributionSetsAll(rsqlParam,
|
||||
new PageRequest(0, 100), false);
|
||||
final Page<DistributionSet> find = distributionSetManagement.findByRsql(new PageRequest(0, 100), rsqlParam);
|
||||
final long countAll = find.getTotalElements();
|
||||
assertThat(find).as("Founded entity is should not be null").isNotNull();
|
||||
assertThat(countAll).as("Founded entity size is wrong").isEqualTo(excpectedEntity);
|
||||
|
||||
@@ -43,7 +43,7 @@ public class RSQLDistributionSetMetadataFieldsTest extends AbstractJpaIntegratio
|
||||
metadata.add(entityFactory.generateMetadata("" + i, "" + i));
|
||||
}
|
||||
|
||||
distributionSetManagement.createDistributionSetMetadata(distributionSetId, metadata);
|
||||
distributionSetManagement.createMetaData(distributionSetId, metadata);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -67,7 +67,7 @@ public class RSQLDistributionSetMetadataFieldsTest extends AbstractJpaIntegratio
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
|
||||
|
||||
final Page<DistributionSetMetadata> findEnitity = distributionSetManagement
|
||||
.findDistributionSetMetadataByDistributionSetId(distributionSetId, rsqlParam, new PageRequest(0, 100));
|
||||
.findMetaDataByDistributionSetIdAndRsql(new PageRequest(0, 100), distributionSetId, rsqlParam);
|
||||
final long countAllEntities = findEnitity.getTotalElements();
|
||||
assertThat(findEnitity).isNotNull();
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
|
||||
@@ -39,9 +39,9 @@ public class RSQLRolloutGroupFields extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
|
||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||
rollout = createRollout("rollout1", 4, dsA.getId(), "controllerId==rollout*");
|
||||
rollout = rolloutManagement.findRolloutById(rollout.getId()).get();
|
||||
rollout = rolloutManagement.get(rollout.getId()).get();
|
||||
|
||||
this.rolloutGroupId = rolloutGroupManagement.findRolloutGroupsByRolloutId(rollout.getId(), PAGE).getContent()
|
||||
this.rolloutGroupId = rolloutGroupManagement.findByRollout(PAGE, rollout.getId()).getContent()
|
||||
.get(0).getId();
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ public class RSQLRolloutGroupFields extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expcetedTargets) {
|
||||
final Page<RolloutGroup> findTargetPage = rolloutGroupManagement.findRolloutGroupsAll(rollout.getId(),
|
||||
rsqlParam, new PageRequest(0, 100));
|
||||
final Page<RolloutGroup> findTargetPage = rolloutGroupManagement.findByRolloutAndRsql(new PageRequest(0, 100),
|
||||
rollout.getId(), rsqlParam);
|
||||
final long countTargetsAll = findTargetPage.getTotalElements();
|
||||
assertThat(findTargetPage).isNotNull();
|
||||
assertThat(countTargetsAll).isEqualTo(expcetedTargets);
|
||||
@@ -84,9 +84,9 @@ public class RSQLRolloutGroupFields extends AbstractJpaIntegrationTest {
|
||||
|
||||
private Rollout createRollout(final String name, final int amountGroups, final long distributionSetId,
|
||||
final String targetFilterQuery) {
|
||||
return rolloutManagement.createRollout(
|
||||
return rolloutManagement.create(
|
||||
entityFactory.rollout().create()
|
||||
.set(distributionSetManagement.findDistributionSetById(distributionSetId).get()).name(name)
|
||||
.set(distributionSetManagement.get(distributionSetId).get()).name(name)
|
||||
.targetFilterQuery(targetFilterQuery),
|
||||
amountGroups, new RolloutGroupConditionBuilder().withDefaults()
|
||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "100").build());
|
||||
|
||||
@@ -31,21 +31,21 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Before
|
||||
public void setupBeforeTest() {
|
||||
final SoftwareModule ah = softwareModuleManagement.createSoftwareModule(entityFactory.softwareModule().create()
|
||||
final SoftwareModule ah = softwareModuleManagement.create(entityFactory.softwareModule().create()
|
||||
.type(appType).name("agent-hub").version("1.0.1").description("agent-hub"));
|
||||
softwareModuleManagement.createSoftwareModule(entityFactory.softwareModule().create().type(runtimeType)
|
||||
softwareModuleManagement.create(entityFactory.softwareModule().create().type(runtimeType)
|
||||
.name("oracle-jre").version("1.7.2").description("aa"));
|
||||
softwareModuleManagement.createSoftwareModule(
|
||||
softwareModuleManagement.create(
|
||||
entityFactory.softwareModule().create().type(osType).name("poky").version("3.0.2").description("aa"));
|
||||
|
||||
final JpaSoftwareModule ah2 = (JpaSoftwareModule) softwareModuleManagement.createSoftwareModule(entityFactory
|
||||
final JpaSoftwareModule ah2 = (JpaSoftwareModule) softwareModuleManagement.create(entityFactory
|
||||
.softwareModule().create().type(appType).name("agent-hub2").version("1.0.1").description("agent-hub2"));
|
||||
|
||||
final MetaData softwareModuleMetadata = entityFactory.generateMetadata("metaKey", "metaValue");
|
||||
softwareModuleManagement.createSoftwareModuleMetadata(ah.getId(), softwareModuleMetadata);
|
||||
softwareModuleManagement.createMetaData(ah.getId(), softwareModuleMetadata);
|
||||
|
||||
final MetaData softwareModuleMetadata2 = entityFactory.generateMetadata("metaKey", "value");
|
||||
softwareModuleManagement.createSoftwareModuleMetadata(ah2.getId(), softwareModuleMetadata2);
|
||||
softwareModuleManagement.createMetaData(ah2.getId(), softwareModuleMetadata2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -105,8 +105,8 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {
|
||||
final Page<SoftwareModule> find = softwareModuleManagement.findSoftwareModulesByPredicate(rsqlParam,
|
||||
new PageRequest(0, 100));
|
||||
final Page<SoftwareModule> find = softwareModuleManagement.findByRsql(new PageRequest(0, 100),
|
||||
rsqlParam);
|
||||
final long countAll = find.getTotalElements();
|
||||
assertThat(find).isNotNull();
|
||||
assertThat(countAll).isEqualTo(excpectedEntity);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractJpaIntegration
|
||||
metadata.add(entityFactory.generateMetadata("" + i, "" + i));
|
||||
}
|
||||
|
||||
softwareModuleManagement.createSoftwareModuleMetadata(softwareModule.getId(), metadata);
|
||||
softwareModuleManagement.createMetaData(softwareModule.getId(), metadata);
|
||||
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractJpaIntegration
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
|
||||
|
||||
final Page<SoftwareModuleMetadata> findEnitity = softwareModuleManagement
|
||||
.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, rsqlParam, new PageRequest(0, 100));
|
||||
.findMetaDataByRsql(new PageRequest(0, 100), softwareModuleId, rsqlParam);
|
||||
final long countAllEntities = findEnitity.getTotalElements();
|
||||
assertThat(findEnitity).isNotNull();
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
|
||||
@@ -60,8 +60,8 @@ public class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {
|
||||
final Page<SoftwareModuleType> find = softwareModuleTypeManagement.findSoftwareModuleTypesAll(rsqlParam,
|
||||
new PageRequest(0, 100));
|
||||
final Page<SoftwareModuleType> find = softwareModuleTypeManagement.findByRsql(new PageRequest(0, 100),
|
||||
rsqlParam);
|
||||
final long countAll = find.getTotalElements();
|
||||
assertThat(find).isNotNull();
|
||||
assertThat(countAll).isEqualTo(excpectedEntity);
|
||||
|
||||
@@ -34,8 +34,8 @@ public class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
final TagCreate targetTag = entityFactory.tag().create().name(Integer.toString(i))
|
||||
.description(Integer.toString(i)).colour(i % 2 == 0 ? "red" : "blue");
|
||||
tagManagement.createTargetTag(targetTag);
|
||||
tagManagement.createDistributionSetTag(targetTag);
|
||||
targetTagManagement.create(targetTag);
|
||||
distributionSetTagManagement.create(targetTag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,8 +101,8 @@ public class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private void assertRSQLQueryDistributionSet(final String rsqlParam, final long expectedEntities) {
|
||||
|
||||
final Page<DistributionSetTag> findEnitity = tagManagement.findAllDistributionSetTags(rsqlParam,
|
||||
new PageRequest(0, 100));
|
||||
final Page<DistributionSetTag> findEnitity = distributionSetTagManagement.findByRsql(new PageRequest(0, 100),
|
||||
rsqlParam);
|
||||
final long countAllEntities = findEnitity.getTotalElements();
|
||||
assertThat(findEnitity).isNotNull();
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
@@ -110,7 +110,7 @@ public class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private void assertRSQLQueryTarget(final String rsqlParam, final long expectedEntities) {
|
||||
|
||||
final Page<TargetTag> findEnitity = tagManagement.findAllTargetTags(rsqlParam, new PageRequest(0, 100));
|
||||
final Page<TargetTag> findEnitity = targetTagManagement.findByRsql(new PageRequest(0, 100), rsqlParam);
|
||||
final long countAllEntities = findEnitity.getTotalElements();
|
||||
assertThat(findEnitity).isNotNull();
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
|
||||
@@ -44,14 +44,14 @@ public class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final Map<String, String> attributes = new HashMap<>();
|
||||
|
||||
target = targetManagement.createTarget(entityFactory.target().create().controllerId("targetId123")
|
||||
target = targetManagement.create(entityFactory.target().create().controllerId("targetId123")
|
||||
.name("targetName123").description("targetDesc123"));
|
||||
attributes.put("revision", "1.1");
|
||||
target = controllerManagement.updateControllerAttributes(target.getControllerId(), attributes);
|
||||
target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(target.getControllerId(), LOCALHOST);
|
||||
|
||||
target2 = targetManagement
|
||||
.createTarget(entityFactory.target().create().controllerId("targetId1234").description("targetId1234"));
|
||||
.create(entityFactory.target().create().controllerId("targetId1234").description("targetId1234"));
|
||||
attributes.put("revision", "1.2");
|
||||
Thread.sleep(1);
|
||||
target2 = controllerManagement.updateControllerAttributes(target2.getControllerId(), attributes);
|
||||
@@ -60,10 +60,10 @@ public class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
testdataFactory.createTarget("targetId1235");
|
||||
testdataFactory.createTarget("targetId1236");
|
||||
|
||||
final TargetTag targetTag = tagManagement.createTargetTag(entityFactory.tag().create().name("Tag1"));
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("Tag2"));
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("Tag3"));
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("Tag4"));
|
||||
final TargetTag targetTag = targetTagManagement.create(entityFactory.tag().create().name("Tag1"));
|
||||
targetTagManagement.create(entityFactory.tag().create().name("Tag2"));
|
||||
targetTagManagement.create(entityFactory.tag().create().name("Tag3"));
|
||||
targetTagManagement.create(entityFactory.tag().create().name("Tag4"));
|
||||
|
||||
targetManagement.assignTag(Arrays.asList(target.getControllerId(), target2.getControllerId()),
|
||||
targetTag.getId());
|
||||
@@ -182,7 +182,7 @@ public class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expcetedTargets) {
|
||||
final Page<Target> findTargetPage = targetManagement.findTargetsAll(rsqlParam, PAGE);
|
||||
final Page<Target> findTargetPage = targetManagement.findByRsql(PAGE, rsqlParam);
|
||||
final long countTargetsAll = findTargetPage.getTotalElements();
|
||||
assertThat(findTargetPage).isNotNull();
|
||||
assertThat(countTargetsAll).isEqualTo(expcetedTargets);
|
||||
|
||||
@@ -72,7 +72,7 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
createTargetForTenant(controllerAnotherTenant, anotherTenant);
|
||||
|
||||
// find all targets for current tenant "mytenant"
|
||||
final Slice<Target> findTargetsAll = targetManagement.findTargetsAll(PAGE);
|
||||
final Slice<Target> findTargetsAll = targetManagement.findAll(PAGE);
|
||||
// no target has been created for "mytenant"
|
||||
assertThat(findTargetsAll).hasSize(0);
|
||||
|
||||
@@ -105,9 +105,9 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// logged in tenant mytenant - check if tenant default data is
|
||||
// autogenerated
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypesAll(PAGE)).isEmpty();
|
||||
assertThat(distributionSetTypeManagement.findAll(PAGE)).isEmpty();
|
||||
assertThat(systemManagement.getTenantMetadata().getTenant().toUpperCase()).isEqualTo("mytenant".toUpperCase());
|
||||
assertThat(distributionSetTypeManagement.findDistributionSetTypesAll(PAGE)).isNotEmpty();
|
||||
assertThat(distributionSetTypeManagement.findAll(PAGE)).isNotEmpty();
|
||||
|
||||
// check that the cache is not getting in the way, i.e. "bumlux" results
|
||||
// in bumlux and not
|
||||
@@ -128,7 +128,7 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// ensure target cannot be deleted by 'mytenant'
|
||||
try {
|
||||
targetManagement.deleteTargets(Arrays.asList(createTargetForTenant.getId()));
|
||||
targetManagement.delete(Arrays.asList(createTargetForTenant.getId()));
|
||||
fail("mytenant should not have been able to delete target of anotherTenant");
|
||||
} catch (final EntityNotFoundException ex) {
|
||||
// ok
|
||||
@@ -173,12 +173,12 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private Slice<Target> findTargetsForTenant(final String tenant) throws Exception {
|
||||
return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant),
|
||||
() -> targetManagement.findTargetsAll(PAGE));
|
||||
() -> targetManagement.findAll(PAGE));
|
||||
}
|
||||
|
||||
private void deleteTargetsForTenant(final String tenant, final Collection<Long> targetIds) throws Exception {
|
||||
securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant), () -> {
|
||||
targetManagement.deleteTargets(targetIds);
|
||||
targetManagement.delete(targetIds);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
@@ -190,7 +190,7 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private Page<DistributionSet> findDistributionSetForTenant(final String tenant) throws Exception {
|
||||
return securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant),
|
||||
() -> distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true));
|
||||
() -> distributionSetManagement.findByCompleted(PAGE, true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user