Example usage for java.time LocalTime now

List of usage examples for java.time LocalTime now

Introduction

In this page you can find the example usage for java.time LocalTime now.

Prototype

public static LocalTime now() 

Source Link

Document

Obtains the current time from the system clock in the default time-zone.

Usage

From source file:alfio.manager.EventManagerIntegrationTest.java

@Test
public void testEventGeneration() {
    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));
    Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository)
            .getKey();// w w  w . ja  v a2 s.c  o m
    List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
    assertNotNull(tickets);
    assertFalse(tickets.isEmpty());
    assertEquals(AVAILABLE_SEATS, tickets.size());
    assertEquals(10, tickets.stream().filter(t -> t.getCategoryId() == null).count());
}

From source file:alfio.manager.AdminReservationManagerIntegrationTest.java

@Test
public void testReserveFromExistingCategoryNotEnoughSeatsNotBounded() 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, "",
            false, null, null, null, null, null));
    performExistingCategoryTest(categories, false, Collections.singletonList(1), false, true, 0,
            AVAILABLE_SEATS);/*w ww  . j  a  v  a  2  s  . c  o m*/
}

From source file:alfio.manager.system.DataMigratorIntegrationTest.java

private Pair<Event, String> initEvent(List<TicketCategoryModification> categories, String displayName) {
    String organizationName = UUID.randomUUID().toString();
    String username = UUID.randomUUID().toString();
    String eventName = UUID.randomUUID().toString();

    organizationRepository.create(organizationName, "org", "email@example.com");
    Organization organization = organizationRepository.findByName(organizationName).get();
    userManager.insertUser(organization.getId(), username, "test", "test", "test@example.com", Role.OPERATOR,
            User.Type.INTERNAL);

    Map<String, String> desc = new HashMap<>();
    desc.put("en", "muh description");
    desc.put("it", "muh description");
    desc.put("de", "muh description");

    EventModification em = new EventModification(null, Event.EventType.INTERNAL, "url", "url", "url", null,
            null, eventName, displayName, organization.getId(), "muh location", "0.0", "0.0",
            ZoneId.systemDefault().getId(), desc,
            new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()),
            new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now().plusHours(1)), BigDecimal.TEN,
            "CHF", AVAILABLE_SEATS, BigDecimal.ONE, true, null, categories, false,
            new LocationDescriptor("", "", "", ""), 7, null, null);
    eventManager.createEvent(em);// w w  w.j a va2  s . com
    return Pair.of(eventManager.getSingleEvent(eventName, username), username);
}

From source file:alfio.manager.EventManagerIntegrationTest.java

@Test
public void testUnboundedEventGeneration() {
    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));
    Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository)
            .getKey();/*from ww w.j  av a 2 s.  c  o  m*/
    List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
    assertNotNull(tickets);
    assertFalse(tickets.isEmpty());
    assertEquals(AVAILABLE_SEATS, tickets.size());
    assertEquals(AVAILABLE_SEATS, tickets.stream().filter(t -> t.getCategoryId() == null).count());
    List<TicketCategory> ticketCategories = ticketCategoryRepository.findByEventId(event.getId());
    assertEquals(1, ticketCategories.size());
    assertEquals(0, ticketCategories.get(0).getMaxTickets());
}

From source file:alfio.manager.AdminReservationManagerIntegrationTest.java

@Test
public void testReserveExistingCategoryNotEnoughSeatsNotBoundedSoldOut() 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, "",
            false, null, null, null, null, null));
    performExistingCategoryTest(categories, false, Collections.singletonList(1), true, true, AVAILABLE_SEATS,
            AVAILABLE_SEATS + 1);/* w  w  w  .j a  v a2  s . c o m*/
}

From source file:electrical_parameters.Carson.java

public void printAll() {
    System.out.println("Cas generovania");
    System.out.println(LocalTime.now());
    System.out.println("Rg [Ohm/km]");
    //        printRealMatrix(this.Rg);
    //        System.out.println("Lg [mH/km]");
    //        printRealMatrix(this.Lg.scalarMultiply(1000));
    //        System.out.println("Xg [Ohm/km]");
    //        printRealMatrix(this.Xg);
    //        /*from  w  w  w . j  a v a2s . c om*/
    //        System.out.println("R_no_gnd [Ohm/km]");
    //        printRealMatrix(this.R_no_gnd);
    //        System.out.println("L_no_gnd [mH/km]");
    //        printRealMatrix(this.L_no_gnd.scalarMultiply(1000));
    //        System.out.println("X_no_gnd [Ohm/km]");
    //        printRealMatrix(this.X_no_gnd);
    //        System.out.println("Z_no_gnd [Ohm/km]");
    //        printComplexMatrix(this.Z_no_gnd);

    System.out.println("R_gnd [Ohm/km]");
    printRealMatrix(this.R_gnd);
    System.out.println("L_gnd [mH/km]");
    printRealMatrix(this.L_gnd.scalarMultiply(1000));
    //        System.out.println("X_gnd [Ohm/km]");
    //        printRealMatrix(this.X_gnd);
    //        System.out.println("Z_gnd [Ohm/km]");
    //        printComplexMatrix(this.Z_gnd);

    //        System.out.println("Rred_no_gnd [Ohm/km]");
    //        printRealMatrix(this.R_red_no_gnd);
    //        System.out.println("Lred_no_gnd [mH/km]");
    //        printRealMatrix(this.L_red_no_gnd.scalarMultiply(1000));
    //        System.out.println("Xred_no_gnd [Ohm/km]");
    //        printRealMatrix(this.X_red_no_gnd);
    //        System.out.println("Zred_no_gnd [Ohm/km]");
    //        printComplexMatrix(this.Z_red_no_gnd);

    System.out.println("Rred_gnd [Ohm/km]");
    printRealMatrix(this.R_red_gnd);
    System.out.println("Lred_gnd [mH/km]");
    printRealMatrix(this.L_red_gnd.scalarMultiply(1000));
    //        System.out.println("Xred_gnd [Ohm/km]");
    //        printRealMatrix(this.X_red_gnd);
    //        System.out.println("Zred_gnd [Ohm/km]");
    //        printComplexMatrix(this.Z_red_gnd);

    //        System.out.println("Rred_no_gnd_symm [Ohm/km]");
    //        printRealMatrix(this.R_red_no_gnd_symm);
    //        System.out.println("Lred_no_gnd_symm [mH/km]");
    //        printRealMatrix(this.L_red_no_gnd_symm.scalarMultiply(1000));
    //        System.out.println("Xred_no_gnd_symm [Ohm/km]");
    //        printRealMatrix(this.X_red_no_gnd_symm);
    //        System.out.println("Zred_no_gnd_symm [Ohm/km]");
    //        printComplexMatrix(this.Z_red_no_gnd_symm);

    System.out.println("Rred_gnd_symm [Ohm/km]");
    printSymmRealMatrix(this.R_red_gnd_symm);
    System.out.println("Lred_gnd_symm [mH/km]");
    printSymmRealMatrix(this.L_red_gnd_symm.scalarMultiply(1000));
    //        System.out.println("Xred_gnd_symm [Ohm/km]");
    //        printRealMatrix(this.X_red_gnd_symm);
    //        System.out.println("Zred_gnd_symm [Ohm/km]");
    //        printComplexMatrix(this.Z_red_gnd_symm);

}

From source file:alfio.manager.TicketReservationManagerIntegrationTest.java

@Test
public void testTicketSelection() {
    List<TicketCategoryModification> categories = Arrays.asList(
            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),
            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> eventAndUsername = initEvent(categories, organizationRepository, userManager,
            eventManager, eventRepository);
    Event event = eventAndUsername.getKey();

    TicketCategory bounded = ticketCategoryRepository.findByEventId(event.getId()).stream()
            .filter(TicketCategory::isBounded).findFirst().orElseThrow(IllegalStateException::new);
    TicketCategory unbounded = ticketCategoryRepository.findByEventId(event.getId()).stream()
            .filter(t -> !t.isBounded()).findFirst().orElseThrow(IllegalStateException::new);

    assertEquals(0, eventStatisticsManager.loadModifiedTickets(event.getId(), bounded.getId(), 0, null).size());
    assertEquals(Integer.valueOf(0),
            eventStatisticsManager.countModifiedTicket(event.getId(), bounded.getId(), null));
    assertEquals(0,/*from w  ww . j  a  v  a 2 s. c om*/
            eventStatisticsManager.loadModifiedTickets(event.getId(), unbounded.getId(), 0, null).size());

    TicketReservationModification tr = new TicketReservationModification();
    tr.setAmount(10);
    tr.setTicketCategoryId(bounded.getId());

    TicketReservationModification tr2 = new TicketReservationModification();
    tr2.setAmount(9);
    tr2.setTicketCategoryId(unbounded.getId());

    TicketReservationWithOptionalCodeModification mod = new TicketReservationWithOptionalCodeModification(tr,
            Optional.empty());
    TicketReservationWithOptionalCodeModification mod2 = new TicketReservationWithOptionalCodeModification(tr2,
            Optional.empty());
    String reservationId = ticketReservationManager.createTicketReservation(event, Arrays.asList(mod, mod2),
            Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Optional.empty(),
            Locale.ENGLISH, false);

    List<TicketReservation> reservations = ticketReservationManager
            .findAllReservationsInEvent(event.getId(), 0, null, null).getKey();
    assertTrue(reservations.size() == 1);
    assertEquals(reservationId, reservations.get(0).getId());

    List<Ticket> pendingTickets = ticketRepository
            .findPendingTicketsInCategories(Arrays.asList(bounded.getId(), unbounded.getId()));
    assertEquals(19, pendingTickets.size());
    pendingTickets.forEach(t -> assertEquals(1000, t.getFinalPriceCts()));
    List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
    assertEquals(1, tickets.size());
    assertTrue(tickets.stream().allMatch(t -> t.getCategoryId() == null));

    TotalPrice totalPrice = ticketReservationManager.totalReservationCostWithVAT(reservationId);

    assertEquals(0, ticketReservationManager.getPendingPayments(event).size());

    PaymentResult confirm = ticketReservationManager.confirm(null, null, event, reservationId,
            "email@example.com", new CustomerName("full name", "full", "name", event), Locale.ENGLISH,
            "billing address", totalPrice, Optional.empty(), Optional.of(PaymentProxy.OFFLINE), false, null,
            null, null);

    assertTrue(confirm.isSuccessful());

    assertEquals(TicketReservation.TicketReservationStatus.OFFLINE_PAYMENT,
            ticketReservationManager.findById(reservationId).get().getStatus());

    assertEquals(1, ticketReservationManager.getPendingPayments(event).size());

    Date now = new Date();
    Date from = DateUtils.addDays(now, -1);
    Date to = DateUtils.addDays(now, 1);

    assertTrue(ticketReservationRepository.getSoldStatistic(event.getId(), from, to).isEmpty()); // -> no reservations
    ticketReservationManager.validateAndConfirmOfflinePayment(reservationId, event, new BigDecimal("190.00"),
            eventAndUsername.getValue());

    assertEquals(19,
            ticketReservationRepository.getSoldStatistic(event.getId(), from, to).get(0).getTicketSoldCount()); // -> 19 tickets reserved

    assertEquals(10,
            eventStatisticsManager.loadModifiedTickets(event.getId(), bounded.getId(), 0, null).size());
    assertEquals(Integer.valueOf(10),
            eventStatisticsManager.countModifiedTicket(event.getId(), bounded.getId(), null));
    assertEquals(9,
            eventStatisticsManager.loadModifiedTickets(event.getId(), unbounded.getId(), 0, null).size());
    assertEquals(Integer.valueOf(9),
            eventStatisticsManager.countModifiedTicket(event.getId(), unbounded.getId(), null));

    assertEquals(TicketReservation.TicketReservationStatus.COMPLETE,
            ticketReservationManager.findById(reservationId).get().getStatus());

    //-------------------

    TicketReservationModification trForDelete = new TicketReservationModification();
    trForDelete.setAmount(1);
    trForDelete.setTicketCategoryId(unbounded.getId());
    TicketReservationWithOptionalCodeModification modForDelete = new TicketReservationWithOptionalCodeModification(
            trForDelete, Optional.empty());
    String reservationId2 = ticketReservationManager.createTicketReservation(event,
            Collections.singletonList(modForDelete), Collections.emptyList(), DateUtils.addDays(new Date(), 1),
            Optional.empty(), Optional.empty(), Locale.ENGLISH, false);

    ticketReservationManager.confirm(null, null, event, reservationId2, "email@example.com",
            new CustomerName("full name", "full", "name", event), Locale.ENGLISH, "billing address", totalPrice,
            Optional.empty(), Optional.of(PaymentProxy.OFFLINE), false, null, null, null);

    assertTrue(ticketReservationManager.findById(reservationId2).isPresent());

    ticketReservationManager.deleteOfflinePayment(event, reservationId2, false);

    Assert.assertFalse(ticketReservationManager.findById(reservationId2).isPresent());
}

From source file:alfio.manager.system.DataMigratorIntegrationTest.java

@Test
public void testMigration() {
    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 a v  a  2s .  c  o  m*/
        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(AVAILABLE_SEATS, 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 testReserveFromExistingCategoryNotEnoughSeatsBounded() 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));
    performExistingCategoryTest(categories, true, Collections.singletonList(2), false, true, 0,
            AVAILABLE_SEATS);// ww w  .j  a  va  2 s  .  c o m
}

From source file:alfio.manager.EventManagerIntegrationTest.java

@Test
public void testEventGenerationWithUnboundedCategory() {
    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", 9,
                    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();//from ww  w .  j  av a 2 s.  c  o  m
    List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
    assertNotNull(tickets);
    assertFalse(tickets.isEmpty());
    assertEquals(AVAILABLE_SEATS, tickets.size());
    assertEquals(1, tickets.stream().filter(t -> t.getCategoryId() == null).count());
}