本文整理匯總了Java中org.apache.storm.shade.com.google.common.collect.ImmutableMap.of方法的典型用法代碼示例。如果您正苦於以下問題:Java ImmutableMap.of方法的具體用法?Java ImmutableMap.of怎麽用?Java ImmutableMap.of使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.storm.shade.com.google.common.collect.ImmutableMap
的用法示例。
在下文中一共展示了ImmutableMap.of方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
示例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);
}
示例3: 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" }
});
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
示例8: 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);
}
示例9: 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);
}
示例10: 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);
}
示例11: 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" } });
}
示例12: 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);
}