// 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.IscsiTargetProperties;
import com.azure.resourcemanager.storagepool.models.Acl;
import com.azure.resourcemanager.storagepool.models.IscsiLun;
import com.azure.resourcemanager.storagepool.models.IscsiTargetAclMode;
import com.azure.resourcemanager.storagepool.models.OperationalStatus;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class IscsiTargetPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IscsiTargetProperties model =
            BinaryData
                .fromString(
                    "{\"aclMode\":\"Dynamic\",\"staticAcls\":[{\"initiatorIqn\":\"ualaexqpvfadmw\",\"mappedLuns\":[\"crgvxpvgom\",\"lf\"]},{\"initiatorIqn\":\"isgwbnbbeldawkz\",\"mappedLuns\":[\"liourqhak\"]}],\"luns\":[{\"name\":\"ashsfwxos\",\"managedDiskAzureResourceId\":\"w\",\"lun\":38783234},{\"name\":\"ugicjooxdjebw\",\"managedDiskAzureResourceId\":\"ucww\",\"lun\":676959366},{\"name\":\"vbvmeu\",\"managedDiskAzureResourceId\":\"civyhzceuo\",\"lun\":745513484}],\"targetIqn\":\"rw\",\"provisioningState\":\"Creating\",\"status\":\"Running\",\"endpoints\":[\"twm\",\"dytdxwitx\"],\"port\":1725876914,\"sessions\":[\"gqwgxhniskxfbkp\",\"cg\"]}")
                .toObject(IscsiTargetProperties.class);
        Assertions.assertEquals(IscsiTargetAclMode.DYNAMIC, model.aclMode());
        Assertions.assertEquals("ualaexqpvfadmw", model.staticAcls().get(0).initiatorIqn());
        Assertions.assertEquals("crgvxpvgom", model.staticAcls().get(0).mappedLuns().get(0));
        Assertions.assertEquals("ashsfwxos", model.luns().get(0).name());
        Assertions.assertEquals("w", model.luns().get(0).managedDiskAzureResourceId());
        Assertions.assertEquals("rw", model.targetIqn());
        Assertions.assertEquals(OperationalStatus.RUNNING, model.status());
        Assertions.assertEquals("twm", model.endpoints().get(0));
        Assertions.assertEquals(1725876914, model.port());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IscsiTargetProperties model =
            new IscsiTargetProperties()
                .withAclMode(IscsiTargetAclMode.DYNAMIC)
                .withStaticAcls(
                    Arrays
                        .asList(
                            new Acl()
                                .withInitiatorIqn("ualaexqpvfadmw")
                                .withMappedLuns(Arrays.asList("crgvxpvgom", "lf")),
                            new Acl().withInitiatorIqn("isgwbnbbeldawkz").withMappedLuns(Arrays.asList("liourqhak"))))
                .withLuns(
                    Arrays
                        .asList(
                            new IscsiLun().withName("ashsfwxos").withManagedDiskAzureResourceId("w"),
                            new IscsiLun().withName("ugicjooxdjebw").withManagedDiskAzureResourceId("ucww"),
                            new IscsiLun().withName("vbvmeu").withManagedDiskAzureResourceId("civyhzceuo")))
                .withTargetIqn("rw")
                .withStatus(OperationalStatus.RUNNING)
                .withEndpoints(Arrays.asList("twm", "dytdxwitx"))
                .withPort(1725876914);
        model = BinaryData.fromObject(model).toObject(IscsiTargetProperties.class);
        Assertions.assertEquals(IscsiTargetAclMode.DYNAMIC, model.aclMode());
        Assertions.assertEquals("ualaexqpvfadmw", model.staticAcls().get(0).initiatorIqn());
        Assertions.assertEquals("crgvxpvgom", model.staticAcls().get(0).mappedLuns().get(0));
        Assertions.assertEquals("ashsfwxos", model.luns().get(0).name());
        Assertions.assertEquals("w", model.luns().get(0).managedDiskAzureResourceId());
        Assertions.assertEquals("rw", model.targetIqn());
        Assertions.assertEquals(OperationalStatus.RUNNING, model.status());
        Assertions.assertEquals("twm", model.endpoints().get(0));
        Assertions.assertEquals(1725876914, model.port());
    }
}
