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

package com.azure.resourcemanager.recoveryservices.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.recoveryservices.fluent.models.VaultCertificateResponseInner;
import com.azure.resourcemanager.recoveryservices.models.ResourceCertificateDetails;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class VaultCertificateResponseInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        VaultCertificateResponseInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"authType\":\"ResourceCertificateDetails\",\"friendlyName\":\"ybczmehmtzo\",\"issuer\":\"sphrupidgs\",\"resourceId\":5720978843418888179,\"subject\":\"hphoycm\",\"thumbprint\":\"ao\",\"validFrom\":\"2021-04-26T13:10:21Z\",\"validTo\":\"2021-03-23T13:19:49Z\"},\"id\":\"mtqio\",\"name\":\"jzehtb\",\"type\":\"ufpo\"}")
                .toObject(VaultCertificateResponseInner.class);
        Assertions.assertEquals("ybczmehmtzo", model.properties().friendlyName());
        Assertions.assertEquals("sphrupidgs", model.properties().issuer());
        Assertions.assertEquals(5720978843418888179L, model.properties().resourceId());
        Assertions.assertEquals("hphoycm", model.properties().subject());
        Assertions.assertEquals("ao", model.properties().thumbprint());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-26T13:10:21Z"), model.properties().validFrom());
        Assertions.assertEquals(OffsetDateTime.parse("2021-03-23T13:19:49Z"), model.properties().validTo());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        VaultCertificateResponseInner model =
            new VaultCertificateResponseInner()
                .withProperties(
                    new ResourceCertificateDetails()
                        .withFriendlyName("ybczmehmtzo")
                        .withIssuer("sphrupidgs")
                        .withResourceId(5720978843418888179L)
                        .withSubject("hphoycm")
                        .withThumbprint("ao")
                        .withValidFrom(OffsetDateTime.parse("2021-04-26T13:10:21Z"))
                        .withValidTo(OffsetDateTime.parse("2021-03-23T13:19:49Z")));
        model = BinaryData.fromObject(model).toObject(VaultCertificateResponseInner.class);
        Assertions.assertEquals("ybczmehmtzo", model.properties().friendlyName());
        Assertions.assertEquals("sphrupidgs", model.properties().issuer());
        Assertions.assertEquals(5720978843418888179L, model.properties().resourceId());
        Assertions.assertEquals("hphoycm", model.properties().subject());
        Assertions.assertEquals("ao", model.properties().thumbprint());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-26T13:10:21Z"), model.properties().validFrom());
        Assertions.assertEquals(OffsetDateTime.parse("2021-03-23T13:19:49Z"), model.properties().validTo());
    }
}
