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

package com.azure.resourcemanager.machinelearning.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.machinelearning.models.ComponentContainerProperties;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ComponentContainerPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ComponentContainerProperties model =
            BinaryData
                .fromString(
                    "{\"isArchived\":false,\"latestVersion\":\"bnhlmc\",\"nextVersion\":\"p\",\"description\":\"gitvg\",\"properties\":{\"rh\":\"rixkwmyijejve\",\"xexccbdreaxhcexd\":\"pna\"},\"tags\":{\"yjsvfyc\":\"qahqkghtpwijn\",\"fvoow\":\"z\",\"pyostronzmyhgfi\":\"rvmtgjq\"}}")
                .toObject(ComponentContainerProperties.class);
        Assertions.assertEquals("gitvg", model.description());
        Assertions.assertEquals("rixkwmyijejve", model.properties().get("rh"));
        Assertions.assertEquals("qahqkghtpwijn", model.tags().get("yjsvfyc"));
        Assertions.assertEquals(false, model.isArchived());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ComponentContainerProperties model =
            new ComponentContainerProperties()
                .withDescription("gitvg")
                .withProperties(mapOf("rh", "rixkwmyijejve", "xexccbdreaxhcexd", "pna"))
                .withTags(mapOf("yjsvfyc", "qahqkghtpwijn", "fvoow", "z", "pyostronzmyhgfi", "rvmtgjq"))
                .withIsArchived(false);
        model = BinaryData.fromObject(model).toObject(ComponentContainerProperties.class);
        Assertions.assertEquals("gitvg", model.description());
        Assertions.assertEquals("rixkwmyijejve", model.properties().get("rh"));
        Assertions.assertEquals("qahqkghtpwijn", model.tags().get("yjsvfyc"));
        Assertions.assertEquals(false, model.isArchived());
    }

    @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;
    }
}
