mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM: Fix up unit test and event web script
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@51947 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -41,6 +41,9 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
|
|||||||
*/
|
*/
|
||||||
public class RmEventPut extends RMEventBase
|
public class RmEventPut extends RMEventBase
|
||||||
{
|
{
|
||||||
|
/** Parameter names */
|
||||||
|
public static final String PARAM_EVENTNAME = "eventname";
|
||||||
|
|
||||||
/** Records management event service */
|
/** Records management event service */
|
||||||
private RecordsManagementEventService rmEventService;
|
private RecordsManagementEventService rmEventService;
|
||||||
|
|
||||||
@@ -72,8 +75,14 @@ public class RmEventPut extends RMEventBase
|
|||||||
json = new JSONObject(new JSONTokener(req.getContent().getContent()));
|
json = new JSONObject(new JSONTokener(req.getContent().getContent()));
|
||||||
|
|
||||||
// Check the event name
|
// Check the event name
|
||||||
String eventName = getValue(json, "eventName");
|
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||||
doCheck(eventName, "No event name was provided.");
|
String eventName = templateVars.get(PARAM_EVENTNAME);
|
||||||
|
if (eventName == null ||
|
||||||
|
eventName.isEmpty() ||
|
||||||
|
rmEventService.existsEvent(eventName) == false)
|
||||||
|
{
|
||||||
|
throw new WebScriptException(Status.STATUS_NOT_FOUND, "No event name was provided.");
|
||||||
|
}
|
||||||
|
|
||||||
// Check the event display label
|
// Check the event display label
|
||||||
String eventDisplayLabel = getValue(json, "eventDisplayLabel");
|
String eventDisplayLabel = getValue(json, "eventDisplayLabel");
|
||||||
|
@@ -181,6 +181,11 @@ public class EventRestApiTest extends BaseRMWebScriptTestCase implements Records
|
|||||||
assertEquals(EVENT_TYPE, eventObj.get(KEY_EVENT_TYPE));
|
assertEquals(EVENT_TYPE, eventObj.get(KEY_EVENT_TYPE));
|
||||||
|
|
||||||
// Bad requests
|
// Bad requests
|
||||||
|
obj = new JSONObject();
|
||||||
|
obj.put(KEY_EVENT_NAME, "cheese");
|
||||||
|
obj.put(KEY_EVENT_DISPLAY_LABEL, "whatever");
|
||||||
|
obj.put(KEY_EVENT_TYPE, EVENT_TYPE);
|
||||||
|
|
||||||
sendRequest(new PutRequest(GET_EVENTS_URL + "/cheese", obj.toString(), APPLICATION_JSON), 404);
|
sendRequest(new PutRequest(GET_EVENTS_URL + "/cheese", obj.toString(), APPLICATION_JSON), 404);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
Reference in New Issue
Block a user