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

package com.azure.resourcemanager.mariadb.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.mariadb.fluent.models.RecommendationActionInner;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class RecommendationActionInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RecommendationActionInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"advisorName\":\"ixisxyawjoy\",\"sessionId\":\"cslyjpk\",\"actionId\":888543440,\"createdTime\":\"2021-12-04T03:35:31Z\",\"expirationTime\":\"2021-07-24T18:59:08Z\",\"reason\":\"nelixhnrztfo\",\"recommendationType\":\"bnxknalaulppg\",\"details\":{\"igvpgylg\":\"pnapnyiropuh\",\"medjvcslynqwwncw\":\"git\",\"pkteo\":\"zhxgktrmgucn\",\"pfqbuaceopzf\":\"llwptfdy\"}},\"id\":\"rhhuaopppcqeqx\",\"name\":\"lzdahzxctobgbkdm\",\"type\":\"izpost\"}")
                .toObject(RecommendationActionInner.class);
        Assertions.assertEquals("ixisxyawjoy", model.advisorName());
        Assertions.assertEquals("cslyjpk", model.sessionId());
        Assertions.assertEquals(888543440, model.actionId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-12-04T03:35:31Z"), model.createdTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-07-24T18:59:08Z"), model.expirationTime());
        Assertions.assertEquals("nelixhnrztfo", model.reason());
        Assertions.assertEquals("bnxknalaulppg", model.recommendationType());
        Assertions.assertEquals("pnapnyiropuh", model.details().get("igvpgylg"));
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RecommendationActionInner model =
            new RecommendationActionInner()
                .withAdvisorName("ixisxyawjoy")
                .withSessionId("cslyjpk")
                .withActionId(888543440)
                .withCreatedTime(OffsetDateTime.parse("2021-12-04T03:35:31Z"))
                .withExpirationTime(OffsetDateTime.parse("2021-07-24T18:59:08Z"))
                .withReason("nelixhnrztfo")
                .withRecommendationType("bnxknalaulppg")
                .withDetails(
                    mapOf(
                        "igvpgylg",
                        "pnapnyiropuh",
                        "medjvcslynqwwncw",
                        "git",
                        "pkteo",
                        "zhxgktrmgucn",
                        "pfqbuaceopzf",
                        "llwptfdy"));
        model = BinaryData.fromObject(model).toObject(RecommendationActionInner.class);
        Assertions.assertEquals("ixisxyawjoy", model.advisorName());
        Assertions.assertEquals("cslyjpk", model.sessionId());
        Assertions.assertEquals(888543440, model.actionId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-12-04T03:35:31Z"), model.createdTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-07-24T18:59:08Z"), model.expirationTime());
        Assertions.assertEquals("nelixhnrztfo", model.reason());
        Assertions.assertEquals("bnxknalaulppg", model.recommendationType());
        Assertions.assertEquals("pnapnyiropuh", model.details().get("igvpgylg"));
    }

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