use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeResourceTypeStepTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
privilegedAction = mock(PrivilegedAction.class);
resourceTypeService = mock(ResourceTypeService.class);
connectionFactory = mock(ConnectionFactory.class);
configManager = mock(ServiceConfigManager.class);
upgradeResourceTypeStep = new UpgradeResourceTypeStep(configManager, resourceTypeService, privilegedAction, connectionFactory, Collections.<String>emptySet()) {
@Override
protected Document getEntitlementXML() throws UpgradeException {
return document;
}
@Override
protected Set<String> getRealmNamesFromParent() throws UpgradeException {
return realms;
}
@Override
protected Set<String> policiesEligibleForUpgrade(String appName, String realm) throws UpgradeException {
return policies;
}
};
when(document.getElementsByTagName(anyString())).thenReturn(new NodeList() {
@Override
public Node item(int i) {
return null;
}
@Override
public int getLength() {
return 0;
}
});
// Mock global and application type service configuration
ServiceConfig globalConfig = mock(ServiceConfig.class);
when(configManager.getGlobalConfig(anyString())).thenReturn(globalConfig);
ServiceConfig appTypesConfig = mock(ServiceConfig.class);
when(globalConfig.getSubConfig(anyString())).thenReturn(appTypesConfig);
// Mock organisation and application service configuration
ServiceConfig orgConfig = mock(ServiceConfig.class);
when(configManager.getOrganizationConfig(anyString(), anyString())).thenReturn(orgConfig);
ServiceConfig appsConfig = mock(ServiceConfig.class);
when(orgConfig.getSubConfig(anyString())).thenReturn(appsConfig);
// Mock application names
when(appsConfig.getSubConfigNames()).thenReturn(Collections.singleton("MyApplication"));
// Mock application data
ServiceConfig appConfig = mock(ServiceConfig.class);
when(appsConfig.getSubConfig("MyApplication")).thenReturn(appConfig);
when(appConfig.getAttributes()).thenReturn(appData);
// Mock application type on application and application type data
ServiceConfig appTypeConfig = mock(ServiceConfig.class);
when(appTypesConfig.getSubConfig("MyApplicationType")).thenReturn(appTypeConfig);
when(appTypeConfig.getAttributes()).thenReturn(appTypeData);
setupDataStructures();
}
Aggregations