// 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.AvailabilityStateValues;
import com.azure.resourcemanager.resourcehealth.models.AvailabilityStatusProperties;
import com.azure.resourcemanager.resourcehealth.models.AvailabilityStatusPropertiesRecentlyResolved;
import com.azure.resourcemanager.resourcehealth.models.ReasonChronicityTypes;
import com.azure.resourcemanager.resourcehealth.models.RecommendedAction;
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 java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AvailabilityStatusPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AvailabilityStatusProperties model =
            BinaryData
                .fromString(
                    "{\"availabilityState\":\"Unknown\",\"title\":\"gsntnbybkzgcwr\",\"summary\":\"lxxwrljdouskc\",\"detailedStatus\":\"kocrcjdkwtnhx\",\"reasonType\":\"jbiksqrglssai\",\"context\":\"p\",\"category\":\"nzl\",\"articleId\":\"fmppe\",\"rootCauseAttributionTime\":\"2021-03-28T22:28:31Z\",\"healthEventType\":\"gxsabkyq\",\"healthEventCause\":\"ujitcjcz\",\"healthEventCategory\":\"evndh\",\"healthEventId\":\"wpdappdsbdkv\",\"resolutionETA\":\"2021-04-24T00:01:09Z\",\"occuredTime\":\"2021-01-30T07:52:01Z\",\"reasonChronicity\":\"Transient\",\"reportedTime\":\"2021-06-21T23:42:54Z\",\"recentlyResolved\":{\"unavailableOccuredTime\":\"2021-01-02T14:30:26Z\",\"resolvedTime\":\"2021-05-06T05:05:41Z\",\"unavailableSummary\":\"tmrldhugjzzdatq\"},\"recommendedActions\":[{\"action\":\"dgeablgphu\",\"actionUrl\":\"cndvkaozwyiftyhx\",\"_ActionUrl.Comment\":\"rokft\",\"actionUrlText\":\"olniwpwcukjf\"}],\"serviceImpactingEvents\":[{\"eventStartTime\":\"2021-03-19T13:58:34Z\",\"eventStatusLastModifiedTime\":\"2021-01-09T05:37:53Z\",\"correlationId\":\"ryplwckbasyypn\",\"status\":{\"value\":\"sgcbac\"},\"incidentProperties\":{\"title\":\"jkot\",\"service\":\"qgoulznd\",\"region\":\"kwy\",\"incidentType\":\"gfgibm\"}},{\"eventStartTime\":\"2021-02-11T14:34:51Z\",\"eventStatusLastModifiedTime\":\"2021-09-02T02:02:12Z\",\"correlationId\":\"qsrxybzqqed\",\"status\":{\"value\":\"bciqfouflm\"},\"incidentProperties\":{\"title\":\"zsm\",\"service\":\"mglougpbkw\",\"region\":\"utduqktapspwgcu\",\"incidentType\":\"tumkdosvqwhbm\"}}]}")
                .toObject(AvailabilityStatusProperties.class);
        Assertions.assertEquals(AvailabilityStateValues.UNKNOWN, model.availabilityState());
        Assertions.assertEquals("gsntnbybkzgcwr", model.title());
        Assertions.assertEquals("lxxwrljdouskc", model.summary());
        Assertions.assertEquals("kocrcjdkwtnhx", model.detailedStatus());
        Assertions.assertEquals("jbiksqrglssai", model.reasonType());
        Assertions.assertEquals("p", model.context());
        Assertions.assertEquals("nzl", model.category());
        Assertions.assertEquals("fmppe", model.articleId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-03-28T22:28:31Z"), model.rootCauseAttributionTime());
        Assertions.assertEquals("gxsabkyq", model.healthEventType());
        Assertions.assertEquals("ujitcjcz", model.healthEventCause());
        Assertions.assertEquals("evndh", model.healthEventCategory());
        Assertions.assertEquals("wpdappdsbdkv", model.healthEventId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-24T00:01:09Z"), model.resolutionEta());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-30T07:52:01Z"), model.occuredTime());
        Assertions.assertEquals(ReasonChronicityTypes.TRANSIENT, model.reasonChronicity());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-21T23:42:54Z"), model.reportedTime());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-01-02T14:30:26Z"), model.recentlyResolved().unavailableOccuredTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-06T05:05:41Z"), model.recentlyResolved().resolvedTime());
        Assertions.assertEquals("tmrldhugjzzdatq", model.recentlyResolved().unavailableSummary());
        Assertions.assertEquals("dgeablgphu", model.recommendedActions().get(0).action());
        Assertions.assertEquals("cndvkaozwyiftyhx", model.recommendedActions().get(0).actionUrl());
        Assertions.assertEquals("olniwpwcukjf", model.recommendedActions().get(0).actionUrlText());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-03-19T13:58:34Z"), model.serviceImpactingEvents().get(0).eventStartTime());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-01-09T05:37:53Z"),
                model.serviceImpactingEvents().get(0).eventStatusLastModifiedTime());
        Assertions.assertEquals("ryplwckbasyypn", model.serviceImpactingEvents().get(0).correlationId());
        Assertions.assertEquals("sgcbac", model.serviceImpactingEvents().get(0).status().value());
        Assertions.assertEquals("jkot", model.serviceImpactingEvents().get(0).incidentProperties().title());
        Assertions.assertEquals("qgoulznd", model.serviceImpactingEvents().get(0).incidentProperties().service());
        Assertions.assertEquals("kwy", model.serviceImpactingEvents().get(0).incidentProperties().region());
        Assertions.assertEquals("gfgibm", model.serviceImpactingEvents().get(0).incidentProperties().incidentType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AvailabilityStatusProperties model =
            new AvailabilityStatusProperties()
                .withAvailabilityState(AvailabilityStateValues.UNKNOWN)
                .withTitle("gsntnbybkzgcwr")
                .withSummary("lxxwrljdouskc")
                .withDetailedStatus("kocrcjdkwtnhx")
                .withReasonType("jbiksqrglssai")
                .withContext("p")
                .withCategory("nzl")
                .withArticleId("fmppe")
                .withRootCauseAttributionTime(OffsetDateTime.parse("2021-03-28T22:28:31Z"))
                .withHealthEventType("gxsabkyq")
                .withHealthEventCause("ujitcjcz")
                .withHealthEventCategory("evndh")
                .withHealthEventId("wpdappdsbdkv")
                .withResolutionEta(OffsetDateTime.parse("2021-04-24T00:01:09Z"))
                .withOccuredTime(OffsetDateTime.parse("2021-01-30T07:52:01Z"))
                .withReasonChronicity(ReasonChronicityTypes.TRANSIENT)
                .withReportedTime(OffsetDateTime.parse("2021-06-21T23:42:54Z"))
                .withRecentlyResolved(
                    new AvailabilityStatusPropertiesRecentlyResolved()
                        .withUnavailableOccuredTime(OffsetDateTime.parse("2021-01-02T14:30:26Z"))
                        .withResolvedTime(OffsetDateTime.parse("2021-05-06T05:05:41Z"))
                        .withUnavailableSummary("tmrldhugjzzdatq"))
                .withRecommendedActions(
                    Arrays
                        .asList(
                            new RecommendedAction()
                                .withAction("dgeablgphu")
                                .withActionUrl("cndvkaozwyiftyhx")
                                .withActionUrlText("olniwpwcukjf")))
                .withServiceImpactingEvents(
                    Arrays
                        .asList(
                            new ServiceImpactingEvent()
                                .withEventStartTime(OffsetDateTime.parse("2021-03-19T13:58:34Z"))
                                .withEventStatusLastModifiedTime(OffsetDateTime.parse("2021-01-09T05:37:53Z"))
                                .withCorrelationId("ryplwckbasyypn")
                                .withStatus(new ServiceImpactingEventStatus().withValue("sgcbac"))
                                .withIncidentProperties(
                                    new ServiceImpactingEventIncidentProperties()
                                        .withTitle("jkot")
                                        .withService("qgoulznd")
                                        .withRegion("kwy")
                                        .withIncidentType("gfgibm")),
                            new ServiceImpactingEvent()
                                .withEventStartTime(OffsetDateTime.parse("2021-02-11T14:34:51Z"))
                                .withEventStatusLastModifiedTime(OffsetDateTime.parse("2021-09-02T02:02:12Z"))
                                .withCorrelationId("qsrxybzqqed")
                                .withStatus(new ServiceImpactingEventStatus().withValue("bciqfouflm"))
                                .withIncidentProperties(
                                    new ServiceImpactingEventIncidentProperties()
                                        .withTitle("zsm")
                                        .withService("mglougpbkw")
                                        .withRegion("utduqktapspwgcu")
                                        .withIncidentType("tumkdosvqwhbm"))));
        model = BinaryData.fromObject(model).toObject(AvailabilityStatusProperties.class);
        Assertions.assertEquals(AvailabilityStateValues.UNKNOWN, model.availabilityState());
        Assertions.assertEquals("gsntnbybkzgcwr", model.title());
        Assertions.assertEquals("lxxwrljdouskc", model.summary());
        Assertions.assertEquals("kocrcjdkwtnhx", model.detailedStatus());
        Assertions.assertEquals("jbiksqrglssai", model.reasonType());
        Assertions.assertEquals("p", model.context());
        Assertions.assertEquals("nzl", model.category());
        Assertions.assertEquals("fmppe", model.articleId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-03-28T22:28:31Z"), model.rootCauseAttributionTime());
        Assertions.assertEquals("gxsabkyq", model.healthEventType());
        Assertions.assertEquals("ujitcjcz", model.healthEventCause());
        Assertions.assertEquals("evndh", model.healthEventCategory());
        Assertions.assertEquals("wpdappdsbdkv", model.healthEventId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-24T00:01:09Z"), model.resolutionEta());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-30T07:52:01Z"), model.occuredTime());
        Assertions.assertEquals(ReasonChronicityTypes.TRANSIENT, model.reasonChronicity());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-21T23:42:54Z"), model.reportedTime());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-01-02T14:30:26Z"), model.recentlyResolved().unavailableOccuredTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-06T05:05:41Z"), model.recentlyResolved().resolvedTime());
        Assertions.assertEquals("tmrldhugjzzdatq", model.recentlyResolved().unavailableSummary());
        Assertions.assertEquals("dgeablgphu", model.recommendedActions().get(0).action());
        Assertions.assertEquals("cndvkaozwyiftyhx", model.recommendedActions().get(0).actionUrl());
        Assertions.assertEquals("olniwpwcukjf", model.recommendedActions().get(0).actionUrlText());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-03-19T13:58:34Z"), model.serviceImpactingEvents().get(0).eventStartTime());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-01-09T05:37:53Z"),
                model.serviceImpactingEvents().get(0).eventStatusLastModifiedTime());
        Assertions.assertEquals("ryplwckbasyypn", model.serviceImpactingEvents().get(0).correlationId());
        Assertions.assertEquals("sgcbac", model.serviceImpactingEvents().get(0).status().value());
        Assertions.assertEquals("jkot", model.serviceImpactingEvents().get(0).incidentProperties().title());
        Assertions.assertEquals("qgoulznd", model.serviceImpactingEvents().get(0).incidentProperties().service());
        Assertions.assertEquals("kwy", model.serviceImpactingEvents().get(0).incidentProperties().region());
        Assertions.assertEquals("gfgibm", model.serviceImpactingEvents().get(0).incidentProperties().incidentType());
    }
}
