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

package com.azure.resourcemanager.newrelicobservability.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.newrelicobservability.models.BillingCycle;
import com.azure.resourcemanager.newrelicobservability.models.PlanData;
import com.azure.resourcemanager.newrelicobservability.models.SwitchBillingRequest;
import com.azure.resourcemanager.newrelicobservability.models.UsageType;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class SwitchBillingRequestTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SwitchBillingRequest model =
            BinaryData
                .fromString(
                    "{\"azureResourceId\":\"vdcsitynn\",\"organizationId\":\"mdectehfiqscjey\",\"planData\":{\"usageType\":\"COMMITTED\",\"billingCycle\":\"MONTHLY\",\"planDetails\":\"gqhcjrefovg\",\"effectiveDate\":\"2021-10-26T09:37:04Z\"},\"userEmail\":\"sle\"}")
                .toObject(SwitchBillingRequest.class);
        Assertions.assertEquals("vdcsitynn", model.azureResourceId());
        Assertions.assertEquals("mdectehfiqscjey", model.organizationId());
        Assertions.assertEquals(UsageType.COMMITTED, model.planData().usageType());
        Assertions.assertEquals(BillingCycle.MONTHLY, model.planData().billingCycle());
        Assertions.assertEquals("gqhcjrefovg", model.planData().planDetails());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-26T09:37:04Z"), model.planData().effectiveDate());
        Assertions.assertEquals("sle", model.userEmail());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SwitchBillingRequest model =
            new SwitchBillingRequest()
                .withAzureResourceId("vdcsitynn")
                .withOrganizationId("mdectehfiqscjey")
                .withPlanData(
                    new PlanData()
                        .withUsageType(UsageType.COMMITTED)
                        .withBillingCycle(BillingCycle.MONTHLY)
                        .withPlanDetails("gqhcjrefovg")
                        .withEffectiveDate(OffsetDateTime.parse("2021-10-26T09:37:04Z")))
                .withUserEmail("sle");
        model = BinaryData.fromObject(model).toObject(SwitchBillingRequest.class);
        Assertions.assertEquals("vdcsitynn", model.azureResourceId());
        Assertions.assertEquals("mdectehfiqscjey", model.organizationId());
        Assertions.assertEquals(UsageType.COMMITTED, model.planData().usageType());
        Assertions.assertEquals(BillingCycle.MONTHLY, model.planData().billingCycle());
        Assertions.assertEquals("gqhcjrefovg", model.planData().planDetails());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-26T09:37:04Z"), model.planData().effectiveDate());
        Assertions.assertEquals("sle", model.userEmail());
    }
}
