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

package com.azure.resourcemanager.commerce.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.commerce.fluent.models.UsageSample;
import com.azure.resourcemanager.commerce.models.InfoField;
import java.time.OffsetDateTime;
import java.util.UUID;
import org.junit.jupiter.api.Assertions;

public final class UsageSampleTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        UsageSample model =
            BinaryData
                .fromString(
                    "{\"subscriptionId\":\"31f9d37f-ba99-4b53-b5f1-186a76a93523\",\"meterId\":\"zyde\",\"usageStartTime\":\"2021-05-18T09:45:02Z\",\"usageEndTime\":\"2021-05-10T11:45:10Z\",\"quantity\":57.05146,\"unit\":\"xinpmqnjaq\",\"meterName\":\"xj\",\"meterCategory\":\"r\",\"meterSubCategory\":\"vcputegj\",\"meterRegion\":\"mfdatscmdvpj\",\"infoFields\":{\"project\":\"suuv\"},\"instanceData\":\"jozkrwfndiod\"}")
                .toObject(UsageSample.class);
        Assertions.assertEquals(UUID.fromString("31f9d37f-ba99-4b53-b5f1-186a76a93523"), model.subscriptionId());
        Assertions.assertEquals("zyde", model.meterId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-18T09:45:02Z"), model.usageStartTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-10T11:45:10Z"), model.usageEndTime());
        Assertions.assertEquals(57.05146F, model.quantity());
        Assertions.assertEquals("xinpmqnjaq", model.unit());
        Assertions.assertEquals("xj", model.meterName());
        Assertions.assertEquals("r", model.meterCategory());
        Assertions.assertEquals("vcputegj", model.meterSubCategory());
        Assertions.assertEquals("mfdatscmdvpj", model.meterRegion());
        Assertions.assertEquals("suuv", model.infoFields().project());
        Assertions.assertEquals("jozkrwfndiod", model.instanceData());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        UsageSample model =
            new UsageSample()
                .withSubscriptionId(UUID.fromString("31f9d37f-ba99-4b53-b5f1-186a76a93523"))
                .withMeterId("zyde")
                .withUsageStartTime(OffsetDateTime.parse("2021-05-18T09:45:02Z"))
                .withUsageEndTime(OffsetDateTime.parse("2021-05-10T11:45:10Z"))
                .withQuantity(57.05146F)
                .withUnit("xinpmqnjaq")
                .withMeterName("xj")
                .withMeterCategory("r")
                .withMeterSubCategory("vcputegj")
                .withMeterRegion("mfdatscmdvpj")
                .withInfoFields(new InfoField().withProject("suuv"))
                .withInstanceData("jozkrwfndiod");
        model = BinaryData.fromObject(model).toObject(UsageSample.class);
        Assertions.assertEquals(UUID.fromString("31f9d37f-ba99-4b53-b5f1-186a76a93523"), model.subscriptionId());
        Assertions.assertEquals("zyde", model.meterId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-18T09:45:02Z"), model.usageStartTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-10T11:45:10Z"), model.usageEndTime());
        Assertions.assertEquals(57.05146F, model.quantity());
        Assertions.assertEquals("xinpmqnjaq", model.unit());
        Assertions.assertEquals("xj", model.meterName());
        Assertions.assertEquals("r", model.meterCategory());
        Assertions.assertEquals("vcputegj", model.meterSubCategory());
        Assertions.assertEquals("mfdatscmdvpj", model.meterRegion());
        Assertions.assertEquals("suuv", model.infoFields().project());
        Assertions.assertEquals("jozkrwfndiod", model.instanceData());
    }
}
