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

package com.azure.resourcemanager.storagepool.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.storagepool.fluent.models.IscsiTargetUpdateProperties;
import com.azure.resourcemanager.storagepool.models.Acl;
import com.azure.resourcemanager.storagepool.models.IscsiLun;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class IscsiTargetUpdatePropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IscsiTargetUpdateProperties model =
            BinaryData
                .fromString(
                    "{\"staticAcls\":[{\"initiatorIqn\":\"vszjfauvjfdxxi\",\"mappedLuns\":[\"tvtc\"]},{\"initiatorIqn\":\"aqtdoqmcbx\",\"mappedLuns\":[\"vxysl\",\"bhsfxob\"]}],\"luns\":[{\"name\":\"k\",\"managedDiskAzureResourceId\":\"lmpewwwfbkr\",\"lun\":910036850},{\"name\":\"svshqjohx\",\"managedDiskAzureResourceId\":\"rsbfovasrruvw\",\"lun\":1393923794},{\"name\":\"qfsubcgjbirx\",\"managedDiskAzureResourceId\":\"pybsrfbjfdtw\",\"lun\":1365200524}]}")
                .toObject(IscsiTargetUpdateProperties.class);
        Assertions.assertEquals("vszjfauvjfdxxi", model.staticAcls().get(0).initiatorIqn());
        Assertions.assertEquals("tvtc", model.staticAcls().get(0).mappedLuns().get(0));
        Assertions.assertEquals("k", model.luns().get(0).name());
        Assertions.assertEquals("lmpewwwfbkr", model.luns().get(0).managedDiskAzureResourceId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IscsiTargetUpdateProperties model =
            new IscsiTargetUpdateProperties()
                .withStaticAcls(
                    Arrays
                        .asList(
                            new Acl().withInitiatorIqn("vszjfauvjfdxxi").withMappedLuns(Arrays.asList("tvtc")),
                            new Acl().withInitiatorIqn("aqtdoqmcbx").withMappedLuns(Arrays.asList("vxysl", "bhsfxob"))))
                .withLuns(
                    Arrays
                        .asList(
                            new IscsiLun().withName("k").withManagedDiskAzureResourceId("lmpewwwfbkr"),
                            new IscsiLun().withName("svshqjohx").withManagedDiskAzureResourceId("rsbfovasrruvw"),
                            new IscsiLun().withName("qfsubcgjbirx").withManagedDiskAzureResourceId("pybsrfbjfdtw")));
        model = BinaryData.fromObject(model).toObject(IscsiTargetUpdateProperties.class);
        Assertions.assertEquals("vszjfauvjfdxxi", model.staticAcls().get(0).initiatorIqn());
        Assertions.assertEquals("tvtc", model.staticAcls().get(0).mappedLuns().get(0));
        Assertions.assertEquals("k", model.luns().get(0).name());
        Assertions.assertEquals("lmpewwwfbkr", model.luns().get(0).managedDiskAzureResourceId());
    }
}
