@Override
public RecordSet getRecordSet(
ConnectorTransactionHandle transaction,
ConnectorSession session,
ConnectorSplit split,
List<? extends ColumnHandle> columns
) {
EthereumSplit ethereumSplit = convertSplit(split);
ImmutableList.Builder<EthereumColumnHandle> handleBuilder = ImmutableList.builder();
for (ColumnHandle handle : columns) {
EthereumColumnHandle columnHandle = convertColumnHandle(handle);
handleBuilder.add(columnHandle);
}
return new EthereumRecordSet(web3j, handleBuilder.build(), ethereumSplit);
}
java类com.google.common.collect.ImmutableList的实例源码
EthereumRecordSetProvider.java 文件源码
项目:presto-ethereum
阅读 42
收藏 0
点赞 0
评论 0
ShowSchemasHandler.java 文件源码
项目:QDrill
阅读 37
收藏 0
点赞 0
评论 0
/** Rewrite the parse tree as SELECT ... FROM INFORMATION_SCHEMA.SCHEMATA ... */
@Override
public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException, ForemanSetupException {
SqlShowSchemas node = unwrap(sqlNode, SqlShowSchemas.class);
List<SqlNode> selectList =
ImmutableList.of((SqlNode) new SqlIdentifier(SCHS_COL_SCHEMA_NAME, SqlParserPos.ZERO));
SqlNode fromClause = new SqlIdentifier(
ImmutableList.of(IS_SCHEMA_NAME, TAB_SCHEMATA), null, SqlParserPos.ZERO, null);
SqlNode where = null;
final SqlNode likePattern = node.getLikePattern();
if (likePattern != null) {
where = DrillParserUtil.createCondition(new SqlIdentifier(SCHS_COL_SCHEMA_NAME, SqlParserPos.ZERO),
SqlStdOperatorTable.LIKE, likePattern);
} else if (node.getWhereClause() != null) {
where = node.getWhereClause();
}
return new SqlSelect(SqlParserPos.ZERO, null, new SqlNodeList(selectList, SqlParserPos.ZERO),
fromClause, where, null, null, null, null, null, null);
}
RecipeSources.java 文件源码
项目:buckaroo
阅读 28
收藏 0
点赞 0
评论 0
public static Process<Event, RecipeIdentifier> selectDependency(final RecipeSource source, final PartialDependency dependency) {
if (dependency.organization.isPresent()) {
return Process.of(
Single.just(RecipeIdentifier.of(dependency.source, dependency.organization.get(), dependency.project))
);
}
final ImmutableList<RecipeIdentifier> candidates = Streams.stream(source
.findCandidates(dependency))
.limit(5)
.collect(toImmutableList());
if (candidates.size() == 0) {
return Process.error(
PartialDependencyResolutionException.of(candidates, dependency));
}
if (candidates.size() > 1) {
return Process.error(PartialDependencyResolutionException.of(candidates, dependency));
}
return Process.of(
Observable.just(
Notification.of("Resolved partial dependency " + dependency.encode() + " to " + candidates.get(0).encode())),
Single.just(candidates.get(0)));
}
TestUtils.java 文件源码
项目:circus-train
阅读 54
收藏 0
点赞 0
评论 0
private static String expandHql(
String database,
String table,
List<FieldSchema> dataColumns,
List<FieldSchema> partitionColumns) {
List<String> dataColumnNames = toQualifiedColumnNames(table, dataColumns);
List<String> partitionColumnNames = partitionColumns != null ? toQualifiedColumnNames(table, partitionColumns)
: ImmutableList.<String> of();
List<String> colNames = ImmutableList
.<String> builder()
.addAll(dataColumnNames)
.addAll(partitionColumnNames)
.build();
String cols = COMMA_JOINER.join(colNames);
return String.format("SELECT %s FROM `%s`.`%s`", cols, database, table);
}
TestHumanReadableStatements.java 文件源码
项目:morf
阅读 33
收藏 0
点赞 0
评论 0
/**
* Tests that the upgrade comes out in the right order.
*/
@Test
public void testRemoveMultipleColumns() {
List<Class<? extends UpgradeStep>> items = ImmutableList.<Class<? extends UpgradeStep>>of(
UpgradeStep511.class
);
ListBackedHumanReadableStatementConsumer consumer = new ListBackedHumanReadableStatementConsumer();
HumanReadableStatementProducer producer = new HumanReadableStatementProducer(items);
producer.produceFor(consumer);
List<String> actual = consumer.getList();
List<String> expected = ImmutableList.of(
"VERSIONSTART:[ALFA v1.0.0]",
"STEPSTART:[SAMPLE-7]-[UpgradeStep511]-[5.1.1 Upgrade Step]",
"CHANGE:[Remove column abc from SomeTable]",
"CHANGE:[Remove column def from SomeTable]",
"STEPEND:[UpgradeStep511]",
"VERSIONEND:[ALFA v1.0.0]"
);
assertEquals(expected, actual);
}
FlattenTemplate.java 文件源码
项目:dremio-oss
阅读 31
收藏 0
点赞 0
评论 0
@Override
public final void setup(BufferAllocator allocator, FunctionContext context, VectorAccessible incoming, VectorAccessible outgoing,
List<TransferPair> transfers, ComplexWriterCreator complexWriterCollector,
long outputMemoryLimit, long outputBatchSize) throws SchemaChangeException{
this.svMode = incoming.getSchema().getSelectionVectorMode();
switch (svMode) {
case FOUR_BYTE:
throw new UnsupportedOperationException("Flatten does not support selection vector inputs.");
case TWO_BYTE:
throw new UnsupportedOperationException("Flatten does not support selection vector inputs.");
}
this.transfers = ImmutableList.copyOf(transfers);
outputAllocator = allocator;
this.outputMemoryLimit = outputMemoryLimit;
this.outputLimit = outputBatchSize;
doSetup(context, incoming, outgoing, complexWriterCollector);
}
AutoMappperProcessor.java 文件源码
项目:android-auto-mapper
阅读 54
收藏 0
点赞 0
评论 0
private ImmutableMap<TypeMirror, FieldSpec> getTypeAdapters(ImmutableList<Property> properties) {
Map<TypeMirror, FieldSpec> typeAdapters = new LinkedHashMap<>();
NameAllocator nameAllocator = new NameAllocator();
nameAllocator.newName("CREATOR");
for (Property property : properties) {
if (property.typeAdapter != null && !typeAdapters.containsKey(property.typeAdapter)) {
ClassName typeName = (ClassName) TypeName.get(property.typeAdapter);
String name = CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, typeName.simpleName());
name = nameAllocator.newName(name, typeName);
typeAdapters.put(property.typeAdapter, FieldSpec.builder(
typeName, NameAllocator.toJavaIdentifier(name), PRIVATE, STATIC, FINAL)
.initializer("new $T()", typeName).build());
}
}
return ImmutableMap.copyOf(typeAdapters);
}
StoredDocumentServiceTests.java 文件源码
项目:document-management-store-app
阅读 33
收藏 0
点赞 0
评论 0
@Test
public void testSaveItemsWithCommandAndToggleConfiguration() throws Exception {
when(toggleConfiguration.isMetadatasearchendpoint()).thenReturn(true);
when(toggleConfiguration.isTtl()).thenReturn(true);
UploadDocumentsCommand uploadDocumentsCommand = new UploadDocumentsCommand();
uploadDocumentsCommand.setFiles(singletonList(TestUtil.TEST_FILE));
uploadDocumentsCommand.setRoles(ImmutableList.of("a", "b"));
uploadDocumentsCommand.setClassification(Classifications.PRIVATE);
uploadDocumentsCommand.setMetadata(ImmutableMap.of("prop1", "value1"));
uploadDocumentsCommand.setTtl(new Date());
List<StoredDocument> documents = storedDocumentService.saveItems(uploadDocumentsCommand);
final StoredDocument storedDocument = documents.get(0);
final DocumentContentVersion latestVersion = storedDocument.getDocumentContentVersions().get(0);
Assert.assertEquals(1, documents.size());
Assert.assertEquals(storedDocument.getRoles(), new HashSet(ImmutableList.of("a", "b")));
Assert.assertEquals(storedDocument.getClassification(), Classifications.PRIVATE);
Assert.assertEquals(storedDocument.getMetadata(), ImmutableMap.of("prop1", "value1"));
Assert.assertNotNull(storedDocument.getTtl());
Assert.assertEquals(TestUtil.TEST_FILE.getContentType(), latestVersion.getMimeType());
Assert.assertEquals(TestUtil.TEST_FILE.getOriginalFilename(), latestVersion.getOriginalDocumentName());
}
R8GMSCoreTreeShakeJarVerificationTest.java 文件源码
项目:r8
阅读 37
收藏 0
点赞 0
评论 0
public AndroidApp buildAndTreeShakeFromDeployJar(
CompilationMode mode, String base, boolean hasReference, int maxSize,
Consumer<InternalOptions> optionsConsumer)
throws ExecutionException, IOException, ProguardRuleParserException, CompilationException {
AndroidApp app = runAndCheckVerification(
CompilerUnderTest.R8,
mode,
hasReference ? base + REFERENCE_APK : null,
null,
base + PG_CONF,
optionsConsumer,
// Don't pass any inputs. The input will be read from the -injars in the Proguard
// configuration file.
ImmutableList.of());
int bytes = applicationSize(app);
assertTrue("Expected max size of " + maxSize + ", got " + bytes, bytes < maxSize);
return app;
}
TestDatabaseUpgradeIntegration.java 文件源码
项目:morf
阅读 34
收藏 0
点赞 0
评论 0
/**
* Test:
* 1. Rename BasicTable to BasicTableRenamed
* 2. Add BasicTable
*
* This tests that everything from BasicTable has been correctly renamed.
*/
@Test
public void testRenameFollowedByAdditionUsingOldName() {
Table newTable = table("BasicTableRenamed").columns(
column("stringCol", DataType.STRING, 20).primaryKey(),
column("nullableStringCol", DataType.STRING, 10).nullable(),
column("decimalTenZeroCol", DataType.DECIMAL, 10),
column("decimalNineFiveCol", DataType.DECIMAL, 9, 5),
column("bigIntegerCol", DataType.BIG_INTEGER, 19),
column("nullableBigIntegerCol", DataType.BIG_INTEGER, 19).nullable()
);
List<Table> tables = Lists.newArrayList(schema.tables());
tables.add(newTable);
verifyUpgrade(schema(tables), ImmutableList.<Class<? extends UpgradeStep>>of(RenameTable.class, AddBasicTable.class));
}
AbstractSqlDialectTest.java 文件源码
项目:morf
阅读 37
收藏 0
点赞 0
评论 0
/**
* Test that an Insert statement is generated with a null value
*/
@Test
public void testInsertWithNullDefaults() {
InsertStatement stmt = new InsertStatement().into(new TableReference(TEST_TABLE))
.from(new TableReference(OTHER_TABLE)).withDefaults(
new NullFieldLiteral().as(DATE_FIELD),
new NullFieldLiteral().as(BOOLEAN_FIELD),
new NullFieldLiteral().as(CHAR_FIELD),
new NullFieldLiteral().as(BLOB_FIELD)
);
String expectedSql = "INSERT INTO " + tableName(TEST_TABLE) + " (id, version, stringField, intField, floatField, dateField, booleanField, charField, blobField, bigIntegerField, clobField) SELECT id, version, stringField, intField, floatField, null AS dateField, null AS booleanField, null AS charField, null AS blobField, 12345 AS bigIntegerField, null AS clobField FROM " + tableName(OTHER_TABLE);
List<String> sql = testDialect.convertStatementToSQL(stmt, metadata, SqlDialect.IdTable.withDeterministicName("idvalues"));
assertEquals("Insert with null defaults", ImmutableList.of(expectedSql), sql);
}
TreeTest.java 文件源码
项目:de.flapdoodle.solid
阅读 40
收藏 0
点赞 0
评论 0
@Test
public void parseSampleTree() {
PropertyTree src=FixedPropertyTree.builder()
.put("one", FixedPropertyTree.builder()
.put("name", "A")
.put("children", "A-a")
.put("children", "A-b")
.put("children", "A-c")
.build())
.put("two", FixedPropertyTree.builder()
.put("name", "B")
.build())
.put("3", FixedPropertyTree.builder()
.put("name", "A-a")
.put("children", "A-a-0")
.build())
.build();
Tree tree = Tree.treeOf(src);
assertEquals("Tree{relation={A=[A-a, A-b, A-c], B=[], A-a=[A-a-0]}}",tree.toString());
ImmutableList<Tree.Node> mappedTree = tree.mapAsTree(ImmutableList.of("A-a-0","C","A-a","B","A"));
assertEquals("[Node{name=C, children=[]}, Node{name=B, children=[]}, Node{name=A, children=[Node{name=A-a, children=[Node{name=A-a-0, children=[]}]}]}]", mappedTree.toString());
}
MoreExecutorsTest.java 文件源码
项目:guava-mock
阅读 32
收藏 0
点赞 0
评论 0
public void testListeningDecorator() throws Exception {
ListeningExecutorService service =
listeningDecorator(newDirectExecutorService());
assertSame(service, listeningDecorator(service));
List<Callable<String>> callables =
ImmutableList.of(Callables.returning("x"));
List<Future<String>> results;
results = service.invokeAll(callables);
assertThat(getOnlyElement(results)).isInstanceOf(TrustedListenableFutureTask.class);
results = service.invokeAll(callables, 1, SECONDS);
assertThat(getOnlyElement(results)).isInstanceOf(TrustedListenableFutureTask.class);
/*
* TODO(cpovirk): move ForwardingTestCase somewhere common, and use it to
* test the forwarded methods
*/
}
SimpleTest.java 文件源码
项目:auto-value-step-builder
阅读 45
收藏 0
点赞 0
评论 0
@Test
public void step() throws Exception {
Person person = Person.step()
.id(PERSON_ID)
.names(ImmutableList.of(PERSON_NAME, PERSON_SURNAME))
.phones(ImmutableList.of(PERSON_PHONE))
.homeAddress(
Address.step()
.title(ADDRESS_TITLE)
.street(ADDRESS_STREET)
.city(ADDRESS_CITY)
.postcode(ADDRESS_POSTCODE)
.countryCode(ADDRESS_COUNTRY_CODE)
.optional()
.streetParts(ADDRESS_STREET_PARTS)
.build()
)
.optional()
.workAddress(PERSON_WORK_ADDRESS)
.birthday(PERSON_BIRTHDAY)
.build();
assertPerson(person);
}
NewStoriesControllerTest.java 文件源码
项目:Facegram
阅读 41
收藏 0
点赞 0
评论 0
@Test
public void shouldGetNewStoriesOfLocation() throws Exception{
Story story = generateStory();
Geolocation geolocation = new Geolocation();
geolocation.setLatitude(0);
geolocation.setLongitude(0);
MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
params.add("latitude",String.valueOf(geolocation.getLatitude()));
params.add("longitude",String.valueOf(geolocation.getLongitude()));
when(newStoriesService.getStoriesOfLocation(any(Geolocation.class))).thenReturn(ImmutableList.of(story));
mockMvc.perform(get("/newStories/location").params(params))
.andExpect(jsonPath("$[0].id").value(story.getId()))
.andExpect(status().isOk());
}
DexBuilder.java 文件源码
项目:andbg
阅读 35
收藏 0
点赞 0
评论 0
@Nonnull public BuilderMethod internMethod(@Nonnull String definingClass,
@Nonnull String name,
@Nullable List<? extends MethodParameter> parameters,
@Nonnull String returnType,
int accessFlags,
@Nonnull Set<? extends Annotation> annotations,
@Nullable MethodImplementation methodImplementation) {
if (parameters == null) {
parameters = ImmutableList.of();
}
return new BuilderMethod(context.methodPool.internMethod(definingClass, name, parameters, returnType),
internMethodParameters(parameters),
accessFlags,
context.annotationSetPool.internAnnotationSet(annotations),
methodImplementation);
}
UtilsTest.java 文件源码
项目:LifecycleAware
阅读 37
收藏 0
点赞 0
评论 0
@Test
public void testDistinctByKey() throws Exception {
List<TestPair> testPairList =
ImmutableList.of(
new TestPair("a", "1"),
new TestPair("a", "2"),
new TestPair("a", "3"),
new TestPair("b", "1")
);
List<TestPair> distinctByFirst = testPairList.stream()
.filter(Utils.distinctByKey(testPair -> testPair.first))
.collect(Collectors.toList());
Assert.assertNotEquals(testPairList, distinctByFirst);
Assert.assertEquals(2, distinctByFirst.size());
}
AuthorityClassifierBuilderTest.java 文件源码
项目:url-classifier
阅读 36
收藏 0
点赞 0
评论 0
private static void runTests(
AuthorityClassifier p,
ImmutableMap<Classification, ImmutableList<String>> inputs) {
Diagnostic.CollectingReceiver<UrlValue> cr = Diagnostic.CollectingReceiver.from(
TestUtil.STDERR_RECEIVER);
try {
for (Map.Entry<Classification, ImmutableList<String>> e
: inputs.entrySet()) {
Classification want = e.getKey();
ImmutableList<String> inputList = e.getValue();
for (int i = 0; i < inputList.size(); ++i) {
cr.clear();
String url = inputList.get(i);
UrlValue inp = UrlValue.from(TEST_URL_CONTEXT, url);
Classification got = p.apply(inp, cr);
assertEquals(i + ": " + url, want, got);
}
cr.clear();
}
} finally {
cr.flush();
}
}
MoshiClassBuilder.java 文件源码
项目:json2java4idea
阅读 39
收藏 0
点赞 0
评论 0
@Nonnull
@Override
protected List<MethodSpec> buildMethods() {
final MethodSpec.Builder constructorBuilder = MethodSpec.constructorBuilder()
.addModifiers(Modifier.PUBLIC);
final ImmutableList.Builder<MethodSpec> builder = ImmutableList.builder();
getProperties().entrySet().forEach(property -> {
final String name = property.getKey();
final TypeName type = property.getValue();
final String fieldName = fieldNamePolicy.convert(name, type);
final String methodName = methodNamePolicy.convert(name, type);
builder.add(MethodSpec.methodBuilder(methodName)
.addModifiers(Modifier.PUBLIC)
.returns(type)
.addStatement("return $L", fieldName)
.build());
final String propertyName = parameterNamePolicy.convert(name, type);
constructorBuilder.addParameter(ParameterSpec.builder(type, propertyName)
.build())
.addStatement("this.$L = $L", fieldName, propertyName);
});
builder.add(constructorBuilder.build());
return builder.build();
}
AbstractNonStreamingHashFunctionTest.java 文件源码
项目:guava-mock
阅读 38
收藏 0
点赞 0
评论 0
/**
* Constructs two trivial HashFunctions (output := input), one streaming and one non-streaming,
* and checks that their results are identical, no matter which newHasher version we used.
*/
public void testExhaustive() {
List<Hasher> hashers = ImmutableList.of(
new StreamingVersion().newHasher(),
new StreamingVersion().newHasher(52),
new NonStreamingVersion().newHasher(),
new NonStreamingVersion().newHasher(123));
Random random = new Random(0);
for (int i = 0; i < 200; i++) {
RandomHasherAction.pickAtRandom(random).performAction(random, hashers);
}
HashCode[] codes = new HashCode[hashers.size()];
for (int i = 0; i < hashers.size(); i++) {
codes[i] = hashers.get(i).hash();
}
for (int i = 1; i < codes.length; i++) {
assertEquals(codes[i - 1], codes[i]);
}
}
TypeTest.java 文件源码
项目:GitHub
阅读 36
收藏 0
点赞 0
评论 0
@Test
public void parseWildcards() {
check(parser.parse("List<?>")).is(
factory.parameterized(
factory.reference("List"),
ImmutableList.of(
factory.extendsWildcard(Type.OBJECT))));
check(parser.parse("Map<? extends List<? extends A>, ? super B>")).is(
factory.parameterized(
factory.reference("Map"),
ImmutableList.of(
factory.extendsWildcard(
factory.parameterized(
factory.reference("List"),
ImmutableList.of(
factory.extendsWildcard(
parameters.variable("A"))))),
factory.superWildcard(
parameters.variable("B")))));
}
AndroidLibraryImpl.java 文件源码
项目:atlas
阅读 33
收藏 0
点赞 0
评论 0
AndroidLibraryImpl(
@NonNull AndroidDependency clonedLibrary,
boolean isProvided,
boolean isSkipped,
@NonNull List<AndroidLibrary> androidLibraries,
@NonNull Collection<JavaLibrary> javaLibraries,
@NonNull Collection<File> localJavaLibraries) {
super(
clonedLibrary.getProjectPath(),
null,
clonedLibrary.getCoordinates(),
isSkipped,
isProvided);
this.androidLibraries = ImmutableList.copyOf(androidLibraries);
this.javaLibraries = ImmutableList.copyOf(javaLibraries);
//FIXME , add localJar later at prepareAllDependencies
this.localJars = new ArrayList<>(localJavaLibraries);
variant = clonedLibrary.getVariant();
bundle = clonedLibrary.getArtifactFile();
folder = clonedLibrary.getExtractedFolder();
manifest = clonedLibrary.getManifest();
jarFile = clonedLibrary.getJarFile();
resFolder = clonedLibrary.getResFolder();
assetsFolder = clonedLibrary.getAssetsFolder();
jniFolder = clonedLibrary.getJniFolder();
aidlFolder = clonedLibrary.getAidlFolder();
renderscriptFolder = clonedLibrary.getRenderscriptFolder();
proguardRules = clonedLibrary.getProguardRules();
lintJar = clonedLibrary.getLintJar();
annotations = clonedLibrary.getExternalAnnotations();
publicResources = clonedLibrary.getPublicResources();
symbolFile = clonedLibrary.getSymbolFile();
hashcode = computeHashCode();
}
AssertionDecrypter.java 文件源码
项目:verify-hub
阅读 33
收藏 0
点赞 0
评论 0
private Assertion decrypt(EncryptedAssertion encryptedAssertion) {
Decrypter decrypter = new DecrypterFactory().createDecrypter(ImmutableList.of(new BasicCredential(publicKey, privateKey)));
decrypter.setRootInNewDocument(true);
try {
return decrypter.decrypt(encryptedAssertion);
} catch (DecryptionException e) {
throw new RuntimeException(e);
}
}
TypeTokenTest.java 文件源码
项目:guava-mock
阅读 55
收藏 0
点赞 0
评论 0
public <T extends List<String>> void testMethod_parameterTypes()
throws NoSuchMethodException {
Method setMethod = List.class.getMethod("set", int.class, Object.class);
Invokable<T, ?> invokable = new TypeToken<T>(getClass()) {}.method(setMethod);
ImmutableList<Parameter> params = invokable.getParameters();
assertEquals(2, params.size());
assertEquals(TypeToken.of(int.class), params.get(0).getType());
assertEquals(TypeToken.of(String.class), params.get(1).getType());
}
ParameterDefinitionResourceProviderTest.java 文件源码
项目:dotwebstack-framework
阅读 52
收藏 0
点赞 0
评论 0
@Test
public void loadResources_GetResources_WithValidData() {
// Arrange
when(graphQueryMock.evaluate()).thenReturn(new IteratingGraphQueryResult(ImmutableMap.of(),
ImmutableList.of(
VALUE_FACTORY.createStatement(DBEERPEDIA.NAME_PARAMETER_ID, RDF.TYPE, ELMO.TERM_FILTER),
VALUE_FACTORY.createStatement(DBEERPEDIA.NAME_PARAMETER_ID, ELMO.NAME_PROP,
DBEERPEDIA.NAME_PARAMETER_VALUE),
VALUE_FACTORY.createStatement(DBEERPEDIA.PLACE_PARAMETER_ID, RDF.TYPE,
ELMO.TERM_FILTER),
VALUE_FACTORY.createStatement(DBEERPEDIA.PLACE_PARAMETER_ID, ELMO.NAME_PROP,
DBEERPEDIA.PLACE_PARAMETER_VALUE))));
when(parameterDefinitionFactoryMock.supports(ELMO.TERM_FILTER)).thenReturn(true);
ParameterDefinition nameParameterDefinition = mock(ParameterDefinition.class);
when(parameterDefinitionFactoryMock.create(Mockito.any(),
Mockito.eq(DBEERPEDIA.NAME_PARAMETER_ID))).thenReturn(nameParameterDefinition);
ParameterDefinition placeParameterDefinition = mock(ParameterDefinition.class);
when(parameterDefinitionFactoryMock.create(Mockito.any(),
Mockito.eq(DBEERPEDIA.PLACE_PARAMETER_ID))).thenReturn(placeParameterDefinition);
// Act
provider.loadResources();
// Assert
assertThat(provider.getAll().entrySet(), hasSize(2));
assertThat(provider.get(DBEERPEDIA.NAME_PARAMETER_ID), sameInstance(nameParameterDefinition));
assertThat(provider.get(DBEERPEDIA.PLACE_PARAMETER_ID), sameInstance(placeParameterDefinition));
}
RktCommandResourceTest.java 文件源码
项目:rkt-launcher
阅读 32
收藏 0
点赞 0
评论 0
@Test
public void shouldRunTrustWithoutPayloadMultiple() throws Exception {
sinceVersion(Api.Version.V0);
final Trust trust = Trust.builder()
.args(ImmutableList.of("http://example.com/pubkey1", "http://example.com/pubkey2"))
.build();
final TrustOutput trustOutput = TrustOutput.builder()
.addTrustedPubkey(TrustedPubkey.builder()
.prefix("")
.key("http://example.com/pubkey1")
.location("")
.build())
.addTrustedPubkey(TrustedPubkey.builder()
.prefix("")
.key("http://example.com/pubkey2")
.location("")
.build())
.build();
when(rktLauncher.run(trust)).thenReturn(trustOutput);
final Response<ByteString> response = awaitResponse(
serviceHelper
.request(DEFAULT_HTTP_METHOD, path("/trust?pubkey=http://example.com/pubkey1"
+ "&pubkey=http://example.com/pubkey2")));
assertThat(response, hasStatus(belongsToFamily(StatusType.Family.SUCCESSFUL)));
assertTrue(response.payload().isPresent());
assertEquals(trustOutput,
Json.deserialize(response.payload().get().toByteArray(), TrustOutput.class));
}
TransactionalContinuousResourceSubStore.java 文件源码
项目:athena
阅读 43
收藏 0
点赞 0
评论 0
private boolean appendValue(ContinuousResource original, ResourceAllocation value) {
ContinuousResourceAllocation oldValue = consumers.putIfAbsent(original.id(),
new ContinuousResourceAllocation(original, ImmutableList.of(value)));
if (oldValue == null) {
return true;
}
ContinuousResourceAllocation newValue = oldValue.allocate(value);
return consumers.replace(original.id(), oldValue, newValue);
}
TestSchedule.java 文件源码
项目:dremio-oss
阅读 39
收藏 0
点赞 0
评论 0
private static Object[] newTestCase(String name, Schedule schedule, String[] events) {
ImmutableList.Builder<Instant> builder = ImmutableList.builder();
for(String event: events) {
builder.add(Instant.parse(event));
}
return new Object[] { name, schedule, builder.build() };
}
HashingTest.java 文件源码
项目:guava-mock
阅读 35
收藏 0
点赞 0
评论 0
public void testAllHashFunctionsHaveKnownHashes() throws Exception {
// The following legacy hashing function methods have been covered by unit testing already.
List<String> legacyHashingMethodNames = ImmutableList.of("murmur2_64", "fprint96");
for (Method method : Hashing.class.getDeclaredMethods()) {
if (method.getReturnType().equals(HashFunction.class) // must return HashFunction
&& Modifier.isPublic(method.getModifiers()) // only the public methods
&& method.getParameterTypes().length == 0 // only the seed-less grapes^W hash functions
&& !legacyHashingMethodNames.contains(method.getName())) {
HashFunction hashFunction = (HashFunction) method.invoke(Hashing.class);
assertTrue("There should be at least 3 entries in KNOWN_HASHES for " + hashFunction,
KNOWN_HASHES.row(hashFunction).size() >= 3);
}
}
}
BindViewTest.java 文件源码
项目:GitHub
阅读 32
收藏 0
点赞 0
评论 0
@Test public void bindingGeneratedView() {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", ""
+ "package test;\n"
+ "import butterknife.BindView;\n"
+ "@PerformGeneration\n"
+ "public class Test {\n"
+ " @BindView(1) GeneratedView thing;\n"
+ "}"
);
// w/o the GeneratingProcessor it can't find `class GeneratedView`
assertAbout(javaSources()).that(ImmutableList.of(source, TestGeneratingProcessor.ANNOTATION))
.processedWith(new ButterKnifeProcessor())
.failsToCompile()
.withErrorContaining("cannot find symbol");
// now the GeneratingProcessor should let it compile
assertAbout(javaSources()).that(ImmutableList.of(source, TestGeneratingProcessor.ANNOTATION))
.processedWith(new ButterKnifeProcessor(), new TestGeneratingProcessor("GeneratedView",
"package test;",
"import android.content.Context;",
"import android.view.View;",
"public class GeneratedView extends View {",
" public GeneratedView(Context context) {",
" super(context);",
" }",
"}"
))
.compilesWithoutError()
.withNoteContaining("@BindView field with unresolved type (GeneratedView)").and()
.withNoteContaining("must elsewhere be generated as a View or interface").and()
.and()
.generatesFileNamed(StandardLocation.CLASS_OUTPUT, "test", "Test_ViewBinding.class");
}