Search in sources :

Example 21 with PerunBl

use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.

the class urn_perun_group_attribute_def_def_unixGroupName_namespaceTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_group_attribute_def_def_unixGroupName_namespace();
    attributeToCheck = new Attribute();
    attributeToCheck.setFriendlyName("unixGID-namespace");
    sess = mock(PerunSessionImpl.class);
    PerunBl perunBl = mock(PerunBl.class);
    when(sess.getPerunBl()).thenReturn(perunBl);
    AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
    when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
    when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_RESOURCE_ATTR_DEF + ":unixGroupName-namespace:")).thenReturn(attributeToCheck);
    GroupsManagerBl groupsManagerBl = mock(GroupsManagerBl.class);
    when(sess.getPerunBl().getGroupsManagerBl()).thenReturn(groupsManagerBl);
    when(sess.getPerunBl().getGroupsManagerBl().isGroupSynchronizedFromExternallSource(sess, group)).thenReturn(false);
    ModulesUtilsBl modulesUtilsBl = mock(ModulesUtilsBl.class);
    when(sess.getPerunBl().getModulesUtilsBl()).thenReturn(modulesUtilsBl);
    ResourcesManagerBl resourcesManagerBl = mock(ResourcesManagerBl.class);
    when(sess.getPerunBl().getResourcesManagerBl()).thenReturn(resourcesManagerBl);
}
Also used : ResourcesManagerBl(cz.metacentrum.perun.core.bl.ResourcesManagerBl) GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) ModulesUtilsBl(cz.metacentrum.perun.core.bl.ModulesUtilsBl) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 22 with PerunBl

use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.

the class urn_perun_group_resource_attribute_def_def_adNameTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_group_resource_attribute_def_def_adName();
    attributeToCheck = new Attribute();
    sess = mock(PerunSessionImpl.class);
    reqAttribute = new Attribute();
    PerunBl perunBl = mock(PerunBl.class);
    when(sess.getPerunBl()).thenReturn(perunBl);
    AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
    when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
    when(attributesManagerBl.getAttribute(sess, resource, AttributesManager.NS_RESOURCE_ATTR_DEF + ":adOuName")).thenReturn(reqAttribute);
    SearcherBl searcherBl = mock(SearcherBl.class);
    when(perunBl.getSearcherBl()).thenReturn(searcherBl);
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) SearcherBl(cz.metacentrum.perun.core.bl.SearcherBl) Before(org.junit.Before)

Example 23 with PerunBl

use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.

the class urn_perun_group_resource_attribute_def_def_o365EmailAddresses_muTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_group_resource_attribute_def_def_o365EmailAddresses_mu();
    // prepare mocks
    session = mock(PerunSessionImpl.class);
    PerunBl perunBl = mock(PerunBl.class);
    am = mock(AttributesManagerBl.class);
    adNameAttr = mock(Attribute.class);
    when(session.getPerunBl()).thenReturn(perunBl);
    when(perunBl.getAttributesManagerBl()).thenReturn(am);
    when(am.getAttribute(session, resource, group, ADNAME_ATTRIBUTE)).thenReturn(adNameAttr);
    when(adNameAttr.getValue()).thenReturn(adName);
    attributeToCheck = new Attribute(classInstance.getAttributeDefinition());
    attributeToCheck.setId(100);
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 24 with PerunBl

use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.

the class urn_perun_member_attribute_def_def_o365EmailAddresses_muTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_member_attribute_def_def_o365EmailAddresses_mu();
    // prepare mocks
    session = mock(PerunSessionImpl.class);
    PerunBl perunBl = mock(PerunBl.class);
    am = mock(AttributesManagerBl.class);
    UsersManagerBl um = mock(UsersManagerBl.class);
    Attribute ucoAttr = mock(Attribute.class);
    when(session.getPerunBl()).thenReturn(perunBl);
    when(perunBl.getAttributesManagerBl()).thenReturn(am);
    when(perunBl.getUsersManagerBl()).thenReturn(um);
    when(um.getUserById(session, member.getUserId())).thenReturn(user);
    when(ucoAttr.getValue()).thenReturn(uco);
    when(ucoAttr.valueAsString()).thenReturn(uco);
    when(um.getUserById(session, member.getUserId())).thenReturn(user);
    when(am.getPerunBeanIdsForUniqueAttributeValue(eq(session), argThat(new BeanAttributeMatcher("member")))).thenReturn(Sets.newHashSet(new Pair<>(member.getId(), 0)));
    when(am.getPerunBeanIdsForUniqueAttributeValue(eq(session), argThat(new BeanAttributeMatcher("group")))).thenReturn(Sets.newHashSet());
    attributeToCheck = new Attribute(classInstance.getAttributeDefinition());
    attributeToCheck.setId(101);
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) UsersManagerBl(cz.metacentrum.perun.core.bl.UsersManagerBl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Pair(cz.metacentrum.perun.core.api.Pair) Before(org.junit.Before)

Example 25 with PerunBl

use of cz.metacentrum.perun.core.bl.PerunBl in project perun by CESNET.

the class urn_perun_resource_attribute_def_def_fairshareGroupNameTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_resource_attribute_def_def_fairshareGroupName();
    attributeToCheck = new Attribute();
    reqAttribute = new Attribute();
    sess = mock(PerunSessionImpl.class);
    Facility facility = new Facility();
    List<Resource> resources = new ArrayList<>();
    Resource resource2 = new Resource();
    resources.add(resource2);
    resources.add(resource);
    PerunBl perunBl = mock(PerunBl.class);
    when(sess.getPerunBl()).thenReturn(perunBl);
    AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
    when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
    when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, resource2, attributeToCheck.getName())).thenReturn(reqAttribute);
    ResourcesManagerBl resourcesManagerBl = mock(ResourcesManagerBl.class);
    when(perunBl.getResourcesManagerBl()).thenReturn(resourcesManagerBl);
    when(resourcesManagerBl.getFacility(sess, resource)).thenReturn(facility);
    FacilitiesManagerBl facilitiesManagerBl = mock(FacilitiesManagerBl.class);
    when(perunBl.getFacilitiesManagerBl()).thenReturn(facilitiesManagerBl);
    when(facilitiesManagerBl.getAssignedResources(sess, facility)).thenReturn(resources);
}
Also used : ResourcesManagerBl(cz.metacentrum.perun.core.bl.ResourcesManagerBl) FacilitiesManagerBl(cz.metacentrum.perun.core.bl.FacilitiesManagerBl) Attribute(cz.metacentrum.perun.core.api.Attribute) Resource(cz.metacentrum.perun.core.api.Resource) ArrayList(java.util.ArrayList) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) Facility(cz.metacentrum.perun.core.api.Facility) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Aggregations

PerunBl (cz.metacentrum.perun.core.bl.PerunBl)130 Attribute (cz.metacentrum.perun.core.api.Attribute)93 Before (org.junit.Before)65 PerunSessionImpl (cz.metacentrum.perun.core.impl.PerunSessionImpl)64 AttributesManagerBl (cz.metacentrum.perun.core.bl.AttributesManagerBl)48 User (cz.metacentrum.perun.core.api.User)41 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)37 ArrayList (java.util.ArrayList)22 Vo (cz.metacentrum.perun.core.api.Vo)21 Facility (cz.metacentrum.perun.core.api.Facility)19 UserExtSource (cz.metacentrum.perun.core.api.UserExtSource)19 ModulesUtilsBl (cz.metacentrum.perun.core.bl.ModulesUtilsBl)19 ExtSource (cz.metacentrum.perun.core.api.ExtSource)16 Member (cz.metacentrum.perun.core.api.Member)16 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)16 UserExtSourceExistsException (cz.metacentrum.perun.core.api.exceptions.UserExtSourceExistsException)16 UsersManagerBl (cz.metacentrum.perun.core.bl.UsersManagerBl)15 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)14 GroupsManagerBl (cz.metacentrum.perun.core.bl.GroupsManagerBl)13 Group (cz.metacentrum.perun.core.api.Group)12