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

package com.azure.resourcemanager.reservations.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.reservations.models.AppliedScopeProperties;
import com.azure.resourcemanager.reservations.models.AppliedScopeType;
import com.azure.resourcemanager.reservations.models.InstanceFlexibility;
import com.azure.resourcemanager.reservations.models.PatchModel;
import com.azure.resourcemanager.reservations.models.PatchPropertiesRenewProperties;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class PatchModelTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        PatchModel model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"appliedScopeType\":\"ManagementGroup\",\"appliedScopes\":[\"bxzpuzycisp\",\"qzahmgkbrp\",\"y\"],\"appliedScopeProperties\":{\"tenantId\":\"bnuqqkpik\",\"managementGroupId\":\"rgvtqag\",\"subscriptionId\":\"uynhijg\",\"resourceGroupId\":\"ebf\",\"displayName\":\"arbu\"},\"instanceFlexibility\":\"Off\",\"name\":\"pnazzm\",\"renew\":false,\"renewProperties\":{},\"reviewDateTime\":\"2021-05-19T03:18:32Z\"}}")
                .toObject(PatchModel.class);
        Assertions.assertEquals(AppliedScopeType.MANAGEMENT_GROUP, model.appliedScopeType());
        Assertions.assertEquals("bxzpuzycisp", model.appliedScopes().get(0));
        Assertions.assertEquals("bnuqqkpik", model.appliedScopeProperties().tenantId());
        Assertions.assertEquals("rgvtqag", model.appliedScopeProperties().managementGroupId());
        Assertions.assertEquals("uynhijg", model.appliedScopeProperties().subscriptionId());
        Assertions.assertEquals("ebf", model.appliedScopeProperties().resourceGroupId());
        Assertions.assertEquals("arbu", model.appliedScopeProperties().displayName());
        Assertions.assertEquals(InstanceFlexibility.OFF, model.instanceFlexibility());
        Assertions.assertEquals("pnazzm", model.name());
        Assertions.assertEquals(false, model.renew());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-19T03:18:32Z"), model.reviewDateTime());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        PatchModel model =
            new PatchModel()
                .withAppliedScopeType(AppliedScopeType.MANAGEMENT_GROUP)
                .withAppliedScopes(Arrays.asList("bxzpuzycisp", "qzahmgkbrp", "y"))
                .withAppliedScopeProperties(
                    new AppliedScopeProperties()
                        .withTenantId("bnuqqkpik")
                        .withManagementGroupId("rgvtqag")
                        .withSubscriptionId("uynhijg")
                        .withResourceGroupId("ebf")
                        .withDisplayName("arbu"))
                .withInstanceFlexibility(InstanceFlexibility.OFF)
                .withName("pnazzm")
                .withRenew(false)
                .withRenewProperties(new PatchPropertiesRenewProperties())
                .withReviewDateTime(OffsetDateTime.parse("2021-05-19T03:18:32Z"));
        model = BinaryData.fromObject(model).toObject(PatchModel.class);
        Assertions.assertEquals(AppliedScopeType.MANAGEMENT_GROUP, model.appliedScopeType());
        Assertions.assertEquals("bxzpuzycisp", model.appliedScopes().get(0));
        Assertions.assertEquals("bnuqqkpik", model.appliedScopeProperties().tenantId());
        Assertions.assertEquals("rgvtqag", model.appliedScopeProperties().managementGroupId());
        Assertions.assertEquals("uynhijg", model.appliedScopeProperties().subscriptionId());
        Assertions.assertEquals("ebf", model.appliedScopeProperties().resourceGroupId());
        Assertions.assertEquals("arbu", model.appliedScopeProperties().displayName());
        Assertions.assertEquals(InstanceFlexibility.OFF, model.instanceFlexibility());
        Assertions.assertEquals("pnazzm", model.name());
        Assertions.assertEquals(false, model.renew());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-19T03:18:32Z"), model.reviewDateTime());
    }
}
