<commit_before>package com.github.aistomin.musicist.model;

import com.github.aistomin.musicist.MusicistSuite;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import org.junit.Assert;
import org.junit.Test;

/**
 * Created by aistomin on 01.05.17.
 * <p>
 * Test for {@link User}
 */
public final class UserTest extends MusicistSuite {

    /**
     * Check that we properly set fields on user during creation.
     *
     * @throws Exception If something goes wrong.
     */
    @Test
    public void testCreateUser() throws Exception {
        final Random random = getRandom();
        final FacebookUser user = new FacebookUser();
        final Long id = random.nextLong();
        user.setId(id);
        final Set<Role> roles = new HashSet<>();
        final Role[] all = Role.values();
        roles.add(all[random.nextInt(all.length)]);
        user.setRoles(roles);
        final String fbid = UUID.randomUUID().toString();
        user.setFacebookId(fbid);
        final String email = fbid + "@test.de";
        user.setEmail(email);
        Assert.assertEquals(id, user.getId());
        Assert.assertEquals(1, user.getRoles().size());
        Assert.assertTrue(user.getRoles().containsAll(roles));
        Assert.assertEquals(fbid, user.getFacebookId());
        Assert.assertEquals(email, user.getEmail());
    }
}<commit_msg>Issue #12. - UserTest.java was refactored: user creation test was cleaned up.<commit_after>package com.github.aistomin.musicist.model;

import com.github.aistomin.musicist.MusicistSuite;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.junit.Assert;
import org.junit.Test;

/**
 * Created by aistomin on 01.05.17.
 * <p>
 * Test for {@link User}
 */
public final class UserTest extends MusicistSuite {

    /**
     * Check that we properly set fields on user during creation.
     *
     * @throws Exception If something goes wrong.
     */
    @Test
    public void testCreateUser() throws Exception {
        final FacebookUser user = new FacebookUser();
        final Long id = getRandom().nextLong();
        user.setId(id);
        final Set<Role> roles = new HashSet<>();
        roles.add(randomRole());
        user.setRoles(roles);
        final String fbid = UUID.randomUUID().toString();
        user.setFacebookId(fbid);
        final String email = fbid + "@test.de";
        user.setEmail(email);
        Assert.assertEquals(id, user.getId());
        Assert.assertEquals(1, user.getRoles().size());
        Assert.assertTrue(user.getRoles().containsAll(roles));
        Assert.assertEquals(fbid, user.getFacebookId());
        Assert.assertEquals(email, user.getEmail());
    }

    /**
     * Get random user's role.
     * @return Random role.
     */
    private Role randomRole() {
        final Role[] all = Role.values();
        return all[getRandom().nextInt(all.length)];
    }
}
{'fraction_non_alphanumeric': 0.12957264957264958, 'fraction_numerical': 0.00547008547008547, 'mean_word_length': 2.844940867279895, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7659184', 'n_tokens_mistral': 871, 'n_tokens_neox': 856, 'n_words': 214}