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

package com.azure.resourcemanager.logz.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.logz.fluent.models.LogzMonitorResourceInner;
import com.azure.resourcemanager.logz.models.IdentityProperties;
import com.azure.resourcemanager.logz.models.LogzOrganizationProperties;
import com.azure.resourcemanager.logz.models.ManagedIdentityTypes;
import com.azure.resourcemanager.logz.models.MarketplaceSubscriptionStatus;
import com.azure.resourcemanager.logz.models.MonitorProperties;
import com.azure.resourcemanager.logz.models.MonitoringStatus;
import com.azure.resourcemanager.logz.models.PlanData;
import com.azure.resourcemanager.logz.models.UserInfo;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class LogzMonitorResourceInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        LogzMonitorResourceInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"provisioningState\":\"Updating\",\"monitoringStatus\":\"Disabled\",\"marketplaceSubscriptionStatus\":\"Active\",\"logzOrganizationProperties\":{\"companyName\":\"czdzev\",\"id\":\"hkr\",\"enterpriseAppId\":\"d\",\"singleSignOnUrl\":\"p\"},\"userInfo\":{\"firstName\":\"dkvwrwjfe\",\"lastName\":\"nhutjeltmrldhugj\",\"emailAddress\":\"datqxhocdgeabl\",\"phoneNumber\":\"huticndvkao\"},\"planData\":{\"usageType\":\"i\",\"billingCycle\":\"yhxhu\",\"planDetails\":\"k\",\"effectiveDate\":\"2021-04-05T15:40:07Z\"},\"liftrResourceCategory\":\"MonitorLogs\",\"liftrResourcePreference\":214532343},\"identity\":{\"principalId\":\"pwcukjfkgiawxk\",\"tenantId\":\"ypl\",\"type\":\"SystemAssigned\"},\"location\":\"basyy\",\"tags\":{\"phejkotynqgoulz\":\"dhsgcba\",\"gakeqsr\":\"dlikwyqkgfgibma\",\"qqedqytbciqfou\":\"yb\"},\"id\":\"lmmnkzsmodmglo\",\"name\":\"gpbkwtmut\",\"type\":\"uqktap\"}")
                .toObject(LogzMonitorResourceInner.class);
        Assertions.assertEquals("basyy", model.location());
        Assertions.assertEquals("dhsgcba", model.tags().get("phejkotynqgoulz"));
        Assertions.assertEquals(MonitoringStatus.DISABLED, model.properties().monitoringStatus());
        Assertions
            .assertEquals(MarketplaceSubscriptionStatus.ACTIVE, model.properties().marketplaceSubscriptionStatus());
        Assertions.assertEquals("czdzev", model.properties().logzOrganizationProperties().companyName());
        Assertions.assertEquals("d", model.properties().logzOrganizationProperties().enterpriseAppId());
        Assertions.assertEquals("p", model.properties().logzOrganizationProperties().singleSignOnUrl());
        Assertions.assertEquals("dkvwrwjfe", model.properties().userInfo().firstName());
        Assertions.assertEquals("nhutjeltmrldhugj", model.properties().userInfo().lastName());
        Assertions.assertEquals("datqxhocdgeabl", model.properties().userInfo().emailAddress());
        Assertions.assertEquals("huticndvkao", model.properties().userInfo().phoneNumber());
        Assertions.assertEquals("i", model.properties().planData().usageType());
        Assertions.assertEquals("yhxhu", model.properties().planData().billingCycle());
        Assertions.assertEquals("k", model.properties().planData().planDetails());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-04-05T15:40:07Z"), model.properties().planData().effectiveDate());
        Assertions.assertEquals(ManagedIdentityTypes.SYSTEM_ASSIGNED, model.identity().type());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        LogzMonitorResourceInner model =
            new LogzMonitorResourceInner()
                .withLocation("basyy")
                .withTags(mapOf("phejkotynqgoulz", "dhsgcba", "gakeqsr", "dlikwyqkgfgibma", "qqedqytbciqfou", "yb"))
                .withProperties(
                    new MonitorProperties()
                        .withMonitoringStatus(MonitoringStatus.DISABLED)
                        .withMarketplaceSubscriptionStatus(MarketplaceSubscriptionStatus.ACTIVE)
                        .withLogzOrganizationProperties(
                            new LogzOrganizationProperties()
                                .withCompanyName("czdzev")
                                .withEnterpriseAppId("d")
                                .withSingleSignOnUrl("p"))
                        .withUserInfo(
                            new UserInfo()
                                .withFirstName("dkvwrwjfe")
                                .withLastName("nhutjeltmrldhugj")
                                .withEmailAddress("datqxhocdgeabl")
                                .withPhoneNumber("huticndvkao"))
                        .withPlanData(
                            new PlanData()
                                .withUsageType("i")
                                .withBillingCycle("yhxhu")
                                .withPlanDetails("k")
                                .withEffectiveDate(OffsetDateTime.parse("2021-04-05T15:40:07Z"))))
                .withIdentity(new IdentityProperties().withType(ManagedIdentityTypes.SYSTEM_ASSIGNED));
        model = BinaryData.fromObject(model).toObject(LogzMonitorResourceInner.class);
        Assertions.assertEquals("basyy", model.location());
        Assertions.assertEquals("dhsgcba", model.tags().get("phejkotynqgoulz"));
        Assertions.assertEquals(MonitoringStatus.DISABLED, model.properties().monitoringStatus());
        Assertions
            .assertEquals(MarketplaceSubscriptionStatus.ACTIVE, model.properties().marketplaceSubscriptionStatus());
        Assertions.assertEquals("czdzev", model.properties().logzOrganizationProperties().companyName());
        Assertions.assertEquals("d", model.properties().logzOrganizationProperties().enterpriseAppId());
        Assertions.assertEquals("p", model.properties().logzOrganizationProperties().singleSignOnUrl());
        Assertions.assertEquals("dkvwrwjfe", model.properties().userInfo().firstName());
        Assertions.assertEquals("nhutjeltmrldhugj", model.properties().userInfo().lastName());
        Assertions.assertEquals("datqxhocdgeabl", model.properties().userInfo().emailAddress());
        Assertions.assertEquals("huticndvkao", model.properties().userInfo().phoneNumber());
        Assertions.assertEquals("i", model.properties().planData().usageType());
        Assertions.assertEquals("yhxhu", model.properties().planData().billingCycle());
        Assertions.assertEquals("k", model.properties().planData().planDetails());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-04-05T15:40:07Z"), model.properties().planData().effectiveDate());
        Assertions.assertEquals(ManagedIdentityTypes.SYSTEM_ASSIGNED, model.identity().type());
    }

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