-
-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sergey
authored and
Sergey
committed
Jan 31, 2025
1 parent
7627891
commit d711801
Showing
2 changed files
with
55 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
/** | ||
* This file is part of alf.io. | ||
* | ||
* <p> | ||
* alf.io is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* <p> | ||
* alf.io is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* <p> | ||
* You should have received a copy of the GNU General Public License | ||
* along with alf.io. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
@@ -24,15 +24,18 @@ | |
import alfio.manager.EventManager; | ||
import alfio.manager.user.UserManager; | ||
import alfio.model.Event; | ||
import alfio.model.PromoCodeDiscount; | ||
import alfio.model.TicketCategory; | ||
import alfio.model.metadata.AlfioMetadata; | ||
import alfio.model.modification.AdminReservationModification; | ||
import alfio.model.modification.DateTimeModification; | ||
import alfio.model.modification.TicketCategoryModification; | ||
import alfio.repository.EventDeleterRepository; | ||
import alfio.repository.EventRepository; | ||
import alfio.repository.PromoCodeDiscountRepository; | ||
import alfio.repository.TicketCategoryRepository; | ||
import alfio.repository.TicketRepository; | ||
import alfio.repository.TicketReservationRepository; | ||
import alfio.repository.system.ConfigurationRepository; | ||
import alfio.repository.user.OrganizationRepository; | ||
import alfio.test.util.AlfioIntegrationTest; | ||
|
@@ -58,7 +61,10 @@ | |
import java.util.List; | ||
|
||
import static alfio.controller.api.admin.EventApiController.FIXED_FIELDS; | ||
import static alfio.test.util.IntegrationTestUtil.*; | ||
import static alfio.test.util.IntegrationTestUtil.AVAILABLE_SEATS; | ||
import static alfio.test.util.IntegrationTestUtil.DESCRIPTION; | ||
import static alfio.test.util.IntegrationTestUtil.initEvent; | ||
import static alfio.test.util.IntegrationTestUtil.owner; | ||
import static alfio.test.util.TestUtil.clockProvider; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
@@ -92,13 +98,18 @@ class EventApiControllerIntegrationTest { | |
private TicketCategoryRepository ticketCategoryRepository; | ||
@Autowired | ||
private TicketRepository ticketRepository; | ||
@Autowired | ||
private PromoCodeDiscountRepository promoCodeDiscountRepository; | ||
@Autowired | ||
private TicketReservationRepository ticketReservationRepository; | ||
|
||
private Event event; | ||
private static final String TEST_ATTENDEE_EXTERNAL_REFERENCE = "123"; | ||
private static final String TEST_ATTENDEE_USER_LANGUAGE = "en"; | ||
private static final String TEST_ATTENDEE_FIRST_NAME = "Attendee"; | ||
private static final String TEST_ATTENDEE_LAST_NAME = "Test"; | ||
private static final String TEST_ATTENDEE_EMAIL = "[email protected]"; | ||
private static final String TEST_PROMO_CODE = "test-promo-code"; | ||
|
||
@Test | ||
void getAllEventsForExternalInPerson() { | ||
|
@@ -152,13 +163,15 @@ void testGivenListOfAttendeesWithFieldsUploadThenSameFieldsAvailableOnCsvDownloa | |
when(principal.getName()).thenReturn(owner(eventAndUser.getValue())); | ||
var modification = getTestAdminReservationModification(); | ||
var result = this.attendeeBulkImportApiController.createReservations(eventAndUser.getKey().getShortName(), modification, false, principal); | ||
var organizationId = organizationRepository.findAllForUser(eventAndUser.getRight()).get(0).getId(); | ||
|
||
// GIVEN - invocation of async processing job | ||
var requestStatus = this.attendeeBulkImportApiController.getRequestsStatus(eventAndUser.getKey().getShortName(), result.getData(), principal); | ||
assertEquals(1, requestStatus.getData().getCountPending()); | ||
|
||
// WHEN - processing of pending reservations completes | ||
this.adminReservationRequestManager.processPendingReservations(); | ||
createPromoCode(organizationId, modification.getCustomerData().getEmailAddress()); | ||
|
||
// THEN - assert correctness of data persisted | ||
var tickets = this.ticketRepository.findAllConfirmedForCSV(event.getId()); | ||
|
@@ -178,7 +191,7 @@ void testGivenListOfAttendeesWithFieldsUploadThenSameFieldsAvailableOnCsvDownloa | |
String expectedTestAttendeeCsvLine = "\""+foundTicket.getUuid()+"\""+",default,"+"\""+event.getShortName()+"\""+",ACQUIRED,0,0,0,0,"+"\""+foundTicket.getTicketsReservationId()+"\""+",\""+TEST_ATTENDEE_FIRST_NAME+" "+TEST_ATTENDEE_LAST_NAME+"\","+TEST_ATTENDEE_FIRST_NAME+","+TEST_ATTENDEE_LAST_NAME+","+TEST_ATTENDEE_EMAIL+",false,"+TEST_ATTENDEE_USER_LANGUAGE; | ||
String returnedCsvContent = mockResponse.getContentAsString().trim().replace("\uFEFF", ""); // remove BOM | ||
assertTrue(returnedCsvContent.startsWith(getExpectedHeaderCsvLine() + "\n" + expectedTestAttendeeCsvLine)); | ||
assertTrue(returnedCsvContent.endsWith("\"Billing Address\",,,," + TEST_ATTENDEE_EXTERNAL_REFERENCE)); | ||
assertTrue(returnedCsvContent.endsWith("\"Billing Address\",,"+TEST_PROMO_CODE+",,," + TEST_ATTENDEE_EXTERNAL_REFERENCE)); | ||
} | ||
|
||
private AdminReservationModification getTestAdminReservationModification() { | ||
|
@@ -202,13 +215,22 @@ private Pair<Event,String> createEvent(Event.EventFormat format) { | |
|
||
} | ||
|
||
private void createPromoCode(int organizationId, String email) { | ||
var eventId = event.getId(); | ||
promoCodeDiscountRepository.addPromoCode(TEST_PROMO_CODE, eventId, organizationId, ZonedDateTime.now(), ZonedDateTime.now() | ||
.plusDays(3), 10, PromoCodeDiscount.DiscountType.FIXED_AMOUNT, "[1,2,3]", 1, "test promo code", "[email protected]", PromoCodeDiscount.CodeType.DISCOUNT, 21, "usd"); | ||
var promoCodeId = promoCodeDiscountRepository.findAllInEvent(eventId).get(0).getId(); | ||
ticketReservationRepository.setPromotionCodeDiscountId(email, promoCodeId); | ||
} | ||
|
||
private String getExpectedHeaderCsvLine() { | ||
String expectedHeaderCsvLine = String.join(",", FIXED_FIELDS); | ||
expectedHeaderCsvLine = expectedHeaderCsvLine.replaceAll("Full Name", "\"Full Name\""); | ||
expectedHeaderCsvLine = expectedHeaderCsvLine.replaceAll("First Name", "\"First Name\""); | ||
expectedHeaderCsvLine = expectedHeaderCsvLine.replaceAll("Last Name", "\"Last Name\""); | ||
expectedHeaderCsvLine = expectedHeaderCsvLine.replaceAll("Billing Address", "\"Billing Address\""); | ||
expectedHeaderCsvLine = expectedHeaderCsvLine.replaceAll("Country Code", "\"Country Code\""); | ||
expectedHeaderCsvLine = expectedHeaderCsvLine.replaceAll("Voucher Code", "\"Voucher Code\""); | ||
expectedHeaderCsvLine = expectedHeaderCsvLine.replaceAll("Payment ID", "\"Payment ID\""); | ||
expectedHeaderCsvLine = expectedHeaderCsvLine.replaceAll("Payment Method", "\"Payment Method\""); | ||
expectedHeaderCsvLine = expectedHeaderCsvLine.replaceAll("External Reference", "\"External Reference\""); | ||
|