// 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.EventStatusValues;
import com.azure.resourcemanager.resourcehealth.models.ImpactedServiceRegion;
import com.azure.resourcemanager.resourcehealth.models.Update;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ImpactedServiceRegionTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ImpactedServiceRegion model =
            BinaryData
                .fromString(
                    "{\"impactedRegion\":\"wpn\",\"status\":\"Active\",\"impactedSubscriptions\":[\"nermcl\",\"plpho\",\"uscrpabgyepsb\",\"tazqugxywpmueefj\"],\"impactedTenants\":[\"qkqujidsu\",\"onobglaocqx\"],\"lastUpdateTime\":\"2021-08-26T18:25:08Z\",\"updates\":[{\"summary\":\"udxytlmoyrx\",\"updateDateTime\":\"2021-08-04T10:24:08Z\"}]}")
                .toObject(ImpactedServiceRegion.class);
        Assertions.assertEquals("wpn", model.impactedRegion());
        Assertions.assertEquals(EventStatusValues.ACTIVE, model.status());
        Assertions.assertEquals("nermcl", model.impactedSubscriptions().get(0));
        Assertions.assertEquals("qkqujidsu", model.impactedTenants().get(0));
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-26T18:25:08Z"), model.lastUpdateTime());
        Assertions.assertEquals("udxytlmoyrx", model.updates().get(0).summary());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-04T10:24:08Z"), model.updates().get(0).updateDateTime());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ImpactedServiceRegion model =
            new ImpactedServiceRegion()
                .withImpactedRegion("wpn")
                .withStatus(EventStatusValues.ACTIVE)
                .withImpactedSubscriptions(Arrays.asList("nermcl", "plpho", "uscrpabgyepsb", "tazqugxywpmueefj"))
                .withImpactedTenants(Arrays.asList("qkqujidsu", "onobglaocqx"))
                .withLastUpdateTime(OffsetDateTime.parse("2021-08-26T18:25:08Z"))
                .withUpdates(
                    Arrays
                        .asList(
                            new Update()
                                .withSummary("udxytlmoyrx")
                                .withUpdateDateTime(OffsetDateTime.parse("2021-08-04T10:24:08Z"))));
        model = BinaryData.fromObject(model).toObject(ImpactedServiceRegion.class);
        Assertions.assertEquals("wpn", model.impactedRegion());
        Assertions.assertEquals(EventStatusValues.ACTIVE, model.status());
        Assertions.assertEquals("nermcl", model.impactedSubscriptions().get(0));
        Assertions.assertEquals("qkqujidsu", model.impactedTenants().get(0));
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-26T18:25:08Z"), model.lastUpdateTime());
        Assertions.assertEquals("udxytlmoyrx", model.updates().get(0).summary());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-04T10:24:08Z"), model.updates().get(0).updateDateTime());
    }
}
