@Test
 public void shouldSearchAConceptSourceIfItMatchesTheQuery() throws Exception {
   MockHttpServletRequest req = request(RequestMethod.GET, getURI());
   req.addParameter("q", "ome");
   SimpleObject result = deserialize(handle(req));
   Assert.assertEquals(2, Util.getResultsSize(result));
 }
  @Test
  public void shouldGetAll() throws Exception {
    SimpleObject result = deserialize(handle(request(RequestMethod.GET, getURI())));

    Assert.assertNotNull(result);
    Assert.assertEquals(getAllCount(), Util.getResultsSize(result));
  }
  @Test
  public void shouldListAllConceptSources() throws Exception {
    MockHttpServletRequest req = request(RequestMethod.GET, getURI());
    SimpleObject result = deserialize(handle(req));

    Assert.assertNotNull(result);
    Assert.assertEquals(getAllCount(), Util.getResultsSize(result));
  }
 /**
  * @see VisitAttributeTypeController#search(String, javax.servlet.http.HttpServletRequest,
  *     HttpServletResponse)
  */
 @Test
 public void search_shouldFindAllMatchingVisitAttributeTypesIfIncludeAllIsSetToTrue()
     throws Exception {
   MockHttpServletRequest request = emptyRequest();
   request.addParameter(RestConstants.REQUEST_PROPERTY_FOR_INCLUDE_ALL, "true");
   Assert.assertEquals(
       3, Util.getResultsSize(controller.search("date", request, emptyResponse())));
 }
コード例 #5
0
  @Test
  public void shouldListAllUsers() throws Exception {
    int totalCount = Context.getUserService().getAllUsers().size();

    SimpleObject result =
        new UserController().getAll(emptyRequest(), new MockHttpServletResponse());
    Assert.assertNotNull(result);
    Assert.assertEquals(totalCount, Util.getResultsSize(result));
  }
コード例 #6
0
 /**
  * @see UserController#createUser(SimpleObject,WebRequest)
  * @verifies create a new user
  */
 @Test
 public void createUser_shouldCreateANewUser() throws Exception {
   int before = Context.getUserService().getAllUsers().size();
   String json =
       "{\"username\":\"test\",\"password\":\"Admin@123\",\"person\":\"da7f524f-27ce-4bb2-86d6-6d1d05312bd5\"}}";
   SimpleObject post = new ObjectMapper().readValue(json, SimpleObject.class);
   Object newUser =
       new UserController().create(post, emptyRequest(), new MockHttpServletResponse());
   Util.log("Created User", newUser);
   Assert.assertEquals(before + 1, Context.getUserService().getAllUsers().size());
 }
コード例 #7
0
 /**
  * @see UserController#getUser(UserAndPassword,WebRequest)
  * @verifies get a default representation of a UserAndPassword
  */
 @Test
 public void getUser_shouldGetADefaultRepresentationOfAUser() throws Exception {
   Object result =
       new UserController().retrieve("c98a1558-e131-11de-babe-001e378eb67e", emptyRequest());
   Assert.assertNotNull(result);
   Util.log("User retrieved (default)", result);
   Assert.assertEquals(
       "c98a1558-e131-11de-babe-001e378eb67e", PropertyUtils.getProperty(result, "uuid"));
   Assert.assertNotNull(PropertyUtils.getProperty(result, "username"));
   Assert.assertEquals("butch", PropertyUtils.getProperty(result, "username"));
   Assert.assertNull(PropertyUtils.getProperty(result, "auditInfo"));
 }
コード例 #8
0
 /**
  * @see PatientController#getPatient(String,WebRequest)
  * @verifies get a full representation of a patient
  */
 @Test
 public void getUser_shouldGetAFullRepresentationOfAPatient() throws Exception {
   MockHttpServletRequest req = new MockHttpServletRequest();
   req.addParameter(
       RestConstants.REQUEST_PROPERTY_FOR_REPRESENTATION, RestConstants.REPRESENTATION_FULL);
   Object result = new UserController().retrieve("c1d8f5c2-e131-11de-babe-001e378eb67e", req);
   Util.log("User retrieved (full)", result);
   Assert.assertNotNull(result);
   Assert.assertEquals(
       "c1d8f5c2-e131-11de-babe-001e378eb67e", PropertyUtils.getProperty(result, "uuid"));
   Assert.assertNotNull(PropertyUtils.getProperty(result, "secretQuestion"));
   Assert.assertEquals("", PropertyUtils.getProperty(result, "secretQuestion"));
 }
コード例 #9
0
 /**
  * @see UserController#createUser(SimpleObject,WebRequest)
  * @verifies create a new user
  */
 @Test
 public void createUser_shouldCreateANewUserWithRoles() throws Exception {
   int before = Context.getUserService().getAllUsers().size();
   String json =
       "{\"username\":\"test\",\"password\":\"Admin@123\",\"person\":\"da7f524f-27ce-4bb2-86d6-6d1d05312bd5\",\"roles\":[\"3480cb6d-c291-46c8-8d3a-96dc33d199fb\"]}";
   SimpleObject post = new ObjectMapper().readValue(json, SimpleObject.class);
   Object newUser =
       new UserController().create(post, emptyRequest(), new MockHttpServletResponse());
   Util.log("Created another user with a role this time", newUser);
   Assert.assertEquals(before + 1, Context.getUserService().getAllUsers().size());
   User createdUser = Context.getUserService().getUserByUsername("test");
   Assert.assertTrue(createdUser.hasRole("Provider"));
 }
コード例 #10
0
 /**
  * @see UserController#findUsers(String,WebRequest,HttpServletResponse)
  * @verifies find matching users
  */
 @Test
 public void findUsers_shouldFindMatchingUsers() throws Exception {
   List<Object> results =
       (List<Object>)
           new UserController()
               .search("but", emptyRequest(), new MockHttpServletResponse())
               .get("results");
   Assert.assertEquals(1, results.size());
   Util.log("Found " + results.size() + " user(s)", results);
   Object result = results.get(0);
   Assert.assertEquals(
       "c98a1558-e131-11de-babe-001e378eb67e", PropertyUtils.getProperty(result, "uuid"));
 }
コード例 #11
0
 /**
  * @see UserController#updateUser(UserAndPassword,SimpleObject,WebRequest)
  * @verifies change a property on a patient
  */
 @Test
 @Ignore("RESTWS-242: Define creatable/updatable properties on UserResource resource")
 public void updateUser_shouldChangeAPropertyOnAUser() throws Exception {
   UserAndPassword user = new UserResource().getByUniqueId("c98a1558-e131-11de-babe-001e378eb67e");
   Assert.assertFalse("5-6".equals(user.getUser().getSystemId()));
   SimpleObject post =
       new ObjectMapper()
           .readValue("{\"systemId\":\"5-6\",\"password\":\"Admin@123\"}", SimpleObject.class);
   Object editedUser =
       new UserController()
           .update(
               "c98a1558-e131-11de-babe-001e378eb67e",
               post,
               emptyRequest(),
               new MockHttpServletResponse());
   Util.log("Edited SystemId", editedUser);
   user = new UserResource().getByUniqueId("c98a1558-e131-11de-babe-001e378eb67e");
   Assert.assertEquals("5-6", user.getUser().getSystemId());
 }
 /**
  * @see VisitAttributeTypeController#search(String, javax.servlet.http.HttpServletRequest,
  *     HttpServletResponse)
  */
 @Test
 public void search_shouldFindMatchingVisitAttributeTypesExcludingRetiredOnes() throws Exception {
   Assert.assertEquals(
       2, Util.getResultsSize(controller.search("date", emptyRequest(), emptyResponse())));
 }
 /**
  * @see VisitAttributeTypeController#getAll(javax.servlet.http.HttpServletRequest,
  *     HttpServletResponse)
  */
 @Test
 public void getAll_shouldGellVisitAttributeTypesExcludingRetiredOnes() throws Exception {
   Assert.assertEquals(3, Util.getResultsSize(controller.getAll(emptyRequest(), emptyResponse())));
 }