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

package com.azure.resourcemanager.managementgroups.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.managementgroups.models.ManagementGroupDetails;
import com.azure.resourcemanager.managementgroups.models.ManagementGroupPathElement;
import com.azure.resourcemanager.managementgroups.models.ParentGroupInfo;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ManagementGroupDetailsTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ManagementGroupDetails model =
            BinaryData
                .fromString(
                    "{\"version\":1818222173,\"updatedTime\":\"2021-01-21T06:57:24Z\",\"updatedBy\":\"ulngsntn\",\"parent\":{\"id\":\"kzgcwrwcl\",\"name\":\"wrljdouskc\",\"displayName\":\"kocrcjdkwtnhx\"},\"path\":[{\"name\":\"iksqr\",\"displayName\":\"ssainqpjwnzll\"},{\"name\":\"mppeebvmgxs\",\"displayName\":\"kyqduujit\"},{\"name\":\"czdzev\",\"displayName\":\"hkr\"},{\"name\":\"d\",\"displayName\":\"p\"}],\"managementGroupAncestors\":[\"dkvwrwjfe\",\"snhu\",\"je\"],\"managementGroupAncestorsChain\":[{\"name\":\"ldhugjzzdatqxh\",\"displayName\":\"dgeablgphu\"},{\"name\":\"cndvkaozwyiftyhx\",\"displayName\":\"rokft\"}]}")
                .toObject(ManagementGroupDetails.class);
        Assertions.assertEquals(1818222173, model.version());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-21T06:57:24Z"), model.updatedTime());
        Assertions.assertEquals("ulngsntn", model.updatedBy());
        Assertions.assertEquals("kzgcwrwcl", model.parent().id());
        Assertions.assertEquals("wrljdouskc", model.parent().name());
        Assertions.assertEquals("kocrcjdkwtnhx", model.parent().displayName());
        Assertions.assertEquals("iksqr", model.path().get(0).name());
        Assertions.assertEquals("ssainqpjwnzll", model.path().get(0).displayName());
        Assertions.assertEquals("dkvwrwjfe", model.managementGroupAncestors().get(0));
        Assertions.assertEquals("ldhugjzzdatqxh", model.managementGroupAncestorsChain().get(0).name());
        Assertions.assertEquals("dgeablgphu", model.managementGroupAncestorsChain().get(0).displayName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ManagementGroupDetails model =
            new ManagementGroupDetails()
                .withVersion(1818222173)
                .withUpdatedTime(OffsetDateTime.parse("2021-01-21T06:57:24Z"))
                .withUpdatedBy("ulngsntn")
                .withParent(
                    new ParentGroupInfo().withId("kzgcwrwcl").withName("wrljdouskc").withDisplayName("kocrcjdkwtnhx"))
                .withPath(
                    Arrays
                        .asList(
                            new ManagementGroupPathElement().withName("iksqr").withDisplayName("ssainqpjwnzll"),
                            new ManagementGroupPathElement().withName("mppeebvmgxs").withDisplayName("kyqduujit"),
                            new ManagementGroupPathElement().withName("czdzev").withDisplayName("hkr"),
                            new ManagementGroupPathElement().withName("d").withDisplayName("p")))
                .withManagementGroupAncestors(Arrays.asList("dkvwrwjfe", "snhu", "je"))
                .withManagementGroupAncestorsChain(
                    Arrays
                        .asList(
                            new ManagementGroupPathElement().withName("ldhugjzzdatqxh").withDisplayName("dgeablgphu"),
                            new ManagementGroupPathElement().withName("cndvkaozwyiftyhx").withDisplayName("rokft")));
        model = BinaryData.fromObject(model).toObject(ManagementGroupDetails.class);
        Assertions.assertEquals(1818222173, model.version());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-21T06:57:24Z"), model.updatedTime());
        Assertions.assertEquals("ulngsntn", model.updatedBy());
        Assertions.assertEquals("kzgcwrwcl", model.parent().id());
        Assertions.assertEquals("wrljdouskc", model.parent().name());
        Assertions.assertEquals("kocrcjdkwtnhx", model.parent().displayName());
        Assertions.assertEquals("iksqr", model.path().get(0).name());
        Assertions.assertEquals("ssainqpjwnzll", model.path().get(0).displayName());
        Assertions.assertEquals("dkvwrwjfe", model.managementGroupAncestors().get(0));
        Assertions.assertEquals("ldhugjzzdatqxh", model.managementGroupAncestorsChain().get(0).name());
        Assertions.assertEquals("dgeablgphu", model.managementGroupAncestorsChain().get(0).displayName());
    }
}
