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

package com.azure.resourcemanager.security.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.security.models.AutomationRuleSet;
import com.azure.resourcemanager.security.models.AutomationTriggeringRule;
import com.azure.resourcemanager.security.models.Operator;
import com.azure.resourcemanager.security.models.PropertyType;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AutomationRuleSetTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AutomationRuleSet model =
            BinaryData
                .fromString(
                    "{\"rules\":[{\"propertyJPath\":\"hvygdyftumr\",\"propertyType\":\"Boolean\",\"expectedValue\":\"wjslbiwkojgcyzt\",\"operator\":\"LesserThan\"}]}")
                .toObject(AutomationRuleSet.class);
        Assertions.assertEquals("hvygdyftumr", model.rules().get(0).propertyJPath());
        Assertions.assertEquals(PropertyType.BOOLEAN, model.rules().get(0).propertyType());
        Assertions.assertEquals("wjslbiwkojgcyzt", model.rules().get(0).expectedValue());
        Assertions.assertEquals(Operator.LESSER_THAN, model.rules().get(0).operator());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AutomationRuleSet model =
            new AutomationRuleSet()
                .withRules(
                    Arrays
                        .asList(
                            new AutomationTriggeringRule()
                                .withPropertyJPath("hvygdyftumr")
                                .withPropertyType(PropertyType.BOOLEAN)
                                .withExpectedValue("wjslbiwkojgcyzt")
                                .withOperator(Operator.LESSER_THAN)));
        model = BinaryData.fromObject(model).toObject(AutomationRuleSet.class);
        Assertions.assertEquals("hvygdyftumr", model.rules().get(0).propertyJPath());
        Assertions.assertEquals(PropertyType.BOOLEAN, model.rules().get(0).propertyType());
        Assertions.assertEquals("wjslbiwkojgcyzt", model.rules().get(0).expectedValue());
        Assertions.assertEquals(Operator.LESSER_THAN, model.rules().get(0).operator());
    }
}
