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

package com.azure.resourcemanager.iothub.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.iothub.fluent.models.UserSubscriptionQuotaListResultInner;
import com.azure.resourcemanager.iothub.models.Name;
import com.azure.resourcemanager.iothub.models.UserSubscriptionQuota;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class UserSubscriptionQuotaListResultInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        UserSubscriptionQuotaListResultInner model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"id\":\"n\",\"type\":\"xisxyawjoyaqcsl\",\"unit\":\"pkii\",\"currentValue\":983085062,\"limit\":1211885049,\"name\":{\"value\":\"eli\",\"localizedValue\":\"nr\"}}],\"nextLink\":\"folhbnxknal\"}")
                .toObject(UserSubscriptionQuotaListResultInner.class);
        Assertions.assertEquals("n", model.value().get(0).id());
        Assertions.assertEquals("xisxyawjoyaqcsl", model.value().get(0).type());
        Assertions.assertEquals("pkii", model.value().get(0).unit());
        Assertions.assertEquals(983085062, model.value().get(0).currentValue());
        Assertions.assertEquals(1211885049, model.value().get(0).limit());
        Assertions.assertEquals("eli", model.value().get(0).name().value());
        Assertions.assertEquals("nr", model.value().get(0).name().localizedValue());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        UserSubscriptionQuotaListResultInner model =
            new UserSubscriptionQuotaListResultInner()
                .withValue(
                    Arrays
                        .asList(
                            new UserSubscriptionQuota()
                                .withId("n")
                                .withType("xisxyawjoyaqcsl")
                                .withUnit("pkii")
                                .withCurrentValue(983085062)
                                .withLimit(1211885049)
                                .withName(new Name().withValue("eli").withLocalizedValue("nr"))));
        model = BinaryData.fromObject(model).toObject(UserSubscriptionQuotaListResultInner.class);
        Assertions.assertEquals("n", model.value().get(0).id());
        Assertions.assertEquals("xisxyawjoyaqcsl", model.value().get(0).type());
        Assertions.assertEquals("pkii", model.value().get(0).unit());
        Assertions.assertEquals(983085062, model.value().get(0).currentValue());
        Assertions.assertEquals(1211885049, model.value().get(0).limit());
        Assertions.assertEquals("eli", model.value().get(0).name().value());
        Assertions.assertEquals("nr", model.value().get(0).name().localizedValue());
    }
}
