<commit_before>package lan.dk.podcastserver.entity;

import org.junit.Before;
import org.junit.Test;

import java.time.ZonedDateTime;
import java.util.HashSet;

import static lan.dk.podcastserver.assertion.Assertions.assertThat;

/**
 * Created by kevin on 15/06/15 for HackerRank problem
 */
public class PodcastTest {

    public static final ZonedDateTime NOW = ZonedDateTime.now();
    public static final Cover COVER = new Cover("ACover");
    public static final Podcast PODCAST = new Podcast();
    public static final String PODCAST_TOSTRING = "Podcast{id=1, title='PodcastDeTest', url='http://nowhere.com', signature='ae4b93a7e8249d6be591649c936dbe7d', type='Youtube', lastUpdate=%s}";


    @Before
    public void init() {
        /* Given */
        PODCAST.setId(1);
        PODCAST.setTitle("PodcastDeTest");
        PODCAST.setUrl("http://nowhere.com");
        PODCAST.setSignature("ae4b93a7e8249d6be591649c936dbe7d");
        PODCAST.setType("Youtube");
        PODCAST.setLastUpdate(NOW);
        PODCAST.setCover(COVER);
        PODCAST.setDescription("A long Description");
        PODCAST.setHasToBeDeleted(true);
        PODCAST.setItems(new HashSet<>());
        PODCAST.setTags(new HashSet<>());
    }

    @Test
    public void should_have_all_setters_and_getters_working() {
        /* Then */
        assertThat(PODCAST)
                .hasId(1)
                .hasTitle("PodcastDeTest")
                .hasUrl("http://nowhere.com")
                .hasSignature("ae4b93a7e8249d6be591649c936dbe7d")
                .hasType("Youtube")
                .hasLastUpdate(NOW)
                .hasCover(COVER)
                .hasDescription("A long Description")
                .hasHasToBeDeleted(true)
                .hasNoItems()
                .hasNoTags();
    }
    
    @Test
    public void should_have_toString() {
        org.assertj.core.api.Assertions.
                assertThat(PODCAST.toString())
                    .isEqualTo(String.format(PODCAST_TOSTRING, NOW));
    }
    
    @Test
    public void should_have_hashcode_and_equals() {
        /* Given */
        Podcast samePodcast = new Podcast();
        samePodcast.setId(1);
        samePodcast.setLastUpdate(NOW);
        samePodcast.setSignature("ae4b93a7e8249d6be591649c936dbe7d");
        samePodcast.setTitle("PodcastDeTest");
        samePodcast.setUrl("http://nowhere.com");

        Object notPodcast = new Object();

        /* Then */
        assertThat(PODCAST).isEqualTo(PODCAST);
        assertThat(PODCAST).isNotEqualTo(notPodcast);
        assertThat(PODCAST).isEqualTo(samePodcast);

        org.assertj.core.api.Assertions.
                assertThat(PODCAST.hashCode())
                .isPositive();
    }
    <commit_msg>fix(podcast): change the test about hashcode<commit_after>package lan.dk.podcastserver.entity;

import org.junit.Before;
import org.junit.Test;

import java.time.ZonedDateTime;
import java.util.HashSet;

import static lan.dk.podcastserver.assertion.Assertions.assertThat;

/**
 * Created by kevin on 15/06/15 for HackerRank problem
 */
public class PodcastTest {

    public static final ZonedDateTime NOW = ZonedDateTime.now();
    public static final Cover COVER = new Cover("ACover");
    public static final Podcast PODCAST = new Podcast();
    public static final String PODCAST_TOSTRING = "Podcast{id=1, title='PodcastDeTest', url='http://nowhere.com', signature='ae4b93a7e8249d6be591649c936dbe7d', type='Youtube', lastUpdate=%s}";


    @Before
    public void init() {
        /* Given */
        PODCAST.setId(1);
        PODCAST.setTitle("PodcastDeTest");
        PODCAST.setUrl("http://nowhere.com");
        PODCAST.setSignature("ae4b93a7e8249d6be591649c936dbe7d");
        PODCAST.setType("Youtube");
        PODCAST.setLastUpdate(NOW);
        PODCAST.setCover(COVER);
        PODCAST.setDescription("A long Description");
        PODCAST.setHasToBeDeleted(true);
        PODCAST.setItems(new HashSet<>());
        PODCAST.setTags(new HashSet<>());
    }

    @Test
    public void should_have_all_setters_and_getters_working() {
        /* Then */
        assertThat(PODCAST)
                .hasId(1)
                .hasTitle("PodcastDeTest")
                .hasUrl("http://nowhere.com")
                .hasSignature("ae4b93a7e8249d6be591649c936dbe7d")
                .hasType("Youtube")
                .hasLastUpdate(NOW)
                .hasCover(COVER)
                .hasDescription("A long Description")
                .hasHasToBeDeleted(true)
                .hasNoItems()
                .hasNoTags();
    }
    
    @Test
    public void should_have_toString() {
        org.assertj.core.api.Assertions.
                assertThat(PODCAST.toString())
                    .isEqualTo(String.format(PODCAST_TOSTRING, NOW));
    }
    
    @Test
    public void should_have_hashcode_and_equals() {
        /* Given */
        Podcast samePodcast = new Podcast();
        samePodcast.setId(1);
        samePodcast.setLastUpdate(NOW);
        samePodcast.setSignature("ae4b93a7e8249d6be591649c936dbe7d");
        samePodcast.setTitle("PodcastDeTest");
        samePodcast.setUrl("http://nowhere.com");

        Object notPodcast = new Object();

        /* Then */
        assertThat(PODCAST).isEqualTo(PODCAST);
        assertThat(PODCAST).isNotEqualTo(notPodcast);
        assertThat(PODCAST).isEqualTo(samePodcast);

        org.assertj.core.api.Assertions.
                assertThat(PODCAST.hashCode())
                .isNotNull();
    }
    
{'fraction_non_alphanumeric': 0.11620739666424945, 'fraction_numerical': 0.03118201595358956, 'mean_word_length': 2.443820224719101, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '529339', 'n_tokens_mistral': 1852, 'n_tokens_neox': 1746, 'n_words': 259}