DBManager implements Closeable { public String getUserServerIp(String email, String appName) { if (isDBEnabled()) { return userDBDao.getUserServerIp(email, appName); } return null; } DBManager(BlockingIOProcessor blockingIOProcessor, boolean isEnabled);  DBManager(String propsFilename, BlockingIOProcessor blockingIOProcessor, boolean isEnabled); void deleteUser(UserKey userKey); void saveUsers(ArrayList<User> users); Redeem selectRedeemByToken(String token); boolean updateRedeem(String email, String token); void insertRedeems(List<Redeem> redeemList); FlashedToken selectFlashedToken(String token); boolean activateFlashedToken(String token); boolean insertFlashedTokens(FlashedToken... flashedTokenList); void insertPurchase(Purchase purchase); boolean insertClonedProject(String token, String projectJson); String selectClonedProject(String token); boolean dbIsNotEnabled(); boolean isDBEnabled(); void executeSQL(String sql); String getUserServerIp(String email, String appName); String getServerByToken(String token); void assignServerToToken(String token, String serverIp, String email, int dashId, int deviceId); void removeToken(String... tokens); Connection getConnection(); @Override void close(); public UserDBDao userDBDao; public ForwardingTokenDBDao forwardingTokenDBDao; }
@Test public void getUserIpNotExists() { String userIp = dbManager.userDBDao.getUserServerIp("test@gmail.com", AppNameUtil.BLYNK); assertNull(userIp); }
@Test public void getUserIp() { ArrayList<User> users = new ArrayList<>(); User user = new User("test@gmail.com", "pass", AppNameUtil.BLYNK, "local", "127.0.0.1", false, false); user.lastModifiedTs = 0; user.lastLoggedAt = 1; user.lastLoggedIP = "127.0.0.1"; users.add(user); dbManager.userDBDao.save(users); String userIp = dbManager.userDBDao.getUserServerIp("test@gmail.com", AppNameUtil.BLYNK); assertEquals("127.0.0.1", userIp); }