// 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.EmergingIssue;
import com.azure.resourcemanager.resourcehealth.models.SeverityValues;
import com.azure.resourcemanager.resourcehealth.models.StageValues;
import com.azure.resourcemanager.resourcehealth.models.StatusActiveEvent;
import com.azure.resourcemanager.resourcehealth.models.StatusBanner;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class EmergingIssueTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        EmergingIssue model =
            BinaryData
                .fromString(
                    "{\"refreshTimestamp\":\"2021-11-26T08:31:17Z\",\"statusBanners\":[{\"title\":\"umveekgpwozuhkf\",\"message\":\"sjyofdx\",\"cloud\":\"us\",\"lastModifiedTime\":\"2021-04-08T00:20:33Z\"},{\"title\":\"uwaboekqvke\",\"message\":\"smv\",\"cloud\":\"wyjsflhhcaalnjix\",\"lastModifiedTime\":\"2021-07-17T12:41:40Z\"},{\"title\":\"awjoyaqcslyjp\",\"message\":\"idzyexznelixhnr\",\"cloud\":\"folhbnxknal\",\"lastModifiedTime\":\"2021-06-16T03:28:56Z\"}],\"statusActiveEvents\":[{\"title\":\"gdtpnapnyiro\",\"description\":\"hpigv\",\"trackingId\":\"ylgqgitxmedjvcsl\",\"startTime\":\"2021-02-07T09:50:45Z\",\"cloud\":\"wncwzzhxgktrmg\",\"severity\":\"Error\",\"stage\":\"Resolve\",\"published\":false,\"lastModifiedTime\":\"2021-10-09T08:24:24Z\",\"impacts\":[]}]}")
                .toObject(EmergingIssue.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-26T08:31:17Z"), model.refreshTimestamp());
        Assertions.assertEquals("umveekgpwozuhkf", model.statusBanners().get(0).title());
        Assertions.assertEquals("sjyofdx", model.statusBanners().get(0).message());
        Assertions.assertEquals("us", model.statusBanners().get(0).cloud());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-04-08T00:20:33Z"), model.statusBanners().get(0).lastModifiedTime());
        Assertions.assertEquals("gdtpnapnyiro", model.statusActiveEvents().get(0).title());
        Assertions.assertEquals("hpigv", model.statusActiveEvents().get(0).description());
        Assertions.assertEquals("ylgqgitxmedjvcsl", model.statusActiveEvents().get(0).trackingId());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-02-07T09:50:45Z"), model.statusActiveEvents().get(0).startTime());
        Assertions.assertEquals("wncwzzhxgktrmg", model.statusActiveEvents().get(0).cloud());
        Assertions.assertEquals(SeverityValues.ERROR, model.statusActiveEvents().get(0).severity());
        Assertions.assertEquals(StageValues.RESOLVE, model.statusActiveEvents().get(0).stage());
        Assertions.assertEquals(false, model.statusActiveEvents().get(0).published());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-10-09T08:24:24Z"), model.statusActiveEvents().get(0).lastModifiedTime());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        EmergingIssue model =
            new EmergingIssue()
                .withRefreshTimestamp(OffsetDateTime.parse("2021-11-26T08:31:17Z"))
                .withStatusBanners(
                    Arrays
                        .asList(
                            new StatusBanner()
                                .withTitle("umveekgpwozuhkf")
                                .withMessage("sjyofdx")
                                .withCloud("us")
                                .withLastModifiedTime(OffsetDateTime.parse("2021-04-08T00:20:33Z")),
                            new StatusBanner()
                                .withTitle("uwaboekqvke")
                                .withMessage("smv")
                                .withCloud("wyjsflhhcaalnjix")
                                .withLastModifiedTime(OffsetDateTime.parse("2021-07-17T12:41:40Z")),
                            new StatusBanner()
                                .withTitle("awjoyaqcslyjp")
                                .withMessage("idzyexznelixhnr")
                                .withCloud("folhbnxknal")
                                .withLastModifiedTime(OffsetDateTime.parse("2021-06-16T03:28:56Z"))))
                .withStatusActiveEvents(
                    Arrays
                        .asList(
                            new StatusActiveEvent()
                                .withTitle("gdtpnapnyiro")
                                .withDescription("hpigv")
                                .withTrackingId("ylgqgitxmedjvcsl")
                                .withStartTime(OffsetDateTime.parse("2021-02-07T09:50:45Z"))
                                .withCloud("wncwzzhxgktrmg")
                                .withSeverity(SeverityValues.ERROR)
                                .withStage(StageValues.RESOLVE)
                                .withPublished(false)
                                .withLastModifiedTime(OffsetDateTime.parse("2021-10-09T08:24:24Z"))
                                .withImpacts(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(EmergingIssue.class);
        Assertions.assertEquals(OffsetDateTime.parse("2021-11-26T08:31:17Z"), model.refreshTimestamp());
        Assertions.assertEquals("umveekgpwozuhkf", model.statusBanners().get(0).title());
        Assertions.assertEquals("sjyofdx", model.statusBanners().get(0).message());
        Assertions.assertEquals("us", model.statusBanners().get(0).cloud());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-04-08T00:20:33Z"), model.statusBanners().get(0).lastModifiedTime());
        Assertions.assertEquals("gdtpnapnyiro", model.statusActiveEvents().get(0).title());
        Assertions.assertEquals("hpigv", model.statusActiveEvents().get(0).description());
        Assertions.assertEquals("ylgqgitxmedjvcsl", model.statusActiveEvents().get(0).trackingId());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-02-07T09:50:45Z"), model.statusActiveEvents().get(0).startTime());
        Assertions.assertEquals("wncwzzhxgktrmg", model.statusActiveEvents().get(0).cloud());
        Assertions.assertEquals(SeverityValues.ERROR, model.statusActiveEvents().get(0).severity());
        Assertions.assertEquals(StageValues.RESOLVE, model.statusActiveEvents().get(0).stage());
        Assertions.assertEquals(false, model.statusActiveEvents().get(0).published());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-10-09T08:24:24Z"), model.statusActiveEvents().get(0).lastModifiedTime());
    }
}
