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

package com.azure.resourcemanager.storagepool.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.storagepool.models.CreatedByType;
import com.azure.resourcemanager.storagepool.models.SystemMetadata;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class SystemMetadataTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SystemMetadata model =
            BinaryData
                .fromString(
                    "{\"createdBy\":\"zloc\",\"createdByType\":\"User\",\"createdAt\":\"2021-11-18T07:05:01Z\",\"lastModifiedBy\":\"erhhbcsglumm\",\"lastModifiedByType\":\"ManagedIdentity\",\"lastModifiedAt\":\"2021-08-25T02:16:19Z\"}")
                .toObject(SystemMetadata.class);
        Assertions.assertEquals("zloc", model.createdBy());
        Assertions.assertEquals(CreatedByType.USER, model.createdByType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-18T07:05:01Z"), model.createdAt());
        Assertions.assertEquals("erhhbcsglumm", model.lastModifiedBy());
        Assertions.assertEquals(CreatedByType.MANAGED_IDENTITY, model.lastModifiedByType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-25T02:16:19Z"), model.lastModifiedAt());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SystemMetadata model =
            new SystemMetadata()
                .withCreatedBy("zloc")
                .withCreatedByType(CreatedByType.USER)
                .withCreatedAt(OffsetDateTime.parse("2021-11-18T07:05:01Z"))
                .withLastModifiedBy("erhhbcsglumm")
                .withLastModifiedByType(CreatedByType.MANAGED_IDENTITY)
                .withLastModifiedAt(OffsetDateTime.parse("2021-08-25T02:16:19Z"));
        model = BinaryData.fromObject(model).toObject(SystemMetadata.class);
        Assertions.assertEquals("zloc", model.createdBy());
        Assertions.assertEquals(CreatedByType.USER, model.createdByType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-18T07:05:01Z"), model.createdAt());
        Assertions.assertEquals("erhhbcsglumm", model.lastModifiedBy());
        Assertions.assertEquals(CreatedByType.MANAGED_IDENTITY, model.lastModifiedByType());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-25T02:16:19Z"), model.lastModifiedAt());
    }
}
