List of usage examples for java.time LocalTime now
public static LocalTime now()
From source file:alfio.manager.EventManagerIntegrationTest.java
@Test public void testDecreaseRestrictedCategoryWithAlreadySentToken() { ensureMinimalConfiguration(configurationRepository); List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", 4, 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);/* www . j a va 2 s . 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()); specialPriceTokenGenerator.generatePendingCodesForCategory(category.getId()); List<SendCodeModification> linked = specialPriceManager.linkAssigneeToCode( Arrays.asList(new SendCodeModification(null, "test1", "test@test.com", "it"), new SendCodeModification(null, "test2", "test@test.com", "it")), event.getShortName(), category.getId(), username); specialPriceManager.sendCodeToAssignee(linked, event.getShortName(), category.getId(), username); TicketCategoryModification tcmOk = new TicketCategoryModification(category.getId(), category.getName(), 2, DateTimeModification.fromZonedDateTime(category.getUtcInception()), DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription, category.getPrice(), true, "", true, null, null, null, null, null); Result<TicketCategory> resOk = eventManager.updateCategory(category.getId(), event, tcmOk, username); Assert.assertTrue(resOk.isSuccess()); TicketCategoryModification tcm = new TicketCategoryModification(category.getId(), category.getName(), 1, DateTimeModification.fromZonedDateTime(category.getUtcInception()), DateTimeModification.fromZonedDateTime(category.getUtcExpiration()), categoryDescription, category.getPrice(), true, "", true, null, null, null, null, null); Result<TicketCategory> res = eventManager.updateCategory(category.getId(), event, tcm, username); Assert.assertFalse(res.isSuccess()); Assert.assertTrue(res.getErrors().contains(ErrorCode.CategoryError.NOT_ENOUGH_FREE_TOKEN_FOR_SHRINK)); }
From source file:alfio.manager.EventManagerIntegrationTest.java
@Test public void testNewBoundedCategoryWithExistingBoundedAndPendingTicket() { 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. java2s. co m Event event = pair.getLeft(); String username = pair.getRight(); assertEquals(new Integer(AVAILABLE_SEATS), ticketRepository.countFreeTicketsForUnbounded(event.getId())); TicketReservationModification trm = new TicketReservationModification(); trm.setAmount(1); trm.setTicketCategoryId(ticketCategoryRepository.findByEventId(event.getId()).get(0).getId()); TicketReservationWithOptionalCodeModification reservation = new TicketReservationWithOptionalCodeModification( trm, Optional.empty()); ticketReservationManager.createTicketReservation(event, Collections.singletonList(reservation), Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Optional.empty(), Locale.ENGLISH, false); TicketCategoryModification tcm = new TicketCategoryModification(null, "new", 1, DateTimeModification.fromZonedDateTime(ZonedDateTime.now()), DateTimeModification.fromZonedDateTime(ZonedDateTime.now().plusDays(1)), Collections.emptyMap(), BigDecimal.TEN, false, "", true, null, null, null, null, null); Result<Integer> insertResult = eventManager.insertCategory(event, tcm, username); assertTrue(insertResult.isSuccess()); Integer categoryID = insertResult.getData(); tcm = new TicketCategoryModification(categoryID, tcm.getName(), AVAILABLE_SEATS, tcm.getInception(), tcm.getExpiration(), tcm.getDescription(), tcm.getPrice(), false, "", true, null, null, null, null, null); Result<TicketCategory> result = eventManager.updateCategory(categoryID, event, tcm, username); assertFalse(result.isSuccess()); }
From source file:alfio.manager.EventManagerIntegrationTest.java
private Pair<Event, String> generateAndEditEvent(int newEventSize) { 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);//from w w w . ja v a 2 s . co m Event event = pair.getKey(); if (newEventSize != AVAILABLE_SEATS) { EventModification update = new EventModification(event.getId(), Event.EventType.INTERNAL, null, null, null, null, null, null, null, event.getOrganizationId(), null, null, null, event.getZoneId().toString(), Collections.emptyMap(), DateTimeModification.fromZonedDateTime(event.getBegin()), DateTimeModification.fromZonedDateTime(event.getEnd()), event.getRegularPrice(), event.getCurrency(), newEventSize, event.getVat(), event.isVatIncluded(), event.getAllowedPaymentProxies(), null, event.isFreeOfCharge(), null, 7, null, null); eventManager.updateEventPrices(event, update, pair.getValue()); } List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId()); assertNotNull(tickets); assertFalse(tickets.isEmpty()); assertEquals(AVAILABLE_SEATS, tickets.size()); if (newEventSize > AVAILABLE_SEATS) { assertEquals(newEventSize - AVAILABLE_SEATS, ticketRepository.countReleasedUnboundedTickets(event.getId()).intValue()); } assertEquals(10, tickets.stream().filter(t -> t.getCategoryId() != null).count()); return Pair.of(eventRepository.findById(event.getId()), pair.getRight()); }
From source file:org.apache.nifi.processors.orc.PutORCTest.java
@Test public void testWriteORCWithAvroLogicalTypes() throws IOException, InitializationException { final String avroSchema = IOUtils.toString( new FileInputStream("src/test/resources/user_logical_types.avsc"), StandardCharsets.UTF_8); schema = new Schema.Parser().parse(avroSchema); Calendar now = Calendar.getInstance(); LocalTime nowTime = LocalTime.now(); LocalDateTime nowDateTime = LocalDateTime.now(); LocalDate epoch = LocalDate.ofEpochDay(0); LocalDate nowDate = LocalDate.now(); final int timeMillis = nowTime.get(ChronoField.MILLI_OF_DAY); final Timestamp timestampMillis = Timestamp.valueOf(nowDateTime); final Date dt = Date.valueOf(nowDate); final double dec = 1234.56; configure(proc, 10, (numUsers, readerFactory) -> { for (int i = 0; i < numUsers; i++) { readerFactory.addRecord(i, timeMillis, timestampMillis, dt, dec); }/*from w ww .j a v a2s . c o m*/ return null; }); final String filename = "testORCWithDefaults-" + System.currentTimeMillis(); final Map<String, String> flowFileAttributes = new HashMap<>(); flowFileAttributes.put(CoreAttributes.FILENAME.key(), filename); testRunner.setProperty(PutORC.HIVE_TABLE_NAME, "myTable"); testRunner.enqueue("trigger", flowFileAttributes); testRunner.run(); testRunner.assertAllFlowFilesTransferred(PutORC.REL_SUCCESS, 1); final Path orcFile = new Path(DIRECTORY + "/" + filename); // verify the successful flow file has the expected attributes final MockFlowFile mockFlowFile = testRunner.getFlowFilesForRelationship(PutORC.REL_SUCCESS).get(0); mockFlowFile.assertAttributeEquals(PutORC.ABSOLUTE_HDFS_PATH_ATTRIBUTE, orcFile.getParent().toString()); mockFlowFile.assertAttributeEquals(CoreAttributes.FILENAME.key(), filename); mockFlowFile.assertAttributeEquals(PutORC.RECORD_COUNT_ATTR, "10"); // DDL will be created with field names normalized (lowercased, e.g.) for Hive by default mockFlowFile.assertAttributeEquals(PutORC.HIVE_DDL_ATTRIBUTE, "CREATE EXTERNAL TABLE IF NOT EXISTS `myTable` (`id` INT, `timemillis` INT, `timestampmillis` TIMESTAMP, `dt` DATE, `dec` DOUBLE) STORED AS ORC"); // verify we generated a provenance event final List<ProvenanceEventRecord> provEvents = testRunner.getProvenanceEvents(); assertEquals(1, provEvents.size()); // verify it was a SEND event with the correct URI final ProvenanceEventRecord provEvent = provEvents.get(0); assertEquals(ProvenanceEventType.SEND, provEvent.getEventType()); // If it runs with a real HDFS, the protocol will be "hdfs://", but with a local filesystem, just assert the filename. Assert.assertTrue(provEvent.getTransitUri().endsWith(DIRECTORY + "/" + filename)); // verify the content of the ORC file by reading it back in verifyORCUsers(orcFile, 10, (x, currUser) -> { assertEquals((int) currUser, ((IntWritable) x.get(0)).get()); assertEquals(timeMillis, ((IntWritable) x.get(1)).get()); assertEquals(timestampMillis, ((TimestampWritableV2) x.get(2)).getTimestamp().toSqlTimestamp()); final DateFormat noTimeOfDayDateFormat = new SimpleDateFormat("yyyy-MM-dd"); noTimeOfDayDateFormat.setTimeZone(TimeZone.getTimeZone("gmt")); assertEquals(noTimeOfDayDateFormat.format(dt), ((DateWritableV2) x.get(3)).get().toString()); assertEquals(dec, ((DoubleWritable) x.get(4)).get(), Double.MIN_VALUE); return null; }); // verify we don't have the temp dot file after success final File tempOrcFile = new File(DIRECTORY + "/." + filename); Assert.assertFalse(tempOrcFile.exists()); // verify we DO have the CRC file after success final File crcAvroORCFile = new File(DIRECTORY + "/." + filename + ".crc"); Assert.assertTrue(crcAvroORCFile.exists()); }
From source file:org.heliosphere.thot.akka.chat.client.TerminalActor.java
/** * Handles a {@code said} message./*from ww w. j av a 2 s .c o m*/ * <hr> * @param message Message to handle. */ private void handleSaid(final UserMessageProtocol.Said message) { output.printSay(LocalTime.now().toString(), message.getUser(), message.getMessage()); }
From source file:org.heliosphere.thot.akka.chat.client.TerminalActor.java
/** * Handles a {@code whispered} message.//from w w w. j a v a 2 s . c o m * <hr> * @param message Message to handle. */ private void handleWhispered(final UserMessageProtocol.Whispered message) { output.printWhisper(LocalTime.now().toString(), message.getUser(), message.getMessage(), message.getSender()); }
From source file:org.heliosphere.thot.akka.chat.tutorial.enumeration.client.actor.TerminalActor.java
/** * Handles and dispatch incoming application chat text message. * <hr>//from w ww . ja v a 2s.co m * @param message Incoming message to handle. */ @SuppressWarnings("incomplete-switch") protected void handleApplicationChatTextMessage(final IMessage message) { ITextMessage data = null; // Domain is: TestMessageProtocolDomain#MESSAGE switch ((TestMessageProtocol) message.getProtocol()) { case MESSAGE_DISCUSSION_SAID: data = (ITextMessage) message.getContent(); output.printSay(LocalTime.now().toString(), data.getSender().getFirstName(), data.getText()); break; case MESSAGE_DISCUSSION_WHISPERED: data = (ITextMessage) message.getContent(); output.printWhisper(LocalTime.now().toString(), data.getRecipient().getFirstName(), data.getText(), data.getSender().getFirstName()); break; default: break; } }
From source file:serposcope.controllers.admin.SettingsController.java
public Result settings() { String diskUsage = dbSizeUtils.getDbUsageFormatted(); String diskFree = dbSizeUtils.getDiskFreeFormatted(); return Results.ok().render("serverTime", LocalTime.now().format(HOUR_MINUTES)) .render("config", baseDB.config.getConfig()).render("diskUsage", diskUsage) .render("diskFree", diskFree).render("runs", baseDB.run.count()); }