@Test public void testGetWithPublicAPI() { ClientResponse getAllResponse = publicV2ApiClient.viewResearcherUrlsXML(user1OrcidId); assertNotNull(getAllResponse); ResearcherUrls researcherUrls = getAllResponse.getEntity(ResearcherUrls.class); assertNotNull(researcherUrls); assertNotNull(researcherUrls.getResearcherUrls()); for (ResearcherUrl rUrl : researcherUrls.getResearcherUrls()) { assertNotNull(rUrl); assertEquals(Visibility.PUBLIC, rUrl.getVisibility()); ClientResponse theRUrl = publicV2ApiClient.viewResearcherUrlXML(user1OrcidId, String.valueOf(rUrl.getPutCode())); assertNotNull(theRUrl); ResearcherUrl researcherUrl = theRUrl.getEntity(ResearcherUrl.class); assertEquals(researcherUrl.getCreatedDate(), rUrl.getCreatedDate()); assertEquals(researcherUrl.getLastModifiedDate(), rUrl.getLastModifiedDate()); assertEquals(researcherUrl.getPutCode(), rUrl.getPutCode()); assertEquals(researcherUrl.getSource(), rUrl.getSource()); assertEquals(researcherUrl.getUrl(), rUrl.getUrl()); assertEquals(researcherUrl.getUrlName(), rUrl.getUrlName()); assertEquals(researcherUrl.getVisibility(), rUrl.getVisibility()); } }
@Test public void testAddMultipleResearcherUrlAndGetThem() throws InterruptedException, JSONException, URISyntaxException { String accessToken = getAccessToken(this.client1ClientId, this.client1ClientSecret, this.client1RedirectUri); assertNotNull(accessToken); Long now = System.currentTimeMillis(); ResearcherUrl rUrlToCreate = new ResearcherUrl(); rUrlToCreate.setVisibility(Visibility.PUBLIC); for (int i = 0; i < 3; i++) { // Change the name rUrlToCreate.setUrlName("url-name-" + now + "-" + i); rUrlToCreate.setUrl(new Url("http://newurl.com/" + now + "/" + i)); // Create it ClientResponse postResponse = memberV2ApiClient.createResearcherUrls(user1OrcidId, rUrlToCreate, accessToken); assertNotNull(postResponse); assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus()); } ClientResponse getAllResponse = memberV2ApiClient.getResearcherUrls(this.user1OrcidId, accessToken); assertNotNull(getAllResponse); ResearcherUrls researcherUrls = getAllResponse.getEntity(ResearcherUrls.class); assertNotNull(researcherUrls); assertNotNull(researcherUrls.getPath()); assertTrue(researcherUrls.getPath().contains(this.user1OrcidId)); assertNotNull(researcherUrls.getResearcherUrls()); boolean found1 = false, found2 = false, found3 = false; for (ResearcherUrl rUrl : researcherUrls.getResearcherUrls()) { if (rUrl.getUrlName().equals("url-name-" + now + "-0")) { found1 = true; } else if (rUrl.getUrlName().equals("url-name-" + now + "-1")) { found2 = true; } else if (rUrl.getUrlName().equals("url-name-" + now + "-2")) { found3 = true; } } assertTrue(found1 && found2 && found3); // Clean for (ResearcherUrl rUrl : researcherUrls.getResearcherUrls()) { memberV2ApiClient.deletePeerReviewXml(this.user1OrcidId, rUrl.getPutCode(), accessToken); } }