Skip to content

Commit

Permalink
feat : use fluent setters
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Feb 9, 2024
1 parent ad548d9 commit 09b5040
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion graphql/boot-graphql-webmvc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@
<configuration>
<java>
<googleJavaFormat>
<version>1.17.0</version>
<version>1.19.2</version>
<style>AOSP</style>
</googleJavaFormat>
</java>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import com.example.graphql.entities.PostCommentEntity;
import com.example.graphql.entities.PostDetailsEntity;
import com.example.graphql.entities.PostEntity;
import com.example.graphql.entities.TagEntity;
import com.example.graphql.repositories.AuthorRepository;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.util.stream.LongStream;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -49,6 +51,12 @@ public void run(String... args) {
postEntity.setDetails(post1Details);
postEntity.addComment(post1Comment);
postEntity.addComment(post1Comment2);
if (i == 1) {
postEntity.addTag(
new TagEntity()
.setTagName("java")
.setTagDescription("new java language"));
}

PostEntity postEntity1 =
new PostEntity()
Expand All @@ -72,7 +80,8 @@ public void run(String... args) {
.setEmail("user" + i + "@example.com")
.setFirstName("first name" + i)
.setLastName("last name" + i)
.setMobile(9848922338L);
.setMobile(9848922338L)
.setRegisteredAt(LocalDateTime.now());
authorEntity.addPost(postEntity);
authorEntity.addPost(postEntity1);
this.authorRepository.save(authorEntity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,16 @@
import java.io.Serializable;
import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Entity
@Table(
name = "tags",
uniqueConstraints = {@UniqueConstraint(columnNames = "tag_name", name = "uc_tag_name")})
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class TagEntity implements Serializable {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ void setUp() {
tagRepository.deleteAll();

tagEntityList = new ArrayList<>();
tagEntityList.add(TagEntity.builder().tagName("First Tag").build());
tagEntityList.add(TagEntity.builder().tagName("Second Tag").build());
tagEntityList.add(TagEntity.builder().tagName("Third Tag").build());
tagEntityList.add(new TagEntity().setTagName("First Tag"));
tagEntityList.add(new TagEntity().setTagName("Second Tag"));
tagEntityList.add(new TagEntity().setTagName("Third Tag"));
tagEntityList = tagRepository.saveAll(tagEntityList);
}

Expand Down

0 comments on commit 09b5040

Please sign in to comment.