Refactor Management interfaces: find/get pattern (#2609)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-08-15 16:18:32 +03:00
committed by GitHub
parent fa4dea75a3
commit b4edde8cc3
100 changed files with 713 additions and 986 deletions

View File

@@ -23,24 +23,24 @@ public abstract class AbstractRepositoryManagementSecurityTest<T extends BaseEnt
/**
* @return the repository management to test with
*/
protected abstract RepositoryManagement<T, C, U> getRepositoryManagement();
protected abstract RepositoryManagement<T, C, U> findRepositoryManagement();
/**
* @return the object to create
*/
protected abstract C getCreateObject();
protected abstract C findCreateObject();
/**
* @return the object to update
*/
protected abstract U getUpdateObject();
protected abstract U findUpdateObject();
/**
* Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
*/
@Test
void createCollectionPermissionCheck() {
assertPermissions(() -> getRepositoryManagement().create(List.of(getCreateObject())), List.of(SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY));
assertPermissions(() -> findRepositoryManagement().create(List.of(findCreateObject())), List.of(SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY));
}
/**
@@ -48,7 +48,7 @@ public abstract class AbstractRepositoryManagementSecurityTest<T extends BaseEnt
*/
@Test
void createPermissionCheck() {
assertPermissions(() -> getRepositoryManagement().create(getCreateObject()), List.of(SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY));
assertPermissions(() -> findRepositoryManagement().create(findCreateObject()), List.of(SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY));
}
/**
@@ -56,7 +56,7 @@ public abstract class AbstractRepositoryManagementSecurityTest<T extends BaseEnt
*/
@Test
void updatePermissionCheck() {
assertPermissions(() -> getRepositoryManagement().update(getUpdateObject()), List.of(SpPermission.UPDATE_REPOSITORY));
assertPermissions(() -> findRepositoryManagement().update(findUpdateObject()), List.of(SpPermission.UPDATE_REPOSITORY));
}
/**
@@ -65,7 +65,7 @@ public abstract class AbstractRepositoryManagementSecurityTest<T extends BaseEnt
@Test
void deletePermissionCheck() {
assertPermissions(() -> {
getRepositoryManagement().delete(1L);
findRepositoryManagement().delete(1L);
return null;
}, List.of(SpPermission.DELETE_REPOSITORY));
}
@@ -75,7 +75,7 @@ public abstract class AbstractRepositoryManagementSecurityTest<T extends BaseEnt
*/
@Test
void countPermissionCheck() {
assertPermissions(() -> getRepositoryManagement().count(), List.of(SpPermission.READ_REPOSITORY));
assertPermissions(() -> findRepositoryManagement().count(), List.of(SpPermission.READ_REPOSITORY));
}
@@ -85,7 +85,7 @@ public abstract class AbstractRepositoryManagementSecurityTest<T extends BaseEnt
@Test
void deleteCollectionRepositoryManagement() {
assertPermissions(() -> {
getRepositoryManagement().delete(List.of(1L));
findRepositoryManagement().delete(List.of(1L));
return null;
}, List.of(SpPermission.DELETE_REPOSITORY));
}
@@ -94,16 +94,16 @@ public abstract class AbstractRepositoryManagementSecurityTest<T extends BaseEnt
* Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
*/
@Test
void getPermissionCheck() {
assertPermissions(() -> getRepositoryManagement().get(1L), List.of(SpPermission.READ_REPOSITORY));
void findPermissionCheck() {
assertPermissions(() -> findRepositoryManagement().find(1L), List.of(SpPermission.READ_REPOSITORY));
}
/**
* Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.
*/
@Test
void getCollectionPermissionCheck() {
assertPermissions(() -> getRepositoryManagement().get(List.of(1L)), List.of(SpPermission.READ_REPOSITORY));
void findCollectionPermissionCheck() {
assertPermissions(() -> findRepositoryManagement().get(List.of(1L)), List.of(SpPermission.READ_REPOSITORY));
}
/**
@@ -111,7 +111,7 @@ public abstract class AbstractRepositoryManagementSecurityTest<T extends BaseEnt
*/
@Test
void existsCollectionPermissionCheck() {
assertPermissions(() -> getRepositoryManagement().exists(1L), List.of(SpPermission.READ_REPOSITORY));
assertPermissions(() -> findRepositoryManagement().exists(1L), List.of(SpPermission.READ_REPOSITORY));
}
/**
@@ -119,7 +119,7 @@ public abstract class AbstractRepositoryManagementSecurityTest<T extends BaseEnt
*/
@Test
void findAllPermissionCheck() {
assertPermissions(() -> getRepositoryManagement().findAll(Pageable.ofSize(1)), List.of(SpPermission.READ_REPOSITORY));
assertPermissions(() -> findRepositoryManagement().findAll(Pageable.ofSize(1)), List.of(SpPermission.READ_REPOSITORY));
}
/**
@@ -127,6 +127,6 @@ public abstract class AbstractRepositoryManagementSecurityTest<T extends BaseEnt
*/
@Test
void findByRsqlPermissionCheck() {
assertPermissions(() -> getRepositoryManagement().findByRsql("(name==*)", Pageable.ofSize(1)), List.of(SpPermission.READ_REPOSITORY));
assertPermissions(() -> findRepositoryManagement().findByRsql("(name==*)", Pageable.ofSize(1)), List.of(SpPermission.READ_REPOSITORY));
}
}

View File

@@ -27,12 +27,12 @@ import java.util.Map;
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
import org.eclipse.hawkbit.repository.Identifiable;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement.AutoAssignDistributionSetUpdate;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.InsufficientPermissionException;
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.junit.jupiter.api.Test;
@@ -74,9 +74,9 @@ class DistributionSetAccessControllerTest extends AbstractJpaIntegrationTest {
.toList()).containsOnly(permittedActionId);
// verify distributionSetManagement#get
assertThat(distributionSetManagement.get(permittedActionId)).isPresent();
assertThat(distributionSetManagement.find(permittedActionId)).isPresent();
final Long hiddenId = hidden.getId();
assertThat(distributionSetManagement.get(hiddenId)).isEmpty();
assertThat(distributionSetManagement.find(hiddenId)).isEmpty();
// verify distributionSetManagement#getWithDetails
assertThat(distributionSetManagement.getWithDetails(permittedActionId)).isPresent();
@@ -246,17 +246,17 @@ class DistributionSetAccessControllerTest extends AbstractJpaIntegrationTest {
UPDATE_DISTRIBUTION_SET + "/id==" + permitted.getId(),
// read / update target needed to update target filter query
READ_TARGET, UPDATE_TARGET), () -> {
assertThat(targetFilterQueryManagement
.updateAutoAssignDS(new TargetFilterQueryManagement.AutoAssignDistributionSetUpdate(targetFilterQuery.getId()).ds(permitted.getId())
.actionType(Action.ActionType.FORCED).confirmationRequired(false))
.getAutoAssignDistributionSet().getId()).isEqualTo(permitted.getId());
targetFilterQueryManagement
.updateAutoAssignDS(new TargetFilterQueryManagement.AutoAssignDistributionSetUpdate(targetFilterQuery.getId())
.ds(readOnly.getId()).actionType(Action.ActionType.FORCED).confirmationRequired(false))
.getAutoAssignDistributionSet().getId();
final TargetFilterQueryManagement.AutoAssignDistributionSetUpdate autoAssignDistributionSetUpdate = new TargetFilterQueryManagement.AutoAssignDistributionSetUpdate(
targetFilterQuery.getId())
.ds(hidden.getId()).actionType(Action.ActionType.FORCED).confirmationRequired(false);
// assertThat(targetFilterQueryManagement
// .updateAutoAssignDS(new AutoAssignDistributionSetUpdate(targetFilterQuery.getId()).ds(permitted.getId())
// .actionType(Action.ActionType.FORCED).confirmationRequired(false))
// .getAutoAssignDistributionSet().getId()).isEqualTo(permitted.getId());
// targetFilterQueryManagement
// .updateAutoAssignDS(new AutoAssignDistributionSetUpdate(targetFilterQuery.getId())
// .ds(readOnly.getId()).actionType(Action.ActionType.FORCED).confirmationRequired(false))
// .getAutoAssignDistributionSet().getId();
final AutoAssignDistributionSetUpdate autoAssignDistributionSetUpdate =
new AutoAssignDistributionSetUpdate(targetFilterQuery.getId())
.ds(hidden.getId()).actionType(Action.ActionType.FORCED).confirmationRequired(false);
assertThatThrownBy(() -> targetFilterQueryManagement.updateAutoAssignDS(autoAssignDistributionSetUpdate))
.isInstanceOf(EntityNotFoundException.class);
});

View File

@@ -88,8 +88,8 @@ class TargetAccessControllerTest extends AbstractJpaIntegrationTest {
.stream().map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId());
// verify targetManagement#get
assertThat(targetManagement.get(permittedTarget.getId())).isPresent();
assertThat(targetManagement.get(hiddenTarget.getId())).isEmpty();
assertThat(targetManagement.find(permittedTarget.getId())).isPresent();
assertThat(targetManagement.find(hiddenTarget.getId())).isEmpty();
// verify targetManagement#get
final List<Long> withHidden = List.of(permittedTarget.getId(), hiddenTarget.getId());

View File

@@ -60,9 +60,9 @@ class TargetTypeAccessControllerTest extends AbstractJpaIntegrationTest {
assertThat(targetTypeManagement.count()).isEqualTo(1);
// verify targetTypeManagement#get by id
assertThat(targetTypeManagement.get(permittedTargetType.getId())).isPresent();
assertThat(targetTypeManagement.find(permittedTargetType.getId())).isPresent();
final Long hiddenTargetTypeId = hiddenTargetType.getId();
assertThat(targetTypeManagement.get(hiddenTargetTypeId)).isEmpty();
assertThat(targetTypeManagement.find(hiddenTargetTypeId)).isEmpty();
// verify targetTypeManagement#getByName
assertThat(targetTypeManagement.getByName(permittedTargetType.getName())).isPresent();

View File

@@ -24,7 +24,6 @@ import org.eclipse.hawkbit.repository.TargetFilterQueryManagement.AutoAssignDist
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement.Create;
import org.eclipse.hawkbit.repository.exception.IncompleteDistributionSetException;
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
import org.eclipse.hawkbit.repository.jpa.specifications.ActionSpecifications;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.Action.Status;
@@ -308,7 +307,7 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
final List<Target> targetsA = createTargetsAndAutoAssignDistSet(targetDsAIdPref, 5, distributionSet, ActionType.FORCED);
implicitLock(distributionSet);
final DistributionSet distributionSetLocked = distributionSetManagement.get(distributionSet.getId()).orElseThrow();
final DistributionSet distributionSetLocked = distributionSetManagement.find(distributionSet.getId()).orElseThrow();
final List<Target> targetsB = createTargetsAndAutoAssignDistSet(targetDsBIdPref, 10, distributionSetLocked, ActionType.SOFT);
final List<Target> targetsC = createTargetsAndAutoAssignDistSet(targetDsCIdPref, 10, distributionSetLocked, ActionType.DOWNLOAD_ONLY);

View File

@@ -25,15 +25,6 @@ import org.junit.jupiter.api.Test;
*/
class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest {
/**
* Tests ArtifactManagement#count() method
*/
@Test
@WithUser(principal = "user", authorities = { SpPermission.READ_REPOSITORY })
void countPermissionCheck() {
assertPermissions(() -> artifactManagement.count(), List.of(SpPermission.READ_REPOSITORY));
}
/**
* Tests ArtifactManagement#create() method
*/
@@ -54,60 +45,6 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest {
}, List.of(SpPermission.DELETE_REPOSITORY));
}
/**
* Tests ArtifactManagement#get() method
*/
@Test
void getPermissionCheck() {
assertPermissions(() -> artifactManagement.get(1L), List.of(SpPermission.READ_REPOSITORY));
assertPermissions(() -> artifactManagement.get(1L), List.of(SpRole.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY));
}
/**
* Tests ArtifactManagement#getByFilenameAndSoftwareModule() method
*/
@Test
void getByFilenameAndSoftwareModulePermissionCheck() {
assertPermissions(() -> artifactManagement.getByFilenameAndSoftwareModule("filename", 1L),
List.of(SpPermission.READ_REPOSITORY), List.of(SpPermission.CREATE_REPOSITORY));
assertPermissions(() -> artifactManagement.getByFilenameAndSoftwareModule("filename", 1L),
List.of(SpRole.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY));
}
/**
* Tests ArtifactManagement#findFirstBySHA1() method
*/
@Test
void findFirstBySHA1PermissionCheck() {
assertPermissions(() -> artifactManagement.findFirstBySHA1("sha1"), List.of(SpPermission.READ_REPOSITORY));
assertPermissions(() -> artifactManagement.findFirstBySHA1("sha1"), List.of(SpRole.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY));
}
/**
* Tests ArtifactManagement#getByFilename() method
*/
@Test
void getByFilenamePermissionCheck() {
assertPermissions(() -> artifactManagement.getByFilename("filename"), List.of(SpPermission.READ_REPOSITORY));
assertPermissions(() -> artifactManagement.getByFilename("filename"), List.of(SpRole.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY));
}
/**
* Tests ArtifactManagement#findBySoftwareModule() method
*/
@Test
void findBySoftwareModulePermissionCheck() {
assertPermissions(() -> artifactManagement.findBySoftwareModule(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
}
/**
* Tests ArtifactManagement#countBySoftwareModule() method
*/
@Test
void countBySoftwareModulePermissionCheck() {
assertPermissions(() -> artifactManagement.countBySoftwareModule(1L), List.of(SpPermission.READ_REPOSITORY));
}
/**
* Tests ArtifactManagement#loadArtifactBinary() method
*/
@@ -116,5 +53,4 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest {
assertPermissions(() -> artifactManagement.loadArtifactBinary("sha1", 1L, false), List.of(SpPermission.DOWNLOAD_REPOSITORY_ARTIFACT), List.of(SpPermission.CREATE_REPOSITORY));
assertPermissions(() -> artifactManagement.loadArtifactBinary("sha1", 1L, false), List.of(SpRole.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY));
}
}

View File

@@ -21,13 +21,13 @@ import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HexFormat;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.Callable;
import jakarta.validation.ConstraintViolationException;
import org.apache.commons.io.IOUtils;
import org.eclipse.hawkbit.im.authentication.SpRole;
import org.eclipse.hawkbit.repository.artifact.exception.ArtifactBinaryNotFoundException;
import org.eclipse.hawkbit.repository.artifact.model.DbArtifact;
import org.eclipse.hawkbit.repository.artifact.model.DbArtifactHash;
import org.eclipse.hawkbit.im.authentication.SpPermission;
@@ -69,11 +69,10 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
void nonExistingEntityAccessReturnsNotPresent() {
final SoftwareModule module = testdataFactory.createSoftwareModuleOs();
assertThat(artifactManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(artifactManagement.getByFilenameAndSoftwareModule(NOT_EXIST_ID, module.getId())).isEmpty();
assertThat(artifactManagement.findFirstBySHA1(NOT_EXIST_ID)).isNotPresent();
assertThat(artifactManagement.loadArtifactBinary(NOT_EXIST_ID, module.getId(), module.isEncrypted())).isEmpty();
final long moduleId = module.getId();
final boolean encrypted = module.isEncrypted();
assertThatExceptionOfType(ArtifactBinaryNotFoundException.class)
.isThrownBy(() -> artifactManagement.loadArtifactBinary(NOT_EXIST_ID, moduleId, encrypted));
}
/**
@@ -96,11 +95,6 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
NOT_EXIST_IDL, "xxx", null, null, null, false, null, artifactSize)), "SoftwareModule");
verifyThrownExceptionBy(() -> artifactManagement.delete(NOT_EXIST_IDL), "Artifact");
verifyThrownExceptionBy(() -> artifactManagement.findBySoftwareModule(NOT_EXIST_IDL, PAGE), "SoftwareModule");
assertThat(artifactManagement.getByFilename(NOT_EXIST_ID)).isEmpty();
verifyThrownExceptionBy(() -> artifactManagement.getByFilenameAndSoftwareModule("xxx", NOT_EXIST_IDL), "SoftwareModule");
}
/**
@@ -136,15 +130,18 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
assertThat(artifact1).isNotEqualTo(artifact2);
assertThat(artifact1.getSha1Hash()).isEqualTo(artifact2.getSha1Hash());
assertThat(artifactManagement.getByFilename("file1").get().getSha1Hash()).isEqualTo(HashGeneratorUtils.generateSHA1(randomBytes));
assertThat(artifactManagement.getByFilename("file1").get().getMd5Hash()).isEqualTo(HashGeneratorUtils.generateMD5(randomBytes));
assertThat(artifactManagement.getByFilename("file1").get().getSha256Hash()).isEqualTo(
HashGeneratorUtils.generateSHA256(randomBytes));
final DbArtifact dbArtifact = artifactManagement.loadArtifactBinary(
HashGeneratorUtils.generateSHA1(randomBytes), sm.getId(), sm.isEncrypted());
final DbArtifactHash hash = dbArtifact.getHashes();
assertThat(hash.getSha1()).isEqualTo(HashGeneratorUtils.generateSHA1(randomBytes));
// md5 and sha256 are kept in local artifact db and should not be provided by "load"
// assertThat(hash.getMd5()).isEqualTo(HashGeneratorUtils.generateMD5(randomBytes));
// assertThat(hash.getSha256()).isEqualTo(HashGeneratorUtils.generateSHA256(randomBytes));
assertThat(artifactRepository.findAll()).hasSize(4);
assertThat(softwareModuleRepository.findAll()).hasSize(3);
assertThat(softwareModuleManagement.get(sm.getId()).get().getArtifacts()).hasSize(3);
assertThat(softwareModuleManagement.find(sm.getId()).get().getArtifacts()).hasSize(3);
}
}
@@ -161,7 +158,7 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
final ArtifactUpload artifactUpload = new ArtifactUpload(
IOUtils.toInputStream(artifactData, "UTF-8"), smID, illegalFilename, false, artifactSize);
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(() -> artifactManagement.create(artifactUpload));
assertThat(softwareModuleManagement.get(smID).get().getArtifacts()).isEmpty();
assertThat(softwareModuleManagement.find(smID).get().getArtifacts()).isEmpty();
}
/**
@@ -179,7 +176,6 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
for (int i = 0; i < maxArtifacts; ++i) {
artifactIds.add(createArtifactForSoftwareModule("file" + i, smId, artifactSize).getId());
}
assertThat(artifactManagement.findBySoftwareModule(smId, PAGE).getTotalElements()).isEqualTo(maxArtifacts);
// create one mode to trigger the quota exceeded error
assertThatExceptionOfType(AssignmentQuotaExceededException.class)
@@ -187,12 +183,9 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
// delete one of the artifacts
artifactManagement.delete(artifactIds.get(0));
assertThat(artifactManagement.findBySoftwareModule(smId, PAGE).getTotalElements())
.isEqualTo(maxArtifacts - 1);
// now we should be able to create an artifact again
createArtifactForSoftwareModule("fileXYZ", smId, artifactSize);
assertThat(artifactManagement.findBySoftwareModule(smId, PAGE).getTotalElements()).isEqualTo(maxArtifacts);
}
/**
@@ -275,18 +268,24 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
assertThat(artifact2.getId()).isNotNull();
assertThat(artifact1.getSha1Hash()).isNotEqualTo(artifact2.getSha1Hash());
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash())).isNotNull();
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact2.getSha1Hash())).isNotNull();
final String currentTenant = tenantAware.getCurrentTenant();
assertThat(binaryArtifactRepository.getBySha1(currentTenant, artifact1.getSha1Hash())).isNotNull();
assertThat(binaryArtifactRepository.getBySha1(currentTenant, artifact2.getSha1Hash())).isNotNull();
artifactManagement.delete(artifact1.getId());
assertThat(artifactRepository.findAll()).hasSize(1);
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash())).isNull();
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact2.getSha1Hash())).isNotNull();
final String sha1Hash = artifact1.getSha1Hash();
assertThatExceptionOfType(ArtifactBinaryNotFoundException.class)
.isThrownBy(() -> binaryArtifactRepository.getBySha1(currentTenant, sha1Hash));
assertThat(binaryArtifactRepository.getBySha1(currentTenant, artifact2.getSha1Hash())).isNotNull();
artifactManagement.delete(artifact2.getId());
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact2.getSha1Hash())).isNull();
final String sha1Hash2 = artifact2.getSha1Hash();
assertThatExceptionOfType(ArtifactBinaryNotFoundException.class)
.isThrownBy(() -> binaryArtifactRepository.getBySha1(currentTenant, sha1Hash2));
assertThat(artifactRepository.findAll()).isEmpty();
}
@@ -313,15 +312,18 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
assertThat(artifact2.getId()).isNotNull();
assertThat((artifact1).getSha1Hash()).isEqualTo(artifact2.getSha1Hash());
assertThat(artifactRepository.findAll()).hasSize(2);
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash())).isNotNull();
final String currentTenant = tenantAware.getCurrentTenant();
assertThat(binaryArtifactRepository.getBySha1(currentTenant, artifact1.getSha1Hash())).isNotNull();
artifactManagement.delete(artifact1.getId());
assertThat(artifactRepository.existsById(artifact1.getId())).isFalse();
assertThat(artifactRepository.findAll()).hasSize(1);
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash())).isNotNull();
assertThat(binaryArtifactRepository.getBySha1(currentTenant, artifact1.getSha1Hash())).isNotNull();
artifactManagement.delete(artifact2.getId());
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), artifact1.getSha1Hash())).isNull();
final String sha1Hash = artifact1.getSha1Hash();
assertThatExceptionOfType(ArtifactBinaryNotFoundException.class)
.isThrownBy(() -> binaryArtifactRepository.getBySha1(currentTenant, sha1Hash));
assertThat(artifactRepository.findAll()).isEmpty();
}
}
@@ -394,19 +396,6 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
verifyTenantArtifactCountIs(tenant2, 1);
}
/**
* Loads an local artifact based on given ID.
*/
@Test
void findArtifact() throws IOException {
final int artifactSize = 5 * 1024;
try (final InputStream inputStream = new RandomGeneratedInputStream(artifactSize)) {
final Artifact artifact = createArtifactForSoftwareModule(
"file1", testdataFactory.createSoftwareModuleOs().getId(), artifactSize, inputStream);
assertThat(artifactManagement.get(artifact.getId())).contains(artifact);
}
}
/**
* Loads an artifact binary based on given ID.
*/
@@ -434,39 +423,6 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
.isThrownBy(() -> artifactManagement.loadArtifactBinary("123", 1, false));
}
/**
* Searches an artifact through the relations of a software module.
*/
@Test
void findArtifactBySoftwareModule() throws IOException {
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
assertThat(artifactManagement.findBySoftwareModule(sm.getId(), PAGE)).isEmpty();
final int artifactSize = 5 * 1024;
try (final InputStream input = new RandomGeneratedInputStream(artifactSize)) {
createArtifactForSoftwareModule("file1", sm.getId(), artifactSize, input);
assertThat(artifactManagement.findBySoftwareModule(sm.getId(), PAGE)).hasSize(1);
}
}
/**
* Searches an artifact through the relations of a software module and the filename.
*/
@Test
void findByFilenameAndSoftwareModule() throws IOException {
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
assertThat(artifactManagement.getByFilenameAndSoftwareModule("file1", sm.getId())).isNotPresent();
final int artifactSize = 5 * 1024;
try (final InputStream inputStream1 = new RandomGeneratedInputStream(artifactSize);
final InputStream inputStream2 = new RandomGeneratedInputStream(artifactSize)) {
createArtifactForSoftwareModule("file1", sm.getId(), artifactSize, inputStream1);
createArtifactForSoftwareModule("file2", sm.getId(), artifactSize, inputStream2);
assertThat(artifactManagement.getByFilenameAndSoftwareModule("file1", sm.getId())).isPresent();
}
}
/**
* Verifies that creation of an artifact with none matching hashes fails.
*/
@@ -522,8 +478,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
assertThat(createdArtifact.getSha256Hash()).isEqualTo(artifactHashes.getSha256());
}
final Optional<DbArtifact> dbArtifact = artifactManagement.loadArtifactBinary(artifactHashes.getSha1(), sm.getId(), sm.isEncrypted());
assertThat(dbArtifact).isPresent();
final DbArtifact dbArtifact = artifactManagement.loadArtifactBinary(artifactHashes.getSha1(), sm.getId(), sm.isEncrypted());
assertThat(dbArtifact).isNotNull();
}
/**
@@ -544,9 +500,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
final Artifact artifact = artifactManagement.create(artifactUpload);
assertThat(artifact).isNotNull();
}
final Optional<DbArtifact> dbArtifact = artifactManagement.loadArtifactBinary(
artifactHashes.getSha1(), smOs.getId(), smOs.isEncrypted());
assertThat(dbArtifact).isPresent();
final DbArtifact dbArtifact = artifactManagement.loadArtifactBinary(artifactHashes.getSha1(), smOs.getId(), smOs.isEncrypted());
assertThat(dbArtifact).isNotNull();
try (final InputStream inputStream = new ByteArrayInputStream(testData)) {
final ArtifactUpload existingArtifactUpload = new ArtifactUpload(
@@ -601,8 +556,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
assertThat(runAsTenant(tenant, () -> artifactRepository.findAll())).hasSize(count);
}
private void assertEqualFileContents(final Optional<DbArtifact> artifact, final byte[] randomBytes) throws IOException {
try (final InputStream inputStream = artifact.get().getFileInputStream()) {
private void assertEqualFileContents(final DbArtifact artifact, final byte[] randomBytes) throws IOException {
try (final InputStream inputStream = artifact.getFileInputStream()) {
assertTrue(
IOUtils.contentEquals(new ByteArrayInputStream(randomBytes), inputStream),
"The stored binary matches the given binary");

View File

@@ -195,10 +195,10 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
* Tests ControllerManagement#getByControllerId() method
*/
@Test
void getByControllerIdPermissionsCheck() {
assertPermissions(() -> controllerManagement.getByControllerId("controllerId"),
void findByControllerIdPermissionsCheck() {
assertPermissions(() -> controllerManagement.findByControllerId("controllerId"),
List.of(SpRole.CONTROLLER_ROLE));
assertPermissions(() -> controllerManagement.getByControllerId("controllerId"),
assertPermissions(() -> controllerManagement.findByControllerId("controllerId"),
List.of(SpRole.SYSTEM_ROLE));
}
@@ -207,8 +207,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
*/
@Test
void getPermissionsCheck() {
assertPermissions(() -> controllerManagement.get(1L), List.of(SpRole.CONTROLLER_ROLE));
assertPermissions(() -> controllerManagement.get(1L), List.of(SpRole.SYSTEM_ROLE));
assertPermissions(() -> controllerManagement.find(1L), List.of(SpRole.CONTROLLER_ROLE));
assertPermissions(() -> controllerManagement.find(1L), List.of(SpRole.SYSTEM_ROLE));
}
/**

View File

@@ -332,8 +332,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
final SoftwareModule module = testdataFactory.createSoftwareModuleOs();
assertThat(controllerManagement.findActionWithDetails(NOT_EXIST_IDL)).isNotPresent();
assertThat(controllerManagement.getByControllerId(NOT_EXIST_ID)).isNotPresent();
assertThat(controllerManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(controllerManagement.findByControllerId(NOT_EXIST_ID)).isNotPresent();
assertThat(controllerManagement.find(NOT_EXIST_IDL)).isNotPresent();
assertThat(controllerManagement.getActionForDownloadByTargetAndSoftwareModule(target.getControllerId(),
module.getId())).isNotPresent();
@@ -1952,14 +1952,14 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
}
private void assertAssignedDistributionSetId(final String controllerId, final Long dsId) {
final Optional<Target> target = controllerManagement.getByControllerId(controllerId);
final Optional<Target> target = controllerManagement.findByControllerId(controllerId);
assertThat(target).isPresent();
final DistributionSet assignedDistributionSet = ((JpaTarget) target.get()).getAssignedDistributionSet();
assertThat(assignedDistributionSet.getId()).isEqualTo(dsId);
}
private void assertInstalledDistributionSetId(final String controllerId, final Long dsId) {
final Optional<Target> target = controllerManagement.getByControllerId(controllerId);
final Optional<Target> target = controllerManagement.findByControllerId(controllerId);
assertThat(target).isPresent();
final DistributionSet installedDistributionSet = ((JpaTarget) target.get()).getInstalledDistributionSet();
if (dsId == null) {

View File

@@ -1341,12 +1341,12 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
distributionSetManagement.delete(dsA.getId());
assertThat(distributionSetManagement.get(dsA.getId())).isNotPresent();
assertThat(distributionSetManagement.find(dsA.getId())).isNotPresent();
// // verify that the ds is not physically deleted
for (final DistributionSet ds : deploymentResult.getDistributionSets()) {
distributionSetManagement.delete(ds.getId());
final DistributionSet foundDS = distributionSetManagement.get(ds.getId()).get();
final DistributionSet foundDS = distributionSetManagement.find(ds.getId()).get();
assertThat(foundDS).as("founded should not be null").isNotNull();
assertThat(foundDS.isDeleted()).as("found ds should be deleted").isTrue();
}
@@ -1780,7 +1780,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
}
private Slice<Action> findActionsByDistributionSet(final Pageable pageable, final long distributionSetId) {
distributionSetManagement.get(distributionSetId).orElseThrow(() ->
distributionSetManagement.find(distributionSetId).orElseThrow(() ->
new EntityNotFoundException(DistributionSet.class, distributionSetId));
return actionRepository
.findAll(byDistributionSetId(distributionSetId), pageable)

View File

@@ -63,7 +63,7 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe
distributionSetInvalidationManagement.invalidateDistributionSet(distributionSetInvalidation);
rolloutHandler.handleAll();
assertThat(targetFilterQueryManagement.get(invalidationTestData.getTargetFilterQuery().getId()).get()
assertThat(targetFilterQueryManagement.find(invalidationTestData.getTargetFilterQuery().getId()).get()
.getAutoAssignDistributionSet()).isNull();
assertThat(rolloutRepository.findById(invalidationTestData.getRollout().getId()).get().getStatus())
.isNotIn(RolloutStatus.STOPPING, RolloutStatus.FINISHED);
@@ -92,7 +92,7 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe
distributionSetInvalidationManagement.invalidateDistributionSet(distributionSetInvalidation);
rolloutHandler.handleAll();
assertThat(targetFilterQueryManagement.get(invalidationTestData.getTargetFilterQuery().getId()).get()
assertThat(targetFilterQueryManagement.find(invalidationTestData.getTargetFilterQuery().getId()).get()
.getAutoAssignDistributionSet()).isNull();
assertThat(rolloutRepository.findById(invalidationTestData.getRollout().getId()).get().getStatus())
.isEqualTo(RolloutStatus.READY);
@@ -124,7 +124,7 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe
distributionSetInvalidationManagement.invalidateDistributionSet(distributionSetInvalidation);
rolloutHandler.handleAll();
assertThat(targetFilterQueryManagement.get(invalidationTestData.getTargetFilterQuery().getId()).get()
assertThat(targetFilterQueryManagement.find(invalidationTestData.getTargetFilterQuery().getId()).get()
.getAutoAssignDistributionSet()).isNull();
// rollout should be deleted when force invalidation
assertThat(rolloutRepository.findById(invalidationTestData.getRollout().getId())).isEmpty();
@@ -146,7 +146,7 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe
distributionSetInvalidationManagement.invalidateDistributionSet(distributionSetInvalidation);
assertThat(targetFilterQueryManagement.get(invalidationTestData.getTargetFilterQuery().getId()).get()
assertThat(targetFilterQueryManagement.find(invalidationTestData.getTargetFilterQuery().getId()).get()
.getAutoAssignDistributionSet()).isNull();
assertThat(rolloutRepository.findById(invalidationTestData.getRollout().getId()).get().getStatus())
.isIn(RolloutStatus.STOPPING, RolloutStatus.FINISHED);

View File

@@ -26,17 +26,17 @@ class DistributionSetManagementSecurityTest
extends AbstractRepositoryManagementSecurityTest<DistributionSet, DistributionSetManagement.Create, DistributionSetManagement.Update> {
@Override
protected DistributionSetManagement getRepositoryManagement() {
protected DistributionSetManagement findRepositoryManagement() {
return distributionSetManagement;
}
@Override
protected DistributionSetManagement.Create getCreateObject() {
protected DistributionSetManagement.Create findCreateObject() {
return DistributionSetManagement.Create.builder().name("name").version("1.0.0").type(defaultDsType()).build();
}
@Override
protected DistributionSetManagement.Update getUpdateObject() {
protected DistributionSetManagement.Update findUpdateObject() {
return DistributionSetManagement.Update.builder().id(0L).name("a new name")
.description("a new description").version("a new version").requiredMigrationStep(true).build();
}
@@ -157,8 +157,8 @@ class DistributionSetManagementSecurityTest
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
*/
@Test
void getOrElseThrowExceptionPermissionsCheck() {
assertPermissions(() -> distributionSetManagement.getOrElseThrowException(1L), List.of(SpPermission.READ_REPOSITORY));
void getPermissionsCheck() {
assertPermissions(() -> distributionSetManagement.get(1L), List.of(SpPermission.READ_REPOSITORY));
}
/**

View File

@@ -91,7 +91,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3) })
void nonExistingEntityAccessReturnsNotPresent() {
final DistributionSet set = testdataFactory.createDistributionSet();
assertThat(distributionSetManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(distributionSetManagement.find(NOT_EXIST_IDL)).isNotPresent();
assertThat(distributionSetManagement.getWithDetails(NOT_EXIST_IDL)).isNotPresent();
assertThat(distributionSetManagement.findByNameAndVersion(NOT_EXIST_ID, NOT_EXIST_ID)).isNotPresent();
assertThat(distributionSetManagement.getMetadata(set.getId()).get(NOT_EXIST_ID)).isNull();
@@ -149,7 +149,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
"DistributionSet");
verifyThrownExceptionBy(() -> distributionSetManagement.createMetadata(NOT_EXIST_IDL, "xxx", "xxx"), "DistributionSet");
verifyThrownExceptionBy(() -> distributionSetManagement.getOrElseThrowException(NOT_EXIST_IDL), "DistributionSet");
verifyThrownExceptionBy(() -> distributionSetManagement.get(NOT_EXIST_IDL), "DistributionSet");
verifyThrownExceptionBy(() -> distributionSetManagement.getValidAndComplete(NOT_EXIST_IDL), "DistributionSet");
}
@@ -292,7 +292,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
.as("ds has wrong tag size")
.hasSize(1));
final DistributionSetTag findDistributionSetTag = getOrThrow(distributionSetTagManagement.get(tag.getId()));
final DistributionSetTag findDistributionSetTag = getOrThrow(distributionSetTagManagement.find(tag.getId()));
assertThat(assignedDS)
.as("assigned ds has wrong size")
@@ -302,7 +302,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
.unassignTag(List.of(assignDS.get(0)), findDistributionSetTag.getId()).get(0);
assertThat(unAssignDS.getId()).as("unassigned ds is wrong").isEqualTo(assignDS.get(0));
assertThat(unAssignDS.getTags()).as("unassigned ds has wrong tag size").isEmpty();
assertThat(distributionSetTagManagement.get(tag.getId())).isPresent();
assertThat(distributionSetTagManagement.find(tag.getId())).isPresent();
assertThat(distributionSetManagement.findByTag(tag.getId(), PAGE).getNumberOfElements())
.as("ds tag ds has wrong ds size").isEqualTo(3);
@@ -508,7 +508,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
// create an DS meta data entry
insertMetadata(knownKey, knownValue, ds);
final DistributionSet changedLockRevisionDS = getOrThrow(distributionSetManagement.get(ds.getId()));
final DistributionSet changedLockRevisionDS = getOrThrow(distributionSetManagement.find(ds.getId()));
assertThat(changedLockRevisionDS.getOptLockRevision()).isEqualTo(2);
waitNextMillis();
@@ -516,7 +516,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
distributionSetManagement.createMetadata(ds.getId(), knownKey, knownUpdateValue);
// we are updating the sw metadata so also modifying the base software
// module so opt lock revision must be three
final DistributionSet reloadedDS = getOrThrow(distributionSetManagement.get(ds.getId()));
final DistributionSet reloadedDS = getOrThrow(distributionSetManagement.find(ds.getId()));
assertThat(reloadedDS.getOptLockRevision()).isEqualTo(3);
assertThat(reloadedDS.getLastModifiedAt()).isPositive();
@@ -562,7 +562,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
assignDistributionSet(dsDeleted, testdataFactory.createTargets(5));
distributionSetManagement.delete(dsDeleted.getId());
dsDeleted = getOrThrow(distributionSetManagement.get(dsDeleted.getId()));
dsDeleted = getOrThrow(distributionSetManagement.find(dsDeleted.getId()));
dsGroup1 = assignTag(dsGroup1, dsTagA);
dsTagA = getOrThrow(distributionSetTagRepository.findById(dsTagA.getId()));
@@ -600,9 +600,9 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
@Test
void lockDistributionSet() {
final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1");
assertThat(distributionSetManagement.get(distributionSet.getId()).map(DistributionSet::isLocked).orElse(true)).isFalse();
assertThat(distributionSetManagement.find(distributionSet.getId()).map(DistributionSet::isLocked).orElse(true)).isFalse();
distributionSetManagement.lock(distributionSet);
assertThat(distributionSetManagement.get(distributionSet.getId()).map(DistributionSet::isLocked).orElse(false)).isTrue();
assertThat(distributionSetManagement.find(distributionSet.getId()).map(DistributionSet::isLocked).orElse(false)).isTrue();
// assert software modules are locked
assertThat(distributionSet.getModules().size()).isNotZero();
distributionSetManagement.getWithDetails(distributionSet.getId()).map(DistributionSet::getModules).orElseThrow()
@@ -616,10 +616,10 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
void deleteUnassignedLockedDistributionSet() {
final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1");
distributionSetManagement.lock(distributionSet);
assertThat(distributionSetManagement.get(distributionSet.getId()).map(DistributionSet::isLocked).orElse(false)).isTrue();
assertThat(distributionSetManagement.find(distributionSet.getId()).map(DistributionSet::isLocked).orElse(false)).isTrue();
distributionSetManagement.delete(distributionSet.getId());
assertThat(distributionSetManagement.get(distributionSet.getId())).isEmpty();
assertThat(distributionSetManagement.find(distributionSet.getId())).isEmpty();
}
/**
@@ -629,13 +629,13 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
void deleteAssignedLockedDistributionSet() {
final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1");
distributionSetManagement.lock(distributionSet);
assertThat(distributionSetManagement.get(distributionSet.getId()).map(DistributionSet::isLocked).orElse(false)).isTrue();
assertThat(distributionSetManagement.find(distributionSet.getId()).map(DistributionSet::isLocked).orElse(false)).isTrue();
final Target target = testdataFactory.createTarget();
assignDistributionSet(distributionSet.getId(), target.getControllerId());
distributionSetManagement.delete(distributionSet.getId());
assertThat(distributionSetManagement.getOrElseThrowException(distributionSet.getId()).isDeleted()).isTrue();
assertThat(distributionSetManagement.get(distributionSet.getId()).isDeleted()).isTrue();
}
/**
@@ -645,9 +645,9 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
void unlockDistributionSet() {
DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1");
distributionSet = distributionSetManagement.lock(distributionSet);
assertThat(distributionSetManagement.get(distributionSet.getId()).map(DistributionSet::isLocked).orElse(false)).isTrue();
assertThat(distributionSetManagement.find(distributionSet.getId()).map(DistributionSet::isLocked).orElse(false)).isTrue();
distributionSet = distributionSetManagement.unlock(distributionSet);
assertThat(distributionSetManagement.get(distributionSet.getId()).map(DistributionSet::isLocked).orElse(true)).isFalse();
assertThat(distributionSetManagement.find(distributionSet.getId()).map(DistributionSet::isLocked).orElse(true)).isFalse();
// assert software modules are not unlocked
assertThat(distributionSet.getModules().size()).isNotZero();
distributionSetManagement.getWithDetails(distributionSet.getId()).map(DistributionSet::getModules).orElseThrow()
@@ -664,7 +664,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
assertThat(softwareModuleCount).isNotZero();
distributionSetManagement.lock(distributionSet);
final Long distributionSetId = distributionSet.getId();
assertThat(distributionSetManagement.get(distributionSetId).map(DistributionSet::isLocked).orElse(false)).isTrue();
assertThat(distributionSetManagement.find(distributionSetId).map(DistributionSet::isLocked).orElse(false)).isTrue();
// try add
final List<Long> moduleIds = List.of(testdataFactory.createSoftwareModule("sm-1").getId());
@@ -709,7 +709,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
skipTags.forEach(skipTag -> {
DistributionSet distributionSetWithSkipTag = testdataFactory.createDistributionSet("ds-skip-" + skipTag.getName());
distributionSetManagement.assignTag(List.of(distributionSetWithSkipTag.getId()), skipTag.getId());
distributionSetWithSkipTag = distributionSetManagement.get(distributionSetWithSkipTag.getId()).orElseThrow();
distributionSetWithSkipTag = distributionSetManagement.find(distributionSetWithSkipTag.getId()).orElseThrow();
// assert that implicit lock isn't applicable for skip tags
assertThat(distributionSetManagement.shouldLockImplicitly(distributionSetWithSkipTag)).isFalse();
});
@@ -725,7 +725,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
.as("Locking an incomplete distribution set should throw an exception")
.isThrownBy(() -> distributionSetManagement.lock(incompleteDistributionSet));
assertThat(
distributionSetManagement.get(incompleteDistributionSet.getId()).map(DistributionSet::isLocked).orElse(true))
distributionSetManagement.find(incompleteDistributionSet.getId()).map(DistributionSet::isLocked).orElse(true))
.isFalse();
}
@@ -909,12 +909,12 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
assertThat(distributionSetManagement.countRolloutsByStatusForDistributionSet(ds2.getId())).hasSize(1);
assertThat(distributionSetManagement.countRolloutsByStatusForDistributionSet(ds3.getId())).isEmpty();
Optional<Rollout> rollout = rolloutManagement.get(rollout1.getId());
Optional<Rollout> rollout = rolloutManagement.find(rollout1.getId());
rollout.ifPresent(value -> assertThat(Rollout.RolloutStatus.valueOf(
String.valueOf(distributionSetManagement.countRolloutsByStatusForDistributionSet(ds1.getId()).get(0).getName()))).isEqualTo(
value.getStatus()));
rollout = rolloutManagement.get(rollout2.getId());
rollout = rolloutManagement.find(rollout2.getId());
rollout.ifPresent(value -> assertThat(Rollout.RolloutStatus.valueOf(
String.valueOf(distributionSetManagement.countRolloutsByStatusForDistributionSet(ds2.getId()).get(0).getName()))).isEqualTo(
value.getStatus()));

View File

@@ -28,17 +28,17 @@ class DistributionSetTagManagementSecurityTest
extends AbstractRepositoryManagementSecurityTest<DistributionSetTag, DistributionSetTagManagement.Create, DistributionSetTagManagement.Update> {
@Override
protected RepositoryManagement getRepositoryManagement() {
protected RepositoryManagement findRepositoryManagement() {
return distributionSetTagManagement;
}
@Override
protected DistributionSetTagManagement.Create getCreateObject() {
protected DistributionSetTagManagement.Create findCreateObject() {
return DistributionSetTagManagement.Create.builder().name(String.format("tag-%d", new Random().nextInt())).build();
}
@Override
protected DistributionSetTagManagement.Update getUpdateObject() {
protected DistributionSetTagManagement.Update findUpdateObject() {
return DistributionSetTagManagement.Update.builder().id(1L).name("tag").build();
}
}

View File

@@ -18,7 +18,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.stream.Stream;
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
@@ -51,7 +50,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
void nonExistingEntityAccessReturnsNotPresent() {
assertThat(distributionSetTagManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(distributionSetTagManagement.find(NOT_EXIST_IDL)).isNotPresent();
}
/**
@@ -91,18 +90,18 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
assignTag(dsBs, tagB);
assignTag(dsCs, tagC);
assignTag(dsABs, distributionSetTagManagement.get(tagA.getId()).orElseThrow());
assignTag(dsABs, distributionSetTagManagement.get(tagB.getId()).orElseThrow());
assignTag(dsABs, distributionSetTagManagement.find(tagA.getId()).orElseThrow());
assignTag(dsABs, distributionSetTagManagement.find(tagB.getId()).orElseThrow());
assignTag(dsACs, distributionSetTagManagement.get(tagA.getId()).orElseThrow());
assignTag(dsACs, distributionSetTagManagement.get(tagC.getId()).orElseThrow());
assignTag(dsACs, distributionSetTagManagement.find(tagA.getId()).orElseThrow());
assignTag(dsACs, distributionSetTagManagement.find(tagC.getId()).orElseThrow());
assignTag(dsBCs, distributionSetTagManagement.get(tagB.getId()).orElseThrow());
assignTag(dsBCs, distributionSetTagManagement.get(tagC.getId()).orElseThrow());
assignTag(dsBCs, distributionSetTagManagement.find(tagB.getId()).orElseThrow());
assignTag(dsBCs, distributionSetTagManagement.find(tagC.getId()).orElseThrow());
assignTag(dsABCs, distributionSetTagManagement.get(tagA.getId()).orElseThrow());
assignTag(dsABCs, distributionSetTagManagement.get(tagB.getId()).orElseThrow());
assignTag(dsABCs, distributionSetTagManagement.get(tagC.getId()).orElseThrow());
assignTag(dsABCs, distributionSetTagManagement.find(tagA.getId()).orElseThrow());
assignTag(dsABCs, distributionSetTagManagement.find(tagB.getId()).orElseThrow());
assignTag(dsABCs, distributionSetTagManagement.find(tagC.getId()).orElseThrow());
// search for not deleted
final DistributionSetFilter.DistributionSetFilterBuilder distributionSetFilterBuilder = getDistributionSetFilterBuilder()
@@ -215,9 +214,9 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
assertThat(distributionSetTagRepository.findById(tag.getId()).orElseThrow().getDescription()).as("wrong tag found")
.isEqualTo("kai2");
assertThat(distributionSetTagManagement.get(tag.getId()).orElseThrow().getColour()).as("wrong tag found")
assertThat(distributionSetTagManagement.find(tag.getId()).orElseThrow().getColour()).as("wrong tag found")
.isEqualTo("colour");
assertThat(distributionSetTagManagement.get(tag.getId()).orElseThrow().getColour()).as("wrong tag found")
assertThat(distributionSetTagManagement.find(tag.getId()).orElseThrow().getColour()).as("wrong tag found")
.isEqualTo("colour");
}

View File

@@ -27,17 +27,17 @@ class DistributionSetTypeManagementSecurityTest
extends AbstractRepositoryManagementSecurityTest<DistributionSetType, DistributionSetTypeManagement.Create, DistributionSetTypeManagement.Update> {
@Override
protected RepositoryManagement getRepositoryManagement() {
protected RepositoryManagement findRepositoryManagement() {
return distributionSetTypeManagement;
}
@Override
protected DistributionSetTypeManagement.Create getCreateObject() {
protected DistributionSetTypeManagement.Create findCreateObject() {
return DistributionSetTypeManagement.Create.builder().key(String.format("key-%d", new Random().nextInt())).name(String.format("name-%d", new Random().nextInt())).build();
}
@Override
protected DistributionSetTypeManagement.Update getUpdateObject() {
protected DistributionSetTypeManagement.Update findUpdateObject() {
return DistributionSetTypeManagement.Update.builder().id(1L).description("description").build();
}

View File

@@ -56,7 +56,7 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
@Test
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 0) })
void nonExistingEntityAccessReturnsNotPresent() {
assertThat(distributionSetTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(distributionSetTypeManagement.find(NOT_EXIST_IDL)).isNotPresent();
assertThat(distributionSetTypeManagement.findByKey(NOT_EXIST_ID)).isNotPresent();
assertThat(distributionSetTypeManagement.findByName(NOT_EXIST_ID)).isNotPresent();
}
@@ -165,8 +165,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
final Long dsType2Id = dsType2.getId();
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(dsType2Id,
moduleTypeIds.subList(0, quota));
assertThat(distributionSetTypeManagement.get(dsType2Id)).isNotEmpty();
assertThat(distributionSetTypeManagement.get(dsType2Id).get().getMandatoryModuleTypes()).hasSize(quota);
assertThat(distributionSetTypeManagement.find(dsType2Id)).isNotEmpty();
assertThat(distributionSetTypeManagement.find(dsType2Id).get().getMandatoryModuleTypes()).hasSize(quota);
// assign one more to trigger the quota exceeded error
final List<Long> softwareModuleTypeIds = Collections.singletonList(moduleTypeIds.get(quota));
assertThatExceptionOfType(AssignmentQuotaExceededException.class)
@@ -177,8 +177,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
.create(DistributionSetTypeManagement.Create.builder().key("dst3").name("dst3").build());
final Long dsType3Id = dsType3.getId();
distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(dsType3Id, moduleTypeIds.subList(0, quota));
assertThat(distributionSetTypeManagement.get(dsType3Id)).isNotEmpty();
assertThat(distributionSetTypeManagement.get(dsType3Id).get().getOptionalModuleTypes()).hasSize(quota);
assertThat(distributionSetTypeManagement.find(dsType3Id)).isNotEmpty();
assertThat(distributionSetTypeManagement.find(dsType3Id).get().getOptionalModuleTypes()).hasSize(quota);
// assign one more to trigger the quota exceeded error
assertThatExceptionOfType(AssignmentQuotaExceededException.class)
.isThrownBy(() -> distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(dsType3Id, softwareModuleTypeIds));

View File

@@ -51,7 +51,7 @@ class LazyControllerManagementTest extends AbstractJpaIntegrationTest {
controllerManagement.findOrRegisterTargetIfItDoesNotExist("AA", LOCALHOST);
TimeUnit.MILLISECONDS.sleep(repositoryProperties.getPollPersistenceFlushTime() + 10);
final Target updated = targetManagement.get(target.getId()).get();
final Target updated = targetManagement.find(target.getId()).get();
assertThat(updated.getOptLockRevision()).isEqualTo(target.getOptLockRevision());
assertThat(updated.getLastTargetQuery()).isGreaterThan(target.getLastTargetQuery());

View File

@@ -22,7 +22,6 @@ import org.eclipse.hawkbit.repository.RolloutManagement.Update;
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
import org.eclipse.hawkbit.repository.model.ActionCancellationType;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetInvalidation;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
import org.eclipse.hawkbit.repository.test.util.TestdataFactory;
@@ -44,15 +43,15 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
*/
@Test
void getPermissionsCheck() {
assertPermissions(() -> rolloutManagement.get(1L), List.of(SpPermission.READ_ROLLOUT));
void findPermissionsCheck() {
assertPermissions(() -> rolloutManagement.find(1L), List.of(SpPermission.READ_ROLLOUT));
}
/**
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
*/
@Test
void getByNamePermissionsCheck() {
void findByNamePermissionsCheck() {
assertPermissions(() -> rolloutManagement.getByName("name"), List.of(SpPermission.READ_ROLLOUT));
}
@@ -60,7 +59,7 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
* Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.
*/
@Test
void getWithDetailedStatusPermissionsCheck() {
void findWithDetailedStatusPermissionsCheck() {
assertPermissions(() -> rolloutManagement.getWithDetailedStatus(1L), List.of(SpPermission.READ_ROLLOUT));
}

View File

@@ -289,7 +289,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void nonExistingEntityAccessReturnsNotPresent() {
assertThat(rolloutManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(rolloutManagement.find(NOT_EXIST_IDL)).isNotPresent();
assertThat(rolloutManagement.getByName(NOT_EXIST_ID)).isNotPresent();
assertThat(rolloutManagement.getWithDetailedStatus(NOT_EXIST_IDL)).isNotPresent();
}
@@ -570,7 +570,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
rolloutHandler.handleAll();
// finish running actions, 2 actions should be finished
assertThat(changeStatusForAllRunningActions(createdRollout, Status.FINISHED)).isEqualTo(2);
assertThat(getRollout(createdRollout.getId()).getStatus()).isEqualTo(RolloutStatus.RUNNING);
assertThat(findRollout(createdRollout.getId()).getStatus()).isEqualTo(RolloutStatus.RUNNING);
}
// check rollout to see that all actions and all groups are finished and
@@ -857,7 +857,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
* Verify that target actions of a rollout get cancelled when another rollout with same targets gets started.
*/
@Test
void targetsOfRolloutGetDistributionSetAssignmentByOtherRollout() {
void targetsOfRolloutFindDistributionSetAssignmentByOtherRollout() {
final int amountTargetsForRollout = 15;
final int amountOtherTargets = 5;
@@ -1187,7 +1187,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
* Verify that the percent count is acting like aspected when targets move to the status finished or error.
*/
@Test
void getFinishedPercentForRunningGroup() {
void findFinishedPercentForRunningGroup() {
final int amountTargetsForRollout = 10;
final int amountGroups = 2;
@@ -1363,7 +1363,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
// Run here, because scheduler is disabled during tests
rolloutHandler.handleAll();
myRollout = getRollout(myRolloutId);
myRollout = findRollout(myRolloutId);
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.RUNNING);
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus = createInitStatusMap();
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.RUNNING, 1L);
@@ -1389,7 +1389,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
rolloutHandler.handleAll();
myRollout = getRollout(myRollout.getId());
myRollout = findRollout(myRollout.getId());
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
rolloutManagement.start(myRollout.getId());
@@ -1568,7 +1568,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
rolloutHandler.handleAll();
// rollout should not have been started
myRollout = getRollout(myRolloutId);
myRollout = findRollout(myRolloutId);
assertThat(myRollout.getName()).isEqualTo("newName");
assertThat(myRollout.getDescription()).isEqualTo("newDesc");
}
@@ -1604,7 +1604,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
rolloutGroups.add(generateRolloutGroup(2, percentTargetsInGroup3, null));
Rollout myRollout = rolloutManagement.create(rolloutcreate, rolloutGroups, conditions);
myRollout = getRollout(myRollout.getId());
myRollout = findRollout(myRollout.getId());
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.CREATING);
for (final RolloutGroup group : rolloutGroupManagement.findByRollout(myRollout.getId(), PAGE).getContent()) {
@@ -1616,7 +1616,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
rolloutHandler.handleAll();
myRollout = getRollout(myRollout.getId());
myRollout = findRollout(myRollout.getId());
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
assertThat(myRollout.getTotalTargets()).isEqualTo(amountTargetsInGroup2and3 + amountTargetsInGroup1);
@@ -1658,7 +1658,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
final Long rolloutId = rolloutManagement.create(rolloutcreate, rolloutGroups, conditions).getId();
assertThat(getRollout(rolloutId)).satisfies(rollout -> {
assertThat(findRollout(rolloutId)).satisfies(rollout -> {
assertThat(rollout.getStatus()).isEqualTo(RolloutStatus.CREATING);
for (final RolloutGroup group : rolloutGroupManagement.findByRollout(rollout.getId(), PAGE).getContent()) {
assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.CREATING);
@@ -1668,7 +1668,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
// first handle iteration will put rollout in ready state
rolloutHandler.handleAll();
assertThat(getRollout(rolloutId)).satisfies(rollout -> {
assertThat(findRollout(rolloutId)).satisfies(rollout -> {
assertThat(rollout.getStatus()).isEqualTo(RolloutStatus.READY);
assertThat(rollout.getTotalTargets()).isEqualTo(amountTargetsInGroup1 + amountTargetsInGroup2);
});
@@ -1796,7 +1796,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
.build();
Rollout myRollout = rolloutManagement.create(rolloutToCreate, amountGroups, false, conditions);
myRollout = getRollout(myRollout.getId());
myRollout = findRollout(myRollout.getId());
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.CREATING);
@@ -2215,10 +2215,10 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
void testRolloutStatusConvert() {
final long id = testdataFactory.createAndStartRollout(1, 0, 1, "100", "80").getId();
for (final RolloutStatus status : RolloutStatus.values()) {
final JpaRollout rollout = ((JpaRollout) rolloutManagement.get(id).orElseThrow());
final JpaRollout rollout = ((JpaRollout) rolloutManagement.find(id).orElseThrow());
rollout.setStatus(status);
rolloutRepository.save(rollout);
assertThat(rolloutManagement.get(id).orElseThrow().getStatus()).isEqualTo(status);
assertThat(rolloutManagement.find(id).orElseThrow().getStatus()).isEqualTo(status);
}
}
@@ -2229,10 +2229,10 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
void testActionTypeConvert() {
final long id = testdataFactory.createAndStartRollout(1, 0, 1, "100", "80").getId();
for (final ActionType actionType : ActionType.values()) {
final JpaRollout rollout = ((JpaRollout) rolloutManagement.get(id).orElseThrow());
final JpaRollout rollout = ((JpaRollout) rolloutManagement.find(id).orElseThrow());
rollout.setActionType(actionType);
rolloutRepository.save(rollout);
assertThat(rolloutManagement.get(id).orElseThrow().getActionType()).isEqualTo(actionType);
assertThat(rolloutManagement.find(id).orElseThrow().getActionType()).isEqualTo(actionType);
}
}
@@ -2355,11 +2355,11 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
}
private Rollout reloadRollout(final Rollout r) {
return getRollout(r.getId());
return findRollout(r.getId());
}
private Rollout getRollout(final Long myRolloutId) {
return rolloutManagement.get(myRolloutId).orElseThrow(NoSuchElementException::new);
private Rollout findRollout(final Long myRolloutId) {
return rolloutManagement.find(myRolloutId).orElseThrow(NoSuchElementException::new);
}
private void assertRolloutGroup(final long rolloutGroupId, final RolloutGroupStatus status,

View File

@@ -29,17 +29,17 @@ class SoftwareManagementSecurityTest
extends AbstractRepositoryManagementSecurityTest<SoftwareModule, SoftwareModuleManagement.Create, SoftwareModuleManagement.Update> {
@Override
protected RepositoryManagement getRepositoryManagement() {
protected RepositoryManagement findRepositoryManagement() {
return softwareModuleManagement;
}
@Override
protected SoftwareModuleManagement.Create getCreateObject() {
protected SoftwareModuleManagement.Create findCreateObject() {
return SoftwareModuleManagement.Create.builder().type(getASmType()).name("name").version("version").build();
}
@Override
protected SoftwareModuleManagement.Update getUpdateObject() {
protected SoftwareModuleManagement.Update findUpdateObject() {
return SoftwareModuleManagement.Update.builder().id(1L).locked(true).build();
}

View File

@@ -26,6 +26,7 @@ import jakarta.validation.ConstraintViolationException;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
import org.eclipse.hawkbit.repository.artifact.exception.ArtifactBinaryNotFoundException;
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
@@ -67,7 +68,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 1) })
void nonExistingEntityAccessReturnsNotPresent() {
final SoftwareModule module = testdataFactory.createSoftwareModuleApp();
assertThat(softwareModuleManagement.get(1234L)).isNotPresent();
assertThat(softwareModuleManagement.find(1234L)).isNotPresent();
final Long moduleId = module.getId();
assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy(() -> softwareModuleManagement.getMetadata(moduleId, NOT_EXIST_ID));
}
@@ -223,10 +224,10 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
// [VERIFY EXPECTED RESULT]:
// verify: SoftwareModule is deleted
assertThat(softwareModuleRepository.findAll()).isEmpty();
assertThat(softwareModuleManagement.get(unassignedModule.getId())).isNotPresent();
assertThat(softwareModuleManagement.find(unassignedModule.getId())).isNotPresent();
// verify: binary data of artifact is deleted
assertArtifactNull(artifact1, artifact2);
assertArtifactDoesntExist(artifact1, artifact2);
// verify: metadata of artifact is deleted
assertThat(artifactRepository.findById(artifact1.getId())).isNotPresent();
@@ -249,7 +250,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
// [VERIFY EXPECTED RESULT]:
// verify: assignedModule is marked as deleted
assignedModule = softwareModuleManagement.get(assignedModule.getId()).get();
assignedModule = softwareModuleManagement.find(assignedModule.getId()).get();
assertTrue(assignedModule.isDeleted(), "The module should be flagged as deleted");
assertThat(softwareModuleManagement.findAll(PAGE)).isEmpty();
assertThat(softwareModuleManagement.findByRsql("name==*", PAGE)).isEmpty();
@@ -260,7 +261,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
final Iterator<Artifact> artifactsIt = assignedModule.getArtifacts().iterator();
final Artifact artifact1 = artifactsIt.next();
final Artifact artifact2 = artifactsIt.next();
assertArtifactNull(artifact1, artifact2);
assertArtifactDoesntExist(artifact1, artifact2);
// verify: artifact meta data is still available
assertThat(artifactRepository.findById(artifact1.getId())).isNotNull();
@@ -293,7 +294,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
// [VERIFY EXPECTED RESULT]:
// verify: assignedModule is marked as deleted
assignedModule = softwareModuleManagement.get(assignedModule.getId()).get();
assignedModule = softwareModuleManagement.find(assignedModule.getId()).get();
assertTrue(assignedModule.isDeleted(), "The found module should be flagged deleted");
assertThat(softwareModuleManagement.findAll(PAGE)).isEmpty();
assertThat(softwareModuleRepository.findAll()).hasSize(1);
@@ -302,7 +303,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
final Iterator<Artifact> artifactsIt = assignedModule.getArtifacts().iterator();
final Artifact artifact1 = artifactsIt.next();
final Artifact artifact2 = artifactsIt.next();
assertArtifactNull(artifact1, artifact2);
assertArtifactDoesntExist(artifact1, artifact2);
// verify: artifact meta data is still available
assertThat(artifactRepository.findById(artifact1.getId())).isNotNull();
@@ -325,7 +326,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
// [STEP2]: Create newArtifactX and add it to SoftwareModuleX
artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(source), moduleX.getId(), "artifactx",
false, artifactSize));
moduleX = softwareModuleManagement.get(moduleX.getId()).get();
moduleX = softwareModuleManagement.find(moduleX.getId()).get();
final Artifact artifactX = moduleX.getArtifacts().iterator().next();
// [STEP3]: Create SoftwareModuleY and add the same ArtifactX
@@ -334,7 +335,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
// [STEP4]: Assign the same ArtifactX to SoftwareModuleY
artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(source), moduleY.getId(), "artifactx",
false, artifactSize));
moduleY = softwareModuleManagement.get(moduleY.getId()).get();
moduleY = softwareModuleManagement.find(moduleY.getId()).get();
final Artifact artifactY = moduleY.getArtifacts().iterator().next();
// [STEP5]: Delete SoftwareModuleX
@@ -343,8 +344,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
// [VERIFY EXPECTED RESULT]:
// verify: SoftwareModuleX is deleted, and ModuelY still exists
assertThat(softwareModuleRepository.findAll()).hasSize(1);
assertThat(softwareModuleManagement.get(moduleX.getId())).isNotPresent();
assertThat(softwareModuleManagement.get(moduleY.getId())).isPresent();
assertThat(softwareModuleManagement.find(moduleX.getId())).isNotPresent();
assertThat(softwareModuleManagement.find(moduleY.getId())).isPresent();
// verify: binary data of artifact is not deleted
assertArtifactNotNull(artifactY);
@@ -370,9 +371,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
// [STEP1]: Create SoftwareModuleX and add a new ArtifactX
SoftwareModule moduleX = createSoftwareModuleWithArtifacts(osType, "modulex", "v1.0", 0);
artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(source), moduleX.getId(), "artifactx",
false, artifactSize));
moduleX = softwareModuleManagement.get(moduleX.getId()).get();
artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(source), moduleX.getId(), "artifactx", false, artifactSize));
moduleX = softwareModuleManagement.find(moduleX.getId()).get();
final Artifact artifactX = moduleX.getArtifacts().iterator().next();
// [STEP2]: Create SoftwareModuleY and add the same ArtifactX
@@ -380,7 +380,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(source), moduleY.getId(), "artifactx",
false, artifactSize));
moduleY = softwareModuleManagement.get(moduleY.getId()).get();
moduleY = softwareModuleManagement.find(moduleY.getId()).get();
final Artifact artifactY = moduleY.getArtifacts().iterator().next();
// [STEP3]: Assign SoftwareModuleX to DistributionSetX and to target
@@ -400,8 +400,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
softwareModuleManagement.delete(moduleY.getId());
// [VERIFY EXPECTED RESULT]:
moduleX = softwareModuleManagement.get(moduleX.getId()).get();
moduleY = softwareModuleManagement.get(moduleY.getId()).get();
moduleX = softwareModuleManagement.find(moduleX.getId()).get();
moduleY = softwareModuleManagement.find(moduleY.getId()).get();
// verify: SoftwareModuleX and SoftwareModule are marked as deleted
assertThat(moduleX).isNotNull();
@@ -412,7 +412,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
assertThat(softwareModuleRepository.findAll()).hasSize(2);
// verify: binary data of artifact is deleted
assertArtifactNull(artifactX, artifactY);
assertArtifactDoesntExist(artifactX, artifactY);
// verify: meta data of artifactX and artifactY is not deleted
assertThat(artifactRepository.findById(artifactY.getId())).isNotNull();
@@ -475,7 +475,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
knownKey1, new MetadataValueCreate(knownValue1, true),
knownKey2, new MetadataValueCreate(knownValue2)));
final SoftwareModule changedLockRevisionModule = softwareModuleManagement.get(softwareModule.getId()).get();
final SoftwareModule changedLockRevisionModule = softwareModuleManagement.find(softwareModule.getId()).get();
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(2);
assertThat(softwareModuleManagement.getMetadata(softwareModule.getId(), knownKey1)).satisfies(metadata -> {
@@ -560,7 +560,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
// base software module should have now the opt lock revision one
// because we are modifying the base software module
SoftwareModule changedLockRevisionModule = softwareModuleManagement.get(ah.getId()).get();
SoftwareModule changedLockRevisionModule = softwareModuleManagement.find(ah.getId()).get();
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(2);
// update the software module metadata
@@ -569,7 +569,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
// we are updating the sw metadata so also modifying the base software
// module so opt lock revision must be two
changedLockRevisionModule = softwareModuleManagement.get(ah.getId()).get();
changedLockRevisionModule = softwareModuleManagement.find(ah.getId()).get();
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(3);
// verify updated meta data contains the updated value
@@ -638,9 +638,9 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
@Test
void lockSoftwareModule() {
final SoftwareModule softwareModule = testdataFactory.createSoftwareModule("sm-1");
assertThat(softwareModuleManagement.get(softwareModule.getId()).map(SoftwareModule::isLocked).orElse(true)).isFalse();
assertThat(softwareModuleManagement.find(softwareModule.getId()).map(SoftwareModule::isLocked).orElse(true)).isFalse();
softwareModuleManagement.lock(softwareModule);
assertThat(softwareModuleManagement.get(softwareModule.getId()).map(SoftwareModule::isLocked).orElse(false)).isTrue();
assertThat(softwareModuleManagement.find(softwareModule.getId()).map(SoftwareModule::isLocked).orElse(false)).isTrue();
}
/**
@@ -650,9 +650,9 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
void unlockSoftwareModule() {
SoftwareModule softwareModule = testdataFactory.createSoftwareModule("sm-1");
softwareModule = softwareModuleManagement.lock(softwareModule);
assertThat(softwareModuleManagement.get(softwareModule.getId()).map(SoftwareModule::isLocked).orElse(false)).isTrue();
assertThat(softwareModuleManagement.find(softwareModule.getId()).map(SoftwareModule::isLocked).orElse(false)).isTrue();
softwareModule = softwareModuleManagement.unlock(softwareModule);
assertThat(softwareModuleManagement.get(softwareModule.getId()).map(SoftwareModule::isLocked).orElse(true)).isFalse();
assertThat(softwareModuleManagement.find(softwareModule.getId()).map(SoftwareModule::isLocked).orElse(true)).isFalse();
}
/**
@@ -664,10 +664,10 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
final Long softwareModuleId = softwareModule.getId();
artifactManagement.create(new ArtifactUpload(new ByteArrayInputStream(new byte[] { 1 }), softwareModuleId, "artifact1", false, 1));
// update software module reference since it is modified, old reference is stale
final int artifactCount = (softwareModule = softwareModuleManagement.get(softwareModuleId).orElseThrow()).getArtifacts().size();
final int artifactCount = (softwareModule = softwareModuleManagement.find(softwareModuleId).orElseThrow()).getArtifacts().size();
assertThat(artifactCount).isNotZero();
softwareModuleManagement.lock(softwareModule);
assertThat(softwareModuleManagement.get(softwareModuleId).map(SoftwareModule::isLocked).orElse(false)).isTrue();
assertThat(softwareModuleManagement.find(softwareModuleId).map(SoftwareModule::isLocked).orElse(false)).isTrue();
// try add
final ArtifactUpload artifactUpload = new ArtifactUpload(new ByteArrayInputStream(new byte[] { 2 }), softwareModuleId, "artifact2",
@@ -675,21 +675,18 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
assertThatExceptionOfType(LockedException.class)
.as("Attempt to modify a locked SM artifacts should throw an exception")
.isThrownBy(() -> artifactManagement.create(artifactUpload));
assertThat(softwareModuleManagement.get(softwareModuleId).get().getArtifacts())
assertThat(softwareModuleManagement.find(softwareModuleId).get().getArtifacts())
.as("Artifacts shall not be added to a locked SM.")
.hasSize(artifactCount);
// try remove
final long artifactId = softwareModuleManagement.get(softwareModuleId).get().getArtifacts().stream().findFirst().get().getId();
final long artifactId = softwareModuleManagement.find(softwareModuleId).get().getArtifacts().stream().findFirst().get().getId();
assertThatExceptionOfType(LockedException.class)
.as("Attempt to modify a locked SM artifacts should throw an exception")
.isThrownBy(() -> artifactManagement.delete(artifactId));
assertThat(softwareModuleManagement.get(softwareModuleId).get().getArtifacts())
assertThat(softwareModuleManagement.find(softwareModuleId).get().getArtifacts())
.as("Artifact shall not be removed from a locked SM.")
.hasSize(artifactCount);
assertThat(artifactManagement.get(artifactId))
.as("Artifact shall not be removed if belongs to a locked SM.")
.isPresent();
}
/**
@@ -705,7 +702,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
softwareModuleManagement.delete(modules.get(0).getId());
distributionSetManagement.lock(distributionSet);
assertThat(distributionSetManagement.get(distributionSet.getId()).map(DistributionSet::isLocked).orElse(false)).isTrue();
assertThat(distributionSetManagement.find(distributionSet.getId()).map(DistributionSet::isLocked).orElse(false)).isTrue();
// try to delete SM of a locked DS
final Long moduleId = modules.get(1).getId();
@@ -749,7 +746,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
}
// Verify correct Creation of SoftwareModule and corresponding artifacts
softwareModule = softwareModuleManagement.get(softwareModule.getId()).get();
softwareModule = softwareModuleManagement.find(softwareModule.getId()).get();
assertThat(softwareModuleRepository.findAll()).hasSize((int) countSoftwareModule + 1);
final List<Artifact> artifacts = softwareModule.getArtifacts();
@@ -767,15 +764,17 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
assertThat(artifactRepository.findAll()).hasSize(results.length);
for (final Artifact result : results) {
assertThat(result.getId()).isNotNull();
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
assertThat(binaryArtifactRepository.getBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
.isNotNull();
}
}
private void assertArtifactNull(final Artifact... results) {
private void assertArtifactDoesntExist(final Artifact... results) {
for (final Artifact result : results) {
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
.isNull();
final String currentTenant = tenantAware.getCurrentTenant();
final String sha1Hash = result.getSha1Hash();
assertThatExceptionOfType(ArtifactBinaryNotFoundException.class)
.isThrownBy(() -> binaryArtifactRepository.getBySha1(currentTenant, sha1Hash));
}
}
}

View File

@@ -27,17 +27,17 @@ class SoftwareModuleTypeManagementSecurityTest
extends AbstractRepositoryManagementSecurityTest<SoftwareModuleType, SoftwareModuleTypeManagement.Create, SoftwareModuleTypeManagement.Update> {
@Override
protected RepositoryManagement getRepositoryManagement() {
protected RepositoryManagement findRepositoryManagement() {
return softwareModuleTypeManagement;
}
@Override
protected SoftwareModuleTypeManagement.Create getCreateObject() {
protected SoftwareModuleTypeManagement.Create findCreateObject() {
return SoftwareModuleTypeManagement.Create.builder().key(String.format("key-%d", new Random().nextInt())).name(String.format("name-%d", new Random().nextInt())).build();
}
@Override
protected SoftwareModuleTypeManagement.Update getUpdateObject() {
protected SoftwareModuleTypeManagement.Update findUpdateObject() {
return SoftwareModuleTypeManagement.Update.builder().id(1L).description("description").build();
}

View File

@@ -44,7 +44,7 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest {
@ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class) })
void nonExistingEntityAccessReturnsNotPresent() {
assertThat(softwareModuleTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(softwareModuleTypeManagement.find(NOT_EXIST_IDL)).isNotPresent();
assertThat(softwareModuleTypeManagement.findByKey(NOT_EXIST_ID)).isNotPresent();
assertThat(softwareModuleTypeManagement.findByName(NOT_EXIST_ID)).isNotPresent();
}

View File

@@ -107,7 +107,7 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest
*/
@Test
void getTargetFilterQueryByIdPermissionsCheck() {
assertPermissions(() -> targetFilterQueryManagement.get(1L), List.of(SpPermission.READ_TARGET));
assertPermissions(() -> targetFilterQueryManagement.find(1L), List.of(SpPermission.READ_TARGET));
}
/**

View File

@@ -69,7 +69,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void nonExistingEntityAccessReturnsNotPresent() {
assertThat(targetFilterQueryManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(targetFilterQueryManagement.find(NOT_EXIST_IDL)).isNotPresent();
}
/**
@@ -117,7 +117,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
final String filterName = "new target filter";
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
.create(Create.builder().name(filterName).query("name==PendingTargets001").build());
assertEquals(targetFilterQuery, targetFilterQueryManagement.get(targetFilterQuery.getId()).get(),
assertEquals(targetFilterQuery, targetFilterQueryManagement.find(targetFilterQuery.getId()).get(),
"Retrieved newly created custom target filter");
}
@@ -191,7 +191,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
Create.builder().name(filterName).query("name==PendingTargets001").build());
targetFilterQueryManagement.delete(targetFilterQuery.getId());
assertFalse(
targetFilterQueryManagement.get(targetFilterQuery.getId()).isPresent(),
targetFilterQueryManagement.find(targetFilterQuery.getId()).isPresent(),
"Returns null as the target filter is deleted");
}
@@ -206,7 +206,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
final String newQuery = "name==PendingTargets002";
targetFilterQueryManagement.update(Update.builder().id(targetFilterQuery.getId()).query(newQuery).build());
assertEquals(newQuery, targetFilterQueryManagement.get(targetFilterQuery.getId()).get().getQuery(),
assertEquals(newQuery, targetFilterQueryManagement.find(targetFilterQuery.getId()).get().getQuery(),
"Returns updated target filter query");
}
@@ -286,14 +286,14 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
implicitLock(distributionSet);
// Check if target filter query is there
TargetFilterQuery tfq = targetFilterQueryManagement.get(targetFilterQuery.getId()).get();
TargetFilterQuery tfq = targetFilterQueryManagement.find(targetFilterQuery.getId()).get();
assertEquals(distributionSet, tfq.getAutoAssignDistributionSet(), "Returns correct distribution set");
assertEquals(ActionType.FORCED, tfq.getAutoAssignActionType(), "Return correct action type");
distributionSetManagement.delete(distributionSet.getId());
// Check if auto assign distribution set is null
tfq = targetFilterQueryManagement.get(targetFilterQuery.getId()).get();
tfq = targetFilterQueryManagement.find(targetFilterQuery.getId()).get();
assertNotNull(tfq, "Returns target filter query");
assertNull(tfq.getAutoAssignDistributionSet(), "Returns distribution set as null");
assertNull(tfq.getAutoAssignActionType(), "Returns action type as null");
@@ -319,17 +319,17 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
implicitLock(distributionSet);
// Check if target filter query is there with the distribution set
TargetFilterQuery tfq = targetFilterQueryManagement.get(filterId).get();
TargetFilterQuery tfq = targetFilterQueryManagement.find(filterId).get();
assertEquals(distributionSet, tfq.getAutoAssignDistributionSet(), "Returns correct distribution set");
assertEquals(ActionType.FORCED, tfq.getAutoAssignActionType(), "Return correct action type");
distributionSetManagement.delete(distributionSet.getId());
// Check if distribution set is still in the database with deleted flag
assertTrue(distributionSetManagement.get(distributionSet.getId()).get().isDeleted(), "Distribution set should be deleted");
assertTrue(distributionSetManagement.find(distributionSet.getId()).get().isDeleted(), "Distribution set should be deleted");
// Check if auto assign distribution set is null
tfq = targetFilterQueryManagement.get(filterId).get();
tfq = targetFilterQueryManagement.find(filterId).get();
assertNotNull(tfq, "Returns target filter query");
assertNull(tfq.getAutoAssignDistributionSet(), "Returns distribution set as null");
assertNull(tfq.getAutoAssignActionType(), "Returns action type as null");
@@ -431,7 +431,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
final Long filterId = targetFilterQueryManagement.create(Create.builder().name("a")
.query("name==*").autoAssignDistributionSet(ds).autoAssignWeight(Action.WEIGHT_MAX).build()).getId();
assertThat(targetFilterQueryManagement.get(filterId).get().getAutoAssignWeight()).contains(Action.WEIGHT_MAX);
assertThat(targetFilterQueryManagement.find(filterId).get().getAutoAssignWeight()).contains(Action.WEIGHT_MAX);
final AutoAssignDistributionSetUpdate autoAssignDistributionSetUpdate = new AutoAssignDistributionSetUpdate(filterId)
.ds(ds.getId()).weight(Action.WEIGHT_MAX + 1);
@@ -445,7 +445,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
new AutoAssignDistributionSetUpdate(filterId).ds(ds.getId()).weight(Action.WEIGHT_MAX));
targetFilterQueryManagement.updateAutoAssignDS(
new AutoAssignDistributionSetUpdate(filterId).ds(ds.getId()).weight(Action.WEIGHT_MIN));
assertThat(targetFilterQueryManagement.get(filterId).get().getAutoAssignWeight()).contains(Action.WEIGHT_MIN);
assertThat(targetFilterQueryManagement.find(filterId).get().getAutoAssignWeight()).contains(Action.WEIGHT_MIN);
}
/**
@@ -531,7 +531,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
if (actionType == ActionType.TIMEFORCED) {
assertThatExceptionOfType(AbstractServerRtException.class).isThrownBy(create::get);
} else {
assertThat(targetFilterQueryManagement.get(create.get()).orElseThrow().getAutoAssignActionType()).isEqualTo(actionType);
assertThat(targetFilterQueryManagement.find(create.get()).orElseThrow().getAutoAssignActionType()).isEqualTo(actionType);
}
}
@@ -626,7 +626,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
}
private void verifyAutoAssignDsAndActionType(final Long filterId, final DistributionSet distributionSet, final ActionType actionType) {
final TargetFilterQuery tfq = targetFilterQueryManagement.get(filterId).get();
final TargetFilterQuery tfq = targetFilterQueryManagement.find(filterId).get();
assertEquals(distributionSet, tfq.getAutoAssignDistributionSet(), "Returns correct distribution set");
assertEquals(actionType, tfq.getAutoAssignActionType(), "Return correct action type");

View File

@@ -322,7 +322,7 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
*/
@Test
void getPermissionsCheck() {
assertPermissions(() -> targetManagement.get(1L), List.of(SpPermission.READ_TARGET));
assertPermissions(() -> targetManagement.find(1L), List.of(SpPermission.READ_TARGET));
}
/**

View File

@@ -108,7 +108,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
void nonExistingEntityAccessReturnsNotPresent() {
final Target target = testdataFactory.createTarget();
assertThat(targetManagement.getByControllerId(NOT_EXIST_ID)).isNotPresent();
assertThat(targetManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(targetManagement.find(NOT_EXIST_IDL)).isNotPresent();
assertThat(targetManagement.getMetadata(target.getControllerId()).get(NOT_EXIST_ID)).isNull();
}
@@ -252,14 +252,14 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
assertThat(assignedTargets).as("Assigned targets are wrong").hasSize(4);
assignedTargets.forEach(target -> assertThat(getTargetTags(target.getControllerId())).hasSize(1));
final TargetTag findTargetTag = targetTagManagement.get(targetTag.getId()).orElseThrow(IllegalStateException::new);
final TargetTag findTargetTag = targetTagManagement.find(targetTag.getId()).orElseThrow(IllegalStateException::new);
assertThat(assignedTargets).as("Assigned targets are wrong")
.hasSize(targetManagement.findByTag(targetTag.getId(), PAGE).getNumberOfElements());
final Target unAssignTarget = targetManagement.unassignTag(List.of("targetId123"), findTargetTag.getId()).get(0);
assertThat(unAssignTarget.getControllerId()).as("Controller id is wrong").isEqualTo("targetId123");
assertThat(getTargetTags(unAssignTarget.getControllerId())).as("Tag size is wrong").isEmpty();
targetTagManagement.get(targetTag.getId()).orElseThrow(NoSuchElementException::new);
targetTagManagement.find(targetTag.getId()).orElseThrow(NoSuchElementException::new);
assertThat(targetManagement.findByTag(targetTag.getId(), PAGE)).as("Assigned targets are wrong").hasSize(3);
assertThat(targetManagement.findByRsqlAndTag("controllerId==targetId123", targetTag.getId(), PAGE))
.as("Assigned targets are wrong").isEmpty();
@@ -812,13 +812,13 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
// create target meta data entry
insertMetadata(knownKey, knownValue, target);
final Target changedLockRevisionTarget = targetManagement.get(target.getId()).orElseThrow(NoSuchElementException::new);
final Target changedLockRevisionTarget = targetManagement.find(target.getId()).orElseThrow(NoSuchElementException::new);
assertThat(changedLockRevisionTarget.getOptLockRevision()).isEqualTo(2);
// update the target metadata
targetManagement.createMetadata(target.getControllerId(), knownKey, knownUpdateValue);
// we are updating the target meta-data so also modifying the target so opt lock revision must be three
final Target changedLockRevisionTarget2 = targetManagement.get(target.getId()).orElseThrow(NoSuchElementException::new);
final Target changedLockRevisionTarget2 = targetManagement.find(target.getId()).orElseThrow(NoSuchElementException::new);
assertThat(changedLockRevisionTarget2.getOptLockRevision()).isEqualTo(3);
assertThat(changedLockRevisionTarget2.getLastModifiedAt()).isPositive();

View File

@@ -84,7 +84,7 @@ class TargetTagManagementSecurityTest extends AbstractJpaIntegrationTest {
*/
@Test
void getPermissionsCheck() {
assertPermissions(() -> targetTagManagement.get(1L), List.of(SpPermission.READ_TARGET));
assertPermissions(() -> targetTagManagement.find(1L), List.of(SpPermission.READ_TARGET));
}
/**

View File

@@ -91,7 +91,7 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
@Test
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void nonExistingEntityAccessReturnsNotPresent() {
assertThat(targetTagManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(targetTagManagement.find(NOT_EXIST_IDL)).isNotPresent();
}
/**
@@ -175,7 +175,7 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
@Test
void createTargetTag() {
final Tag tag = targetTagManagement.create(Create.builder().name("k1").description("k2").colour("colour").build());
assertThat(targetTagManagement.get(tag.getId()).orElseThrow().getColour()).as("wrong tag found").isEqualTo("colour");
assertThat(targetTagManagement.find(tag.getId()).orElseThrow().getColour()).as("wrong tag found").isEqualTo("colour");
}
/**

View File

@@ -13,7 +13,6 @@ import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.hawkbit.im.authentication.SpPermission;
import org.eclipse.hawkbit.repository.TargetTypeManagement;
import org.eclipse.hawkbit.repository.TargetTypeManagement.Create;
import org.eclipse.hawkbit.repository.TargetTypeManagement.Update;
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
@@ -101,7 +100,7 @@ class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest {
*/
@Test
void getPermissionsCheck() {
assertPermissions(() -> targetTypeManagement.get(1L), List.of(SpPermission.READ_TARGET));
assertPermissions(() -> targetTypeManagement.find(1L), List.of(SpPermission.READ_TARGET));
}
/**

View File

@@ -46,7 +46,7 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
@Test
@ExpectEvents({ @Expect(type = TargetTypeCreatedEvent.class) })
void nonExistingEntityAccessReturnsNotPresent() {
assertThat(targetTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
assertThat(targetTypeManagement.find(NOT_EXIST_IDL)).isNotPresent();
assertThat(targetTypeManagement.getByName(NOT_EXIST_ID)).isNotPresent();
}

View File

@@ -36,7 +36,7 @@ class RsqlRolloutFieldTest extends AbstractJpaIntegrationTest {
testdataFactory.createTargets(20, "rollout", "rollout");
final DistributionSet dsA = testdataFactory.createDistributionSet("");
rollout = createRollout("rollout1", 4, dsA.getId(), "controllerId==rollout*");
rollout = rolloutManagement.get(rollout.getId()).get();
rollout = rolloutManagement.find(rollout.getId()).get();
}
/**
@@ -60,7 +60,7 @@ class RsqlRolloutFieldTest extends AbstractJpaIntegrationTest {
private Rollout createRollout(final String name, final int amountGroups, final long distributionSetId, final String targetFilterQuery) {
return rolloutManagement.create(
Create.builder()
.distributionSet(distributionSetManagement.get(distributionSetId).get()).name(name).targetFilterQuery(targetFilterQuery)
.distributionSet(distributionSetManagement.find(distributionSetId).get()).name(name).targetFilterQuery(targetFilterQuery)
.build(),
amountGroups,
false,

View File

@@ -40,7 +40,7 @@ class RsqlRolloutGroupFieldTest extends AbstractJpaIntegrationTest {
testdataFactory.createTargets(amountTargets, "rollout", "rollout");
final DistributionSet dsA = testdataFactory.createDistributionSet("");
rollout = createRollout("rollout1", 4, dsA.getId(), "controllerId==rollout*");
rollout = rolloutManagement.get(rollout.getId()).get();
rollout = rolloutManagement.find(rollout.getId()).get();
this.rolloutGroupId = rolloutGroupManagement.findByRollout(rollout.getId(), PAGE).getContent().get(0).getId();
}
@@ -102,7 +102,7 @@ class RsqlRolloutGroupFieldTest extends AbstractJpaIntegrationTest {
final String targetFilterQuery) {
return rolloutManagement.create(
Create.builder()
.distributionSet(distributionSetManagement.get(distributionSetId).get()).name(name).targetFilterQuery(targetFilterQuery)
.distributionSet(distributionSetManagement.find(distributionSetId).get()).name(name).targetFilterQuery(targetFilterQuery)
.build(),
amountGroups, false, new RolloutGroupConditionBuilder().withDefaults()
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "100").build());