use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class RuleServiceTest method testUpdateRule.
public void testUpdateRule() throws Exception {
JSONObject jsonRule = createRule(testNodeRef);
String ruleId = jsonRule.getJSONObject("data").getString("id");
Response getResponse = sendRequest(new GetRequest(formateRuleUrl(testNodeRef, ruleId)), 200);
JSONObject before = new JSONObject(getResponse.getContentAsString());
// do some changes
before.put("description", "this is modified description for test_rule");
// do some changes for action object
JSONObject beforeAction = before.getJSONObject("action");
// no changes for actions list
beforeAction.remove("actions");
// clear conditions
beforeAction.put("conditions", new JSONArray());
Response putResponse = sendRequest(new PutRequest(formateRuleUrl(testNodeRef, ruleId), before.toString(), "application/json"), 200);
JSONObject after = new JSONObject(putResponse.getContentAsString());
// sent and retrieved objects should be the same (except ids and urls)
// this means that all changes was saved
checkUpdatedRule(before, after);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class RuleServiceTest method testGetActionConstraint.
public void testGetActionConstraint() throws Exception {
List<ParameterConstraint> constraints = actionService.getParameterConstraints();
if (constraints.size() == 0) {
return;
}
String name = constraints.get(0).getName();
Response response = sendRequest(new GetRequest(formateActionConstraintUrl(name)), 200);
JSONObject result = new JSONObject(response.getContentAsString());
assertNotNull(result);
assertTrue(result.has("data"));
JSONObject data = result.getJSONObject("data");
assertTrue(data.has("name"));
assertTrue(data.has("values"));
JSONArray values = data.getJSONArray("values");
for (int i = 0; i < values.length(); i++) {
JSONObject value = values.getJSONObject(i);
assertTrue(value.has("value"));
assertTrue(value.has("displayLabel"));
}
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class SiteExportServiceTest method testExportSiteWithMutipleUsers.
public void testExportSiteWithMutipleUsers() throws Exception {
// Create a site
String shortName = GUID.generate();
createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
// add a user and a person as members
addSiteMember(USER_FROM_LDAP, shortName);
addSiteMember(USER_ONE, shortName);
// Export site
Response response = sendRequest(new GetRequest(getExportUrl(shortName)), 200);
// check exported files
List<String> entries = getEntries(new ZipInputStream(new ByteArrayInputStream(response.getContentAsByteArray())));
assertFalse(entries.contains("No_Users_In_Site.txt"));
assertFalse(entries.contains("No_Persons_In_Site.txt"));
assertTrue(entries.contains("People.acp"));
assertTrue(entries.contains(shortName + "-people.xml"));
assertTrue(entries.contains("Users.acp"));
assertTrue(entries.contains(shortName + "-users.xml"));
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class SiteServiceTest method testListInvitation.
/**
* Detailed Test of List Invitation Web Script.
* @throws Exception
*/
public void testListInvitation() throws Exception {
String shortName = GUID.generate();
createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
String inviteeComments = "Please sir, let $* me in";
String userName = USER_TWO;
String roleName = SiteModel.SITE_CONSUMER;
String moderatedIdA = createModeratedInvitation(shortName, inviteeComments, userName, roleName);
String inviteeCommentsB = "Please sir, let $* me in";
String userNameB = USER_THREE;
String roleNameB = SiteModel.SITE_CONSUMER;
String moderatedIdB = createModeratedInvitation(shortName, inviteeCommentsB, userNameB, roleNameB);
String inviteeFirstName = "Buffy";
String inviteeLastName = "Summers";
String inviteeEmail = "buffy@sunnydale";
String inviteeUserName = userName;
String serverPath = "http://localhost:8081/share/";
String acceptURL = "page/accept-invite";
String rejectURL = "page/reject-invite";
// Create a nominated invitation
String nominatedId = createNominatedInvitation(shortName, inviteeFirstName, inviteeLastName, inviteeEmail, inviteeUserName, roleName, serverPath, acceptURL, rejectURL, 201);
/**
* search by user - negative test wombat does not have an invitation
*/
{
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations?inviteeUserName=wombat"), 200);
JSONObject top = new JSONObject(response.getContentAsString());
JSONArray data = top.getJSONArray("data");
assertEquals("user wombat", data.length(), 0);
}
/**
* search by user - find USER_TWO's invitation
*/
{
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations?inviteeUserName=" + USER_TWO), 200);
JSONObject top = new JSONObject(response.getContentAsString());
// System.out.println(response.getContentAsString());
JSONArray data = top.getJSONArray("data");
assertEquals("user two invitation not found", 1, data.length());
JSONObject first = data.getJSONObject(0);
assertEquals("userid is wrong", first.getString("inviteeUserName"), USER_TWO);
}
/**
* search by type - should find two moderated invitations
*/
{
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations?invitationType=MODERATED"), 200);
JSONObject top = new JSONObject(response.getContentAsString());
// System.out.println(response.getContentAsString());
JSONArray data = top.getJSONArray("data");
assertEquals("two moderated invitations not found", data.length(), 2);
}
// negative test - unknown invitationType
{
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations?invitationType=Crap"), 500);
JSONObject top = new JSONObject(response.getContentAsString());
}
/**
* search by user and type
*/
{
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations?inviteeUserName=" + USER_TWO + "&invitationType=MODERATED"), 200);
JSONObject top = new JSONObject(response.getContentAsString());
// System.out.println(response.getContentAsString());
JSONArray data = top.getJSONArray("data");
assertEquals("user two invitation not found", data.length(), 1);
JSONObject first = data.getJSONObject(0);
assertEquals("first userid is wrong", first.getString("inviteeUserName"), USER_TWO);
assertEquals("type is wrong", first.getString("invitationType"), "MODERATED");
}
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class SiteServiceTest method testGetMemberships.
public void testGetMemberships() throws Exception {
// Create a site
String shortName = GUID.generate();
createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
// Check the memberships
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS), 200);
JSONArray result = new JSONArray(response.getContentAsString());
assertNotNull(result);
assertEquals(1, result.length());
JSONObject membership = result.getJSONObject(0);
assertEquals(SiteModel.SITE_MANAGER, membership.get("role"));
assertEquals(USER_ONE, membership.getJSONObject("authority").get("userName"));
}
Aggregations