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

package com.azure.resourcemanager.mariadb.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.mariadb.models.TopQueryStatisticsInput;
import java.time.OffsetDateTime;
import org.junit.jupiter.api.Assertions;

public final class TopQueryStatisticsInputTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        TopQueryStatisticsInput model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"numberOfTopQueries\":338198941,\"aggregationFunction\":\"uosvmkfssxqukk\",\"observedMetric\":\"plgmgsxnk\",\"observationStartTime\":\"2021-10-15T20:07:23Z\",\"observationEndTime\":\"2021-07-28T04:14:11Z\",\"aggregationWindow\":\"deslp\"}}")
                .toObject(TopQueryStatisticsInput.class);
        Assertions.assertEquals(338198941, model.numberOfTopQueries());
        Assertions.assertEquals("uosvmkfssxqukk", model.aggregationFunction());
        Assertions.assertEquals("plgmgsxnk", model.observedMetric());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-15T20:07:23Z"), model.observationStartTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-07-28T04:14:11Z"), model.observationEndTime());
        Assertions.assertEquals("deslp", model.aggregationWindow());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        TopQueryStatisticsInput model =
            new TopQueryStatisticsInput()
                .withNumberOfTopQueries(338198941)
                .withAggregationFunction("uosvmkfssxqukk")
                .withObservedMetric("plgmgsxnk")
                .withObservationStartTime(OffsetDateTime.parse("2021-10-15T20:07:23Z"))
                .withObservationEndTime(OffsetDateTime.parse("2021-07-28T04:14:11Z"))
                .withAggregationWindow("deslp");
        model = BinaryData.fromObject(model).toObject(TopQueryStatisticsInput.class);
        Assertions.assertEquals(338198941, model.numberOfTopQueries());
        Assertions.assertEquals("uosvmkfssxqukk", model.aggregationFunction());
        Assertions.assertEquals("plgmgsxnk", model.observedMetric());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-15T20:07:23Z"), model.observationStartTime());
        Assertions.assertEquals(OffsetDateTime.parse("2021-07-28T04:14:11Z"), model.observationEndTime());
        Assertions.assertEquals("deslp", model.aggregationWindow());
    }
}
