Package org.springside.examples.quickstart.entity

Examples of org.springside.examples.quickstart.entity.Task


    return "task/taskList";
  }

  @RequestMapping(value = "create", method = RequestMethod.GET)
  public String createForm(Model model) {
    model.addAttribute("task", new Task());
    model.addAttribute("action", "create");
    return "task/taskForm";
  }
View Full Code Here


    return taskService.getAllTask();
  }

  @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = MediaTypes.JSON_UTF_8)
  public Task get(@PathVariable("id") Long id) {
    Task task = taskService.getTask(id);
    if (task == null) {
      String message = "任务不存在(id:" + id + ")";
      logger.warn(message);
      throw new RestException(HttpStatus.NOT_FOUND, message);
    }
View Full Code Here

   * 获取任务.
   */
  @Test
  @Category(Smoke.class)
  public void getTask() {
    Task task = restTemplate.getForObject(resourceUrl + "/{id}", Task.class, 1L);
    assertThat(task.getTitle()).isEqualTo("Study PlayFramework 2.0");
  }
View Full Code Here

  @Test
  @Category(Smoke.class)
  public void createUpdateAndDeleteTask() {

    // create
    Task task = TaskData.randomTask();

    URI createdTaskUri = restTemplate.postForLocation(resourceUrl, task);
    System.out.println(createdTaskUri.toString());
    Task createdTask = restTemplate.getForObject(createdTaskUri, Task.class);
    assertThat(createdTask.getTitle()).isEqualTo(task.getTitle());

    // update
    String id = StringUtils.substringAfterLast(createdTaskUri.toString(), "/");
    task.setId(new Long(id));
    task.setTitle(TaskData.randomTitle());

    restTemplate.put(createdTaskUri, task);

    Task updatedTask = restTemplate.getForObject(createdTaskUri, Task.class);
    assertThat(updatedTask.getTitle()).isEqualTo(task.getTitle());

    // delete
    restTemplate.delete(createdTaskUri);

    try {
View Full Code Here

  @Test
  public void invalidInput() {

    // create
    Task titleBlankTask = new Task();
    try {
      restTemplate.postForLocation(resourceUrl, titleBlankTask);
      fail("Create should fail while title is blank");
    } catch (HttpStatusCodeException e) {
      assertThat(e.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
      Map messages = jsonMapper.fromJson(e.getResponseBodyAsString(), Map.class);
      assertThat(messages).hasSize(1);
      assertThat(messages.get("title")).isIn("may not be empty", "不能为空");
    }

    // update
    titleBlankTask.setId(1L);
    try {
      restTemplate.put(resourceUrl + "/1", titleBlankTask);
      fail("Update should fail while title is blank");
    } catch (HttpStatusCodeException e) {
      assertThat(e.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
View Full Code Here

* @author calvin
*/
public class TaskData {

  public static Task randomTask() {
    Task task = new Task();
    task.setTitle(randomTitle());
    User user = new User(1L);
    task.setUser(user);
    return task;
  }
View Full Code Here

    s.open("/task/");

    // create
    s.click(By.linkText("创建任务"));

    Task task = TaskData.randomTask();
    s.type(By.id("task_title"), task.getTitle());
    s.click(By.id("submit_btn"));

    assertThat(s.isTextPresent("创建任务成功")).isTrue();

    // update
    s.click(By.linkText(task.getTitle()));
    assertThat(s.getValue(By.id("task_title"))).isEqualTo(task.getTitle());

    String newTitle = TaskData.randomTitle();
    s.type(By.id("task_title"), newTitle);
    s.click(By.id("submit_btn"));
    assertThat(s.isTextPresent("更新任务成功")).isTrue();
View Full Code Here

TOP

Related Classes of org.springside.examples.quickstart.entity.Task

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.