// 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.fluent.models.AvailabilityStatusInner;
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 java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AvailabilityStatusInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AvailabilityStatusInner model =
            BinaryData
                .fromString(
                    "{\"id\":\"yoqpsoaccta\",\"name\":\"kljla\",\"type\":\"cr\",\"location\":\"fdfdosygexpa\",\"properties\":{\"availabilityState\":\"Unavailable\",\"title\":\"msbzjhcrz\",\"summary\":\"dphlxaolt\",\"detailedStatus\":\"trg\",\"reasonType\":\"bpf\",\"context\":\"s\",\"category\":\"zgvfcjrwz\",\"articleId\":\"xjtfelluwfzit\",\"rootCauseAttributionTime\":\"2021-10-17T22:50:15Z\",\"healthEventType\":\"qfpjk\",\"healthEventCause\":\"xofpdvhpfxxypi\",\"healthEventCategory\":\"nmayhuybb\",\"healthEventId\":\"odepoogin\",\"resolutionETA\":\"2021-04-24T19:55:27Z\",\"occuredTime\":\"2021-11-03T11:27:22Z\",\"reasonChronicity\":\"Persistent\",\"reportedTime\":\"2021-06-18T10:02:36Z\",\"recentlyResolved\":{\"unavailableOccuredTime\":\"2021-11-24T18:41:38Z\",\"resolvedTime\":\"2021-08-23T15:48:59Z\",\"unavailableSummary\":\"theotusiv\"},\"recommendedActions\":[{\"action\":\"ciqihnhung\",\"actionUrl\":\"jzrnf\",\"_ActionUrl.Comment\":\"xgispemvtzfkufu\",\"actionUrlText\":\"jofxqe\"}],\"serviceImpactingEvents\":[{\"eventStartTime\":\"2021-11-09T06:35:40Z\",\"eventStatusLastModifiedTime\":\"2021-11-08T09:04:14Z\",\"correlationId\":\"qjbasvms\"}]}}")
                .toObject(AvailabilityStatusInner.class);
        Assertions.assertEquals("yoqpsoaccta", model.id());
        Assertions.assertEquals("kljla", model.name());
        Assertions.assertEquals("cr", model.type());
        Assertions.assertEquals("fdfdosygexpa", model.location());
        Assertions.assertEquals(AvailabilityStateValues.UNAVAILABLE, model.properties().availabilityState());
        Assertions.assertEquals("msbzjhcrz", model.properties().title());
        Assertions.assertEquals("dphlxaolt", model.properties().summary());
        Assertions.assertEquals("trg", model.properties().detailedStatus());
        Assertions.assertEquals("bpf", model.properties().reasonType());
        Assertions.assertEquals("s", model.properties().context());
        Assertions.assertEquals("zgvfcjrwz", model.properties().category());
        Assertions.assertEquals("xjtfelluwfzit", model.properties().articleId());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-10-17T22:50:15Z"), model.properties().rootCauseAttributionTime());
        Assertions.assertEquals("qfpjk", model.properties().healthEventType());
        Assertions.assertEquals("xofpdvhpfxxypi", model.properties().healthEventCause());
        Assertions.assertEquals("nmayhuybb", model.properties().healthEventCategory());
        Assertions.assertEquals("odepoogin", model.properties().healthEventId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-24T19:55:27Z"), model.properties().resolutionEta());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-03T11:27:22Z"), model.properties().occuredTime());
        Assertions.assertEquals(ReasonChronicityTypes.PERSISTENT, model.properties().reasonChronicity());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-18T10:02:36Z"), model.properties().reportedTime());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-11-24T18:41:38Z"),
                model.properties().recentlyResolved().unavailableOccuredTime());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-08-23T15:48:59Z"), model.properties().recentlyResolved().resolvedTime());
        Assertions.assertEquals("theotusiv", model.properties().recentlyResolved().unavailableSummary());
        Assertions.assertEquals("ciqihnhung", model.properties().recommendedActions().get(0).action());
        Assertions.assertEquals("jzrnf", model.properties().recommendedActions().get(0).actionUrl());
        Assertions.assertEquals("jofxqe", model.properties().recommendedActions().get(0).actionUrlText());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-11-09T06:35:40Z"),
                model.properties().serviceImpactingEvents().get(0).eventStartTime());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-11-08T09:04:14Z"),
                model.properties().serviceImpactingEvents().get(0).eventStatusLastModifiedTime());
        Assertions.assertEquals("qjbasvms", model.properties().serviceImpactingEvents().get(0).correlationId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AvailabilityStatusInner model =
            new AvailabilityStatusInner()
                .withId("yoqpsoaccta")
                .withName("kljla")
                .withType("cr")
                .withLocation("fdfdosygexpa")
                .withProperties(
                    new AvailabilityStatusProperties()
                        .withAvailabilityState(AvailabilityStateValues.UNAVAILABLE)
                        .withTitle("msbzjhcrz")
                        .withSummary("dphlxaolt")
                        .withDetailedStatus("trg")
                        .withReasonType("bpf")
                        .withContext("s")
                        .withCategory("zgvfcjrwz")
                        .withArticleId("xjtfelluwfzit")
                        .withRootCauseAttributionTime(OffsetDateTime.parse("2021-10-17T22:50:15Z"))
                        .withHealthEventType("qfpjk")
                        .withHealthEventCause("xofpdvhpfxxypi")
                        .withHealthEventCategory("nmayhuybb")
                        .withHealthEventId("odepoogin")
                        .withResolutionEta(OffsetDateTime.parse("2021-04-24T19:55:27Z"))
                        .withOccuredTime(OffsetDateTime.parse("2021-11-03T11:27:22Z"))
                        .withReasonChronicity(ReasonChronicityTypes.PERSISTENT)
                        .withReportedTime(OffsetDateTime.parse("2021-06-18T10:02:36Z"))
                        .withRecentlyResolved(
                            new AvailabilityStatusPropertiesRecentlyResolved()
                                .withUnavailableOccuredTime(OffsetDateTime.parse("2021-11-24T18:41:38Z"))
                                .withResolvedTime(OffsetDateTime.parse("2021-08-23T15:48:59Z"))
                                .withUnavailableSummary("theotusiv"))
                        .withRecommendedActions(
                            Arrays
                                .asList(
                                    new RecommendedAction()
                                        .withAction("ciqihnhung")
                                        .withActionUrl("jzrnf")
                                        .withActionUrlText("jofxqe")))
                        .withServiceImpactingEvents(
                            Arrays
                                .asList(
                                    new ServiceImpactingEvent()
                                        .withEventStartTime(OffsetDateTime.parse("2021-11-09T06:35:40Z"))
                                        .withEventStatusLastModifiedTime(OffsetDateTime.parse("2021-11-08T09:04:14Z"))
                                        .withCorrelationId("qjbasvms"))));
        model = BinaryData.fromObject(model).toObject(AvailabilityStatusInner.class);
        Assertions.assertEquals("yoqpsoaccta", model.id());
        Assertions.assertEquals("kljla", model.name());
        Assertions.assertEquals("cr", model.type());
        Assertions.assertEquals("fdfdosygexpa", model.location());
        Assertions.assertEquals(AvailabilityStateValues.UNAVAILABLE, model.properties().availabilityState());
        Assertions.assertEquals("msbzjhcrz", model.properties().title());
        Assertions.assertEquals("dphlxaolt", model.properties().summary());
        Assertions.assertEquals("trg", model.properties().detailedStatus());
        Assertions.assertEquals("bpf", model.properties().reasonType());
        Assertions.assertEquals("s", model.properties().context());
        Assertions.assertEquals("zgvfcjrwz", model.properties().category());
        Assertions.assertEquals("xjtfelluwfzit", model.properties().articleId());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-10-17T22:50:15Z"), model.properties().rootCauseAttributionTime());
        Assertions.assertEquals("qfpjk", model.properties().healthEventType());
        Assertions.assertEquals("xofpdvhpfxxypi", model.properties().healthEventCause());
        Assertions.assertEquals("nmayhuybb", model.properties().healthEventCategory());
        Assertions.assertEquals("odepoogin", model.properties().healthEventId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-04-24T19:55:27Z"), model.properties().resolutionEta());
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-03T11:27:22Z"), model.properties().occuredTime());
        Assertions.assertEquals(ReasonChronicityTypes.PERSISTENT, model.properties().reasonChronicity());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-18T10:02:36Z"), model.properties().reportedTime());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-11-24T18:41:38Z"),
                model.properties().recentlyResolved().unavailableOccuredTime());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-08-23T15:48:59Z"), model.properties().recentlyResolved().resolvedTime());
        Assertions.assertEquals("theotusiv", model.properties().recentlyResolved().unavailableSummary());
        Assertions.assertEquals("ciqihnhung", model.properties().recommendedActions().get(0).action());
        Assertions.assertEquals("jzrnf", model.properties().recommendedActions().get(0).actionUrl());
        Assertions.assertEquals("jofxqe", model.properties().recommendedActions().get(0).actionUrlText());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-11-09T06:35:40Z"),
                model.properties().serviceImpactingEvents().get(0).eventStartTime());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-11-08T09:04:14Z"),
                model.properties().serviceImpactingEvents().get(0).eventStatusLastModifiedTime());
        Assertions.assertEquals("qjbasvms", model.properties().serviceImpactingEvents().get(0).correlationId());
    }
}
