Search in sources :

Example 6 with FunctionLibrary

use of org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary in project carbon-identity-framework by wso2.

the class FunctionLibraryManagementServiceTest method testAlreadyExistFunctionLibrary.

@Test(dataProvider = "tesAlreadyExistFunctionLibraryDataProvider")
public void testAlreadyExistFunctionLibrary(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());
    } catch (FunctionLibraryManagementException e) {
        assertEquals(e.getMessage(), "Already a script library available with the name: " + ((FunctionLibrary) functionLibrary).getFunctionLibraryName() + ".");
    } catch (Exception e) {
        fail("Exception", e);
    }
}
Also used : FunctionLibraryDAOImpl(org.wso2.carbon.identity.functions.library.mgt.dao.impl.FunctionLibraryDAOImpl) FunctionLibraryManagementException(org.wso2.carbon.identity.functions.library.mgt.exception.FunctionLibraryManagementException) FunctionLibrary(org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary) FunctionLibraryManagementException(org.wso2.carbon.identity.functions.library.mgt.exception.FunctionLibraryManagementException) Test(org.testng.annotations.Test) PowerMockIdentityBaseTest(org.wso2.carbon.identity.testutil.powermock.PowerMockIdentityBaseTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 7 with FunctionLibrary

use of org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary in project carbon-identity-framework by wso2.

the class FunctionLibraryManagementServiceTest method getFunctionLibraryData.

@DataProvider(name = "getFunctionLibraryDataProvider")
public Object[][] getFunctionLibraryData() {
    FunctionLibrary functionLibrary9 = new FunctionLibrary();
    functionLibrary9.setFunctionLibraryName("sample9");
    functionLibrary9.setDescription("sample9");
    functionLibrary9.setFunctionLibraryScript("function samplefunction9(){}");
    FunctionLibrary functionLibrary10 = new FunctionLibrary();
    functionLibrary10.setFunctionLibraryName("sample10");
    functionLibrary10.setDescription("sample10");
    functionLibrary10.setFunctionLibraryScript("function samplefunction10(){}");
    return new Object[][] { { functionLibrary9, SAMPLE_TENANT_DOMAIN }, { functionLibrary10, null } };
}
Also used : FunctionLibrary(org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary) DataProvider(org.testng.annotations.DataProvider)

Example 8 with FunctionLibrary

use of org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary in project carbon-identity-framework by wso2.

the class FunctionLibraryManagementServiceTest method testFunctionLibraryNameRequiredDataProvider.

@DataProvider(name = "testFunctionLibraryNameRequiredDataProvider")
public Object[][] testFunctionLibraryNameRequiredDataProvider() {
    FunctionLibrary functionLibrary20 = new FunctionLibrary();
    functionLibrary20.setFunctionLibraryName(null);
    functionLibrary20.setDescription("sample18");
    functionLibrary20.setFunctionLibraryScript("function samplefunction20(){}");
    return new Object[][] { { functionLibrary20, SAMPLE_TENANT_DOMAIN2 } };
}
Also used : FunctionLibrary(org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary) DataProvider(org.testng.annotations.DataProvider)

Example 9 with FunctionLibrary

use of org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary in project carbon-identity-framework by wso2.

the class FunctionLibraryManagementServiceTest method listFunctionLibrariesData.

@DataProvider(name = "listFunctionLibraryDataProvider")
public Object[][] listFunctionLibrariesData() {
    FunctionLibrary functionLibrary6 = new FunctionLibrary();
    functionLibrary6.setFunctionLibraryName("sample6");
    functionLibrary6.setDescription("sample6");
    functionLibrary6.setFunctionLibraryScript("function samplefunction6(){}");
    FunctionLibrary functionLibrary7 = new FunctionLibrary();
    functionLibrary7.setFunctionLibraryName("sample7");
    functionLibrary7.setDescription("sample7");
    functionLibrary7.setFunctionLibraryScript("function samplefunction7(){}");
    FunctionLibrary functionLibrary8 = new FunctionLibrary();
    functionLibrary8.setFunctionLibraryName("sample8");
    functionLibrary8.setDescription("sample8");
    functionLibrary8.setFunctionLibraryScript("function samplefunction8(){}");
    return new Object[][] { { Arrays.asList(functionLibrary6, functionLibrary7, functionLibrary8), SAMPLE_TENANT_DOMAIN } };
}
Also used : FunctionLibrary(org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary) DataProvider(org.testng.annotations.DataProvider)

Example 10 with FunctionLibrary

use of org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary in project carbon-identity-framework by wso2.

the class FunctionLibraryManagementServiceTest method createFunctionLibraryData.

@DataProvider(name = "createFunctionLibraryDataProvider")
public Object[][] createFunctionLibraryData() {
    FunctionLibrary functionLibrary1 = new FunctionLibrary();
    functionLibrary1.setFunctionLibraryName("sample1");
    functionLibrary1.setDescription("sample1");
    functionLibrary1.setFunctionLibraryScript("function samplefunction1(){}");
    FunctionLibrary functionLibrary2 = new FunctionLibrary();
    functionLibrary2.setFunctionLibraryName("sample2");
    functionLibrary2.setDescription("sample2");
    functionLibrary2.setFunctionLibraryScript("function samplefunction2(){}");
    FunctionLibrary functionLibrary3 = new FunctionLibrary();
    functionLibrary3.setFunctionLibraryName("sample3");
    functionLibrary3.setDescription("sample3");
    functionLibrary3.setFunctionLibraryScript("function samplefunction3(){}");
    FunctionLibrary functionLibrary4 = new FunctionLibrary();
    functionLibrary4.setFunctionLibraryName("sample4");
    functionLibrary4.setDescription("sample4");
    functionLibrary4.setFunctionLibraryScript("function samplefunction4(){}");
    FunctionLibrary functionLibrary5 = new FunctionLibrary();
    functionLibrary5.setFunctionLibraryName("sample5");
    functionLibrary5.setDescription("sample5");
    functionLibrary5.setFunctionLibraryScript("function samplefunction5(){}");
    return new Object[][] { { functionLibrary1, SAMPLE_TENANT_DOMAIN }, { functionLibrary2, SAMPLE_TENANT_DOMAIN }, { functionLibrary3, SAMPLE_TENANT_DOMAIN2 }, { functionLibrary4, SAMPLE_TENANT_DOMAIN2 }, { functionLibrary5, SAMPLE_TENANT_DOMAIN2 } };
}
Also used : FunctionLibrary(org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary) DataProvider(org.testng.annotations.DataProvider)

Aggregations

FunctionLibrary (org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary)31 Test (org.testng.annotations.Test)19 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)15 PowerMockIdentityBaseTest (org.wso2.carbon.identity.testutil.powermock.PowerMockIdentityBaseTest)15 DataProvider (org.testng.annotations.DataProvider)13 FunctionLibraryManagementException (org.wso2.carbon.identity.functions.library.mgt.exception.FunctionLibraryManagementException)11 FunctionLibraryDAO (org.wso2.carbon.identity.functions.library.mgt.dao.FunctionLibraryDAO)10 Connection (java.sql.Connection)9 FunctionLibraryDAOImpl (org.wso2.carbon.identity.functions.library.mgt.dao.impl.FunctionLibraryDAOImpl)9 SQLException (java.sql.SQLException)5 AxisFault (org.apache.axis2.AxisFault)5 FunctionLibrary (org.wso2.carbon.identity.functions.library.mgt.model.xsd.FunctionLibrary)5 IOException (java.io.IOException)4 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)4 PreparedStatement (java.sql.PreparedStatement)3 IdentityRuntimeException (org.wso2.carbon.identity.base.IdentityRuntimeException)3 File (java.io.File)2 ResultSet (java.sql.ResultSet)2 ArrayList (java.util.ArrayList)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1