use of io.envoyproxy.envoy.config.core.v3.Address in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method testViewAddress.
@Test
public void testViewAddress() {
Response response = serviceDelegator.viewAddress(ORCID, 9L);
assertNotNull(response);
Address address = (Address) response.getEntity();
assertNotNull(address);
assertNotNull(address.getLastModifiedDate());
assertNotNull(address.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(9), address.getPutCode());
assertNotNull(address.getCountry());
assertEquals(Iso3166Country.US, address.getCountry().getValue());
assertEquals(Visibility.PUBLIC.value(), address.getVisibility().value());
assertEquals("/0000-0000-0000-0003/address/9", address.getPath());
assertEquals("APP-5555555555555555", address.getSource().retrieveSourcePath());
}
use of io.envoyproxy.envoy.config.core.v3.Address in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method testGetPublicAddressUsingToken.
// Address
@Test
public void testGetPublicAddressUsingToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewAddress(ORCID, 9L);
assertNotNull(r);
Address a = (Address) r.getEntity();
assertNotNull(a);
assertNotNull(a.getLastModifiedDate());
assertNotNull(a.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(9), a.getPutCode());
}
use of io.envoyproxy.envoy.config.core.v3.Address in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_AddressesTest method testAddAddress.
@Test
public void testAddAddress() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.createAddress("4444-4444-4444-4442", Utils.getAddress());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
Map<?, ?> map = response.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List<?> resultWithPutCode = (List<?>) map.get("Location");
Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
response = serviceDelegator.viewAddress("4444-4444-4444-4442", putCode);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
Address newAddress = (Address) response.getEntity();
assertNotNull(newAddress);
Utils.verifyLastModified(newAddress.getLastModifiedDate());
assertEquals(Iso3166Country.ES, newAddress.getCountry().getValue());
assertEquals(Visibility.LIMITED, newAddress.getVisibility());
assertNotNull(newAddress.getSource());
assertEquals("APP-5555555555555555", newAddress.getSource().retrieveSourcePath());
assertNotNull(newAddress.getCreatedDate());
Utils.verifyLastModified(newAddress.getLastModifiedDate());
// Remove it
response = serviceDelegator.deleteAddress("4444-4444-4444-4442", putCode);
assertNotNull(response);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
use of io.envoyproxy.envoy.config.core.v3.Address in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_AddressesTest method testViewPublicAddress.
@Test
public void testViewPublicAddress() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewAddress("4444-4444-4444-4447", 2L);
assertNotNull(response);
Address address = (Address) response.getEntity();
assertNotNull(address);
assertEquals("/4444-4444-4444-4447/address/2", address.getPath());
Utils.verifyLastModified(address.getLastModifiedDate());
assertEquals(Visibility.PUBLIC, address.getVisibility());
assertEquals("4444-4444-4444-4447", address.getSource().retrieveSourcePath());
assertEquals(Iso3166Country.US, address.getCountry().getValue());
}
use of io.envoyproxy.envoy.config.core.v3.Address in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_AddressesTest method testUpdateAddress.
@Test
public void testUpdateAddress() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
Response response = serviceDelegator.viewAddress("4444-4444-4444-4442", 1L);
assertNotNull(response);
Address address = (Address) response.getEntity();
assertNotNull(address);
Utils.verifyLastModified(address.getLastModifiedDate());
LastModifiedDate before = address.getLastModifiedDate();
assertEquals(Iso3166Country.US, address.getCountry().getValue());
assertEquals(Visibility.PUBLIC, address.getVisibility());
address.getCountry().setValue(Iso3166Country.PA);
response = serviceDelegator.updateAddress("4444-4444-4444-4442", 1L, address);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewAddress("4444-4444-4444-4442", 1L);
assertNotNull(response);
address = (Address) response.getEntity();
assertNotNull(address);
Utils.verifyLastModified(address.getLastModifiedDate());
LastModifiedDate after = address.getLastModifiedDate();
assertTrue(after.after(before));
assertEquals(Iso3166Country.PA, address.getCountry().getValue());
// Set it back to US again
address.getCountry().setValue(Iso3166Country.US);
response = serviceDelegator.updateAddress("4444-4444-4444-4442", 1L, address);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewAddress("4444-4444-4444-4442", 1L);
address = (Address) response.getEntity();
assertNotNull(address);
Utils.verifyLastModified(address.getLastModifiedDate());
assertNotNull(address.getLastModifiedDate());
assertTrue(address.getLastModifiedDate().after(after));
assertEquals(Iso3166Country.US, address.getCountry().getValue());
assertEquals(Visibility.PUBLIC, address.getVisibility());
}
Aggregations