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

package com.azure.resourcemanager.machinelearning.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.machinelearning.fluent.models.BatchEndpointInner;
import com.azure.resourcemanager.machinelearning.models.BatchEndpointProperties;
import com.azure.resourcemanager.machinelearning.models.BatchEndpointTrackedResourceArmPaginatedResult;
import com.azure.resourcemanager.machinelearning.models.EndpointAuthMode;
import com.azure.resourcemanager.machinelearning.models.ManagedServiceIdentity;
import com.azure.resourcemanager.machinelearning.models.ManagedServiceIdentityType;
import com.azure.resourcemanager.machinelearning.models.Sku;
import com.azure.resourcemanager.machinelearning.models.SkuTier;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class BatchEndpointTrackedResourceArmPaginatedResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        BatchEndpointTrackedResourceArmPaginatedResult model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"gcj\",\"value\":[{\"identity\":{\"principalId\":\"f81557b3-3455-43a9-863a-877ebc9a8614\",\"tenantId\":\"ca2f438e-dabf-4a7a-808b-9b35946ac806\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{}},\"kind\":\"ttdumorppxebmnzb\",\"properties\":{\"provisioningState\":\"Canceled\",\"authMode\":\"Key\",\"description\":\"lkfg\",\"properties\":{},\"scoringUri\":\"euel\",\"swaggerUri\":\"hsd\"},\"sku\":{\"name\":\"t\",\"tier\":\"Standard\",\"size\":\"kd\",\"family\":\"wq\",\"capacity\":180318621},\"location\":\"zx\",\"tags\":{\"sg\":\"ithhqzon\",\"c\":\"b\"},\"id\":\"hfwdsjnkaljutiis\",\"name\":\"acffgdkzzewkfvhq\",\"type\":\"railvpnppfuf\"}]}")
                .toObject(BatchEndpointTrackedResourceArmPaginatedResult.class);
        Assertions.assertEquals("gcj", model.nextLink());
        Assertions.assertEquals("zx", model.value().get(0).location());
        Assertions.assertEquals("ithhqzon", model.value().get(0).tags().get("sg"));
        Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("ttdumorppxebmnzb", model.value().get(0).kind());
        Assertions.assertEquals(EndpointAuthMode.KEY, model.value().get(0).properties().authMode());
        Assertions.assertEquals("lkfg", model.value().get(0).properties().description());
        Assertions.assertEquals("t", model.value().get(0).sku().name());
        Assertions.assertEquals(SkuTier.STANDARD, model.value().get(0).sku().tier());
        Assertions.assertEquals("kd", model.value().get(0).sku().size());
        Assertions.assertEquals("wq", model.value().get(0).sku().family());
        Assertions.assertEquals(180318621, model.value().get(0).sku().capacity());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        BatchEndpointTrackedResourceArmPaginatedResult model =
            new BatchEndpointTrackedResourceArmPaginatedResult()
                .withNextLink("gcj")
                .withValue(
                    Arrays
                        .asList(
                            new BatchEndpointInner()
                                .withLocation("zx")
                                .withTags(mapOf("sg", "ithhqzon", "c", "b"))
                                .withIdentity(
                                    new ManagedServiceIdentity()
                                        .withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED)
                                        .withUserAssignedIdentities(mapOf()))
                                .withKind("ttdumorppxebmnzb")
                                .withProperties(
                                    new BatchEndpointProperties()
                                        .withAuthMode(EndpointAuthMode.KEY)
                                        .withDescription("lkfg")
                                        .withProperties(mapOf()))
                                .withSku(
                                    new Sku()
                                        .withName("t")
                                        .withTier(SkuTier.STANDARD)
                                        .withSize("kd")
                                        .withFamily("wq")
                                        .withCapacity(180318621))));
        model = BinaryData.fromObject(model).toObject(BatchEndpointTrackedResourceArmPaginatedResult.class);
        Assertions.assertEquals("gcj", model.nextLink());
        Assertions.assertEquals("zx", model.value().get(0).location());
        Assertions.assertEquals("ithhqzon", model.value().get(0).tags().get("sg"));
        Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED, model.value().get(0).identity().type());
        Assertions.assertEquals("ttdumorppxebmnzb", model.value().get(0).kind());
        Assertions.assertEquals(EndpointAuthMode.KEY, model.value().get(0).properties().authMode());
        Assertions.assertEquals("lkfg", model.value().get(0).properties().description());
        Assertions.assertEquals("t", model.value().get(0).sku().name());
        Assertions.assertEquals(SkuTier.STANDARD, model.value().get(0).sku().tier());
        Assertions.assertEquals("kd", model.value().get(0).sku().size());
        Assertions.assertEquals("wq", model.value().get(0).sku().family());
        Assertions.assertEquals(180318621, model.value().get(0).sku().capacity());
    }

    @SuppressWarnings("unchecked")
    private static <T> Map<String, T> mapOf(Object... inputs) {
        Map<String, T> map = new HashMap<>();
        for (int i = 0; i < inputs.length; i += 2) {
            String key = (String) inputs[i];
            T value = (T) inputs[i + 1];
            map.put(key, value);
        }
        return map;
    }
}
