use of org.wso2.carbon.apimgt.cleanup.service.IdpKeyMangerPurge in project carbon-apimgt by wso2.
the class IdpKmPurgeTest method testOrganizationRemoval.
@Test
public void testOrganizationRemoval() throws APIManagementException, UserStoreException {
PowerMockito.mockStatic(APIUtil.class);
PowerMockito.mockStatic(OrganizationPurgeDAO.class);
PowerMockito.when(OrganizationPurgeDAO.getInstance()).thenReturn(organizationPurgeDAO);
PowerMockito.mockStatic(ApiMgtDAO.class);
PowerMockito.when(ApiMgtDAO.getInstance()).thenReturn(apiMgtDAO);
KeyManagerConfigurationDTO kmConfig = Mockito.mock(KeyManagerConfigurationDTO.class);
List<KeyManagerConfigurationDTO> keyManagerList = new ArrayList<>();
keyManagerList.add(kmConfig);
Mockito.doReturn(keyManagerList).when(amAdmin).getKeyManagerConfigurationsByOrganization("testOrg");
Mockito.doNothing().when(organizationPurgeDAO).deleteKeyManagerConfigurationList(keyManagerList, "testOrg");
Mockito.doReturn(true).when(organizationPurgeDAO).keyManagerOrganizationExist(Mockito.anyString());
Mockito.doNothing().when(amAdmin).deleteIdentityProvider("testOrg", kmConfig);
Mockito.when(APIUtil.isInternalOrganization("testOrg")).thenReturn(true);
IdpKeyMangerPurge kmPurge = new IdpKeyManagerPurgeWrapper(organizationPurgeDAO);
LinkedHashMap<String, String> subtaskResult = kmPurge.purge("testOrg");
for (Map.Entry<String, String> entry : subtaskResult.entrySet()) {
Assert.assertEquals(entry.getKey() + " is not successful", APIConstants.OrganizationDeletion.COMPLETED, entry.getValue());
}
Mockito.verify(organizationPurgeDAO, Mockito.times(1)).deleteKeyManagerConfigurationList(Matchers.anyListOf(KeyManagerConfigurationDTO.class), Mockito.any());
}
Aggregations