// File generated from our OpenAPI spec by Stainless.

package com.increase.api.models.exports

import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import com.increase.api.core.jsonMapper
import java.time.LocalDate
import java.time.OffsetDateTime
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

internal class ExportListPageResponseTest {

    @Test
    fun create() {
        val exportListPageResponse =
            ExportListPageResponse.builder()
                .addData(
                    Export.builder()
                        .id("export_8s4m48qz3bclzje0zwh9")
                        .accountStatementBai2(
                            Export.AccountStatementBai2.builder()
                                .accountId("account_id")
                                .effectiveDate(LocalDate.parse("2019-12-27"))
                                .programId("program_id")
                                .build()
                        )
                        .accountStatementOfx(
                            Export.AccountStatementOfx.builder()
                                .accountId("account_id")
                                .createdAt(
                                    Export.AccountStatementOfx.CreatedAt.builder()
                                        .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .build()
                                )
                                .build()
                        )
                        .accountVerificationLetter(
                            Export.AccountVerificationLetter.builder()
                                .accountNumberId("account_number_id")
                                .balanceDate(LocalDate.parse("2019-12-27"))
                                .build()
                        )
                        .balanceCsv(
                            Export.BalanceCsv.builder()
                                .accountId("account_id")
                                .createdAt(
                                    Export.BalanceCsv.CreatedAt.builder()
                                        .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .build()
                                )
                                .build()
                        )
                        .bookkeepingAccountBalanceCsv(
                            Export.BookkeepingAccountBalanceCsv.builder()
                                .bookkeepingAccountId("bookkeeping_account_id")
                                .onOrAfterDate(LocalDate.parse("2019-12-27"))
                                .onOrBeforeDate(LocalDate.parse("2019-12-27"))
                                .build()
                        )
                        .category(Export.Category.TRANSACTION_CSV)
                        .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z"))
                        .dailyAccountBalanceCsv(
                            Export.DailyAccountBalanceCsv.builder()
                                .accountId("account_id")
                                .onOrAfterDate(LocalDate.parse("2019-12-27"))
                                .onOrBeforeDate(LocalDate.parse("2019-12-27"))
                                .build()
                        )
                        .dashboardTableCsv(Export.DashboardTableCsv.builder().build())
                        .entityCsv(Export.EntityCsv.builder().build())
                        .feeCsv(
                            Export.FeeCsv.builder()
                                .createdAt(
                                    Export.FeeCsv.CreatedAt.builder()
                                        .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .onOrBefore(
                                            OffsetDateTime.parse("2019-12-27T18:11:19.117Z")
                                        )
                                        .build()
                                )
                                .build()
                        )
                        .form1099Int(
                            Export.Form1099Int.builder()
                                .accountId("account_id")
                                .corrected(true)
                                .description("description")
                                .year(0L)
                                .build()
                        )
                        .form1099Misc(
                            Export.Form1099Misc.builder()
                                .accountId("account_id")
                                .corrected(true)
                                .year(0L)
                                .build()
                        )
                        .fundingInstructions(
                            Export.FundingInstructions.builder()
                                .accountNumberId("account_number_id")
                                .build()
                        )
                        .idempotencyKey(null)
                        .result(Export.Result.builder().fileId("file_makxrc67oh9l6sg7w9yc").build())
                        .status(Export.Status.COMPLETE)
                        .transactionCsv(
                            Export.TransactionCsv.builder()
                                .accountId("account_in71c4amph0vgo2qllky")
                                .createdAt(
                                    Export.TransactionCsv.CreatedAt.builder()
                                        .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .build()
                                )
                                .build()
                        )
                        .type(Export.Type.EXPORT)
                        .vendorCsv(Export.VendorCsv.builder().build())
                        .voidedCheck(
                            Export.VoidedCheck.builder()
                                .accountNumberId("account_number_id")
                                .addPayer(Export.VoidedCheck.Payer.builder().line("line").build())
                                .build()
                        )
                        .build()
                )
                .nextCursor("v57w5d")
                .build()

        assertThat(exportListPageResponse.data())
            .containsExactly(
                Export.builder()
                    .id("export_8s4m48qz3bclzje0zwh9")
                    .accountStatementBai2(
                        Export.AccountStatementBai2.builder()
                            .accountId("account_id")
                            .effectiveDate(LocalDate.parse("2019-12-27"))
                            .programId("program_id")
                            .build()
                    )
                    .accountStatementOfx(
                        Export.AccountStatementOfx.builder()
                            .accountId("account_id")
                            .createdAt(
                                Export.AccountStatementOfx.CreatedAt.builder()
                                    .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                    .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                    .build()
                            )
                            .build()
                    )
                    .accountVerificationLetter(
                        Export.AccountVerificationLetter.builder()
                            .accountNumberId("account_number_id")
                            .balanceDate(LocalDate.parse("2019-12-27"))
                            .build()
                    )
                    .balanceCsv(
                        Export.BalanceCsv.builder()
                            .accountId("account_id")
                            .createdAt(
                                Export.BalanceCsv.CreatedAt.builder()
                                    .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                    .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                    .build()
                            )
                            .build()
                    )
                    .bookkeepingAccountBalanceCsv(
                        Export.BookkeepingAccountBalanceCsv.builder()
                            .bookkeepingAccountId("bookkeeping_account_id")
                            .onOrAfterDate(LocalDate.parse("2019-12-27"))
                            .onOrBeforeDate(LocalDate.parse("2019-12-27"))
                            .build()
                    )
                    .category(Export.Category.TRANSACTION_CSV)
                    .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z"))
                    .dailyAccountBalanceCsv(
                        Export.DailyAccountBalanceCsv.builder()
                            .accountId("account_id")
                            .onOrAfterDate(LocalDate.parse("2019-12-27"))
                            .onOrBeforeDate(LocalDate.parse("2019-12-27"))
                            .build()
                    )
                    .dashboardTableCsv(Export.DashboardTableCsv.builder().build())
                    .entityCsv(Export.EntityCsv.builder().build())
                    .feeCsv(
                        Export.FeeCsv.builder()
                            .createdAt(
                                Export.FeeCsv.CreatedAt.builder()
                                    .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                    .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                    .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                    .onOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                    .build()
                            )
                            .build()
                    )
                    .form1099Int(
                        Export.Form1099Int.builder()
                            .accountId("account_id")
                            .corrected(true)
                            .description("description")
                            .year(0L)
                            .build()
                    )
                    .form1099Misc(
                        Export.Form1099Misc.builder()
                            .accountId("account_id")
                            .corrected(true)
                            .year(0L)
                            .build()
                    )
                    .fundingInstructions(
                        Export.FundingInstructions.builder()
                            .accountNumberId("account_number_id")
                            .build()
                    )
                    .idempotencyKey(null)
                    .result(Export.Result.builder().fileId("file_makxrc67oh9l6sg7w9yc").build())
                    .status(Export.Status.COMPLETE)
                    .transactionCsv(
                        Export.TransactionCsv.builder()
                            .accountId("account_in71c4amph0vgo2qllky")
                            .createdAt(
                                Export.TransactionCsv.CreatedAt.builder()
                                    .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                    .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                    .build()
                            )
                            .build()
                    )
                    .type(Export.Type.EXPORT)
                    .vendorCsv(Export.VendorCsv.builder().build())
                    .voidedCheck(
                        Export.VoidedCheck.builder()
                            .accountNumberId("account_number_id")
                            .addPayer(Export.VoidedCheck.Payer.builder().line("line").build())
                            .build()
                    )
                    .build()
            )
        assertThat(exportListPageResponse.nextCursor()).contains("v57w5d")
    }

    @Test
    fun roundtrip() {
        val jsonMapper = jsonMapper()
        val exportListPageResponse =
            ExportListPageResponse.builder()
                .addData(
                    Export.builder()
                        .id("export_8s4m48qz3bclzje0zwh9")
                        .accountStatementBai2(
                            Export.AccountStatementBai2.builder()
                                .accountId("account_id")
                                .effectiveDate(LocalDate.parse("2019-12-27"))
                                .programId("program_id")
                                .build()
                        )
                        .accountStatementOfx(
                            Export.AccountStatementOfx.builder()
                                .accountId("account_id")
                                .createdAt(
                                    Export.AccountStatementOfx.CreatedAt.builder()
                                        .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .build()
                                )
                                .build()
                        )
                        .accountVerificationLetter(
                            Export.AccountVerificationLetter.builder()
                                .accountNumberId("account_number_id")
                                .balanceDate(LocalDate.parse("2019-12-27"))
                                .build()
                        )
                        .balanceCsv(
                            Export.BalanceCsv.builder()
                                .accountId("account_id")
                                .createdAt(
                                    Export.BalanceCsv.CreatedAt.builder()
                                        .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .build()
                                )
                                .build()
                        )
                        .bookkeepingAccountBalanceCsv(
                            Export.BookkeepingAccountBalanceCsv.builder()
                                .bookkeepingAccountId("bookkeeping_account_id")
                                .onOrAfterDate(LocalDate.parse("2019-12-27"))
                                .onOrBeforeDate(LocalDate.parse("2019-12-27"))
                                .build()
                        )
                        .category(Export.Category.TRANSACTION_CSV)
                        .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z"))
                        .dailyAccountBalanceCsv(
                            Export.DailyAccountBalanceCsv.builder()
                                .accountId("account_id")
                                .onOrAfterDate(LocalDate.parse("2019-12-27"))
                                .onOrBeforeDate(LocalDate.parse("2019-12-27"))
                                .build()
                        )
                        .dashboardTableCsv(Export.DashboardTableCsv.builder().build())
                        .entityCsv(Export.EntityCsv.builder().build())
                        .feeCsv(
                            Export.FeeCsv.builder()
                                .createdAt(
                                    Export.FeeCsv.CreatedAt.builder()
                                        .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .onOrBefore(
                                            OffsetDateTime.parse("2019-12-27T18:11:19.117Z")
                                        )
                                        .build()
                                )
                                .build()
                        )
                        .form1099Int(
                            Export.Form1099Int.builder()
                                .accountId("account_id")
                                .corrected(true)
                                .description("description")
                                .year(0L)
                                .build()
                        )
                        .form1099Misc(
                            Export.Form1099Misc.builder()
                                .accountId("account_id")
                                .corrected(true)
                                .year(0L)
                                .build()
                        )
                        .fundingInstructions(
                            Export.FundingInstructions.builder()
                                .accountNumberId("account_number_id")
                                .build()
                        )
                        .idempotencyKey(null)
                        .result(Export.Result.builder().fileId("file_makxrc67oh9l6sg7w9yc").build())
                        .status(Export.Status.COMPLETE)
                        .transactionCsv(
                            Export.TransactionCsv.builder()
                                .accountId("account_in71c4amph0vgo2qllky")
                                .createdAt(
                                    Export.TransactionCsv.CreatedAt.builder()
                                        .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                                        .build()
                                )
                                .build()
                        )
                        .type(Export.Type.EXPORT)
                        .vendorCsv(Export.VendorCsv.builder().build())
                        .voidedCheck(
                            Export.VoidedCheck.builder()
                                .accountNumberId("account_number_id")
                                .addPayer(Export.VoidedCheck.Payer.builder().line("line").build())
                                .build()
                        )
                        .build()
                )
                .nextCursor("v57w5d")
                .build()

        val roundtrippedExportListPageResponse =
            jsonMapper.readValue(
                jsonMapper.writeValueAsString(exportListPageResponse),
                jacksonTypeRef<ExportListPageResponse>(),
            )

        assertThat(roundtrippedExportListPageResponse).isEqualTo(exportListPageResponse)
    }
}
