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

package com.azure.resourcemanager.cognitiveservices.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.cognitiveservices.models.MetricName;
import com.azure.resourcemanager.cognitiveservices.models.QuotaUsageStatus;
import com.azure.resourcemanager.cognitiveservices.models.UnitType;
import com.azure.resourcemanager.cognitiveservices.models.Usage;
import org.junit.jupiter.api.Assertions;

public final class UsageTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        Usage model =
            BinaryData
                .fromString(
                    "{\"unit\":\"Milliseconds\",\"name\":{\"value\":\"kqsleyyvxy\",\"localizedValue\":\"pkc\"},\"quotaPeriod\":\"tpngjcrcczsqpjh\",\"limit\":15.683771184024254,\"currentValue\":5.670664395942426,\"nextResetTime\":\"sounqecanoaeu\",\"status\":\"Included\"}")
                .toObject(Usage.class);
        Assertions.assertEquals(UnitType.MILLISECONDS, model.unit());
        Assertions.assertEquals("kqsleyyvxy", model.name().value());
        Assertions.assertEquals("pkc", model.name().localizedValue());
        Assertions.assertEquals("tpngjcrcczsqpjh", model.quotaPeriod());
        Assertions.assertEquals(15.683771184024254D, model.limit());
        Assertions.assertEquals(5.670664395942426D, model.currentValue());
        Assertions.assertEquals("sounqecanoaeu", model.nextResetTime());
        Assertions.assertEquals(QuotaUsageStatus.INCLUDED, model.status());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        Usage model =
            new Usage()
                .withUnit(UnitType.MILLISECONDS)
                .withName(new MetricName().withValue("kqsleyyvxy").withLocalizedValue("pkc"))
                .withQuotaPeriod("tpngjcrcczsqpjh")
                .withLimit(15.683771184024254D)
                .withCurrentValue(5.670664395942426D)
                .withNextResetTime("sounqecanoaeu")
                .withStatus(QuotaUsageStatus.INCLUDED);
        model = BinaryData.fromObject(model).toObject(Usage.class);
        Assertions.assertEquals(UnitType.MILLISECONDS, model.unit());
        Assertions.assertEquals("kqsleyyvxy", model.name().value());
        Assertions.assertEquals("pkc", model.name().localizedValue());
        Assertions.assertEquals("tpngjcrcczsqpjh", model.quotaPeriod());
        Assertions.assertEquals(15.683771184024254D, model.limit());
        Assertions.assertEquals(5.670664395942426D, model.currentValue());
        Assertions.assertEquals("sounqecanoaeu", model.nextResetTime());
        Assertions.assertEquals(QuotaUsageStatus.INCLUDED, model.status());
    }
}
