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


Java ImmutableMap类代码示例

本文整理汇总了Java中org.apache.storm.shade.com.google.common.collect.ImmutableMap的典型用法代码示例。如果您正苦于以下问题:Java ImmutableMap类的具体用法?Java ImmutableMap怎么用?Java ImmutableMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ImmutableMap类属于org.apache.storm.shade.com.google.common.collect包,在下文中一共展示了ImmutableMap类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBackfillRooms_unknownMessageType

import org.apache.storm.shade.com.google.common.collect.ImmutableMap; //导入依赖的package包/类
@Test
public void testBackfillRooms_unknownMessageType() {
    stormConf.put(ConfigurationConstants.CHATALYTICS_CONFIG.txt, YamlUtils.writeYaml(config));
    IChatAlyticsDAO dbDao = mock(IChatAlyticsDAO.class);
    IChatApiDAO slackDao = mock(IChatApiDAO.class);
    underTest.open(chatConfig, slackDao, dbDao, context, collector);

    Map<String, User> users = ImmutableMap.of("u1", new User("u1", "email", false, false, false,
                                                             "name", "mention_name", null,
                                                             DateTime.now(), DateTime.now(),
                                                             null, null, null, null));
    Room room = new Room("r1", "room", null, DateTime.now(), DateTime.now(), null, false, false,
                         null, null);
    Map<String, Room> rooms = ImmutableMap.of("r1", room);
    Interval interval = new Interval(DateTime.now().minusDays(1), DateTime.now());
    Message message = new Message(DateTime.now(), "from", "u1", "test message", "r1",
                                  MessageType.UNKNOWN);
    List<Message> messages = Lists.newArrayList(message);

    when(slackDao.getMessages(interval.getStart(), interval.getEnd(), room)).thenReturn(messages);

    underTest.backfillRooms(users, rooms, interval);
    verify(slackDao).getMessages(interval.getStart(), interval.getEnd(), room);
    verifyNoMoreInteractions(slackDao);
    verifyZeroInteractions(collector);
}
 
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:27,代码来源:SlackBackfillSpoutTest.java

示例2: testBackfillRooms_nullUser

import org.apache.storm.shade.com.google.common.collect.ImmutableMap; //导入依赖的package包/类
@Test
public void testBackfillRooms_nullUser() {
    stormConf.put(ConfigurationConstants.CHATALYTICS_CONFIG.txt, YamlUtils.writeYaml(config));
    IChatAlyticsDAO dbDao = mock(IChatAlyticsDAO.class);
    IChatApiDAO slackDao = mock(IChatApiDAO.class);
    underTest.open(chatConfig, slackDao, dbDao, context, collector);

    Map<String, User> users = ImmutableMap.of("u1", new User("u1", "email", false, false, false,
                                                             "name", "mention_name", null,
                                                             DateTime.now(), DateTime.now(),
                                                             null, null, null, null));
    Room room = new Room("r1", "room", null, DateTime.now(), DateTime.now(), null, false, false,
                         null, null);
    Map<String, Room> rooms = ImmutableMap.of("r1", room);
    Interval interval = new Interval(DateTime.now().minusDays(1), DateTime.now());
    Message message = new Message(DateTime.now(), "from", "u2", "test message", "r1",
                                  MessageType.MESSAGE);
    List<Message> messages = Lists.newArrayList(message);

    when(slackDao.getMessages(interval.getStart(), interval.getEnd(), room)).thenReturn(messages);

    underTest.backfillRooms(users, rooms, interval);
    verify(slackDao).getMessages(interval.getStart(), interval.getEnd(), room);
    verifyNoMoreInteractions(slackDao);
    verifyZeroInteractions(collector);
}
 
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:27,代码来源:SlackBackfillSpoutTest.java

示例3: testSimpleWriteTopology

import org.apache.storm.shade.com.google.common.collect.ImmutableMap; //导入依赖的package包/类
@Test
public void testSimpleWriteTopology() throws Exception {
    List doc1 = Collections.singletonList(ImmutableMap.of("one", 1, "two", 2));
    List doc2 = Collections.singletonList(ImmutableMap.of("OTP", "Otopeni", "SFO", "San Fran"));

    String target = index + "/simple-write";
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("test-spout-1", new TestSpout(ImmutableList.of(doc2, doc1), new Fields("doc")));
    builder.setBolt("es-bolt-1", new TestBolt(new EsBolt(target, conf))).shuffleGrouping("test-spout-1");

    MultiIndexSpoutStormSuite.run(index + "simple", builder.createTopology(), COMPONENT_HAS_COMPLETED);

    COMPONENT_HAS_COMPLETED.waitFor(1, TimeValue.timeValueSeconds(10));

    RestUtils.refresh(index);
    assertTrue(RestUtils.exists(target));
    String results = RestUtils.get(target + "/_search?");
    assertThat(results, containsString("SFO"));
}
 
开发者ID:elastic,项目名称:elasticsearch-hadoop,代码行数:20,代码来源:AbstractStormSimpleBoltTests.java

示例4: configs

import org.apache.storm.shade.com.google.common.collect.ImmutableMap; //导入依赖的package包/类
@Parameters
public static Collection<Object[]> configs() throws IOException {
    // no ack
    Map noAck = new LinkedHashMap(Collections.singletonMap(StormConfigurationOptions.ES_STORM_SPOUT_RELIABLE, Boolean.FALSE.toString()));

    // read ack
    Map ack = new LinkedHashMap(Collections.singletonMap(StormConfigurationOptions.ES_STORM_SPOUT_RELIABLE, Boolean.TRUE.toString()));

    // read ack bounded queue
    Map ackWithSize = new LinkedHashMap(ImmutableMap.of(StormConfigurationOptions.ES_STORM_SPOUT_RELIABLE, Boolean.TRUE.toString(), StormConfigurationOptions.ES_STORM_SPOUT_RELIABLE_QUEUE_SIZE, "1"));

    // read ack bounded queue with no retries
    Map ackWithSizeNoRetries = new LinkedHashMap(ImmutableMap.of(StormConfigurationOptions.ES_STORM_SPOUT_RELIABLE, Boolean.TRUE.toString(),
            StormConfigurationOptions.ES_STORM_SPOUT_RELIABLE_QUEUE_SIZE, "1",
            StormConfigurationOptions.ES_STORM_SPOUT_RELIABLE_RETRIES_PER_TUPLE, "1",
            StormConfigurationOptions.ES_STORM_SPOUT_FIELDS, "message"));

    return Arrays.asList(new Object[][] {
        { noAck, "storm-spout" },
        { ack, "storm-spout-reliable" },
        //{ ackWithSize, "storm-spout-reliable-size" },
            //{ ackWithSizeNoRetries, "storm-spout-reliable-size-no-retries" } 
    });
}
 
开发者ID:elastic,项目名称:elasticsearch-hadoop,代码行数:25,代码来源:AbstractStormSpoutTests.java

示例5: testOnMessageEvent

import org.apache.storm.shade.com.google.common.collect.ImmutableMap; //导入依赖的package包/类
/**
 * Tests the {@link SlackMessageSpout#onMessageEvent(Message, Session)} method and makes sure
 * that a fatMessage is created and then pushed to a queue for consumption. This test also calls
 * {@link SlackMessageSpout#nextTuple()} to see if the fat message is properly consumed from the
 * queue.
 */
@Test
public void testOnMessageEvent() throws Exception {
    // setup mocks
    WebSocketContainer mockSocketContainer = mock(WebSocketContainer.class);
    when(mockSocketContainer.connectToServer(underTest, WEB_SOCKET_TEST_URI))
        .thenReturn(mock(Session.class));
    JsonSlackDAO slackDao = mock(JsonSlackDAO.class);
    when(slackDao.getRealtimeWebSocketURI()).thenReturn(WEB_SOCKET_TEST_URI);
    underTest.open(chatConfig, slackDao, mockSocketContainer, mockContext, mockCollector);

    String userId = "U03AFSSD";

    // make the chat API DAO return a map of users
    Map<String, User> users = ImmutableMap.of(userId,
                                              new User(userId, null, false, false,  false,
                                                       "name", "mention_name", null,
                                                       DateTime.now(), DateTime.now(), null,
                                                       null, null, null));
    when(slackDao.getUsers()).thenReturn(users);

    Message triggerMessage = new Message(DateTime.now(), "Test User", userId, "test msg",
                                         "C09ADF43", MESSAGE);

    underTest.onMessageEvent(triggerMessage, mock(Session.class));
    verify(slackDao).getUsers();
    verify(slackDao).getRooms();
    verify(slackDao).getRealtimeWebSocketURI();
    verifyNoMoreInteractions(slackDao);
    underTest.nextTuple();
    verify(mockCollector).emit(any(Values.class));
    verifyNoMoreInteractions(mockCollector);

    // make sure nothing got emitted
    underTest.nextTuple();
    verifyNoMoreInteractions(mockCollector);
}
 
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:43,代码来源:SlackMessageSpoutTest.java

示例6: testOnMessageEvent_botUser

import org.apache.storm.shade.com.google.common.collect.ImmutableMap; //导入依赖的package包/类
@Test
public void testOnMessageEvent_botUser() throws Exception {
    JsonSlackDAO slackDao = mock(JsonSlackDAO.class);
    Map<String, User> users = ImmutableMap.of("u1", new User("u1", "email", false, false, false,
                                                             "name", "mention_name", null,
                                                             DateTime.now(), DateTime.now(),
                                                             null, null, null, null));
    Map<String, Room> rooms = ImmutableMap.of("r1", new Room("r1", "room", null, DateTime.now(),
                                                             DateTime.now(), null, false, false,
                                                             null, null));
    when(slackDao.getUsers()).thenReturn(users);
    when(slackDao.getRooms()).thenReturn(rooms);
    Session session = mock(Session.class);
    when(session.getId()).thenReturn("id");
    when(slackDao.getRealtimeWebSocketURI()).thenReturn(WEB_SOCKET_TEST_URI);
    WebSocketContainer webSocket = mock(WebSocketContainer.class);
    when(webSocket.connectToServer(underTest, WEB_SOCKET_TEST_URI)).thenReturn(session);
    underTest.open(chatConfig, slackDao, webSocket, mockContext, mockCollector);

    Message triggerMessage = new Message(DateTime.now(), "BotUser", "b1", "test msg",
                                         "r1", MessageType.BOT_MESSAGE);
    underTest.onMessageEvent(triggerMessage, mock(Session.class));
    verify(slackDao).getUsers();
    verify(slackDao).getRooms();
    verify(slackDao).getRealtimeWebSocketURI();
    verifyNoMoreInteractions(slackDao);
    underTest.nextTuple();
    verify(mockCollector).emit(any(Values.class));
    verifyNoMoreInteractions(mockCollector);
}
 
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:31,代码来源:SlackMessageSpoutTest.java

示例7: testOnMessageEvent_nullUser

import org.apache.storm.shade.com.google.common.collect.ImmutableMap; //导入依赖的package包/类
@Test
public void testOnMessageEvent_nullUser() throws Exception {
    JsonSlackDAO slackDao = mock(JsonSlackDAO.class);
    Map<String, User> users = ImmutableMap.of("u1", new User("u1", "email", false, false, false,
                                                             "name", "mention_name", null,
                                                             DateTime.now(), DateTime.now(),
                                                             null, null, null, null));
    Map<String, Room> rooms = ImmutableMap.of("r1", new Room("r1", "room", null, DateTime.now(),
                                                             DateTime.now(), null, false, false,
                                                             null, null));
    when(slackDao.getUsers()).thenReturn(users);
    when(slackDao.getRooms()).thenReturn(rooms);
    Session session = mock(Session.class);
    when(session.getId()).thenReturn("id");
    when(slackDao.getRealtimeWebSocketURI()).thenReturn(WEB_SOCKET_TEST_URI);
    WebSocketContainer webSocket = mock(WebSocketContainer.class);
    when(webSocket.connectToServer(underTest, WEB_SOCKET_TEST_URI)).thenReturn(session);
    underTest.open(chatConfig, slackDao, webSocket, mockContext, mockCollector);

    Message triggerMessage = new Message(DateTime.now(), "BotUser", "u2", "test msg", "r1",
                                         MESSAGE);
    underTest.onMessageEvent(triggerMessage, mock(Session.class));
    verify(slackDao).getUsers();
    verify(slackDao).getRooms();
    verify(slackDao).getRealtimeWebSocketURI();
    verifyNoMoreInteractions(slackDao);
    underTest.nextTuple();
    verifyZeroInteractions(mockCollector);
}
 
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:30,代码来源:SlackMessageSpoutTest.java

示例8: testOnMessageEvent_nullRoom

import org.apache.storm.shade.com.google.common.collect.ImmutableMap; //导入依赖的package包/类
@Test
public void testOnMessageEvent_nullRoom() throws Exception {
    JsonSlackDAO slackDao = mock(JsonSlackDAO.class);
    Map<String, User> users = ImmutableMap.of("u1", new User("u1", "email", false, false, false,
                                                             "name", "mention_name", null,
                                                             DateTime.now(), DateTime.now(),
                                                             null, null, null, null));
    Map<String, Room> rooms = ImmutableMap.of();
    when(slackDao.getUsers()).thenReturn(users);
    when(slackDao.getRooms()).thenReturn(rooms);
    Session session = mock(Session.class);
    when(session.getId()).thenReturn("id");
    when(slackDao.getRealtimeWebSocketURI()).thenReturn(WEB_SOCKET_TEST_URI);
    WebSocketContainer webSocket = mock(WebSocketContainer.class);
    when(webSocket.connectToServer(underTest, WEB_SOCKET_TEST_URI)).thenReturn(session);
    underTest.open(chatConfig, slackDao, webSocket, mockContext, mockCollector);

    // this was a direct chat message
    Message triggerMessage = new Message(DateTime.now(), "name", "u1", "test msg",
                                         "D1R3CTM355", MESSAGE);
    underTest.onMessageEvent(triggerMessage, mock(Session.class));

    verify(slackDao).getUsers();
    verify(slackDao).getRooms();
    verify(slackDao).getRealtimeWebSocketURI();
    verifyNoMoreInteractions(slackDao);
    underTest.nextTuple();
    verify(mockCollector).emit(any(Values.class));
    verifyNoMoreInteractions(mockCollector);

    // make sure nothing got emitted
    underTest.nextTuple();
    verifyNoMoreInteractions(mockCollector);
}
 
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:35,代码来源:SlackMessageSpoutTest.java

示例9: testNextTuple

import org.apache.storm.shade.com.google.common.collect.ImmutableMap; //导入依赖的package包/类
@Test
public void testNextTuple() {
    chatConfig.granularityMins = 0;
    stormConf.put(ConfigurationConstants.CHATALYTICS_CONFIG.txt, YamlUtils.writeYaml(config));
    IChatAlyticsDAO dbDao = mock(IChatAlyticsDAO.class);
    IChatApiDAO slackDao = mock(IChatApiDAO.class);
    underTest.open(chatConfig, slackDao, dbDao, context, collector);

    Map<String, User> users = ImmutableMap.of("u1", new User("u1", "email", false, false, false,
                                                             "name", "mention_name", null,
                                                             DateTime.now(), DateTime.now(),
                                                             null, null, null, null));
    Map<String, Room> rooms = ImmutableMap.of("r1", new Room("r1", "room", null, DateTime.now(),
                                                             DateTime.now(), null, false, false,
                                                             null, null));

    when(dbDao.getLastMessagePullTime()).thenReturn(new DateTime(0, DateTimeZone.UTC));
    when(slackDao.getUsers()).thenReturn(users);
    when(slackDao.getRooms()).thenReturn(rooms);

    underTest.nextTuple();
    verify(slackDao).getUsers();
    verify(slackDao).getRooms();
    verify(dbDao).setLastMessagePullTime(any(DateTime.class));
    verify(dbDao).getLastMessagePullTime();
    verifyNoMoreInteractions(dbDao);
}
 
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:28,代码来源:SlackBackfillSpoutTest.java

示例10: testBackfillRooms

import org.apache.storm.shade.com.google.common.collect.ImmutableMap; //导入依赖的package包/类
/**
 * Check to see if a {@link FatMessage} gets emitted when the user is not null, the message type
 * is valid and the room is not archived
 */
@Test
public void testBackfillRooms() {
    stormConf.put(ConfigurationConstants.CHATALYTICS_CONFIG.txt, YamlUtils.writeYaml(config));
    IChatAlyticsDAO dbDao = mock(IChatAlyticsDAO.class);
    IChatApiDAO slackDao = mock(IChatApiDAO.class);
    underTest.open(chatConfig, slackDao, dbDao, context, collector);

    Map<String, User> users = ImmutableMap.of("u1", new User("u1", "email", false, false, false,
                                                             "name", "mention_name", null,
                                                             DateTime.now(), DateTime.now(),
                                                             null, null, null, null));
    Room room = new Room("r1", "room", null, DateTime.now(), DateTime.now(), null, false, false,
                         null, null);
    Map<String, Room> rooms = ImmutableMap.of("r1", room);
    Interval interval = new Interval(DateTime.now().minusDays(1), DateTime.now());
    Message message = new Message(DateTime.now(), "from", "u1", "test message", "r1",
                                  MessageType.MESSAGE);
    List<Message> messages = Lists.newArrayList(message);

    when(slackDao.getMessages(interval.getStart(), interval.getEnd(), room)).thenReturn(messages);

    underTest.backfillRooms(users, rooms, interval);
    verify(slackDao).getMessages(interval.getStart(), interval.getEnd(), room);
    verifyNoMoreInteractions(slackDao);
    verify(collector).emit(any(Values.class));
    verifyNoMoreInteractions(collector);
}
 
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:32,代码来源:SlackBackfillSpoutTest.java

示例11: testBackfillRooms_botUser

import org.apache.storm.shade.com.google.common.collect.ImmutableMap; //导入依赖的package包/类
@Test
public void testBackfillRooms_botUser() {
    stormConf.put(ConfigurationConstants.CHATALYTICS_CONFIG.txt, YamlUtils.writeYaml(config));
    IChatAlyticsDAO dbDao = mock(IChatAlyticsDAO.class);
    IChatApiDAO slackDao = mock(IChatApiDAO.class);
    underTest.open(chatConfig, slackDao, dbDao, context, collector);

    Map<String, User> users = ImmutableMap.of("u1", new User("u1", "email", false, false, false,
                                                             "name", "mention_name", null,
                                                             DateTime.now(), DateTime.now(),
                                                             null, null, null, null));
    Room room = new Room("r1", "room", null, DateTime.now(), DateTime.now(), null, false, false,
                         null, null);
    Map<String, Room> rooms = ImmutableMap.of("r1", room);
    Interval interval = new Interval(DateTime.now().minusDays(1), DateTime.now());
    Message message = new Message(DateTime.now(), "from", "b1", "test message", "r1",
                                  MessageType.BOT_MESSAGE);
    List<Message> messages = Lists.newArrayList(message);

    when(slackDao.getMessages(interval.getStart(), interval.getEnd(), room)).thenReturn(messages);

    underTest.backfillRooms(users, rooms, interval);
    verify(slackDao).getMessages(interval.getStart(), interval.getEnd(), room);
    verifyNoMoreInteractions(slackDao);
    verify(collector).emit(any(Values.class));
    verifyNoMoreInteractions(collector);
}
 
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:28,代码来源:SlackBackfillSpoutTest.java

示例12: configs

import org.apache.storm.shade.com.google.common.collect.ImmutableMap; //导入依赖的package包/类
@Parameters
public static Collection<Object[]> configs() throws IOException {
    // no ack
    Map noAck = new HashMap(ImmutableMap.of(StormConfigurationOptions.ES_STORM_BOLT_ACK, Boolean.FALSE.toString()));

    // write ack
    Map ack = new HashMap(ImmutableMap.of(StormConfigurationOptions.ES_STORM_BOLT_ACK, Boolean.TRUE.toString()));
    return Arrays.asList(new Object[][] { { noAck, "storm-bolt" }, { ack, "storm-bolt-ack" } });
}
 
开发者ID:elastic,项目名称:elasticsearch-hadoop,代码行数:10,代码来源:AbstractStormBoltTests.java

示例13: testOnMessageEvent_withStatDate

import org.apache.storm.shade.com.google.common.collect.ImmutableMap; //导入依赖的package包/类
@Test
public void testOnMessageEvent_withStatDate() throws Exception {
    JsonSlackDAO slackDao = mock(JsonSlackDAO.class);
    Session session = mock(Session.class);
    when(session.getId()).thenReturn("id");
    when(slackDao.getRealtimeWebSocketURI()).thenReturn(WEB_SOCKET_TEST_URI);
    WebSocketContainer webSocket = mock(WebSocketContainer.class);
    when(webSocket.connectToServer(underTest, WEB_SOCKET_TEST_URI)).thenReturn(session);

    DateTime startDate = DateTime.now();
    chatConfig.startDate = startDate.toString();

    // open with a start date
    underTest.open(chatConfig, slackDao, webSocket, mockContext, mockCollector);

    DateTime messageDate = startDate.minusHours(1);
    Message triggerMessage = new Message(messageDate, "name", "u1", "test msg", "D1R3CTM355",
                                         MESSAGE);
    underTest.onMessageEvent(triggerMessage, session);
    verify(slackDao).getRealtimeWebSocketURI();
    verifyNoMoreInteractions(slackDao);
    underTest.nextTuple();
    verifyZeroInteractions(mockCollector);

    // try again with a message date that's after the start date
    messageDate = startDate.plusHours(1);
    Map<String, User> users = ImmutableMap.of("u1", new User("u1", "email", false, false, false,
                                                             "name", "mention_name", null,
                                                             DateTime.now(), DateTime.now(),
                                                             null, null, null, null));
    Map<String, Room> rooms = ImmutableMap.of();
    when(slackDao.getUsers()).thenReturn(users);
    when(slackDao.getRooms()).thenReturn(rooms);
    triggerMessage = new Message(messageDate, "name", "u1", "test msg", "D1R3CTM355", MESSAGE);
    underTest.onMessageEvent(triggerMessage, session);
    verify(slackDao).getUsers();
    verify(slackDao).getRooms();
    verify(slackDao).getRealtimeWebSocketURI();
    verifyNoMoreInteractions(slackDao);
    underTest.nextTuple();
    verify(mockCollector).emit(any(Values.class));
    verifyNoMoreInteractions(mockCollector);

    // try again with a message date that is equal to the start date
    reset(slackDao);
    messageDate = startDate;
    triggerMessage = new Message(messageDate, "name", "u1", "test msg", "D1R3CTM355", MESSAGE);
    underTest.onMessageEvent(triggerMessage, session);
    verify(slackDao).getUsers();
    verify(slackDao).getRooms();
    verifyNoMoreInteractions(slackDao);
    underTest.nextTuple();
    verify(mockCollector).emit(any(Values.class));
    verifyNoMoreInteractions(mockCollector);
}
 
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:56,代码来源:SlackMessageSpoutTest.java


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