<commit_before>package nl.tehdreamteam.se42.data.user;

import nl.tehdreamteam.se42.data.user.hibernate.UserHibernateRepository;
import nl.tehdreamteam.se42.domain.LoginCredentials;
import nl.tehdreamteam.se42.domain.User;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * @author Lesley
 */
public final class UserRepositoryIntegrationTest {

    private UserRepository repository;
    private User user;

    @Test
    public void createAndGet_whenCalled_createsUserAndPersists() {
        givenHibernateUserRepository();
        givenDefaultUser();

        saveUser();

        verifyUserIsAdded();
    }

    @Before
    public void resetFields() {
        repository = null;
        user = null;
    }

    private void saveUser() {
        repository.save(user);
    }

    private void verifyUserIsAdded() {
        User expected = user;
        User actual = repository.get(expected.getLoginCredentials().getUsername());

        String expectedUsername = user.getLoginCredentials().getUsername();
        String actualUsername = user.getLoginCredentials().getUsername();
        assertEquals(expectedUsername, actualUsername);
    }

    private void givenDefaultUser() {
        LoginCredentials credentials = new LoginCredentials("username", "password");
        user = new User(credentials);
    }

    private void givenHibernateUserRepository() {
        repository = new UserHibernateRepository();
    }

}<commit_msg>Correctly clean database after integration-test.<commit_after>package nl.tehdreamteam.se42.data.user;

import nl.tehdreamteam.se42.data.user.hibernate.UserHibernateRepository;
import nl.tehdreamteam.se42.domain.LoginCredentials;
import nl.tehdreamteam.se42.domain.User;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * @author Lesley
 */
public final class UserRepositoryIntegrationTest {

    private UserRepository repository;
    private User user;

    @Test
    public void createAndGet_whenCalled_createsUserAndPersists() {
        givenHibernateUserRepository();
        givenDefaultUser();

        saveUser();

        verifyUserIsAdded();
    }

    @Before
    public void resetFields() {
        repository = null;
        user = null;
    }

    @After
    public void resetPersistency() {
        deleteUser();
    }

    private void saveUser() {
        repository.save(user);
    }

    private void deleteUser() {
        repository.delete(user);
    }

    private void verifyUserIsAdded() {
        User expected = user;
        User actual = repository.get(expected.getLoginCredentials().getUsername());

        String expectedUsername = user.getLoginCredentials().getUsername();
        String actualUsername = user.getLoginCredentials().getUsername();
        assertEquals(expectedUsername, actualUsername);
    }

    private void givenDefaultUser() {
        LoginCredentials credentials = new LoginCredentials("username", "password");
        user = new User(credentials);
    }

    private void givenHibernateUserRepository() {
        repository = new UserHibernateRepository();
    }

}
{'fraction_non_alphanumeric': 0.0959119496855346, 'fraction_numerical': 0.005031446540880503, 'mean_word_length': 3.2697986577181206, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '22701', 'n_tokens_mistral': 864, 'n_tokens_neox': 841, 'n_words': 177}