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

package com.azure.resourcemanager.devhub.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.devhub.fluent.models.WorkflowInner;
import com.azure.resourcemanager.devhub.models.DockerfileGenerationMode;
import com.azure.resourcemanager.devhub.models.GenerationLanguage;
import com.azure.resourcemanager.devhub.models.GenerationManifestType;
import com.azure.resourcemanager.devhub.models.ManifestGenerationMode;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class WorkflowInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        WorkflowInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"githubWorkflowProfile\":{\"repositoryOwner\":\"uujitcjc\",\"repositoryName\":\"zevndhkrwpdappds\",\"branchName\":\"kvwrwjfeu\",\"dockerfile\":\"hutje\",\"dockerBuildContext\":\"mrldhu\",\"namespace\":\"zdatqxhocdg\",\"aksResourceId\":\"gphuticndvka\",\"prURL\":\"wyiftyhxhur\",\"pullNumber\":233179905,\"prStatus\":\"submitted\",\"authStatus\":\"NotFound\"},\"artifactGenerationProperties\":{\"generationLanguage\":\"php\",\"languageVersion\":\"wcukjfkgiawxk\",\"builderVersion\":\"ypl\",\"port\":\"kbasyypn\",\"appName\":\"hsgcbacphejkot\",\"dockerfileOutputDirectory\":\"qgoulznd\",\"manifestOutputDirectory\":\"kwy\",\"dockerfileGenerationMode\":\"enabled\",\"manifestGenerationMode\":\"enabled\",\"manifestType\":\"helm\",\"imageName\":\"adgakeqsrxybz\",\"namespace\":\"e\",\"imageTag\":\"ytb\"}},\"location\":\"qfou\",\"tags\":{\"glougpbk\":\"mnkzsmod\",\"uqktap\":\"tmut\",\"kdosvqw\":\"pwgcuertu\"},\"id\":\"bmdg\",\"name\":\"bjf\",\"type\":\"dgmb\"}")
                .toObject(WorkflowInner.class);
        Assertions.assertEquals("qfou", model.location());
        Assertions.assertEquals("mnkzsmod", model.tags().get("glougpbk"));
        Assertions.assertEquals("uujitcjc", model.repositoryOwner());
        Assertions.assertEquals("zevndhkrwpdappds", model.repositoryName());
        Assertions.assertEquals("kvwrwjfeu", model.branchName());
        Assertions.assertEquals("hutje", model.dockerfile());
        Assertions.assertEquals("mrldhu", model.dockerBuildContext());
        Assertions.assertEquals("zdatqxhocdg", model.namespace());
        Assertions.assertEquals("gphuticndvka", model.aksResourceId());
        Assertions.assertEquals(GenerationLanguage.PHP, model.generationLanguage());
        Assertions.assertEquals("wcukjfkgiawxk", model.languageVersion());
        Assertions.assertEquals("ypl", model.builderVersion());
        Assertions.assertEquals("kbasyypn", model.port());
        Assertions.assertEquals("hsgcbacphejkot", model.appName());
        Assertions.assertEquals("qgoulznd", model.dockerfileOutputDirectory());
        Assertions.assertEquals("kwy", model.manifestOutputDirectory());
        Assertions.assertEquals(DockerfileGenerationMode.ENABLED, model.dockerfileGenerationMode());
        Assertions.assertEquals(ManifestGenerationMode.ENABLED, model.manifestGenerationMode());
        Assertions.assertEquals(GenerationManifestType.HELM, model.manifestType());
        Assertions.assertEquals("adgakeqsrxybz", model.imageName());
        Assertions.assertEquals("e", model.namespaceArtifactGenerationPropertiesNamespace());
        Assertions.assertEquals("ytb", model.imageTag());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        WorkflowInner model =
            new WorkflowInner()
                .withLocation("qfou")
                .withTags(mapOf("glougpbk", "mnkzsmod", "uqktap", "tmut", "kdosvqw", "pwgcuertu"))
                .withRepositoryOwner("uujitcjc")
                .withRepositoryName("zevndhkrwpdappds")
                .withBranchName("kvwrwjfeu")
                .withDockerfile("hutje")
                .withDockerBuildContext("mrldhu")
                .withNamespace("zdatqxhocdg")
                .withAksResourceId("gphuticndvka")
                .withGenerationLanguage(GenerationLanguage.PHP)
                .withLanguageVersion("wcukjfkgiawxk")
                .withBuilderVersion("ypl")
                .withPort("kbasyypn")
                .withAppName("hsgcbacphejkot")
                .withDockerfileOutputDirectory("qgoulznd")
                .withManifestOutputDirectory("kwy")
                .withDockerfileGenerationMode(DockerfileGenerationMode.ENABLED)
                .withManifestGenerationMode(ManifestGenerationMode.ENABLED)
                .withManifestType(GenerationManifestType.HELM)
                .withImageName("adgakeqsrxybz")
                .withNamespaceArtifactGenerationPropertiesNamespace("e")
                .withImageTag("ytb");
        model = BinaryData.fromObject(model).toObject(WorkflowInner.class);
        Assertions.assertEquals("qfou", model.location());
        Assertions.assertEquals("mnkzsmod", model.tags().get("glougpbk"));
        Assertions.assertEquals("uujitcjc", model.repositoryOwner());
        Assertions.assertEquals("zevndhkrwpdappds", model.repositoryName());
        Assertions.assertEquals("kvwrwjfeu", model.branchName());
        Assertions.assertEquals("hutje", model.dockerfile());
        Assertions.assertEquals("mrldhu", model.dockerBuildContext());
        Assertions.assertEquals("zdatqxhocdg", model.namespace());
        Assertions.assertEquals("gphuticndvka", model.aksResourceId());
        Assertions.assertEquals(GenerationLanguage.PHP, model.generationLanguage());
        Assertions.assertEquals("wcukjfkgiawxk", model.languageVersion());
        Assertions.assertEquals("ypl", model.builderVersion());
        Assertions.assertEquals("kbasyypn", model.port());
        Assertions.assertEquals("hsgcbacphejkot", model.appName());
        Assertions.assertEquals("qgoulznd", model.dockerfileOutputDirectory());
        Assertions.assertEquals("kwy", model.manifestOutputDirectory());
        Assertions.assertEquals(DockerfileGenerationMode.ENABLED, model.dockerfileGenerationMode());
        Assertions.assertEquals(ManifestGenerationMode.ENABLED, model.manifestGenerationMode());
        Assertions.assertEquals(GenerationManifestType.HELM, model.manifestType());
        Assertions.assertEquals("adgakeqsrxybz", model.imageName());
        Assertions.assertEquals("e", model.namespaceArtifactGenerationPropertiesNamespace());
        Assertions.assertEquals("ytb", model.imageTag());
    }

    @SuppressWarnings("unchecked")
    private static <T> Map<String, T> mapOf(Object... inputs) {
        Map<String, T> map = new HashMap<>();
        for (int i = 0; i < inputs.length; i += 2) {
            String key = (String) inputs[i];
            T value = (T) inputs[i + 1];
            map.put(key, value);
        }
        return map;
    }
}
