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

package com.azure.resourcemanager.changeanalysis.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.changeanalysis.models.ChangeCategory;
import com.azure.resourcemanager.changeanalysis.models.ChangeProperties;
import com.azure.resourcemanager.changeanalysis.models.ChangeType;
import com.azure.resourcemanager.changeanalysis.models.Level;
import com.azure.resourcemanager.changeanalysis.models.PropertyChange;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ChangePropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ChangeProperties model =
            BinaryData
                .fromString(
                    "{\"resourceId\":\"vtz\",\"timeStamp\":\"2021-09-18T00:19:24Z\",\"initiatedByList\":[\"bljofxqeof\",\"aeqjhqjbasvms\",\"jqul\"],\"changeType\":\"Add\",\"propertyChanges\":[{\"changeType\":\"Add\",\"changeCategory\":\"System\",\"jsonPath\":\"zgcwrw\",\"displayName\":\"xxwr\",\"level\":\"Important\",\"description\":\"uskcqvkocrcj\",\"oldValue\":\"wtnhxbnjbiksqr\",\"newValue\":\"ssainqpjwnzll\",\"isDataMasked\":true}]}")
                .toObject(ChangeProperties.class);
        Assertions.assertEquals("vtz", model.resourceId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-18T00:19:24Z"), model.timestamp());
        Assertions.assertEquals("bljofxqeof", model.initiatedByList().get(0));
        Assertions.assertEquals(ChangeType.ADD, model.changeType());
        Assertions.assertEquals(ChangeType.ADD, model.propertyChanges().get(0).changeType());
        Assertions.assertEquals(ChangeCategory.SYSTEM, model.propertyChanges().get(0).changeCategory());
        Assertions.assertEquals("zgcwrw", model.propertyChanges().get(0).jsonPath());
        Assertions.assertEquals("xxwr", model.propertyChanges().get(0).displayName());
        Assertions.assertEquals(Level.IMPORTANT, model.propertyChanges().get(0).level());
        Assertions.assertEquals("uskcqvkocrcj", model.propertyChanges().get(0).description());
        Assertions.assertEquals("wtnhxbnjbiksqr", model.propertyChanges().get(0).oldValue());
        Assertions.assertEquals("ssainqpjwnzll", model.propertyChanges().get(0).newValue());
        Assertions.assertEquals(true, model.propertyChanges().get(0).isDataMasked());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ChangeProperties model =
            new ChangeProperties()
                .withResourceId("vtz")
                .withTimestamp(OffsetDateTime.parse("2021-09-18T00:19:24Z"))
                .withInitiatedByList(Arrays.asList("bljofxqeof", "aeqjhqjbasvms", "jqul"))
                .withChangeType(ChangeType.ADD)
                .withPropertyChanges(
                    Arrays
                        .asList(
                            new PropertyChange()
                                .withChangeType(ChangeType.ADD)
                                .withChangeCategory(ChangeCategory.SYSTEM)
                                .withJsonPath("zgcwrw")
                                .withDisplayName("xxwr")
                                .withLevel(Level.IMPORTANT)
                                .withDescription("uskcqvkocrcj")
                                .withOldValue("wtnhxbnjbiksqr")
                                .withNewValue("ssainqpjwnzll")
                                .withIsDataMasked(true)));
        model = BinaryData.fromObject(model).toObject(ChangeProperties.class);
        Assertions.assertEquals("vtz", model.resourceId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-09-18T00:19:24Z"), model.timestamp());
        Assertions.assertEquals("bljofxqeof", model.initiatedByList().get(0));
        Assertions.assertEquals(ChangeType.ADD, model.changeType());
        Assertions.assertEquals(ChangeType.ADD, model.propertyChanges().get(0).changeType());
        Assertions.assertEquals(ChangeCategory.SYSTEM, model.propertyChanges().get(0).changeCategory());
        Assertions.assertEquals("zgcwrw", model.propertyChanges().get(0).jsonPath());
        Assertions.assertEquals("xxwr", model.propertyChanges().get(0).displayName());
        Assertions.assertEquals(Level.IMPORTANT, model.propertyChanges().get(0).level());
        Assertions.assertEquals("uskcqvkocrcj", model.propertyChanges().get(0).description());
        Assertions.assertEquals("wtnhxbnjbiksqr", model.propertyChanges().get(0).oldValue());
        Assertions.assertEquals("ssainqpjwnzll", model.propertyChanges().get(0).newValue());
        Assertions.assertEquals(true, model.propertyChanges().get(0).isDataMasked());
    }
}
