// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.iothub.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.iothub.fluent.models.TestRouteResultInner;
import com.azure.resourcemanager.iothub.models.RouteCompilationError;
import com.azure.resourcemanager.iothub.models.RouteErrorSeverity;
import com.azure.resourcemanager.iothub.models.TestResultStatus;
import com.azure.resourcemanager.iothub.models.TestRouteResultDetails;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class TestRouteResultInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        TestRouteResultInner model =
            BinaryData
                .fromString(
                    "{\"result\":\"true\",\"details\":{\"compilationErrors\":[{\"message\":\"fgohdneuelfphs\",\"severity\":\"warning\"}]}}")
                .toObject(TestRouteResultInner.class);
        Assertions.assertEquals(TestResultStatus.TRUE, model.result());
        Assertions.assertEquals("fgohdneuelfphs", model.details().compilationErrors().get(0).message());
        Assertions.assertEquals(RouteErrorSeverity.WARNING, model.details().compilationErrors().get(0).severity());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        TestRouteResultInner model =
            new TestRouteResultInner()
                .withResult(TestResultStatus.TRUE)
                .withDetails(
                    new TestRouteResultDetails()
                        .withCompilationErrors(
                            Arrays
                                .asList(
                                    new RouteCompilationError()
                                        .withMessage("fgohdneuelfphs")
                                        .withSeverity(RouteErrorSeverity.WARNING))));
        model = BinaryData.fromObject(model).toObject(TestRouteResultInner.class);
        Assertions.assertEquals(TestResultStatus.TRUE, model.result());
        Assertions.assertEquals("fgohdneuelfphs", model.details().compilationErrors().get(0).message());
        Assertions.assertEquals(RouteErrorSeverity.WARNING, model.details().compilationErrors().get(0).severity());
    }
}
