// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.policyinsights.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.policyinsights.fluent.models.AttestationProperties;
import com.azure.resourcemanager.policyinsights.models.AttestationEvidence;
import com.azure.resourcemanager.policyinsights.models.ComplianceState;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class AttestationPropertiesTests {
    @Test
    public void testDeserialize() {
        AttestationProperties model =
            BinaryData
                .fromString(
                    "{\"policyAssignmentId\":\"y\",\"policyDefinitionReferenceId\":\"nyowxwlmdjrkvfg\",\"complianceState\":\"Unknown\",\"expiresOn\":\"2021-01-22T04:49:05Z\",\"owner\":\"bodacizsjq\",\"comments\":\"krribdeibqi\",\"evidence\":[{\"description\":\"hvxndzwmkrefajpj\",\"sourceUri\":\"wkqnyhg\"}],\"provisioningState\":\"j\",\"lastComplianceStateChangeAt\":\"2021-03-05T18:22:33Z\",\"assessmentDate\":\"2021-01-15T08:47:59Z\"}")
                .toObject(AttestationProperties.class);
        Assertions.assertEquals("y", model.policyAssignmentId());
        Assertions.assertEquals("nyowxwlmdjrkvfg", model.policyDefinitionReferenceId());
        Assertions.assertEquals(ComplianceState.UNKNOWN, model.complianceState());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-22T04:49:05Z"), model.expiresOn());
        Assertions.assertEquals("bodacizsjq", model.owner());
        Assertions.assertEquals("krribdeibqi", model.comments());
        Assertions.assertEquals("hvxndzwmkrefajpj", model.evidence().get(0).description());
        Assertions.assertEquals("wkqnyhg", model.evidence().get(0).sourceUri());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-15T08:47:59Z"), model.assessmentDate());
    }

    @Test
    public void testSerialize() {
        AttestationProperties model =
            new AttestationProperties()
                .withPolicyAssignmentId("y")
                .withPolicyDefinitionReferenceId("nyowxwlmdjrkvfg")
                .withComplianceState(ComplianceState.UNKNOWN)
                .withExpiresOn(OffsetDateTime.parse("2021-01-22T04:49:05Z"))
                .withOwner("bodacizsjq")
                .withComments("krribdeibqi")
                .withEvidence(
                    Arrays
                        .asList(new AttestationEvidence().withDescription("hvxndzwmkrefajpj").withSourceUri("wkqnyhg")))
                .withAssessmentDate(OffsetDateTime.parse("2021-01-15T08:47:59Z"));
        model = BinaryData.fromObject(model).toObject(AttestationProperties.class);
        Assertions.assertEquals("y", model.policyAssignmentId());
        Assertions.assertEquals("nyowxwlmdjrkvfg", model.policyDefinitionReferenceId());
        Assertions.assertEquals(ComplianceState.UNKNOWN, model.complianceState());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-22T04:49:05Z"), model.expiresOn());
        Assertions.assertEquals("bodacizsjq", model.owner());
        Assertions.assertEquals("krribdeibqi", model.comments());
        Assertions.assertEquals("hvxndzwmkrefajpj", model.evidence().get(0).description());
        Assertions.assertEquals("wkqnyhg", model.evidence().get(0).sourceUri());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-15T08:47:59Z"), model.assessmentDate());
    }
}
