package io.delphiplatform.api.v3.bigtable.processing;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.time.LocalDate;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import io.delphiplatform.api.v3.bigtable.entity.Chartmetric;
import io.delphiplatform.api.v3.constant.ChartmetricPartner;
import io.delphiplatform.api.v3.model.ArtistFollower;

class ArtistFollowerConverterTest {

    private ArtistFollowerConverter artistFollowerConverter = new ArtistFollowerConverter();

    @Test
    void convert_facebook() {
        Chartmetric chartmetric = new Chartmetric();
        chartmetric.setDate(LocalDate.of(2020, 10, 1));
        chartmetric.setDsp(ChartmetricPartner.FACEBOOK);
        chartmetric.setArtistId("artist_id");
        chartmetric.setLikes(100L);
        chartmetric.setTalks(200L);

        List<ArtistFollower> artistFollowers = artistFollowerConverter.convert(Stream.of(
            chartmetric
        )).collect(Collectors.toList());

        Assertions.assertEquals(1, artistFollowers.size());
        Assertions.assertEquals(chartmetric.getDate(), artistFollowers.get(0).getDate());
        Assertions.assertEquals(chartmetric.getLikes(), artistFollowers.get(0).getFacebookLikes());
        Assertions.assertEquals(chartmetric.getTalks(), artistFollowers.get(0).getFacebookStorytellers());
    }
}