当前位置: 首页>>代码示例>>Java>>正文


Java Sets.newHashSet方法代码示例

本文整理汇总了Java中com.beust.jcommander.internal.Sets.newHashSet方法的典型用法代码示例。如果您正苦于以下问题:Java Sets.newHashSet方法的具体用法?Java Sets.newHashSet怎么用?Java Sets.newHashSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.beust.jcommander.internal.Sets的用法示例。


在下文中一共展示了Sets.newHashSet方法的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);
    }
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:19,代码来源:TokenSupplierTest.java

示例2: 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;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:20,代码来源:AqlJSonResultTest.java

示例3: 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"));
}
 
开发者ID:w11k,项目名称:lsql,代码行数:21,代码来源:LSqlTest.java

示例4: 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
}
 
开发者ID:jivesoftware,项目名称:amza,代码行数:17,代码来源:AmzaBotEndpointsTest.java

示例5: 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);
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:23,代码来源:VerbatimProcessorTest.java

示例6: 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");
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:22,代码来源:OccurrenceInterpreterTest.java

示例7: 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());
    }
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:30,代码来源:UploadCertFilesPathValidator.java

示例8: 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));
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:16,代码来源:EntityBeanGeneratorTest.java

示例9: 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());
    }
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:30,代码来源:OrganizationTest.java

示例10: 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());
    }
}
 
开发者ID:conveyal,项目名称:osm-lib,代码行数:38,代码来源:NodeTrackerTest.java

示例11: 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;
}
 
开发者ID:prestodb,项目名称:tempto,代码行数:14,代码来源:TestInitializationListener.java

示例12: listKeys

import com.beust.jcommander.internal.Sets; //导入方法依赖的package包/类
@Override
public Set<String> listKeys()
{
    Set<String> acc = Sets.newHashSet();
    listKeys(map, null, acc);
    return acc;
}
 
开发者ID:prestodb,项目名称:tempto,代码行数:8,代码来源:MapConfiguration.java

示例13: testListQuery

import com.beust.jcommander.internal.Sets; //导入方法依赖的package包/类
@Test
public void testListQuery() {
  final Set<Long> ids = Sets.newHashSet();
  ids.add(saveQuery().getId());
  ids.add(saveQuery().getId());
  ids.add(saveQuery().getId());
  ids.add(saveQuery().getId());
  final ListResponse list = list(0, 4);
  final List<SavedQuery> queries = list.getResoures();
  assertEquals(ids.size(), queries.size());
}
 
开发者ID:apache,项目名称:lens,代码行数:12,代码来源:TestSavedQueryService.java

示例14: setup

import com.beust.jcommander.internal.Sets; //导入方法依赖的package包/类
@BeforeClass
@SuppressWarnings("unchecked")
public void setup() throws IOException {
    jsonSource = JsonUtils.jsonToObject(jsonSourceString);
    // added for type cast checking
    Set<String> aSet = Sets.newHashSet();
    aSet.add("i");
    aSet.add("j");
    ((Map) jsonSource).put("s", aSet);
}
 
开发者ID:bazaarvoice,项目名称:jolt,代码行数:11,代码来源:JsonUtilsTest.java

示例15: testNeoIndices

import com.beust.jcommander.internal.Sets; //导入方法依赖的package包/类
@Test
public void testNeoIndices() throws Exception {
  final UUID datasetKey = datasetKey(1);

  Normalizer norm = Normalizer.create(cfg, datasetKey);
  norm.run();

  openDb(datasetKey);
  compareStats(norm.getStats());

  Set<String> taxonIndices = Sets.newHashSet();
  taxonIndices.add(NeoProperties.TAXON_ID);
  taxonIndices.add(NeoProperties.SCIENTIFIC_NAME);
  taxonIndices.add(NeoProperties.CANONICAL_NAME);
  try (Transaction tx = beginTx()) {
    Schema schema = dao.getNeo().schema();
    for (IndexDefinition idf : schema.getIndexes(Labels.TAXON)) {
      List<String> idxProps = Iterables.asList(idf.getPropertyKeys());
      assertTrue(idxProps.size() == 1);
      assertTrue(taxonIndices.remove(idxProps.get(0)));
    }

    assertNotNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.TAXON_ID, "1001")));
    assertNotNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.SCIENTIFIC_NAME, "Crepis bakeri Greene")));
    assertNotNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.CANONICAL_NAME, "Crepis bakeri")));

    assertNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.TAXON_ID, "x1001")));
    assertNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.SCIENTIFIC_NAME, "xCrepis bakeri Greene")));
    assertNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.CANONICAL_NAME, "xCrepis bakeri")));
  }
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:32,代码来源:NormalizerTest.java


注:本文中的com.beust.jcommander.internal.Sets.newHashSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。