package com.iqser.red.service.peristence.v1.server.integration.tests;

import static org.assertj.core.api.Assertions.assertThat;

import java.time.OffsetDateTime;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

import com.iqser.red.service.peristence.v1.server.integration.client.RedactionLogClient;
import com.iqser.red.service.peristence.v1.server.integration.service.DossierTesterAndProvider;
import com.iqser.red.service.peristence.v1.server.integration.service.FileTesterAndProvider;
import com.iqser.red.service.peristence.v1.server.integration.utils.AbstractPersistenceServerServiceTest;
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.FilteredRedactionLogRequest;

public class RedactionLogTest extends AbstractPersistenceServerServiceTest {

    @Autowired
    private FileTesterAndProvider fileTesterAndProvider;

    @Autowired
    private DossierTesterAndProvider dossierTesterAndProvider;

    @Autowired
    private RedactionLogClient redactionLogClient;


    @Test
    public void testRedactionLog() {

        var dossier = dossierTesterAndProvider.provideTestDossier();
        var file = fileTesterAndProvider.testAndProvideFile(dossier);

        assertThat(redactionLogClient.getSectionGrid(dossier.getId(), file.getId())).isNotNull();
        assertThat(redactionLogClient.getRedactionLog(dossier.getId(), file.getId(), null, true, false)).isNotNull();
        assertThat(redactionLogClient.getRedactionLog(dossier.getId(), file.getId(), null, false, false)).isNotNull();
        assertThat(redactionLogClient.getFilteredRedactionLog(dossier.getId(),
                file.getId(),
                FilteredRedactionLogRequest.builder()
                        .excludedTypes(null)
                        .withManualRedactions(true)
                        .includeFalsePositives(false)
                        .specifiedDate(OffsetDateTime.now().minusDays(30))
                        .build())).isNotNull();
    }

}
