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

package com.azure.resourcemanager.sqlvirtualmachine.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.sqlvirtualmachine.models.AgReplica;
import com.azure.resourcemanager.sqlvirtualmachine.models.Commit;
import com.azure.resourcemanager.sqlvirtualmachine.models.Failover;
import com.azure.resourcemanager.sqlvirtualmachine.models.ReadableSecondary;
import com.azure.resourcemanager.sqlvirtualmachine.models.Role;
import org.junit.jupiter.api.Assertions;

public final class AgReplicaTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AgReplica model =
            BinaryData
                .fromString(
                    "{\"sqlVirtualMachineInstanceId\":\"akhmsbzjhcrz\",\"role\":\"SECONDARY\",\"commit\":\"ASYNCHRONOUS_COMMIT\",\"failover\":\"AUTOMATIC\",\"readableSecondary\":\"ALL\"}")
                .toObject(AgReplica.class);
        Assertions.assertEquals("akhmsbzjhcrz", model.sqlVirtualMachineInstanceId());
        Assertions.assertEquals(Role.SECONDARY, model.role());
        Assertions.assertEquals(Commit.ASYNCHRONOUS_COMMIT, model.commit());
        Assertions.assertEquals(Failover.AUTOMATIC, model.failover());
        Assertions.assertEquals(ReadableSecondary.ALL, model.readableSecondary());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AgReplica model =
            new AgReplica()
                .withSqlVirtualMachineInstanceId("akhmsbzjhcrz")
                .withRole(Role.SECONDARY)
                .withCommit(Commit.ASYNCHRONOUS_COMMIT)
                .withFailover(Failover.AUTOMATIC)
                .withReadableSecondary(ReadableSecondary.ALL);
        model = BinaryData.fromObject(model).toObject(AgReplica.class);
        Assertions.assertEquals("akhmsbzjhcrz", model.sqlVirtualMachineInstanceId());
        Assertions.assertEquals(Role.SECONDARY, model.role());
        Assertions.assertEquals(Commit.ASYNCHRONOUS_COMMIT, model.commit());
        Assertions.assertEquals(Failover.AUTOMATIC, model.failover());
        Assertions.assertEquals(ReadableSecondary.ALL, model.readableSecondary());
    }
}
