mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.2.0 (5.2.0) to HEAD (5.2)
133849 rmunteanu: REPO-1746: Merge fixes for 5.2 GA issues to 5.2.0 branch Merged 5.2.N (5.2.1) to 5.2.0 (5.2.0) 133351 jvonka: REPO-1646: V1 REST API - cannot unset optional fields (eg. when updating person / site details ...) - minor fixes with tests (update person) - ensure enabled & emailNotificationsEnabled cannot be null - null/empty company object should unset all fields (fix for empty case) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@134188 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -833,6 +833,11 @@ public class TestPeople extends EnterpriseTestApi
|
||||
// TODO: temp fix, set back to orig firstName
|
||||
publicApiClient.setRequestContext(new RequestContext(account1.getId(), account1Admin, "admin"));
|
||||
people.update(personId, qjson("{ `firstName`:`Bill` }"), 200);
|
||||
|
||||
// -ve test: check that required/mandatory/non-null fields cannot be unset (or empty string)
|
||||
people.update("people", personId, null, null, qjson("{ `firstName`:`` }"), null, "Expected 400 response when updating " + personId, 400);
|
||||
people.update("people", personId, null, null, qjson("{ `email`:`` }"), null, "Expected 400 response when updating " + personId, 400);
|
||||
people.update("people", personId, null, null, qjson("{ `emailNotificationsEnabled`:`` }"), null, "Expected 400 response when updating " + personId, 400);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -977,7 +982,6 @@ public class TestPeople extends EnterpriseTestApi
|
||||
+ " \"location\":null,\n"
|
||||
|
||||
+ " \"company\": {\n"
|
||||
+ " \"organization\":null,\n"
|
||||
+ " \"address1\":null,\n"
|
||||
+ " \"address2\":null,\n"
|
||||
+ " \"address3\":null,\n"
|
||||
@@ -1005,7 +1009,8 @@ public class TestPeople extends EnterpriseTestApi
|
||||
assertNull(updatedPerson.getLocation());
|
||||
|
||||
assertNotNull(updatedPerson.getCompany());
|
||||
assertNull(updatedPerson.getCompany().getOrganization());
|
||||
assertNotNull(updatedPerson.getCompany().getOrganization());
|
||||
|
||||
assertNull(updatedPerson.getCompany().getAddress1());
|
||||
assertNull(updatedPerson.getCompany().getAddress2());
|
||||
assertNull(updatedPerson.getCompany().getAddress3());
|
||||
@@ -1018,6 +1023,19 @@ public class TestPeople extends EnterpriseTestApi
|
||||
assertNull(updatedPerson.getTelephone());
|
||||
assertNull(updatedPerson.getUserStatus());
|
||||
|
||||
// test ability to unset company fields as a whole
|
||||
response = people.update("people", personId, null, null,
|
||||
"{\n"
|
||||
+ " \"company\": {} \n"
|
||||
+ "}", params,
|
||||
"Expected 200 response when updating " + personId, 200);
|
||||
|
||||
updatedPerson = Person.parsePerson((JSONObject) response.getJsonResponse().get("entry"));
|
||||
|
||||
// note: empty company object is returned for backwards compatibility (with pre-existing getPerson API <= 5.1)
|
||||
assertNotNull(updatedPerson.getCompany());
|
||||
assertNull(updatedPerson.getCompany().getOrganization());
|
||||
|
||||
// set at least one company field
|
||||
String updatedOrgName = "another org";
|
||||
|
||||
@@ -1045,7 +1063,6 @@ public class TestPeople extends EnterpriseTestApi
|
||||
|
||||
// note: empty company object is returned for backwards compatibility (with pre-existing getPerson API <= 5.1)
|
||||
assertNotNull(updatedPerson.getCompany());
|
||||
|
||||
assertNull(updatedPerson.getCompany().getOrganization());
|
||||
}
|
||||
|
||||
@@ -1085,6 +1102,10 @@ public class TestPeople extends EnterpriseTestApi
|
||||
assertEquals(enabled, updatedPerson.isEnabled());
|
||||
}
|
||||
|
||||
// -ve test: enabled flag cannot be null/empty
|
||||
people.update("people", personId, null, null, qjson("{ `enabled`: null }"), null, "Expected 400 response when updating " + personId, 400);
|
||||
people.update("people", personId, null, null, qjson("{ `enabled`: `` }"), null, "Expected 400 response when updating " + personId, 400);
|
||||
|
||||
// Use non-admin user's own credentials
|
||||
publicApiClient.setRequestContext(new RequestContext(account3.getId(), personId, "password"));
|
||||
|
||||
|
Reference in New Issue
Block a user