Search in sources :

Example 81 with UpgradeException

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();
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ResourceTypeService(org.forgerock.openam.entitlement.service.ResourceTypeService) Document(org.w3c.dom.Document) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ConnectionFactory(org.forgerock.openam.sm.datalayer.api.ConnectionFactory) PrivilegedAction(java.security.PrivilegedAction) ServiceConfig(com.sun.identity.sm.ServiceConfig) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

UpgradeException (org.forgerock.openam.upgrade.UpgradeException)81 SSOException (com.iplanet.sso.SSOException)29 HashMap (java.util.HashMap)27 SMSException (com.sun.identity.sm.SMSException)25 Set (java.util.Set)25 HashSet (java.util.HashSet)22 Map (java.util.Map)22 ServiceConfig (com.sun.identity.sm.ServiceConfig)21 EntitlementException (com.sun.identity.entitlement.EntitlementException)16 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)14 Application (com.sun.identity.entitlement.Application)10 IOException (java.io.IOException)10 PolicyManager (com.sun.identity.policy.PolicyManager)8 PolicyException (com.sun.identity.policy.PolicyException)6 ServiceNotFoundException (com.sun.identity.sm.ServiceNotFoundException)6 EntitlementUtils.resourceTypeFromMap (org.forgerock.openam.entitlement.utils.EntitlementUtils.resourceTypeFromMap)6 Node (org.w3c.dom.Node)5 ServiceSchema (com.sun.identity.sm.ServiceSchema)4 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)4 Properties (java.util.Properties)4