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

package com.azure.resourcemanager.cognitiveservices.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.cognitiveservices.models.CommitmentPeriod;
import com.azure.resourcemanager.cognitiveservices.models.CommitmentPlanProperties;
import com.azure.resourcemanager.cognitiveservices.models.HostingModel;
import org.junit.jupiter.api.Assertions;

public final class CommitmentPlanPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        CommitmentPlanProperties model =
            BinaryData
                .fromString(
                    "{\"provisioningState\":\"Accepted\",\"commitmentPlanGuid\":\"jvcdwxlpqekf\",\"hostingModel\":\"Web\",\"planType\":\"tjsyin\",\"current\":{\"tier\":\"qatmtdhtmdvy\",\"count\":932898449,\"quota\":{\"quantity\":6469861763062162700,\"unit\":\"ywkbirryuzhlhkjo\"},\"startDate\":\"vqqaatjinrvgo\",\"endDate\":\"mfiibfggj\"},\"autoRenew\":false,\"next\":{\"tier\":\"rwxkvtkkgl\",\"count\":1852467405,\"quota\":{\"quantity\":1820890215128443908,\"unit\":\"ayvblmhvkzuhbx\"},\"startDate\":\"yhgsopbyrqufe\",\"endDate\":\"uvwzfbnh\"},\"last\":{\"tier\":\"tlpdn\",\"count\":1116199441,\"quota\":{\"quantity\":6928961478611605886,\"unit\":\"rixkwmyijejve\"},\"startDate\":\"hbpnaixexccbd\",\"endDate\":\"ax\"},\"provisioningIssues\":[\"xdrrvqahqkghtp\",\"ijnhyjsvfycxzbf\",\"oowvrv\"]}")
                .toObject(CommitmentPlanProperties.class);
        Assertions.assertEquals("jvcdwxlpqekf", model.commitmentPlanGuid());
        Assertions.assertEquals(HostingModel.WEB, model.hostingModel());
        Assertions.assertEquals("tjsyin", model.planType());
        Assertions.assertEquals("qatmtdhtmdvy", model.current().tier());
        Assertions.assertEquals(932898449, model.current().count());
        Assertions.assertEquals(false, model.autoRenew());
        Assertions.assertEquals("rwxkvtkkgl", model.next().tier());
        Assertions.assertEquals(1852467405, model.next().count());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        CommitmentPlanProperties model =
            new CommitmentPlanProperties()
                .withCommitmentPlanGuid("jvcdwxlpqekf")
                .withHostingModel(HostingModel.WEB)
                .withPlanType("tjsyin")
                .withCurrent(new CommitmentPeriod().withTier("qatmtdhtmdvy").withCount(932898449))
                .withAutoRenew(false)
                .withNext(new CommitmentPeriod().withTier("rwxkvtkkgl").withCount(1852467405));
        model = BinaryData.fromObject(model).toObject(CommitmentPlanProperties.class);
        Assertions.assertEquals("jvcdwxlpqekf", model.commitmentPlanGuid());
        Assertions.assertEquals(HostingModel.WEB, model.hostingModel());
        Assertions.assertEquals("tjsyin", model.planType());
        Assertions.assertEquals("qatmtdhtmdvy", model.current().tier());
        Assertions.assertEquals(932898449, model.current().count());
        Assertions.assertEquals(false, model.autoRenew());
        Assertions.assertEquals("rwxkvtkkgl", model.next().tier());
        Assertions.assertEquals(1852467405, model.next().count());
    }
}
