Skip to content

Commit

Permalink
Add new test in TenantWorkflowConfigHolderTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Avishka-Shamendra committed Nov 22, 2023
1 parent a95f71f commit 447b1ff
Showing 1 changed file with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,11 @@ public void testFailureToLoadTenantWFConfigWhenWFExecutorPropertySetterInInvalid
"that takes a single String, int, long, float, double or boolean parameter", e.getMessage());
}
}


/**
* This method tests the correct loading of properties where property values can have
* different types, such as string, int, double, etc.
*/
@Test
public void testLoadingTenantWFConfigWhenWFExecutorHasMultipleParamTypes() throws Exception {
//Workflow executor class setter methods are available for different parameter types
Expand Down Expand Up @@ -346,6 +350,50 @@ public void testLoadingTenantWFConfigWhenWFExecutorHasMultipleParamTypes() throw
"param types");
}
}

/**
* This method tests the correct loading of properties when all property values are specified as strings.
* This supports proper migration of workflow-extensions properties
*/
@Test
public void testLoadingTenantWFExecutorWithMultipleParamTypesWhenAllPropValuesAreSpecifiedAsStrings() throws Exception {
//Workflow executor class setter methods are available for different parameter types
JsonObject WFExecutor = JsonParser.parseString("{\n" +
" \"Workflows\": {\n" +
" \"UserSignUp\": {\n" +
" \"Enabled\": true,\n" +
" \"Class\": \"org.wso2.carbon.apimgt.impl.workflow.WorkflowExecutorWithMultipleParamTypes\",\n" +
" \"Properties\": {\n" +
" \"StringParam\": \"admin\",\n" +
" \"IntParam\": \"1\",\n" +
" \"BooleanParam\": \"true\",\n" +
" \"LongParam\": \"10000000\",\n" +
" \"DoubleParam\": \"10.1000000000\",\n" +
" \"FloatParam\": \"10.1\",\n" +
" \"OMElementParam\": \"<omElement>test</omElement>\"\n" +
" }\n" +
" }\n" +
" }\n" +
"}").getAsJsonObject();
TenantWorkflowConfigHolder tenantWorkflowConfigHolder = new TenantWorkflowConfigHolder(tenantDomain, tenantID);
Mockito.when(apimConfigService.getWorkFlowConfig(tenantDomain))
.thenReturn(WorkflowTestUtils.getWorkFlowConfigDTOFromJsonConfig(WFExecutor));
try {
tenantWorkflowConfigHolder.load();
Assert.assertNotNull(tenantWorkflowConfigHolder.getWorkflowExecutor("AM_USER_SIGNUP"));
WorkflowExecutorWithMultipleParamTypes executor = (WorkflowExecutorWithMultipleParamTypes) tenantWorkflowConfigHolder.getWorkflowExecutor("AM_USER_SIGNUP");
Assert.assertEquals("admin", executor.stringParam);
Assert.assertEquals((Integer) 1, executor.intParam);
Assert.assertEquals(true, executor.boolParam);
Assert.assertEquals(10000000, executor.longParam);
Assert.assertEquals((Double) 10.1000000000, executor.doubleParam);
Assert.assertEquals((Float) 10.1f, executor.floatParam);
Assert.assertEquals("<omElement>test</omElement>", executor.omElement.toString());
} catch (WorkflowException e) {
Assert.fail("Unexpected WorkflowException has been thrown while loading workflow executor for different " +
"param types");
}
}
}

/**
Expand Down

0 comments on commit 447b1ff

Please sign in to comment.