<commit_before>package zzpj.breathalyser.service;

import org.junit.Assert;
import org.junit.Test;
import zzpj.breathalyser.model.User;
import zzpj.breathalyser.model.UserDetails;
import zzpj.breathalyser.repository.IUsersRepository;
import zzpj.breathalyser.repository.UsersRepository;

import static org.junit.Assert.*;

/**
 * Created by Krzychu on 29.08.2016.
 */
public class UsersServiceTest {
    @Test
    public void initializeUsers() throws Exception {

        IUsersService usersService = new UsersService();
        usersService.initializeUsers();
        int result = usersService.getAllUsers().size();
        int expected = 5;
        Assert.assertEquals(expected, result);

    }

    @Test
    public void addUser() throws Exception {
        IUsersService usersService = new UsersService();
        UserDetails userDetails = new UserDetails("name", "surname", 100, 180, 25, true);
        User user = new User("login", "password", "email", userDetails);
        usersService.addUser(user);
        User result = usersService.getAllUsers().get(0);
        User expected = user;
        Assert.assertEquals(expected, result);
    }

    @Test
    public void setUsersRepository() throws Exception {
        IUsersService usersService = new UsersService();
        UsersRepository usersRepository = new UsersRepository();
        usersService.setUsersRepository(usersRepository);
        IUsersRepository result = usersService.getUsersRepository();
        IUsersRepository expected = usersRepository;
        Assert.assertEquals(expected, result);
    }

    @Test
    public void onLogin() throws Exception {
        IUsersService usersService = new UsersService();
        UserDetails userDetails = new UserDetails("name", "surname", 100, 180, 25, true);
        User user = new User("login", "password", "email", userDetails);
        usersService.addUser(user);
        boolean result = usersService.onLogin("login", "password");
        boolean expected = true;
        Assert.assertEquals(expected, result);
    }

    @Test
    public void getAllUsers() throws Exception {
        IUsersService usersService = new UsersService();
        UserDetails userDetails = new UserDetails("name", "surname", 100, 180, 25, true);
        User user = new User("login", "password", "email", userDetails);
        usersService.addUser(user);
        int result = usersService.getAllUsers().size();
        int expected = 1;
        Assert.assertEquals(expected, result);
    }

}<commit_msg>Added tests for UsersService, UsersRespository, UserDataInitializer. Some neccessary changes in UsersService class - initialization usersRepository field.<commit_after>package zzpj.breathalyser.service;

import org.junit.Assert;
import org.junit.Test;
import zzpj.breathalyser.model.User;
import zzpj.breathalyser.model.UserDetails;
import zzpj.breathalyser.repository.IUsersRepository;
import zzpj.breathalyser.repository.UsersRepository;

import static org.junit.Assert.*;

/**
 * Created by Krzychu on 29.08.2016.
 */
public class UsersServiceTest {
    @Test
    public void initializeUsers() throws Exception {

        IUsersService usersService = new UsersService();
        usersService.initializeUsers();
        int result = usersService.getAllUsers().size();
        int expected = 5;
        Assert.assertEquals(expected, result);

    }

    @Test
    public void addUser() throws Exception {
        IUsersService usersService = new UsersService();
        UserDetails userDetails = new UserDetails("name", "surname", 100, 180, 25, true);
        User user = new User("login", "password", "email", userDetails);
        usersService.addUser(user);
        User result = usersService.getAllUsers().get(0);
        User expected = user;
        Assert.assertEquals(expected, result);
    }

    @Test
    public void setUsersRepository() throws Exception {

        IUsersService usersService = new UsersService();
        UsersRepository usersRepository = new UsersRepository();
        usersService.setUsersRepository(usersRepository);
        IUsersRepository result = usersService.getUsersRepository();
        IUsersRepository expected = usersRepository;
        Assert.assertEquals(expected, result);

    }

    @Test
    public void onLogin() throws Exception {

        IUsersService usersService = new UsersService();
        UserDetails userDetails = new UserDetails("name", "surname", 100, 180, 25, true);
        User user = new User("login", "password", "email", userDetails);
        usersService.addUser(user);
        boolean result = usersService.onLogin("login", "password");
        boolean expected = true;
        Assert.assertEquals(expected, result);
        
    }

    @Test
    public void getAllUsers() throws Exception {

        IUsersService usersService = new UsersService();
        UserDetails userDetails = new UserDetails("name", "surname", 100, 180, 25, true);
        User user = new User("login", "password", "email", userDetails);
        usersService.addUser(user);
        int result = usersService.getAllUsers().size();
        int expected = 1;
        Assert.assertEquals(expected, result);

    }

}
{'fraction_non_alphanumeric': 0.10370226788137236, 'fraction_numerical': 0.013568521031207599, 'mean_word_length': 3.3179916317991633, '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': '5394724', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1336, 'n_words': 360}