// Path: src/main/java/org/rundeck/plugin/salt/SaltApiNodeStepPlugin.java
// public enum SaltApiNodeStepFailureReason implements FailureReason {
//     EXIT_CODE, ARGUMENTS_MISSING, ARGUMENTS_INVALID, AUTHENTICATION_FAILURE, COMMUNICATION_FAILURE, SALT_API_FAILURE, SALT_TARGET_MISMATCH, INTERRUPTED;
// }
// 
// Path: src/main/java/org/rundeck/plugin/salt/validation/Validators.java
// public class Validators {
//     
//     /**
//      * Checks that the given propertyValue is not empty or null.
//      * 
//      * @param propertyName The name of the property that is being checked
//      * @param propertyValue The value of the property that is being checked.
//      * @param reason A {@link com.dtolabs.rundeck.core.execution.workflow.steps.node.NodeStepFailure} for this this validation failure.
//      * @param nodeName The node this node step is executing against.
//      */ 
//     public static void checkNotEmpty(String propertyName, String propertyValue, FailureReason reason, INodeEntry entry)
//             throws SaltStepValidationException {
//         if (StringUtils.isEmpty(propertyValue)) {
//             throw new SaltStepValidationException(propertyName, String.format("%s is a required property.",
//                     propertyName), reason, entry.getNodename());
//         }
//     }
// }


import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.rundeck.plugin.salt.SaltApiNodeStepPlugin.SaltApiNodeStepFailureReason;
import org.rundeck.plugin.salt.validation.SaltStepValidationException;
import org.rundeck.plugin.salt.validation.Validators;
import com.dtolabs.rundeck.core.execution.workflow.steps.node.NodeStepException;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
        PowerMockito.verifyStatic();
        Validators.checkNotEmpty(SaltApiNodeStepPlugin.SALT_PASSWORD_OPTION_NAME, PARAM_PASSWORD,
                SaltApiNodeStepFailureReason.ARGUMENTS_MISSING, node);
        PowerMockito.verifyNoMoreInteractions(Validators.class);
    }

    @Test
    public void testValidateThrowsIfValidatorThrows() throws SaltStepValidationException {
        SaltStepValidationException e = new SaltStepValidationException("some property", "Some message",
                SaltApiNodeStepFailureReason.ARGUMENTS_INVALID, node.getNodename());
        PowerMockito.mockStatic(Validators.class);
        PowerMockito.doThrow(e).when(Validators.class);
        Validators.checkNotEmpty(Mockito.anyString(), Mockito.anyString(),
                Mockito.any(SaltApiNodeStepFailureReason.class), Mockito.same(node));

        try {
            plugin.validate(PARAM_USER, PARAM_PASSWORD, node);
            Assert.fail("Expected exception");
        } catch (SaltStepValidationException ne) {
            Assert.assertSame("Expected mocked exception to be thrown", e, ne);
        }
    }

    @Test
    public void testValidateChecksValidEndpointHttpUrl() throws NodeStepException {
        plugin.saltEndpoint = "https://some.machine.com";
        plugin.validate(PARAM_USER, PARAM_PASSWORD, node);
    }

    @Test
// Path: src/main/java/org/rundeck/plugin/salt/SaltApiNodeStepPlugin.java
// public enum SaltApiNodeStepFailureReason implements FailureReason {
//     EXIT_CODE, ARGUMENTS_MISSING, ARGUMENTS_INVALID, AUTHENTICATION_FAILURE, COMMUNICATION_FAILURE, SALT_API_FAILURE, SALT_TARGET_MISMATCH, INTERRUPTED;
// }
// 
// Path: src/main/java/org/rundeck/plugin/salt/validation/Validators.java
// public class Validators {
//     
//     /**
//      * Checks that the given propertyValue is not empty or null.
//      * 
//      * @param propertyName The name of the property that is being checked
//      * @param propertyValue The value of the property that is being checked.
//      * @param reason A {@link com.dtolabs.rundeck.core.execution.workflow.steps.node.NodeStepFailure} for this this validation failure.
//      * @param nodeName The node this node step is executing against.
//      */ 
//     public static void checkNotEmpty(String propertyName, String propertyValue, FailureReason reason, INodeEntry entry)
//             throws SaltStepValidationException {
//         if (StringUtils.isEmpty(propertyValue)) {
//             throw new SaltStepValidationException(propertyName, String.format("%s is a required property.",
//                     propertyName), reason, entry.getNodename());
//         }
//     }
// }


// Path: src/test/java/org/rundeck/plugin/salt/SaltApiNodeStepPlugin_ValidationTest.java
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.rundeck.plugin.salt.SaltApiNodeStepPlugin.SaltApiNodeStepFailureReason;
import org.rundeck.plugin.salt.validation.SaltStepValidationException;
import org.rundeck.plugin.salt.validation.Validators;
import com.dtolabs.rundeck.core.execution.workflow.steps.node.NodeStepException;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;

        PowerMockito.verifyStatic();
        Validators.checkNotEmpty(SaltApiNodeStepPlugin.SALT_PASSWORD_OPTION_NAME, PARAM_PASSWORD,
                SaltApiNodeStepFailureReason.ARGUMENTS_MISSING, node);
        PowerMockito.verifyNoMoreInteractions(Validators.class);
    }

    @Test
    public void testValidateThrowsIfValidatorThrows() throws SaltStepValidationException {
        SaltStepValidationException e = new SaltStepValidationException("some property", "Some message",
                SaltApiNodeStepFailureReason.ARGUMENTS_INVALID, node.getNodename());
        PowerMockito.mockStatic(Validators.class);
        PowerMockito.doThrow(e).when(Validators.class);
        Validators.checkNotEmpty(Mockito.anyString(), Mockito.anyString(),
                Mockito.any(SaltApiNodeStepFailureReason.class), Mockito.same(node));

        try {
            plugin.validate(PARAM_USER, PARAM_PASSWORD, node);
            Assert.fail("Expected exception");
        } catch (SaltStepValidationException ne) {
            Assert.assertSame("Expected mocked exception to be thrown", e, ne);
        }
    }

    @Test
    public void testValidateChecksValidEndpointHttpUrl() throws NodeStepException {
        plugin.saltEndpoint = "https://some.machine.com";
        plugin.validate(PARAM_USER, PARAM_PASSWORD, node);
    }

    @Test
    public void testValidateChecksValidEndpointHttpsUrl() throws NodeStepException {