@Test public void getGroupsOnline() { ServerGroup bw = serverGroup("bw"); ServerGroup sw = serverGroup("sw"); ServerGroup lobby = serverGroup("lobby"); increment(bw, 5); increment(sw, 4); increment(lobby, 6); Map<String, Integer> groupsOnline = repository.getGroupsOnline(); assertEquals(3, groupsOnline.size()); assertEquals(5, groupsOnline.get("bw")); assertEquals(4, groupsOnline.get("sw")); assertEquals(6, groupsOnline.get("lobby")); assertEquals(15, repository.getGlobalOnline()); }
@Override public Map<String, Integer> getGroupsOnline() { return redisTransactions.runTransaction(jedis -> { Map<String, Integer> result = new HashMap<>(); Map<String, String> stringMap = jedis.hgetAll(HASH_TABLE); for (Map.Entry<String, String> entry : stringMap.entrySet()) { result.put(entry.getKey(), Integer.valueOf(entry.getValue())); } return result; }); }
RedisGlobalOnlineRepository implements GlobalOnlineRepository { @Override public Map<String, Integer> getGroupsOnline() { return redisTransactions.runTransaction(jedis -> { Map<String, Integer> result = new HashMap<>(); Map<String, String> stringMap = jedis.hgetAll(HASH_TABLE); for (Map.Entry<String, String> entry : stringMap.entrySet()) { result.put(entry.getKey(), Integer.valueOf(entry.getValue())); } return result; }); } }
RedisGlobalOnlineRepository implements GlobalOnlineRepository { @Override public Map<String, Integer> getGroupsOnline() { return redisTransactions.runTransaction(jedis -> { Map<String, Integer> result = new HashMap<>(); Map<String, String> stringMap = jedis.hgetAll(HASH_TABLE); for (Map.Entry<String, String> entry : stringMap.entrySet()) { result.put(entry.getKey(), Integer.valueOf(entry.getValue())); } return result; }); }  }
RedisGlobalOnlineRepository implements GlobalOnlineRepository { @Override public Map<String, Integer> getGroupsOnline() { return redisTransactions.runTransaction(jedis -> { Map<String, Integer> result = new HashMap<>(); Map<String, String> stringMap = jedis.hgetAll(HASH_TABLE); for (Map.Entry<String, String> entry : stringMap.entrySet()) { result.put(entry.getKey(), Integer.valueOf(entry.getValue())); } return result; }); }  @Override Map<String, Integer> getGroupsOnline(); @Override void increment(ServerGroup group); @Override int getGlobalOnline(); @Override void decrement(ServerGroup group); }
RedisGlobalOnlineRepository implements GlobalOnlineRepository { @Override public Map<String, Integer> getGroupsOnline() { return redisTransactions.runTransaction(jedis -> { Map<String, Integer> result = new HashMap<>(); Map<String, String> stringMap = jedis.hgetAll(HASH_TABLE); for (Map.Entry<String, String> entry : stringMap.entrySet()) { result.put(entry.getKey(), Integer.valueOf(entry.getValue())); } return result; }); }  @Override Map<String, Integer> getGroupsOnline(); @Override void increment(ServerGroup group); @Override int getGlobalOnline(); @Override void decrement(ServerGroup group);  }