UserSettingsClient { public Map<String, Map<String, String>> findAll() throws IOException { Scan scan = new Scan(); ResultScanner results = getTableInterface().getScanner(scan); Map<String, Map<String, String>> allUserSettings = new HashMap<>(); for (Result result : results) { allUserSettings.put(new String(result.getRow(), StandardCharsets.UTF_8), getAllUserSettings(result)); } return allUserSettings; } UserSettingsClient();  UserSettingsClient(Supplier<Map<String, Object>> globalConfigSupplier, TableProvider tableProvider);  UserSettingsClient(Table userSettingsTable, byte[] cf); synchronized void init(Supplier<Map<String, Object>> globalConfigSupplier, TableProvider tableProvider); Table getTableInterface(); Map<String, String> findOne(String user); Optional<String> findOne(String user, String type); Map<String, Map<String, String>> findAll(); Map<String, Optional<String>> findAll(String type); void save(String user, String type, String userSettings); void delete(String user); void delete(String user, String type); Map<String, String> getAllUserSettings(Result result); static String USER_SETTINGS_HBASE_TABLE; static String USER_SETTINGS_HBASE_CF; }
@Test public void shouldFindAll() throws Exception { ResultScanner resultScanner = mock(ResultScanner.class); Result result1 = mock(Result.class); Result result2 = mock(Result.class); when(result1.getRow()).thenReturn("user1".getBytes(StandardCharsets.UTF_8)); when(result2.getRow()).thenReturn("user2".getBytes(StandardCharsets.UTF_8)); when(result1.getValue(cf, Bytes.toBytes("type"))).thenReturn("userSettings1String".getBytes( StandardCharsets.UTF_8)); when(result2.getValue(cf, Bytes.toBytes("type"))).thenReturn("userSettings2String".getBytes( StandardCharsets.UTF_8)); when(resultScanner.iterator()).thenReturn(Arrays.asList(result1, result2).iterator()); when(userSettingsTable.getScanner(any(Scan.class))).thenReturn(resultScanner); UserSettingsClient userSettingsClient = new UserSettingsClient(userSettingsTable, cf); assertEquals(new HashMap<String, Optional<String>>() {{ put("user1", Optional.of("userSettings1String")); put("user2", Optional.of("userSettings2String")); }}, userSettingsClient.findAll("type")); }