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

Test/#221 user domain #222

Merged
merged 5 commits into from
Mar 6, 2024
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
10 changes: 5 additions & 5 deletions src/main/java/io/oeid/mogakgo/domain/user/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ public static User of(long githubPk, String username, String avatarUrl, String g
return new User(githubPk, username, avatarUrl, githubUrl, repositoryUrl);
}

public void addDevelopLanguage(UserDevelopLanguageTag userDevelopLanguageTag) {
protected void addDevelopLanguage(UserDevelopLanguageTag userDevelopLanguageTag) {
if (userDevelopLanguageTags.size() + 1 > MAX_TAG_SIZE) {
throw new UserException(ErrorCode400.USER_DEVELOP_LANGUAGE_BAD_REQUEST);
}
userDevelopLanguageTags.add(userDevelopLanguageTag);
}

public void addWantedJob(UserWantedJobTag userWantedJobTag) {
protected void addWantedJob(UserWantedJobTag userWantedJobTag) {
if (userWantedJobTags.size() + 1 > MAX_TAG_SIZE) {
throw new UserException(ErrorCode400.USER_DEVELOP_LANGUAGE_BAD_REQUEST);
}
Expand All @@ -165,11 +165,11 @@ public void updateUsername(String username) {
this.username = username;
}

public synchronized void increaseAvailableLikeCount() {
public void increaseAvailableLikeCount() {
this.availableLikeCount += 1;
}

public synchronized void decreaseAvailableLikeCount() {
public void decreaseAvailableLikeCount() {
if (this.availableLikeCount <= 0) {
throw new UserException(USER_AVAILABLE_LIKE_COUNT_IS_ZERO);
}
Expand Down Expand Up @@ -222,7 +222,7 @@ public void updateJandiRateByReview(ReviewRating rating, double time) {
}

public void updateJandiRateByCancel() {
this.jandiRate += -5 * JANDI_WEIGHT;
this.jandiRate += ReviewRating.ONE.getValue() * JANDI_WEIGHT;
}

private boolean validateAvailableRegionUpdate(Region region) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Entity
Expand All @@ -37,7 +36,6 @@ public class UserDevelopLanguageTag {
@Column(name = "develop_language")
private DevelopLanguage developLanguage;

@Setter
@Column(name = "byte_size", nullable = false)
private Integer byteSize;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.oeid.mogakgo.domain.user.domain;

import static org.assertj.core.api.Assertions.assertThat;

import io.oeid.mogakgo.domain.user.domain.enums.DevelopLanguage;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

@DisplayName("๋„๋ฉ”์ธ ํ…Œ์ŠคํŠธ: UserDevelopLanguageTag")
class UserDevelopLanguageTagDomainTest {
private static final Long GITHUB_PK = 85854384L;
private static final String GITHUB_ID = "tidavid1";
private static final String AVATAR_URL = "https://avatars.githubusercontent.com/u/85854384?v=4";
private static final String GITHUB_URL = "https://github.com/tidavid1";
private static final String REPOSITORY_URL = "https://api.github.com/users/tidavid1/repos";
private static final User USER = User.of(GITHUB_PK, GITHUB_ID, AVATAR_URL, GITHUB_URL, REPOSITORY_URL);

@Test
void ๊ฐœ๋ฐœ์–ธ์–ด_ํƒœ๊ทธ_์ƒ์„ฑ() {
// Arrange
var expectedByteSize = 100;
// Act
UserDevelopLanguageTag userDevelopLanguageTag = UserDevelopLanguageTag.builder()
.user(USER)
.developLanguage(DevelopLanguage.JAVA)
.byteSize(expectedByteSize)
.build();

// Assert
assertThat(userDevelopLanguageTag)
.extracting("user", "developLanguage", "byteSize")
.containsExactly(USER, DevelopLanguage.JAVA, expectedByteSize);
}
}
Loading
Loading