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"); }
@Test public void addSchoolToOwnProfile() throws Exception { MockResponse mockResponse = new MockResponse().setBody("{\n" + " \"school\": {\n" + " \"id\": \"42\",\n" + " \"name\": \"University of Hamburg\",\n" + " \"subject\": null,\n" + " \"degree\": null,\n" + " \"begin_date\": null,\n" + " \"end_date\": null,\n" + " \"notes\": null\n" + " }\n" + '}'); server.enqueue(mockResponse); server.enqueue(mockResponse); Response<School, HttpError> response1 = resource.addSchool("University of Hamburg").execute(); // If no exception was thrown then the spec is build correctly. assertThat(response1.body().id()).isEqualTo("42"); // This would require a name, but the server prevents that in the real world. Response<School, HttpError> response2 = resource.addSchool(new School()).execute(); // If no exception was thrown then the spec is build correctly. assertThat(response2.body().id()).isEqualTo("42"); }