use of org.wso2.carbon.apimgt.rest.api.admin.dto.WorkflowDTO in project carbon-apimgt by wso2.
the class ApplicationDeletionSimpleWorkflowExecutorTest method init.
@Before
public void init() {
applicationDeletionSimpleWorkflowExecutor = new ApplicationDeletionSimpleWorkflowExecutor();
PowerMockito.mockStatic(ApiMgtDAO.class);
apiMgtDAO = Mockito.mock(ApiMgtDAO.class);
PowerMockito.when(ApiMgtDAO.getInstance()).thenReturn(apiMgtDAO);
workflowDTO = new ApplicationWorkflowDTO();
workflowDTO.setWorkflowReference("1");
application = new Application("test", new Subscriber("testUser"));
workflowDTO.setApplication(application);
}
use of org.wso2.carbon.apimgt.rest.api.admin.dto.WorkflowDTO in project carbon-apimgt by wso2.
the class ApplicationRegistrationWSWorkflowExecutorTest method testFailureToCompleteApplicationRegistrationWSWFWhenKeyGenerationFailed.
@Test
public void testFailureToCompleteApplicationRegistrationWSWFWhenKeyGenerationFailed() throws Exception {
applicationRegistrationWSWorkflowExecutor.setUsername(adminUsername);
applicationRegistrationWSWorkflowExecutor.setPassword(adminPassword.toCharArray());
workflowDTO.setStatus(WorkflowStatus.APPROVED);
PowerMockito.doThrow(new APIManagementException("Error occurred when updating the status of the Application " + "Registration process")).when(keyManager).createApplication((OAuthAppRequest) Mockito.anyObject());
try {
applicationRegistrationWSWorkflowExecutor.complete(workflowDTO);
Assert.fail("Expected WorkflowException has not occurred while completing application registration " + "workflow");
} catch (WorkflowException e) {
Assert.assertEquals(e.getMessage(), "Error occurred when updating the status of the Application " + "Registration process");
}
}
use of org.wso2.carbon.apimgt.rest.api.admin.dto.WorkflowDTO in project carbon-apimgt by wso2.
the class SubscriptionCreationSimpleWorkflowExecutorTest method testExecutingSubscriptionCreationWorkFlow.
@Test
public void testExecutingSubscriptionCreationWorkFlow() throws APIManagementException {
WorkflowDTO workflowDTO = new WorkflowDTO();
workflowDTO.setWorkflowReference("1");
try {
PowerMockito.doNothing().when(apiMgtDAO).updateSubscriptionStatus(1, "UNBLOCKED");
Assert.assertNotNull(subscriptionCreationSimpleWorkflowExecutor.execute(workflowDTO));
} catch (WorkflowException e) {
Assert.fail("Unexpected WorkflowException occurred while executing Subscription creation simple workflow");
}
}
use of org.wso2.carbon.apimgt.rest.api.admin.dto.WorkflowDTO in project carbon-apimgt by wso2.
the class UserSignUpSimpleWorkflowExecutorTest method testExecutingUserSignUpSimpleWorkflow.
@Test
public void testExecutingUserSignUpSimpleWorkflow() throws APIManagementException, UserStoreException {
Map<String, Boolean> roleMap = new HashMap<String, Boolean>();
roleMap.put(signUpRole, false);
UserRegistrationConfigDTO userRegistrationConfigDTO = new UserRegistrationConfigDTO();
userRegistrationConfigDTO.setAdminUserName("admin");
userRegistrationConfigDTO.setAdminPassword("admin");
userRegistrationConfigDTO.setRoles(roleMap);
PowerMockito.when(SelfSignUpUtil.getSignupConfiguration(tenantDomain)).thenReturn(userRegistrationConfigDTO);
PowerMockito.when(SelfSignUpUtil.getRoleNames(userRegistrationConfigDTO)).thenCallRealMethod();
Mockito.when(userStoreManager.isExistingUser(username)).thenReturn(true);
Mockito.when(userStoreManager.isExistingRole("Internal/" + signUpRole)).thenReturn(true);
Mockito.doNothing().when(userStoreManager).updateRoleListOfUser(username, null, new String[] { "Internal/" + signUpRole });
try {
Assert.assertNotNull(userSignUpSimpleWorkflowExecutor.execute(workflowDTO));
} catch (WorkflowException e) {
Assert.fail("Unexpected WorkflowException has thrown while executing the user signup simple workflow");
}
}
use of org.wso2.carbon.apimgt.rest.api.admin.dto.WorkflowDTO in project carbon-apimgt by wso2.
the class UserSignUpSimpleWorkflowExecutorTest method init.
@Before
public void init() throws Exception {
userSignUpSimpleWorkflowExecutor = new UserSignUpSimpleWorkflowExecutor();
workflowDTO = new WorkflowDTO();
workflowDTO.setExternalWorkflowReference("12345");
workflowDTO.setTenantDomain(tenantDomain);
workflowDTO.setStatus(WorkflowStatus.APPROVED);
workflowDTO.setWorkflowReference(username);
ServiceReferenceHolder serviceReferenceHolder = Mockito.mock(ServiceReferenceHolder.class);
apiManagerConfiguration = Mockito.mock(APIManagerConfiguration.class);
RealmService realmService = Mockito.mock(RealmService.class);
TenantManager tenantManager = Mockito.mock(TenantManager.class);
UserRealm userRealm = Mockito.mock(UserRealm.class);
userStoreManager = Mockito.mock(UserStoreManager.class);
ServiceClient serviceClient = Mockito.mock(ServiceClient.class);
PowerMockito.mockStatic(ServiceReferenceHolder.class);
PowerMockito.mockStatic(SelfSignUpUtil.class);
PowerMockito.mockStatic(CarbonUtils.class);
Mockito.when(ServiceReferenceHolder.getInstance()).thenReturn(serviceReferenceHolder);
APIManagerConfigurationService apiManagerConfigurationService = new APIManagerConfigurationServiceImpl(apiManagerConfiguration);
Mockito.when(serviceReferenceHolder.getAPIManagerConfigurationService()).thenReturn(apiManagerConfigurationService);
Mockito.when(serviceReferenceHolder.getRealmService()).thenReturn(realmService);
Mockito.when(realmService.getTenantManager()).thenReturn(tenantManager);
Mockito.when(tenantManager.getTenantId(tenantDomain)).thenReturn(tenantID);
Mockito.when(tenantManager.getTenantId(tenantDomain)).thenReturn(tenantID);
Mockito.when(realmService.getTenantUserRealm(tenantID)).thenReturn(userRealm);
Mockito.when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
}
Aggregations