// 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.IscsiTargetInner;
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 IscsiTargetInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IscsiTargetInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"aclMode\":\"Static\",\"staticAcls\":[{\"initiatorIqn\":\"lxotogtwrupq\",\"mappedLuns\":[]},{\"initiatorIqn\":\"xvnmicykvceov\",\"mappedLuns\":[]},{\"initiatorIqn\":\"ilovnot\",\"mappedLuns\":[]},{\"initiatorIqn\":\"fj\",\"mappedLuns\":[]}],\"luns\":[{\"name\":\"jbkcnxdhbttkph\",\"managedDiskAzureResourceId\":\"wpn\",\"lun\":224051014},{\"name\":\"oqnermclfpl\",\"managedDiskAzureResourceId\":\"hoxus\",\"lun\":2041952882},{\"name\":\"abgy\",\"managedDiskAzureResourceId\":\"psbjta\",\"lun\":610868240},{\"name\":\"gxywpmue\",\"managedDiskAzureResourceId\":\"fjz\",\"lun\":224913714}],\"targetIqn\":\"kqujidsuyono\",\"provisioningState\":\"Failed\",\"status\":\"Running\",\"endpoints\":[\"cq\",\"tcc\",\"g\"],\"port\":1054992005,\"sessions\":[\"tlmoyrx\",\"wfudwpzntxhdzhl\",\"qj\",\"hckfrlhrx\"]},\"systemData\":{\"createdBy\":\"yvpycanuzbpzk\",\"createdByType\":\"ManagedIdentity\",\"createdAt\":\"2021-09-06T02:44:44Z\",\"lastModifiedBy\":\"crnwbmeh\",\"lastModifiedByType\":\"Key\",\"lastModifiedAt\":\"2021-09-03T17:59:20Z\"},\"managedBy\":\"us\",\"managedByExtended\":[\"lhspkdee\"],\"id\":\"aofmxagkvtme\",\"name\":\"mqkrhahvljuahaqu\",\"type\":\"c\"}")
                .toObject(IscsiTargetInner.class);
        Assertions.assertEquals(IscsiTargetAclMode.STATIC, model.aclMode());
        Assertions.assertEquals("lxotogtwrupq", model.staticAcls().get(0).initiatorIqn());
        Assertions.assertEquals("jbkcnxdhbttkph", model.luns().get(0).name());
        Assertions.assertEquals("wpn", model.luns().get(0).managedDiskAzureResourceId());
        Assertions.assertEquals("kqujidsuyono", model.targetIqn());
        Assertions.assertEquals(OperationalStatus.RUNNING, model.status());
        Assertions.assertEquals("cq", model.endpoints().get(0));
        Assertions.assertEquals(1054992005, model.port());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IscsiTargetInner model =
            new IscsiTargetInner()
                .withAclMode(IscsiTargetAclMode.STATIC)
                .withStaticAcls(
                    Arrays
                        .asList(
                            new Acl().withInitiatorIqn("lxotogtwrupq").withMappedLuns(Arrays.asList()),
                            new Acl().withInitiatorIqn("xvnmicykvceov").withMappedLuns(Arrays.asList()),
                            new Acl().withInitiatorIqn("ilovnot").withMappedLuns(Arrays.asList()),
                            new Acl().withInitiatorIqn("fj").withMappedLuns(Arrays.asList())))
                .withLuns(
                    Arrays
                        .asList(
                            new IscsiLun().withName("jbkcnxdhbttkph").withManagedDiskAzureResourceId("wpn"),
                            new IscsiLun().withName("oqnermclfpl").withManagedDiskAzureResourceId("hoxus"),
                            new IscsiLun().withName("abgy").withManagedDiskAzureResourceId("psbjta"),
                            new IscsiLun().withName("gxywpmue").withManagedDiskAzureResourceId("fjz")))
                .withTargetIqn("kqujidsuyono")
                .withStatus(OperationalStatus.RUNNING)
                .withEndpoints(Arrays.asList("cq", "tcc", "g"))
                .withPort(1054992005);
        model = BinaryData.fromObject(model).toObject(IscsiTargetInner.class);
        Assertions.assertEquals(IscsiTargetAclMode.STATIC, model.aclMode());
        Assertions.assertEquals("lxotogtwrupq", model.staticAcls().get(0).initiatorIqn());
        Assertions.assertEquals("jbkcnxdhbttkph", model.luns().get(0).name());
        Assertions.assertEquals("wpn", model.luns().get(0).managedDiskAzureResourceId());
        Assertions.assertEquals("kqujidsuyono", model.targetIqn());
        Assertions.assertEquals(OperationalStatus.RUNNING, model.status());
        Assertions.assertEquals("cq", model.endpoints().get(0));
        Assertions.assertEquals(1054992005, model.port());
    }
}
