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

package com.azure.resourcemanager.storagecache.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.storagecache.fluent.models.StorageTargetInner;
import com.azure.resourcemanager.storagecache.models.OperationalStateType;
import com.azure.resourcemanager.storagecache.models.StorageTargetType;
import com.azure.resourcemanager.storagecache.models.StorageTargetsResult;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class StorageTargetsResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        StorageTargetsResult model =
            BinaryData
                .fromString(
                    "{\"nextLink\":\"cjefuzmu\",\"value\":[{\"properties\":{\"junctions\":[],\"targetType\":\"nfs3\",\"provisioningState\":\"Canceled\",\"state\":\"Ready\",\"allocationPercentage\":964392835},\"location\":\"zbtbhj\",\"id\":\"lkfg\",\"name\":\"hdneuelfph\",\"type\":\"dyhtozfikdowwquu\"},{\"properties\":{\"junctions\":[],\"targetType\":\"clfs\",\"provisioningState\":\"Succeeded\",\"state\":\"Busy\",\"allocationPercentage\":176578322},\"location\":\"osggbhc\",\"id\":\"fwdsj\",\"name\":\"ka\",\"type\":\"jutiiswacff\"},{\"properties\":{\"junctions\":[],\"targetType\":\"blobNfs\",\"provisioningState\":\"Failed\",\"state\":\"Flushing\",\"allocationPercentage\":875285248},\"location\":\"ilvpnppfuflrwd\",\"id\":\"dlxyjrxs\",\"name\":\"gafcnihgwqapnedg\",\"type\":\"bcvkcvqvpkeq\"}]}")
                .toObject(StorageTargetsResult.class);
        Assertions.assertEquals("cjefuzmu", model.nextLink());
        Assertions.assertEquals(StorageTargetType.NFS3, model.value().get(0).targetType());
        Assertions.assertEquals(OperationalStateType.READY, model.value().get(0).state());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        StorageTargetsResult model =
            new StorageTargetsResult()
                .withNextLink("cjefuzmu")
                .withValue(
                    Arrays
                        .asList(
                            new StorageTargetInner()
                                .withJunctions(Arrays.asList())
                                .withTargetType(StorageTargetType.NFS3)
                                .withState(OperationalStateType.READY),
                            new StorageTargetInner()
                                .withJunctions(Arrays.asList())
                                .withTargetType(StorageTargetType.CLFS)
                                .withState(OperationalStateType.BUSY),
                            new StorageTargetInner()
                                .withJunctions(Arrays.asList())
                                .withTargetType(StorageTargetType.BLOB_NFS)
                                .withState(OperationalStateType.FLUSHING)));
        model = BinaryData.fromObject(model).toObject(StorageTargetsResult.class);
        Assertions.assertEquals("cjefuzmu", model.nextLink());
        Assertions.assertEquals(StorageTargetType.NFS3, model.value().get(0).targetType());
        Assertions.assertEquals(OperationalStateType.READY, model.value().get(0).state());
    }
}
