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

package com.azure.resourcemanager.recoveryservices.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.recoveryservices.fluent.models.VaultUsageInner;
import com.azure.resourcemanager.recoveryservices.models.NameInfo;
import com.azure.resourcemanager.recoveryservices.models.UsagesUnit;
import com.azure.resourcemanager.recoveryservices.models.VaultUsageList;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class VaultUsageListTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        VaultUsageList model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"unit\":\"BytesPerSecond\",\"quotaPeriod\":\"plwzbhvgyugu\",\"nextResetTime\":\"2021-08-08T10:54:54Z\",\"currentValue\":1314770680233615773,\"limit\":4208322413418754380,\"name\":{\"value\":\"kkfpl\",\"localizedValue\":\"gsxnkjzkdeslpv\"}},{\"unit\":\"Seconds\",\"quotaPeriod\":\"i\",\"nextResetTime\":\"2021-09-12T13:52:28Z\",\"currentValue\":3778996207980672783,\"limit\":8356501836980248875,\"name\":{\"value\":\"aiuebbaumnyqu\",\"localizedValue\":\"deoj\"}},{\"unit\":\"CountPerSecond\",\"quotaPeriod\":\"khsmtxpsiebt\",\"nextResetTime\":\"2021-03-12T10:20:21Z\",\"currentValue\":3953779484897603289,\"limit\":8344746335940164882,\"name\":{\"value\":\"dqmh\",\"localizedValue\":\"dhtldwkyz\"}},{\"unit\":\"CountPerSecond\",\"quotaPeriod\":\"kn\",\"nextResetTime\":\"2021-10-01T12:00:34Z\",\"currentValue\":8510740878740325389,\"limit\":3553868760097746067,\"name\":{\"value\":\"ogtwrupqsxvnmi\",\"localizedValue\":\"kvceoveilovnotyf\"}}]}")
                .toObject(VaultUsageList.class);
        Assertions.assertEquals(UsagesUnit.BYTES_PER_SECOND, model.value().get(0).unit());
        Assertions.assertEquals("plwzbhvgyugu", model.value().get(0).quotaPeriod());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-08T10:54:54Z"), model.value().get(0).nextResetTime());
        Assertions.assertEquals(1314770680233615773L, model.value().get(0).currentValue());
        Assertions.assertEquals(4208322413418754380L, model.value().get(0).limit());
        Assertions.assertEquals("kkfpl", model.value().get(0).name().value());
        Assertions.assertEquals("gsxnkjzkdeslpv", model.value().get(0).name().localizedValue());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        VaultUsageList model =
            new VaultUsageList()
                .withValue(
                    Arrays
                        .asList(
                            new VaultUsageInner()
                                .withUnit(UsagesUnit.BYTES_PER_SECOND)
                                .withQuotaPeriod("plwzbhvgyugu")
                                .withNextResetTime(OffsetDateTime.parse("2021-08-08T10:54:54Z"))
                                .withCurrentValue(1314770680233615773L)
                                .withLimit(4208322413418754380L)
                                .withName(new NameInfo().withValue("kkfpl").withLocalizedValue("gsxnkjzkdeslpv")),
                            new VaultUsageInner()
                                .withUnit(UsagesUnit.SECONDS)
                                .withQuotaPeriod("i")
                                .withNextResetTime(OffsetDateTime.parse("2021-09-12T13:52:28Z"))
                                .withCurrentValue(3778996207980672783L)
                                .withLimit(8356501836980248875L)
                                .withName(new NameInfo().withValue("aiuebbaumnyqu").withLocalizedValue("deoj")),
                            new VaultUsageInner()
                                .withUnit(UsagesUnit.COUNT_PER_SECOND)
                                .withQuotaPeriod("khsmtxpsiebt")
                                .withNextResetTime(OffsetDateTime.parse("2021-03-12T10:20:21Z"))
                                .withCurrentValue(3953779484897603289L)
                                .withLimit(8344746335940164882L)
                                .withName(new NameInfo().withValue("dqmh").withLocalizedValue("dhtldwkyz")),
                            new VaultUsageInner()
                                .withUnit(UsagesUnit.COUNT_PER_SECOND)
                                .withQuotaPeriod("kn")
                                .withNextResetTime(OffsetDateTime.parse("2021-10-01T12:00:34Z"))
                                .withCurrentValue(8510740878740325389L)
                                .withLimit(3553868760097746067L)
                                .withName(
                                    new NameInfo()
                                        .withValue("ogtwrupqsxvnmi")
                                        .withLocalizedValue("kvceoveilovnotyf"))));
        model = BinaryData.fromObject(model).toObject(VaultUsageList.class);
        Assertions.assertEquals(UsagesUnit.BYTES_PER_SECOND, model.value().get(0).unit());
        Assertions.assertEquals("plwzbhvgyugu", model.value().get(0).quotaPeriod());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-08T10:54:54Z"), model.value().get(0).nextResetTime());
        Assertions.assertEquals(1314770680233615773L, model.value().get(0).currentValue());
        Assertions.assertEquals(4208322413418754380L, model.value().get(0).limit());
        Assertions.assertEquals("kkfpl", model.value().get(0).name().value());
        Assertions.assertEquals("gsxnkjzkdeslpv", model.value().get(0).name().localizedValue());
    }
}
