use of org.assertj.core.util.VisibleForTesting in project assertj-core by assertj.
the class AbstractDateAssert method parse.
/**
* Thread safe utility method to parse a Date with {@link #userDateFormats} first, then {@link #DEFAULT_DATE_FORMATS}.
* <p>
* Returns <code>null</code> if dateAsString parameter is <code>null</code>.
*
* @param dateAsString the string to parse as a Date with {@link #userDateFormats}
* @return the corresponding Date, null if dateAsString parameter is null.
* @throws AssertionError if the string can't be parsed as a Date
*/
@VisibleForTesting
Date parse(String dateAsString) {
if (dateAsString == null)
return null;
// parse with date format specified by user if any, otherwise use default formats
// no synchronization needed as userCustomDateFormat is thread local
Date date = parseDateWith(dateAsString, userDateFormats.get());
if (date != null)
return date;
// no matching user date format, let's try default format
date = parseDateWithDefaultDateFormats(dateAsString);
if (date != null)
return date;
// no matching date format, throw an error
throw new AssertionError(String.format("Failed to parse %s with any of these date formats:%n %s", dateAsString, info.representation().toStringOf(dateFormatsInOrderOfUsage())));
}
use of org.assertj.core.util.VisibleForTesting in project cassandra by apache.
the class RangeCommands method rangeCommandIterator.
@VisibleForTesting
// created iterators will be closed in CQL layer through the chain of transformations
@SuppressWarnings("resource")
static RangeCommandIterator rangeCommandIterator(PartitionRangeReadCommand command, ConsistencyLevel consistencyLevel, long queryStartNanoTime) {
Tracing.trace("Computing ranges to query");
Keyspace keyspace = Keyspace.open(command.metadata().keyspace);
ReplicaPlanIterator replicaPlans = new ReplicaPlanIterator(command.dataRange().keyRange(), keyspace, consistencyLevel);
// our estimate of how many result rows there will be per-range
float resultsPerRange = estimateResultsPerRange(command, keyspace);
// underestimate how many rows we will get per-range in order to increase the likelihood that we'll
// fetch enough rows in the first round
resultsPerRange -= resultsPerRange * CONCURRENT_SUBREQUESTS_MARGIN;
int maxConcurrencyFactor = Math.min(replicaPlans.size(), MAX_CONCURRENT_RANGE_REQUESTS);
int concurrencyFactor = resultsPerRange == 0.0 ? 1 : Math.max(1, Math.min(maxConcurrencyFactor, (int) Math.ceil(command.limits().count() / resultsPerRange)));
logger.trace("Estimated result rows per range: {}; requested rows: {}, ranges.size(): {}; concurrent range requests: {}", resultsPerRange, command.limits().count(), replicaPlans.size(), concurrencyFactor);
Tracing.trace("Submitting range requests on {} ranges with a concurrency of {} ({} rows per range expected)", replicaPlans.size(), concurrencyFactor, resultsPerRange);
ReplicaPlanMerger mergedReplicaPlans = new ReplicaPlanMerger(replicaPlans, keyspace, consistencyLevel);
return new RangeCommandIterator(mergedReplicaPlans, command, concurrencyFactor, maxConcurrencyFactor, replicaPlans.size(), queryStartNanoTime);
}
Aggregations