use findByDebitorNumber instead of findByDefaultPrefix
This commit is contained in:
parent
8343152382
commit
afa7c9d0f7
@ -10,5 +10,5 @@ public interface HsBookingDebitorRepository extends Repository<HsBookingDebitorE
|
||||
|
||||
Optional<HsBookingDebitorEntity> findByUuid(UUID id);
|
||||
|
||||
List<HsBookingDebitorEntity> findByDefaultPrefix(String defaultPrefix); // FIXME: change to findByDebitorNumber
|
||||
List<HsBookingDebitorEntity> findByDebitorNumber(int debitorNumber);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var givenDebitor = debitorRepo.findByDefaultPrefix("fir").stream()
|
||||
final var givenDebitor = debitorRepo.findByDebitorNumber(1000111).stream()
|
||||
.findFirst()
|
||||
.orElseThrow();
|
||||
|
||||
@ -87,7 +87,7 @@ class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
void globalAdmin_canAddBookingProject() {
|
||||
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenDebitor = debitorRepo.findByDefaultPrefix("fir").stream()
|
||||
final var givenDebitor = debitorRepo.findByDebitorNumber(1000111).stream()
|
||||
.findFirst()
|
||||
.orElseThrow();
|
||||
|
||||
@ -193,7 +193,7 @@ class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
@Test
|
||||
void globalAdmin_canPatchAllUpdatablePropertiesOfBookingProject() {
|
||||
|
||||
final var givenBookingProject = givenSomeBookingProject("fir", "some project");
|
||||
final var givenBookingProject = givenSomeBookingProject(1000111, "some project");
|
||||
|
||||
RestAssured // @formatter:off
|
||||
.given()
|
||||
@ -232,7 +232,7 @@ class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
@Test
|
||||
void globalAdmin_canDeleteArbitraryBookingProject() {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenBookingProject = givenSomeBookingProject("fir", "some project");
|
||||
final var givenBookingProject = givenSomeBookingProject(1000111, "some project");
|
||||
|
||||
RestAssured // @formatter:off
|
||||
.given()
|
||||
@ -250,7 +250,7 @@ class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
@Test
|
||||
void normalUser_canNotDeleteUnrelatedBookingProject() {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenBookingProject = givenSomeBookingProject("fir", "some project");
|
||||
final var givenBookingProject = givenSomeBookingProject(1000111, "some project");
|
||||
|
||||
RestAssured // @formatter:off
|
||||
.given()
|
||||
@ -266,10 +266,10 @@ class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithClean
|
||||
}
|
||||
}
|
||||
|
||||
private HsBookingProjectEntity givenSomeBookingProject(final String defaultPrefix, final String caption) {
|
||||
private HsBookingProjectEntity givenSomeBookingProject(final int debitorNumber, final String caption) {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context.define("superuser-alex@hostsharing.net");
|
||||
final var givenDebitor = debitorRepo.findByDefaultPrefix(defaultPrefix).stream().findAny().orElseThrow();
|
||||
final var givenDebitor = debitorRepo.findByDebitorNumber(debitorNumber).stream().findAny().orElseThrow();
|
||||
final var newBookingProject = HsBookingProjectEntity.builder()
|
||||
.uuid(UUID.randomUUID())
|
||||
.debitor(givenDebitor)
|
||||
|
@ -63,7 +63,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var count = bookingProjectRepo.count();
|
||||
final var givenDebitor = debitorRepo.findByDefaultPrefix("fir").get(0);
|
||||
final var givenDebitor = debitorRepo.findByDebitorNumber(1000111).get(0);
|
||||
|
||||
// when
|
||||
final var result = attempt(em, () -> {
|
||||
@ -92,7 +92,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
|
||||
// when
|
||||
attempt(em, () -> {
|
||||
final var givenDebitor = debitorRepo.findByDefaultPrefix("fir").get(0);
|
||||
final var givenDebitor = debitorRepo.findByDebitorNumber(1000111).get(0);
|
||||
final var newBookingProject = HsBookingProjectEntity.builder()
|
||||
.debitor(givenDebitor)
|
||||
.caption("some new booking project")
|
||||
@ -148,7 +148,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
public void globalAdmin_withoutAssumedRole_canViewAllBookingProjectsOfArbitraryDebitor() {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var debitorUuid = debitorRepo.findByDefaultPrefix("sec").stream()
|
||||
final var debitorUuid = debitorRepo.findByDebitorNumber(1000212).stream()
|
||||
.findAny().orElseThrow().getUuid();
|
||||
|
||||
// when
|
||||
@ -164,7 +164,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
public void normalUser_canViewOnlyRelatedBookingProjects() {
|
||||
// given:
|
||||
context("person-FirbySusan@example.com");
|
||||
final var debitorUuid = debitorRepo.findByDefaultPrefix("fir").stream()
|
||||
final var debitorUuid = debitorRepo.findByDebitorNumber(1000111).stream()
|
||||
.findAny().orElseThrow().getUuid();
|
||||
|
||||
// when:
|
||||
@ -183,7 +183,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
@Test
|
||||
public void hostsharingAdmin_canUpdateArbitraryBookingProject() {
|
||||
// given
|
||||
final var givenBookingProjectUuid = givenSomeTemporaryBookingProject("fir").getUuid();
|
||||
final var givenBookingProjectUuid = givenSomeTemporaryBookingProject(1000111).getUuid();
|
||||
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
@ -214,7 +214,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
public void globalAdmin_withoutAssumedRole_canDeleteAnyBookingProject() {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net", null);
|
||||
final var givenBookingProject = givenSomeTemporaryBookingProject("fir");
|
||||
final var givenBookingProject = givenSomeTemporaryBookingProject(1000111);
|
||||
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
@ -234,7 +234,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
public void nonGlobalAdmin_canNotDeleteTheirRelatedBookingProject() {
|
||||
// given
|
||||
context("superuser-alex@hostsharing.net", null);
|
||||
final var givenBookingProject = givenSomeTemporaryBookingProject("fir");
|
||||
final var givenBookingProject = givenSomeTemporaryBookingProject(1000111);
|
||||
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
@ -260,7 +260,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var initialRoleNames = Array.from(distinctRoleNamesOf(rawRoleRepo.findAll()));
|
||||
final var initialGrantNames = Array.from(distinctGrantDisplaysOf(rawGrantRepo.findAll()));
|
||||
final var givenBookingProject = givenSomeTemporaryBookingProject("fir");
|
||||
final var givenBookingProject = givenSomeTemporaryBookingProject(1000111);
|
||||
|
||||
// when
|
||||
final var result = jpaAttempt.transacted(() -> {
|
||||
@ -295,10 +295,10 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
||||
"[creating booking-project test-data 1000313, hs_booking_project, INSERT]");
|
||||
}
|
||||
|
||||
private HsBookingProjectEntity givenSomeTemporaryBookingProject(final String defaultPrefix) {
|
||||
private HsBookingProjectEntity givenSomeTemporaryBookingProject(final int debitorNumber) {
|
||||
return jpaAttempt.transacted(() -> {
|
||||
context("superuser-alex@hostsharing.net");
|
||||
final var givenDebitor = debitorRepo.findByDefaultPrefix(defaultPrefix).get(0);
|
||||
final var givenDebitor = debitorRepo.findByDebitorNumber(debitorNumber).get(0);
|
||||
final var newBookingProject = HsBookingProjectEntity.builder()
|
||||
.debitor(givenDebitor)
|
||||
.caption("some temp project")
|
||||
|
Loading…
Reference in New Issue
Block a user