// 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.UsageAggregationInner;
import com.azure.resourcemanager.commerce.models.UsageAggregationListResult;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.UUID;
import org.junit.jupiter.api.Assertions;

public final class UsageAggregationListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        UsageAggregationListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"id\":\"quvgjxpybczme\",\"name\":\"tzopbsphrupidgsy\",\"type\":\"ejhphoyc\",\"properties\":{\"subscriptionId\":\"99348804-291c-4340-9004-5c0e38008bae\",\"meterId\":\"obhdxbmtqioqjze\",\"usageStartTime\":\"2021-01-14T01:11:27Z\",\"usageEndTime\":\"2021-03-02T03:48:42Z\",\"quantity\":6.097913,\"unit\":\"wnoi\",\"meterName\":\"wlrxyb\",\"meterCategory\":\"oqijgkdmbpaz\",\"meterSubCategory\":\"bc\",\"meterRegion\":\"pdznrbtcqqjnqgl\",\"instanceData\":\"nufo\"}},{\"id\":\"jywif\",\"name\":\"esaagdfm\",\"type\":\"zlhjxrifkwmrvkt\",\"properties\":{\"subscriptionId\":\"1c9a61f5-07a2-48b5-a039-b38ffa691c18\",\"meterId\":\"to\",\"usageStartTime\":\"2021-11-17T06:57:14Z\",\"usageEndTime\":\"2021-01-23T08:07:58Z\",\"quantity\":42.458458,\"unit\":\"psqucmpoyf\",\"meterName\":\"fogknygjofjdde\",\"meterCategory\":\"rd\",\"meterSubCategory\":\"pewnw\",\"meterRegion\":\"itjz\",\"instanceData\":\"usarhmofc\"}},{\"id\":\"smy\",\"name\":\"kdtmlxhekuk\",\"type\":\"txukcdmp\",\"properties\":{\"subscriptionId\":\"cf09efcc-695d-425b-b772-a9f354d422c6\",\"meterId\":\"y\",\"usageStartTime\":\"2021-11-03T04:50:08Z\",\"usageEndTime\":\"2021-03-23T07:07:23Z\",\"quantity\":80.46482,\"unit\":\"dxtayrlhm\",\"meterName\":\"fp\",\"meterCategory\":\"qobmtukk\",\"meterSubCategory\":\"yrtih\",\"meterRegion\":\"tijbpzvgnwzsymgl\",\"instanceData\":\"cyzkohdbihanuf\"}}],\"nextLink\":\"cbjy\"}")
                .toObject(UsageAggregationListResult.class);
        Assertions.assertEquals("quvgjxpybczme", model.value().get(0).id());
        Assertions.assertEquals("tzopbsphrupidgsy", model.value().get(0).name());
        Assertions.assertEquals("ejhphoyc", model.value().get(0).type());
        Assertions
            .assertEquals(
                UUID.fromString("99348804-291c-4340-9004-5c0e38008bae"), model.value().get(0).subscriptionId());
        Assertions.assertEquals("obhdxbmtqioqjze", model.value().get(0).meterId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-14T01:11:27Z"), model.value().get(0).usageStartTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-03-02T03:48:42Z"), model.value().get(0).usageEndTime());
        Assertions.assertEquals(6.097913F, model.value().get(0).quantity());
        Assertions.assertEquals("wnoi", model.value().get(0).unit());
        Assertions.assertEquals("wlrxyb", model.value().get(0).meterName());
        Assertions.assertEquals("oqijgkdmbpaz", model.value().get(0).meterCategory());
        Assertions.assertEquals("bc", model.value().get(0).meterSubCategory());
        Assertions.assertEquals("pdznrbtcqqjnqgl", model.value().get(0).meterRegion());
        Assertions.assertEquals("nufo", model.value().get(0).instanceData());
        Assertions.assertEquals("cbjy", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        UsageAggregationListResult model =
            new UsageAggregationListResult()
                .withValue(
                    Arrays
                        .asList(
                            new UsageAggregationInner()
                                .withId("quvgjxpybczme")
                                .withName("tzopbsphrupidgsy")
                                .withType("ejhphoyc")
                                .withSubscriptionId(UUID.fromString("99348804-291c-4340-9004-5c0e38008bae"))
                                .withMeterId("obhdxbmtqioqjze")
                                .withUsageStartTime(OffsetDateTime.parse("2021-01-14T01:11:27Z"))
                                .withUsageEndTime(OffsetDateTime.parse("2021-03-02T03:48:42Z"))
                                .withQuantity(6.097913F)
                                .withUnit("wnoi")
                                .withMeterName("wlrxyb")
                                .withMeterCategory("oqijgkdmbpaz")
                                .withMeterSubCategory("bc")
                                .withMeterRegion("pdznrbtcqqjnqgl")
                                .withInstanceData("nufo"),
                            new UsageAggregationInner()
                                .withId("jywif")
                                .withName("esaagdfm")
                                .withType("zlhjxrifkwmrvkt")
                                .withSubscriptionId(UUID.fromString("1c9a61f5-07a2-48b5-a039-b38ffa691c18"))
                                .withMeterId("to")
                                .withUsageStartTime(OffsetDateTime.parse("2021-11-17T06:57:14Z"))
                                .withUsageEndTime(OffsetDateTime.parse("2021-01-23T08:07:58Z"))
                                .withQuantity(42.458458F)
                                .withUnit("psqucmpoyf")
                                .withMeterName("fogknygjofjdde")
                                .withMeterCategory("rd")
                                .withMeterSubCategory("pewnw")
                                .withMeterRegion("itjz")
                                .withInstanceData("usarhmofc"),
                            new UsageAggregationInner()
                                .withId("smy")
                                .withName("kdtmlxhekuk")
                                .withType("txukcdmp")
                                .withSubscriptionId(UUID.fromString("cf09efcc-695d-425b-b772-a9f354d422c6"))
                                .withMeterId("y")
                                .withUsageStartTime(OffsetDateTime.parse("2021-11-03T04:50:08Z"))
                                .withUsageEndTime(OffsetDateTime.parse("2021-03-23T07:07:23Z"))
                                .withQuantity(80.46482F)
                                .withUnit("dxtayrlhm")
                                .withMeterName("fp")
                                .withMeterCategory("qobmtukk")
                                .withMeterSubCategory("yrtih")
                                .withMeterRegion("tijbpzvgnwzsymgl")
                                .withInstanceData("cyzkohdbihanuf")))
                .withNextLink("cbjy");
        model = BinaryData.fromObject(model).toObject(UsageAggregationListResult.class);
        Assertions.assertEquals("quvgjxpybczme", model.value().get(0).id());
        Assertions.assertEquals("tzopbsphrupidgsy", model.value().get(0).name());
        Assertions.assertEquals("ejhphoyc", model.value().get(0).type());
        Assertions
            .assertEquals(
                UUID.fromString("99348804-291c-4340-9004-5c0e38008bae"), model.value().get(0).subscriptionId());
        Assertions.assertEquals("obhdxbmtqioqjze", model.value().get(0).meterId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-14T01:11:27Z"), model.value().get(0).usageStartTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-03-02T03:48:42Z"), model.value().get(0).usageEndTime());
        Assertions.assertEquals(6.097913F, model.value().get(0).quantity());
        Assertions.assertEquals("wnoi", model.value().get(0).unit());
        Assertions.assertEquals("wlrxyb", model.value().get(0).meterName());
        Assertions.assertEquals("oqijgkdmbpaz", model.value().get(0).meterCategory());
        Assertions.assertEquals("bc", model.value().get(0).meterSubCategory());
        Assertions.assertEquals("pdznrbtcqqjnqgl", model.value().get(0).meterRegion());
        Assertions.assertEquals("nufo", model.value().get(0).instanceData());
        Assertions.assertEquals("cbjy", model.nextLink());
    }
}
