Search in sources :

Example 46 with UserExtSource

use of cz.metacentrum.perun.core.api.UserExtSource in project perun by CESNET.

the class UsersManagerEntryIntegrationTest method removeUserExtSourcePersistent.

@Test(expected = InternalErrorException.class)
public void removeUserExtSourcePersistent() throws Exception {
    System.out.println(CLASS_NAME + "removeUserExtSourcePersistent");
    // Assuming ExtSource PERUN is persistent (set as property)
    ExtSource extSource = perun.getExtSourcesManagerBl().getExtSourceByName(sess, "PERUN");
    List<UserExtSource> userExtSources = usersManager.getUserExtSources(sess, user);
    for (UserExtSource ues : userExtSources) {
        if (ues.getExtSource().equals(extSource)) {
            usersManager.removeUserExtSource(sess, user, ues);
            break;
        }
    }
}
Also used : UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) ExtSource(cz.metacentrum.perun.core.api.ExtSource) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 47 with UserExtSource

use of cz.metacentrum.perun.core.api.UserExtSource in project perun by CESNET.

the class UsersManagerEntryIntegrationTest method setUpCandidateForSponsoredUser.

private Candidate setUpCandidateForSponsoredUser() {
    Candidate candidate = new Candidate();
    candidate.setFirstName("Sponsored");
    candidate.setId(0);
    candidate.setMiddleName("");
    candidate.setLastName("User01");
    candidate.setTitleBefore("");
    candidate.setTitleAfter("");
    candidate.setServiceUser(false);
    candidate.setSponsoredUser(true);
    final UserExtSource userExtSource = new UserExtSource(extSource, Long.toHexString(Double.doubleToLongBits(Math.random())));
    candidate.setUserExtSource(userExtSource);
    candidate.setAttributes(new HashMap<String, String>());
    return candidate;
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource)

Example 48 with UserExtSource

use of cz.metacentrum.perun.core.api.UserExtSource in project perun by CESNET.

the class UsersManagerEntryIntegrationTest method getActiveUserExtSourcesIfEmpty.

@Test
public void getActiveUserExtSourcesIfEmpty() throws Exception {
    System.out.println(CLASS_NAME + "getActiveUserExtSources");
    User emptyUser = setUpEmptyUser();
    List<UserExtSource> ues = perun.getUsersManagerBl().getUserExtSources(sess, emptyUser);
    for (UserExtSource uExtSource : ues) {
        perun.getUsersManagerBl().removeUserExtSource(sess, emptyUser, uExtSource);
    }
    ues = perun.getUsersManagerBl().getActiveUserExtSources(sess, emptyUser);
    assertTrue(ues.isEmpty());
}
Also used : RichUser(cz.metacentrum.perun.core.api.RichUser) User(cz.metacentrum.perun.core.api.User) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 49 with UserExtSource

use of cz.metacentrum.perun.core.api.UserExtSource in project perun by CESNET.

the class urn_perun_group_resource_attribute_def_def_isUnixGroupIntegrationtest method setUpCandidate.

private Candidate setUpCandidate() {
    //Mockito.mock(Candidate.class);
    Candidate candidate = new Candidate();
    candidate.setFirstName(userFirstName);
    candidate.setId(0);
    candidate.setMiddleName("");
    candidate.setLastName(userLastName);
    candidate.setTitleBefore("");
    candidate.setTitleAfter("");
    final UserExtSource userExtSource = new UserExtSource(extSource, extLogin);
    candidate.setUserExtSource(userExtSource);
    candidate.setAttributes(new HashMap<String, String>());
    return candidate;
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource)

Example 50 with UserExtSource

use of cz.metacentrum.perun.core.api.UserExtSource in project perun by CESNET.

the class urn_perun_group_resource_attribute_def_def_isUnixGroupIntegrationtest method setUpUserExtSource.

private void setUpUserExtSource() throws Exception {
    ExtSource externalSource = perun.getExtSourcesManager().getExtSourceByName(sess, extSourceName);
    // gets real external source object from database
    userExtSource.setExtSource(externalSource);
    // put real external source into user's external source
    userExtSource.setLogin(extLogin);
    // set users login in his ext source
    assertNotNull(usersManager.addUserExtSource(sess, user, userExtSource));
// create new user ext source in database
}
Also used : UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) ExtSource(cz.metacentrum.perun.core.api.ExtSource)

Aggregations

UserExtSource (cz.metacentrum.perun.core.api.UserExtSource)79 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)34 Test (org.junit.Test)34 ExtSource (cz.metacentrum.perun.core.api.ExtSource)28 Attribute (cz.metacentrum.perun.core.api.Attribute)19 Candidate (cz.metacentrum.perun.core.api.Candidate)18 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)14 User (cz.metacentrum.perun.core.api.User)12 Member (cz.metacentrum.perun.core.api.Member)11 ArrayList (java.util.ArrayList)11 RichAttribute (cz.metacentrum.perun.core.api.RichAttribute)8 Group (cz.metacentrum.perun.core.api.Group)7 ExtSourceNotExistsException (cz.metacentrum.perun.core.api.exceptions.ExtSourceNotExistsException)6 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)5 HashMap (java.util.HashMap)5 RichUser (cz.metacentrum.perun.core.api.RichUser)4 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)4 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)4 Matcher (java.util.regex.Matcher)4 RichMember (cz.metacentrum.perun.core.api.RichMember)3