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

package com.azure.resourcemanager.servicefabric.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.servicefabric.fluent.models.ServiceResourceInner;
import com.azure.resourcemanager.servicefabric.fluent.models.ServiceResourceListInner;
import com.azure.resourcemanager.servicefabric.models.ArmServicePackageActivationMode;
import com.azure.resourcemanager.servicefabric.models.MoveCost;
import com.azure.resourcemanager.servicefabric.models.ServiceResourceProperties;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ServiceResourceListInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ServiceResourceListInner model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"serviceKind\":\"ServiceResourceProperties\",\"provisioningState\":\"vljxywsu\",\"serviceTypeName\":\"yrs\",\"servicePackageActivationMode\":\"ExclusiveProcess\",\"serviceDnsName\":\"g\",\"placementConstraints\":\"gvraeaen\",\"correlationScheme\":[],\"serviceLoadMetrics\":[],\"servicePlacementPolicies\":[],\"defaultMoveCost\":\"High\"},\"location\":\"wlquuijfqkace\",\"tags\":{\"f\":\"pfpubjibww\",\"kn\":\"ohqkvpuvksgpls\"},\"etag\":\"fsynljphuop\",\"id\":\"dlqiyntorzih\",\"name\":\"eosjswsr\",\"type\":\"slyzrpzbchckqq\"},{\"properties\":{\"serviceKind\":\"ServiceResourceProperties\",\"provisioningState\":\"ox\",\"serviceTypeName\":\"suiizynkedyat\",\"servicePackageActivationMode\":\"ExclusiveProcess\",\"serviceDnsName\":\"mibzyhwitsmypyyn\",\"placementConstraints\":\"dpumnzgmw\",\"correlationScheme\":[],\"serviceLoadMetrics\":[],\"servicePlacementPolicies\":[],\"defaultMoveCost\":\"Medium\"},\"location\":\"nsorgjhxbldt\",\"tags\":{\"xdy\":\"rlkdmtncvokotl\",\"tdtbnnhadooc\":\"gsyocogj\"},\"etag\":\"vcikhnvpamqgx\",\"id\":\"u\",\"name\":\"zikywgg\",\"type\":\"kallatmel\"},{\"properties\":{\"serviceKind\":\"ServiceResourceProperties\",\"provisioningState\":\"piccjzkzivgv\",\"serviceTypeName\":\"nayrhyrnxxmueedn\",\"servicePackageActivationMode\":\"SharedProcess\",\"serviceDnsName\":\"tkwqqtchealm\",\"placementConstraints\":\"tdaaygdvwvg\",\"correlationScheme\":[],\"serviceLoadMetrics\":[],\"servicePlacementPolicies\":[],\"defaultMoveCost\":\"Zero\"},\"location\":\"rtfudxepxg\",\"tags\":{\"mnpkukghimdblxg\":\"gvr\",\"mszkkfo\":\"imfnjhfjx\",\"kzikfjawneaivxwc\":\"rey\"},\"etag\":\"lpcirelsf\",\"id\":\"enwabfatk\",\"name\":\"ddxbjhwuaanoz\",\"type\":\"osphyoul\"},{\"properties\":{\"serviceKind\":\"ServiceResourceProperties\",\"provisioningState\":\"v\",\"serviceTypeName\":\"glrvimjwosytxi\",\"servicePackageActivationMode\":\"SharedProcess\",\"serviceDnsName\":\"cktqumiekkezzi\",\"placementConstraints\":\"ly\",\"correlationScheme\":[],\"serviceLoadMetrics\":[],\"servicePlacementPolicies\":[],\"defaultMoveCost\":\"Zero\"},\"location\":\"gebdunygaeq\",\"tags\":{\"a\":\"qfatpxllrxcyjm\",\"arm\":\"su\",\"rw\":\"wdmjsjqbjhhyx\",\"duhpk\":\"yc\"},\"etag\":\"gymare\",\"id\":\"ajxq\",\"name\":\"gjhkycubeddg\",\"type\":\"sofwqmzqalkrmnji\"}],\"nextLink\":\"xacqqudfnbyx\"}")
                .toObject(ServiceResourceListInner.class);
        Assertions.assertEquals("gvraeaen", model.value().get(0).properties().placementConstraints());
        Assertions.assertEquals(MoveCost.HIGH, model.value().get(0).properties().defaultMoveCost());
        Assertions.assertEquals("yrs", model.value().get(0).properties().serviceTypeName());
        Assertions
            .assertEquals(
                ArmServicePackageActivationMode.EXCLUSIVE_PROCESS,
                model.value().get(0).properties().servicePackageActivationMode());
        Assertions.assertEquals("g", model.value().get(0).properties().serviceDnsName());
        Assertions.assertEquals("wlquuijfqkace", model.value().get(0).location());
        Assertions.assertEquals("pfpubjibww", model.value().get(0).tags().get("f"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ServiceResourceListInner model =
            new ServiceResourceListInner()
                .withValue(
                    Arrays
                        .asList(
                            new ServiceResourceInner()
                                .withProperties(
                                    new ServiceResourceProperties()
                                        .withPlacementConstraints("gvraeaen")
                                        .withCorrelationScheme(Arrays.asList())
                                        .withServiceLoadMetrics(Arrays.asList())
                                        .withServicePlacementPolicies(Arrays.asList())
                                        .withDefaultMoveCost(MoveCost.HIGH)
                                        .withServiceTypeName("yrs")
                                        .withServicePackageActivationMode(
                                            ArmServicePackageActivationMode.EXCLUSIVE_PROCESS)
                                        .withServiceDnsName("g"))
                                .withLocation("wlquuijfqkace")
                                .withTags(mapOf("f", "pfpubjibww", "kn", "ohqkvpuvksgpls")),
                            new ServiceResourceInner()
                                .withProperties(
                                    new ServiceResourceProperties()
                                        .withPlacementConstraints("dpumnzgmw")
                                        .withCorrelationScheme(Arrays.asList())
                                        .withServiceLoadMetrics(Arrays.asList())
                                        .withServicePlacementPolicies(Arrays.asList())
                                        .withDefaultMoveCost(MoveCost.MEDIUM)
                                        .withServiceTypeName("suiizynkedyat")
                                        .withServicePackageActivationMode(
                                            ArmServicePackageActivationMode.EXCLUSIVE_PROCESS)
                                        .withServiceDnsName("mibzyhwitsmypyyn"))
                                .withLocation("nsorgjhxbldt")
                                .withTags(mapOf("xdy", "rlkdmtncvokotl", "tdtbnnhadooc", "gsyocogj")),
                            new ServiceResourceInner()
                                .withProperties(
                                    new ServiceResourceProperties()
                                        .withPlacementConstraints("tdaaygdvwvg")
                                        .withCorrelationScheme(Arrays.asList())
                                        .withServiceLoadMetrics(Arrays.asList())
                                        .withServicePlacementPolicies(Arrays.asList())
                                        .withDefaultMoveCost(MoveCost.ZERO)
                                        .withServiceTypeName("nayrhyrnxxmueedn")
                                        .withServicePackageActivationMode(
                                            ArmServicePackageActivationMode.SHARED_PROCESS)
                                        .withServiceDnsName("tkwqqtchealm"))
                                .withLocation("rtfudxepxg")
                                .withTags(
                                    mapOf("mnpkukghimdblxg", "gvr", "mszkkfo", "imfnjhfjx", "kzikfjawneaivxwc", "rey")),
                            new ServiceResourceInner()
                                .withProperties(
                                    new ServiceResourceProperties()
                                        .withPlacementConstraints("ly")
                                        .withCorrelationScheme(Arrays.asList())
                                        .withServiceLoadMetrics(Arrays.asList())
                                        .withServicePlacementPolicies(Arrays.asList())
                                        .withDefaultMoveCost(MoveCost.ZERO)
                                        .withServiceTypeName("glrvimjwosytxi")
                                        .withServicePackageActivationMode(
                                            ArmServicePackageActivationMode.SHARED_PROCESS)
                                        .withServiceDnsName("cktqumiekkezzi"))
                                .withLocation("gebdunygaeq")
                                .withTags(
                                    mapOf("a", "qfatpxllrxcyjm", "arm", "su", "rw", "wdmjsjqbjhhyx", "duhpk", "yc"))));
        model = BinaryData.fromObject(model).toObject(ServiceResourceListInner.class);
        Assertions.assertEquals("gvraeaen", model.value().get(0).properties().placementConstraints());
        Assertions.assertEquals(MoveCost.HIGH, model.value().get(0).properties().defaultMoveCost());
        Assertions.assertEquals("yrs", model.value().get(0).properties().serviceTypeName());
        Assertions
            .assertEquals(
                ArmServicePackageActivationMode.EXCLUSIVE_PROCESS,
                model.value().get(0).properties().servicePackageActivationMode());
        Assertions.assertEquals("g", model.value().get(0).properties().serviceDnsName());
        Assertions.assertEquals("wlquuijfqkace", model.value().get(0).location());
        Assertions.assertEquals("pfpubjibww", model.value().get(0).tags().get("f"));
    }

    @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;
    }
}
