use of org.junit.experimental.theories.Theory in project Aeron by real-logic.
the class RetransmitHandlerTest method shouldRetransmitOnMultipleNaks.
@Theory
public void shouldRetransmitOnMultipleNaks(final BiConsumer<RetransmitHandlerTest, Integer> creator) {
createTermBuffer(creator, 5);
handler.onNak(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH, TERM_BUFFER_LENGTH, retransmitSender);
handler.onNak(TERM_ID, offsetOfFrame(1), ALIGNED_FRAME_LENGTH, TERM_BUFFER_LENGTH, retransmitSender);
currentTime = TimeUnit.MILLISECONDS.toNanos(100);
handler.processTimeouts(currentTime, retransmitSender);
final InOrder inOrder = inOrder(retransmitSender);
inOrder.verify(retransmitSender).resend(TERM_ID, offsetOfFrame(0), ALIGNED_FRAME_LENGTH);
inOrder.verify(retransmitSender).resend(TERM_ID, offsetOfFrame(1), ALIGNED_FRAME_LENGTH);
}
use of org.junit.experimental.theories.Theory in project Aeron by real-logic.
the class RetransmitHandlerTest method shouldRetransmitOnNakOverMtuLength.
@Theory
public void shouldRetransmitOnNakOverMtuLength(final BiConsumer<RetransmitHandlerTest, Integer> creator) {
final int numFramesPerMtu = MTU_LENGTH / ALIGNED_FRAME_LENGTH;
createTermBuffer(creator, numFramesPerMtu * 5);
handler.onNak(TERM_ID, offsetOfFrame(0), MTU_LENGTH * 2, TERM_BUFFER_LENGTH, retransmitSender);
currentTime = TimeUnit.MILLISECONDS.toNanos(100);
handler.processTimeouts(currentTime, retransmitSender);
verify(retransmitSender).resend(TERM_ID, offsetOfFrame(0), MTU_LENGTH * 2);
}
use of org.junit.experimental.theories.Theory in project graphhopper by graphhopper.
the class FareTest method irrelevantAlternatives.
@Theory
public void irrelevantAlternatives(Map<String, Fare> fares, Trip trip) {
assumeThat("There are at least two fares.", fares.entrySet().size(), is(greaterThanOrEqualTo(2)));
// If we only use one fare, say, the most expensive one...
Fare mostExpensiveFare = fares.values().stream().max(Comparator.comparingDouble(f -> f.fare_attribute.price)).get();
HashMap<String, Fare> singleFare = new HashMap<>();
singleFare.put(mostExpensiveFare.fare_id, mostExpensiveFare);
// ..and that still works for our trip..
assumeThat("There is at least one fare for each segment.", trip.segments.stream().map(segment -> Fares.possibleFares(singleFare, segment)).collect(Collectors.toList()), everyItem(is(not(empty()))));
double priceWithOneOption = Fares.cheapestFare(singleFare, trip).get().getAmount().doubleValue();
double priceWithAllOptions = Fares.cheapestFare(fares, trip).get().getAmount().doubleValue();
assertThat("...it shouldn't get more expensive when we put the cheaper options back.", priceWithAllOptions, lessThanOrEqualTo(priceWithOneOption));
}
use of org.junit.experimental.theories.Theory in project graphhopper by graphhopper.
the class FareTest method canGoAllTheWayOnOneTicket.
@Theory
public void canGoAllTheWayOnOneTicket(Map<String, Fare> fares, Trip trip) throws IOException {
assumeThat("Only one fare.", fares.size(), equalTo(1));
Fare onlyFare = fares.values().iterator().next();
assumeThat("Fare allows the number of transfers we need for our trip.", onlyFare.fare_attribute.transfers, greaterThanOrEqualTo(trip.segments.size()));
assumeThat("Fare allows the time we need for our trip.", (long) onlyFare.fare_attribute.transfer_duration, greaterThanOrEqualTo(trip.segments.get(trip.segments.size() - 1).getStartTime() - trip.segments.get(0).getStartTime()));
Amount amount = Fares.cheapestFare(fares, trip).get();
Assert.assertEquals(BigDecimal.valueOf(onlyFare.fare_attribute.price), amount.getAmount());
}
use of org.junit.experimental.theories.Theory in project grakn by graknlabs.
the class LockTest method whenGettingLockWithNullInPath_LockIsAcquired.
@Theory
public void whenGettingLockWithNullInPath_LockIsAcquired(Locks locks) {
String lockName = "/\u0000";
Lock lock = getLock(locks, lockName);
assertThat(lock.tryLock(), is(true));
lock.unlock();
}
Aggregations