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

package com.azure.resourcemanager.iothub.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.iothub.fluent.models.TestAllRoutesResultInner;
import com.azure.resourcemanager.iothub.models.MatchedRoute;
import com.azure.resourcemanager.iothub.models.RouteProperties;
import com.azure.resourcemanager.iothub.models.RoutingSource;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class TestAllRoutesResultInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        TestAllRoutesResultInner model =
            BinaryData
                .fromString(
                    "{\"routes\":[{\"properties\":{\"name\":\"ygmi\",\"source\":\"TwinChangeEvents\",\"condition\":\"nzdndslgna\",\"endpointNames\":[],\"isEnabled\":false}}]}")
                .toObject(TestAllRoutesResultInner.class);
        Assertions.assertEquals("ygmi", model.routes().get(0).properties().name());
        Assertions.assertEquals(RoutingSource.TWIN_CHANGE_EVENTS, model.routes().get(0).properties().source());
        Assertions.assertEquals("nzdndslgna", model.routes().get(0).properties().condition());
        Assertions.assertEquals(false, model.routes().get(0).properties().isEnabled());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        TestAllRoutesResultInner model =
            new TestAllRoutesResultInner()
                .withRoutes(
                    Arrays
                        .asList(
                            new MatchedRoute()
                                .withProperties(
                                    new RouteProperties()
                                        .withName("ygmi")
                                        .withSource(RoutingSource.TWIN_CHANGE_EVENTS)
                                        .withCondition("nzdndslgna")
                                        .withEndpointNames(Arrays.asList())
                                        .withIsEnabled(false))));
        model = BinaryData.fromObject(model).toObject(TestAllRoutesResultInner.class);
        Assertions.assertEquals("ygmi", model.routes().get(0).properties().name());
        Assertions.assertEquals(RoutingSource.TWIN_CHANGE_EVENTS, model.routes().get(0).properties().source());
        Assertions.assertEquals("nzdndslgna", model.routes().get(0).properties().condition());
        Assertions.assertEquals(false, model.routes().get(0).properties().isEnabled());
    }
}
