// Path: src/test/java/org/simplify4u/plugins/TestUtils.java
// public static SignatureCheckResult.SignatureCheckResultBuilder aSignatureCheckResultBuilder(Date date) {
//     return SignatureCheckResult.builder()
//             .artifact(ArtifactInfo.builder()
//                     .groupId("groupId")
//                     .artifactId("artifactId")
//                     .type("jar")
//                     .classifier("classifier")
//                     .version("1.0")
//                     .build())
//             .signature(SignatureInfo.builder()
//                     .version(4)
//                     .keyId(KeyId.from(0x1234L))
//                     .hashAlgorithm(HashAlgorithmTags.MD5)
//                     .keyAlgorithm(PublicKeyAlgorithmTags.RSA_GENERAL)
//                     .date(date)
//                     .build())
//             .key(KeyInfo.builder()
//                     .version(4)
//                     .fingerprint(new KeyFingerprint("0x12345678901234567890"))
//                     .master(new KeyFingerprint("0x09876543210987654321"))
//                     .algorithm(PublicKeyAlgorithmTags.RSA_GENERAL)
//                     .uids(Collections.singleton("Test uid <uid@example.com>"))
//                     .bits(2048)
//                     .date(date)
//                     .build())
//             .status(SignatureStatus.SIGNATURE_VALID)
//             .keyShowUrl("https://example.com/key");
// }


import java.io.File;
import java.io.IOException;
import java.time.ZonedDateTime;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.simplify4u.plugins.TestUtils.aSignatureCheckResultBuilder;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/*
 * Copyright 2021 Slawomir Jaranowski
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.simplify4u.plugins.pgp;




public class ReportsUtilsTest {

    private ReportsUtils reportsUtils = new ReportsUtils();
    private File reportFile;

    @BeforeMethod
    void setup() throws IOException {
        reportFile = File.createTempFile("report-test", ".json");
        reportFile.deleteOnExit();
    }

    @AfterMethod
    void cleanup() {
        reportFile.delete();
    }

    @Test
    void shouldGenerateEmptyArray() throws IOException {
        reportsUtils.writeReportAsJson(reportFile, Collections.emptyList());
        assertThat(reportFile).hasContent("[]");
    }

    @Test
    void nullCollectionThrowNPE() {
        assertThatThrownBy(() -> reportsUtils.writeReportAsJson(reportFile, null))
                .isExactlyInstanceOf(NullPointerException.class);
    }

    @Test
    void shouldGenerateReport() throws IOException {

        File expectedReport = new File(getClass().getResource("/test-report.json").getFile());

        ZonedDateTime zonedDateTime = ZonedDateTime.parse("2020-06-05T11:22:33.444+00:00[UTC]");
        Date date1 = Date.from(zonedDateTime.toInstant());
        Date date2 = Date.from(zonedDateTime.minusDays(44).minusHours(1).toInstant());

// Path: src/test/java/org/simplify4u/plugins/TestUtils.java
// public static SignatureCheckResult.SignatureCheckResultBuilder aSignatureCheckResultBuilder(Date date) {
//     return SignatureCheckResult.builder()
//             .artifact(ArtifactInfo.builder()
//                     .groupId("groupId")
//                     .artifactId("artifactId")
//                     .type("jar")
//                     .classifier("classifier")
//                     .version("1.0")
//                     .build())
//             .signature(SignatureInfo.builder()
//                     .version(4)
//                     .keyId(KeyId.from(0x1234L))
//                     .hashAlgorithm(HashAlgorithmTags.MD5)
//                     .keyAlgorithm(PublicKeyAlgorithmTags.RSA_GENERAL)
//                     .date(date)
//                     .build())
//             .key(KeyInfo.builder()
//                     .version(4)
//                     .fingerprint(new KeyFingerprint("0x12345678901234567890"))
//                     .master(new KeyFingerprint("0x09876543210987654321"))
//                     .algorithm(PublicKeyAlgorithmTags.RSA_GENERAL)
//                     .uids(Collections.singleton("Test uid <uid@example.com>"))
//                     .bits(2048)
//                     .date(date)
//                     .build())
//             .status(SignatureStatus.SIGNATURE_VALID)
//             .keyShowUrl("https://example.com/key");
// }


// Path: src/test/java/org/simplify4u/plugins/pgp/ReportsUtilsTest.java
import java.io.File;
import java.io.IOException;
import java.time.ZonedDateTime;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.simplify4u.plugins.TestUtils.aSignatureCheckResultBuilder;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

/*
 * Copyright 2021 Slawomir Jaranowski
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.simplify4u.plugins.pgp;




public class ReportsUtilsTest {

    private ReportsUtils reportsUtils = new ReportsUtils();
    private File reportFile;

    @BeforeMethod
    void setup() throws IOException {
        reportFile = File.createTempFile("report-test", ".json");
        reportFile.deleteOnExit();
    }

    @AfterMethod
    void cleanup() {
        reportFile.delete();
    }

    @Test
    void shouldGenerateEmptyArray() throws IOException {
        reportsUtils.writeReportAsJson(reportFile, Collections.emptyList());
        assertThat(reportFile).hasContent("[]");
    }

    @Test
    void nullCollectionThrowNPE() {
        assertThatThrownBy(() -> reportsUtils.writeReportAsJson(reportFile, null))
                .isExactlyInstanceOf(NullPointerException.class);
    }

    @Test
    void shouldGenerateReport() throws IOException {

        File expectedReport = new File(getClass().getResource("/test-report.json").getFile());

        ZonedDateTime zonedDateTime = ZonedDateTime.parse("2020-06-05T11:22:33.444+00:00[UTC]");
        Date date1 = Date.from(zonedDateTime.toInstant());
        Date date2 = Date.from(zonedDateTime.minusDays(44).minusHours(1).toInstant());

        SignatureCheckResult checkResult1 = aSignatureCheckResultBuilder(date1)