use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class urn_perun_facility_attribute_def_virt_minUIDTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_facility_attribute_def_virt_minUID();
session = mock(PerunSessionImpl.class);
facility = new Facility();
attributeToCheck = new Attribute();
attributeToCheck.setFriendlyName("friendly_name");
reqAttribute = new Attribute();
PerunBl perunBl = mock(PerunBl.class);
when(session.getPerunBl()).thenReturn(perunBl);
AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class GroupAndGroupStructureSynchronizationIntegrationTest method setUpBaseGroup.
private void setUpBaseGroup(Vo vo) throws Exception {
extSource = extSourceManagerBl.createExtSource(sess, extSource, null);
Group returnedGroup = groupsManagerBl.createGroup(sess, vo, baseGroup);
extSourceManagerBl.addExtSource(sess, vo, extSource);
Attribute attr = attributesManagerBl.getAttribute(sess, baseGroup, GroupsManager.GROUPEXTSOURCE_ATTRNAME);
attr.setValue(extSource.getName());
attributesManagerBl.setAttribute(sess, baseGroup, attr);
extSourceManagerBl.addExtSource(sess, baseGroup, extSource);
Attribute membersQuery = new Attribute(((PerunBl) sess.getPerun()).getAttributesManagerBl().getAttributeDefinition(sess, GroupsManager.GROUPMEMBERSQUERY_ATTRNAME));
membersQuery.setValue("SELECT * from members where groupName='?';");
attributesManagerBl.setAttribute(sess, baseGroup, membersQuery);
Attribute interval = new Attribute(((PerunBl) sess.getPerun()).getAttributesManagerBl().getAttributeDefinition(sess, GroupsManager.GROUPSYNCHROINTERVAL_ATTRNAME));
interval.setValue("1");
attributesManagerBl.setAttribute(sess, baseGroup, interval);
AttributeDefinition loginAttrDef = setGroupAttribute("groupLogin");
Attribute structureLoginName = new Attribute(((PerunBl) sess.getPerun()).getAttributesManagerBl().getAttributeDefinition(sess, GroupsManager.GROUPS_STRUCTURE_LOGIN_ATTRNAME));
structureLoginName.setValue(loginAttrDef.getName());
attributesManagerBl.setAttribute(sess, baseGroup, structureLoginName);
// create test Group in database
assertNotNull("unable to create testing Group", returnedGroup);
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class Utils method parseAdditionalUserExtSource.
/**
* Returns additional user ext source either found in Perun or creates new. Parameter userExtSourceRaw is array of
* Strings containing name, type and extLogin. If any of the required parts is empty, ParserException is thrown.
* Used in extractAdditionalUserExtSources to get ues.
*
* @param sess perun session
* @param userExtSourceRaw array of strings containing all parts of ues
* @return UserExtSource additional ues
*/
private static UserExtSource parseAdditionalUserExtSource(PerunSession sess, String[] userExtSourceRaw) {
// Get extLogin from 3rd part of userExtSourceRaw as well as ues attributes, so it needs to be parsed from it
String extLogin = userExtSourceRaw[2].split(";")[0];
// Check whether any of the required parts of ues are not empty
if (userExtSourceRaw[0].isEmpty() || userExtSourceRaw[1].isEmpty() || extLogin.isEmpty()) {
throw new ParserException("Some of the required parts of userExtSource are empty.");
}
ExtSource additionalExtSource;
try {
// Try to get extSource, with full extSource object (containg ID)
additionalExtSource = ((PerunBl) sess.getPerun()).getExtSourcesManagerBl().getExtSourceByName(sess, userExtSourceRaw[0]);
} catch (ExtSourceNotExistsException e) {
try {
// Create new one if not exists
additionalExtSource = new ExtSource(userExtSourceRaw[0], userExtSourceRaw[1]);
additionalExtSource = ((PerunBl) sess.getPerun()).getExtSourcesManagerBl().createExtSource(sess, additionalExtSource, null);
} catch (ExtSourceExistsException e1) {
throw new ConsistencyErrorException("Creating existing extSource: " + userExtSourceRaw[0]);
}
}
// Get optional LoA (0 if not stated)
int loa = parseAdditionalUESLoa(userExtSourceRaw);
return new UserExtSource(additionalExtSource, loa, extLogin);
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class urn_perun_user_attribute_def_virt_loaTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_user_attribute_def_virt_loa();
session = mock(PerunSessionImpl.class);
user = new User(0, "John", "Doe", "", "", "");
attributeToCheck = new Attribute();
PerunBl perunBl = mock(PerunBl.class);
when(session.getPerunBl()).thenReturn(perunBl);
}
use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.
the class urn_perun_resource_attribute_def_def_replicaDestinationTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_resource_attribute_def_def_replicaDestination();
attributeToCheck = new Attribute();
sess = mock(PerunSessionImpl.class);
PerunBl perunBl = mock(PerunBl.class);
when(sess.getPerunBl()).thenReturn(perunBl);
modulesUtilsBl = mock(ModulesUtilsBl.class);
when(perunBl.getModulesUtilsBl()).thenReturn(modulesUtilsBl);
}
Aggregations