Search in sources :

Example 36 with Candidate

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

the class VosManagerEntryIntegrationTest method findCandidatesWithOneResult.

@Test
@Ignore
public void findCandidatesWithOneResult() throws Exception {
    System.out.println(CLASS_NAME + "findCandidatesWithOneResult");
    final Vo createdVo = vosManagerEntry.createVo(sess, myVo);
    addExtSourceDelegate(createdVo);
    final List<Candidate> candidates = vosManagerEntry.findCandidates(sess, createdVo, "kouril", 1);
    assertEquals(1, candidates.size());
    removeExtSourceDelegate(createdVo);
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) MemberCandidate(cz.metacentrum.perun.core.api.MemberCandidate) BanOnVo(cz.metacentrum.perun.core.api.BanOnVo) Vo(cz.metacentrum.perun.core.api.Vo) Ignore(org.junit.Ignore) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 37 with Candidate

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

the class VosManagerEntryIntegrationTest method prepareCandidate.

private Candidate prepareCandidate() {
    String userFirstName = Long.toHexString(Double.doubleToLongBits(Math.random()));
    String userLastName = Long.toHexString(Double.doubleToLongBits(Math.random()));
    // his login in external source
    String extLogin = Long.toHexString(Double.doubleToLongBits(Math.random()));
    // Mockito.mock(Candidate.class);
    final Candidate candidate = new Candidate();
    candidate.setFirstName(userFirstName);
    candidate.setId(0);
    candidate.setMiddleName("");
    candidate.setLastName(userLastName);
    candidate.setTitleBefore("");
    candidate.setTitleAfter("");
    final ExtSource extSource = new ExtSource(0, "testExtSource", "cz.metacentrum.perun.core.impl.ExtSourceInternal");
    final UserExtSource userExtSource = new UserExtSource(extSource, extLogin);
    candidate.setUserExtSource(userExtSource);
    candidate.setAttributes(new HashMap<>());
    return candidate;
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) MemberCandidate(cz.metacentrum.perun.core.api.MemberCandidate) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) ExtSource(cz.metacentrum.perun.core.api.ExtSource) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource)

Example 38 with Candidate

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

the class VosManagerEntryIntegrationTest method prepareCandidateWithExtSource.

private Candidate prepareCandidateWithExtSource(String name, ExtSource es) {
    String userLastName = Long.toHexString(Double.doubleToLongBits(Math.random()));
    String extLogin = Long.toHexString(Double.doubleToLongBits(Math.random()));
    final Candidate candidate = new Candidate();
    candidate.setFirstName(name);
    candidate.setId(0);
    candidate.setMiddleName("");
    candidate.setLastName(userLastName);
    candidate.setTitleBefore("");
    candidate.setTitleAfter("");
    final UserExtSource userExtSource = new UserExtSource(es, extLogin);
    candidate.setUserExtSource(userExtSource);
    candidate.setAttributes(new HashMap<>());
    return candidate;
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) MemberCandidate(cz.metacentrum.perun.core.api.MemberCandidate) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource)

Example 39 with Candidate

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

the class RegistrarManagerImplUnitTest method testDisplayNameWithOnlyLastNameAndFedInfo.

@Test
public void testDisplayNameWithOnlyLastNameAndFedInfo() {
    Candidate candidate = new Candidate();
    Map<String, String> attributes = new HashMap<>();
    attributes.put(URN_USER_DISPLAY_NAME, "Sassmann");
    Map<String, String> fedData = new HashMap<>();
    fedData.put("sn", "Sassmann");
    fedData.put("givenName", "Vojtech");
    registrarManager.parseNamesFromDisplayNameAndFedInfo(candidate, attributes, fedData);
    assertThat(candidate.getTitleBefore()).isEqualTo(null);
    assertThat(candidate.getTitleAfter()).isEqualTo(null);
    assertThat(candidate.getFirstName()).isEqualTo("Vojtech");
    assertThat(candidate.getLastName()).isEqualTo("Sassmann");
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 40 with Candidate

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

the class RegistrarManagerImplUnitTest method testParseNamesIfTheMiddleNameEqualsFirstName.

@Test
public void testParseNamesIfTheMiddleNameEqualsFirstName() {
    Candidate candidate = new Candidate();
    Map<String, String> attributes = new HashMap<>();
    attributes.put(URN_USER_DISPLAY_NAME, "Bc. Jakub Jakub Hejda Dis.");
    Map<String, String> fedData = new HashMap<>();
    fedData.put("givenName", "Jakub");
    fedData.put("sn", "Hejda");
    Candidate candidate2 = new Candidate();
    Map<String, String> attributes2 = new HashMap<>();
    attributes2.put(URN_USER_DISPLAY_NAME, "Sir doc. John Paolo John Paolo Van Horn Phd.");
    Map<String, String> fedData2 = new HashMap<>();
    fedData2.put("givenName", "John Paolo");
    fedData2.put("sn", "Van Horn");
    registrarManager.parseNamesFromDisplayNameAndFedInfo(candidate, attributes, fedData);
    registrarManager.parseNamesFromDisplayNameAndFedInfo(candidate2, attributes2, fedData2);
    assertThat(candidate.getTitleBefore()).isEqualTo("Bc.");
    assertThat(candidate.getFirstName()).isEqualTo("Jakub");
    assertThat(candidate.getMiddleName()).isEqualTo("Jakub");
    assertThat(candidate.getLastName()).isEqualTo("Hejda");
    assertThat(candidate.getTitleAfter()).isEqualTo("Dis.");
    assertThat(candidate2.getTitleBefore()).isEqualTo("Sir doc.");
    assertThat(candidate2.getFirstName()).isEqualTo("John Paolo");
    assertThat(candidate2.getMiddleName()).isEqualTo("John Paolo");
    assertThat(candidate2.getLastName()).isEqualTo("Van Horn");
    assertThat(candidate2.getTitleAfter()).isEqualTo("Phd.");
}
Also used : Candidate(cz.metacentrum.perun.core.api.Candidate) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

Candidate (cz.metacentrum.perun.core.api.Candidate)100 UserExtSource (cz.metacentrum.perun.core.api.UserExtSource)52 Test (org.junit.Test)41 Member (cz.metacentrum.perun.core.api.Member)37 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)30 ExtSource (cz.metacentrum.perun.core.api.ExtSource)25 RichMember (cz.metacentrum.perun.core.api.RichMember)24 User (cz.metacentrum.perun.core.api.User)23 HashMap (java.util.HashMap)23 ArrayList (java.util.ArrayList)21 Group (cz.metacentrum.perun.core.api.Group)15 Attribute (cz.metacentrum.perun.core.api.Attribute)14 Map (java.util.Map)12 MemberCandidate (cz.metacentrum.perun.core.api.MemberCandidate)11 RichUser (cz.metacentrum.perun.core.api.RichUser)11 Vo (cz.metacentrum.perun.core.api.Vo)11 LinkedHashMap (java.util.LinkedHashMap)11 RichUserExtSource (cz.metacentrum.perun.core.api.RichUserExtSource)9 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)9 CandidateNotExistsException (cz.metacentrum.perun.core.api.exceptions.CandidateNotExistsException)8