<commit_before>package io.teiler.api.service;

import java.util.ArrayList;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

import io.teiler.server.Tylr;
import io.teiler.server.dto.Expense;
import io.teiler.server.dto.Group;
import io.teiler.server.dto.Person;
import io.teiler.server.dto.Share;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = Tylr.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@TestPropertySource(properties = {"local.server.port=4567"})
@AutoConfigureTestDatabase
public class ExpenseServiceTest {

    private static final String TEST_GROUP_NAME = "Testgruppe";

    private static final String TEST_EXPENSE_TITLE = "Testausgabe";
    private static final Integer TEST_EXPENSE_AMOUNT = 4200;
    private static final Person TEST_PAYER = new Person(-1, "Hans");
    private static final Person TEST_PROFITEER_1 = TEST_PAYER;
    private static final Person TEST_PROFITEER_2 = new Person(-2, "Paul");
    private static final Person TEST_PROFITEER_3 = new Person(-3, "Peter");

    @Autowired
    private ExpenseService expenseService;
    
    @Autowired
    private GroupService groupService;
    
    @Autowired
    private PersonService personService;

    @Test
    public void testCreateExpenseWithSingleProfiteer() {
        Group testGroup = groupService.createGroup(TEST_GROUP_NAME);
        
        TEST_PROFITEER_1.setId(personService.createPerson(testGroup.getId(), TEST_PROFITEER_1.getName()).getId());
        TEST_PROFITEER_2.setId(personService.createPerson(testGroup.getId(), TEST_PROFITEER_2.getName()).getId());
        TEST_PROFITEER_3.setId(personService.createPerson(testGroup.getId(), TEST_PROFITEER_3.getName()).getId());
        
        // We have to set the shares here in order to have the correct Person-Ids in the Profiteers.
        List<Share> testShares = getTestShares();
        
        Expense testExpense = new Expense(null, TEST_EXPENSE_AMOUNT, TEST_PAYER, TEST_EXPENSE_TITLE,
            testShares);
        Expense expense = expenseService.createExpense(testExpense, testGroup.getId());

        Assert.assertEquals(TEST_EXPENSE_TITLE, expense.getTitle());
        Assert.assertEquals(TEST_EXPENSE_AMOUNT, expense.getAmount());
        Assert.assertEquals(TEST_PAYER.getId(), expense.getPayer().getId());
        
        Assert.assertFalse(expense.getShares().isEmpty());
        Assert.assertEquals(testShares.size(), expense.getShares().size());
    }

    private List<Share> getTestShares() {
        List<Share> shares = new ArrayList<>(3);
        shares.add(new Share(null, TEST_PROFITEER_1, 300));
        shares.add(new Share(null, TEST_PROFITEER_2, 300));
        shares.add(new Share(null, TEST_PROFITEER_3, 400));
        return shares;
    }

}<commit_msg>fix input values for expense service test<commit_after>package io.teiler.api.service;

import java.util.ArrayList;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

import io.teiler.server.Tylr;
import io.teiler.server.dto.Expense;
import io.teiler.server.dto.Group;
import io.teiler.server.dto.Person;
import io.teiler.server.dto.Share;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = Tylr.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@TestPropertySource(properties = {"local.server.port=4567"})
@AutoConfigureTestDatabase
public class ExpenseServiceTest {

    private static final String TEST_GROUP_NAME = "Testgruppe";

    private static final String TEST_EXPENSE_TITLE = "Testausgabe";
    private static final Integer TEST_EXPENSE_AMOUNT = 4200;
    private static final Person TEST_PAYER = new Person(-1, "Hans");
    private static final Person TEST_PROFITEER_1 = TEST_PAYER;
    private static final Person TEST_PROFITEER_2 = new Person(-2, "Paul");
    private static final Person TEST_PROFITEER_3 = new Person(-3, "Peter");

    @Autowired
    private ExpenseService expenseService;
    
    @Autowired
    private GroupService groupService;
    
    @Autowired
    private PersonService personService;

    @Test
    public void testCreateExpenseWithSingleProfiteer() {
        Group testGroup = groupService.createGroup(TEST_GROUP_NAME);
        
        TEST_PROFITEER_1.setId(personService.createPerson(testGroup.getId(), TEST_PROFITEER_1.getName()).getId());
        TEST_PROFITEER_2.setId(personService.createPerson(testGroup.getId(), TEST_PROFITEER_2.getName()).getId());
        TEST_PROFITEER_3.setId(personService.createPerson(testGroup.getId(), TEST_PROFITEER_3.getName()).getId());
        
        // We have to set the shares here in order to have the correct Person-Ids in the Profiteers.
        List<Share> testShares = getTestShares();
        
        Expense testExpense = new Expense(null, TEST_EXPENSE_AMOUNT, TEST_PAYER, TEST_EXPENSE_TITLE,
            testShares);
        Expense expense = expenseService.createExpense(testExpense, testGroup.getId());

        Assert.assertEquals(TEST_EXPENSE_TITLE, expense.getTitle());
        Assert.assertEquals(TEST_EXPENSE_AMOUNT, expense.getAmount());
        Assert.assertEquals(TEST_PAYER.getId(), expense.getPayer().getId());
        
        Assert.assertFalse(expense.getShares().isEmpty());
        Assert.assertEquals(testShares.size(), expense.getShares().size());
    }

    private List<Share> getTestShares() {
        List<Share> shares = new ArrayList<>(3);
        shares.add(new Share(null, TEST_PROFITEER_1, 1200));
        shares.add(new Share(null, TEST_PROFITEER_2, 1500));
        shares.add(new Share(null, TEST_PROFITEER_3, 1500));
        return shares;
    }

}
{'fraction_non_alphanumeric': 0.103399209486166, 'fraction_numerical': 0.011225296442687747, 'mean_word_length': 4.320437342304458, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1887786', 'n_tokens_mistral': 1946, 'n_tokens_neox': 1923, 'n_words': 362}