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

package com.azure.resourcemanager.dataprotection.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.dataprotection.models.CopyOption;
import com.azure.resourcemanager.dataprotection.models.DataStoreInfoBase;
import com.azure.resourcemanager.dataprotection.models.DataStoreTypes;
import com.azure.resourcemanager.dataprotection.models.DeleteOption;
import com.azure.resourcemanager.dataprotection.models.SourceLifeCycle;
import com.azure.resourcemanager.dataprotection.models.TargetCopySetting;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class SourceLifeCycleTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SourceLifeCycle model =
            BinaryData
                .fromString(
                    "{\"deleteAfter\":{\"objectType\":\"DeleteOption\",\"duration\":\"vfvpdbodaciz\"},\"sourceDataStore\":{\"dataStoreType\":\"OperationalStore\",\"objectType\":\"q\"},\"targetDataStoreCopySettings\":[{\"copyAfter\":{\"objectType\":\"CopyOption\"},\"dataStore\":{\"dataStoreType\":\"ArchiveStore\",\"objectType\":\"r\"}},{\"copyAfter\":{\"objectType\":\"CopyOption\"},\"dataStore\":{\"dataStoreType\":\"ArchiveStore\",\"objectType\":\"deibqip\"}},{\"copyAfter\":{\"objectType\":\"CopyOption\"},\"dataStore\":{\"dataStoreType\":\"ArchiveStore\",\"objectType\":\"ghvxndzwmkrefa\"}}]}")
                .toObject(SourceLifeCycle.class);
        Assertions.assertEquals("vfvpdbodaciz", model.deleteAfter().duration());
        Assertions.assertEquals(DataStoreTypes.OPERATIONAL_STORE, model.sourceDataStore().dataStoreType());
        Assertions.assertEquals("q", model.sourceDataStore().objectType());
        Assertions
            .assertEquals(
                DataStoreTypes.ARCHIVE_STORE, model.targetDataStoreCopySettings().get(0).dataStore().dataStoreType());
        Assertions.assertEquals("r", model.targetDataStoreCopySettings().get(0).dataStore().objectType());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SourceLifeCycle model =
            new SourceLifeCycle()
                .withDeleteAfter(new DeleteOption().withDuration("vfvpdbodaciz"))
                .withSourceDataStore(
                    new DataStoreInfoBase().withDataStoreType(DataStoreTypes.OPERATIONAL_STORE).withObjectType("q"))
                .withTargetDataStoreCopySettings(
                    Arrays
                        .asList(
                            new TargetCopySetting()
                                .withCopyAfter(new CopyOption())
                                .withDataStore(
                                    new DataStoreInfoBase()
                                        .withDataStoreType(DataStoreTypes.ARCHIVE_STORE)
                                        .withObjectType("r")),
                            new TargetCopySetting()
                                .withCopyAfter(new CopyOption())
                                .withDataStore(
                                    new DataStoreInfoBase()
                                        .withDataStoreType(DataStoreTypes.ARCHIVE_STORE)
                                        .withObjectType("deibqip")),
                            new TargetCopySetting()
                                .withCopyAfter(new CopyOption())
                                .withDataStore(
                                    new DataStoreInfoBase()
                                        .withDataStoreType(DataStoreTypes.ARCHIVE_STORE)
                                        .withObjectType("ghvxndzwmkrefa"))));
        model = BinaryData.fromObject(model).toObject(SourceLifeCycle.class);
        Assertions.assertEquals("vfvpdbodaciz", model.deleteAfter().duration());
        Assertions.assertEquals(DataStoreTypes.OPERATIONAL_STORE, model.sourceDataStore().dataStoreType());
        Assertions.assertEquals("q", model.sourceDataStore().objectType());
        Assertions
            .assertEquals(
                DataStoreTypes.ARCHIVE_STORE, model.targetDataStoreCopySettings().get(0).dataStore().dataStoreType());
        Assertions.assertEquals("r", model.targetDataStoreCopySettings().get(0).dataStore().objectType());
    }
}
