下面列出了org.apache.commons.lang3.tuple.Triple#getMiddle ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
@Override
public void registerIcons(String modName, Block block, IIconRegister register) {
IIcon base = register.registerIcon(modName + ":" + texturePath);
int wh = (int) Math.sqrt(size);
TextureSubmap[][] submaps = new TextureSubmap[wh][wh];
TextureSubmap[][] submapsSmall = new TextureSubmap[wh][wh];
for (int i = 0; i < size; i++) {
AbstractSubmapManager manager = (AbstractSubmapManager) TextureType.CTMX.createManagerFor(CarvingUtils.getDefaultVariationFor(block, meta, 0), texturePath + "-" + i);
manager.registerIcons(modName, block, register);
Object cached = manager.getCachedObject();
Triple<IIcon, TextureSubmap, TextureSubmap> triple = (Triple<IIcon, TextureSubmap, TextureSubmap>) cached;
submaps[i % wh][i / wh] = triple.getMiddle();
submapsSmall[i % wh][i / wh] = triple.getRight();
if (i == 0) {
defaultIcon = triple.getRight().getSubIcon(0, 0);
}
}
submap = new Submap(base, wh, submaps);
smallSubmap = new Submap(base, wh, submapsSmall);
}
private void processApplication(Map<String, Application> appCache,
Map.Entry<String, Pair<Set<GrpcHost>, Set<GrpcHost>>> entry) {
Triple<String, String, String> appNameServiceVersion = getAppNameServiceVersion(entry.getKey());
Pair<Set<GrpcHost>, Set<GrpcHost>> providerConsumer = entry.getValue();
String appName = appNameServiceVersion.getLeft();
String serviceName = appNameServiceVersion.getMiddle();
String version = appNameServiceVersion.getRight();
Application application = new Application(appName);
GrpcService service = new GrpcService(appName, version, serviceName);
if (providerConsumer.getLeft() != null) {
service.addProviderHosts(providerConsumer.getLeft());
}
if (providerConsumer.getRight() != null) {
service.addConsumerHosts(providerConsumer.getRight());
}
application.addService(service);
if (appCache.get(application.getAppName()) == null) {
appCache.put(application.getAppName(), application);
} else {
appCache.get(application.getAppName()).addServices(application.getServices());
}
}
AesCbcHmacSha2Decryptor(String name, byte[] key, byte[] iv, byte[] authenticationData, byte[] authenticationTag, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException {
// Split the key to get the AES key, the HMAC key and the HMAC
// object
Triple<byte[], byte[], Mac> parameters = GetAlgorithmParameters(name, key);
// Save the MAC provider and key
_hmac = parameters.getRight();
_hmac_key = parameters.getMiddle();
// Create the AES provider
_inner = new AesCbc.AesCbcDecryptor(parameters.getLeft(), iv, provider);
_aad_length = toBigEndian(authenticationData.length * 8);
// Save the tag
_tag = authenticationTag;
// Prime the hash.
_hmac.update(authenticationData);
_hmac.update(iv);
}
@Override
public void migrateConfig(List<Triple<Character, String, String>> oldConfig){
for(Triple<Character, String, String> entry:oldConfig){
if (entry.getLeft() == 'B'){
BooleanValue value;
switch(entry.getMiddle()){
case "disableMod": value = ClientSettings.disableMod; break;
case "enableDoubleTap": value = ClientSettings.enableDoubleTap; break;
case "enableAllDirs": value = ClientSettings.enableAllDirs; break;
case "flyOnGround": value = ClientSettings.flyOnGround; break;
default: continue;
}
BetterSprintingMod.config.set(value, entry.getRight().equalsIgnoreCase("true"));
}
else if (entry.getLeft() == 'I' && entry.getMiddle().equals("flySpeedBoost")){
BetterSprintingMod.config.set(ClientSettings.flySpeedBoost, Integer.parseInt(entry.getRight()));
}
else if (entry.getLeft() == 'S' && entry.getMiddle().equals("sprintKeyMode") && entry.getRight().equals("HOLD")){
BetterSprintingMod.config.set(ClientSettings.sprintKeyMode, SprintKeyMode.HOLD);
}
}
}
@Override
public void migrateConfig(List<Triple<Character, String, String>> oldConfig){
for(Triple<Character, String, String> entry:oldConfig){
if (entry.getLeft() == 'B'){
BooleanValue value;
switch(entry.getMiddle()){
case "disableClientMod": value = ServerSettings.disableClientMod; break;
case "enableSurvivalFlyBoost": value = ServerSettings.enableSurvivalFlyBoost; break;
case "enableAllDirs": value = ServerSettings.enableAllDirs; break;
default: continue;
}
BetterSprintingMod.config.set(value, entry.getRight().equalsIgnoreCase("true"));
}
}
}
@Test
public void testDistributeSeatsFirstCategoryIsUnbounded() throws Exception {
List<TicketCategoryModification> categories = getPreSalesTicketCategoryModifications(false, AVAILABLE_SEATS, true, 10);
Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
Event event = pair.getKey();
TicketCategory firstCategory = eventManager.loadTicketCategories(event).stream().filter(t->t.getName().equals("defaultFirst")).findFirst().orElseThrow(IllegalStateException::new);
configurationManager.saveCategoryConfiguration(firstCategory.getId(), event.getId(), Collections.singletonList(new ConfigurationModification(null, ConfigurationKeys.MAX_AMOUNT_OF_TICKETS_BY_RESERVATION.getValue(), "1")), pair.getRight()+"_owner");
configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_PRE_REGISTRATION, "true");
configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_WAITING_QUEUE, "true");
boolean result = waitingQueueManager.subscribe(event, customerJohnDoe(event), "[email protected]", null, Locale.ENGLISH);
assertTrue(result);
List<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> subscriptions = waitingQueueManager.distributeSeats(event).collect(Collectors.toList());
assertEquals(1, subscriptions.size());
Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime> subscriptionDetail = subscriptions.get(0);
assertEquals("[email protected]", subscriptionDetail.getLeft().getEmailAddress());
TicketReservationWithOptionalCodeModification reservation = subscriptionDetail.getMiddle();
assertEquals(Integer.valueOf(firstCategory.getId()), reservation.getTicketCategoryId());
assertEquals(Integer.valueOf(1), reservation.getAmount());
assertTrue(subscriptionDetail.getRight().isAfter(ZonedDateTime.now()));
}
@Test
public void testDistributeSeatsFirstCategoryIsBounded() throws Exception {
List<TicketCategoryModification> categories = getPreSalesTicketCategoryModifications(true, 10, true, 10);
Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);
Event event = pair.getKey();
TicketCategory firstCategory = eventManager.loadTicketCategories(event).stream().filter(t->t.getName().equals("defaultFirst")).findFirst().orElseThrow(IllegalStateException::new);
configurationManager.saveCategoryConfiguration(firstCategory.getId(), event.getId(), Collections.singletonList(new ConfigurationModification(null, ConfigurationKeys.MAX_AMOUNT_OF_TICKETS_BY_RESERVATION.getValue(), "1")), pair.getRight()+"_owner");
configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_PRE_REGISTRATION, "true");
configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_WAITING_QUEUE, "true");
boolean result = waitingQueueManager.subscribe(event, customerJohnDoe(event), "[email protected]", null, Locale.ENGLISH);
assertTrue(result);
List<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> subscriptions = waitingQueueManager.distributeSeats(event).collect(Collectors.toList());
assertEquals(1, subscriptions.size());
Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime> subscriptionDetail = subscriptions.get(0);
assertEquals("[email protected]", subscriptionDetail.getLeft().getEmailAddress());
TicketReservationWithOptionalCodeModification reservation = subscriptionDetail.getMiddle();
assertEquals(Integer.valueOf(firstCategory.getId()), reservation.getTicketCategoryId());
assertEquals(Integer.valueOf(1), reservation.getAmount());
assertTrue(subscriptionDetail.getRight().isAfter(ZonedDateTime.now()));
}
public Collection<T> execute() {
if (this.uri != null) {
final Triple<List<T>, URI, List<ClientAnnotation>> res = fetchPartial(this.uri.build(), itemRef);
this.nextPageURI = res.getMiddle();
if (items == null) {
items = res.getLeft();
} else {
items.clear();
items.addAll(res.getLeft());
}
annotations.clear();
annotations.addAll(res.getRight());
}
return this;
}
@SuppressWarnings("unchecked")
public <S extends T, SEC extends EntityCollection<S, ?, ?>> SEC fetchWholeEntitySet(
final URIBuilder uriBuilder, final Class<S> typeRef, final Class<SEC> collTypeRef) {
final List<S> res = new ArrayList<S>();
final List<ClientAnnotation> anns = new ArrayList<ClientAnnotation>();
URI nextURI = uriBuilder.build();
while (nextURI != null) {
final Triple<List<T>, URI, List<ClientAnnotation>> entitySet = fetchPartial(nextURI, (Class<T>) typeRef);
res.addAll((List<S>) entitySet.getLeft());
nextURI = entitySet.getMiddle();
anns.addAll(entitySet.getRight());
}
final EntityCollectionInvocationHandler<S> entityCollectionHandler =
new EntityCollectionInvocationHandler<S>(service, res, collTypeRef, targetEntitySetURI, uriBuilder);
entityCollectionHandler.setAnnotations(anns);
return (SEC) Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {collTypeRef},
entityCollectionHandler);
}
public static void insertRowLock(final ConnectionAdapter adapterConnection, final DbRuntimeContext runTimeContext,
final String tableName, final Object rowKey) throws SQLException {
long transId = runTimeContext.getTransId();
long branchId = runTimeContext.getBranchId();
String instanceId = runTimeContext.getInstanceId();
PreparedStatement pstmt = null;
try {
pstmt = adapterConnection.getSourceConnection().prepareStatement(INSERT_SQL);
pstmt.setLong(1, branchId);
pstmt.setLong(2, transId);
pstmt.setString(3, tableName);
pstmt.setObject(4, rowKey);
pstmt.setString(5, instanceId);
pstmt.executeUpdate();
} catch (SQLException e) {
if (e.getErrorCode() == 1062) {
Triple<Long, Long, String> triple = query(adapterConnection.getSourceConnection(), tableName, rowKey);
if (!Objects.isNull(triple) && !Objects.isNull(triple.getMiddle()) && transId == triple.getMiddle()) {
return;
}
throw new DtsLockConflictException(String.format(
"Row[Table:%s,Pk:%s] locked by other global transaction[TransId:%s,BranchId:%s,InstanceId:%s]",
tableName, rowKey, triple.getMiddle(), triple.getLeft(), triple.getRight()));
} else {
throw e;
}
} finally {
if (pstmt != null)
pstmt.close();
}
}
private Set<String> buildQueryCondition(String search, String dimension, Boolean accurate) {
Set<String> beAboutToQuery = Sets.newHashSet();
Map<String, Pair<Set<GrpcHost>, Set<GrpcHost>>> servicesPassing = registryRepository.getAllPassingService();
for (Map.Entry<String, Pair<Set<GrpcHost>, Set<GrpcHost>>> entry : servicesPassing.entrySet()) {
String serviceKey = entry.getKey();
Triple<String, String, String> appNameServiceVersion = getAppNameServiceVersion(serviceKey);
String appName = appNameServiceVersion.getLeft();
String serviceName = appNameServiceVersion.getMiddle();
if (dimension.equals("service")) {
if (accurate) {
if (StringUtils.equalsIgnoreCase(serviceName, search)) {
beAboutToQuery.add(serviceKey);
}
} else {
if (StringUtils.containsIgnoreCase(serviceName, search)) {
beAboutToQuery.add(serviceKey);
}
}
} else {
if (accurate) {
if (StringUtils.equalsIgnoreCase(appName, search)) {
beAboutToQuery.add(serviceKey);
}
} else {
if (StringUtils.containsIgnoreCase(appName, search)) {
beAboutToQuery.add(serviceKey);
}
}
}
}
return beAboutToQuery;
}
@SuppressWarnings("unchecked")
public <S extends T, SEC extends EntityCollection<S, ?, ?>> SEC execute(final Class<SEC> collTypeRef) {
final Class<S> ref = (Class<S>) ClassUtils.extractTypeArg(collTypeRef,
AbstractEntitySet.class, AbstractSingleton.class, EntityCollection.class);
final Class<S> oref = (Class<S>) ClassUtils.extractTypeArg(this.collItemRef,
AbstractEntitySet.class, AbstractSingleton.class, EntityCollection.class);
if (!oref.equals(ref)) {
uri.appendDerivedEntityTypeSegment(new FullQualifiedName(
ClassUtils.getNamespace(ref), ClassUtils.getEntityTypeName(ref)).toString());
}
final List<ClientAnnotation> anns = new ArrayList<ClientAnnotation>();
final Triple<List<T>, URI, List<ClientAnnotation>> entitySet = fetchPartial(uri.build(), (Class<T>) ref);
anns.addAll(entitySet.getRight());
final EntityCollectionInvocationHandler<S> entityCollectionHandler = new EntityCollectionInvocationHandler<S>(
service, (List<S>) entitySet.getLeft(), collTypeRef, this.baseURI, uri);
entityCollectionHandler.setAnnotations(anns);
entityCollectionHandler.nextPageURI = entitySet.getMiddle();
return (SEC) Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {collTypeRef},
entityCollectionHandler);
}
@Override
public Map<String, PrimitiveTypeProvider> convert(Triple<String, String, String> data) {
final HashMap<String, PrimitiveTypeProvider> map = new HashMap<>(2);
String id = "v_" + data.getLeft() + "_" + data.getMiddle();
map.put(SimpleFulltextFeatureDescriptor.FIELDNAMES[0], PrimitiveTypeProvider.fromObject(id));
map.put(SimpleFulltextFeatureDescriptor.FIELDNAMES[1], PrimitiveTypeProvider.fromObject(data.getRight()));
return map;
}
private Triple<ValidationResult, Event, Ticket> assignTicket(UpdateTicketOwnerForm updateTicketOwner,
Optional<Errors> bindingResult,
Locale fallbackLocale,
Optional<UserDetails> userDetails,
Triple<Event, TicketReservation, Ticket> result,
String formPrefix) {
Ticket t = result.getRight();
final Event event = result.getLeft();
if(t.getLockedAssignment()) {
//in case of locked assignment, fullName and Email will be overwritten
updateTicketOwner.setFirstName(t.getFirstName());
updateTicketOwner.setLastName(t.getLastName());
updateTicketOwner.setFullName(t.getFullName());
updateTicketOwner.setEmail(t.getEmail());
}
final TicketReservation ticketReservation = result.getMiddle();
List<TicketFieldConfiguration> fieldConf = ticketFieldRepository.findAdditionalFieldsForEvent(event.getId());
var sameCountryValidator = new SameCountryValidator(configurationManager, extensionManager, event, ticketReservation.getId(), vatChecker);
AdvancedTicketAssignmentValidator advancedValidator = new AdvancedTicketAssignmentValidator(sameCountryValidator,
new GroupManager.WhitelistValidator(event.getId(), groupManager));
var additionalServiceIds = new HashSet<>(additionalServiceItemRepository.findAdditionalServiceIdsByReservationUuid(t.getTicketsReservationId()));
var ticketFieldFilterer = new Validator.TicketFieldsFilterer(fieldConf, ticketUUID -> t.getCategoryId(), additionalServiceIds, ticketRepository.findFirstTicketInReservation(t.getTicketsReservationId()));
Validator.AdvancedValidationContext context = new Validator.AdvancedValidationContext(updateTicketOwner, fieldConf, t.getCategoryId(), t.getUuid(), formPrefix);
ValidationResult validationResult = Validator.validateTicketAssignment(updateTicketOwner, ticketFieldFilterer.getFieldsForTicket(t.getUuid()), bindingResult, event, formPrefix, sameCountryValidator)
.or(Validator.performAdvancedValidation(advancedValidator, context, bindingResult.orElse(null)))
.ifSuccess(() -> updateTicketOwner(updateTicketOwner, fallbackLocale, t, event, ticketReservation, userDetails));
return Triple.of(validationResult, event, ticketRepository.findByUUID(t.getUuid()));
}
private List<AltSiteRecord> createDesignMatrixOfSingleContext(final Triple<String, Nucleotide, ReadOrientation> transition,
final int refDepth, final int altDepth,
final int refF1R2, final int altF1R2,
final int numExamples) {
final List<AltSiteRecord> altDesignMatrix = new ArrayList<>(numExamples);
final String refContext = transition.getLeft();
final Nucleotide altAllele = transition.getMiddle();
IntStream.range(0, numExamples).forEach(i ->
altDesignMatrix.add(new AltSiteRecord(refContext, refDepth, altDepth, refF1R2, altF1R2, altAllele)));
return altDesignMatrix;
}
public void setupNotificationChannels() {
if (SDK_INT >= android.os.Build.VERSION_CODES.O) {
// Each triple contains the channel ID, name, and importance level
List<Triple<String, String, Integer>> notificationTripleList =
new ArrayList<Triple<String, String, Integer>>() {{
add(Triple.of(CHANNEL_IMG, "Image downloads",
NotificationManager.IMPORTANCE_LOW));
add(Triple.of(CHANNEL_COMMENT_CACHE, "Comment caching",
NotificationManager.IMPORTANCE_LOW));
add(Triple.of(CHANNEL_MAIL, "Reddit mail",
NotificationManager.IMPORTANCE_HIGH));
add(Triple.of(CHANNEL_MODMAIL, "Reddit modmail",
NotificationManager.IMPORTANCE_HIGH));
add(Triple.of(CHANNEL_SUBCHECKING, "Submission post checking",
NotificationManager.IMPORTANCE_LOW));
}};
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
for (Triple<String, String, Integer> notificationTriple : notificationTripleList) {
NotificationChannel notificationChannel =
new NotificationChannel(notificationTriple.getLeft(),
notificationTriple.getMiddle(), notificationTriple.getRight());
notificationChannel.enableLights(true);
notificationChannel.setShowBadge(
notificationTriple.getRight() == NotificationManager.IMPORTANCE_HIGH);
notificationChannel.setLightColor(
notificationTriple.getLeft().contains("MODMAIL") ? getResources().getColor(
R.color.md_red_500, null) : Palette.getColor(""));
if (notificationManager != null) {
notificationManager.createNotificationChannel(notificationChannel);
}
}
}
}
private void extractIndices(DatabaseMetaData metadata,
String catalog,
String schema,
String table,
String label,
boolean isVertex) {
String lastIndexName = null;
IndexType lastIndexType = null;
List<String> lastColumns = new LinkedList<>();
List<Triple<String, Boolean, String>> indexes = this.sqlDialect.getIndexInfo(metadata, catalog, schema, table, false, true);
for (Triple<String, Boolean, String> index : indexes) {
String indexName = index.getLeft();
boolean nonUnique = index.getMiddle();
String columnName = index.getRight();
if (lastIndexName == null) {
lastIndexName = indexName;
lastIndexType = nonUnique ? IndexType.NON_UNIQUE : IndexType.UNIQUE;
} else if (!lastIndexName.equals(indexName)) {
if (!this.sqlDialect.isSystemIndex(lastIndexName)) {
if (!Schema.GLOBAL_UNIQUE_INDEX_SCHEMA.equals(schema)) {
TopologyManager.addIndex(sqlgGraph, schema, label, isVertex, lastIndexName, lastIndexType, lastColumns);
}
}
lastColumns.clear();
lastIndexName = indexName;
lastIndexType = nonUnique ? IndexType.NON_UNIQUE : IndexType.UNIQUE;
}
lastColumns.add(columnName);
}
if (!this.sqlDialect.isSystemIndex(lastIndexName)) {
if (!Schema.GLOBAL_UNIQUE_INDEX_SCHEMA.equals(schema)) {
TopologyManager.addIndex(sqlgGraph, schema, label, isVertex, lastIndexName, lastIndexType, lastColumns);
}
}
}
/**
* @implNote snapshot the transactions for creating new block template.
* @return the transactions ready to be seal into the new blocks.
*/
public List<AionTransaction> snapshot() {
lock.lock();
try {
if (poolTransactions.isEmpty()) {
return Collections.emptyList();
}
Map<AionAddress, BigInteger> accountPickingInfo = new HashMap<>();
Set<ByteArrayWrapper> pickedTxHash = new HashSet<>();
// We use the multi rounds picking strategy.
List<AionTransaction> pickedTransactions = new ArrayList<>();
int totalPicked;
long cumulatedTxEncodedSize = 0;
long cumulatedTxEnergyConsumed = 0;
LOG_TXPOOL.info("Start to pick transaction");
do {
totalPicked = pickedTransactions.size();
Triple<List<AionTransaction>, Long, Long> newPicked =
pickTransaction(
accountPickingInfo,
pickedTxHash,
cumulatedTxEncodedSize,
cumulatedTxEnergyConsumed);
cumulatedTxEncodedSize += newPicked.getMiddle();
cumulatedTxEnergyConsumed += newPicked.getRight();
LOG_TXPOOL.debug(
"transaction picked: {}, newPickedEncodedSize: {}, newPickedEnergyConsumed: {}",
newPicked.getLeft().size(),
newPicked.getMiddle(),
newPicked.getRight());
pickedTransactions.addAll(newPicked.getLeft());
} while (totalPicked < pickedTransactions.size());
LOG_TXPOOL.info(
"snapshot {} tx, totalEncodedSize: {}, totalEnergyConsumed: {}",
pickedTransactions.size(),
cumulatedTxEncodedSize,
cumulatedTxEnergyConsumed);
return pickedTransactions;
} finally {
lock.unlock();
}
}
@Test
public void testAssignTicketToWaitingQueueUnboundedCategory() {
LocalDateTime start = LocalDateTime.now().minusMinutes(1);
LocalDateTime end = LocalDateTime.now().plusMinutes(20);
List<TicketCategoryModification> categories = Collections.singletonList(
new TicketCategoryModification(null, "default", AVAILABLE_SEATS,
new DateTimeModification(start.toLocalDate(), start.toLocalTime()),
new DateTimeModification(end.toLocalDate(), end.toLocalTime()),
DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null, 0, null, null, AlfioMetadata.empty()));
configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_WAITING_QUEUE, "true");
Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository).getKey();
TicketCategory unbounded = ticketCategoryRepository.findAllTicketCategories(event.getId()).get(0);
TicketReservationModification tr = new TicketReservationModification();
tr.setAmount(AVAILABLE_SEATS - 1);
tr.setTicketCategoryId(unbounded.getId());
TicketReservationModification tr2 = new TicketReservationModification();
tr2.setAmount(1);
tr2.setTicketCategoryId(unbounded.getId());
TicketReservationWithOptionalCodeModification multi = new TicketReservationWithOptionalCodeModification(tr, Optional.empty());
TicketReservationWithOptionalCodeModification single = new TicketReservationWithOptionalCodeModification(tr2, Optional.empty());
String reservationId = ticketReservationManager.createTicketReservation(event, Collections.singletonList(multi), Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Locale.ENGLISH, false);
Pair<TotalPrice, Optional<PromoCodeDiscount>> priceAndDiscount = ticketReservationManager.totalReservationCostWithVAT(reservationId);
TotalPrice reservationCost = priceAndDiscount.getLeft();
assertTrue(priceAndDiscount.getRight().isEmpty());
PaymentSpecification specification = new PaymentSpecification(reservationId, null, reservationCost.getPriceWithVAT(),
event, "[email protected]", new CustomerName("full name", "full", "name", event.mustUseFirstAndLastName()),
"billing address", null, Locale.ENGLISH, true, false, null, "IT", "123456", PriceContainer.VatStatus.INCLUDED, true, false);
PaymentResult result = ticketReservationManager.performPayment(specification, reservationCost, PaymentProxy.OFFLINE, PaymentMethod.BANK_TRANSFER);
assertTrue(result.isSuccessful());
String reservationIdSingle = ticketReservationManager.createTicketReservation(event, Collections.singletonList(single), Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Locale.ENGLISH, false);
Pair<TotalPrice, Optional<PromoCodeDiscount>> priceAndDiscountSingle = ticketReservationManager.totalReservationCostWithVAT(reservationId);
TotalPrice reservationCostSingle = priceAndDiscountSingle.getLeft();
assertTrue(priceAndDiscountSingle.getRight().isEmpty());
specification = new PaymentSpecification(reservationIdSingle, null, reservationCostSingle.getPriceWithVAT(),
event, "[email protected]", new CustomerName("full name", "full", "name", event.mustUseFirstAndLastName()),
"billing address", null, Locale.ENGLISH, true, false, null, "IT", "123456", PriceContainer.VatStatus.INCLUDED, true, false);
PaymentResult resultSingle = ticketReservationManager.performPayment(specification, reservationCostSingle, PaymentProxy.OFFLINE, PaymentMethod.BANK_TRANSFER);
assertTrue(resultSingle.isSuccessful());
assertEquals(0, eventRepository.findStatisticsFor(event.getId()).getDynamicAllocation());
assertTrue(waitingQueueManager.subscribe(event, customerJohnDoe(event), "[email protected]", null, Locale.ENGLISH));
ticketReservationManager.deleteOfflinePayment(event, reservationIdSingle, false, false, null);
List<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> subscriptions = waitingQueueManager.distributeSeats(event).collect(Collectors.toList());
assertEquals(1, subscriptions.size());
Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime> subscriptionDetail = subscriptions.get(0);
assertEquals("[email protected]", subscriptionDetail.getLeft().getEmailAddress());
TicketReservationWithOptionalCodeModification reservation = subscriptionDetail.getMiddle();
assertEquals(Integer.valueOf(unbounded.getId()), reservation.getTicketCategoryId());
assertEquals(Integer.valueOf(1), reservation.getAmount());
assertTrue(subscriptionDetail.getRight().isAfter(ZonedDateTime.now()));
}
@Test
public void testAssignTicketToWaitingQueueBoundedCategory() {
LocalDateTime start = LocalDateTime.now().minusMinutes(2);
LocalDateTime end = LocalDateTime.now().plusMinutes(20);
List<TicketCategoryModification> categories = Collections.singletonList(
new TicketCategoryModification(null, "default", AVAILABLE_SEATS,
new DateTimeModification(start.toLocalDate(), start.toLocalTime()),
new DateTimeModification(end.toLocalDate(), end.toLocalTime()),
DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null, 0, null, null, AlfioMetadata.empty()));
configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_WAITING_QUEUE, "true");
Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository).getKey();
TicketCategory bounded = ticketCategoryRepository.findAllTicketCategories(event.getId()).get(0);
TicketReservationModification tr = new TicketReservationModification();
tr.setAmount(AVAILABLE_SEATS - 1);
tr.setTicketCategoryId(bounded.getId());
TicketReservationModification tr2 = new TicketReservationModification();
tr2.setAmount(1);
tr2.setTicketCategoryId(bounded.getId());
TicketReservationWithOptionalCodeModification multi = new TicketReservationWithOptionalCodeModification(tr, Optional.empty());
TicketReservationWithOptionalCodeModification single = new TicketReservationWithOptionalCodeModification(tr2, Optional.empty());
String reservationId = ticketReservationManager.createTicketReservation(event, Collections.singletonList(multi), Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Locale.ENGLISH, false);
Pair<TotalPrice, Optional<PromoCodeDiscount>> priceAndDiscount = ticketReservationManager.totalReservationCostWithVAT(reservationId);
TotalPrice reservationCost = priceAndDiscount.getLeft();
assertTrue(priceAndDiscount.getRight().isEmpty());
PaymentSpecification specification = new PaymentSpecification(reservationId, null, reservationCost.getPriceWithVAT(),
event, "[email protected]", new CustomerName("full name", "full", "name", event.mustUseFirstAndLastName()),
"billing address", null, Locale.ENGLISH, true, false, null, "IT", "123456", PriceContainer.VatStatus.INCLUDED, true, false);
PaymentResult result = ticketReservationManager.performPayment(specification, reservationCost, PaymentProxy.OFFLINE, PaymentMethod.BANK_TRANSFER);
assertTrue(result.isSuccessful());
String reservationIdSingle = ticketReservationManager.createTicketReservation(event, Collections.singletonList(single), Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Locale.ENGLISH, false);
Pair<TotalPrice, Optional<PromoCodeDiscount>> priceAndDiscountSingle = ticketReservationManager.totalReservationCostWithVAT(reservationId);
TotalPrice reservationCostSingle = priceAndDiscountSingle.getLeft();
assertTrue(priceAndDiscountSingle.getRight().isEmpty());
specification = new PaymentSpecification(reservationIdSingle, null, reservationCostSingle.getPriceWithVAT(),
event, "[email protected]", new CustomerName("full name", "full", "name", event.mustUseFirstAndLastName()),
"billing address", null, Locale.ENGLISH, true, false, null, "IT", "123456", PriceContainer.VatStatus.INCLUDED, true, false);
PaymentResult resultSingle = ticketReservationManager.performPayment(specification, reservationCostSingle, PaymentProxy.OFFLINE, PaymentMethod.BANK_TRANSFER);
assertTrue(resultSingle.isSuccessful());
assertEquals(0, eventRepository.findStatisticsFor(event.getId()).getDynamicAllocation());
assertTrue(waitingQueueManager.subscribe(event, customerJohnDoe(event), "[email protected]", null, Locale.ENGLISH));
ticketReservationManager.deleteOfflinePayment(event, reservationIdSingle, false, false, null);
List<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> subscriptions = waitingQueueManager.distributeSeats(event).collect(Collectors.toList());
assertEquals(1, subscriptions.size());
Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime> subscriptionDetail = subscriptions.get(0);
assertEquals("[email protected]", subscriptionDetail.getLeft().getEmailAddress());
TicketReservationWithOptionalCodeModification reservation = subscriptionDetail.getMiddle();
assertEquals(Integer.valueOf(bounded.getId()), reservation.getTicketCategoryId());
assertEquals(Integer.valueOf(1), reservation.getAmount());
assertTrue(subscriptionDetail.getRight().isAfter(ZonedDateTime.now()));
}