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

package com.azure.resourcemanager.redisenterprise.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.redisenterprise.models.AofFrequency;
import com.azure.resourcemanager.redisenterprise.models.Persistence;
import com.azure.resourcemanager.redisenterprise.models.RdbFrequency;
import org.junit.jupiter.api.Assertions;

public final class PersistenceTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        Persistence model =
            BinaryData
                .fromString(
                    "{\"aofEnabled\":true,\"rdbEnabled\":false,\"aofFrequency\":\"always\",\"rdbFrequency\":\"12h\"}")
                .toObject(Persistence.class);
        Assertions.assertEquals(true, model.aofEnabled());
        Assertions.assertEquals(false, model.rdbEnabled());
        Assertions.assertEquals(AofFrequency.ALWAYS, model.aofFrequency());
        Assertions.assertEquals(RdbFrequency.ONE_TWOH, model.rdbFrequency());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        Persistence model =
            new Persistence()
                .withAofEnabled(true)
                .withRdbEnabled(false)
                .withAofFrequency(AofFrequency.ALWAYS)
                .withRdbFrequency(RdbFrequency.ONE_TWOH);
        model = BinaryData.fromObject(model).toObject(Persistence.class);
        Assertions.assertEquals(true, model.aofEnabled());
        Assertions.assertEquals(false, model.rdbEnabled());
        Assertions.assertEquals(AofFrequency.ALWAYS, model.aofFrequency());
        Assertions.assertEquals(RdbFrequency.ONE_TWOH, model.rdbFrequency());
    }
}
