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

package com.azure.resourcemanager.security.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.security.models.ConfigurationStatus;
import com.azure.resourcemanager.security.models.FileType;
import com.azure.resourcemanager.security.models.PathRecommendation;
import com.azure.resourcemanager.security.models.PublisherInfo;
import com.azure.resourcemanager.security.models.RecommendationAction;
import com.azure.resourcemanager.security.models.RecommendationType;
import com.azure.resourcemanager.security.models.UserRecommendation;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class PathRecommendationTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        PathRecommendation model =
            BinaryData
                .fromString(
                    "{\"path\":\"sgbpfgzdjtx\",\"action\":\"Remove\",\"type\":\"IoT_InstallAgent\",\"publisherInfo\":{\"publisherName\":\"gaqvlgafcqusrd\",\"productName\":\"t\",\"binaryName\":\"sdtutnwlduyc\",\"version\":\"zhyrmewipmve\"},\"common\":false,\"userSids\":[\"uqgsj\",\"xundxgk\",\"twzhhzjhfjmhv\",\"muvgp\"],\"usernames\":[{\"username\":\"qsxvmhf\",\"recommendationAction\":\"Remove\"},{\"username\":\"yihsasbhudypohyu\",\"recommendationAction\":\"Add\"}],\"fileType\":\"Script\",\"configurationStatus\":\"NoStatus\"}")
                .toObject(PathRecommendation.class);
        Assertions.assertEquals("sgbpfgzdjtx", model.path());
        Assertions.assertEquals(RecommendationAction.REMOVE, model.action());
        Assertions.assertEquals(RecommendationType.IO_T_INSTALL_AGENT, model.type());
        Assertions.assertEquals("gaqvlgafcqusrd", model.publisherInfo().publisherName());
        Assertions.assertEquals("t", model.publisherInfo().productName());
        Assertions.assertEquals("sdtutnwlduyc", model.publisherInfo().binaryName());
        Assertions.assertEquals("zhyrmewipmve", model.publisherInfo().version());
        Assertions.assertEquals(false, model.common());
        Assertions.assertEquals("uqgsj", model.userSids().get(0));
        Assertions.assertEquals("qsxvmhf", model.usernames().get(0).username());
        Assertions.assertEquals(RecommendationAction.REMOVE, model.usernames().get(0).recommendationAction());
        Assertions.assertEquals(FileType.SCRIPT, model.fileType());
        Assertions.assertEquals(ConfigurationStatus.NO_STATUS, model.configurationStatus());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        PathRecommendation model =
            new PathRecommendation()
                .withPath("sgbpfgzdjtx")
                .withAction(RecommendationAction.REMOVE)
                .withType(RecommendationType.IO_T_INSTALL_AGENT)
                .withPublisherInfo(
                    new PublisherInfo()
                        .withPublisherName("gaqvlgafcqusrd")
                        .withProductName("t")
                        .withBinaryName("sdtutnwlduyc")
                        .withVersion("zhyrmewipmve"))
                .withCommon(false)
                .withUserSids(Arrays.asList("uqgsj", "xundxgk", "twzhhzjhfjmhv", "muvgp"))
                .withUsernames(
                    Arrays
                        .asList(
                            new UserRecommendation()
                                .withUsername("qsxvmhf")
                                .withRecommendationAction(RecommendationAction.REMOVE),
                            new UserRecommendation()
                                .withUsername("yihsasbhudypohyu")
                                .withRecommendationAction(RecommendationAction.ADD)))
                .withFileType(FileType.SCRIPT)
                .withConfigurationStatus(ConfigurationStatus.NO_STATUS);
        model = BinaryData.fromObject(model).toObject(PathRecommendation.class);
        Assertions.assertEquals("sgbpfgzdjtx", model.path());
        Assertions.assertEquals(RecommendationAction.REMOVE, model.action());
        Assertions.assertEquals(RecommendationType.IO_T_INSTALL_AGENT, model.type());
        Assertions.assertEquals("gaqvlgafcqusrd", model.publisherInfo().publisherName());
        Assertions.assertEquals("t", model.publisherInfo().productName());
        Assertions.assertEquals("sdtutnwlduyc", model.publisherInfo().binaryName());
        Assertions.assertEquals("zhyrmewipmve", model.publisherInfo().version());
        Assertions.assertEquals(false, model.common());
        Assertions.assertEquals("uqgsj", model.userSids().get(0));
        Assertions.assertEquals("qsxvmhf", model.usernames().get(0).username());
        Assertions.assertEquals(RecommendationAction.REMOVE, model.usernames().get(0).recommendationAction());
        Assertions.assertEquals(FileType.SCRIPT, model.fileType());
        Assertions.assertEquals(ConfigurationStatus.NO_STATUS, model.configurationStatus());
    }
}
