@Test
  public void testInvalidPutCodeReturns404() throws InterruptedException, JSONException {
    String accessToken =
        getAccessToken(this.client1ClientId, this.client1ClientSecret, this.client1RedirectUri);
    assertNotNull(accessToken);

    Address address = new Address();
    address.setCountry(new Country(Iso3166Country.CR));
    address.setVisibility(Visibility.PUBLIC);
    address.setPutCode(1234567890L);

    ClientResponse response = memberV2ApiClient.updateAddress(user1OrcidId, address, accessToken);
    assertNotNull(response);
    assertEquals(ClientResponse.Status.NOT_FOUND.getStatusCode(), response.getStatus());
  }
  @SuppressWarnings({"deprecation", "rawtypes"})
  @Test
  public void testCreateGetUpdateAndDeleteKeyword() throws InterruptedException, JSONException {
    String accessToken =
        getAccessToken(this.client1ClientId, this.client1ClientSecret, this.client1RedirectUri);
    assertNotNull(accessToken);

    Address address = new Address();
    address.setCountry(new Country(Iso3166Country.CR));
    address.setVisibility(Visibility.PUBLIC);
    // Create
    ClientResponse response = memberV2ApiClient.createAddress(user1OrcidId, address, accessToken);
    assertNotNull(response);
    assertEquals(ClientResponse.Status.CREATED.getStatusCode(), response.getStatus());
    Map map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List resultWithPutCode = (List) map.get("Location");
    String location = resultWithPutCode.get(0).toString();
    Long putCode = Long.valueOf(location.substring(location.lastIndexOf('/') + 1));

    // Get all and verify
    response = memberV2ApiClient.viewAddresses(user1OrcidId, accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    Addresses addresses = response.getEntity(Addresses.class);
    assertNotNull(addresses);
    assertNotNull(addresses.getAddress());
    assertEquals(2, addresses.getAddress().size());

    boolean foundUS = false;
    boolean foundCR = false;

    for (Address add : addresses.getAddress()) {
      assertEquals(Visibility.PUBLIC, add.getVisibility());
      assertNotNull(add.getCountry());
      assertNotNull(add.getCountry().getValue());
      if (add.getCountry().getValue().equals(Iso3166Country.US)) {
        foundUS = true;
      } else if (add.getCountry().getValue().equals(Iso3166Country.CR)) {
        foundCR = true;
      }
    }

    assertTrue(foundUS);
    assertTrue(foundCR);

    // Get it
    response = memberV2ApiClient.viewAddress(user1OrcidId, putCode, accessToken);
    assertNotNull(response);
    address = response.getEntity(Address.class);
    assertNotNull(address);
    assertNotNull(address.getSource());
    assertEquals(client1ClientId, address.getSource().retrieveSourcePath());
    assertNotNull(address.getCountry());
    assertNotNull(address.getCountry().getValue());
    assertEquals(Iso3166Country.CR, address.getCountry().getValue());
    assertEquals(Visibility.PUBLIC, address.getVisibility());

    // Update
    address.getCountry().setValue(Iso3166Country.PA);
    response = memberV2ApiClient.updateAddress(user1OrcidId, address, accessToken);
    assertNotNull(response);
    assertEquals(ClientResponse.Status.OK.getStatusCode(), response.getStatus());
    response = memberV2ApiClient.viewAddress(user1OrcidId, putCode, accessToken);
    assertNotNull(response);
    Address updatedAddress = response.getEntity(Address.class);
    assertNotNull(updatedAddress);
    assertNotNull(updatedAddress.getCountry());
    assertEquals(Iso3166Country.PA, updatedAddress.getCountry().getValue());
    assertEquals(address.getPutCode(), updatedAddress.getPutCode());

    // Delete
    response = memberV2ApiClient.deleteAddress(user1OrcidId, putCode, accessToken);
    assertNotNull(response);
    assertEquals(ClientResponse.Status.NO_CONTENT.getStatusCode(), response.getStatus());

    // Check it was deleted
    testGetAddressWithMembersAPI();
  }