本文整理匯總了Java中com.google.common.annotations.VisibleForTesting類的典型用法代碼示例。如果您正苦於以下問題:Java VisibleForTesting類的具體用法?Java VisibleForTesting怎麽用?Java VisibleForTesting使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
VisibleForTesting類屬於com.google.common.annotations包,在下文中一共展示了VisibleForTesting類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createRequest
import com.google.common.annotations.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
static SendMessageBatchRequest createRequest(String queueUrl, Map<String, SendMessageEntry> entries) {
return new SendMessageBatchRequest()
.withQueueUrl(queueUrl)
.withEntries(entries.entrySet().stream().map(keyValue -> {
SendMessageBatchRequestEntry entry = new SendMessageBatchRequestEntry()
.withId(keyValue.getKey())
.withMessageBody(keyValue.getValue().getBody());
keyValue.getValue().getDelay()
.ifPresent((delay) -> entry.setDelaySeconds((int) delay.getSeconds()));
return entry;
}).collect(Collectors.toList())
);
}
示例2: generateContent
import com.google.common.annotations.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
String generateContent(URL staticFile, Api api) throws IOException {
final STGroupFile stGroup = createSTGroup(staticFile);
final String fileName = new File(staticFile.getPath()).getName();
final ST st = stGroup.getInstanceOf("main");
st.add("vendorName", vendorName);
if (fileName.equals("ResourceClassMap.php.stg")) {
st.add("package", TypeGenModel.TYPES);
}
if (fileName.equals("Config.php.stg")) {
final String apiUri = api.getBaseUri().getTemplate();
final String authUri = api.getSecuritySchemes().stream()
.filter(securityScheme -> securityScheme.getSettings() instanceof OAuth20Settings)
.map(securityScheme -> ((OAuth20Settings)securityScheme.getSettings()).getAccessTokenUri())
.findFirst().orElse("");
st.add("apiUri", apiUri);
st.add("authUri", authUri);
}
return st.render();
}
示例3: fromMeter
import com.google.common.annotations.VisibleForTesting; //導入依賴的package包/類
/**
* Build an {@link InfluxDbMeasurement} from a meter.
*/
@VisibleForTesting InfluxDbMeasurement fromMeter(final String metricName, final Meter mt, final long timestamp) {
final DropwizardMeasurement measurement = parser.parse(metricName);
final Map<String, String> tags = new HashMap<>(baseTags);
tags.putAll(measurement.tags());
return new InfluxDbMeasurement.Builder(measurement.name(), timestamp)
.putTags(tags)
.putField("count", mt.getCount())
.putField("one-minute", convertRate(mt.getOneMinuteRate()))
.putField("five-minute", convertRate(mt.getFiveMinuteRate()))
.putField("fifteen-minute", convertRate(mt.getFifteenMinuteRate()))
.putField("mean-minute", convertRate(mt.getMeanRate()))
.build();
}
示例4: ColumnDefinition
import com.google.common.annotations.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
public ColumnDefinition(String ksName,
String cfName,
ColumnIdentifier name,
AbstractType<?> type,
int position,
Kind kind)
{
super(ksName, cfName, name, type);
assert name != null && type != null && kind != null;
assert name.isInterned();
assert (position == NO_POSITION) == !kind.isPrimaryKeyKind(); // The position really only make sense for partition and clustering columns (and those must have one),
// so make sure we don't sneak it for something else since it'd breaks equals()
this.kind = kind;
this.position = position;
this.cellPathComparator = makeCellPathComparator(kind, type);
this.cellComparator = cellPathComparator == null ? ColumnData.comparator : (a, b) -> cellPathComparator.compare(a.path(), b.path());
this.asymmetricCellPathComparator = cellPathComparator == null ? null : (a, b) -> cellPathComparator.compare(((Cell)a).path(), (CellPath) b);
this.comparisonOrder = comparisonOrder(kind, isComplex(), Math.max(0, position), name);
}
示例5: forceSecureOpenFSDataInputStream
import com.google.common.annotations.VisibleForTesting; //導入依賴的package包/類
/**
* Same as openFSDataInputStream except that it will run even if security is
* off. This is used by unit tests.
*/
@VisibleForTesting
protected static FSDataInputStream forceSecureOpenFSDataInputStream(
File file,
String expectedOwner, String expectedGroup) throws IOException {
final FSDataInputStream in =
rawFilesystem.open(new Path(file.getAbsolutePath()));
boolean success = false;
try {
Stat stat = NativeIO.POSIX.getFstat(in.getFileDescriptor());
checkStat(file, stat.getOwner(), stat.getGroup(), expectedOwner,
expectedGroup);
success = true;
return in;
} finally {
if (!success) {
in.close();
}
}
}
示例6: getDoAs
import com.google.common.annotations.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
static String getDoAs(HttpServletRequest request) {
List<NameValuePair> list = URLEncodedUtils.parse(request.getQueryString(),
UTF8_CHARSET);
if (list != null) {
for (NameValuePair nv : list) {
if (DelegationTokenAuthenticatedURL.DO_AS.
equalsIgnoreCase(nv.getName())) {
return nv.getValue();
}
}
}
return null;
}
示例7: buildMapFromSource
import com.google.common.annotations.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
Map<String, Object> buildMapFromSource(Reference[] insertColumns,
Object[] insertValues,
boolean isRawSourceInsert) {
Map<String, Object> sourceAsMap;
if (isRawSourceInsert) {
BytesRef source = (BytesRef) insertValues[0];
sourceAsMap = XContentHelper.convertToMap(new BytesArray(source), true).v2();
} else {
sourceAsMap = new LinkedHashMap<>(insertColumns.length);
for (int i = 0; i < insertColumns.length; i++) {
sourceAsMap.put(insertColumns[i].ident().columnIdent().fqn(), insertValues[i]);
}
}
return sourceAsMap;
}
示例8: alterWriteRequest
import com.google.common.annotations.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
public static void alterWriteRequest(WRITE3Request request, long cachedOffset) {
long offset = request.getOffset();
int count = request.getCount();
long smallerCount = offset + count - cachedOffset;
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Got overwrite with appended data (%d-%d),"
+ " current offset %d," + " drop the overlapped section (%d-%d)"
+ " and append new data (%d-%d).", offset, (offset + count - 1),
cachedOffset, offset, (cachedOffset - 1), cachedOffset, (offset
+ count - 1)));
}
ByteBuffer data = request.getData();
Preconditions.checkState(data.position() == 0,
"The write request data has non-zero position");
data.position((int) (cachedOffset - offset));
Preconditions.checkState(data.limit() - data.position() == smallerCount,
"The write request buffer has wrong limit/position regarding count");
request.setOffset(cachedOffset);
request.setCount((int) smallerCount);
}
示例9: super
import com.google.common.annotations.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
JavaKeyStoreProvider(JavaKeyStoreProvider other) {
super(new Configuration());
uri = other.uri;
path = other.path;
fs = other.fs;
permissions = other.permissions;
keyStore = other.keyStore;
password = other.password;
changed = other.changed;
readLock = other.readLock;
writeLock = other.writeLock;
}
示例10: getAllAppListings
import com.google.common.annotations.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
@SuppressWarnings("GuardedBy")
Optional<ImmutableSet<AppListing>> getAllAppListings(String hostBundleId) {
Set<AppListing> listings = appIdToListings.values();
ImmutableSet<String> hostAppIds =
listings
.stream()
.filter(appListing -> appListing.app.applicationBundleId().equals(hostBundleId))
.map(appListing -> appListing.app.applicationId())
.collect(ImmutableSet.toImmutableSet());
Verify.verify(hostAppIds.size() <= 1, "multiple matching host apps: %s", hostAppIds);
if (!hostAppIds.isEmpty()) {
String hostAppId = Iterables.getOnlyElement(hostAppIds);
ImmutableSet<AppListing> childListings =
listings
.stream()
.filter(
appListing ->
hostAppId.equals(appListing.app.optionalHostApplicationId().orNull()))
.collect(ImmutableSet.toImmutableSet());
if (!childListings.isEmpty()
&& childListings.stream().allMatch(appListing -> appListing.listing.isPresent())) {
return Optional.of(childListings);
}
}
return Optional.empty();
}
示例11: reset
import com.google.common.annotations.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
final void reset(Instant startTimestamp, ImmutableList<String> labelValues) {
Lock lock = valueLocks.get(labelValues);
lock.lock();
try {
this.values.put(labelValues, 0);
this.valueStartTimestamps.put(labelValues, startTimestamp);
} finally {
lock.unlock();
}
}
示例12: triggerDeletionReportForTests
import com.google.common.annotations.VisibleForTesting; //導入依賴的package包/類
@VisibleForTesting
void triggerDeletionReportForTests() {
synchronized (pendingIncrementalBRperStorage) {
lastDeletedReport = 0;
pendingIncrementalBRperStorage.notifyAll();
while (lastDeletedReport == 0) {
try {
pendingIncrementalBRperStorage.wait(100);
} catch (InterruptedException e) {
return;
}
}
}
}
示例13: lessThanBranchFree
import com.google.common.annotations.VisibleForTesting; //導入依賴的package包/類
/**
* Returns 1 if {@code x < y} as unsigned integers, and 0 otherwise. Assumes that x - y fits into
* a signed int. The implementation is branch-free, and benchmarks suggest it is measurably (if
* narrowly) faster than the straightforward ternary expression.
*/
@VisibleForTesting
static int lessThanBranchFree(int x, int y) {
// The double negation is optimized away by normal Java, but is necessary for GWT
// to make sure bit twiddling works as expected.
return ~~(x - y) >>> (Integer.SIZE - 1);
}
示例14:
import com.google.common.annotations.VisibleForTesting; //導入依賴的package包/類
/**
* Skip {@code src} over the encoded varuint64.
* @param src source buffer
* @param cmp if true, parse the compliment of the value.
* @return the number of bytes skipped.
*/
@VisibleForTesting
static int skipVaruint64(PositionedByteRange src, boolean cmp) {
final int len = lengthVaruint64(src, cmp);
src.setPosition(src.getPosition() + len);
return len;
}
示例15: getConnection
import com.google.common.annotations.VisibleForTesting; //導入依賴的package包/類
/**
* <em>INTERNAL</em> Used by unit tests and tools to do low-level
* manipulations.
* @return An HConnection instance.
* @deprecated This method will be changed from public to package protected.
*/
// TODO(tsuna): Remove this. Unit tests shouldn't require public helpers.
@Deprecated
@VisibleForTesting
public HConnection getConnection() {
return this.connection;
}