Search in sources :

Example 1 with IRODSRuleExecResultOutputParameter

use of org.irods.jargon.core.rule.IRODSRuleExecResultOutputParameter in project metalnx-web by irods-contrib.

the class RuleServiceImpl method executeRule.

@Override
public Map<String, IRODSRuleExecResultOutputParameter> executeRule(String rule) throws DataGridRuleException, DataGridConnectionRefusedException {
    if (rule == null || rule.isEmpty())
        return null;
    Map<String, IRODSRuleExecResultOutputParameter> ruleResultMap;
    try {
        IRODSRuleExecResult result = is.getRuleProcessingAO().executeRule(rule);
        ruleResultMap = result.getOutputParameterResults();
    } catch (JargonException e) {
        String error = String.format("Could not execute rule %s: %s", rule, e.getMessage());
        logger.error(error);
        throw new DataGridRuleException(error);
    }
    return ruleResultMap;
}
Also used : DataGridRuleException(com.emc.metalnx.core.domain.exceptions.DataGridRuleException) IRODSRuleExecResultOutputParameter(org.irods.jargon.core.rule.IRODSRuleExecResultOutputParameter) JargonException(org.irods.jargon.core.exception.JargonException) IRODSRuleExecResult(org.irods.jargon.core.rule.IRODSRuleExecResult)

Example 2 with IRODSRuleExecResultOutputParameter

use of org.irods.jargon.core.rule.IRODSRuleExecResultOutputParameter in project metalnx-web by irods-contrib.

the class TestRuleService method testGetMSIsRule.

@Test
public void testGetMSIsRule() throws DataGridRuleException, DataGridConnectionRefusedException {
    Map<String, IRODSRuleExecResultOutputParameter> result = new HashMap<>();
    IRODSRuleExecResultOutputParameter output = new IRODSRuleExecResultOutputParameter();
    output.setOutputParamType(IRODSRuleExecResultOutputParameter.OutputParamType.STRING);
    output.setParameterName("*msis");
    output.setResultObject("libmsi1.so, libmsi2.so, libmsi3.so, libmsi4.so");
    result.put("*msis", output);
    when(ruleService.executeRule(anyString())).thenReturn(result);
    List<String> msis = ruleService.execGetMSIsRule("icat.test.com");
    assertNotNull(msis);
    assertFalse(msis.isEmpty());
    assertTrue(msis.contains("libmsi1.so"));
    assertTrue(msis.contains("libmsi2.so"));
    assertTrue(msis.contains("libmsi3.so"));
    assertTrue(msis.contains("libmsi4.so"));
}
Also used : HashMap(java.util.HashMap) IRODSRuleExecResultOutputParameter(org.irods.jargon.core.rule.IRODSRuleExecResultOutputParameter) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 3 with IRODSRuleExecResultOutputParameter

use of org.irods.jargon.core.rule.IRODSRuleExecResultOutputParameter in project metalnx-web by irods-contrib.

the class TestRuleService method testGetVersionRule.

@Test
public void testGetVersionRule() throws DataGridRuleException, DataGridConnectionRefusedException {
    Map<String, IRODSRuleExecResultOutputParameter> result = new HashMap<>();
    IRODSRuleExecResultOutputParameter output = new IRODSRuleExecResultOutputParameter();
    output.setOutputParamType(IRODSRuleExecResultOutputParameter.OutputParamType.STRING);
    output.setParameterName("*version");
    output.setResultObject(msiVersion);
    result.put("*version", output);
    when(ruleService.executeRule(anyString())).thenReturn(result);
    String version = ruleService.execGetVersionRule("icat.test.com");
    assertEquals(msiVersion, version);
}
Also used : HashMap(java.util.HashMap) IRODSRuleExecResultOutputParameter(org.irods.jargon.core.rule.IRODSRuleExecResultOutputParameter) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 4 with IRODSRuleExecResultOutputParameter

use of org.irods.jargon.core.rule.IRODSRuleExecResultOutputParameter in project metalnx-web by irods-contrib.

the class TestRuleService method testGetMSIsRuleNoReturn.

@Test
public void testGetMSIsRuleNoReturn() throws DataGridRuleException, DataGridConnectionRefusedException {
    Map<String, IRODSRuleExecResultOutputParameter> result = new HashMap<>();
    IRODSRuleExecResultOutputParameter output = new IRODSRuleExecResultOutputParameter();
    output.setOutputParamType(IRODSRuleExecResultOutputParameter.OutputParamType.STRING);
    output.setParameterName("*msis");
    output.setResultObject(null);
    result.put("*msis", output);
    when(ruleService.executeRule(anyString())).thenReturn(result);
    List<String> msis = ruleService.execGetMSIsRule(HOST);
    assertNotNull(msis);
    assertTrue(msis.isEmpty());
}
Also used : HashMap(java.util.HashMap) IRODSRuleExecResultOutputParameter(org.irods.jargon.core.rule.IRODSRuleExecResultOutputParameter) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

IRODSRuleExecResultOutputParameter (org.irods.jargon.core.rule.IRODSRuleExecResultOutputParameter)4 HashMap (java.util.HashMap)3 Test (org.junit.Test)3 Matchers.anyString (org.mockito.Matchers.anyString)3 DataGridRuleException (com.emc.metalnx.core.domain.exceptions.DataGridRuleException)1 JargonException (org.irods.jargon.core.exception.JargonException)1 IRODSRuleExecResult (org.irods.jargon.core.rule.IRODSRuleExecResult)1