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);
|
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
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var givenDebitor = debitorRepo.findByDefaultPrefix("fir").stream()
|
final var givenDebitor = debitorRepo.findByDebitorNumber(1000111).stream()
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithClean
|
|||||||
void globalAdmin_canAddBookingProject() {
|
void globalAdmin_canAddBookingProject() {
|
||||||
|
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenDebitor = debitorRepo.findByDefaultPrefix("fir").stream()
|
final var givenDebitor = debitorRepo.findByDebitorNumber(1000111).stream()
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithClean
|
|||||||
@Test
|
@Test
|
||||||
void globalAdmin_canPatchAllUpdatablePropertiesOfBookingProject() {
|
void globalAdmin_canPatchAllUpdatablePropertiesOfBookingProject() {
|
||||||
|
|
||||||
final var givenBookingProject = givenSomeBookingProject("fir", "some project");
|
final var givenBookingProject = givenSomeBookingProject(1000111, "some project");
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
@ -232,7 +232,7 @@ class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithClean
|
|||||||
@Test
|
@Test
|
||||||
void globalAdmin_canDeleteArbitraryBookingProject() {
|
void globalAdmin_canDeleteArbitraryBookingProject() {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenBookingProject = givenSomeBookingProject("fir", "some project");
|
final var givenBookingProject = givenSomeBookingProject(1000111, "some project");
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.given()
|
||||||
@ -250,7 +250,7 @@ class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithClean
|
|||||||
@Test
|
@Test
|
||||||
void normalUser_canNotDeleteUnrelatedBookingProject() {
|
void normalUser_canNotDeleteUnrelatedBookingProject() {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenBookingProject = givenSomeBookingProject("fir", "some project");
|
final var givenBookingProject = givenSomeBookingProject(1000111, "some project");
|
||||||
|
|
||||||
RestAssured // @formatter:off
|
RestAssured // @formatter:off
|
||||||
.given()
|
.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(() -> {
|
return jpaAttempt.transacted(() -> {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
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()
|
final var newBookingProject = HsBookingProjectEntity.builder()
|
||||||
.uuid(UUID.randomUUID())
|
.uuid(UUID.randomUUID())
|
||||||
.debitor(givenDebitor)
|
.debitor(givenDebitor)
|
||||||
|
@ -63,7 +63,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
|||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var count = bookingProjectRepo.count();
|
final var count = bookingProjectRepo.count();
|
||||||
final var givenDebitor = debitorRepo.findByDefaultPrefix("fir").get(0);
|
final var givenDebitor = debitorRepo.findByDebitorNumber(1000111).get(0);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = attempt(em, () -> {
|
final var result = attempt(em, () -> {
|
||||||
@ -92,7 +92,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
attempt(em, () -> {
|
attempt(em, () -> {
|
||||||
final var givenDebitor = debitorRepo.findByDefaultPrefix("fir").get(0);
|
final var givenDebitor = debitorRepo.findByDebitorNumber(1000111).get(0);
|
||||||
final var newBookingProject = HsBookingProjectEntity.builder()
|
final var newBookingProject = HsBookingProjectEntity.builder()
|
||||||
.debitor(givenDebitor)
|
.debitor(givenDebitor)
|
||||||
.caption("some new booking project")
|
.caption("some new booking project")
|
||||||
@ -148,7 +148,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
|||||||
public void globalAdmin_withoutAssumedRole_canViewAllBookingProjectsOfArbitraryDebitor() {
|
public void globalAdmin_withoutAssumedRole_canViewAllBookingProjectsOfArbitraryDebitor() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var debitorUuid = debitorRepo.findByDefaultPrefix("sec").stream()
|
final var debitorUuid = debitorRepo.findByDebitorNumber(1000212).stream()
|
||||||
.findAny().orElseThrow().getUuid();
|
.findAny().orElseThrow().getUuid();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -164,7 +164,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
|||||||
public void normalUser_canViewOnlyRelatedBookingProjects() {
|
public void normalUser_canViewOnlyRelatedBookingProjects() {
|
||||||
// given:
|
// given:
|
||||||
context("person-FirbySusan@example.com");
|
context("person-FirbySusan@example.com");
|
||||||
final var debitorUuid = debitorRepo.findByDefaultPrefix("fir").stream()
|
final var debitorUuid = debitorRepo.findByDebitorNumber(1000111).stream()
|
||||||
.findAny().orElseThrow().getUuid();
|
.findAny().orElseThrow().getUuid();
|
||||||
|
|
||||||
// when:
|
// when:
|
||||||
@ -183,7 +183,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
|||||||
@Test
|
@Test
|
||||||
public void hostsharingAdmin_canUpdateArbitraryBookingProject() {
|
public void hostsharingAdmin_canUpdateArbitraryBookingProject() {
|
||||||
// given
|
// given
|
||||||
final var givenBookingProjectUuid = givenSomeTemporaryBookingProject("fir").getUuid();
|
final var givenBookingProjectUuid = givenSomeTemporaryBookingProject(1000111).getUuid();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
@ -214,7 +214,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
|||||||
public void globalAdmin_withoutAssumedRole_canDeleteAnyBookingProject() {
|
public void globalAdmin_withoutAssumedRole_canDeleteAnyBookingProject() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net", null);
|
context("superuser-alex@hostsharing.net", null);
|
||||||
final var givenBookingProject = givenSomeTemporaryBookingProject("fir");
|
final var givenBookingProject = givenSomeTemporaryBookingProject(1000111);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
@ -234,7 +234,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
|||||||
public void nonGlobalAdmin_canNotDeleteTheirRelatedBookingProject() {
|
public void nonGlobalAdmin_canNotDeleteTheirRelatedBookingProject() {
|
||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net", null);
|
context("superuser-alex@hostsharing.net", null);
|
||||||
final var givenBookingProject = givenSomeTemporaryBookingProject("fir");
|
final var givenBookingProject = givenSomeTemporaryBookingProject(1000111);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
@ -260,7 +260,7 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
|||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var initialRoleNames = Array.from(distinctRoleNamesOf(rawRoleRepo.findAll()));
|
final var initialRoleNames = Array.from(distinctRoleNamesOf(rawRoleRepo.findAll()));
|
||||||
final var initialGrantNames = Array.from(distinctGrantDisplaysOf(rawGrantRepo.findAll()));
|
final var initialGrantNames = Array.from(distinctGrantDisplaysOf(rawGrantRepo.findAll()));
|
||||||
final var givenBookingProject = givenSomeTemporaryBookingProject("fir");
|
final var givenBookingProject = givenSomeTemporaryBookingProject(1000111);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = jpaAttempt.transacted(() -> {
|
final var result = jpaAttempt.transacted(() -> {
|
||||||
@ -295,10 +295,10 @@ class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithClea
|
|||||||
"[creating booking-project test-data 1000313, hs_booking_project, INSERT]");
|
"[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(() -> {
|
return jpaAttempt.transacted(() -> {
|
||||||
context("superuser-alex@hostsharing.net");
|
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()
|
final var newBookingProject = HsBookingProjectEntity.builder()
|
||||||
.debitor(givenDebitor)
|
.debitor(givenDebitor)
|
||||||
.caption("some temp project")
|
.caption("some temp project")
|
||||||
|
Loading…
Reference in New Issue
Block a user