Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ updates:
directory: "/"
schedule:
interval: "weekly"
cooldown:
default-days: 7
open-pull-requests-limit: 5
groups:
spring:
Expand All @@ -13,16 +15,13 @@ updates:
gradle-plugins:
patterns:
- "org.ec4j.editorconfig"
- "io.freefair.lombok"
- "com.google.cloud.tools.jib"
test-dependencies:
patterns:
- "org.mockito*"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
cooldown:
default-days: 7
open-pull-requests-limit: 5
groups:
github-actions:
Expand Down
3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ plugins {
id 'io.spring.dependency-management' version '1.1.7'
id 'java'
id 'jacoco'
id "io.freefair.lombok" version "9.5.0"
id "org.ec4j.editorconfig" version "0.1.0"
id 'com.google.cloud.tools.jib' version '3.5.3'
}
Expand All @@ -30,8 +29,6 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-webmvc-test'
testImplementation 'org.springframework.boot:spring-boot-data-jpa-test'
testImplementation 'org.springframework.boot:spring-boot-security-test'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.mockito:mockito-inline:5.2.0'
}

apply from: 'test.gradle'
Expand Down
3 changes: 0 additions & 3 deletions lombok.config

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,30 @@
import io.github.raeperd.realworld.application.user.ProfileModel.ProfileModelNested;
import io.github.raeperd.realworld.domain.article.Article;
import io.github.raeperd.realworld.domain.article.tag.Tag;
import lombok.Value;

import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Set;

import static java.util.stream.Collectors.toSet;

@Value
class ArticleModel {

ArticleModelNested article;
record ArticleModel(ArticleModelNested article) {

static ArticleModel fromArticle(Article article) {
return new ArticleModel(ArticleModelNested.fromArticle(article));
}

@Value
static class ArticleModelNested {
String slug;
String title;
String description;
String body;
Set<String> tagList;
ZonedDateTime createdAt;
ZonedDateTime updatedAt;
boolean favorited;
int favoritesCount;
ProfileModelNested author;
record ArticleModelNested(
String slug,
String title,
String description,
String body,
Set<String> tagList,
ZonedDateTime createdAt,
ZonedDateTime updatedAt,
boolean favorited,
int favoritesCount,
ProfileModelNested author) {

static ArticleModelNested fromArticle(Article article) {
final var contents = article.getContents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import io.github.raeperd.realworld.domain.article.ArticleContents;
import io.github.raeperd.realworld.domain.article.ArticleTitle;
import io.github.raeperd.realworld.domain.article.tag.Tag;
import lombok.Value;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand All @@ -16,17 +15,11 @@

@JsonTypeName("article")
@JsonTypeInfo(include = WRAPPER_OBJECT, use = NAME)
@Value
class ArticlePostRequestDTO {

@NotBlank
String title;
@NotBlank
String description;
@NotBlank
String body;
@NotNull
Set<Tag> tagList;
record ArticlePostRequestDTO(
@NotBlank String title,
@NotBlank String description,
@NotBlank String body,
@NotNull Set<Tag> tagList) {

ArticleContents toArticleContents() {
return new ArticleContents(description, ArticleTitle.of(title), body, tagList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.github.raeperd.realworld.domain.article.ArticleTitle;
import io.github.raeperd.realworld.domain.article.ArticleUpdateRequest;
import lombok.Value;

import static com.fasterxml.jackson.annotation.JsonTypeInfo.As.WRAPPER_OBJECT;
import static com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME;
Expand All @@ -13,12 +12,7 @@

@JsonTypeName("article")
@JsonTypeInfo(include = WRAPPER_OBJECT, use = NAME)
@Value
class ArticlePutRequestDTO {

String title;
String description;
String body;
record ArticlePutRequestDTO(String title, String description, String body) {

ArticleUpdateRequest toUpdateRequest() {
return builder().titleToUpdate(ofNullable(title).map(ArticleTitle::of).orElse(null))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,15 @@

import io.github.raeperd.realworld.application.article.ArticleModel.ArticleModelNested;
import io.github.raeperd.realworld.domain.article.Article;
import lombok.Value;
import org.springframework.data.domain.Page;

import java.util.List;

import static java.util.stream.Collectors.toList;

@Value
class MultipleArticleModel {

List<ArticleModelNested> articles;
int articlesCount;
record MultipleArticleModel(List<ArticleModelNested> articles, int articlesCount) {

static MultipleArticleModel fromArticles(Page<Article> articles) {
final var articlesCollected = articles.map(ArticleModelNested::fromArticle)
.stream().collect(toList());
.stream().toList();
return new MultipleArticleModel(articlesCollected, articlesCollected.size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,22 @@

import io.github.raeperd.realworld.application.user.ProfileModel.ProfileModelNested;
import io.github.raeperd.realworld.domain.article.comment.Comment;
import lombok.Value;

import java.time.ZoneId;
import java.time.ZonedDateTime;

@Value
class CommentModel {

CommentModelNested comment;
record CommentModel(CommentModelNested comment) {

static CommentModel fromComment(Comment comment) {
return new CommentModel(CommentModelNested.fromComment(comment));
}

@Value
static class CommentModelNested {
long id;
String body;
ZonedDateTime createdAt;
ZonedDateTime updatedAt;
ProfileModelNested author;
record CommentModelNested(
long id,
String body,
ZonedDateTime createdAt,
ZonedDateTime updatedAt,
ProfileModelNested author) {

static CommentModelNested fromComment(Comment comment) {
return new CommentModelNested(comment.getId(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package io.github.raeperd.realworld.application.article.comment;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Getter;

import jakarta.validation.constraints.NotBlank;

Expand All @@ -12,14 +10,5 @@

@JsonTypeName("comment")
@JsonTypeInfo(include = WRAPPER_OBJECT, use = NAME)
@Getter
class CommentPostRequestDTO {

@NotBlank
private final String body;

@JsonCreator
CommentPostRequestDTO(String body) {
this.body = body;
}
record CommentPostRequestDTO(@NotBlank String body) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CommentRestController {
@PostMapping("/articles/{slug}/comments")
public CommentModel postComments(@AuthenticationPrincipal UserJWTPayload jwtPayload,
@PathVariable String slug, @Valid @RequestBody CommentPostRequestDTO dto) {
final var commentAdded = commentService.createComment(jwtPayload.getUserId(), slug, dto.getBody());
final var commentAdded = commentService.createComment(jwtPayload.getUserId(), slug, dto.body());
return CommentModel.fromComment(commentAdded);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@

import io.github.raeperd.realworld.application.article.comment.CommentModel.CommentModelNested;
import io.github.raeperd.realworld.domain.article.comment.Comment;
import lombok.Value;

import java.util.List;
import java.util.Set;

import static java.util.stream.Collectors.toList;

@Value
class MultipleCommentModel {

List<CommentModelNested> comments;
record MultipleCommentModel(List<CommentModelNested> comments) {

static MultipleCommentModel fromComments(Set<Comment> comments) {
final var commentsCollected = comments.stream().map(CommentModelNested::fromComment)
.collect(toList());
.toList();
return new MultipleCommentModel(commentsCollected);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
package io.github.raeperd.realworld.application.tag;

import lombok.Getter;

import java.util.Set;

@Getter
class TagsModel {

private final Set<String> tags;

TagsModel(Set<String> tags) {
this.tags = tags;
}
record TagsModel(Set<String> tags) {
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
package io.github.raeperd.realworld.application.user;

import io.github.raeperd.realworld.domain.user.Profile;
import lombok.Value;

import static java.lang.String.valueOf;

@Value
public class ProfileModel {

ProfileModelNested profile;
public record ProfileModel(ProfileModelNested profile) {

public static ProfileModel fromProfile(Profile profile) {
return new ProfileModel(ProfileModelNested.fromProfile(profile));
}

@Value
public static class ProfileModelNested {
String username;
String bio;
String image;
boolean following;
public record ProfileModelNested(String username, String bio, String image, boolean following) {

public static ProfileModelNested fromProfile(Profile profile) {
return new ProfileModelNested(valueOf(profile.getUserName()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Value;

import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
Expand All @@ -12,12 +11,5 @@

@JsonTypeName("user")
@JsonTypeInfo(include = WRAPPER_OBJECT, use = NAME)
@Value
class UserLoginRequestDTO {

@Email
String email;
@NotBlank
String password;

record UserLoginRequestDTO(@Email String email, @NotBlank String password) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,14 @@
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.github.raeperd.realworld.domain.user.User;
import lombok.Value;

import static com.fasterxml.jackson.annotation.JsonTypeInfo.As.WRAPPER_OBJECT;
import static com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME;
import static java.lang.String.valueOf;

@JsonTypeName("user")
@JsonTypeInfo(include = WRAPPER_OBJECT, use = NAME)
@Value
class UserModel {

String email;
String username;
String token;
String bio;
String image;
record UserModel(String email, String username, String token, String bio, String image) {

static UserModel fromUserAndToken(User user, String token) {
return new UserModel(
Expand All @@ -28,5 +20,4 @@ static UserModel fromUserAndToken(User user, String token) {
"",
"");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import io.github.raeperd.realworld.domain.user.Email;
import io.github.raeperd.realworld.domain.user.UserName;
import io.github.raeperd.realworld.domain.user.UserSignUpRequest;
import lombok.Value;

import jakarta.validation.constraints.NotBlank;

Expand All @@ -14,21 +13,15 @@

@JsonTypeName("user")
@JsonTypeInfo(include = WRAPPER_OBJECT, use = NAME)
@Value
class UserPostRequestDTO {

@jakarta.validation.constraints.Email
String email;
@NotBlank
String username;
@NotBlank
String password;
record UserPostRequestDTO(
@jakarta.validation.constraints.Email String email,
@NotBlank String username,
@NotBlank String password) {

UserSignUpRequest toSignUpRequest() {
return new UserSignUpRequest(
new Email(email),
new UserName(username),
password);
}

}
Loading