UkelonnServiceProvider extends UkelonnServiceBase { static boolean hasUserWithNonEmptyUsername(PasswordsWithUser passwords) { User user = passwords.getUser(); if (user == null) { return false; } String username = user.getUsername(); if (username == null) { return false; } return !username.isEmpty(); }  @Activate void activate(); @Reference(target = "(osgi.jndi.service.name=jdbc/ukelonn)") void setDataSource(DataSource datasource); @Override DataSource getDataSource(); @Reference void setUserAdmin(UserManagementService useradmin); @Reference void setLogservice(LogService logservice); @Override LogService getLogservice(); @Override List<Account> getAccounts(); @Override Account getAccount(String username); @Override Account registerPerformedJob(PerformedTransaction job); @Override List<TransactionType> getJobTypes(); @Override List<Transaction> getJobs(int accountId); @Override List<Transaction> getPayments(int accountId); @Override List<Transaction> deleteJobsFromAccount(int accountId, List<Integer> idsOfJobsToDelete); @Override List<Transaction> updateJob(UpdatedTransaction editedJob); @Override List<TransactionType> getPaymenttypes(); @Override Account registerPayment(PerformedTransaction payment); @Override List<TransactionType> modifyJobtype(TransactionType jobtype); @Override List<TransactionType> createJobtype(TransactionType jobtype); @Override List<TransactionType> modifyPaymenttype(TransactionType paymenttype); @Override List<TransactionType> createPaymenttype(TransactionType paymenttype); @Override Account addAccount(User user); @Override List<SumYear> earningsSumOverYear(String username); @Override List<SumYearMonth> earningsSumOverMonth(String username); @Override List<Notification> notificationsTo(String username); @Override void notificationTo(String username, Notification notification); Account mapAccount(ResultSet results);  }
@Test public void testHasUserWithNonEmptyUsername() { PasswordsWithUser passwords = new PasswordsWithUser(); User userWithUsername = new User(1, "foo", null, null, null); passwords.setUser(userWithUsername); assertTrue(UkelonnServiceProvider.hasUserWithNonEmptyUsername(passwords)); User userWithEmptyUsername = new User(1, "", null, null, null); passwords.setUser(userWithEmptyUsername); assertFalse(UkelonnServiceProvider.hasUserWithNonEmptyUsername(passwords)); User userWithNullUsername = new User(1, null, null, null, null); passwords.setUser(userWithNullUsername); assertFalse(UkelonnServiceProvider.hasUserWithNonEmptyUsername(passwords)); passwords.setUser(null); assertFalse(UkelonnServiceProvider.hasUserWithNonEmptyUsername(passwords)); }