// 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.PlanDataProperties;
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 PlanDataPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        PlanDataProperties model =
            BinaryData
                .fromString(
                    "{\"planData\":{\"usageType\":\"PAYG\",\"billingCycle\":\"MONTHLY\",\"planDetails\":\"ddglm\",\"effectiveDate\":\"2020-12-21T16:15:31Z\"},\"orgCreationSource\":\"NEWRELIC\",\"accountCreationSource\":\"NEWRELIC\"}")
                .toObject(PlanDataProperties.class);
        Assertions.assertEquals(UsageType.PAYG, model.planData().usageType());
        Assertions.assertEquals(BillingCycle.MONTHLY, model.planData().billingCycle());
        Assertions.assertEquals("ddglm", model.planData().planDetails());
        Assertions.assertEquals(OffsetDateTime.parse("2020-12-21T16:15:31Z"), model.planData().effectiveDate());
        Assertions.assertEquals(OrgCreationSource.NEWRELIC, model.orgCreationSource());
        Assertions.assertEquals(AccountCreationSource.NEWRELIC, model.accountCreationSource());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        PlanDataProperties model =
            new PlanDataProperties()
                .withPlanData(
                    new PlanData()
                        .withUsageType(UsageType.PAYG)
                        .withBillingCycle(BillingCycle.MONTHLY)
                        .withPlanDetails("ddglm")
                        .withEffectiveDate(OffsetDateTime.parse("2020-12-21T16:15:31Z")))
                .withOrgCreationSource(OrgCreationSource.NEWRELIC)
                .withAccountCreationSource(AccountCreationSource.NEWRELIC);
        model = BinaryData.fromObject(model).toObject(PlanDataProperties.class);
        Assertions.assertEquals(UsageType.PAYG, model.planData().usageType());
        Assertions.assertEquals(BillingCycle.MONTHLY, model.planData().billingCycle());
        Assertions.assertEquals("ddglm", model.planData().planDetails());
        Assertions.assertEquals(OffsetDateTime.parse("2020-12-21T16:15:31Z"), model.planData().effectiveDate());
        Assertions.assertEquals(OrgCreationSource.NEWRELIC, model.orgCreationSource());
        Assertions.assertEquals(AccountCreationSource.NEWRELIC, model.accountCreationSource());
    }
}
