// 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.models.RouteCompilationError;
import com.azure.resourcemanager.iothub.models.RouteErrorPosition;
import com.azure.resourcemanager.iothub.models.RouteErrorRange;
import com.azure.resourcemanager.iothub.models.RouteErrorSeverity;
import org.junit.jupiter.api.Assertions;

public final class RouteCompilationErrorTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RouteCompilationError model =
            BinaryData
                .fromString(
                    "{\"message\":\"dsjnka\",\"severity\":\"warning\",\"location\":{\"start\":{\"line\":600848345,\"column\":1914741160},\"end\":{\"line\":1975902978,\"column\":2043531661}}}")
                .toObject(RouteCompilationError.class);
        Assertions.assertEquals("dsjnka", model.message());
        Assertions.assertEquals(RouteErrorSeverity.WARNING, model.severity());
        Assertions.assertEquals(600848345, model.location().start().line());
        Assertions.assertEquals(1914741160, model.location().start().column());
        Assertions.assertEquals(1975902978, model.location().end().line());
        Assertions.assertEquals(2043531661, model.location().end().column());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RouteCompilationError model =
            new RouteCompilationError()
                .withMessage("dsjnka")
                .withSeverity(RouteErrorSeverity.WARNING)
                .withLocation(
                    new RouteErrorRange()
                        .withStart(new RouteErrorPosition().withLine(600848345).withColumn(1914741160))
                        .withEnd(new RouteErrorPosition().withLine(1975902978).withColumn(2043531661)));
        model = BinaryData.fromObject(model).toObject(RouteCompilationError.class);
        Assertions.assertEquals("dsjnka", model.message());
        Assertions.assertEquals(RouteErrorSeverity.WARNING, model.severity());
        Assertions.assertEquals(600848345, model.location().start().line());
        Assertions.assertEquals(1914741160, model.location().start().column());
        Assertions.assertEquals(1975902978, model.location().end().line());
        Assertions.assertEquals(2043531661, model.location().end().column());
    }
}
