// 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.ServiceImpactingEvent;
import com.azure.resourcemanager.resourcehealth.models.ServiceImpactingEventIncidentProperties;
import com.azure.resourcemanager.resourcehealth.models.ServiceImpactingEventStatus;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class ServiceImpactingEventTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ServiceImpactingEvent model =
            BinaryData
                .fromString(
                    "{\"eventStartTime\":\"2021-12-06T02:09:40Z\",\"eventStatusLastModifiedTime\":\"2020-12-23T05:46:04Z\",\"correlationId\":\"ysvlejuvf\",\"status\":{\"value\":\"rlyxwjkcprbnw\"},\"incidentProperties\":{\"title\":\"jvtbvpyss\",\"service\":\"nruj\",\"region\":\"uhmuouqfprwzwbn\",\"incidentType\":\"itnwuizgazxufi\"}}")
                .toObject(ServiceImpactingEvent.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-12-06T02:09:40Z"), model.eventStartTime());
        Assertions.assertEquals(OffsetDateTime.parse("2020-12-23T05:46:04Z"), model.eventStatusLastModifiedTime());
        Assertions.assertEquals("ysvlejuvf", model.correlationId());
        Assertions.assertEquals("rlyxwjkcprbnw", model.status().value());
        Assertions.assertEquals("jvtbvpyss", model.incidentProperties().title());
        Assertions.assertEquals("nruj", model.incidentProperties().service());
        Assertions.assertEquals("uhmuouqfprwzwbn", model.incidentProperties().region());
        Assertions.assertEquals("itnwuizgazxufi", model.incidentProperties().incidentType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ServiceImpactingEvent model =
            new ServiceImpactingEvent()
                .withEventStartTime(OffsetDateTime.parse("2021-12-06T02:09:40Z"))
                .withEventStatusLastModifiedTime(OffsetDateTime.parse("2020-12-23T05:46:04Z"))
                .withCorrelationId("ysvlejuvf")
                .withStatus(new ServiceImpactingEventStatus().withValue("rlyxwjkcprbnw"))
                .withIncidentProperties(
                    new ServiceImpactingEventIncidentProperties()
                        .withTitle("jvtbvpyss")
                        .withService("nruj")
                        .withRegion("uhmuouqfprwzwbn")
                        .withIncidentType("itnwuizgazxufi"));
        model = BinaryData.fromObject(model).toObject(ServiceImpactingEvent.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-12-06T02:09:40Z"), model.eventStartTime());
        Assertions.assertEquals(OffsetDateTime.parse("2020-12-23T05:46:04Z"), model.eventStatusLastModifiedTime());
        Assertions.assertEquals("ysvlejuvf", model.correlationId());
        Assertions.assertEquals("rlyxwjkcprbnw", model.status().value());
        Assertions.assertEquals("jvtbvpyss", model.incidentProperties().title());
        Assertions.assertEquals("nruj", model.incidentProperties().service());
        Assertions.assertEquals("uhmuouqfprwzwbn", model.incidentProperties().region());
        Assertions.assertEquals("itnwuizgazxufi", model.incidentProperties().incidentType());
    }
}
