/** * Returns the user primary occupation. This method will also check the users education fields if the user is a * student. */ public String primaryOccupationName() { String primaryOccupation = null; // Check if we have a primary company if (professionalExperience != null && professionalExperience.primaryCompany() != null) { Company company = professionalExperience.primaryCompany(); primaryOccupation = company.title(); } // If the primary company not available try to use the primary school (the user may be a student) if (primaryOccupation == null || primaryOccupation.isEmpty()) { if (educationBackground != null && educationBackground.primarySchool() != null) { School primarySchool = educationBackground.primarySchool(); primaryOccupation = primarySchool.degree(); } } return primaryOccupation; }
private static void assertSchools(XingUser user) { School primarySchool = new School(); primarySchool.id("42_abcdef"); primarySchool.name("Carl-von-Ossietzky Universtät Schellenburg"); primarySchool.degree("MSc CE/CS"); List<String> notes = new ArrayList<>(3); notes.add("CS"); notes.add("IT"); notes.add("Android"); primarySchool.notes(notes); primarySchool.beginDate(new SafeCalendar(1998, Calendar.AUGUST)); primarySchool.endDate(new SafeCalendar(2005, Calendar.FEBRUARY)); assertThat(user.educationBackground().primarySchool()).isEqualTo(primarySchool); School otherSchool = new School(); otherSchool.id("42_abcdef"); otherSchool.name("Carl-von-Ossietzky Universtät Schellenburg"); otherSchool.degree("MSc CE/CS"); otherSchool.subject("CE"); otherSchool.beginDate(new SafeCalendar(1998, Calendar.AUGUST)); otherSchool.endDate(new SafeCalendar(2005, Calendar.FEBRUARY)); assertThat(user.educationBackground().schools()) .containsExactly(otherSchool); }
@Test public void testPrimaryInstitutionName() throws Exception { String primaryInstutionName = "Test Company"; assertThat(user.primaryInstitutionName()).isEqualTo(primaryInstutionName); user.professionalExperience(null); user.educationBackground(new EducationalBackground() .primarySchool(new School() .id("123123") .name("Universe School") .beginDate(new SafeCalendar(2001)) .endDate(new SafeCalendar(2015)) .degree("Master of the Universe") .subject("Universe"))); assertThat(user.primaryInstitutionName()).isEqualTo("Universe School"); }
@Test public void testPrimaryOccupationName() throws Exception { String primaryOccupationName = "Test Worker"; assertThat(user.primaryOccupationName()).isEqualTo(primaryOccupationName); user.professionalExperience(null); user.educationBackground(new EducationalBackground() .primarySchool(new School() .id("123123") .name("Universe School") .beginDate(new SafeCalendar(2001)) .endDate(new SafeCalendar(2015)) .degree("Master of the Universe") .subject("Universe"))); assertThat(user.primaryOccupationName()).isEqualTo("Master of the Universe"); }