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

package com.azure.resourcemanager.containerservicefleet.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.containerservicefleet.fluent.models.UpdateRunProperties;
import com.azure.resourcemanager.containerservicefleet.models.ManagedClusterUpdate;
import com.azure.resourcemanager.containerservicefleet.models.ManagedClusterUpgradeSpec;
import com.azure.resourcemanager.containerservicefleet.models.ManagedClusterUpgradeType;
import com.azure.resourcemanager.containerservicefleet.models.UpdateRunStrategy;
import com.azure.resourcemanager.containerservicefleet.models.UpdateStage;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class UpdateRunPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        UpdateRunProperties model =
            BinaryData
                .fromString(
                    "{\"provisioningState\":\"Canceled\",\"strategy\":{\"stages\":[{\"name\":\"bnwbxgjvtbvpyssz\",\"groups\":[],\"afterStageWaitInSeconds\":315783866},{\"name\":\"jq\",\"groups\":[],\"afterStageWaitInSeconds\":1745806154},{\"name\":\"uouq\",\"groups\":[],\"afterStageWaitInSeconds\":326786210},{\"name\":\"zw\",\"groups\":[],\"afterStageWaitInSeconds\":2100303933}]},\"managedClusterUpdate\":{\"upgrade\":{\"type\":\"NodeImageOnly\",\"kubernetesVersion\":\"nwui\"}},\"status\":{\"status\":{\"startTime\":\"2021-08-08T04:29:53Z\",\"completedTime\":\"2021-11-07T16:18:10Z\",\"state\":\"Failed\"},\"stages\":[{\"name\":\"i\",\"groups\":[]}]}}")
                .toObject(UpdateRunProperties.class);
        Assertions.assertEquals("bnwbxgjvtbvpyssz", model.strategy().stages().get(0).name());
        Assertions.assertEquals(315783866, model.strategy().stages().get(0).afterStageWaitInSeconds());
        Assertions
            .assertEquals(ManagedClusterUpgradeType.NODE_IMAGE_ONLY, model.managedClusterUpdate().upgrade().type());
        Assertions.assertEquals("nwui", model.managedClusterUpdate().upgrade().kubernetesVersion());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        UpdateRunProperties model =
            new UpdateRunProperties()
                .withStrategy(
                    new UpdateRunStrategy()
                        .withStages(
                            Arrays
                                .asList(
                                    new UpdateStage()
                                        .withName("bnwbxgjvtbvpyssz")
                                        .withGroups(Arrays.asList())
                                        .withAfterStageWaitInSeconds(315783866),
                                    new UpdateStage()
                                        .withName("jq")
                                        .withGroups(Arrays.asList())
                                        .withAfterStageWaitInSeconds(1745806154),
                                    new UpdateStage()
                                        .withName("uouq")
                                        .withGroups(Arrays.asList())
                                        .withAfterStageWaitInSeconds(326786210),
                                    new UpdateStage()
                                        .withName("zw")
                                        .withGroups(Arrays.asList())
                                        .withAfterStageWaitInSeconds(2100303933))))
                .withManagedClusterUpdate(
                    new ManagedClusterUpdate()
                        .withUpgrade(
                            new ManagedClusterUpgradeSpec()
                                .withType(ManagedClusterUpgradeType.NODE_IMAGE_ONLY)
                                .withKubernetesVersion("nwui")));
        model = BinaryData.fromObject(model).toObject(UpdateRunProperties.class);
        Assertions.assertEquals("bnwbxgjvtbvpyssz", model.strategy().stages().get(0).name());
        Assertions.assertEquals(315783866, model.strategy().stages().get(0).afterStageWaitInSeconds());
        Assertions
            .assertEquals(ManagedClusterUpgradeType.NODE_IMAGE_ONLY, model.managedClusterUpdate().upgrade().type());
        Assertions.assertEquals("nwui", model.managedClusterUpdate().upgrade().kubernetesVersion());
    }
}
