UkelonnServiceProvider extends UkelonnServiceBase { @Override public List<TransactionType> createJobtype(TransactionType jobtype) { try(Connection connection = datasource.getConnection()) { try(PreparedStatement statement = connection.prepareStatement("insert into transaction_types (transaction_type_name, transaction_amount, transaction_is_work, transaction_is_wage_payment) values (?, ?, true, false)")) { statement.setString(1, jobtype.getTransactionTypeName()); statement.setObject(2, jobtype.getTransactionAmount()); statement.executeUpdate(); } } catch (SQLException e) { String message = String.format("Failed to create jobtype \"%s\" in the database", jobtype.getTransactionTypeName()); logError(message, e); throw new UkelonnException(message, e); } return getJobTypes(); }  @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 testCreateJobtype() { UkelonnService ukelonn = getUkelonnServiceSingleton(); List<TransactionType> originalJobtypes = ukelonn.getJobTypes(); TransactionType jobtype = new TransactionType(-1, "Skrubb badegolv", 200.0, true, false); List<TransactionType> updatedJobtypes = ukelonn.createJobtype(jobtype); assertThat(updatedJobtypes.size()).isGreaterThan(originalJobtypes.size()); }