package com.emonster.taroaichat.domain;

import static com.emonster.taroaichat.domain.DonationTestSamples.*;
import static com.emonster.taroaichat.domain.TarotSessionTestSamples.*;
import static com.emonster.taroaichat.domain.UserProfileTestSamples.*;
import static org.assertj.core.api.Assertions.assertThat;

import com.emonster.taroaichat.web.rest.TestUtil;
import java.util.HashSet;
import java.util.Set;
import org.junit.jupiter.api.Test;

class UserProfileTest {

    @Test
    void equalsVerifier() throws Exception {
        TestUtil.equalsVerifier(UserProfile.class);
        UserProfile userProfile1 = getUserProfileSample1();
        UserProfile userProfile2 = new UserProfile();
        assertThat(userProfile1).isNotEqualTo(userProfile2);

        userProfile2.setId(userProfile1.getId());
        assertThat(userProfile1).isEqualTo(userProfile2);

        userProfile2 = getUserProfileSample2();
        assertThat(userProfile1).isNotEqualTo(userProfile2);
    }

    @Test
    void tarotSessionTest() {
        UserProfile userProfile = getUserProfileRandomSampleGenerator();
        TarotSession tarotSessionBack = getTarotSessionRandomSampleGenerator();

        userProfile.addTarotSession(tarotSessionBack);
        assertThat(userProfile.getTarotSessions()).containsOnly(tarotSessionBack);
        assertThat(tarotSessionBack.getUserProfile()).isEqualTo(userProfile);

        userProfile.removeTarotSession(tarotSessionBack);
        assertThat(userProfile.getTarotSessions()).doesNotContain(tarotSessionBack);
        assertThat(tarotSessionBack.getUserProfile()).isNull();

        userProfile.tarotSessions(new HashSet<>(Set.of(tarotSessionBack)));
        assertThat(userProfile.getTarotSessions()).containsOnly(tarotSessionBack);
        assertThat(tarotSessionBack.getUserProfile()).isEqualTo(userProfile);

        userProfile.setTarotSessions(new HashSet<>());
        assertThat(userProfile.getTarotSessions()).doesNotContain(tarotSessionBack);
        assertThat(tarotSessionBack.getUserProfile()).isNull();
    }

    @Test
    void donationTest() {
        UserProfile userProfile = getUserProfileRandomSampleGenerator();
        Donation donationBack = getDonationRandomSampleGenerator();

        userProfile.addDonation(donationBack);
        assertThat(userProfile.getDonations()).containsOnly(donationBack);
        assertThat(donationBack.getUserProfile()).isEqualTo(userProfile);

        userProfile.removeDonation(donationBack);
        assertThat(userProfile.getDonations()).doesNotContain(donationBack);
        assertThat(donationBack.getUserProfile()).isNull();

        userProfile.donations(new HashSet<>(Set.of(donationBack)));
        assertThat(userProfile.getDonations()).containsOnly(donationBack);
        assertThat(donationBack.getUserProfile()).isEqualTo(userProfile);

        userProfile.setDonations(new HashSet<>());
        assertThat(userProfile.getDonations()).doesNotContain(donationBack);
        assertThat(donationBack.getUserProfile()).isNull();
    }
}
