-
Notifications
You must be signed in to change notification settings - Fork 96
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
Refactor : Adjust resolveFieldName Method Logic to Correctly Handle Primitive boolean Field Names #1096
Open
rawfishthelgh
wants to merge
9
commits into
naver:main
Choose a base branch
from
rawfishthelgh:refactor/switch_condition_order
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Refactor : Adjust resolveFieldName Method Logic to Correctly Handle Primitive boolean Field Names #1096
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
829c97d
feat : switch order of if - condition in resolveFieldName method
rawfishthelgh 62beb85
test: add tests of JavaGetterPropertyFieldNameResolverTest.java
rawfishthelgh 3c0b8ac
test: fix test to pass checkStyleTest
rawfishthelgh 21b5ce0
test: License 추가, public 제거
rawfishthelgh af1765f
test: 테스트 대상 SUT 명명
rawfishthelgh 7d4a940
test: 테스트 컨벤션 통일
rawfishthelgh bc731d1
test: style 규약 준수
rawfishthelgh 259326e
test: 테스트클래스 네이밍 변경
rawfishthelgh 465795d
test: public API를 통한 생성자 기반 테스트 변경
rawfishthelgh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
.../java/com/navercorp/fixturemonkey/tests/java/JavaGetterPropertyFieldNameResolverTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Fixture Monkey | ||
* | ||
* Copyright (c) 2021-present NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.fixturemonkey.tests.java; | ||
|
||
import static com.navercorp.fixturemonkey.api.expression.JavaGetterMethodPropertySelector.javaGetter; | ||
import static com.navercorp.fixturemonkey.tests.TestEnvironment.TEST_COUNT; | ||
import static org.assertj.core.api.BDDAssertions.thenCode; | ||
|
||
import org.junit.jupiter.api.RepeatedTest; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import com.navercorp.fixturemonkey.FixtureMonkey; | ||
import com.navercorp.fixturemonkey.api.introspector.ConstructorPropertiesArbitraryIntrospector; | ||
|
||
class JavaGetterPropertyFieldNameResolverTest { | ||
|
||
private static final FixtureMonkey SUT = FixtureMonkey.builder() | ||
.objectIntrospector(ConstructorPropertiesArbitraryIntrospector.INSTANCE) | ||
.build(); | ||
|
||
@RepeatedTest(TEST_COUNT) | ||
void testNonBooleanFieldWithIsPrefix() { | ||
thenCode(SUT.giveMeBuilder(JavaGetterObject.class) | ||
.set(javaGetter(JavaGetterObject::getIsStatus), "javaGetterStringStatus")::sample) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ex. then(actual.getIsStatus()).isEqualTo("javaGetterStringStatus") |
||
.doesNotThrowAnyException(); | ||
} | ||
|
||
@RepeatedTest(TEST_COUNT) | ||
void testPrimitiveTypeBooleanFieldWithIsPrefix() { | ||
thenCode(SUT.giveMeBuilder(JavaGetterObject.class) | ||
.set(javaGetter(JavaGetterObject::isActive), true)::sample) | ||
.doesNotThrowAnyException(); | ||
} | ||
|
||
@RepeatedTest(TEST_COUNT) | ||
void testBooleanFieldWithoutIsPrefix() { | ||
thenCode(SUT.giveMeBuilder(JavaGetterObject.class) | ||
.set(javaGetter(JavaGetterObject::isEnabled), true)::sample) | ||
.doesNotThrowAnyException(); | ||
} | ||
|
||
@RepeatedTest(TEST_COUNT) | ||
void testNonBooleanFieldWithoutIsPrefix() { | ||
thenCode(SUT.giveMeBuilder(JavaGetterObject.class) | ||
.set(javaGetter(JavaGetterObject::getName), "javaGetterObjectName")::sample) | ||
.doesNotThrowAnyException(); | ||
} | ||
|
||
@RepeatedTest(TEST_COUNT) | ||
void testWrapperTypeBooleanFieldWithIsPrefix() { | ||
thenCode(SUT.giveMeBuilder(JavaGetterObject.class) | ||
.set(javaGetter(JavaGetterObject::getIsDeleted), true)::sample) | ||
.doesNotThrowAnyException(); | ||
} | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
private static class JavaGetterObject { | ||
private String isStatus; | ||
private boolean isActive; | ||
private boolean enabled; | ||
private String name; | ||
private Boolean isDeleted; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
하위호환을 보장하고 안전하게 변경됨을 보장하기 위해 다음 테스트들이 추가되면 좋을 것 같습니다.
is
가 이름의 prefix로 붙은 boolean이 아닌 필드를 setis
가 이름의 prefix로 붙지않은 boolean의 필드를 setis
가 이름의 prefix로 붙은 boolean인 필드를 setis
가 이름의 prefix로 붙지않은 boolean이 아닌 필드를 setThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트 추가했습니다!
추가로 Boolean 필드가 Wrapper Type일 경우와 Primitive Type일 경우의 테스트도 작성했습니다.