public void registerConfigProducer(@Observes AfterBeanDiscovery abd, BeanManager bm) { // excludes type that are already produced by ConfigProducer Set<Class> types = injectionPoints.stream() .filter(ip -> ip.getType() instanceof Class && ip.getType() != String.class && ip.getType() != Boolean.class && ip.getType() != Boolean.TYPE && ip.getType() != Integer.class && ip.getType() != Integer.TYPE && ip.getType() != Long.class && ip.getType() != Long.TYPE && ip.getType() != Float.class && ip.getType() != Float.TYPE && ip.getType() != Double.class && ip.getType() != Double.TYPE && ip.getType() != Duration.class && ip.getType() != LocalDate.class && ip.getType() != LocalTime.class && ip.getType() != LocalDateTime.class) .map(ip -> (Class) ip.getType()) .collect(Collectors.toSet()); types.forEach(type -> abd.addBean(new ConfigInjectionBean(bm, type))); }
@Test(dataProvider="calendars") public void test_badWithAdjusterChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalAdjuster adjuster = new FixedAdjuster(cdt2); if (chrono != chrono2) { try { cdt.with(adjuster); Assert.fail("WithAdjuster should have thrown a ClassCastException, " + "required: " + cdt + ", supplied: " + cdt2); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoLocalDateTime<?> result = cdt.with(adjuster); assertEquals(result, cdt2, "WithAdjuster failed to replace date"); } } }
@Override @SuppressWarnings("InfiniteLoopStatement") public void run() { while (true) { Platform.runLater(() -> { calendarView.setToday(LocalDate.now()); calendarView.setTime(LocalTime.now()); }); try { sleep(TEN_SECONDS); } catch (InterruptedException e) { // Do nothing } } }
@Test(dataProvider="resolveMinuteOfDay") public void test_resolveMinuteOfDay(ResolverStyle style, long value, Integer expectedMinute, int expectedDays) { String str = Long.toString(value); DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(MINUTE_OF_DAY).toFormatter(); if (expectedMinute != null) { TemporalAccessor accessor = f.withResolverStyle(style).parse(str); assertEquals(accessor.query(TemporalQueries.localDate()), null); assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.ofSecondOfDay(expectedMinute * 60)); assertEquals(accessor.query(DateTimeFormatter.parsedExcessDays()), Period.ofDays(expectedDays)); } else { try { f.withResolverStyle(style).parse(str); fail(); } catch (DateTimeParseException ex) { // expected } } }
public static void main(String[] args) { // Hours, minutes LocalTime timeHrsMin = LocalTime.of(12, 12); // Hours, minutes and seconds LocalTime timeHrsMinSec = LocalTime.of(0, 12, 6); // Hours, minutes, seconds and nanoseconds LocalTime timeHrsMinSecNano = LocalTime.of(14, 7, 10, 998654578); // DateTimeException //LocalTime timeHrsMin1 = LocalTime.of(120, 12);// Runtime exception //LocalTime timeHrsMin2 = LocalTime.of(9986545781, 12);// Compilation error // To get the current time from the system clock, use the static method now() LocalTime date3 = LocalTime.now(); // Parse a string to instantiate LocalTime by using its static method parse() LocalTime time = LocalTime.parse("15:08:23"); }
@Test(dataProvider="calendars") public void test_badPlusTemporalUnitChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoLocalDateTime<?> cdt = chrono.date(refDate).atTime(LocalTime.NOON); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoLocalDateTime<?> cdt2 = chrono2.date(refDate).atTime(LocalTime.NOON); TemporalUnit adjuster = new FixedTemporalUnit(cdt2); if (chrono != chrono2) { try { cdt.plus(1, adjuster); Assert.fail("TemporalUnit.doPlus plus should have thrown a ClassCastException" + cdt + ", can not be cast to " + cdt2); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoLocalDateTime<?> result = cdt.plus(1, adjuster); assertEquals(result, cdt2, "WithAdjuster failed to replace date"); } } }
@Test(dataProvider="calendars") public void test_badTemporalFieldChrono(Chronology chrono) { LocalDate refDate = LocalDate.of(2013, 1, 1); ChronoZonedDateTime<?> czdt = chrono.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); for (Chronology[] clist : data_of_calendars()) { Chronology chrono2 = clist[0]; ChronoZonedDateTime<?> czdt2 = chrono2.date(refDate).atTime(LocalTime.NOON).atZone(ZoneOffset.UTC); TemporalField adjuster = new FixedTemporalField(czdt2); if (chrono != chrono2) { try { czdt.with(adjuster, 1); Assert.fail("TemporalField doWith() should have thrown a ClassCastException, " + czdt.getClass() + " can not be cast to " + czdt2.getClass()); } catch (ClassCastException cce) { // Expected exception; not an error } } else { // Same chronology, ChronoZonedDateTime<?> result = czdt.with(adjuster, 1); assertEquals(result, czdt2, "TemporalField doWith() failed to replace date"); } } }
@Test(dataProvider = "fields") public void test_WBY_isSupportedBy(TemporalField weekField, TemporalField yearField) { assertEquals(yearField.isSupportedBy(LocalTime.NOON), false); assertEquals(yearField.isSupportedBy(MonthDay.of(2, 1)), false); assertEquals(yearField.isSupportedBy(LocalDate.MIN), true); assertEquals(yearField.isSupportedBy(OffsetDateTime.MAX), true); }
@DataProvider(name="unitAndTemporal") Object[][] data_unitAndTemporal() { return new Object[][] { {CENTURIES, LocalDate.of(2000, 1, 10), true, 1, LocalDate.of(2100, 1, 10)}, {DECADES, LocalDate.of(2000, 1, 10), true, 1, LocalDate.of(2010, 1, 10)}, {YEARS, LocalDate.of(2000, 1, 10), true, 1, LocalDate.of(2001, 1, 10)}, {MONTHS, LocalDate.of(2000, 1, 10), true, 1, LocalDate.of(2000, 2, 10)}, {WEEKS, LocalDate.of(2000, 1, 10), true, 1, LocalDate.of(2000, 1, 17)}, {DAYS, LocalDate.of(2000, 1, 10), true, 1, LocalDate.of(2000, 1, 11)}, {HALF_DAYS, LocalTime.of(1, 2, 3, 400), true, 1, LocalTime.of(13, 2, 3, 400)}, {HOURS, LocalTime.of(1, 2, 3, 400), true, 1, LocalTime.of(2, 2, 3, 400)}, {MINUTES, LocalTime.of(1, 2, 3, 400), true, 1, LocalTime.of(1, 3, 3, 400)}, {SECONDS, LocalTime.of(1, 2, 3, 400), true, 1, LocalTime.of(1, 2, 4, 400)}, {MICROS, LocalTime.of(1, 2, 3, 400), true, 1, LocalTime.of(1, 2, 3, 1000 + 400)}, {MILLIS, LocalTime.of(1, 2, 3, 400), true, 1, LocalTime.of(1, 2, 3, 1000*1000 + 400)}, {NANOS, LocalTime.of(1, 2, 3, 400), true, 1, LocalTime.of(1, 2, 3, 1 + 400)}, {CENTURIES, LocalTime.of(1, 2, 3, 400), false, 1, null}, {DECADES, LocalTime.of(1, 2, 3, 400), false, 1, null}, {YEARS, LocalTime.of(1, 2, 3, 400), false, 1, null}, {MONTHS, LocalTime.of(1, 2, 3, 400), false, 1, null}, {WEEKS, LocalTime.of(1, 2, 3, 400), false, 1, null}, {DAYS, LocalTime.of(1, 2, 3, 400), false, 1, null}, {HALF_DAYS, LocalDate.of(2000, 2, 29), false, 1, null}, {HOURS, LocalDate.of(2000, 2, 29), false, 1, null}, {MINUTES, LocalDate.of(2000, 2, 29), false, 1, null}, {SECONDS, LocalDate.of(2000, 2, 29), false, 1, null}, {MICROS, LocalDate.of(2000, 2, 29), false, 1, null}, {MILLIS, LocalDate.of(2000, 2, 29), false, 1, null}, {NANOS, LocalDate.of(2000, 2, 29), false, 1, null}, }; }
/** * used for logging significant (unexpected) errors (level 1) * @param caller the java class from which the command is called * @param error the error */ public static void exception(Class caller, Throwable error) { if(Main.getBotSettingsManager().getLogLevel() < 1) return; String now = LocalTime.now().truncatedTo(ChronoUnit.SECONDS).format(DateTimeFormatter.ISO_LOCAL_TIME); String content = "[" + now + "] " + ANSI_PURPLE + "[Excp]" + ANSI_RESET + " " + ANSI_PURPLE_BACKGROUND + ANSI_BLACK + "[" + caller.getSimpleName() + "]" + ANSI_RESET + " " + ANSI_PURPLE + error.getMessage() + ANSI_RESET; System.out.println(content); error.printStackTrace(); }
@Test public void factory_time_4ints_singletons() { for (int i = 0; i < 24; i++) { LocalTime test1 = LocalTime.of(i, 0, 0, 0); LocalTime test2 = LocalTime.of(i, 0, 0, 0); assertSame(test1, test2); } }
@Test public void now_Clock_allSecsInDay() { for (int i = 0; i < (2 * 24 * 60 * 60); i++) { Instant instant = Instant.ofEpochSecond(i, 8); Clock clock = Clock.fixed(instant, ZoneOffset.UTC); LocalTime test = LocalTime.now(clock); assertEquals(test.getHour(), (i / (60 * 60)) % 24); assertEquals(test.getMinute(), (i / 60) % 60); assertEquals(test.getSecond(), i % 60); assertEquals(test.getNano(), 8); } }
public ZonedDateTime getZonedDateTimeAt(double x, double y) { Point2D location = getSkinnable().localToScreen(x, y); for (MonthDayView view : controlsMap.values()) { if (view.localToScreen(view.getLayoutBounds()).contains(location)) { return ZonedDateTime.of(view.getDate(), LocalTime.NOON, getSkinnable().getZoneId()); } } return null; }
@Test public void test_toNanoOfDay() { LocalTime t = LocalTime.of(0, 0); for (int i = 0; i < 1000000; i++) { assertEquals(t.toNanoOfDay(), i); t = t.plusNanos(1); } t = LocalTime.of(0, 0); for (int i = 1; i <= 1000000; i++) { t = t.minusNanos(1); assertEquals(t.toNanoOfDay(), 24 * 60 * 60 * 1000000000L - i); } }
private void updateFields() { updatingFields = true; TimeField timeField = getSkinnable(); LocalTime localTime = timeField.getValue(); if (localTime != null) { hourField.setText(Integer.toString(localTime.getHour())); minuteField.setText(Integer.toString(localTime.getMinute())); } else { hourField.setText(""); minuteField.setText(""); } updatingFields = false; }
@Test public void testDateJava8() throws ParseException, PebbleException, IOException { PebbleEngine pebble = new PebbleEngine .Builder() .loader(new StringLoader()) .strictVariables(false) .defaultLocale(Locale.ENGLISH) .build(); final LocalDateTime localDateTime = LocalDateTime.of(2017, 6, 30, 13, 30, 35, 0); final ZonedDateTime zonedDateTime = ZonedDateTime.of(localDateTime, ZoneId.of("GMT+0100")); final LocalDate localDate = localDateTime.toLocalDate(); final LocalTime localTime = localDateTime.toLocalTime(); StringBuilder source = new StringBuilder(); source .append("{{ localDateTime | date }}") .append("{{ localDateTime | date('yyyy-MM-dd HH:mm:ss') }}") .append("{{ zonedDateTime | date('yyyy-MM-dd HH:mm:ssXXX') }}") .append("{{ localDate | date('yyyy-MM-dd') }}") .append("{{ localTime | date('HH:mm:ss') }}"); PebbleTemplate template = pebble.getTemplate(source.toString()); Map<String, Object> context = new HashMap<>(); context.put("localDateTime", localDateTime); context.put("zonedDateTime", zonedDateTime); context.put("localDate", localDate); context.put("localTime", localTime); Writer writer = new StringWriter(); template.evaluate(writer, context); assertEquals("2017-06-30T13:30:352017-06-30 13:30:352017-06-30 13:30:35+01:002017-06-3013:30:35", writer.toString()); }
@Test public void test_serialization_format_hm() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(baos) ) { dos.writeByte(4); dos.writeByte(22); dos.writeByte(-1 - 17); } byte[] bytes = baos.toByteArray(); assertSerializedBySer(LocalTime.of(22, 17), bytes); }
/** * Constructor. * * @param date the date part of the date-time, not null * @param time the time part of the date-time, not null */ private ChronoLocalDateTimeImpl(D date, LocalTime time) { Objects.requireNonNull(date, "date"); Objects.requireNonNull(time, "time"); this.date = date; this.time = time; }
@Test public void test_with_longTemporalField_minuteOfDay() { for (long i : testPoints(24 * 60)) { LocalTime test = TEST_12_30_40_987654321.with(MINUTE_OF_DAY, i); assertEquals(test.get(MINUTE_OF_DAY), i); assertEquals(test.get(SECOND_OF_MINUTE), TEST_12_30_40_987654321.get(SECOND_OF_MINUTE)); assertEquals(test.get(NANO_OF_SECOND), TEST_12_30_40_987654321.get(NANO_OF_SECOND)); } }
@Test public void testDateTimePointFilter_0640_30() throws ParseException { TimePointFilter instance = new TimePointFilter(LocalTime.parse("06:40"),30); FilterResult result = instance.filter(data); List<VaultEntry> filteredData = new ArrayList<>(); filteredData.add(new VaultEntry(VaultEntryType.SLEEP_LIGHT, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:13"), 9.0)); filteredData.add(new VaultEntry(VaultEntryType.HEART_RATE, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:16"), 66.0)); filteredData.add(new VaultEntry(VaultEntryType.HEART_RATE_VARIABILITY, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:16"), 50.0, 93.0)); filteredData.add(new VaultEntry(VaultEntryType.STRESS, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:16"), 30.25)); filteredData.add(new VaultEntry(VaultEntryType.SLEEP_LIGHT, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:22"), 7.0)); filteredData.add(new VaultEntry(VaultEntryType.STRESS, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:26"), 27.25)); filteredData.add(new VaultEntry(VaultEntryType.HEART_RATE_VARIABILITY, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:26"), 50.0, 97.0)); filteredData.add(new VaultEntry(VaultEntryType.HEART_RATE, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:26"), 62.0)); filteredData.add(new VaultEntry(VaultEntryType.SLEEP_DEEP, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:29"), 11.0)); filteredData.add(new VaultEntry(VaultEntryType.HEART_RATE, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:36"), 63.0)); filteredData.add(new VaultEntry(VaultEntryType.HEART_RATE_VARIABILITY, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:36"), 50.0, 98.0)); filteredData.add(new VaultEntry(VaultEntryType.STRESS, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:36"), 26.5)); filteredData.add(new VaultEntry(VaultEntryType.SLEEP_LIGHT, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:40"), 15.0)); filteredData.add(new VaultEntry(VaultEntryType.HEART_RATE, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:46"), 58.0)); filteredData.add(new VaultEntry(VaultEntryType.HEART_RATE_VARIABILITY, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:46"), 50.0, 97.0)); filteredData.add(new VaultEntry(VaultEntryType.STRESS, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:46"), 27.25)); filteredData.add(new VaultEntry(VaultEntryType.SLEEP_DEEP, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:55"), 27.0)); filteredData.add(new VaultEntry(VaultEntryType.HEART_RATE, TestFunctions.creatNewDateToCheckFor("2017.06.29-06:56"), 59.0)); filteredData.add(new VaultEntry(VaultEntryType.BASAL_PROFILE, TestFunctions.creatNewDateToCheckFor("2017.06.29-07:00"), 1.15)); filteredData.add(new VaultEntry(VaultEntryType.HEART_RATE, TestFunctions.creatNewDateToCheckFor("2017.06.29-07:06"), 56.0)); List<Pair<Date, Date>> timeSeries = new ArrayList<>(); timeSeries.add(new Pair<>(TestFunctions.creatNewDateToCheckFor("2017.06.29-06:13"), TestFunctions.creatNewDateToCheckFor("2017.06.29-07:06"))); FilterResult checkForThisResult = new FilterResult(filteredData, timeSeries); assertEquals(result.filteredData, checkForThisResult.filteredData); assertEquals(result.timeSeries, checkForThisResult.timeSeries); //assertEquals(result, checkForThisResult); }
/** * Test of filter method, of class EventFilter. * * @author juehv, aa80hifa */ @Test public void testCombinationFilter() throws ParseException { Filter firstFilter = new EventFilter(VaultEntryType.HEART_RATE); Filter secondFilter = new TimePointFilter(LocalTime.MIN, 1); List<VaultEntry> data = StaticDataset.getStaticDataset(); Filter combinationFilter = new CombinationFilter(data, firstFilter, secondFilter); FilterResult result = combinationFilter.filter(data); System.out.println(result.size()); }
@Test public void test_with_longTemporalField_secondOfMinute() { for (long i : testPoints(60L)) { LocalTime test = TEST_12_30_40_987654321.with(SECOND_OF_MINUTE, i); assertEquals(test.get(SECOND_OF_MINUTE), i); assertEquals(test.get(HOUR_OF_DAY), TEST_12_30_40_987654321.get(HOUR_OF_DAY)); assertEquals(test.get(MINUTE_OF_HOUR), TEST_12_30_40_987654321.get(MINUTE_OF_HOUR)); assertEquals(test.get(NANO_OF_SECOND), TEST_12_30_40_987654321.get(NANO_OF_SECOND)); } }
@Test public void test_toSecondOfDay_fromNanoOfDay_symmetry() { LocalTime t = LocalTime.of(0, 0); for (int i = 0; i < 24 * 60 * 60; i++) { assertEquals(LocalTime.ofSecondOfDay(t.toSecondOfDay()), t); t = t.plusSeconds(1); } }
@Listener public void onOpened(PlayerOpenedCrateEvent event) { Player player = event.getPlayer(); Manager manager = event.getManager(); Drop drop = event.getDrop(); if (manager.isSendOpenMessage()) { Optional<String> optional_custom_open_message = manager.getCustomOpenMessage(); if (optional_custom_open_message.isPresent()) { player.sendMessage(TextSerializers.FORMATTING_CODE. deserialize(optional_custom_open_message.get(). replace("%MANAGER%", manager.getName()))); } else { player.sendMessage(LanguageUtils.getText("SUCCESSFULLY_OPENED_MANAGER", new Pair<String, String>("%MANAGER%", manager.getName()))); } } if (GWMCrates.getInstance().isLogOpenedCrates()) { try { String time = LocalTime.now().withNano(0).format(DateTimeFormatter.ISO_LOCAL_TIME); String player_name = player.getName(); String player_uuid = player.getUniqueId().toString(); String manager_name = manager.getName(); String manager_id = manager.getId(); String drop_name = drop == null ? "null" : drop.getId().orElse("Unknown ID"); Location<World> location = player.getLocation(); String player_location = location.getExtent().getName() + ' ' + location.getBlockX() + ' ' + location.getBlockY() + ' ' + location.getBlockZ(); LOG_FILE_WRITER.write(LanguageUtils.getPhrase("CRATE_OPENING_LOG_MESSAGE", new Pair("%TIME%", time), new Pair("%PLAYER%", player_name), new Pair("%PLAYER_UUID%", player_uuid), new Pair("%MANAGER_NAME%", manager_name), new Pair("%MANAGER_ID%", manager_id), new Pair("%DROP%", drop_name), new Pair("%LOCATION%", player_location)) + '\n'); LOG_FILE_WRITER.flush(); } catch (Exception e) { GWMCrates.getInstance().getLogger().warn("Exception logging crate opening!", e); } } }
@Test public void test_with_longTemporalField_secondOfDay() { for (long i : testPoints(24 * 60 * 60)) { LocalTime test = TEST_12_30_40_987654321.with(SECOND_OF_DAY, i); assertEquals(test.get(SECOND_OF_DAY), i); assertEquals(test.get(NANO_OF_SECOND), TEST_12_30_40_987654321.get(NANO_OF_SECOND)); } }
public TimeScaleViewSkin(T view) { super(view); LocalTime time = LocalTime.of(1, 0); for (int i = 1; i < 24; i++) { Label label = new Label(time.format(formatter)); label.setManaged(false); label.setMaxWidth(Double.MAX_VALUE); label.setAlignment(Pos.CENTER_RIGHT); label.getStyleClass().add("time-label"); //$NON-NLS-1$ label.setTextOverrun(OverrunStyle.CLIP); labels.add(label); getChildren().add(label); time = time.plusHours(1); } currentTimeLabel = new Label(); currentTimeLabel.getStyleClass().add("current-time-label"); //$NON-NLS-1$ currentTimeLabel.setManaged(false); currentTimeLabel.setMaxWidth(Double.MAX_VALUE); currentTimeLabel.setAlignment(Pos.CENTER_RIGHT); currentTimeLabel.setOpacity(0); currentTimeLabel.setTextOverrun(OverrunStyle.CLIP); currentTimeLabel.visibleProperty().bind(view.enableCurrentTimeMarkerProperty()); getChildren().add(currentTimeLabel); updateCurrentTimeMarkerVisibility(); view.showCurrentTimeMarkerProperty().addListener( it -> updateCurrentTimeMarkerVisibility()); setupCurrentTimeMarkerSupport(); updateShowMarkers(); }
@Test public void constructor() { final AuctionType auctionType = fixture.create(AuctionType.class); final BigDecimal pairedShares = fixture.create(BigDecimal.class); final BigDecimal imbalanceShares = fixture.create(BigDecimal.class); final BigDecimal referencePrice = fixture.create(BigDecimal.class); final BigDecimal indicativePrice = fixture.create(BigDecimal.class); final BigDecimal auctionBookPrice = fixture.create(BigDecimal.class); final BigDecimal collarReferencePrice = fixture.create(BigDecimal.class); final BigDecimal lowerCollarPrice = fixture.create(BigDecimal.class); final BigDecimal upperCollarPrice = fixture.create(BigDecimal.class); final BigDecimal extensionNumber = fixture.create(BigDecimal.class); final LocalTime startTime = fixture.create(LocalTime.class); final Long lastUpdate = fixture.create(Long.class); final Auction auction = new Auction(auctionType, pairedShares, imbalanceShares, referencePrice, indicativePrice, auctionBookPrice, collarReferencePrice, lowerCollarPrice, upperCollarPrice, extensionNumber, startTime, lastUpdate); assertThat(auction.getAuctionType()).isEqualTo(auctionType); assertThat(auction.getPairedShares()).isEqualTo(pairedShares); assertThat(auction.getReferencePrice()).isEqualTo(referencePrice); assertThat(auction.getIndicativePrice()).isEqualTo(indicativePrice); assertThat(auction.getAuctionBookPrice()).isEqualTo(auctionBookPrice); assertThat(auction.getCollarReferencePrice()).isEqualTo(collarReferencePrice); assertThat(auction.getLowerCollarPrice()).isEqualTo(lowerCollarPrice); assertThat(auction.getUpperCollarPrice()).isEqualTo(upperCollarPrice); assertThat(auction.getExtensionNumber()).isEqualTo(extensionNumber); assertThat(auction.getStartTime()).isEqualTo(startTime); assertThat(auction.getLastUpdate()).isEqualTo(lastUpdate); }
@Test public void test_with_longTemporalField_hourOfDay() { for (int i = 0; i < 24; i++) { LocalTime test = TEST_12_30_40_987654321.with(HOUR_OF_DAY, i); assertEquals(test.get(HOUR_OF_DAY), i); assertEquals(test.get(MINUTE_OF_HOUR), TEST_12_30_40_987654321.get(MINUTE_OF_HOUR)); assertEquals(test.get(SECOND_OF_MINUTE), TEST_12_30_40_987654321.get(SECOND_OF_MINUTE)); assertEquals(test.get(NANO_OF_SECOND), TEST_12_30_40_987654321.get(NANO_OF_SECOND)); } }
@Test public void test_equals_endOfDayDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertEquals(a.equals(a), true); assertEquals(a.equals(b), false); assertEquals(b.equals(a), false); assertEquals(b.equals(b), true); }
@Test public void setLocalTime() { final LocalTime value = LocalTime.now(); final Iterator<Value<?>> it = ps.setLocalTime(value).params().iterator(); assertEquals(new LocalTimeValue(value), it.next()); assertFalse(it.hasNext()); }
private DateCalculatorResult getTimeDiff(final OperatorToken operatorToken, final TimeToken startTimeToken, final Token thirdToken) throws DateCalcException { if (operatorToken.isAddition()) { throw new DateCalcException("Time differences should be expressed as TIME1 - TIME2. To do time math, please use units of measure (e.g., now + 15 minutes"); } LocalTime startTime = startTimeToken.getValue(); LocalTime endTime = ((TimeToken) thirdToken).getValue(); return new DateCalculatorResult(Duration.between(startTime, endTime).abs()); // return (startTime.isBefore(endTime)) // ? new DateCalculatorResult(Duration.between(startTime, endTime)) // : new DateCalculatorResult(Duration.between(endTime, startTime)); }
@Test public void test_plusHours_one() { LocalTime t = LocalTime.MIDNIGHT; for (int i = 0; i < 50; i++) { t = t.plusHours(1); assertEquals(t.getHour(), (i + 1) % 24); } }
static Stream<Arguments> goodMapConditionAndResult() { return Stream.of( Arguments.of( ImmutableMap.of(), Collections.emptyList(), DSL.trueCondition() ), Arguments.of( // this one makes no sense but this is correct ^^ ImmutableMap.of("key1", "value1", "key2", "12:25:30", "key3", "2017-05-17T12:25:30"), createFilterValueTrueConditionPrefixedN("key", 5), createNTrueCondition(3) ), // TODO might fail sometimes as Map of Impl is not predictable in ordering Arguments.of( ImmutableMap.of("key1", "value1", "key2", "12:25:30", "key3", "2017-05-17T12:25:30"), Arrays.asList(Filter.of( "key1", "key2", v1 -> "val1", v2 -> LocalTime.of(12, 23, 34), (v1, v2) -> DSL.field("name", String.class).likeIgnoreCase(v1 + "%") .and(DSL.field("atime", Time.class).ge(Time.valueOf(v2)))), Filter.of("key3", LocalDateTime::parse, v1 -> DSL.field("a_date_time", Timestamp.class).lessThan(Timestamp.valueOf(v1))), Filter.of("key4", DSL::trueCondition), Filter.of("key5", DSL::trueCondition)), DSL.field("name", String.class).likeIgnoreCase("val1%") .and(DSL.field("atime", Time.class).ge(Time.valueOf("12:23:34"))) .and(DSL.field("a_date_time", Timestamp.class).lessThan(Timestamp.valueOf("2017-05-17 12:25:30")))) ); }
@ParameterizedTest @MethodSource("goodStringParsableAndResult") void parse(final String argument, final List<LocalTime> expected) { Assertions.assertEquals(expected, FilterMultipleValueParser.ofTime().parse(argument)); Assertions.assertEquals(expected.size(), FilterMultipleValueParser.ofTime().parse(argument).size()); Assertions.assertEquals(expected, FilterMultipleValueParser.ofTime().parse(argument, ",")); }
@Override public LocalTime convertToModel(Date value, Class<? extends LocalTime> targetType, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { if (value != null) { final Calendar calendar = Calendar.getInstance(locale); calendar.setTime(value); return LocalTime.of(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND)); } return null; }
@FXThread public void hide() { final Duration duration = Duration.between(showedTime, LocalTime.now()); final int seconds = (int) duration.getSeconds(); final Window window = dialog.getOwner(); final Scene scene = window.getScene(); if (scene instanceof EditorFXScene) { final EditorFXScene editorFXScene = (EditorFXScene) scene; final StackPane container = editorFXScene.getContainer(); container.setFocusTraversable(true); } if (focusOwner != null) { focusOwner.requestFocus(); } dialog.hide(); final JFXApplication application = JFXApplication.getInstance(); application.removeWindow(dialog); GAnalytics.sendEvent(GAEvent.Category.DIALOG, GAEvent.Action.DIALOG_CLOSED, getDialogId()); GAnalytics.sendTiming(GAEvent.Category.DIALOG, GAEvent.Label.SHOWING_A_DIALOG, seconds, getDialogId()); }
@Test public void testIsTodayCalculation() { LocalDateTime localDateTime = LocalDateTime.now(); Assert.assertTrue(DataUtils.isToday(localDateTime)); Assert.assertTrue(DataUtils.isToday(LocalDateTime.of(localDateTime.toLocalDate(), LocalTime.MIN))); Assert.assertTrue(DataUtils.isToday(LocalDateTime.of(localDateTime.toLocalDate(), LocalTime.MAX))); Assert.assertFalse(DataUtils.isToday(localDateTime.minusDays(1))); }
@DataProvider(name="durationBetweenLocalTime") Object[][] data_durationBetweenLocalTime() { return new Object[][] { {LocalTime.of(11, 0, 30), LocalTime.of(11, 0, 45), 15L, 0}, {LocalTime.of(11, 0, 30), LocalTime.of(11, 0, 25), -5L, 0}, }; }
@Test public void test_minusHours_fromOne() { LocalTime base = LocalTime.of(1, 0); for (int i = -50; i < 50; i++) { LocalTime t = base.minusHours(i); assertEquals(t.getHour(), (1 + (-i % 24) + 24) % 24); } }
private void setStartTime(LocalTime time) { if (startTime == null) { _startTime = time; } else { startTime.set(time); } }