use of org.wso2.carbon.identity.functions.library.mgt.FunctionLibraryManagementService in project carbon-identity-framework by wso2.
the class FunctionLibraryManagementServiceTest method getFunctionLibrary.
@Test(dataProvider = "getFunctionLibraryDataProvider")
public void getFunctionLibrary(Object functionLibrary, String tenantDomain) {
try {
FunctionLibraryManagementService functionLibraryManagementService = FunctionLibraryManagementServiceImpl.getInstance();
FunctionLibraryDAOImpl functionLibraryDAO = PowerMockito.mock(FunctionLibraryDAOImpl.class);
PowerMockito.whenNew(FunctionLibraryDAOImpl.class).withNoArguments().thenReturn(functionLibraryDAO);
when(functionLibraryDAO.isFunctionLibraryExists(((FunctionLibrary) functionLibrary).getFunctionLibraryName(), tenantDomain)).thenReturn(false);
when(functionLibraryDAO.getFunctionLibrary(((FunctionLibrary) functionLibrary).getFunctionLibraryName(), tenantDomain)).thenReturn((FunctionLibrary) functionLibrary);
addFunctionLibraries(functionLibraryManagementService, Collections.singletonList(functionLibrary), tenantDomain);
assertTrue(functionLibraryManagementService.getFunctionLibrary(((FunctionLibrary) functionLibrary).getFunctionLibraryName(), tenantDomain) != null, "Failed to retrieve script library");
// Clean after test
deleteFunctionLibraries(functionLibraryManagementService, Collections.singletonList(functionLibrary), tenantDomain);
} catch (Exception e) {
fail("Exception", e);
}
}
use of org.wso2.carbon.identity.functions.library.mgt.FunctionLibraryManagementService in project carbon-identity-framework by wso2.
the class FunctionLibraryManagementServiceTest method createFunctionLibrary.
@Test(dataProvider = "createFunctionLibraryDataProvider")
public void createFunctionLibrary(Object functionLibrary, String tenantDomain) {
FunctionLibraryDAOImpl functionLibraryDAO = PowerMockito.mock(FunctionLibraryDAOImpl.class);
try {
PowerMockito.whenNew(FunctionLibraryDAOImpl.class).withNoArguments().thenReturn(functionLibraryDAO);
when(functionLibraryDAO.getFunctionLibrary(((FunctionLibrary) functionLibrary).getFunctionLibraryName(), tenantDomain)).thenReturn((FunctionLibrary) functionLibrary);
FunctionLibraryManagementService functionLibraryManagementService = FunctionLibraryManagementServiceImpl.getInstance();
functionLibraryManagementService.createFunctionLibrary((FunctionLibrary) functionLibrary, tenantDomain);
assertEquals(functionLibraryManagementService.getFunctionLibrary(((FunctionLibrary) functionLibrary).getFunctionLibraryName(), tenantDomain).getFunctionLibraryName(), ((FunctionLibrary) functionLibrary).getFunctionLibraryName());
// Clean after test
functionLibraryManagementService.deleteFunctionLibrary(((FunctionLibrary) functionLibrary).getFunctionLibraryName(), tenantDomain);
} catch (Exception e) {
fail("Error test Create script library ", e);
}
}
use of org.wso2.carbon.identity.functions.library.mgt.FunctionLibraryManagementService in project carbon-identity-framework by wso2.
the class FunctionLibraryManagementServiceTest method testIsRegexValidated.
@Test(dataProvider = "testIsRegexValidatedDataProvider")
public void testIsRegexValidated(Object functionLibrary, String tenantDomain) {
FunctionLibraryDAOImpl functionLibraryDAO = PowerMockito.mock(FunctionLibraryDAOImpl.class);
try {
PowerMockito.whenNew(FunctionLibraryDAOImpl.class).withNoArguments().thenReturn(functionLibraryDAO);
when(functionLibraryDAO.getFunctionLibrary(((FunctionLibrary) functionLibrary).getFunctionLibraryName(), tenantDomain)).thenReturn((FunctionLibrary) functionLibrary);
FunctionLibraryManagementService functionLibraryManagementService = FunctionLibraryManagementServiceImpl.getInstance();
functionLibraryManagementService.createFunctionLibrary((FunctionLibrary) functionLibrary, tenantDomain);
} catch (FunctionLibraryManagementException e) {
assertEquals(e.getMessage(), "The script library name is not valid! It is not adhering to the regex " + FunctionLibraryMgtUtil.FUNCTION_LIBRARY_NAME_VALIDATING_REGEX + ".");
} catch (Exception e) {
fail("Exception", e);
}
}
use of org.wso2.carbon.identity.functions.library.mgt.FunctionLibraryManagementService in project identity-api-server by wso2.
the class ScriptLibraryMgtOSGIService method createInstance.
protected FunctionLibraryManagementService createInstance() throws Exception {
if (this.functionLibraryManagementService == null) {
FunctionLibraryManagementService taskOperationService = (FunctionLibraryManagementService) PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(FunctionLibraryManagementService.class, (Hashtable) null);
if (taskOperationService == null) {
throw new Exception("Unable to retrieve Function Library Management Service.");
}
this.functionLibraryManagementService = taskOperationService;
}
return this.functionLibraryManagementService;
}
Aggregations