Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Nullability Annotations to Java Classes] Add Missing Nullability Annotations to All Comment SqlUtils & Model Classes (breaking) #2870

Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
54ffcc1
Cleanup: Remove unused transient level field from comment model
ParaskP7 Oct 13, 2023
3821422
Analysis: Add missing n-a to comment model
ParaskP7 Oct 13, 2023
6e73649
Analysis: Add missing n-a to comment error on comment store
ParaskP7 Oct 13, 2023
dfc9856
Refactor: Create missing switch branch on comment error utils
ParaskP7 Oct 13, 2023
97617df
Analysis: Add missing n-a to on comment changed on comment store
ParaskP7 Oct 13, 2023
4f45ac8
Analysis: Add missing n-a to on comment likes changed on comment store
ParaskP7 Oct 13, 2023
afe04d3
Analysis: Add missing n-a to get comments for site on comment store
ParaskP7 Oct 13, 2023
6f6f787
Analysis: Add missing n-a to get comment by local id on comment store
ParaskP7 Oct 13, 2023
ad4e4fd
Analysis: Add missing n-a to all payload methods on comment store
ParaskP7 Oct 13, 2023
0465dff
Analysis: Add missing n-a to comment error to fetch comments payload
ParaskP7 Oct 13, 2023
3d47628
Analysis: Add missing n-a to comment error to fetched cmt likes payload
ParaskP7 Oct 13, 2023
bd52c72
Analysis: Add missing n-a to comment error to push comment payload
ParaskP7 Oct 13, 2023
8b52511
Analysis: Replace collections with cmt list sort on comments sql utils
ParaskP7 Oct 13, 2023
93ece6b
Refactor: Replace anonymous classes with lambda on comment sql utils
ParaskP7 Oct 13, 2023
fe724ca
Analysis: Replace comments published timestamp with long compare
ParaskP7 Oct 13, 2023
33328c9
Analysis: Suppress resource warning for well sql give me writable db
ParaskP7 Oct 13, 2023
e3dfdd5
Analysis: Guard usages of statuses on comment sql utils
ParaskP7 Oct 13, 2023
dce9c68
Analysis: Add missing n-a to insert or update cmt on comment sql utils
ParaskP7 Oct 13, 2023
3585f82
Analysis: Add missing n-a to remove comment on comment sql utils
ParaskP7 Oct 13, 2023
64a642b
Analysis: Add missing n-a to remove comments on comment sql utils
ParaskP7 Oct 13, 2023
f2b5c5c
Analysis: Add missing n-a to remove comment gaps on comment sql utils
ParaskP7 Oct 13, 2023
d24959c
Analysis: Add missing n-a to insert or update cmt likes on cmt sql utils
ParaskP7 Oct 13, 2023
a164dd0
Analysis: Add missing n-a to get cmt likes by cmt id on cmt sql utils
ParaskP7 Oct 13, 2023
94fbe92
Merge branch 'trunk' of github.com:wordpress-mobile/WordPress-FluxC-A…
ParaskP7 Oct 18, 2023
1b43bf0
Refactor: Simplify if/switch with if statement on comment error utils
ParaskP7 Oct 19, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public void testInstantiateAndCreateNewComment() throws InterruptedException {

// Check comment has been modified in the DB
CommentModel comment = mCommentStore.getCommentByLocalId(mNewComment.getId());
assertNotNull(comment);
assertTrue(comment.getContent().contains(mNewComment.getContent()));
}

Expand All @@ -174,6 +175,7 @@ public void testLikeAndUnlikeComment() throws InterruptedException {

// Check comment has been modified in the DB
CommentModel comment = mCommentStore.getCommentByLocalId(firstComment.getId());
assertNotNull(comment);
assertTrue(comment.getILike());

// Unlike comment
Expand All @@ -185,6 +187,7 @@ public void testLikeAndUnlikeComment() throws InterruptedException {

// Check comment has been modified in the DB
comment = mCommentStore.getCommentByLocalId(firstComment.getId());
assertNotNull(comment);
assertFalse(comment.getILike());
}

Expand All @@ -205,6 +208,7 @@ public void testDeleteCommentOnce() throws InterruptedException {

// Check comment has been modified in the DB
CommentModel comment = mCommentStore.getCommentByLocalId(mNewComment.getId());
assertNotNull(comment);
assertTrue(comment.getContent().contains(mNewComment.getContent()));

// Delete
Expand All @@ -216,6 +220,7 @@ public void testDeleteCommentOnce() throws InterruptedException {

// Make sure the comment is still here but state changed
comment = mCommentStore.getCommentByLocalId(mNewComment.getId());
assertNotNull(comment);
assertEquals(CommentStatus.TRASH.toString(), comment.getStatus());
}

Expand All @@ -236,6 +241,7 @@ public void testDeleteCommentTwice() throws InterruptedException {

// Check comment has been modified in the DB
CommentModel comment = mCommentStore.getCommentByLocalId(mNewComment.getId());
assertNotNull(comment);
assertTrue(comment.getContent().contains(mNewComment.getContent()));

// Delete once (ie. move to trash)
Expand Down Expand Up @@ -326,6 +332,7 @@ public void testInstantiateAndCreateReplyComment() throws InterruptedException {
CommentModel comment = mCommentStore.getCommentByLocalId(mNewComment.getId());

// Using .contains() in the assert below because server might wrap the response in <p>
assertNotNull(comment);
assertTrue(comment.getContent().contains(mNewComment.getContent()));
assertNotSame(mNewComment.getRemoteCommentId(), comment.getRemoteCommentId());
assertNotSame(mNewComment.getRemoteSiteId(), comment.getRemoteSiteId());
Expand Down Expand Up @@ -415,6 +422,7 @@ public void testCommentResponseContainsURL() throws InterruptedException {

// Check the new comment response contains URL
CommentModel comment = mCommentStore.getCommentByLocalId(mNewComment.getId());
assertNotNull(comment);
assertNotNull(comment.getUrl());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public void testInstantiateAndCreateNewComment() throws InterruptedException {

// Check comment has been modified in the DB
CommentModel comment = mCommentStore.getCommentByLocalId(mNewComment.getId());
assertNotNull(comment);
assertTrue(comment.getContent().contains(mNewComment.getContent()));
}

Expand Down Expand Up @@ -172,6 +173,7 @@ public void testInstantiateAndCreateReplyComment() throws InterruptedException {

// Check comment has been modified in the DB
CommentModel comment = mCommentStore.getCommentByLocalId(mNewComment.getId());
assertNotNull(comment);
assertEquals(comment.getContent(), mNewComment.getContent());
assertEquals(comment.getAuthorId(), firstComment.getAuthorId());
assertEquals(comment.getParentId(), firstComment.getRemoteCommentId());
Expand All @@ -196,6 +198,7 @@ public void testEditValidComment() throws InterruptedException {
assertTrue(mCountDownLatch.await(TestUtils.DEFAULT_TIMEOUT_MS, TimeUnit.MILLISECONDS));

CommentModel comment = mCommentStore.getCommentByLocalId(firstComment.getId());
assertNotNull(comment);
assertEquals(comment.getContent(), firstComment.getContent());
}

Expand Down Expand Up @@ -235,6 +238,7 @@ public void testDeleteCommentOnce() throws InterruptedException {

// Check comment has been modified in the DB
CommentModel comment = mCommentStore.getCommentByLocalId(mNewComment.getId());
assertNotNull(comment);
assertTrue(comment.getContent().contains(mNewComment.getContent()));

// Delete
Expand All @@ -246,6 +250,7 @@ public void testDeleteCommentOnce() throws InterruptedException {

// Make sure the comment is still here but state changed
comment = mCommentStore.getCommentByLocalId(mNewComment.getId());
assertNotNull(comment);
assertEquals(CommentStatus.TRASH.toString(), comment.getStatus());
}

Expand All @@ -266,6 +271,7 @@ public void testDeleteCommentTwice() throws InterruptedException {

// Check comment has been modified in the DB
CommentModel comment = mCommentStore.getCommentByLocalId(mNewComment.getId());
assertNotNull(comment);
assertTrue(comment.getContent().contains(mNewComment.getContent()));

// Delete once (ie. move to trash)
Expand Down Expand Up @@ -302,6 +308,7 @@ public void testCommentResponseContainsURL() throws InterruptedException {

// Check the new comment response contains URL
CommentModel comment = mCommentStore.getCommentByLocalId(mNewComment.getId());
assertNotNull(comment);
assertNotNull(comment.getUrl());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ class CommentsMapperTest {
authorEmail = entity.authorEmail
authorProfileImageUrl = entity.authorProfileImageUrl
postTitle = entity.postTitle
status = entity.status
datePublished = entity.datePublished
status = entity.status ?: ""
datePublished = entity.datePublished ?: ""
publishedTimestamp = entity.publishedTimestamp
content = entity.content
url = entity.authorProfileImageUrl
content = entity.content ?: ""
url = entity.authorProfileImageUrl ?: ""
hasParent = entity.hasParent
parentId = entity.parentId
iLike = entity.iLike
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.wordpress.android.fluxc.model;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.yarolegovich.wellsql.core.Identifiable;
import com.yarolegovich.wellsql.core.annotation.Column;
import com.yarolegovich.wellsql.core.annotation.PrimaryKey;
Expand All @@ -11,6 +14,7 @@
import java.io.Serializable;

@Table
@SuppressWarnings("NotNullFieldNotInitialized")
public class CommentModel extends Payload<BaseNetworkError> implements Identifiable, Serializable {
private static final long serialVersionUID = 3454722213760369852L;

Expand All @@ -23,19 +27,19 @@ public class CommentModel extends Payload<BaseNetworkError> implements Identifia
@Column private long mRemoteSiteId;

// Comment author
@Column private String mAuthorUrl;
@Column private String mAuthorName;
@Column private String mAuthorEmail;
@Nullable @Column private String mAuthorUrl;
wzieba marked this conversation as resolved.
Show resolved Hide resolved
@Nullable @Column private String mAuthorName;
@Nullable @Column private String mAuthorEmail;
@Column private long mAuthorId;
@Column private String mAuthorProfileImageUrl;
@Nullable @Column private String mAuthorProfileImageUrl;

// Comment data
@Column private String mPostTitle;
@Column private String mStatus;
@Column private String mDatePublished;
@Nullable @Column private String mPostTitle;
@NonNull @Column private String mStatus;
@NonNull @Column private String mDatePublished;
@Column private long mPublishedTimestamp;
@Column private String mContent;
@Column private String mUrl;
@NonNull @Column private String mContent;
@NonNull @Column private String mUrl;

// Parent Comment Data
@Column private boolean mHasParent;
Expand All @@ -54,9 +58,6 @@ public void setId(int id) {
mId = id;
}

// not stored in db - denotes the hierarchical level of this comment
public transient int level = 0;

public long getRemoteCommentId() {
return mRemoteCommentId;
}
Expand All @@ -73,67 +74,75 @@ public void setRemotePostId(long remotePostId) {
mRemotePostId = remotePostId;
}

@Nullable
public String getAuthorUrl() {
return mAuthorUrl;
}

public void setAuthorUrl(String authorUrl) {
public void setAuthorUrl(@Nullable String authorUrl) {
this.mAuthorUrl = authorUrl;
}

@Nullable
public String getAuthorName() {
return mAuthorName;
}

public void setAuthorName(String authorName) {
public void setAuthorName(@Nullable String authorName) {
this.mAuthorName = authorName;
}

@Nullable
public String getAuthorEmail() {
return mAuthorEmail;
}

public void setAuthorEmail(String authorEmail) {
public void setAuthorEmail(@Nullable String authorEmail) {
this.mAuthorEmail = authorEmail;
}

@Nullable
public String getAuthorProfileImageUrl() {
return mAuthorProfileImageUrl;
}

public void setAuthorProfileImageUrl(String authorProfileImageUrl) {
public void setAuthorProfileImageUrl(@Nullable String authorProfileImageUrl) {
this.mAuthorProfileImageUrl = authorProfileImageUrl;
}

@Nullable
public String getPostTitle() {
return mPostTitle;
}

public void setPostTitle(String postTitle) {
public void setPostTitle(@Nullable String postTitle) {
this.mPostTitle = postTitle;
}

@NonNull
public String getStatus() {
return mStatus;
}

public void setStatus(String status) {
public void setStatus(@NonNull String status) {
this.mStatus = status;
}

@NonNull
public String getDatePublished() {
return mDatePublished;
}

public void setDatePublished(String datePublished) {
public void setDatePublished(@NonNull String datePublished) {
this.mDatePublished = datePublished;
}

@NonNull
public String getContent() {
return mContent;
}

public void setContent(String content) {
public void setContent(@NonNull String content) {
this.mContent = content;
}

Expand Down Expand Up @@ -169,11 +178,12 @@ public void setILike(boolean iLike) {
mILike = iLike;
}

@NonNull
public String getUrl() {
return mUrl;
}

public void setUrl(String url) {
public void setUrl(@NonNull String url) {
mUrl = url;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ class CommentsMapper @Inject constructor(
this.authorEmail = entity.authorEmail
this.authorProfileImageUrl = entity.authorProfileImageUrl
this.postTitle = entity.postTitle
this.status = entity.status
this.datePublished = entity.datePublished
this.status = entity.status ?: ""
this.datePublished = entity.datePublished ?: ""
this.publishedTimestamp = entity.publishedTimestamp
this.content = entity.content
this.url = entity.url
this.content = entity.content ?: ""
this.url = entity.url ?: ""
this.hasParent = entity.hasParent
this.parentId = entity.parentId
this.iLike = entity.iLike
Expand Down
Loading
Loading