UserSearchResourceTest.java 981 字节
Newer Older
1
package org.activiti.rest.api.legacy;
T
tijsrademakers 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

import org.activiti.rest.BaseRestTestCase;
import org.codehaus.jackson.JsonNode;
import org.restlet.representation.Representation;
import org.restlet.resource.ClientResource;

public class UserSearchResourceTest extends BaseRestTestCase {

  public void testGetAllUsers() throws Exception {
    ClientResource client = getAuthenticatedClient("users");
    try {
      client.get();
      fail();
    } catch(Exception e) {
      // not allowed, should provide search text
    }
  }
  
  public void testGetUsers() throws Exception {
    ClientResource client = getAuthenticatedClient("users?searchText=erm");
    Representation response = client.get();
    JsonNode responseNode = objectMapper.readTree(response.getStream());
    assertNotNull(responseNode);
    assertEquals(1, responseNode.get("total").asInt());
    JsonNode userNode = responseNode.get("data").get(0);
    assertEquals("Kermit", userNode.get("firstName").asText());
  }
}