List of usage examples for java.time LocalTime now
public static LocalTime now()
From source file:alfio.controller.ReservationFlowIntegrationTest.java
@Before public void ensureConfiguration() { IntegrationTestUtil.ensureMinimalConfiguration(configurationRepository); List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now().minusDays(1), LocalTime.now()), new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null)); Pair<Event, String> eventAndUser = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository);// ww w .java 2 s .co m event = eventAndUser.getKey(); user = eventAndUser.getValue() + "_owner"; // TemplateManager templateManager = Mockito.mock(TemplateManager.class); reservationApiController = new ReservationApiController(eventRepository, ticketHelper, templateManager, i18nManager, euVatChecker, ticketReservationRepository, ticketReservationManager); }
From source file:alfio.manager.AdminReservationManagerIntegrationTest.java
@Test public void testReserveFromExistingCategoryNotEnoughSeatsNoExtensionAllowedBounded() throws Exception { 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)); performExistingCategoryTest(categories, true, Collections.singletonList(AVAILABLE_SEATS + 1), false, false, 0, AVAILABLE_SEATS);//from www .j av a 2s. c om }
From source file:electrical_parameters.Basic.java
public void printAll() { System.out.println("Cas generovania"); System.out.println(LocalTime.now()); System.out.println("Rg [Ohm/km]"); System.out.println(this.Rg); System.out.println("Dg [mH/km]"); System.out.println(this.Dg); System.out.println("R [Ohm/km]"); printRealMatrix(this.R); System.out.println("L [mH/km]"); printRealMatrix(this.L.scalarMultiply(1000)); System.out.println("X [Ohm/km]"); printRealMatrix(this.X); System.out.println("Z [Ohm/km]"); printComplexMatrix(this.Z); System.out.println("Rred [Ohm/km]"); printRealMatrix(this.R_red); System.out.println("Lred [mH/km]"); printRealMatrix(this.L_red.scalarMultiply(1000)); System.out.println("Xred [Ohm/km]"); printRealMatrix(this.X_red); System.out.println("Zred [Ohm/km]"); printComplexMatrix(this.Z_red); System.out.println("Rred_symm [Ohm/km]"); printSymmRealMatrix(this.R_red_symm); System.out.println("Lred_symm [mH/km]"); printSymmRealMatrix(this.L_red_symm.scalarMultiply(1000)); System.out.println("Xred_symm [Ohm/km]"); printSymmRealMatrix(this.X_red_symm); System.out.println("Zred_symm [Ohm/km]"); printSymmComplexMatrix(this.Z_red_symm); }
From source file:alfio.manager.system.DataMigratorIntegrationTest.java
@Test public void testMigrationWithExistingRecord() { 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> eventUsername = initEvent(categories); Event event = eventUsername.getKey(); try {//from w w w. j a v a2 s .c o m eventMigrationRepository.insertMigrationData(event.getId(), "1.4", ZonedDateTime.now(ZoneId.of("UTC")).minusDays(1), EventMigration.Status.COMPLETE.toString()); eventRepository.updatePrices("CHF", 40, false, BigDecimal.ONE, "STRIPE", event.getId(), PriceContainer.VatStatus.NOT_INCLUDED, 1000); dataMigrator.migrateEventsToCurrentVersion(); EventMigration eventMigration = eventMigrationRepository.loadEventMigration(event.getId()); assertNotNull(eventMigration); //assertEquals(buildTimestamp, eventMigration.getBuildTimestamp().toString()); assertEquals(currentVersion, eventMigration.getCurrentVersion()); List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId()); assertNotNull(tickets); assertFalse(tickets.isEmpty()); assertEquals(20, tickets.size()); assertTrue(tickets.stream().allMatch(t -> t.getCategoryId() == null)); } finally { eventManager.deleteEvent(event.getId(), eventUsername.getValue()); } }
From source file:alfio.manager.AdminReservationManagerIntegrationTest.java
@Test public void testReserveFromExistingCategoryNotEnoughSeatsNoExtensionAllowedNotBounded() throws Exception { 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)); performExistingCategoryTest(categories, true, Collections.singletonList(AVAILABLE_SEATS + 1), false, false, 0, AVAILABLE_SEATS);//from w w w . ja va2 s .co m }
From source file:alfio.manager.AdminReservationManagerIntegrationTest.java
@Test public void testReserveFromNewCategory() throws Exception { List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 1, 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> eventWithUsername = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository); Event event = eventWithUsername.getKey(); String username = eventWithUsername.getValue(); DateTimeModification expiration = DateTimeModification.fromZonedDateTime(ZonedDateTime.now().plusDays(1)); CustomerData customerData = new CustomerData("Integration", "Test", "integration-test@test.ch", "Billing Address", "en"); Category category = new Category(null, "name", new BigDecimal("100.00")); int attendees = AVAILABLE_SEATS; List<TicketsInfo> ticketsInfoList = Collections .singletonList(new TicketsInfo(category, generateAttendees(attendees), true, false)); AdminReservationModification modification = new AdminReservationModification(expiration, customerData, ticketsInfoList, "en", false, null); Result<Pair<TicketReservation, List<Ticket>>> result = adminReservationManager .createReservation(modification, event.getShortName(), username); assertTrue(result.isSuccess());/* ww w . j a va 2 s.c o m*/ Pair<TicketReservation, List<Ticket>> data = result.getData(); List<Ticket> tickets = data.getRight(); assertTrue(tickets.size() == attendees); assertNotNull(data.getLeft()); int categoryId = tickets.get(0).getCategoryId(); Event modified = eventManager.getSingleEvent(event.getShortName(), username); assertEquals(attendees + 1, eventRepository.countExistingTickets(event.getId()).intValue()); assertEquals(attendees, ticketRepository.findPendingTicketsInCategories(Collections.singletonList(categoryId)).size()); TicketCategory categoryModified = ticketCategoryRepository.getByIdAndActive(categoryId, event.getId()); assertEquals(categoryModified.getMaxTickets(), attendees); ticketCategoryRepository.findByEventId(event.getId()) .forEach(tc -> assertTrue(specialPriceRepository.findAllByCategoryId(tc.getId()).stream() .allMatch(sp -> sp.getStatus() == SpecialPrice.Status.PENDING))); adminReservationManager.confirmReservation(event.getShortName(), data.getLeft().getId(), username); ticketCategoryRepository.findByEventId(event.getId()) .forEach(tc -> assertTrue(specialPriceRepository.findAllByCategoryId(tc.getId()).stream() .allMatch(sp -> sp.getStatus() == SpecialPrice.Status.TAKEN))); assertFalse(ticketRepository.findAllReservationsConfirmedButNotAssigned(event.getId()) .contains(data.getLeft().getId())); }
From source file:alfio.manager.EventManagerIntegrationTest.java
@Test(expected = IllegalArgumentException.class) public void testEventGenerationWithOverflow() { List<TicketCategoryModification> categories = Arrays.asList( 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), 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), 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)); Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository) .getKey();/* w w w . j av a2s . c om*/ List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId()); assertNotNull(tickets); assertFalse(tickets.isEmpty()); assertEquals(AVAILABLE_SEATS, tickets.size()); assertTrue(tickets.stream().noneMatch(t -> t.getCategoryId() == null)); }
From source file:electrical_parameters.CDER.java
public void printAll() { System.out.println("Cas generovania"); System.out.println(LocalTime.now()); System.out.println("R [Ohm/km]"); printRealMatrix(this.R_real); System.out.println("L [mH/km]"); printRealMatrix(this.L_real.scalarMultiply(1000)); // System.out.println("X [Ohm/km]"); // printRealMatrix(this.X_real); System.out.println("Rred [Ohm/km]"); printRealMatrix(this.R_red); System.out.println("Lred [mH/km]"); printRealMatrix(this.L_red.scalarMultiply(1000)); // System.out.println("Xred [Ohm/km]"); // printRealMatrix(this.X_red); // System.out.println("Zred [Ohm/km]"); // printComplexMatrix(this.Z_red); System.out.println("Rred_symm [Ohm/km]"); printSymmRealMatrix(this.R_red_symm); System.out.println("Lred_symm [mH/km]"); printSymmRealMatrix(this.L_red_symm.scalarMultiply(1000)); // System.out.println("Xred_symm [Ohm/km]"); // printSymmRealMatrix(this.X_red_symm); // System.out.println("Zred_symm [Ohm/km]"); // printSymmComplexMatrix(this.Z_red_symm); }
From source file:alfio.manager.system.DataMigratorIntegrationTest.java
@Test public void testAlreadyMigratedEvent() { 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> eventUsername = initEvent(categories); Event event = eventUsername.getKey(); try {//from w ww. j av a 2 s .com ZonedDateTime migrationTs = ZonedDateTime.now(ZoneId.of("UTC")); eventMigrationRepository.insertMigrationData(event.getId(), currentVersion, migrationTs, EventMigration.Status.COMPLETE.toString()); eventRepository.updatePrices("CHF", 40, false, BigDecimal.ONE, "STRIPE", event.getId(), PriceContainer.VatStatus.NOT_INCLUDED, 1000); dataMigrator.migrateEventsToCurrentVersion(); EventMigration eventMigration = eventMigrationRepository.loadEventMigration(event.getId()); assertNotNull(eventMigration); //assertEquals(migrationTs.toString(), eventMigration.getBuildTimestamp().toString()); assertEquals(currentVersion, eventMigration.getCurrentVersion()); List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId()); assertNotNull(tickets); assertFalse(tickets.isEmpty()); assertEquals(AVAILABLE_SEATS, tickets.size());//<-- the migration has not been done assertTrue(tickets.stream().allMatch(t -> t.getCategoryId() == null)); } finally { eventManager.deleteEvent(event.getId(), eventUsername.getValue()); } }
From source file:alfio.manager.WaitingQueueManagerIntegrationTest.java
@Test public void testWaitingQueueForUnboundedCategory() { 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)); Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository) .getKey();// w w w. jav a 2s.c o m TicketCategory unbounded = ticketCategoryRepository.findByEventId(event.getId()).get(0); TicketReservationModification tr = new TicketReservationModification(); tr.setAmount(AVAILABLE_SEATS); tr.setTicketCategoryId(unbounded.getId()); TicketReservationWithOptionalCodeModification mod = new TicketReservationWithOptionalCodeModification(tr, Optional.empty()); String reservationId = ticketReservationManager.createTicketReservation(event, Collections.singletonList(mod), Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.<String>empty(), Optional.<String>empty(), Locale.ENGLISH, false); TotalPrice reservationCost = ticketReservationManager.totalReservationCostWithVAT(reservationId); PaymentResult result = ticketReservationManager.confirm("", null, event, reservationId, "test@test.ch", new CustomerName("Full Name", "Full", "Name", event), Locale.ENGLISH, "", reservationCost, Optional.empty(), Optional.of(PaymentProxy.OFFLINE), false, null, null, null); assertTrue(result.isSuccessful()); assertEquals(0, eventRepository.findStatisticsFor(event.getId()).getDynamicAllocation()); }