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

package com.azure.resourcemanager.resourcehealth.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.resourcehealth.models.EmergingIssueImpact;
import com.azure.resourcemanager.resourcehealth.models.ImpactedRegion;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class EmergingIssueImpactTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        EmergingIssueImpact model =
            BinaryData
                .fromString(
                    "{\"id\":\"fxoblytkb\",\"name\":\"pe\",\"regions\":[{\"id\":\"bkrvrnsvshqj\",\"name\":\"xc\"},{\"id\":\"bfovasrruvwbhsq\",\"name\":\"ubcgjbirxb\"},{\"id\":\"bsrfbj\",\"name\":\"twss\"}]}")
                .toObject(EmergingIssueImpact.class);
        Assertions.assertEquals("fxoblytkb", model.id());
        Assertions.assertEquals("pe", model.name());
        Assertions.assertEquals("bkrvrnsvshqj", model.regions().get(0).id());
        Assertions.assertEquals("xc", model.regions().get(0).name());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        EmergingIssueImpact model =
            new EmergingIssueImpact()
                .withId("fxoblytkb")
                .withName("pe")
                .withRegions(
                    Arrays
                        .asList(
                            new ImpactedRegion().withId("bkrvrnsvshqj").withName("xc"),
                            new ImpactedRegion().withId("bfovasrruvwbhsq").withName("ubcgjbirxb"),
                            new ImpactedRegion().withId("bsrfbj").withName("twss")));
        model = BinaryData.fromObject(model).toObject(EmergingIssueImpact.class);
        Assertions.assertEquals("fxoblytkb", model.id());
        Assertions.assertEquals("pe", model.name());
        Assertions.assertEquals("bkrvrnsvshqj", model.regions().get(0).id());
        Assertions.assertEquals("xc", model.regions().get(0).name());
    }
}
