UserSettingsClient { public Map<String, String> findOne(String user) throws IOException { Result result = getResult(user); return getAllUserSettings(result); } 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 shouldFindOne() throws Exception { Result result = mock(Result.class); when(result.getValue(cf, Bytes.toBytes("type"))).thenReturn("userSettings1String".getBytes( StandardCharsets.UTF_8)); Get get = new Get("user1".getBytes(StandardCharsets.UTF_8)); get.addFamily(cf); when(userSettingsTable.get(get)).thenReturn(result); UserSettingsClient userSettingsClient = new UserSettingsClient(userSettingsTable, cf); assertEquals("userSettings1String", userSettingsClient.findOne("user1", "type").get()); assertFalse(userSettingsClient.findOne("missingUser", "type").isPresent()); }