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

package com.azure.resourcemanager.advisor.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.advisor.fluent.models.ResourceRecommendationBaseInner;
import com.azure.resourcemanager.advisor.models.Category;
import com.azure.resourcemanager.advisor.models.Impact;
import com.azure.resourcemanager.advisor.models.ResourceRecommendationBaseListResult;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ResourceRecommendationBaseListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ResourceRecommendationBaseListResult model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"hmsbzjhcrzevdp\",\"value\":[{\"properties\":{\"category\":\"HighAvailability\",\"impact\":\"Low\",\"impactedField\":\"trg\",\"impactedValue\":\"bpf\",\"lastUpdated\":\"2021-02-22T07:39:39Z\",\"metadata\":{},\"recommendationTypeId\":\"zgvfcjrwz\",\"suppressionIds\":[],\"extendedProperties\":{},\"description\":\"elluwfziton\",\"label\":\"qfpjk\",\"learnMoreLink\":\"xofpdvhpfxxypi\",\"potentialBenefits\":\"nmayhuybb\",\"actions\":[],\"remediation\":{},\"exposedMetadataProperties\":{}},\"id\":\"epoo\",\"name\":\"inuvamiheogn\",\"type\":\"rxzxtheo\"},{\"properties\":{\"category\":\"Performance\",\"impact\":\"High\",\"impactedField\":\"v\",\"impactedValue\":\"iqihn\",\"lastUpdated\":\"2021-07-19T03:18:26Z\",\"metadata\":{},\"recommendationTypeId\":\"wjzrnfygxgisp\",\"suppressionIds\":[],\"extendedProperties\":{},\"description\":\"kufubljo\",\"label\":\"qeof\",\"learnMoreLink\":\"e\",\"potentialBenefits\":\"hqjbasvmsmj\",\"actions\":[],\"remediation\":{},\"exposedMetadataProperties\":{}},\"id\":\"gsntnbybkzgcwr\",\"name\":\"clxxwrljdo\",\"type\":\"skcqvkocrcjd\"}]}")
                .toObject(ResourceRecommendationBaseListResult.class);
        Assertions.assertEquals("hmsbzjhcrzevdp", model.nextLink());
        Assertions.assertEquals(Category.HIGH_AVAILABILITY, model.value().get(0).category());
        Assertions.assertEquals(Impact.LOW, model.value().get(0).impact());
        Assertions.assertEquals("trg", model.value().get(0).impactedField());
        Assertions.assertEquals("bpf", model.value().get(0).impactedValue());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-22T07:39:39Z"), model.value().get(0).lastUpdated());
        Assertions.assertEquals("zgvfcjrwz", model.value().get(0).recommendationTypeId());
        Assertions.assertEquals("elluwfziton", model.value().get(0).description());
        Assertions.assertEquals("qfpjk", model.value().get(0).label());
        Assertions.assertEquals("xofpdvhpfxxypi", model.value().get(0).learnMoreLink());
        Assertions.assertEquals("nmayhuybb", model.value().get(0).potentialBenefits());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ResourceRecommendationBaseListResult model =
            new ResourceRecommendationBaseListResult()
                .withNextLink("hmsbzjhcrzevdp")
                .withValue(
                    Arrays
                        .asList(
                            new ResourceRecommendationBaseInner()
                                .withCategory(Category.HIGH_AVAILABILITY)
                                .withImpact(Impact.LOW)
                                .withImpactedField("trg")
                                .withImpactedValue("bpf")
                                .withLastUpdated(OffsetDateTime.parse("2021-02-22T07:39:39Z"))
                                .withMetadata(mapOf())
                                .withRecommendationTypeId("zgvfcjrwz")
                                .withSuppressionIds(Arrays.asList())
                                .withExtendedProperties(mapOf())
                                .withDescription("elluwfziton")
                                .withLabel("qfpjk")
                                .withLearnMoreLink("xofpdvhpfxxypi")
                                .withPotentialBenefits("nmayhuybb")
                                .withActions(Arrays.asList())
                                .withRemediation(mapOf())
                                .withExposedMetadataProperties(mapOf()),
                            new ResourceRecommendationBaseInner()
                                .withCategory(Category.PERFORMANCE)
                                .withImpact(Impact.HIGH)
                                .withImpactedField("v")
                                .withImpactedValue("iqihn")
                                .withLastUpdated(OffsetDateTime.parse("2021-07-19T03:18:26Z"))
                                .withMetadata(mapOf())
                                .withRecommendationTypeId("wjzrnfygxgisp")
                                .withSuppressionIds(Arrays.asList())
                                .withExtendedProperties(mapOf())
                                .withDescription("kufubljo")
                                .withLabel("qeof")
                                .withLearnMoreLink("e")
                                .withPotentialBenefits("hqjbasvmsmj")
                                .withActions(Arrays.asList())
                                .withRemediation(mapOf())
                                .withExposedMetadataProperties(mapOf())));
        model = BinaryData.fromObject(model).toObject(ResourceRecommendationBaseListResult.class);
        Assertions.assertEquals("hmsbzjhcrzevdp", model.nextLink());
        Assertions.assertEquals(Category.HIGH_AVAILABILITY, model.value().get(0).category());
        Assertions.assertEquals(Impact.LOW, model.value().get(0).impact());
        Assertions.assertEquals("trg", model.value().get(0).impactedField());
        Assertions.assertEquals("bpf", model.value().get(0).impactedValue());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-22T07:39:39Z"), model.value().get(0).lastUpdated());
        Assertions.assertEquals("zgvfcjrwz", model.value().get(0).recommendationTypeId());
        Assertions.assertEquals("elluwfziton", model.value().get(0).description());
        Assertions.assertEquals("qfpjk", model.value().get(0).label());
        Assertions.assertEquals("xofpdvhpfxxypi", model.value().get(0).learnMoreLink());
        Assertions.assertEquals("nmayhuybb", model.value().get(0).potentialBenefits());
    }

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