Refactoring of RepostioryManagement and extending classes (#2174)
* createMetaData renamed to putMetaData * getXXX methods returing Optional are renamed to findXXX * unified method order (code cosmetics) Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -14,7 +14,6 @@ import java.util.List;
|
||||
import io.qameta.allure.Description;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
import org.eclipse.hawkbit.repository.RepositoryManagement;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
@@ -105,7 +104,7 @@ public abstract class AbstractRepositoryManagementSecurityTest<T, C, U> extends
|
||||
@Test
|
||||
@Description("Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.")
|
||||
public void findByRsqlPermissionCheck() {
|
||||
assertPermissions(() -> getRepositoryManagement().findByRsql(Pageable.ofSize(1), "(name==*)"), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> getRepositoryManagement().findByRsql("(name==*)", Pageable.ofSize(1)), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
.containsOnly(permitted.getId());
|
||||
|
||||
// verify distributionSetManagement#findByRsql
|
||||
assertThat(distributionSetManagement.findByRsql(Pageable.unpaged(), "name==*").get().map(Identifiable::getId)
|
||||
assertThat(distributionSetManagement.findByRsql("name==*", Pageable.unpaged()).get().map(Identifiable::getId)
|
||||
.toList()).containsOnly(permitted.getId());
|
||||
|
||||
// verify distributionSetManagement#findByCompleted
|
||||
@@ -82,8 +82,8 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
|
||||
// verify distributionSetManagement#findByDistributionSetFilter
|
||||
assertThat(distributionSetManagement
|
||||
.findByDistributionSetFilter(Pageable.unpaged(),
|
||||
DistributionSetFilter.builder().isDeleted(false).build())
|
||||
.findByDistributionSetFilter(DistributionSetFilter.builder().isDeleted(false).build(), Pageable.unpaged()
|
||||
)
|
||||
.get().map(Identifiable::getId).toList()).containsOnly(permitted.getId());
|
||||
|
||||
// verify distributionSetManagement#get
|
||||
@@ -106,14 +106,14 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
}).as("Fail if request hidden.").isInstanceOf(EntityNotFoundException.class);
|
||||
|
||||
// verify distributionSetManagement#getByNameAndVersion
|
||||
assertThat(distributionSetManagement.getByNameAndVersion(permitted.getName(), permitted.getVersion()))
|
||||
assertThat(distributionSetManagement.findByNameAndVersion(permitted.getName(), permitted.getVersion()))
|
||||
.isPresent();
|
||||
assertThat(distributionSetManagement.getByNameAndVersion(hidden.getName(), hidden.getVersion())).isEmpty();
|
||||
assertThat(distributionSetManagement.findByNameAndVersion(hidden.getName(), hidden.getVersion())).isEmpty();
|
||||
|
||||
// verify distributionSetManagement#getByAction
|
||||
assertThat(distributionSetManagement.getByAction(permittedAction.getId())).isPresent();
|
||||
assertThat(distributionSetManagement.findByAction(permittedAction.getId())).isPresent();
|
||||
assertThatThrownBy(() -> {
|
||||
distributionSetManagement.getByAction(hiddenAction.getId());
|
||||
distributionSetManagement.findByAction(hiddenAction.getId());
|
||||
}).as("Action is hidden.").isInstanceOf(InsufficientPermissionException.class);
|
||||
}
|
||||
|
||||
@@ -152,11 +152,11 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
final JpaDistributionSetMetadata metadata = new JpaDistributionSetMetadata("test", "test");
|
||||
|
||||
// verify distributionSetManagement#createMetaData
|
||||
distributionSetManagement.createMetaData(permitted.getId(), Collections.singletonList(metadata));
|
||||
assertThatThrownBy(() -> distributionSetManagement.createMetaData(readOnly.getId(), Collections.singletonList(metadata)))
|
||||
distributionSetManagement.putMetaData(permitted.getId(), Collections.singletonList(metadata));
|
||||
assertThatThrownBy(() -> distributionSetManagement.putMetaData(readOnly.getId(), Collections.singletonList(metadata)))
|
||||
.as("Distribution set not allowed to me modified.")
|
||||
.isInstanceOf(EntityNotFoundException.class);
|
||||
assertThatThrownBy(() -> distributionSetManagement.createMetaData(hidden.getId(), Collections.singletonList(metadata)))
|
||||
assertThatThrownBy(() -> distributionSetManagement.putMetaData(hidden.getId(), Collections.singletonList(metadata)))
|
||||
.as("Distribution set should not be visible.")
|
||||
.isInstanceOf(EntityNotFoundException.class);
|
||||
|
||||
@@ -204,10 +204,10 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest {
|
||||
// allow updating the permitted distributionSet
|
||||
defineAccess(AccessController.Operation.UPDATE, permitted);
|
||||
|
||||
assertThat(distributionSetManagement.findByTag(Pageable.unpaged(), dsTag.getId()).get().map(Identifiable::getId)
|
||||
assertThat(distributionSetManagement.findByTag(dsTag.getId(), Pageable.unpaged()).get().map(Identifiable::getId)
|
||||
.toList()).containsOnly(permitted.getId(), readOnly.getId());
|
||||
|
||||
assertThat(distributionSetManagement.findByRsqlAndTag(Pageable.unpaged(), "name==*", dsTag.getId()).get()
|
||||
assertThat(distributionSetManagement.findByRsqlAndTag("name==*", dsTag.getId(), Pageable.unpaged()).get()
|
||||
.map(Identifiable::getId).toList()).containsOnly(permitted.getId(), readOnly.getId());
|
||||
|
||||
// verify distributionSetManagement#unassignTag on permitted target
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
package org.eclipse.hawkbit.repository.jpa.management;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
@@ -69,7 +68,7 @@ class DistributionSetManagementSecurityTest
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void createMetaDataPermissionsCheck() {
|
||||
assertPermissions(
|
||||
() -> distributionSetManagement.createMetaData(1L, List.of(entityFactory.generateTargetMetadata("key", "value"))),
|
||||
() -> distributionSetManagement.putMetaData(1L, List.of(entityFactory.generateTargetMetadata("key", "value"))),
|
||||
List.of(SpPermission.UPDATE_REPOSITORY));
|
||||
}
|
||||
|
||||
@@ -103,7 +102,7 @@ class DistributionSetManagementSecurityTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void getByActionPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.getByAction(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> distributionSetManagement.findByAction(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -115,7 +114,7 @@ class DistributionSetManagementSecurityTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void getByNameAndVersionPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.getByNameAndVersion("name", "version"), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> distributionSetManagement.findByNameAndVersion("name", "version"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -139,7 +138,7 @@ class DistributionSetManagementSecurityTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findMetaDataByDistributionSetIdPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.findMetaDataByDistributionSetId(PAGE, 1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> distributionSetManagement.findMetaDataByDistributionSetId(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -151,7 +150,7 @@ class DistributionSetManagementSecurityTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findMetaDataByDistributionSetIdAndRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(PAGE, 1L, "rsql"),
|
||||
assertPermissions(() -> distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(1L, "rsql", PAGE),
|
||||
List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@@ -170,7 +169,7 @@ class DistributionSetManagementSecurityTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByDistributionSetFilterPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.findByDistributionSetFilter(PAGE, DistributionSetFilter.builder().build()),
|
||||
assertPermissions(() -> distributionSetManagement.findByDistributionSetFilter(DistributionSetFilter.builder().build(), PAGE),
|
||||
List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@@ -184,19 +183,19 @@ class DistributionSetManagementSecurityTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByTagPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.findByTag(PAGE, 1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> distributionSetManagement.findByTag(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByRsqlAndTagPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.findByRsqlAndTag(PAGE, "rsql", 1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> distributionSetManagement.findByRsqlAndTag("rsql", 1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void getMetaDataByDistributionSetIdPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetManagement.getMetaDataByDistributionSetId(1L, "key"), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> distributionSetManagement.findMetaDataByDistributionSetId(1L, "key"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -96,8 +96,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet set = testdataFactory.createDistributionSet();
|
||||
assertThat(distributionSetManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetManagement.getWithDetails(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetManagement.getByNameAndVersion(NOT_EXIST_ID, NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetManagement.getMetaDataByDistributionSetId(set.getId(), NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetManagement.findByNameAndVersion(NOT_EXIST_ID, NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetManagement.findMetaDataByDistributionSetId(set.getId(), NOT_EXIST_ID)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -125,8 +125,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.assignTag(singletonList(set.getId()), NOT_EXIST_IDL), "DistributionSetTag");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.assignTag(singletonList(NOT_EXIST_IDL), dsTag.getId()), "DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findByTag(PAGE, NOT_EXIST_IDL), "DistributionSetTag");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findByRsqlAndTag(PAGE, "name==*", NOT_EXIST_IDL), "DistributionSetTag");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findByTag(NOT_EXIST_IDL, PAGE), "DistributionSetTag");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findByRsqlAndTag("name==*", NOT_EXIST_IDL, PAGE), "DistributionSetTag");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.assignTag(singletonList(NOT_EXIST_IDL), dsTag.getId()), "DistributionSet");
|
||||
verifyThrownExceptionBy(() ->
|
||||
@@ -139,7 +139,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.create(
|
||||
entityFactory.distributionSet().create().name("xxx").type(NOT_EXIST_ID)), "DistributionSetType");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.createMetaData(
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.putMetaData(
|
||||
NOT_EXIST_IDL, singletonList(entityFactory.generateDsMetadata("123", "123"))), "DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.delete(singletonList(NOT_EXIST_IDL)), "DistributionSet");
|
||||
@@ -149,16 +149,16 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.deleteMetaData(set.getId(), NOT_EXIST_ID),
|
||||
"DistributionSetMetadata");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.getByAction(NOT_EXIST_IDL), "Action");
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findByAction(NOT_EXIST_IDL), "Action");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.getMetaDataByDistributionSetId(NOT_EXIST_IDL, "xxx"),
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findMetaDataByDistributionSetId(NOT_EXIST_IDL, "xxx"),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findMetaDataByDistributionSetId(PAGE, NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> distributionSetManagement.findMetaDataByDistributionSetId(NOT_EXIST_IDL, PAGE),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
() -> distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(NOT_EXIST_IDL, "name==*", PAGE),
|
||||
"DistributionSet");
|
||||
|
||||
assertThatThrownBy(() -> distributionSetManagement.isInUse(NOT_EXIST_IDL))
|
||||
@@ -325,22 +325,22 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
.as("ds has wrong tag size")
|
||||
.isEqualTo(1));
|
||||
|
||||
final DistributionSetTag findDistributionSetTag = getOrThrow(distributionSetTagManagement.getByName(TAG1_NAME));
|
||||
final DistributionSetTag findDistributionSetTag = getOrThrow(distributionSetTagManagement.findByName(TAG1_NAME));
|
||||
|
||||
assertThat(assignedDS.size()).as("assigned ds has wrong size")
|
||||
.isEqualTo(distributionSetManagement.findByTag(PAGE, tag.getId()).getNumberOfElements());
|
||||
.isEqualTo(distributionSetManagement.findByTag(tag.getId(), PAGE).getNumberOfElements());
|
||||
|
||||
final JpaDistributionSet unAssignDS = (JpaDistributionSet) distributionSetManagement
|
||||
.unassignTag(assignDS.get(0), findDistributionSetTag.getId());
|
||||
assertThat(unAssignDS.getId()).as("unassigned ds is wrong").isEqualTo(assignDS.get(0));
|
||||
assertThat(unAssignDS.getTags().size()).as("unassigned ds has wrong tag size").isZero();
|
||||
assertThat(distributionSetTagManagement.getByName(TAG1_NAME)).isPresent();
|
||||
assertThat(distributionSetManagement.findByTag(PAGE, tag.getId()).getNumberOfElements())
|
||||
assertThat(distributionSetTagManagement.findByName(TAG1_NAME)).isPresent();
|
||||
assertThat(distributionSetManagement.findByTag(tag.getId(), PAGE).getNumberOfElements())
|
||||
.as("ds tag ds has wrong ds size").isEqualTo(3);
|
||||
|
||||
assertThat(distributionSetManagement.findByRsqlAndTag(PAGE, "name==" + unAssignDS.getName(), tag.getId())
|
||||
assertThat(distributionSetManagement.findByRsqlAndTag("name==" + unAssignDS.getName(), tag.getId(), PAGE)
|
||||
.getNumberOfElements()).as("ds tag ds has wrong ds size").isZero();
|
||||
assertThat(distributionSetManagement.findByRsqlAndTag(PAGE, "name!=" + unAssignDS.getName(), tag.getId())
|
||||
assertThat(distributionSetManagement.findByRsqlAndTag("name!=" + unAssignDS.getName(), tag.getId(), PAGE)
|
||||
.getNumberOfElements()).as("ds tag ds has wrong ds size").isEqualTo(3);
|
||||
}
|
||||
|
||||
@@ -791,10 +791,10 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
final Page<DistributionSetMetadata> metadataOfDs1 = distributionSetManagement
|
||||
.findMetaDataByDistributionSetId(PageRequest.of(0, 100), ds1.getId());
|
||||
.findMetaDataByDistributionSetId(ds1.getId(), PageRequest.of(0, 100));
|
||||
|
||||
final Page<DistributionSetMetadata> metadataOfDs2 = distributionSetManagement
|
||||
.findMetaDataByDistributionSetId(PageRequest.of(0, 100), ds2.getId());
|
||||
.findMetaDataByDistributionSetId(ds2.getId(), PageRequest.of(0, 100));
|
||||
|
||||
assertThat(metadataOfDs1.getNumberOfElements())
|
||||
.isEqualTo(quotaManagement.getMaxMetaDataEntriesPerDistributionSet());
|
||||
@@ -831,7 +831,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
||||
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(2);
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).hasSize(2);
|
||||
assertThat(distributionSetManagement.findByRsql(PAGE, "name==*")).hasSize(2);
|
||||
assertThat(distributionSetManagement.findByRsql("name==*", PAGE)).hasSize(2);
|
||||
assertThat(distributionSetManagement.count()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@@ -889,7 +889,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
final String knownUpdateValue = "knownUpdateValue";
|
||||
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet();
|
||||
distributionSetManagement.createMetaData(ds.getId(),
|
||||
distributionSetManagement.putMetaData(ds.getId(),
|
||||
singletonList(entityFactory.generateDsMetadata(knownKey1, knownValue)));
|
||||
|
||||
distributionSetInvalidationManagement.invalidateDistributionSet(
|
||||
@@ -898,7 +898,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
// assert that no new metadata can be created
|
||||
assertThatExceptionOfType(InvalidDistributionSetException.class)
|
||||
.as("Invalid distributionSet should throw an exception")
|
||||
.isThrownBy(() -> distributionSetManagement.createMetaData(ds.getId(),
|
||||
.isThrownBy(() -> distributionSetManagement.putMetaData(ds.getId(),
|
||||
singletonList(entityFactory.generateDsMetadata(knownKey2, knownValue))));
|
||||
|
||||
// assert that an existing metadata can not be updated
|
||||
@@ -1251,18 +1251,18 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void assertThatFilterContainsOnlyGivenDistributionSets(final DistributionSetFilterBuilder filterBuilder,
|
||||
final List<DistributionSet> distributionSets) {
|
||||
final int expectedDsSize = distributionSets.size();
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, filterBuilder.build()).getContent())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(filterBuilder.build(), PAGE).getContent())
|
||||
.hasSize(expectedDsSize).containsOnly(distributionSets.toArray(new DistributionSet[expectedDsSize]));
|
||||
}
|
||||
|
||||
private void assertThatFilterDoesNotContainAnyDistributionSet(final DistributionSetFilterBuilder filterBuilder) {
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, filterBuilder.build()).getContent())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(filterBuilder.build(), PAGE).getContent())
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
private void assertThatFilterHasSizeAndDoesNotContainDistributionSet(
|
||||
final DistributionSetFilterBuilder filterBuilder, final int size, final DistributionSet ds) {
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, filterBuilder.build()).getContent())
|
||||
assertThat(distributionSetManagement.findByDistributionSetFilter(filterBuilder.build(), PAGE).getContent())
|
||||
.hasSize(size).doesNotContain(ds);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class DistributionSetTagManagementSecurityTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void getByNameWitPermissionWorks() {
|
||||
assertPermissions(() -> distributionSetTagManagement.getByName("tagName"), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> distributionSetTagManagement.findByName("tagName"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -56,7 +56,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Verifies that management get access reacts as specified on calls for non existing entities by means of Optional not present.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||
void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(distributionSetTagManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetTagManagement.findByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetTagManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
}
|
||||
|
||||
@@ -95,18 +95,18 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assignTag(dsBs, tagB);
|
||||
assignTag(dsCs, tagC);
|
||||
|
||||
assignTag(dsABs, distributionSetTagManagement.getByName(tagA.getName()).get());
|
||||
assignTag(dsABs, distributionSetTagManagement.getByName(tagB.getName()).get());
|
||||
assignTag(dsABs, distributionSetTagManagement.findByName(tagA.getName()).get());
|
||||
assignTag(dsABs, distributionSetTagManagement.findByName(tagB.getName()).get());
|
||||
|
||||
assignTag(dsACs, distributionSetTagManagement.getByName(tagA.getName()).get());
|
||||
assignTag(dsACs, distributionSetTagManagement.getByName(tagC.getName()).get());
|
||||
assignTag(dsACs, distributionSetTagManagement.findByName(tagA.getName()).get());
|
||||
assignTag(dsACs, distributionSetTagManagement.findByName(tagC.getName()).get());
|
||||
|
||||
assignTag(dsBCs, distributionSetTagManagement.getByName(tagB.getName()).get());
|
||||
assignTag(dsBCs, distributionSetTagManagement.getByName(tagC.getName()).get());
|
||||
assignTag(dsBCs, distributionSetTagManagement.findByName(tagB.getName()).get());
|
||||
assignTag(dsBCs, distributionSetTagManagement.findByName(tagC.getName()).get());
|
||||
|
||||
assignTag(dsABCs, distributionSetTagManagement.getByName(tagA.getName()).get());
|
||||
assignTag(dsABCs, distributionSetTagManagement.getByName(tagB.getName()).get());
|
||||
assignTag(dsABCs, distributionSetTagManagement.getByName(tagC.getName()).get());
|
||||
assignTag(dsABCs, distributionSetTagManagement.findByName(tagA.getName()).get());
|
||||
assignTag(dsABCs, distributionSetTagManagement.findByName(tagB.getName()).get());
|
||||
assignTag(dsABCs, distributionSetTagManagement.findByName(tagC.getName()).get());
|
||||
|
||||
// search for not deleted
|
||||
final DistributionSetFilter.DistributionSetFilterBuilder distributionSetFilterBuilder = getDistributionSetFilterBuilder()
|
||||
@@ -150,7 +150,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(result).size().isEqualTo(20);
|
||||
assertThat(result).containsAll(distributionSetManagement.get(groupA.stream().map(DistributionSet::getId).toList()));
|
||||
assertThat(
|
||||
distributionSetManagement.findByTag(Pageable.unpaged(), tag.getId()).getContent().stream()
|
||||
distributionSetManagement.findByTag(tag.getId(), Pageable.unpaged()).getContent().stream()
|
||||
.map(DistributionSet::getId)
|
||||
.sorted()
|
||||
.toList())
|
||||
@@ -163,7 +163,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(result).containsAll(distributionSetManagement
|
||||
.get(groupAB.stream().map(DistributionSet::getId).toList()));
|
||||
assertThat(
|
||||
distributionSetManagement.findByTag(Pageable.unpaged(), tag.getId()).getContent().stream().map(DistributionSet::getId).sorted()
|
||||
distributionSetManagement.findByTag(tag.getId(), Pageable.unpaged()).getContent().stream().map(DistributionSet::getId).sorted()
|
||||
.toList())
|
||||
.isEqualTo(groupAB.stream().map(DistributionSet::getId).sorted().toList());
|
||||
|
||||
@@ -171,7 +171,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
result = unassignTag(concat(groupA, groupB), tag);
|
||||
assertThat(result).size().isEqualTo(40);
|
||||
assertThat(result).containsAll(distributionSetManagement.get(concat(groupB, groupA).stream().map(DistributionSet::getId).toList()));
|
||||
assertThat(distributionSetManagement.findByTag(Pageable.unpaged(), tag.getId()).getContent()).isEmpty();
|
||||
assertThat(distributionSetManagement.findByTag(tag.getId(), Pageable.unpaged()).getContent()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -210,7 +210,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
assertThat(distributionSetTagRepository.findByNameEquals("kai1").get().getDescription()).as("wrong tag found")
|
||||
.isEqualTo("kai2");
|
||||
assertThat(distributionSetTagManagement.getByName("kai1").get().getColour()).as("wrong tag found")
|
||||
assertThat(distributionSetTagManagement.findByName("kai1").get().getColour()).as("wrong tag found")
|
||||
.isEqualTo("colour");
|
||||
assertThat(distributionSetTagManagement.get(tag.getId()).get().getColour()).as("wrong tag found")
|
||||
.isEqualTo("colour");
|
||||
@@ -302,7 +302,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void verifyExpectedFilteredDistributionSets(final DistributionSetFilter.DistributionSetFilterBuilder distributionSetFilterBuilder,
|
||||
final Stream<Collection<DistributionSet>> expectedFilteredDistributionSets) {
|
||||
final Collection<Long> retrievedFilteredDsIds = distributionSetManagement
|
||||
.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build()).stream()
|
||||
.findByDistributionSetFilter(distributionSetFilterBuilder.build(), PAGE).stream()
|
||||
.map(DistributionSet::getId).toList();
|
||||
final Collection<Long> expectedFilteredDsIds = expectedFilteredDistributionSets.flatMap(Collection::stream)
|
||||
.map(DistributionSet::getId).toList();
|
||||
|
||||
@@ -46,13 +46,13 @@ public class DistributionSetTypeManagementSecurityTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void getByKeyPermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetTypeManagement.getByKey("key"), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> distributionSetTypeManagement.findByKey("key"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void getByNamePermissionsCheck() {
|
||||
assertPermissions(() -> distributionSetTypeManagement.getByName("name"), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> distributionSetTypeManagement.findByName("name"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -58,8 +58,8 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 0) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(distributionSetTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.getByKey(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.findByKey(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.findByName(NOT_EXIST_ID)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -111,23 +111,23 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
public void updateUnassignedDistributionSetTypeModules() {
|
||||
final DistributionSetType updatableType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
|
||||
// add OS
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(),
|
||||
Set.of(osType.getId()));
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes())
|
||||
.containsOnly(osType);
|
||||
|
||||
// add JVM
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(),
|
||||
Set.of(runtimeType.getId()));
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes())
|
||||
.containsOnly(osType, runtimeType);
|
||||
|
||||
// remove OS
|
||||
distributionSetTypeManagement.unassignSoftwareModuleType(updatableType.getId(), osType.getId());
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes())
|
||||
.containsOnly(runtimeType);
|
||||
}
|
||||
|
||||
@@ -186,9 +186,9 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
distributionSetTypeManagement.update(
|
||||
entityFactory.distributionSetType().update(nonUpdatableType.getId()).description("a new description"));
|
||||
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getDescription())
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getDescription())
|
||||
.isEqualTo("a new description");
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getColour()).isEqualTo("test123");
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getColour()).isEqualTo("test123");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -206,7 +206,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
public void removeModuleToAssignedDistributionSetTypeFails() {
|
||||
DistributionSetType nonUpdatableType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
|
||||
nonUpdatableType = distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(nonUpdatableType.getId(),
|
||||
Set.of(osType.getId()));
|
||||
@@ -242,11 +242,11 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
entityFactory.distributionSet().create().name("softdeleted").version("1").type(toBeDeleted.getKey()));
|
||||
|
||||
distributionSetTypeManagement.delete(toBeDeleted.getId());
|
||||
final Optional<DistributionSetType> softdeleted = distributionSetTypeManagement.getByKey("softdeleted");
|
||||
final Optional<DistributionSetType> softdeleted = distributionSetTypeManagement.findByKey("softdeleted");
|
||||
assertThat(softdeleted).isPresent();
|
||||
assertThat(softdeleted.get().isDeleted()).isTrue();
|
||||
assertThat(distributionSetTypeManagement.findAll(PAGE)).hasSize(existing);
|
||||
assertThat(distributionSetTypeManagement.findByRsql(PAGE, "name==*")).hasSize(existing);
|
||||
assertThat(distributionSetTypeManagement.findByRsql("name==*", PAGE)).hasSize(existing);
|
||||
assertThat(distributionSetTypeManagement.count()).isEqualTo(existing);
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
private DistributionSetType createDistributionSetTypeUsedByDs() {
|
||||
final DistributionSetType nonUpdatableType = distributionSetTypeManagement.create(entityFactory
|
||||
.distributionSetType().create().key("updatableType").name("to be deleted").colour("test123"));
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
distributionSetManagement.create(entityFactory.distributionSet().create().name("newtypesoft").version("1")
|
||||
.type(nonUpdatableType.getKey()));
|
||||
return nonUpdatableType;
|
||||
|
||||
@@ -46,9 +46,9 @@ public class SoftwareManagementSecurityTest
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void createMetaDataPermissionsCheck() {
|
||||
assertPermissions(
|
||||
() -> softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(1L).key("key").value("value")),
|
||||
() -> softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(1L).key("key").value("value")),
|
||||
List.of(SpPermission.UPDATE_REPOSITORY));
|
||||
assertPermissions(() -> softwareModuleManagement.createMetaData(
|
||||
assertPermissions(() -> softwareModuleManagement.putMetaData(
|
||||
List.of(entityFactory.softwareModuleMetadata().create(1L).key("key").value("value"))), List.of(SpPermission.UPDATE_REPOSITORY));
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class SoftwareManagementSecurityTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByAssignedToPermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleManagement.findByAssignedTo(PAGE, 1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> softwareModuleManagement.findByAssignedTo(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -76,19 +76,19 @@ public class SoftwareManagementSecurityTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByTextAndTypePermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleManagement.findByTextAndType(PAGE, "text", 1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> softwareModuleManagement.findByTextAndType("text", 1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getByNameAndVersionAndTypePermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleManagement.getByNameAndVersionAndType("name", "version", 1L),
|
||||
assertPermissions(() -> softwareModuleManagement.findByNameAndVersionAndType("name", "version", 1L),
|
||||
List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void getMetaDataBySoftwareModuleIdPermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleManagement.getMetaDataBySoftwareModuleId(1L, "key"), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> softwareModuleManagement.findMetaDataBySoftwareModuleId(1L, "key"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,13 +113,13 @@ public class SoftwareManagementSecurityTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findMetaDataByRsqlPermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleManagement.findMetaDataByRsql(PAGE, 1L, "key==value"), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> softwareModuleManagement.findMetaDataByRsql(1L, "key==value", PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByTypePermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleManagement.findByType(PAGE, 1L), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> softwareModuleManagement.findByType(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -68,10 +68,10 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
assertThat(softwareModuleManagement.get(1234L)).isNotPresent();
|
||||
|
||||
assertThat(softwareModuleManagement.getByNameAndVersionAndType(NOT_EXIST_ID, NOT_EXIST_ID, osType.getId()))
|
||||
assertThat(softwareModuleManagement.findByNameAndVersionAndType(NOT_EXIST_ID, NOT_EXIST_ID, osType.getId()))
|
||||
.isNotPresent();
|
||||
|
||||
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(module.getId(), NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(module.getId(), NOT_EXIST_ID)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,11 +91,11 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
"SoftwareModuleType");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.createMetaData(
|
||||
() -> softwareModuleManagement.updateMetaData(
|
||||
entityFactory.softwareModuleMetadata().create(NOT_EXIST_IDL).key("xxx").value("xxx")),
|
||||
"SoftwareModule");
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.createMetaData(Collections.singletonList(
|
||||
() -> softwareModuleManagement.putMetaData(Collections.singletonList(
|
||||
entityFactory.softwareModuleMetadata().create(NOT_EXIST_IDL).key("xxx").value("xxx"))),
|
||||
"SoftwareModule");
|
||||
|
||||
@@ -115,21 +115,21 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
entityFactory.softwareModuleMetadata().update(module.getId(), NOT_EXIST_ID).value("xxx")),
|
||||
"SoftwareModuleMetadata");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findByAssignedTo(PAGE, NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findByAssignedTo(NOT_EXIST_IDL, PAGE),
|
||||
"DistributionSet");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.getByNameAndVersionAndType("xxx", "xxx", NOT_EXIST_IDL),
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findByNameAndVersionAndType("xxx", "xxx", NOT_EXIST_IDL),
|
||||
"SoftwareModuleType");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.getMetaDataBySoftwareModuleId(NOT_EXIST_IDL, NOT_EXIST_ID),
|
||||
() -> softwareModuleManagement.findMetaDataBySoftwareModuleId(NOT_EXIST_IDL, NOT_EXIST_ID),
|
||||
"SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findMetaDataBySoftwareModuleId(PAGE, NOT_EXIST_IDL),
|
||||
"SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findMetaDataByRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findMetaDataByRsql(NOT_EXIST_IDL, "name==*", PAGE),
|
||||
"SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findByType(PAGE, NOT_EXIST_IDL), "SoftwareModule");
|
||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findByType(NOT_EXIST_IDL, PAGE), "SoftwareModule");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> softwareModuleManagement.update(entityFactory.softwareModule().update(NOT_EXIST_IDL)),
|
||||
@@ -195,23 +195,23 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
implicitLock(jvm);
|
||||
|
||||
// standard searches
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "poky", osType.getId()).getContent()).hasSize(1);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "poky", osType.getId()).getContent().get(0))
|
||||
assertThat(softwareModuleManagement.findByTextAndType("poky", osType.getId(), PAGE).getContent()).hasSize(1);
|
||||
assertThat(softwareModuleManagement.findByTextAndType("poky", osType.getId(), PAGE).getContent().get(0))
|
||||
.isEqualTo(os);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "oracle", runtimeType.getId()).getContent())
|
||||
assertThat(softwareModuleManagement.findByTextAndType("oracle", runtimeType.getId(), PAGE).getContent())
|
||||
.hasSize(1);
|
||||
assertThat(
|
||||
softwareModuleManagement.findByTextAndType(PAGE, "oracle", runtimeType.getId()).getContent().get(0))
|
||||
softwareModuleManagement.findByTextAndType("oracle", runtimeType.getId(), PAGE).getContent().get(0))
|
||||
.isEqualTo(jvm);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, ":1.0.1", appType.getId()).getContent()).hasSize(1)
|
||||
assertThat(softwareModuleManagement.findByTextAndType(":1.0.1", appType.getId(), PAGE).getContent()).hasSize(1)
|
||||
.first().isEqualTo(ah);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, ":1.0", appType.getId()).getContent()).hasSize(2);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(":1.0", appType.getId(), PAGE).getContent()).hasSize(2);
|
||||
|
||||
distributionSetManagement.unlock(ds.getId()); // otherwise delete will be rejected as a part of a locked DS
|
||||
softwareModuleManagement.delete(ah2.getId());
|
||||
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, ":1.0", appType.getId()).getContent()).hasSize(1);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, ":1.0", appType.getId()).getContent().get(0))
|
||||
assertThat(softwareModuleManagement.findByTextAndType(":1.0", appType.getId(), PAGE).getContent()).hasSize(1);
|
||||
assertThat(softwareModuleManagement.findByTextAndType(":1.0", appType.getId(), PAGE).getContent().get(0))
|
||||
.isEqualTo(ah);
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
softwareModuleManagement.delete(testdataFactory.createSoftwareModuleOs("deleted").getId());
|
||||
testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
assertThat(softwareModuleManagement.findByType(PAGE, osType.getId()).getContent())
|
||||
assertThat(softwareModuleManagement.findByType(osType.getId(), PAGE).getContent())
|
||||
.as("Expected to find the following number of modules:").hasSize(2).as("with the following elements")
|
||||
.contains(two, one);
|
||||
}
|
||||
@@ -297,7 +297,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
assignedModule = softwareModuleManagement.get(assignedModule.getId()).get();
|
||||
assertTrue(assignedModule.isDeleted(), "The module should be flagged as deleted");
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).isEmpty();
|
||||
assertThat(softwareModuleManagement.findByRsql(PAGE, "name==*")).isEmpty();
|
||||
assertThat(softwareModuleManagement.findByRsql("name==*", PAGE)).isEmpty();
|
||||
assertThat(softwareModuleManagement.count()).isZero();
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(1);
|
||||
|
||||
@@ -484,7 +484,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
.name("set").version("1").modules(Arrays.asList(one.getId(), deleted.getId())));
|
||||
softwareModuleManagement.delete(deleted.getId());
|
||||
|
||||
assertThat(softwareModuleManagement.findByAssignedTo(PAGE, set.getId()).getContent())
|
||||
assertThat(softwareModuleManagement.findByAssignedTo(set.getId(), PAGE).getContent())
|
||||
.as("Found this number of modules").hasSize(2);
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
.key(knownKey2).value(knownValue2);
|
||||
|
||||
final List<SoftwareModuleMetadata> softwareModuleMetadata = softwareModuleManagement
|
||||
.createMetaData(Arrays.asList(swMetadata1, swMetadata2));
|
||||
.putMetaData(Arrays.asList(swMetadata1, swMetadata2));
|
||||
|
||||
final SoftwareModule changedLockRevisionModule = softwareModuleManagement.get(ah.getId()).get();
|
||||
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(2);
|
||||
@@ -528,13 +528,13 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule module = testdataFactory.createSoftwareModuleApp("m1");
|
||||
final int maxMetaData = quotaManagement.getMaxMetaDataEntriesPerSoftwareModule();
|
||||
for (int i = 0; i < maxMetaData; ++i) {
|
||||
softwareModuleManagement.createMetaData(
|
||||
softwareModuleManagement.updateMetaData(
|
||||
entityFactory.softwareModuleMetadata().create(module.getId()).key("k" + i).value("v" + i));
|
||||
}
|
||||
|
||||
// quota exceeded
|
||||
assertThatExceptionOfType(AssignmentQuotaExceededException.class)
|
||||
.isThrownBy(() -> softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata()
|
||||
.isThrownBy(() -> softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata()
|
||||
.create(module.getId()).key("k" + maxMetaData).value("v" + maxMetaData)));
|
||||
|
||||
// add multiple meta data entries at once
|
||||
@@ -545,13 +545,13 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
// quota exceeded
|
||||
assertThatExceptionOfType(AssignmentQuotaExceededException.class)
|
||||
.isThrownBy(() -> softwareModuleManagement.createMetaData(create));
|
||||
.isThrownBy(() -> softwareModuleManagement.putMetaData(create));
|
||||
|
||||
// add some meta data entries
|
||||
final SoftwareModule module3 = testdataFactory.createSoftwareModuleApp("m3");
|
||||
final int firstHalf = Math.round((maxMetaData) / 2.f);
|
||||
for (int i = 0; i < firstHalf; ++i) {
|
||||
softwareModuleManagement.createMetaData(
|
||||
softwareModuleManagement.updateMetaData(
|
||||
entityFactory.softwareModuleMetadata().create(module3.getId()).key("k" + i).value("v" + i));
|
||||
}
|
||||
// add too many data entries
|
||||
@@ -562,7 +562,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
// quota exceeded
|
||||
assertThatExceptionOfType(AssignmentQuotaExceededException.class)
|
||||
.isThrownBy(() -> softwareModuleManagement.createMetaData(create2));
|
||||
.isThrownBy(() -> softwareModuleManagement.putMetaData(create2));
|
||||
|
||||
}
|
||||
|
||||
@@ -574,21 +574,21 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final String knownValue1 = "myKnownValue1";
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(ah.getId()).key(knownKey1)
|
||||
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(ah.getId()).key(knownKey1)
|
||||
.value(knownValue1).targetVisible(true));
|
||||
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
||||
.isThrownBy(() -> softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata()
|
||||
.isThrownBy(() -> softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata()
|
||||
.create(ah.getId()).key(knownKey1).value(knownValue1).targetVisible(true)))
|
||||
.withMessageContaining("Metadata").withMessageContaining(knownKey1);
|
||||
|
||||
final String knownKey2 = "myKnownKey2";
|
||||
|
||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(ah.getId()).key(knownKey2)
|
||||
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(ah.getId()).key(knownKey2)
|
||||
.value(knownValue1).targetVisible(false));
|
||||
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
||||
.isThrownBy(() -> softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata()
|
||||
.isThrownBy(() -> softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata()
|
||||
.create(ah.getId()).key(knownKey2).value(knownValue1).targetVisible(true)))
|
||||
.withMessageContaining("Metadata").withMessageContaining(knownKey2);
|
||||
}
|
||||
@@ -607,7 +607,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(ah.getOptLockRevision()).isEqualTo(1);
|
||||
|
||||
// create an software module meta data entry
|
||||
final SoftwareModuleMetadata softwareModuleMetadata = softwareModuleManagement.createMetaData(
|
||||
final SoftwareModuleMetadata softwareModuleMetadata = softwareModuleManagement.updateMetaData(
|
||||
entityFactory.softwareModuleMetadata().create(ah.getId()).key(knownKey).value(knownValue));
|
||||
assertThat(softwareModuleMetadata.isTargetVisible()).isFalse();
|
||||
assertThat(softwareModuleMetadata.getValue()).isEqualTo(knownValue);
|
||||
@@ -642,7 +642,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final SoftwareModule swModule = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
softwareModuleManagement.createMetaData(
|
||||
softwareModuleManagement.updateMetaData(
|
||||
entityFactory.softwareModuleMetadata().create(swModule.getId()).key(knownKey1).value(knownValue1));
|
||||
|
||||
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(PageRequest.of(0, 10), swModule.getId())
|
||||
@@ -665,10 +665,10 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
||||
|
||||
softwareModuleManagement.createMetaData(
|
||||
softwareModuleManagement.updateMetaData(
|
||||
entityFactory.softwareModuleMetadata().create(ah.getId()).key(knownKey1).value(knownValue1));
|
||||
|
||||
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(ah.getId(), "doesnotexist")).isNotPresent();
|
||||
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(ah.getId(), "doesnotexist")).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -682,12 +682,12 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final int metadataCountSw2 = 10;
|
||||
|
||||
for (int index = 0; index < metadataCountSw1; index++) {
|
||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(sw1.getId())
|
||||
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(sw1.getId())
|
||||
.key("key" + index).value("value" + index).targetVisible(true));
|
||||
}
|
||||
|
||||
for (int index = 0; index < metadataCountSw2; index++) {
|
||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(sw2.getId())
|
||||
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(sw2.getId())
|
||||
.key("key" + index).value("value" + index).targetVisible(false));
|
||||
}
|
||||
|
||||
|
||||
@@ -46,13 +46,13 @@ public class SoftwareModuleTypeManagementSecurityTest
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void getByKeyPermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleTypeManagement.getByKey("key"), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> softwareModuleTypeManagement.findByKey("key"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void getByNamePermissionsCheck() {
|
||||
assertPermissions(() -> softwareModuleTypeManagement.getByName("name"), List.of(SpPermission.READ_REPOSITORY));
|
||||
assertPermissions(() -> softwareModuleTypeManagement.findByName("name"), List.of(SpPermission.READ_REPOSITORY));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
|
||||
assertThat(softwareModuleTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(softwareModuleTypeManagement.getByKey(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(softwareModuleTypeManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(softwareModuleTypeManagement.findByKey(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(softwareModuleTypeManagement.findByName(NOT_EXIST_ID)).isNotPresent();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -129,7 +129,7 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
// delete assigned
|
||||
softwareModuleTypeManagement.delete(type.getId());
|
||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
|
||||
assertThat(softwareModuleTypeManagement.findByRsql(PAGE, "name==*")).hasSize(3).contains(osType, runtimeType,
|
||||
assertThat(softwareModuleTypeManagement.findByRsql("name==*", PAGE)).hasSize(3).contains(osType, runtimeType,
|
||||
appType);
|
||||
assertThat(softwareModuleTypeManagement.count()).isEqualTo(3);
|
||||
|
||||
@@ -147,7 +147,7 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
||||
softwareModuleTypeManagement
|
||||
.create(entityFactory.softwareModuleType().create().key("thetype2").name("anothername"));
|
||||
|
||||
assertThat(softwareModuleTypeManagement.getByName("thename").get()).as("Type with given name").isEqualTo(found);
|
||||
assertThat(softwareModuleTypeManagement.findByName("thename").get()).as("Type with given name").isEqualTo(found);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -202,7 +202,7 @@ public class RSQLDistributionSetFieldTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expectedEntity) {
|
||||
final Page<DistributionSet> find = distributionSetManagement.findByRsql(PageRequest.of(0, 100), rsqlParam);
|
||||
final Page<DistributionSet> find = distributionSetManagement.findByRsql(rsqlParam, PageRequest.of(0, 100));
|
||||
final long countAll = find.getTotalElements();
|
||||
assertThat(find).as("Found entity is should not be null").isNotNull();
|
||||
assertThat(countAll).as("Found entity size is wrong").isEqualTo(expectedEntity);
|
||||
|
||||
@@ -44,9 +44,9 @@ public class RSQLDistributionSetMetadataFieldsTest extends AbstractJpaIntegratio
|
||||
metadata.add(entityFactory.generateDsMetadata("" + i, "" + i));
|
||||
}
|
||||
|
||||
distributionSetManagement.createMetaData(distributionSetId, metadata);
|
||||
distributionSetManagement.putMetaData(distributionSetId, metadata);
|
||||
|
||||
distributionSetManagement.createMetaData(distributionSetId,
|
||||
distributionSetManagement.putMetaData(distributionSetId,
|
||||
Arrays.asList(entityFactory.generateDsMetadata("emptyValueTest", null)));
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class RSQLDistributionSetMetadataFieldsTest extends AbstractJpaIntegratio
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
|
||||
|
||||
final Page<DistributionSetMetadata> findEnitity = distributionSetManagement
|
||||
.findMetaDataByDistributionSetIdAndRsql(PageRequest.of(0, 100), distributionSetId, rsqlParam);
|
||||
.findMetaDataByDistributionSetIdAndRsql(distributionSetId, rsqlParam, PageRequest.of(0, 100));
|
||||
final long countAllEntities = findEnitity.getTotalElements();
|
||||
assertThat(findEnitity).isNotNull();
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
|
||||
@@ -51,11 +51,11 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final SoftwareModuleMetadataCreate softwareModuleMetadata = entityFactory.softwareModuleMetadata()
|
||||
.create(ah.getId()).key("metaKey").value("metaValue");
|
||||
softwareModuleManagement.createMetaData(softwareModuleMetadata);
|
||||
softwareModuleManagement.updateMetaData(softwareModuleMetadata);
|
||||
|
||||
final SoftwareModuleMetadataCreate softwareModuleMetadata2 = entityFactory.softwareModuleMetadata()
|
||||
.create(ah2.getId()).key("metaKey").value("value");
|
||||
softwareModuleManagement.createMetaData(softwareModuleMetadata2);
|
||||
softwareModuleManagement.updateMetaData(softwareModuleMetadata2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -150,7 +150,7 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expectedEntity) {
|
||||
final Page<SoftwareModule> find = softwareModuleManagement.findByRsql(PageRequest.of(0, 100), rsqlParam);
|
||||
final Page<SoftwareModule> find = softwareModuleManagement.findByRsql(rsqlParam, PageRequest.of(0, 100));
|
||||
final long countAll = find.getTotalElements();
|
||||
assertThat(find).isNotNull();
|
||||
assertThat(countAll).isEqualTo(expectedEntity);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractJpaIntegration
|
||||
metadata.add(entityFactory.softwareModuleMetadata().create(softwareModule.getId()).key("emptyMd")
|
||||
.targetVisible(true));
|
||||
|
||||
softwareModuleManagement.createMetaData(metadata);
|
||||
softwareModuleManagement.putMetaData(metadata);
|
||||
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractJpaIntegration
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
|
||||
|
||||
final Page<SoftwareModuleMetadata> findEnitity = softwareModuleManagement
|
||||
.findMetaDataByRsql(PageRequest.of(0, 100), softwareModuleId, rsqlParam);
|
||||
.findMetaDataByRsql(softwareModuleId, rsqlParam, PageRequest.of(0, 100));
|
||||
final long countAllEntities = findEnitity.getTotalElements();
|
||||
assertThat(findEnitity).isNotNull();
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
|
||||
@@ -78,8 +78,8 @@ public class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest
|
||||
}
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {
|
||||
final Page<SoftwareModuleType> find = softwareModuleTypeManagement.findByRsql(PageRequest.of(0, 100),
|
||||
rsqlParam);
|
||||
final Page<SoftwareModuleType> find = softwareModuleTypeManagement.findByRsql(rsqlParam, PageRequest.of(0, 100)
|
||||
);
|
||||
final long countAll = find.getTotalElements();
|
||||
assertThat(find).isNotNull();
|
||||
assertThat(countAll).isEqualTo(excpectedEntity);
|
||||
|
||||
@@ -119,8 +119,8 @@ public class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private void assertRSQLQueryDistributionSet(final String rsqlParam, final long expectedEntities) {
|
||||
|
||||
final Page<DistributionSetTag> findEnitity = distributionSetTagManagement.findByRsql(PageRequest.of(0, 100),
|
||||
rsqlParam);
|
||||
final Page<DistributionSetTag> findEnitity = distributionSetTagManagement.findByRsql(rsqlParam, PageRequest.of(0, 100)
|
||||
);
|
||||
final long countAllEntities = findEnitity.getTotalElements();
|
||||
assertThat(findEnitity).isNotNull();
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
|
||||
Reference in New Issue
Block a user