// 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.fluent.models.PlanDataResourceInner;
import com.azure.resourcemanager.newrelicobservability.models.AccountCreationSource;
import com.azure.resourcemanager.newrelicobservability.models.BillingCycle;
import com.azure.resourcemanager.newrelicobservability.models.OrgCreationSource;
import com.azure.resourcemanager.newrelicobservability.models.PlanData;
import com.azure.resourcemanager.newrelicobservability.models.UsageType;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class PlanDataResourceInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        PlanDataResourceInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"planData\":{\"usageType\":\"PAYG\",\"billingCycle\":\"YEARLY\",\"planDetails\":\"hvpmoue\",\"effectiveDate\":\"2021-06-30T20:07:19Z\"},\"orgCreationSource\":\"NEWRELIC\",\"accountCreationSource\":\"LIFTR\"},\"id\":\"eojnxqbzvddn\",\"name\":\"wndeicbtwnp\",\"type\":\"aoqvuh\"}")
                .toObject(PlanDataResourceInner.class);
        Assertions.assertEquals(UsageType.PAYG, model.planData().usageType());
        Assertions.assertEquals(BillingCycle.YEARLY, model.planData().billingCycle());
        Assertions.assertEquals("hvpmoue", model.planData().planDetails());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-30T20:07:19Z"), model.planData().effectiveDate());
        Assertions.assertEquals(OrgCreationSource.NEWRELIC, model.orgCreationSource());
        Assertions.assertEquals(AccountCreationSource.LIFTR, model.accountCreationSource());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        PlanDataResourceInner model =
            new PlanDataResourceInner()
                .withPlanData(
                    new PlanData()
                        .withUsageType(UsageType.PAYG)
                        .withBillingCycle(BillingCycle.YEARLY)
                        .withPlanDetails("hvpmoue")
                        .withEffectiveDate(OffsetDateTime.parse("2021-06-30T20:07:19Z")))
                .withOrgCreationSource(OrgCreationSource.NEWRELIC)
                .withAccountCreationSource(AccountCreationSource.LIFTR);
        model = BinaryData.fromObject(model).toObject(PlanDataResourceInner.class);
        Assertions.assertEquals(UsageType.PAYG, model.planData().usageType());
        Assertions.assertEquals(BillingCycle.YEARLY, model.planData().billingCycle());
        Assertions.assertEquals("hvpmoue", model.planData().planDetails());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-30T20:07:19Z"), model.planData().effectiveDate());
        Assertions.assertEquals(OrgCreationSource.NEWRELIC, model.orgCreationSource());
        Assertions.assertEquals(AccountCreationSource.LIFTR, model.accountCreationSource());
    }
}
