RoomsResource { @GET @Path("room") @Produces(MediaType.APPLICATION_JSON) public Room getRoom(@QueryParam(ROOM) String roomName) { Map<String, Room> rooms = getRooms(); return rooms.get(roomName); } RoomsResource(ChatAlyticsConfig config); @VisibleForTesting protected  RoomsResource(IChatApiDAO chatApiDao); @GET @Produces(MediaType.APPLICATION_JSON) Map<String, Room> getRooms(); @GET @Path("room") @Produces(MediaType.APPLICATION_JSON) Room getRoom(@QueryParam(ROOM) String roomName); static final String ROOM_ENDPOINT; }
@Test public void testGetRoom() { Room room1 = new Room("r1", "r1channel", "r1topic", null ,null, "owner1", false, false, null, null); Room room2 = new Room("r2", "r2channel", "r2topic", null ,null, "owner2", false, false, null, null); Map<String, Room> rooms = ImmutableMap.of("r1", room1, "r2", room2); when(chatApiDao.getRooms()).thenReturn(rooms); Room result = underTest.getRoom("r1channel"); assertEquals(rooms.get("r1"), result); }