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

package com.azure.resourcemanager.netapp.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.netapp.fluent.models.BackupPolicyInner;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class BackupPolicyInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        BackupPolicyInner model =
            BinaryData
                .fromString(
                    "{\"etag\":\"uhpkxkgymar\",\"properties\":{\"backupPolicyId\":\"n\",\"provisioningState\":\"xqugjhkycubedd\",\"dailyBackupsToKeep\":2056337569,\"weeklyBackupsToKeep\":1063119881,\"monthlyBackupsToKeep\":1853639964,\"volumesAssigned\":1153520576,\"enabled\":false,\"volumeBackups\":[{\"volumeName\":\"mnjijpxacqqudf\",\"backupsCount\":1238431927,\"policyEnabled\":false},{\"volumeName\":\"aabjyvayffimrz\",\"backupsCount\":1007625802,\"policyEnabled\":true},{\"volumeName\":\"gsexne\",\"backupsCount\":779817958,\"policyEnabled\":false},{\"volumeName\":\"wmewzsyy\",\"backupsCount\":1091496648,\"policyEnabled\":true}]},\"location\":\"i\",\"tags\":{\"qbrqubpaxhexiili\":\"dpfrxtrthzvaytdw\"},\"id\":\"pdtii\",\"name\":\"q\",\"type\":\"d\"}")
                .toObject(BackupPolicyInner.class);
        Assertions.assertEquals("i", model.location());
        Assertions.assertEquals("dpfrxtrthzvaytdw", model.tags().get("qbrqubpaxhexiili"));
        Assertions.assertEquals(2056337569, model.dailyBackupsToKeep());
        Assertions.assertEquals(1063119881, model.weeklyBackupsToKeep());
        Assertions.assertEquals(1853639964, model.monthlyBackupsToKeep());
        Assertions.assertEquals(false, model.enabled());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        BackupPolicyInner model =
            new BackupPolicyInner()
                .withLocation("i")
                .withTags(mapOf("qbrqubpaxhexiili", "dpfrxtrthzvaytdw"))
                .withDailyBackupsToKeep(2056337569)
                .withWeeklyBackupsToKeep(1063119881)
                .withMonthlyBackupsToKeep(1853639964)
                .withEnabled(false);
        model = BinaryData.fromObject(model).toObject(BackupPolicyInner.class);
        Assertions.assertEquals("i", model.location());
        Assertions.assertEquals("dpfrxtrthzvaytdw", model.tags().get("qbrqubpaxhexiili"));
        Assertions.assertEquals(2056337569, model.dailyBackupsToKeep());
        Assertions.assertEquals(1063119881, model.weeklyBackupsToKeep());
        Assertions.assertEquals(1853639964, model.monthlyBackupsToKeep());
        Assertions.assertEquals(false, model.enabled());
    }

    @SuppressWarnings("unchecked")
    private static <T> Map<String, T> mapOf(Object... inputs) {
        Map<String, T> map = new HashMap<>();
        for (int i = 0; i < inputs.length; i += 2) {
            String key = (String) inputs[i];
            T value = (T) inputs[i + 1];
            map.put(key, value);
        }
        return map;
    }
}
