package cz.moneta.test.utils.task.wso2.depersonalization;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import cz.moneta.test.dsl.wso2.objects.traininggov.DoDepersCustTestRequest;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;

import java.util.Arrays;

import static org.junit.jupiter.api.Assertions.assertEquals;

@TestScenario()
public class DepersonalizationTasksTest {
    private final ObjectMapper jackson = new ObjectMapper();

    @TestCase
    public void depersonalizationTasksNullValues() throws JsonProcessingException {
        DoDepersCustTestRequest request = DoDepersCustTestRequest.builder()
                .fonCif(null)
                .fopCif(null)
                .rcNum(null)
                .icoNum(null)
                .rsData(null)
                .build();

        String requestJson = this.jackson.writeValueAsString(request);

        assertEquals("{\"ICO_NUM\":null,\"FOPCIF\":null,\"RC_NUM\":null,\"FONCIF\":null,\"RS_1\":null}", requestJson);
    }

    @TestCase
    public void depersonalizationTasksEmptyValues() throws JsonProcessingException {
        DoDepersCustTestRequest request = DoDepersCustTestRequest.builder()
                .build();

        String requestJson = this.jackson.writeValueAsString(request);

        assertEquals("{\"ICO_NUM\":null,\"FOPCIF\":null,\"RC_NUM\":null,\"FONCIF\":null,\"RS_1\":[]}", requestJson);
    }

    @TestCase
    public void depersonalizationTasksFilledValues() throws JsonProcessingException {
        DoDepersCustTestRequest request = DoDepersCustTestRequest.builder()
                .fonCif("VALUE_FON_CIF")
                .fopCif("VALUE_FOP_CIF")
                .rcNum("VALUE_RC_NUM")
                .icoNum("VALUE_ICO_NUM")
                .rsData(Arrays.asList(DoDepersCustTestRequest.Rs1.builder()
                                .srcSysIdIn("NAS0")
                                .build(),
                        DoDepersCustTestRequest.Rs1.builder()
                                .srcSysIdIn("ICB0")
                                .build()))
                .build();

        String requestJson = this.jackson.writeValueAsString(request);

        assertEquals("{\"ICO_NUM\":\"VALUE_ICO_NUM\",\"FOPCIF\":\"VALUE_FOP_CIF\",\"RC_NUM\":\"VALUE_RC_NUM\",\"FONCIF\":\"VALUE_FON_CIF\",\"RS_1\":[{\"SRC_SYS_ID_IN\":\"NAS0\"},{\"SRC_SYS_ID_IN\":\"ICB0\"}]}", requestJson);
    }
}
