List of usage examples for java.time LocalTime now
public static LocalTime now()
From source file:alfio.manager.EventManagerIntegrationTest.java
@Test public void testAddBoundedCategoryToUnboundedEvent() { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 0, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null)); Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);//from w w w . j a va 2 s. com Event event = pair.getKey(); TicketCategoryModification tcm = new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null); Result<Integer> result = eventManager.insertCategory(event, tcm, pair.getValue()); assertTrue(result.isSuccess()); List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId()); assertNotNull(tickets); assertFalse(tickets.isEmpty()); assertEquals(10, tickets.size()); assertEquals(10, tickets.stream().filter(t -> t.getCategoryId() == null).count()); assertEquals(10, ticketRepository.countReleasedTicketInCategory(event.getId(), result.getData()).intValue()); }
From source file:alfio.manager.EventManagerIntegrationTest.java
@Test public void testUpdateBoundedCategory() { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null)); Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);//w w w .j a v a 2s. com Event event = pair.getKey(); TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0); TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), "default", 20, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null); eventManager.updateCategory(category.getId(), event.getId(), tcm, pair.getValue()); waitingQueueSubscriptionProcessor.distributeAvailableSeats(event); List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId()); assertNotNull(tickets); assertFalse(tickets.isEmpty()); assertEquals(AVAILABLE_SEATS, tickets.size()); assertEquals(0, tickets.stream().filter(t -> t.getCategoryId() == null).count()); }
From source file:alfio.manager.EventManagerIntegrationTest.java
@Test public void testUpdateEventHeader() { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null)); Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);/*from ww w .j ava 2 s. c o m*/ Event event = pair.getLeft(); String username = pair.getRight(); Map<String, String> desc = new HashMap<>(); desc.put("en", "muh description new"); desc.put("it", "muh description new"); desc.put("de", "muh description new"); EventModification em = new EventModification(event.getId(), Event.EventType.INTERNAL, "http://example.com/new", null, "http://example.com/tc", "https://example.com/img.png", null, event.getShortName(), "new display name", event.getOrganizationId(), event.getLocation(), "0.0", "0.0", ZoneId.systemDefault().getId(), desc, DateTimeModification.fromZonedDateTime(event.getBegin()), DateTimeModification.fromZonedDateTime(event.getEnd().plusDays(42)), event.getRegularPrice(), event.getCurrency(), eventRepository.countExistingTickets(event.getId()), event.getVat(), event.isVatIncluded(), event.getAllowedPaymentProxies(), Collections.emptyList(), false, null, 7, null, null); eventManager.updateEventHeader(event, em, username); Event updatedEvent = eventRepository.findById(event.getId()); Assert.assertEquals("http://example.com/new", updatedEvent.getWebsiteUrl()); Assert.assertEquals("http://example.com/tc", updatedEvent.getTermsAndConditionsUrl()); Assert.assertEquals("https://example.com/img.png", updatedEvent.getImageUrl()); Assert.assertEquals("new display name", updatedEvent.getDisplayName()); }
From source file:alfio.manager.EventManagerIntegrationTest.java
@Test public void testUpdateBoundedFlagToTrue() { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null)); Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);/* w w w . jav a2 s . c o m*/ Event event = pair.getLeft(); String username = pair.getRight(); assertEquals(new Integer(AVAILABLE_SEATS), ticketRepository.countFreeTicketsForUnbounded(event.getId())); TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0); Map<String, String> categoryDescription = ticketCategoryDescriptionRepository .descriptionForTicketCategory(category.getId()); TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), AVAILABLE_SEATS, DateTimeModification.fromZonedDateTime(category.getUtcInception()), DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription, category.getPrice(), false, "", true, null, null, null, null, null); Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username); assertTrue(result.isSuccess()); assertEquals(new Integer(0), ticketRepository.countFreeTicketsForUnbounded(event.getId())); }
From source file:alfio.manager.EventManagerIntegrationTest.java
@Test public void testUpdateBoundedFlagToFalse() { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null)); Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);// w ww . j a v a 2 s. com Event event = pair.getLeft(); String username = pair.getRight(); assertEquals(new Integer(0), ticketRepository.countFreeTicketsForUnbounded(event.getId())); TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0); Map<String, String> categoryDescription = ticketCategoryDescriptionRepository .descriptionForTicketCategory(category.getId()); TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), AVAILABLE_SEATS, DateTimeModification.fromZonedDateTime(category.getUtcInception()), DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription, category.getPrice(), false, "", false, null, null, null, null, null); Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username); assertTrue(result.isSuccess()); assertEquals(AVAILABLE_SEATS, ticketRepository.countReleasedUnboundedTickets(event.getId()).intValue()); waitingQueueSubscriptionProcessor.distributeAvailableSeats(event); assertEquals(AVAILABLE_SEATS, ticketRepository.countFreeTicketsForUnbounded(event.getId()).intValue()); }
From source file:alfio.manager.WaitingQueueManagerIntegrationTest.java
private List<TicketCategoryModification> getPreSalesTicketCategoryModifications(boolean firstBounded, int firstSeats, boolean lastBounded, int lastSeats) { LocalDateTime start = LocalDateTime.now().plusMinutes(4); return Arrays.asList( new TicketCategoryModification(null, "defaultFirst", firstSeats, new DateTimeModification(start.toLocalDate(), start.toLocalTime()), new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", firstBounded, null, null, null, null, null), new TicketCategoryModification(null, "defaultLast", lastSeats, new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()), new DateTimeModification(LocalDate.now().plusDays(2), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", lastBounded, null, null, null, null, null)); }
From source file:alfio.manager.EventManagerIntegrationTest.java
@Test public void testValidationBoundedFailedRestrictedFlag() { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, true, "", true, null, null, null, null, null)); Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);/*from w w w. ja v a 2s .co m*/ Event event = pair.getLeft(); String username = pair.getRight(); TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0); Map<String, String> categoryDescription = ticketCategoryDescriptionRepository .descriptionForTicketCategory(category.getId()); TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), 10, DateTimeModification.fromZonedDateTime(category.getUtcInception()), DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription, category.getPrice(), true, "", false, null, null, null, null, null); Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username); assertFalse(result.isSuccess()); }
From source file:alfio.manager.EventManagerIntegrationTest.java
@Test public void testValidationBoundedFailedPendingTickets() { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null)); Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);//w w w. j av a 2 s. c o m Event event = pair.getLeft(); String username = pair.getRight(); TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0); Map<String, String> categoryDescription = ticketCategoryDescriptionRepository .descriptionForTicketCategory(category.getId()); List<Integer> tickets = ticketRepository.selectTicketInCategoryForUpdate(event.getId(), category.getId(), 1, Collections.singletonList(Ticket.TicketStatus.FREE.name())); String reservationId = "12345678"; ticketReservationRepository.createNewReservation(reservationId, DateUtils.addDays(new Date(), 1), null, "en", event.getId(), event.getVat(), event.isVatIncluded()); ticketRepository.reserveTickets(reservationId, tickets, category.getId(), "en", 100); TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), 10, DateTimeModification.fromZonedDateTime(category.getUtcInception()), DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription, category.getPrice(), false, "", false, null, null, null, null, null); Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username); assertFalse(result.isSuccess()); }
From source file:alfio.manager.EventManagerIntegrationTest.java
@Test public void testIncreaseRestrictedCategory() { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, true, "", true, null, null, null, null, null)); Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);/*from w ww . ja va 2 s .c o m*/ Event event = pair.getLeft(); String username = pair.getRight(); TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0); Map<String, String> categoryDescription = ticketCategoryDescriptionRepository .descriptionForTicketCategory(category.getId()); TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), 11, DateTimeModification.fromZonedDateTime(category.getUtcInception()), DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription, category.getPrice(), true, "", true, null, null, null, null, null); Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username); assertTrue(result.isSuccess()); assertEquals(11, ticketRepository.countFreeTickets(event.getId(), category.getId()).intValue()); }
From source file:alfio.manager.EventManagerIntegrationTest.java
@Test public void testDecreaseRestrictedCategory() { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 10, new DateTimeModification(LocalDate.now(), LocalTime.now()), new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, true, "", true, null, null, null, null, null)); Pair<Event, String> pair = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);/*from w ww . j ava 2s . c om*/ Event event = pair.getLeft(); String username = pair.getRight(); TicketCategory category = ticketCategoryRepository.findByEventId(event.getId()).get(0); Map<String, String> categoryDescription = ticketCategoryDescriptionRepository .descriptionForTicketCategory(category.getId()); TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), 9, DateTimeModification.fromZonedDateTime(category.getUtcInception()), DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription, category.getPrice(), true, "", true, null, null, null, null, null); Result<TicketCategory> result = eventManager.updateCategory(category.getId(), event, tcm, username); assertTrue(result.isSuccess()); assertEquals(9, ticketRepository.countFreeTickets(event.getId(), category.getId()).intValue()); assertEquals(1, ticketRepository.countReleasedUnboundedTickets(event.getId()).intValue()); }