Java Code Examples for java.time.Instant#plus()

The following examples show how to use java.time.Instant#plus() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CuratorCompletionWaiter.java    From vespa with Apache License 2.0 6 votes vote down vote up
private List<String> awaitInternal(Duration timeout) throws Exception {
    Instant startTime = clock.instant();
    Instant endTime = startTime.plus(timeout);
    List<String> respondents;
    do {
        respondents = curator.framework().getChildren().forPath(barrierPath);

        // First, check if all config servers responded
        if (respondents.size() == curator.zooKeeperEnsembleCount()) {
            log.log(Level.FINE, barrierCompletedMessage(respondents, startTime));
            break;
        }
        // If some are missing, quorum is enough
        if (respondents.size() >= barrierMemberCount()) {
            log.log(Level.INFO, barrierCompletedMessage(respondents, startTime));
            break;
        }

        Thread.sleep(100);
    } while (clock.instant().isBefore(endTime));

    return respondents;
}
 
Example 2
Source File: DecisionTreeRuleTest.java    From swblocks-decisiontree with Apache License 2.0 6 votes vote down vote up
@Test
public void testConstructor() {
    final InputDriver[] testInputDriver = getInputDriverArray("input1");
    final InputDriver[] testEvaluationDriver = getInputDriverArray("output1");
    final Instant startInstance = Instant.now();
    final Instant endInstance = startInstance.plus(1, ChronoUnit.DAYS);
    final DecisionTreeRule decisionTreeRule = new DecisionTreeRule(new UUID(0, 1),
            new UUID(0, 2), testInputDriver, testEvaluationDriver, this.outputDriver,
            startInstance, endInstance);

    assertArrayEquals(testInputDriver, decisionTreeRule.getDrivers());
    assertTrue(decisionTreeRule.getEvaluations().isPresent());
    assertArrayEquals(testEvaluationDriver, decisionTreeRule.getEvaluations().get());
    assertEquals(new UUID(0, 1), decisionTreeRule.getRuleIdentifier());
    assertEquals(new UUID(0, 2), decisionTreeRule.getRuleCode());
    assertEquals("result", decisionTreeRule.getOutputs().get("outputDriver"));
    assertEquals(startInstance, decisionTreeRule.getStart());
    assertEquals(endInstance, decisionTreeRule.getEnd());
}
 
Example 3
Source File: DecisionTreeRuleSetTest.java    From swblocks-decisiontree with Apache License 2.0 6 votes vote down vote up
@Test
public void testConstruction() {
    final Instant startInstance = Instant.now();
    final Instant endInstance = startInstance.plus(1, ChronoUnit.DAYS);

    final UUID uuid = new UUID(0, 1);
    final DecisionTreeRule testRule = new DecisionTreeRule(uuid, UUID.randomUUID(), getInputDriverArray(),
            Collections.singletonMap("outputDriver", "result"), startInstance, endInstance);

    final List<String> driverNames = Arrays.asList("driver1", "driver2");
    final List<WeightedDriver> weightedDriverResults = Arrays.asList(new WeightedDriver("driver1", 4),
            new WeightedDriver("driver2", 2));

    final DecisionTreeRuleSet ruleSet = new DecisionTreeRuleSet("TestName",
            Collections.singletonMap(uuid, testRule), driverNames);
    assertEquals("TestName", ruleSet.getName());
    assertEquals(1, ruleSet.getRules().size());
    assertEquals(Collections.emptyList(), ruleSet.getEvaluationNames());
    assertEquals(uuid, ruleSet.getRules().get(uuid).getRuleIdentifier());
    assertEquals(driverNames, ruleSet.getDriverNames());
    assertEquals(weightedDriverResults, ruleSet.getWeightedDrivers());
    assertEquals("DecisionTreeRuleSet{name='TestName'}", ruleSet.toString());
}
 
Example 4
Source File: DatedEvaluatorTest.java    From swblocks-decisiontree with Apache License 2.0 6 votes vote down vote up
@Test
public void testSixRules() {
    final Builder<RuleSetBuilder, DecisionTreeRuleSet> ruleSetBuilder = ruleSetBuilder();
    final Instant now = Instant.now();
    final Instant start = now.minus(Period.ofWeeks(1));
    final Instant finish = now.plus(Period.ofWeeks(4));
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "*", "CME", "*", "*", "INDEX", start, finish, 1L, "1.1");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "*", "CME", "S&P", "*", "INDEX", start, finish, 2L, "1.2");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "VOICE", "CME", "ED", "*", "RATE", start, finish, 3L, "1.4");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "VOICE", "*", "*", "US", "*", start, finish, 4L, "1.5");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "*", "*", "*", "US", "*", start, finish, 5L, "1.2");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "*", "*", "*", "UK", "*", start, finish, 6L, "1.1");

    final DecisionTreeRuleSet ruleSet = ruleSetBuilder.build();
    final TreeNode node = constructTree(ruleSet);
    Assert.assertNotNull(node);

    checkMatch(inputA, now, node, 3L);
    checkMatch(inputB, now, node, 4L);
    checkMatch(inputC, now, node, 4L);
    checkMatch(inputD, now, node, 6L);
    checkMatch(inputE, now, node, 5L);
    checkMatch(inputF, now, node, 6L);
}
 
Example 5
Source File: TimeSliceCacheConcurrencyTest.java    From swblocks-decisiontree with Apache License 2.0 6 votes vote down vote up
@Test
@Concurrent(count = 20)
@Repeating(repetition = 200)
public void cacheAccess() {
    final Instant now = Instant.now();
    final int start = (int) (Math.random() * 100);
    final int end = start + (int) (Math.random() * 100);

    final Range<Instant> dateRange = new Range<>(now.plus(Period.ofWeeks(start)), now.plus(Period.ofWeeks(end)));
    final TreeNode node = NodeSupplier.createTreeNode(
            new StringDriver(UUID.randomUUID().toString()), NodeSupplier.ROOT_NODE_LEVEL).get();

    final Optional<TreeNode> treeNode = Optional.of(node);
    this.cache.put(dateRange, treeNode);

    for (final Range<Instant> dr : this.cache.keys()) {
        this.cache.get(Optional.of(dr));
    }

    this.cache.get(Optional.of(dateRange));
}
 
Example 6
Source File: ConsistentKeyLocker.java    From titan1withtp3.1 with Apache License 2.0 6 votes vote down vote up
/**
 * Try to write a lock record remotely up to the configured number of
 *  times. If the store produces
 * {@link TemporaryLockingException}, then we'll call mutate again to add a
 * new column with an updated timestamp and to delete the column that tried
 * to write when the store threw an exception. We continue like that up to
 * the retry limit. If the store throws anything else, such as an unchecked
 * exception or a {@link com.thinkaurelius.titan.diskstorage.PermanentBackendException}, then we'll try to
 * delete whatever we added and return without further retries.
 *
 * @param lockID lock to acquire
 * @param txh    transaction
 * @return the timestamp, in nanoseconds since UNIX Epoch, on the lock
 *         column that we successfully wrote to the store
 * @throws TemporaryLockingException if the lock retry count is exceeded without successfully
 *                                   writing the lock in less than the wait limit
 * @throws Throwable                 if the storage layer throws anything else
 */
@Override
protected ConsistentKeyLockStatus writeSingleLock(KeyColumn lockID, StoreTransaction txh) throws Throwable {

    final StaticBuffer lockKey = serializer.toLockKey(lockID.getKey(), lockID.getColumn());
    StaticBuffer oldLockCol = null;

    for (int i = 0; i < lockRetryCount; i++) {
        WriteResult wr = tryWriteLockOnce(lockKey, oldLockCol, txh);
        if (wr.isSuccessful() && wr.getDuration().compareTo(lockWait) <= 0) {
            final Instant writeInstant = wr.getWriteTimestamp();
            final Instant expireInstant = writeInstant.plus(lockExpire);
            return new ConsistentKeyLockStatus(writeInstant, expireInstant);
        }
        oldLockCol = wr.getLockCol();
        handleMutationFailure(lockID, lockKey, wr, txh);
    }
    tryDeleteLockOnce(lockKey, oldLockCol, txh);
    // TODO log exception or successful too-slow write here
    throw new TemporaryBackendException("Lock write retry count exceeded");
}
 
Example 7
Source File: DatedEvaluatorTest.java    From swblocks-decisiontree with Apache License 2.0 6 votes vote down vote up
@Test
public void testFiveRules() {
    final Builder<RuleSetBuilder, DecisionTreeRuleSet> ruleSetBuilder = ruleSetBuilder();
    final Instant now = Instant.now();
    final Instant start = now.minus(Period.ofWeeks(1));
    final Instant finish = now.plus(Period.ofWeeks(4));

    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "*", "CME", "*", "*", "INDEX", start, finish, 1L, "1.1");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "*", "CME", "S&P", "*", "INDEX", start, finish, 2L, "1.2");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "VOICE", "CME", "ED", "*", "RATE", start, finish, 3L, "1.4");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "VOICE", "*", "*", "US", "*", start, finish, 4L, "1.5");
    CommisionRuleSetSupplier.addRule(ruleSetBuilder, "*", "*", "*", "US", "*", start, finish, 5L, "1.2");

    final DecisionTreeRuleSet ruleSet = ruleSetBuilder.build();
    final TreeNode node = constructTree(ruleSet);
    Assert.assertNotNull(node);

    checkMatch(inputA, now, node, 3L);
    checkMatch(inputB, now, node, 4L);
    checkMatch(inputC, now, node, 4L);
    checkMatch(inputE, now, node, 5L);

    checkNoMatch(inputD, now, node);
    checkNoMatch(inputF, now, node);
}
 
Example 8
Source File: TCKInstant.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="plusTemporalAmount")
public void test_plusTemporalAmount(TemporalUnit unit, TemporalAmount amount, int seconds, int nanos) {
    Instant inst = Instant.ofEpochMilli(1000);
    Instant actual = inst.plus(amount);
    Instant expected = Instant.ofEpochSecond(seconds, nanos);
    assertEquals(actual, expected, "plus(TemporalAmount) failed");
}
 
Example 9
Source File: ChangeTest.java    From swblocks-decisiontree with Apache License 2.0 5 votes vote down vote up
@Test
public void changeAuditInfo() {
    testConstruction();

    Instant initiatorTime = NOW;

    final Audit audit = getBean().getAudit();
    assertEquals("USER1", audit.getInitiator());
    assertEquals(initiatorTime, audit.getInitiatorTime());
    assertEquals("USER2", audit.getAuthoriser());

    Instant authoriserTime = initiatorTime.plus(Period.ofWeeks(1));
    assertEquals(authoriserTime, audit.getAuthoriserTime());

    initiatorTime = NOW.plus(Period.ofWeeks(5));
    authoriserTime = initiatorTime.plus(Period.ofWeeks(1));
    final Audit newAudit = new Audit("USER3", initiatorTime, "USER4", authoriserTime);
    getBean().setAudit(newAudit);

    this.injectedValues.clear();

    this.injectedValues.put("initiator", "USER3");
    this.injectedValues.put("initiatorTime", initiatorTime);
    this.injectedValues.put("authoriser", "USER4");
    this.injectedValues.put("authoriserTime", authoriserTime);

    JblTestClassUtils.assertGetterCorrectForConstructorInjection(this.injectedValues, getBean().getAudit());
}
 
Example 10
Source File: ValueGroupChangeTest.java    From swblocks-decisiontree with Apache License 2.0 5 votes vote down vote up
@Test
public void hashCodeCorrect() {
    final UUID id = new UUID(0, 1);
    final Instant start = Instant.now().minus(Period.ofWeeks(-1));
    final Instant end = start.plus(Period.ofWeeks(5));
    final DateRange range = new DateRange(start, end);
    final List<String> drivers = Arrays.asList("Test1", "Test2", "Test3");
    final ValueGroup valueGroup = new ValueGroup(id, "TestValueGroup", drivers, range);

    final ValueGroupChange change = new ValueGroupChange(Type.NEW, valueGroup);
    final ValueGroupChange other = new ValueGroupChange(Type.NEW, valueGroup);

    assertEquals(change.hashCode(), other.hashCode());
}
 
Example 11
Source File: RateLimitedBatcherTest.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Test
public void keepMostRecentUpdatesInEachBatch() {
    final Instant now = Instant.ofEpochMilli(testScheduler.now());
    final Instant moreRecent = now.plus(ofMillis(1));
    final BatchableOperationMock old = new BatchableOperationMock(LOW, now, "resource2", "sub2", "create");
    final BatchableOperationMock recent = new BatchableOperationMock(LOW, moreRecent, "resource2", "sub2", "remove");

    assertEmitSingleAfterReceiving(recent, old, recent);
}
 
Example 12
Source File: Profiler.java    From diirt with MIT License 5 votes vote down vote up
public void profile(){
    preLoopAction();

    stopWatch = new StopWatch(profileSettings.getMaxTries());
    stopWatch.setTimeType(profileSettings.getTimeType());

    nTries = 0;

    //System Time
    Instant start = Instant.now();
    Instant end = start.plus(Duration.ofSeconds(profileSettings.getTestTime()));

    //Trials
    while (end.compareTo(Instant.now()) >= 0 &&           //not over max time
           !Thread.currentThread().isInterrupted() &&       //not interrupted
           nTries < profileSettings.getMaxTries()) {        //not over max tries

                nTries++;
                stopWatch.start();

                iterationAction();

                stopWatch.stop();

                postIterationAction();
    }
}
 
Example 13
Source File: ShopItem.java    From functional-eventsourcing with Apache License 2.0 5 votes vote down vote up
private Instant calculatePaymentTimeoutDate(Instant boughtAt, int hoursToPaymentTimeout) {
    final Instant paymentTimeout = boughtAt.plus(hoursToPaymentTimeout, ChronoUnit.MINUTES);
    if (paymentTimeout.isBefore(boughtAt)) {
        throw new IllegalArgumentException("Payment timeout day is before ordering date!");
    }
    return paymentTimeout;
}
 
Example 14
Source File: DecisionTreeRuleTest.java    From swblocks-decisiontree with Apache License 2.0 5 votes vote down vote up
@Test
public void testIsActiveWithinDateRange() {
    final Instant startInstance = Instant.now().minus(1, ChronoUnit.DAYS);
    final Instant endInstance = startInstance.plus(2, ChronoUnit.DAYS);
    final DecisionTreeRule decisionTreeRule = new DecisionTreeRule(new UUID(0, 1), UUID.randomUUID(),
            getInputDriverArray("input1", "input2"), this.outputDriver, startInstance, endInstance);

    assertTrue(decisionTreeRule.isActiveAt(Instant.now()));
    Assert.assertFalse(decisionTreeRule.isActiveAt(Instant.now().minus(2, ChronoUnit.DAYS)));
    Assert.assertFalse(decisionTreeRule.isActiveAt(Instant.now().plus(2, ChronoUnit.DAYS)));
}
 
Example 15
Source File: TCKInstant.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="plusTemporalAmount")
public void test_plusTemporalAmount(TemporalUnit unit, TemporalAmount amount, int seconds, int nanos) {
    Instant inst = Instant.ofEpochMilli(1000);
    Instant actual = inst.plus(amount);
    Instant expected = Instant.ofEpochSecond(seconds, nanos);
    assertEquals(actual, expected, "plus(TemporalAmount) failed");
}
 
Example 16
Source File: TCKInstant.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void plus_longTemporalUnit_overflowTooSmall() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND);
    i.plus(999999999, NANOS);
    i.plus(-1, SECONDS);
}
 
Example 17
Source File: KCVSLog.java    From titan1withtp3.1 with Apache License 2.0 4 votes vote down vote up
@Override
public void run() {
    try {
        if (allowReadMarkerRecovery) setReadMarker();

        final int timeslice = getTimeSlice(messageTimeStart);

        // Setup time range we're about to query
        final Instant currentTime = times.getTime();
        // Can only read messages stamped up to the following time without violating design constraints
        final Instant maxSafeMessageTime = currentTime.minus(readLagTime);
        // We also have to stay inside the current timeslice or we could drop messages
        final Instant timesliceEnd = times.getTime((timeslice + 1) * TIMESLICE_INTERVAL);

        Instant messageTimeEnd =
                0 > maxSafeMessageTime.compareTo(timesliceEnd) /* maxSafeMessageTime < timesliceEnd */ ?
                maxSafeMessageTime : timesliceEnd;

        if (0 >  messageTimeStart.compareTo(messageTimeEnd)) {
            // nextTimepoint is strictly earlier than timeWindowEnd
            log.trace("MessagePuller time window: [{}, {})", messageTimeStart, messageTimeEnd);
        } else {
            /*
             * nextTimepoint is equal to or later than timeWindowEnd. We
             * can't run a column slice using these timestamps, since
             * the start would be greater than the end.
             *
             * This could happen during a brief window right after
             * startup with ReadMarker.fromNow(). However, if
             * nextTimestamp is much later than timeWindowEnd, then
             * something is probably misconfigured.
             */
            final Duration delta = Duration.between(messageTimeEnd, messageTimeStart);

            if (delta.toNanos() / 3 > readLagTime.toNanos()) {
                log.warn("MessagePuller configured with ReadMarker timestamp in the improbably distant future: {} (current time is {})", messageTimeStart, currentTime);
            } else {
                log.debug("MessagePuller configured with ReadMarker timestamp slightly ahead of read lag time; waiting for the clock to catch up");
            }

            return;
        }
        Preconditions.checkState(messageTimeStart.compareTo(messageTimeEnd) < 0);
        Preconditions.checkState(messageTimeEnd.compareTo(currentTime) <= 0, "Attempting to read messages from the future: messageTimeEnd=% vs currentTime=%s", messageTimeEnd, currentTime);

        StaticBuffer logKey = getLogKey(partitionId,bucketId,timeslice);
        KeySliceQuery query = new KeySliceQuery(logKey, BufferUtil.getLongBuffer(times.getTime(messageTimeStart)), BufferUtil.getLongBuffer(times.getTime(messageTimeEnd)));
        query.setLimit(maxReadMsg);
        log.trace("Converted MessagePuller time window to {}", query);

        List<Entry> entries= BackendOperation.execute(getOperation(query),KCVSLog.this,times,maxReadTime);
        prepareMessageProcessing(entries);
        if (entries.size()>=maxReadMsg) {
            /*Read another set of messages to ensure that we have exhausted all messages to the next timestamp.
            Since we have reached the request limit, it may be possible that there are additional messages
            with the same timestamp which we would miss on subsequent iterations */
            Entry lastEntry = entries.get(entries.size()-1);
            //Adding 2 microseconds (=> very few extra messages), not adding one to avoid that the slice is possibly empty
            messageTimeEnd = messageTimeEnd.plus(TWO_MICROSECONDS);
            log.debug("Extended time window to {}", messageTimeEnd);
            //Retrieve all messages up to this adjusted timepoint (no limit this time => get all entries to that point)
            query = new KeySliceQuery(logKey, BufferUtil.nextBiggerBuffer(lastEntry.getColumn()), BufferUtil.getLongBuffer(times.getTime(messageTimeEnd)));
            log.debug("Converted extended MessagePuller time window to {}", query);
            List<Entry> extraEntries = BackendOperation.execute(getOperation(query),KCVSLog.this,times,maxReadTime);
            prepareMessageProcessing(extraEntries);
        }
        messageTimeStart = messageTimeEnd;
    } catch (Throwable e) {
        log.warn("Could not read messages for timestamp ["+messageTimeStart+"] (this read will be retried)",e);
    }
}
 
Example 18
Source File: DatedEvaluatorTest.java    From swblocks-decisiontree with Apache License 2.0 4 votes vote down vote up
@Test
public void testAlternativePathsFailurePathsAndValueGroups() {
    final Instant now = Instant.now();
    final Instant start = now.minus(Period.ofWeeks(1));
    final Instant finish = now.plus(Period.ofWeeks(4));

    final Builder<RuleSetBuilder, DecisionTreeRuleSet> ruleSetBuilder = RuleSetBuilder.creator(Arrays.asList(
            "MARKUP_CODE", "CLIENT_ACCOUNT", "CLIENT_SPN", "ADVISOR_SPN", "EXECUTION_VENUE", "MEMBERSHIP",
            "SECURITY_TYPE", "CONTRACT", "FEE_GROUP", "PRODUCT_GROUP", "EXCHANGE", "REGION"));

    ruleSetBuilder.with(RuleSetBuilder::rule, RuleBuilder.creator()
            .with(RuleBuilder::input, Arrays.asList("CLM", "*", "VG:AdVG1589CLM:0152035:03227805:0521659",
                    "VG:VG1589CLM:0151488:4679563:7888805", "*", "*", "*", "*", "381", "Equity indices",
                    "VG:IFEU:IFLL", "ER"))
            .with(RuleBuilder::start, start)
            .with(RuleBuilder::end, finish)
            .with(RuleBuilder::setId, new UUID(0, 1L)));

    ruleSetBuilder.with(RuleSetBuilder::rule, RuleBuilder.creator()
            .with(RuleBuilder::input, Arrays.asList("CLM", "*", "VG:AdVG1589CLM:0152035:03227805:0521659",
                    "VG:VG1589CLM:0151488:4679563:7888805", "*", "*", "*", "*", "*", "*", "VG:IFEU:IFLL", "ER"))
            .with(RuleBuilder::start, start)
            .with(RuleBuilder::end, finish)
            .with(RuleBuilder::setId, new UUID(0, 2L)));

    ruleSetBuilder.with(RuleSetBuilder::rule, RuleBuilder.creator()
            .with(RuleBuilder::input, Arrays.asList("CLM", "*", "VG:AdVG1589CLM:0152035:03227805:0521659",
                    "VG:AdVG1589CLM:0151488:3679563:6888805", "*", "*", "*", "*", "*", "*", "VG:IFEU:IFLL", "ER"))
            .with(RuleBuilder::start, start)
            .with(RuleBuilder::end, finish)
            .with(RuleBuilder::setId, new UUID(0, 3L)));

    ruleSetBuilder.with(RuleSetBuilder::rule, RuleBuilder.creator()
            .with(RuleBuilder::input, Arrays.asList("CLM", "*", "VG:AdVG1589CLM:0152035:03227805:0521659",
                    "VG:VG1589CLM:0151488:4679563:7888805", "ELEC", "NMEM", "*", "*", "123", "Equity indices",
                    "VG:IFEU:IFLL", "ER"))
            .with(RuleBuilder::start, start)
            .with(RuleBuilder::end, finish)
            .with(RuleBuilder::setId, new UUID(0, 4L)));

    final DecisionTreeRuleSet ruleSet = ruleSetBuilder.build();
    final TreeNode node = constructTree(ruleSet);
    Assert.assertNotNull(node);

    final List<String> inputs = Arrays.asList("CLM", "A102059551", "0152035", "0151488",
            "ELEC", "NMEM", "FUTURE", "Y2", "381", "Equity indices", "IFLL", "ER");
    final Optional<UUID> result = Evaluator.singleEvaluate(inputs, now, node);
    assertTrue(result.isPresent());
    assertEquals(new UUID(0, 1L), result.get());
}
 
Example 19
Source File: TCKInstant.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void plus_Duration_overflowTooSmall() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND);
    i.plus(Duration.ofSeconds(-1, 999999999));
}
 
Example 20
Source File: TCKInstant.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void plus_Duration_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 999999999);
    i.plus(Duration.ofSeconds(0, 1));
}