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

package com.azure.resourcemanager.securitydevops.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.securitydevops.models.ActionableRemediation;
import com.azure.resourcemanager.securitydevops.models.ActionableRemediationState;
import com.azure.resourcemanager.securitydevops.models.AzureDevOpsRepoProperties;
import com.azure.resourcemanager.securitydevops.models.ProvisioningState;
import com.azure.resourcemanager.securitydevops.models.RuleCategory;
import com.azure.resourcemanager.securitydevops.models.TargetBranchConfiguration;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class AzureDevOpsRepoPropertiesTests {
    @Test
    public void testDeserialize() {
        AzureDevOpsRepoProperties model =
            BinaryData
                .fromString(
                    "{\"provisioningState\":\"Canceled\",\"repoId\":\"xsabkyqdu\",\"repoUrl\":\"itcjczdz\",\"orgName\":\"ndhkrw\",\"projectName\":\"appd\",\"visibility\":\"dkvwrwjfe\",\"actionableRemediation\":{\"state\":\"Enabled\",\"severityLevels\":[\"je\",\"tmrldhugjzzdatq\"],\"categories\":[\"IaC\"],\"branchConfiguration\":{\"names\":[\"ablgphuticndvk\",\"ozwyiftyhxhuro\"]}}}")
                .toObject(AzureDevOpsRepoProperties.class);
        Assertions.assertEquals(ProvisioningState.CANCELED, model.provisioningState());
        Assertions.assertEquals("xsabkyqdu", model.repoId());
        Assertions.assertEquals("itcjczdz", model.repoUrl());
        Assertions.assertEquals("ndhkrw", model.orgName());
        Assertions.assertEquals("appd", model.projectName());
        Assertions.assertEquals("dkvwrwjfe", model.visibility());
        Assertions.assertEquals(ActionableRemediationState.ENABLED, model.actionableRemediation().state());
        Assertions.assertEquals("je", model.actionableRemediation().severityLevels().get(0));
        Assertions.assertEquals(RuleCategory.IAC, model.actionableRemediation().categories().get(0));
        Assertions.assertEquals("ablgphuticndvk", model.actionableRemediation().branchConfiguration().names().get(0));
    }

    @Test
    public void testSerialize() {
        AzureDevOpsRepoProperties model =
            new AzureDevOpsRepoProperties()
                .withProvisioningState(ProvisioningState.CANCELED)
                .withRepoId("xsabkyqdu")
                .withRepoUrl("itcjczdz")
                .withOrgName("ndhkrw")
                .withProjectName("appd")
                .withVisibility("dkvwrwjfe")
                .withActionableRemediation(
                    new ActionableRemediation()
                        .withState(ActionableRemediationState.ENABLED)
                        .withSeverityLevels(Arrays.asList("je", "tmrldhugjzzdatq"))
                        .withCategories(Arrays.asList(RuleCategory.IAC))
                        .withBranchConfiguration(
                            new TargetBranchConfiguration()
                                .withNames(Arrays.asList("ablgphuticndvk", "ozwyiftyhxhuro"))));
        model = BinaryData.fromObject(model).toObject(AzureDevOpsRepoProperties.class);
        Assertions.assertEquals(ProvisioningState.CANCELED, model.provisioningState());
        Assertions.assertEquals("xsabkyqdu", model.repoId());
        Assertions.assertEquals("itcjczdz", model.repoUrl());
        Assertions.assertEquals("ndhkrw", model.orgName());
        Assertions.assertEquals("appd", model.projectName());
        Assertions.assertEquals("dkvwrwjfe", model.visibility());
        Assertions.assertEquals(ActionableRemediationState.ENABLED, model.actionableRemediation().state());
        Assertions.assertEquals("je", model.actionableRemediation().severityLevels().get(0));
        Assertions.assertEquals(RuleCategory.IAC, model.actionableRemediation().categories().get(0));
        Assertions.assertEquals("ablgphuticndvk", model.actionableRemediation().branchConfiguration().names().get(0));
    }
}
