本文整理汇总了Java中org.testng.collections.Maps类的典型用法代码示例。如果您正苦于以下问题:Java Maps类的具体用法?Java Maps怎么用?Java Maps使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Maps类属于org.testng.collections包,在下文中一共展示了Maps类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDocTest
import org.testng.collections.Maps; //导入依赖的package包/类
@Test
void createDocTest()
{
BaseIndexer indexer = new SolrIndexer("", TEST1);
List<String> languages = Lists.newArrayList();
languages.add(LOCALE);
Map<String, Object> createdDoc = indexer.createDoc(ID, ENGLISH_TITLE, SPANISH_TITLE, ALT_TITLE, languages);
Map<String, Object> expectedDoc = Maps.newHashMap();
expectedDoc.put(Properties.idField.get(), ID + "_" + TEST1);
expectedDoc.put(Properties.titleFields.get().get(0) + "_en", ENGLISH_TITLE);
Set<Object> localizedTitles = Sets.newHashSet();
localizedTitles.add(SPANISH_TITLE);
expectedDoc.put(Properties.titleFields.get().get(0) + "_es", localizedTitles);
expectedDoc.put(Properties.docTypeFieldName.get(), TEST1);
Assert.assertEquals(createdDoc, expectedDoc);
StringBuilder jsonStringOfDoc = indexer.getJsonStringOfDoc(new ObjectMapper().valueToTree(createdDoc));
Assert.assertEquals(jsonStringOfDoc.toString(), "[{\"query_testing_type\":\"test1\",\"title_en\":\"title en\",\"id\":\"123_test1\",\"title_es\":[\"title es\"]}]");
String urlForAddingDoc = indexer.getUrlForAddingDoc(createdDoc);
Assert.assertEquals(urlForAddingDoc, "http://localhost:8983/solr/qtest/update");
String urlForCommitting = indexer.getUrlForCommitting();
Assert.assertEquals(urlForCommitting, "http://localhost:8983/solr/qtest/update?commit=true");
}
示例2: setup
import org.testng.collections.Maps; //导入依赖的package包/类
@Override
protected void setup() throws Exception {
super.internalSetup();
super.producerBaseSetup();
pulsarSpoutConf = new PulsarSpoutConfiguration();
pulsarSpoutConf.setServiceUrl(serviceUrl);
pulsarSpoutConf.setTopic(topic);
pulsarSpoutConf.setSubscriptionName(subscriptionName);
pulsarSpoutConf.setMessageToValuesMapper(messageToValuesMapper);
pulsarSpoutConf.setFailedRetriesTimeout(1, TimeUnit.SECONDS);
pulsarSpoutConf.setMaxFailedRetries(2);
pulsarSpoutConf.setSharedConsumerEnabled(true);
pulsarSpoutConf.setMetricsTimeIntervalInSecs(60);
consumerConf = new ConsumerConfiguration();
consumerConf.setSubscriptionType(SubscriptionType.Shared);
spout = new PulsarSpout(pulsarSpoutConf, new ClientConfiguration(), consumerConf);
mockCollector = new MockSpoutOutputCollector();
SpoutOutputCollector collector = new SpoutOutputCollector(mockCollector);
TopologyContext context = mock(TopologyContext.class);
when(context.getThisComponentId()).thenReturn("test-spout-" + methodName);
when(context.getThisTaskId()).thenReturn(0);
spout.open(Maps.newHashMap(), context, collector);
producer = pulsarClient.createProducer(topic);
}
示例3: testSharedConsumer
import org.testng.collections.Maps; //导入依赖的package包/类
@Test
public void testSharedConsumer() throws Exception {
PersistentTopicStats topicStats = admin.persistentTopics().getStats(topic);
Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1);
PulsarSpout otherSpout = new PulsarSpout(pulsarSpoutConf, new ClientConfiguration(), consumerConf);
MockSpoutOutputCollector otherMockCollector = new MockSpoutOutputCollector();
SpoutOutputCollector collector = new SpoutOutputCollector(otherMockCollector);
TopologyContext context = mock(TopologyContext.class);
when(context.getThisComponentId()).thenReturn("test-spout-" + methodName);
when(context.getThisTaskId()).thenReturn(1);
otherSpout.open(Maps.newHashMap(), context, collector);
topicStats = admin.persistentTopics().getStats(topic);
Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1);
otherSpout.close();
topicStats = admin.persistentTopics().getStats(topic);
Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1);
}
示例4: testNoSharedConsumer
import org.testng.collections.Maps; //导入依赖的package包/类
@Test
public void testNoSharedConsumer() throws Exception {
PersistentTopicStats topicStats = admin.persistentTopics().getStats(topic);
Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1);
pulsarSpoutConf.setSharedConsumerEnabled(false);
PulsarSpout otherSpout = new PulsarSpout(pulsarSpoutConf, new ClientConfiguration(), consumerConf);
MockSpoutOutputCollector otherMockCollector = new MockSpoutOutputCollector();
SpoutOutputCollector collector = new SpoutOutputCollector(otherMockCollector);
TopologyContext context = mock(TopologyContext.class);
when(context.getThisComponentId()).thenReturn("test-spout-" + methodName);
when(context.getThisTaskId()).thenReturn(1);
otherSpout.open(Maps.newHashMap(), context, collector);
topicStats = admin.persistentTopics().getStats(topic);
Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 2);
otherSpout.close();
topicStats = admin.persistentTopics().getStats(topic);
Assert.assertEquals(topicStats.subscriptions.get(subscriptionName).consumers.size(), 1);
}
示例5: testFailedConsumer
import org.testng.collections.Maps; //导入依赖的package包/类
@Test
public void testFailedConsumer() throws Exception {
PulsarSpoutConfiguration pulsarSpoutConf = new PulsarSpoutConfiguration();
pulsarSpoutConf.setServiceUrl(serviceUrl);
pulsarSpoutConf.setTopic("persistent://invalidTopic");
pulsarSpoutConf.setSubscriptionName(subscriptionName);
pulsarSpoutConf.setMessageToValuesMapper(messageToValuesMapper);
pulsarSpoutConf.setFailedRetriesTimeout(1, TimeUnit.SECONDS);
pulsarSpoutConf.setMaxFailedRetries(2);
pulsarSpoutConf.setSharedConsumerEnabled(false);
pulsarSpoutConf.setMetricsTimeIntervalInSecs(60);
ConsumerConfiguration consumerConf = new ConsumerConfiguration();
consumerConf.setSubscriptionType(SubscriptionType.Shared);
PulsarSpout spout = new PulsarSpout(pulsarSpoutConf, new ClientConfiguration(), consumerConf);
MockSpoutOutputCollector mockCollector = new MockSpoutOutputCollector();
SpoutOutputCollector collector = new SpoutOutputCollector(mockCollector);
TopologyContext context = mock(TopologyContext.class);
when(context.getThisComponentId()).thenReturn("new-test" + methodName);
when(context.getThisTaskId()).thenReturn(0);
try {
spout.open(Maps.newHashMap(), context, collector);
fail("should have failed as consumer creation failed");
} catch (IllegalStateException e) {
// Ok
}
}
示例6: setup
import org.testng.collections.Maps; //导入依赖的package包/类
@Override
protected void setup() throws Exception {
super.internalSetup();
super.producerBaseSetup();
pulsarBoltConf = new PulsarBoltConfiguration();
pulsarBoltConf.setServiceUrl(serviceUrl);
pulsarBoltConf.setTopic(topic);
pulsarBoltConf.setTupleToMessageMapper(tupleToMessageMapper);
pulsarBoltConf.setMetricsTimeIntervalInSecs(60);
bolt = new PulsarBolt(pulsarBoltConf, new ClientConfiguration());
mockCollector = new MockOutputCollector();
OutputCollector collector = new OutputCollector(mockCollector);
TopologyContext context = mock(TopologyContext.class);
when(context.getThisComponentId()).thenReturn("test-bolt-" + methodName);
when(context.getThisTaskId()).thenReturn(0);
bolt.prepare(Maps.newHashMap(), context, collector);
consumer = pulsarClient.subscribe(topic, subscriptionName);
}
示例7: testSharedProducer
import org.testng.collections.Maps; //导入依赖的package包/类
@Test
public void testSharedProducer() throws Exception {
PersistentTopicStats topicStats = admin.persistentTopics().getStats(topic);
Assert.assertEquals(topicStats.publishers.size(), 1);
PulsarBolt otherBolt = new PulsarBolt(pulsarBoltConf, new ClientConfiguration());
MockOutputCollector otherMockCollector = new MockOutputCollector();
OutputCollector collector = new OutputCollector(otherMockCollector);
TopologyContext context = mock(TopologyContext.class);
when(context.getThisComponentId()).thenReturn("test-bolt-" + methodName);
when(context.getThisTaskId()).thenReturn(1);
otherBolt.prepare(Maps.newHashMap(), context, collector);
topicStats = admin.persistentTopics().getStats(topic);
Assert.assertEquals(topicStats.publishers.size(), 1);
otherBolt.close();
topicStats = admin.persistentTopics().getStats(topic);
Assert.assertEquals(topicStats.publishers.size(), 1);
}
示例8: testFailedProducer
import org.testng.collections.Maps; //导入依赖的package包/类
@Test
public void testFailedProducer() {
PulsarBoltConfiguration pulsarBoltConf = new PulsarBoltConfiguration();
pulsarBoltConf.setServiceUrl(serviceUrl);
pulsarBoltConf.setTopic("persistent://invalid");
pulsarBoltConf.setTupleToMessageMapper(tupleToMessageMapper);
pulsarBoltConf.setMetricsTimeIntervalInSecs(60);
PulsarBolt bolt = new PulsarBolt(pulsarBoltConf, new ClientConfiguration());
MockOutputCollector mockCollector = new MockOutputCollector();
OutputCollector collector = new OutputCollector(mockCollector);
TopologyContext context = mock(TopologyContext.class);
when(context.getThisComponentId()).thenReturn("new" + methodName);
when(context.getThisTaskId()).thenReturn(0);
try {
bolt.prepare(Maps.newHashMap(), context, collector);
fail("should have failed as producer creation failed");
} catch (IllegalStateException ie) {
// Ok.
}
}
示例9: createInstances
import org.testng.collections.Maps; //导入依赖的package包/类
private List<List<IMethodInstance>> createInstances(List<IMethodInstance> methodInstances) {
Map<Object, List<IMethodInstance>> map = Maps.newHashMap();
// MapList<IMethodInstance[], Object> map = new MapList<IMethodInstance[], Object>();
for (IMethodInstance imi : methodInstances) {
for (Object o : imi.getInstances()) {
System.out.println(o);
List<IMethodInstance> l = map.get(o);
if (l == null) {
l = Lists.newArrayList();
map.put(o, l);
}
l.add(imi);
}
// for (Object instance : imi.getInstances()) {
// map.put(imi, instance);
// }
}
// return map.getKeys();
// System.out.println(map);
return new ArrayList<List<IMethodInstance>>(map.values());
}
示例10: getNodeReplicas
import org.testng.collections.Maps; //导入依赖的package包/类
/** Returns all replicas per node. */
private Map<String, List<ReplicaInfo>> getNodeReplicas() {
final ClusterState clusterState = getClusterState();
final Map<String, List<ReplicaInfo>> result = Maps.newHashMap();
for (final DocCollection collection : clusterState.getCollectionsMap().values()) {
for (final Slice slice : collection.getSlices()) {
for (final Replica replica : slice.getReplicas()) {
List<ReplicaInfo> nodeReplicas = result.get(replica.getNodeName());
if (nodeReplicas == null) {
nodeReplicas = Lists.newArrayList();
result.put(replica.getNodeName(), nodeReplicas);
}
nodeReplicas.add(new ReplicaInfo(replica, collection.getName(), slice.getName()));
}
}
}
return result;
}
示例11: checkDeletions
import org.testng.collections.Maps; //导入依赖的package包/类
@Test(dependsOnMethods = "getAndClearNotifications", groups = "eps")
public void checkDeletions() throws Exception
{
waitForIndex(0, "nonExistantCountsAsAll?");
JsonNode results = doNotificationsSearch("dontfindanything", null, Maps.newHashMap(), getToken());
assertEquals(results.get("available").asInt(), 0, "Should be no notifications");
}
示例12: testInsertMany
import org.testng.collections.Maps; //导入依赖的package包/类
@Test
public void testInsertMany() throws Exception {
List<Map<String, Object>> dataList = Lists.newArrayList();
for (int i =0; i< 10; i++){
Map<String, Object> map = Maps.newHashMap();
map.put("number", i);
dataList.add(map);
}
dataAccess.insertMany("testNumber", dataList);
}
示例13: createDocTest
import org.testng.collections.Maps; //导入依赖的package包/类
@Test
void createDocTest()
{
BaseIndexer indexer = new ElasticsearchIndexer("", TEST1);
List<String> languages = Lists.newArrayList();
languages.add(LOCALE);
Map<String, Object> createdDoc = indexer.createDoc(ID, ENGLISH_TITLE, SPANISH_TITLE, ALT_TITLE, languages);
Map<String, Object> expectedDoc = Maps.newHashMap();
expectedDoc.put(Properties.idField.get(), ID + "_" + TEST1);
expectedDoc.put(Properties.titleFields.get().get(0) + "_en", ENGLISH_TITLE);
Set<Object> localizedTitles = Sets.newHashSet();
localizedTitles.add(SPANISH_TITLE);
expectedDoc.put(Properties.titleFields.get().get(0) + "_es", localizedTitles);
expectedDoc.put(Properties.docTypeFieldName.get(), TEST1);
Assert.assertEquals(createdDoc, expectedDoc);
StringBuilder jsonStringOfDoc = indexer.getJsonStringOfDoc(new ObjectMapper().valueToTree(createdDoc));
Assert.assertEquals(jsonStringOfDoc.toString(), "{\"query_testing_type\":\"test1\",\"title_en\":\"title en\",\"id\":\"123_test1\",\"title_es\":[\"title es\"]}");
String urlForAddingDoc = indexer.getUrlForAddingDoc(createdDoc);
Assert.assertEquals(urlForAddingDoc, "http://localhost:8983/solr/qtest/test_doc/123_test1");
String urlForCommitting = indexer.getUrlForCommitting();
Assert.assertEquals(urlForCommitting, "http://localhost:8983/solr/qtest/_flush");
}
示例14: createDocTest
import org.testng.collections.Maps; //导入依赖的package包/类
@Test
void createDocTest()
{
GoogleDataExtractor titleExtractor = Mockito.mock(GoogleDataExtractor.class);
Map<String, Map<Integer, TitleWithQueries>> mapOfQueriesToTitles = Maps.newHashMap();
Map<Integer, TitleWithQueries> titlesWithQueries = Maps.newHashMap();
TitleWithQueries titleWithQueries = new TitleWithQueries(DATASET_ID);
titleWithQueries.setValue(TitleWithQueries.ID, ID1);
titleWithQueries.setValue(TitleWithQueries.TITLE_EN, ENGLISH_TITLE);
titleWithQueries.setValue(TitleWithQueries.TITLE_LOCALE, SPANISH_TITLE);
titleWithQueries.setValue(TitleWithQueries.Q_ + "regular", Q1);
titlesWithQueries.put(1, titleWithQueries);
TitleWithQueries titleWithQueries2 = new TitleWithQueries(DATASET_ID);
titleWithQueries2.setValue(TitleWithQueries.ID, ID2);
titleWithQueries2.setValue(TitleWithQueries.TITLE_EN, ENGLISH_TITLE);
titleWithQueries2.setValue(TitleWithQueries.TITLE_LOCALE, SPANISH_TITLE);
titleWithQueries2.setValue(TitleWithQueries.Q_ + "regular", Q1);
titlesWithQueries.put(2, titleWithQueries2);
mapOfQueriesToTitles.put(DATASET_ID, titlesWithQueries);
Mockito.when(titleExtractor.getTitlesWithQueriesPerDataset()).thenReturn(mapOfQueriesToTitles);
Queries queries = new Queries(DATASET_ID, TEST1, titleExtractor);
queries.populateFromGoogleSpreadsheets();
Map<String, Set<String>> queryToIdMap = queries.getQueryToIdMap();
Map<String, Set<String>> expectedQueryToIdMap = Maps.newHashMap();
Set<String> titles = Sets.newHashSet();
titles.add(ID1+"_"+DATASET_ID);
titles.add(ID2+"_"+DATASET_ID);
expectedQueryToIdMap.put(Q1, titles);
Assert.assertEquals(queryToIdMap, expectedQueryToIdMap);
}
示例15: createGroups
import org.testng.collections.Maps; //导入依赖的package包/类
private Map<String, String> createGroups(String[] groups) {
Map<String, String> result = Maps.newHashMap();
// Groups that were passed on the command line
for (String group : groups) {
result.put(group, group);
}
// See if we have any MetaGroups and
// expand them if they match one of the groups
// we have just been passed
List<String> unfinishedGroups = Lists.newArrayList();
if (m_metaGroups.size() > 0) {
collectGroups(groups, unfinishedGroups, result);
// Do we need to loop over unfinished groups?
while (unfinishedGroups.size() > 0) {
String[] uGroups = unfinishedGroups.toArray(new String[unfinishedGroups.size()]);
unfinishedGroups = Lists.newArrayList();
collectGroups(uGroups, unfinishedGroups, result);
}
}
// Utils.dumpMap(result);
return result;
}