// 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.fluent.models.ManagementGroupProperties;
import com.azure.resourcemanager.managementgroups.models.ManagementGroupChildInfo;
import com.azure.resourcemanager.managementgroups.models.ManagementGroupChildType;
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 ManagementGroupPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ManagementGroupProperties model =
            BinaryData
                .fromString(
                    "{\"tenantId\":\"ilzyd\",\"displayName\":\"o\",\"details\":{\"version\":2010120941,\"updatedTime\":\"2021-04-29T07:45:55Z\",\"updatedBy\":\"inpm\",\"parent\":{\"id\":\"aqwi\",\"name\":\"sprozvcput\",\"displayName\":\"jvwmfda\"},\"path\":[{\"name\":\"dvpjhulsuuvmk\",\"displayName\":\"zkrwfn\"}],\"managementGroupAncestors\":[\"djpslw\",\"jdpvwryo\",\"psoacctazakljl\"],\"managementGroupAncestorsChain\":[{\"name\":\"ryffdfdosy\",\"displayName\":\"xpaojakhmsbz\"},{\"name\":\"crzevdphlx\",\"displayName\":\"lthqtrgqjbp\"},{\"name\":\"fsinzgvfcjrwzoxx\",\"displayName\":\"felluwfzitonpe\"}]},\"children\":[{\"type\":\"/subscriptions\",\"id\":\"lxofpdvhpfxxypin\",\"name\":\"mayhuybbkpodepoo\",\"displayName\":\"nuvamiheogna\",\"children\":[]},{\"type\":\"/subscriptions\",\"id\":\"eotusivyevc\",\"name\":\"qi\",\"displayName\":\"hungbwjzrnf\",\"children\":[]},{\"type\":\"Microsoft.Management/managementGroups\",\"id\":\"pemvtzfkufubljof\",\"name\":\"eofjaeqjh\",\"displayName\":\"b\",\"children\":[]}]}")
                .toObject(ManagementGroupProperties.class);
        Assertions.assertEquals("ilzyd", model.tenantId());
        Assertions.assertEquals("o", model.displayName());
        Assertions.assertEquals(2010120941, model.details().version());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-29T07:45:55Z"), model.details().updatedTime());
        Assertions.assertEquals("inpm", model.details().updatedBy());
        Assertions.assertEquals("aqwi", model.details().parent().id());
        Assertions.assertEquals("sprozvcput", model.details().parent().name());
        Assertions.assertEquals("jvwmfda", model.details().parent().displayName());
        Assertions.assertEquals("dvpjhulsuuvmk", model.details().path().get(0).name());
        Assertions.assertEquals("zkrwfn", model.details().path().get(0).displayName());
        Assertions.assertEquals("djpslw", model.details().managementGroupAncestors().get(0));
        Assertions.assertEquals("ryffdfdosy", model.details().managementGroupAncestorsChain().get(0).name());
        Assertions.assertEquals("xpaojakhmsbz", model.details().managementGroupAncestorsChain().get(0).displayName());
        Assertions.assertEquals(ManagementGroupChildType.SUBSCRIPTIONS, model.children().get(0).type());
        Assertions.assertEquals("lxofpdvhpfxxypin", model.children().get(0).id());
        Assertions.assertEquals("mayhuybbkpodepoo", model.children().get(0).name());
        Assertions.assertEquals("nuvamiheogna", model.children().get(0).displayName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ManagementGroupProperties model =
            new ManagementGroupProperties()
                .withTenantId("ilzyd")
                .withDisplayName("o")
                .withDetails(
                    new ManagementGroupDetails()
                        .withVersion(2010120941)
                        .withUpdatedTime(OffsetDateTime.parse("2021-04-29T07:45:55Z"))
                        .withUpdatedBy("inpm")
                        .withParent(
                            new ParentGroupInfo().withId("aqwi").withName("sprozvcput").withDisplayName("jvwmfda"))
                        .withPath(
                            Arrays
                                .asList(
                                    new ManagementGroupPathElement()
                                        .withName("dvpjhulsuuvmk")
                                        .withDisplayName("zkrwfn")))
                        .withManagementGroupAncestors(Arrays.asList("djpslw", "jdpvwryo", "psoacctazakljl"))
                        .withManagementGroupAncestorsChain(
                            Arrays
                                .asList(
                                    new ManagementGroupPathElement()
                                        .withName("ryffdfdosy")
                                        .withDisplayName("xpaojakhmsbz"),
                                    new ManagementGroupPathElement()
                                        .withName("crzevdphlx")
                                        .withDisplayName("lthqtrgqjbp"),
                                    new ManagementGroupPathElement()
                                        .withName("fsinzgvfcjrwzoxx")
                                        .withDisplayName("felluwfzitonpe"))))
                .withChildren(
                    Arrays
                        .asList(
                            new ManagementGroupChildInfo()
                                .withType(ManagementGroupChildType.SUBSCRIPTIONS)
                                .withId("lxofpdvhpfxxypin")
                                .withName("mayhuybbkpodepoo")
                                .withDisplayName("nuvamiheogna")
                                .withChildren(Arrays.asList()),
                            new ManagementGroupChildInfo()
                                .withType(ManagementGroupChildType.SUBSCRIPTIONS)
                                .withId("eotusivyevc")
                                .withName("qi")
                                .withDisplayName("hungbwjzrnf")
                                .withChildren(Arrays.asList()),
                            new ManagementGroupChildInfo()
                                .withType(ManagementGroupChildType.MICROSOFT_MANAGEMENT_MANAGEMENT_GROUPS)
                                .withId("pemvtzfkufubljof")
                                .withName("eofjaeqjh")
                                .withDisplayName("b")
                                .withChildren(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(ManagementGroupProperties.class);
        Assertions.assertEquals("ilzyd", model.tenantId());
        Assertions.assertEquals("o", model.displayName());
        Assertions.assertEquals(2010120941, model.details().version());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-29T07:45:55Z"), model.details().updatedTime());
        Assertions.assertEquals("inpm", model.details().updatedBy());
        Assertions.assertEquals("aqwi", model.details().parent().id());
        Assertions.assertEquals("sprozvcput", model.details().parent().name());
        Assertions.assertEquals("jvwmfda", model.details().parent().displayName());
        Assertions.assertEquals("dvpjhulsuuvmk", model.details().path().get(0).name());
        Assertions.assertEquals("zkrwfn", model.details().path().get(0).displayName());
        Assertions.assertEquals("djpslw", model.details().managementGroupAncestors().get(0));
        Assertions.assertEquals("ryffdfdosy", model.details().managementGroupAncestorsChain().get(0).name());
        Assertions.assertEquals("xpaojakhmsbz", model.details().managementGroupAncestorsChain().get(0).displayName());
        Assertions.assertEquals(ManagementGroupChildType.SUBSCRIPTIONS, model.children().get(0).type());
        Assertions.assertEquals("lxofpdvhpfxxypin", model.children().get(0).id());
        Assertions.assertEquals("mayhuybbkpodepoo", model.children().get(0).name());
        Assertions.assertEquals("nuvamiheogna", model.children().get(0).displayName());
    }
}
