// 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.models.MoveCost;
import com.azure.resourcemanager.servicefabric.models.ServiceCorrelationDescription;
import com.azure.resourcemanager.servicefabric.models.ServiceCorrelationScheme;
import com.azure.resourcemanager.servicefabric.models.ServiceLoadMetricDescription;
import com.azure.resourcemanager.servicefabric.models.ServiceLoadMetricWeight;
import com.azure.resourcemanager.servicefabric.models.ServicePlacementPolicyDescription;
import com.azure.resourcemanager.servicefabric.models.ServiceResourceUpdateProperties;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ServiceResourceUpdatePropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ServiceResourceUpdateProperties model =
            BinaryData
                .fromString(
                    "{\"serviceKind\":\"ServiceResourceUpdateProperties\",\"placementConstraints\":\"yuq\",\"correlationScheme\":[{\"scheme\":\"AlignedAffinity\",\"serviceName\":\"lp\"},{\"scheme\":\"AlignedAffinity\",\"serviceName\":\"cciuqgbdbutau\"}],\"serviceLoadMetrics\":[{\"name\":\"tkuwhhmhykojo\",\"weight\":\"Low\",\"primaryDefaultLoad\":351936442,\"secondaryDefaultLoad\":1456966010,\"defaultLoad\":1324529031},{\"name\":\"chkoymkcdyh\",\"weight\":\"High\",\"primaryDefaultLoad\":823230249,\"secondaryDefaultLoad\":426200809,\"defaultLoad\":668813662}],\"servicePlacementPolicies\":[{\"type\":\"ServicePlacementPolicyDescription\"},{\"type\":\"ServicePlacementPolicyDescription\"},{\"type\":\"ServicePlacementPolicyDescription\"}],\"defaultMoveCost\":\"Medium\"}")
                .toObject(ServiceResourceUpdateProperties.class);
        Assertions.assertEquals("yuq", model.placementConstraints());
        Assertions.assertEquals(ServiceCorrelationScheme.ALIGNED_AFFINITY, model.correlationScheme().get(0).scheme());
        Assertions.assertEquals("lp", model.correlationScheme().get(0).serviceName());
        Assertions.assertEquals("tkuwhhmhykojo", model.serviceLoadMetrics().get(0).name());
        Assertions.assertEquals(ServiceLoadMetricWeight.LOW, model.serviceLoadMetrics().get(0).weight());
        Assertions.assertEquals(351936442, model.serviceLoadMetrics().get(0).primaryDefaultLoad());
        Assertions.assertEquals(1456966010, model.serviceLoadMetrics().get(0).secondaryDefaultLoad());
        Assertions.assertEquals(1324529031, model.serviceLoadMetrics().get(0).defaultLoad());
        Assertions.assertEquals(MoveCost.MEDIUM, model.defaultMoveCost());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ServiceResourceUpdateProperties model =
            new ServiceResourceUpdateProperties()
                .withPlacementConstraints("yuq")
                .withCorrelationScheme(
                    Arrays
                        .asList(
                            new ServiceCorrelationDescription()
                                .withScheme(ServiceCorrelationScheme.ALIGNED_AFFINITY)
                                .withServiceName("lp"),
                            new ServiceCorrelationDescription()
                                .withScheme(ServiceCorrelationScheme.ALIGNED_AFFINITY)
                                .withServiceName("cciuqgbdbutau")))
                .withServiceLoadMetrics(
                    Arrays
                        .asList(
                            new ServiceLoadMetricDescription()
                                .withName("tkuwhhmhykojo")
                                .withWeight(ServiceLoadMetricWeight.LOW)
                                .withPrimaryDefaultLoad(351936442)
                                .withSecondaryDefaultLoad(1456966010)
                                .withDefaultLoad(1324529031),
                            new ServiceLoadMetricDescription()
                                .withName("chkoymkcdyh")
                                .withWeight(ServiceLoadMetricWeight.HIGH)
                                .withPrimaryDefaultLoad(823230249)
                                .withSecondaryDefaultLoad(426200809)
                                .withDefaultLoad(668813662)))
                .withServicePlacementPolicies(
                    Arrays
                        .asList(
                            new ServicePlacementPolicyDescription(),
                            new ServicePlacementPolicyDescription(),
                            new ServicePlacementPolicyDescription()))
                .withDefaultMoveCost(MoveCost.MEDIUM);
        model = BinaryData.fromObject(model).toObject(ServiceResourceUpdateProperties.class);
        Assertions.assertEquals("yuq", model.placementConstraints());
        Assertions.assertEquals(ServiceCorrelationScheme.ALIGNED_AFFINITY, model.correlationScheme().get(0).scheme());
        Assertions.assertEquals("lp", model.correlationScheme().get(0).serviceName());
        Assertions.assertEquals("tkuwhhmhykojo", model.serviceLoadMetrics().get(0).name());
        Assertions.assertEquals(ServiceLoadMetricWeight.LOW, model.serviceLoadMetrics().get(0).weight());
        Assertions.assertEquals(351936442, model.serviceLoadMetrics().get(0).primaryDefaultLoad());
        Assertions.assertEquals(1456966010, model.serviceLoadMetrics().get(0).secondaryDefaultLoad());
        Assertions.assertEquals(1324529031, model.serviceLoadMetrics().get(0).defaultLoad());
        Assertions.assertEquals(MoveCost.MEDIUM, model.defaultMoveCost());
    }
}
