2017-08-17 13:27:29 +07:00
|
|
|
package io.spring;
|
|
|
|
|
2017-08-18 16:08:27 +07:00
|
|
|
import io.spring.application.data.ArticleData;
|
|
|
|
import io.spring.application.data.ProfileData;
|
2017-08-17 13:27:29 +07:00
|
|
|
import io.spring.core.article.Article;
|
|
|
|
import io.spring.core.user.User;
|
|
|
|
import org.joda.time.DateTime;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
public class TestHelper {
|
|
|
|
public static ArticleData articleDataFixture(String seed, User user) {
|
|
|
|
DateTime now = new DateTime();
|
|
|
|
return new ArticleData(
|
|
|
|
seed + "id",
|
|
|
|
"title-" + seed,
|
|
|
|
"title " + seed,
|
|
|
|
"desc " + seed,
|
|
|
|
"body " + seed, false, 0, now, now, new ArrayList<>(),
|
|
|
|
new ProfileData(user.getId(), user.getUsername(), user.getBio(), user.getImage(), false));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ArticleData getArticleDataFromArticleAndUser(Article article, User user) {
|
|
|
|
return new ArticleData(
|
|
|
|
article.getId(),
|
|
|
|
article.getSlug(),
|
|
|
|
article.getTitle(),
|
|
|
|
article.getDescription(),
|
|
|
|
article.getBody(),
|
|
|
|
false,
|
|
|
|
0,
|
2017-08-17 16:17:37 +07:00
|
|
|
article.getCreatedAt(),
|
|
|
|
article.getUpdatedAt(),
|
2017-08-17 13:27:29 +07:00
|
|
|
Arrays.asList("joda"),
|
|
|
|
new ProfileData(user.getId(), user.getUsername(), user.getBio(), user.getImage(), false));
|
|
|
|
}
|
|
|
|
}
|