本文整理汇总了Java中com.beust.jcommander.internal.Sets类的典型用法代码示例。如果您正苦于以下问题:Java Sets类的具体用法?Java Sets怎么用?Java Sets使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Sets类属于com.beust.jcommander.internal包,在下文中一共展示了Sets类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sanityTestGet
import com.beust.jcommander.internal.Sets; //导入依赖的package包/类
@Test
public void sanityTestGet() {
TokenSupplier supplier = new TokenSupplier();
Set<String> previous = Sets.newHashSet();
for (int i = 0; i < 1000; i++) {
String current = supplier.get();
// not the same
assertFalse(previous.contains(current));
// check length
assertEquals(24, current.length());
previous.add(current);
}
}
示例2: getDomainApplicationMap
import com.beust.jcommander.internal.Sets; //导入依赖的package包/类
/** Return a set of all fully-qualified domain names with open applications. */
private static Set<String> getDomainApplicationMap(final String tld) {
return ofy()
.transact(
() -> {
Set<String> labels = Sets.newHashSet();
List<DomainApplication> domainApplications;
domainApplications =
ofy().load().type(DomainApplication.class).filter("tld", tld).list();
for (DomainApplication domainApplication : domainApplications) {
// Ignore deleted and rejected applications. They aren't under consideration.
ApplicationStatus applicationStatus = domainApplication.getApplicationStatus();
DateTime deletionTime = domainApplication.getDeletionTime();
if (applicationStatus == REJECTED
|| isAtOrAfter(ofy().getTransactionTime(), deletionTime)) {
continue;
}
labels.add(domainApplication.getFullyQualifiedDomainName());
}
return labels;
});
}
示例3: contains
import com.beust.jcommander.internal.Sets; //导入依赖的package包/类
private boolean contains(Map resultMap, Map expectedMap) {
for (Object o : resultMap.keySet()) {
Object result = resultMap.get(o);
Object expected = expectedMap.get(o);
if (result instanceof Map) {
contains((Map) result, (Map) expected);
} else if (result instanceof List) {
Set<Object> resultSet = Sets.newHashSet();
resultSet.addAll((List) result);
Set<Object> expectedSet = Sets.newHashSet();
resultSet.addAll((List) expected);
contains(resultSet, expectedSet);
} else if (!result.equals(expected)) {
return false;
}
}
return true;
}
示例4: fetchMetaDataForAllTables
import com.beust.jcommander.internal.Sets; //导入依赖的package包/类
@Test
public void fetchMetaDataForAllTables() throws SQLException {
createTable("CREATE TABLE table1 (a TEXT, b INT)");
createTable("CREATE TABLE table2 (c TEXT, d INT)");
lSql.fetchMetaDataForAllTables();
Set<String> tableWithColumns = Sets.newHashSet();
Iterable<Table> tables = lSql.getTables();
for (Table table : tables) {
for (Column column : table.getColumns().values()) {
tableWithColumns.add(table.getTableName() + "-" + column.getJavaColumnName());
}
}
assertTrue(tableWithColumns.contains("table1-a"));
assertTrue(tableWithColumns.contains("table1-b"));
assertTrue(tableWithColumns.contains("table2-c"));
assertTrue(tableWithColumns.contains("table2-d"));
}
示例5: verifyBatchSetPost
import com.beust.jcommander.internal.Sets; //导入依赖的package包/类
@Test
public void verifyBatchSetPost() throws Exception {
Set<Entry<String, String>> set = Sets.newHashSet();
set.add(new AbstractMap.SimpleEntry<>("foo", "bar"));
set.add(new AbstractMap.SimpleEntry<>("ham", "eggs"));
String setJson = new ObjectMapper().writeValueAsString(set);
Assert.assertEquals(setJson, "[{\"ham\":\"eggs\"},{\"foo\":\"bar\"}]");
// i.e.
//
// curl -X POST \
// -H "Content-Type:application/json" \
// -d '[{"ham":"eggs"},{"foo":"bar"}]' \
// 10.126.5.87:10000/api/amzabot/v1/keys
}
示例6: setUp
import com.beust.jcommander.internal.Sets; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
long now = new Date().getTime();
zkServer = new TestingServer();
curator = CuratorFrameworkFactory.builder().connectString(zkServer.getConnectString()).namespace("crawler")
.retryPolicy(new RetryNTimes(1, 1000)).build();
curator.start();
zookeeperConnector = new ZookeeperConnector(curator);
fragmentService = new FragmentPersistenceServiceMock(new OccurrenceKeyPersistenceServiceMock());
String json = Resources.toString(Resources.getResource("fragment.json"), org.apache.commons.io.Charsets.UTF_8);
Fragment fragment = new Fragment(DATASET_KEY, json.getBytes(Charsets.UTF_8), json.getBytes(Charsets.UTF_8),
Fragment.FragmentType.JSON, EndpointType.DWC_ARCHIVE, new Date(), 1, null, null, new Date().getTime());
Set<UniqueIdentifier> uniqueIds = Sets.newHashSet();
uniqueIds.add(new HolyTriplet(DATASET_KEY, "ic", "cc", "cn", null));
fragmentService.insert(fragment, uniqueIds);
occurrenceService = new OccurrencePersistenceServiceMock(fragmentService);
verbatimProcessor = new VerbatimProcessor(fragmentService, occurrenceService, messagePublisher, zookeeperConnector);
FragmentPersistedListener fragmentPersistedListener = new FragmentPersistedListener(verbatimProcessor);
MessageListener messageListener = new MessageListener(CONNECTION_PARAMETERS);
messageListener.listen("frag_persisted_test_" + now, 1, fragmentPersistedListener);
}
示例7: setUp
import com.beust.jcommander.internal.Sets; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
ApiClientConfiguration cfg = new ApiClientConfiguration();;
cfg.url = URI.create("http://api.gbif-dev.org/v1/");
FragmentPersistenceService fragmentPersister =
new FragmentPersistenceServiceMock(new OccurrenceKeyPersistenceServiceMock());
Fragment fragment = new Fragment(DATASET_KEY, "fake".getBytes(Charsets.UTF_8), "fake".getBytes(Charsets.UTF_8),
Fragment.FragmentType.JSON, EndpointType.DWC_ARCHIVE, new Date(), 1, null, null, new Date().getTime());
Set<UniqueIdentifier> uniqueIds = Sets.newHashSet();
uniqueIds.add(new HolyTriplet(DATASET_KEY, "ic", "cc", "cn", null));
fragmentPersister.insert(fragment, uniqueIds);
interpreter = new OccurrenceInterpreter(new DatasetInfoInterpreter(cfg.newApiClient()),
new TaxonomyInterpreter(cfg.newApiClient()),
new LocationInterpreter(new CoordinateInterpreter(cfg.newApiClient())));
verb = buildVerbatim(fragment.getKey());
verbMod = buildVerbatim(fragment.getKey());
verbMod.setVerbatimField(DwcTerm.scientificName, "Panthera onca goldmani");
}
示例8: describeClassTree
import com.beust.jcommander.internal.Sets; //导入依赖的package包/类
/**
* Given an object return the set of classes that it extends
* or implements.
*
* @param arg object to describe
* @return set of classes that are implemented or extended by that object
*/
private static Set<Class<?>> describeClassTree(Class<?> inputClass) {
if(inputClass == null) {
return Collections.emptySet();
}
// create result collector
Set<Class<?>> classes = Sets.newLinkedHashSet();
// describe tree
describeClassTree(inputClass, classes);
return classes;
}
示例9: validate
import com.beust.jcommander.internal.Sets; //导入依赖的package包/类
@Override
public void validate(final String name, final Path value) throws ParameterException {
if (value == null) {
throw new ParameterException("Value must be specified.");
}
final File certDirectory = value.toFile();
final Set<String> filenames = Sets.newHashSet();
if (!certDirectory.canRead()) {
throw new ParameterException("Specified path is not readable.");
}
if (!certDirectory.isDirectory()) {
throw new ParameterException("Specified path is not a directory.");
}
final FilenameFilter filter = new RegexFileFilter("^.*\\.pem$");
final File[] files = certDirectory.listFiles(filter);
Arrays.stream(files).forEach(file -> filenames.add(file.getName()));
if (!filenames.containsAll(EXPECTED_FILE_NAMES)) {
final StringJoiner sj = new StringJoiner(", ", "[", "]");
EXPECTED_FILE_NAMES.stream().forEach(sj::add);
throw new ParameterException("Not all expected files are present! Expected: " + sj.toString());
}
}
示例10: beanShouldImplementEqualsAndHashcode
import com.beust.jcommander.internal.Sets; //导入依赖的package包/类
@Test
public void beanShouldImplementEqualsAndHashcode() throws Exception
{
RepositoryPullRequestMapping bean1 = generator.createInstanceOf(RepositoryPullRequestMapping.class);
RepositoryPullRequestMapping bean2 = generator.createInstanceOf(RepositoryPullRequestMapping.class);
Set<RepositoryPullRequestMapping> set = Sets.newHashSet();
set.add(bean1);
set.add(bean2);
assertEquals(set.size(), 2);
set.remove(bean1);
assertEquals(set.size(), 1);
assertEquals(true, set.contains(bean2));
}
示例11: testClonedInstance
import com.beust.jcommander.internal.Sets; //导入依赖的package包/类
@Test
public void testClonedInstance()
{
final Organization original = new Organization();
final List<Group> groups = ImmutableList.of(new Group("slug", "group"));
final Set<Group> defaultGroups = Sets.newHashSet();
defaultGroups.add(new Group("slug", "default"));
original.setAutolinkNewRepos(true);
original.setCredential(new Credential("oauthKey", "oauthSecret", "accessToken"));
original.setDefaultGroups(defaultGroups);
original.setDvcsType("bitbucket");
original.setHostUrl("hostUrl");
original.setId(100);
original.setName("name");
original.setGroups(groups);
original.setOrganizationUrl("url");
original.setSmartcommitsOnNewRepos(true);
Organization clonedOrg = new Organization(original);
assertThat(clonedOrg).isNotSameAs(original);
assertThat(EqualsBuilder.reflectionEquals(clonedOrg, original)).isTrue();
// assert transient fields missed by EqualsBuilder.reflectionEquals
assertThat(clonedOrg.getCredential().equals(original.getCredential())).isTrue();
assertThat(clonedOrg.getDefaultGroups().iterator().next()).isSameAs(original.getDefaultGroups().iterator().next());
assertThat(clonedOrg.getGroups().iterator().next()).isSameAs(original.getGroups().iterator().next());
}
示例12: testAgainstSet
import com.beust.jcommander.internal.Sets; //导入依赖的package包/类
/**
* Check the NodeTracker against a stock Set<Long>.
* This is done in ranges that will include numbers significantly greater than 2^32
*/
public void testAgainstSet() {
final int N = 1000;
// Set N numbers in each of four different ranges.
Set<Long> numbers = Sets.newHashSet();
NodeTracker tracker = new NodeTracker();
for (long lo : new long[] {1L << 6, 1L << 16, 1L << 34, 1L << 50} ) {
// Simultaneously set up a basic Set<Long> that will serve as a reference
// and a NodeTracker that we want to test.
long hi = 0L;
for (int i = 0; i < 1000; i++) {
long n = i * i + lo;
numbers.add(n);
tracker.add(n);
hi = n;
}
// Check that the two set implementations match for every value in the range (including unset ones).
// Note that a Set<Long> containing 0L returns false for contains((int)0).
for (long i = lo; i < hi; i++) {
if (tracker.contains(i)) {
assertTrue(numbers.contains(i));
} else {
assertFalse(numbers.contains(i));
}
if (numbers.contains(i)) {
assertTrue(tracker.contains(i));
} else {
assertFalse(tracker.contains(i));
}
}
assertEquals(numbers.size(), tracker.cardinality());
}
}
示例13: resolveAllTestsRequirements
import com.beust.jcommander.internal.Sets; //导入依赖的package包/类
private Set<Requirement> resolveAllTestsRequirements(ITestContext context)
{
// we cannot assume that context contains RequirementsAwareTestNGMethod instances here
// as interceptor is for some reason called after onStart() which uses this method.
Set<Requirement> allTestsRequirements = Sets.newHashSet();
for (ITestNGMethod iTestNGMethod : context.getAllTestMethods()) {
Set<Set<Requirement>> requirementsSets = new TestSpecificRequirementsResolver(configuration).resolve(iTestNGMethod);
for (Set<Requirement> requirementsSet : requirementsSets) {
allTestsRequirements.addAll(requirementsSet);
}
}
return allTestsRequirements;
}
示例14: listKeys
import com.beust.jcommander.internal.Sets; //导入依赖的package包/类
@Override
public Set<String> listKeys()
{
Set<String> acc = Sets.newHashSet();
listKeys(map, null, acc);
return acc;
}
示例15: testGetTotalQueryCostForUserWithZeroLaunchedQueries
import com.beust.jcommander.internal.Sets; //导入依赖的package包/类
@Test
public void testGetTotalQueryCostForUserWithZeroLaunchedQueries() throws LensException {
QueryCollection mockQueries = mock(QueryCollection.class);
when(mockQueries.getQueries(MOCK_USER)).thenReturn(Sets.<QueryContext>newLinkedHashSet());
EstimatedQueryCollection queries = new DefaultEstimatedQueryCollection(mockQueries);
QueryCost actualQueryCost = queries.getTotalQueryCost(MOCK_USER);
assertEquals(actualQueryCost, new StaticQueryCost(0));
}