use of org.forgerock.openam.sm.datalayer.api.ConnectionFactory in project OpenAM by OpenRock.
the class UpgradeEntitlementSubConfigsStepTest method setUp.
@BeforeMethod
public void setUp() throws IllegalAccessException, InstantiationException {
mockTypes = new HashSet<ApplicationType>(3);
final ApplicationType type1 = newType("type1");
final ApplicationType type2 = newType("type2");
final ApplicationType type3 = newType("type3");
mockTypes.addAll(Arrays.asList(type1, type2, type3));
this.type1 = type1;
mockApplications = new HashSet<Application>(3);
final Application application1 = newApplication("application1", type1);
final Application application2 = newApplication("application2", type1);
final Application application3 = newApplication("application3", type1);
mockApplications.addAll(Arrays.asList(application1, application2, application3));
entitlementService = mock(EntitlementConfiguration.class);
adminTokenAction = mock(PrivilegedAction.class);
connectionFactory = mock(ConnectionFactory.class);
resourceTypeConfiguration = mock(ResourceTypeConfiguration.class);
upgradeStep = new SafeUpgradeEntitlementSubConfigsStep(entitlementService, resourceTypeConfiguration, adminTokenAction, connectionFactory);
final HashSet<String> conditions = new HashSet<String>();
conditions.add("condition.entry.1");
conditions.add("condition.entry.2");
final HashSet<String> subjects = new HashSet<String>();
subjects.add("subject.entry.1");
subjects.add("subject.entry.2");
final HashSet<String> resources = new HashSet<String>();
resources.add("http://*");
resources.add("https://*");
app = newApplication("application4", type1);
app.setConditions(conditions);
app.setSubjects(subjects);
app.setEntitlementCombinerName(DEFAULT_COMBINER);
}
use of org.forgerock.openam.sm.datalayer.api.ConnectionFactory 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