// 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.ServiceResourcePropertiesBase;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ServiceResourcePropertiesBaseTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ServiceResourcePropertiesBase model =
            BinaryData
                .fromString(
                    "{\"placementConstraints\":\"dsotbobzd\",\"correlationScheme\":[{\"scheme\":\"Invalid\",\"serviceName\":\"wvnhdldwmgx\"},{\"scheme\":\"Affinity\",\"serviceName\":\"rslpmutwuoeg\"}],\"serviceLoadMetrics\":[{\"name\":\"hjwniyqsluic\",\"weight\":\"Medium\",\"primaryDefaultLoad\":1810528552,\"secondaryDefaultLoad\":523061291,\"defaultLoad\":1186626451},{\"name\":\"mbmpaxmodfvuefy\",\"weight\":\"Low\",\"primaryDefaultLoad\":1288756278,\"secondaryDefaultLoad\":1216827134,\"defaultLoad\":1662682497}],\"servicePlacementPolicies\":[{\"type\":\"ServicePlacementPolicyDescription\"},{\"type\":\"ServicePlacementPolicyDescription\"},{\"type\":\"ServicePlacementPolicyDescription\"},{\"type\":\"ServicePlacementPolicyDescription\"}],\"defaultMoveCost\":\"Medium\"}")
                .toObject(ServiceResourcePropertiesBase.class);
        Assertions.assertEquals("dsotbobzd", model.placementConstraints());
        Assertions.assertEquals(ServiceCorrelationScheme.INVALID, model.correlationScheme().get(0).scheme());
        Assertions.assertEquals("wvnhdldwmgx", model.correlationScheme().get(0).serviceName());
        Assertions.assertEquals("hjwniyqsluic", model.serviceLoadMetrics().get(0).name());
        Assertions.assertEquals(ServiceLoadMetricWeight.MEDIUM, model.serviceLoadMetrics().get(0).weight());
        Assertions.assertEquals(1810528552, model.serviceLoadMetrics().get(0).primaryDefaultLoad());
        Assertions.assertEquals(523061291, model.serviceLoadMetrics().get(0).secondaryDefaultLoad());
        Assertions.assertEquals(1186626451, model.serviceLoadMetrics().get(0).defaultLoad());
        Assertions.assertEquals(MoveCost.MEDIUM, model.defaultMoveCost());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ServiceResourcePropertiesBase model =
            new ServiceResourcePropertiesBase()
                .withPlacementConstraints("dsotbobzd")
                .withCorrelationScheme(
                    Arrays
                        .asList(
                            new ServiceCorrelationDescription()
                                .withScheme(ServiceCorrelationScheme.INVALID)
                                .withServiceName("wvnhdldwmgx"),
                            new ServiceCorrelationDescription()
                                .withScheme(ServiceCorrelationScheme.AFFINITY)
                                .withServiceName("rslpmutwuoeg")))
                .withServiceLoadMetrics(
                    Arrays
                        .asList(
                            new ServiceLoadMetricDescription()
                                .withName("hjwniyqsluic")
                                .withWeight(ServiceLoadMetricWeight.MEDIUM)
                                .withPrimaryDefaultLoad(1810528552)
                                .withSecondaryDefaultLoad(523061291)
                                .withDefaultLoad(1186626451),
                            new ServiceLoadMetricDescription()
                                .withName("mbmpaxmodfvuefy")
                                .withWeight(ServiceLoadMetricWeight.LOW)
                                .withPrimaryDefaultLoad(1288756278)
                                .withSecondaryDefaultLoad(1216827134)
                                .withDefaultLoad(1662682497)))
                .withServicePlacementPolicies(
                    Arrays
                        .asList(
                            new ServicePlacementPolicyDescription(),
                            new ServicePlacementPolicyDescription(),
                            new ServicePlacementPolicyDescription(),
                            new ServicePlacementPolicyDescription()))
                .withDefaultMoveCost(MoveCost.MEDIUM);
        model = BinaryData.fromObject(model).toObject(ServiceResourcePropertiesBase.class);
        Assertions.assertEquals("dsotbobzd", model.placementConstraints());
        Assertions.assertEquals(ServiceCorrelationScheme.INVALID, model.correlationScheme().get(0).scheme());
        Assertions.assertEquals("wvnhdldwmgx", model.correlationScheme().get(0).serviceName());
        Assertions.assertEquals("hjwniyqsluic", model.serviceLoadMetrics().get(0).name());
        Assertions.assertEquals(ServiceLoadMetricWeight.MEDIUM, model.serviceLoadMetrics().get(0).weight());
        Assertions.assertEquals(1810528552, model.serviceLoadMetrics().get(0).primaryDefaultLoad());
        Assertions.assertEquals(523061291, model.serviceLoadMetrics().get(0).secondaryDefaultLoad());
        Assertions.assertEquals(1186626451, model.serviceLoadMetrics().get(0).defaultLoad());
        Assertions.assertEquals(MoveCost.MEDIUM, model.defaultMoveCost());
    }
}
