I want to deserialize Json array in the Rest-Assure respons into TodoList with Todo object as elements in the List. I have a class Todo
import java.util.Date;
public class Todo {
private Long id;
private String name;
private String description;
private Date targetDate;
private Boolean isDone;
protected Todo() {
}
/**
* Get the id of the bank.
* @return id for the bank
*/
public Long getId() {
return id;
}
public Todo(String name, String description, Date targetDate, boolean isDone) {
this.name = name;
this.description = description;
this.targetDate = targetDate;
this.isDone = isDone;
}
public void setName( String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public String getDescription() {
return this.description;
}
public Date getTargetDate() {
return this.targetDate;
}
public Boolean getIsDone() {
return this.isDone;
}
public void setId(Long id) {
this.id = id;
}
public void setDescription(String description) {
this.description = description;
}
public void setTargetDate(Date targetDate) {
this.targetDate = targetDate;
}
public void setIsDone(Boolean isDone) {
this.isDone = isDone;
}
}
Objects of this class is manage in a ListTodo class
package com.steinko.todo;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
public class TodoList {
private List<Todo> todos = new ArrayList<>();
public void addTodo(Todo todo) {
this.todos.add(todo);
}
public void addAllTodos(Collection<Todo> todos) {
this.todos.addAll(todos);
}
public List<Todo> booksByAuthor(String author) {
return todos.stream()
.filter(book -> Objects.equals(author, book.getName()))
.collect(Collectors.toList());
}
}
I want that the Rest Assure query shuold deliver a TodoList. I want to convert from a Json array into TodoList How do I do that
TodoList result = given().
when().
get("/user/stein/todos").??????