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

public final class StatusActiveEventTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        StatusActiveEvent model =
            BinaryData
                .fromString(
                    "{\"title\":\"qeqxo\",\"description\":\"dahzxctobg\",\"trackingId\":\"dmoizpostmg\",\"startTime\":\"2021-03-12T03:59:06Z\",\"cloud\":\"unrmfqjhhkxb\",\"severity\":\"Information\",\"stage\":\"Resolve\",\"published\":false,\"lastModifiedTime\":\"2021-07-29T03:03:57Z\",\"impacts\":[{\"id\":\"gudivkrtswbxqz\",\"name\":\"zjf\",\"regions\":[]},{\"id\":\"fdxxivetvtcqaqtd\",\"name\":\"mcbxvwvxysl\",\"regions\":[]}]}")
                .toObject(StatusActiveEvent.class);
        Assertions.assertEquals("qeqxo", model.title());
        Assertions.assertEquals("dahzxctobg", model.description());
        Assertions.assertEquals("dmoizpostmg", model.trackingId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-03-12T03:59:06Z"), model.startTime());
        Assertions.assertEquals("unrmfqjhhkxb", model.cloud());
        Assertions.assertEquals(SeverityValues.INFORMATION, model.severity());
        Assertions.assertEquals(StageValues.RESOLVE, model.stage());
        Assertions.assertEquals(false, model.published());
        Assertions.assertEquals(OffsetDateTime.parse("2021-07-29T03:03:57Z"), model.lastModifiedTime());
        Assertions.assertEquals("gudivkrtswbxqz", model.impacts().get(0).id());
        Assertions.assertEquals("zjf", model.impacts().get(0).name());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        StatusActiveEvent model =
            new StatusActiveEvent()
                .withTitle("qeqxo")
                .withDescription("dahzxctobg")
                .withTrackingId("dmoizpostmg")
                .withStartTime(OffsetDateTime.parse("2021-03-12T03:59:06Z"))
                .withCloud("unrmfqjhhkxb")
                .withSeverity(SeverityValues.INFORMATION)
                .withStage(StageValues.RESOLVE)
                .withPublished(false)
                .withLastModifiedTime(OffsetDateTime.parse("2021-07-29T03:03:57Z"))
                .withImpacts(
                    Arrays
                        .asList(
                            new EmergingIssueImpact()
                                .withId("gudivkrtswbxqz")
                                .withName("zjf")
                                .withRegions(Arrays.asList()),
                            new EmergingIssueImpact()
                                .withId("fdxxivetvtcqaqtd")
                                .withName("mcbxvwvxysl")
                                .withRegions(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(StatusActiveEvent.class);
        Assertions.assertEquals("qeqxo", model.title());
        Assertions.assertEquals("dahzxctobg", model.description());
        Assertions.assertEquals("dmoizpostmg", model.trackingId());
        Assertions.assertEquals(OffsetDateTime.parse("2021-03-12T03:59:06Z"), model.startTime());
        Assertions.assertEquals("unrmfqjhhkxb", model.cloud());
        Assertions.assertEquals(SeverityValues.INFORMATION, model.severity());
        Assertions.assertEquals(StageValues.RESOLVE, model.stage());
        Assertions.assertEquals(false, model.published());
        Assertions.assertEquals(OffsetDateTime.parse("2021-07-29T03:03:57Z"), model.lastModifiedTime());
        Assertions.assertEquals("gudivkrtswbxqz", model.impacts().get(0).id());
        Assertions.assertEquals("zjf", model.impacts().get(0).name());
    }
}
