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

package com.azure.resourcemanager.recoveryservicesbackup.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.recoveryservicesbackup.models.DpmProtectedItemExtendedInfo;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class DpmProtectedItemExtendedInfoTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        DpmProtectedItemExtendedInfo model =
            BinaryData
                .fromString(
                    "{\"protectableObjectLoadPath\":{\"pttaqutd\":\"jgicgaao\",\"gehkfkimrtixokff\":\"wemxswvruunzz\",\"qwhix\":\"yinljqe\"},\"protected\":false,\"isPresentOnCloud\":false,\"lastBackupStatus\":\"hiyxgvelfclduc\",\"lastRefreshedAt\":\"2021-06-28T02:53:43Z\",\"oldestRecoveryPoint\":\"2020-12-30T21:40:21Z\",\"recoveryPointCount\":1691245829,\"onPremiseOldestRecoveryPoint\":\"2021-01-25T09:33:02Z\",\"onPremiseLatestRecoveryPoint\":\"2021-02-26T01:35:32Z\",\"onPremiseRecoveryPointCount\":1517477938,\"isCollocated\":true,\"protectionGroupName\":\"tmninw\",\"diskStorageUsedInBytes\":\"zcilnghg\",\"totalDiskStorageSizeInBytes\":\"ejjtbxqmul\"}")
                .toObject(DpmProtectedItemExtendedInfo.class);
        Assertions.assertEquals("jgicgaao", model.protectableObjectLoadPath().get("pttaqutd"));
        Assertions.assertEquals(false, model.protectedProperty());
        Assertions.assertEquals(false, model.isPresentOnCloud());
        Assertions.assertEquals("hiyxgvelfclduc", model.lastBackupStatus());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-28T02:53:43Z"), model.lastRefreshedAt());
        Assertions.assertEquals(OffsetDateTime.parse("2020-12-30T21:40:21Z"), model.oldestRecoveryPoint());
        Assertions.assertEquals(1691245829, model.recoveryPointCount());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-25T09:33:02Z"), model.onPremiseOldestRecoveryPoint());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-26T01:35:32Z"), model.onPremiseLatestRecoveryPoint());
        Assertions.assertEquals(1517477938, model.onPremiseRecoveryPointCount());
        Assertions.assertEquals(true, model.isCollocated());
        Assertions.assertEquals("tmninw", model.protectionGroupName());
        Assertions.assertEquals("zcilnghg", model.diskStorageUsedInBytes());
        Assertions.assertEquals("ejjtbxqmul", model.totalDiskStorageSizeInBytes());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        DpmProtectedItemExtendedInfo model =
            new DpmProtectedItemExtendedInfo()
                .withProtectableObjectLoadPath(
                    mapOf("pttaqutd", "jgicgaao", "gehkfkimrtixokff", "wemxswvruunzz", "qwhix", "yinljqe"))
                .withProtectedProperty(false)
                .withIsPresentOnCloud(false)
                .withLastBackupStatus("hiyxgvelfclduc")
                .withLastRefreshedAt(OffsetDateTime.parse("2021-06-28T02:53:43Z"))
                .withOldestRecoveryPoint(OffsetDateTime.parse("2020-12-30T21:40:21Z"))
                .withRecoveryPointCount(1691245829)
                .withOnPremiseOldestRecoveryPoint(OffsetDateTime.parse("2021-01-25T09:33:02Z"))
                .withOnPremiseLatestRecoveryPoint(OffsetDateTime.parse("2021-02-26T01:35:32Z"))
                .withOnPremiseRecoveryPointCount(1517477938)
                .withIsCollocated(true)
                .withProtectionGroupName("tmninw")
                .withDiskStorageUsedInBytes("zcilnghg")
                .withTotalDiskStorageSizeInBytes("ejjtbxqmul");
        model = BinaryData.fromObject(model).toObject(DpmProtectedItemExtendedInfo.class);
        Assertions.assertEquals("jgicgaao", model.protectableObjectLoadPath().get("pttaqutd"));
        Assertions.assertEquals(false, model.protectedProperty());
        Assertions.assertEquals(false, model.isPresentOnCloud());
        Assertions.assertEquals("hiyxgvelfclduc", model.lastBackupStatus());
        Assertions.assertEquals(OffsetDateTime.parse("2021-06-28T02:53:43Z"), model.lastRefreshedAt());
        Assertions.assertEquals(OffsetDateTime.parse("2020-12-30T21:40:21Z"), model.oldestRecoveryPoint());
        Assertions.assertEquals(1691245829, model.recoveryPointCount());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-25T09:33:02Z"), model.onPremiseOldestRecoveryPoint());
        Assertions.assertEquals(OffsetDateTime.parse("2021-02-26T01:35:32Z"), model.onPremiseLatestRecoveryPoint());
        Assertions.assertEquals(1517477938, model.onPremiseRecoveryPointCount());
        Assertions.assertEquals(true, model.isCollocated());
        Assertions.assertEquals("tmninw", model.protectionGroupName());
        Assertions.assertEquals("zcilnghg", model.diskStorageUsedInBytes());
        Assertions.assertEquals("ejjtbxqmul", model.totalDiskStorageSizeInBytes());
    }

    @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;
    }
}
