Skip to content

Commit

Permalink
test: modify Java test code
Browse files Browse the repository at this point in the history
- Fixed some variable names that do not conform to the Java naming convention
- Remove unnecessary public
  • Loading branch information
hyeok7777 committed Mar 8, 2023
1 parent ea4e1ce commit 4e58035
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ class AllMethodTest {

@Test
@DisplayName("it finds all methods")
public void scanAllMethod() throws IOException {
void scanAllMethod() throws IOException {
assertThat(scanner.scan().getMethods())
.hasSizeGreaterThan(9000).hasSizeLessThan(10000);
}

@Test
@DisplayName("it returns same codeBaseFingerprint for every scan")
public void codeBaseFingerprint() throws IOException {
void codeBaseFingerprint() throws IOException {
String expectedFingerprint = scanner.scan().getCodeBaseFingerprint();

assertThat(scanner.scan().getCodeBaseFingerprint())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ class AllMethodTest {

@Test
@DisplayName("it finds correct number of methods")
public void scanAllMethod() throws IOException {
void scanAllMethod() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).hasSize(64);
}

@Test
@DisplayName("it returns same codeBaseFingerprint for every scan")
public void codeBaseFingerprint() throws IOException {
void codeBaseFingerprint() throws IOException {
String expectedFingerprint = scanner.scan().getCodeBaseFingerprint();
assertThat(scanner.scan().getCodeBaseFingerprint()).isEqualTo(expectedFingerprint);
}
Expand All @@ -85,7 +85,7 @@ public void setConstructorFilter() {

@Test
@DisplayName("it does not contain constructor")
public void scanFilterConstructor() throws IOException {
void scanFilterConstructor() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).map(Method::isConstructor).containsOnly(false);
}
Expand All @@ -102,7 +102,7 @@ public void setVisibilityFilter() {

@Test
@DisplayName("it finds correct number of methods")
public void scanFilterVisibility() throws IOException {
void scanFilterVisibility() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).hasSize(65);
}
Expand All @@ -120,7 +120,7 @@ public void setExcludedPackages() {

@Test
@DisplayName("it finds correct number of methods")
public void scanFilterExcludedPackages() throws IOException {
void scanFilterExcludedPackages() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).allSatisfy(e -> assertThat(e.getSignature()).doesNotContain("com.example.demo.additional"));
}
Expand All @@ -137,7 +137,7 @@ public void setAnnotationFilter() {

@Test
@DisplayName("it finds correct number of methods")
public void scanFilterAnnotation() throws IOException {
void scanFilterAnnotation() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).allSatisfy(each -> assertThat(each.getDeclaringType()).contains("Controller"));
}
Expand All @@ -155,7 +155,7 @@ public void setFilters() {

@Test
@DisplayName("it finds correct number of methods")
public void scanFilterAdditionalPackage() throws IOException {
void scanFilterAdditionalPackage() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).hasSize(19);
}
Expand All @@ -174,7 +174,7 @@ public void setFilter() {

@Test
@DisplayName("it finds correct number of methods")
public void scanFilterGetterSetter() throws IOException {
void scanFilterGetterSetter() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).hasSize(50);
}
Expand All @@ -191,7 +191,7 @@ public void setPackages() {

@Test
@DisplayName("it finds methods successfully")
public void scanRecursively() throws IOException {
void scanRecursively() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).isNotEmpty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ class AllMethodTest {

@Test
@DisplayName("it finds all methods")
public void scanAllMethod() throws IOException {
void scanAllMethod() throws IOException {
CodeBase scan = scanner.scan();
List<Method> methods = scan.getMethods();
methods.forEach(method -> System.out.println(method.getSignature()));
}

@Test
@DisplayName("it returns same codeBaseFingerprint for every scan")
public void codeBaseFingerprint() throws IOException {
void codeBaseFingerprint() throws IOException {
String expectedFingerprint = scanner.scan().getCodeBaseFingerprint();

assertThat(scanner.scan().getCodeBaseFingerprint())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ class AllMethodTest {

@Test
@DisplayName("it finds correct number of methods")
public void scanAllMethod() throws IOException {
void scanAllMethod() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).hasSize(64);
}

@Test
@DisplayName("it returns same codeBaseFingerprint for every scan")
public void codeBaseFingerprint() throws IOException {
void codeBaseFingerprint() throws IOException {
String expected = scanner.scan().getCodeBaseFingerprint();
assertThat(scanner.scan().getCodeBaseFingerprint())
.isEqualTo(expected);
Expand All @@ -70,7 +70,7 @@ public void setConstructorFilter() {

@Test
@DisplayName("it does not contain constructor")
public void scanFilterConstructor() throws IOException {
void scanFilterConstructor() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).map(Method::isConstructor).containsOnly(false);
}
Expand All @@ -87,7 +87,7 @@ public void setVisibilityFilter() {

@Test
@DisplayName("it finds correct number of methods")
public void scanFilterVisibility() throws IOException {
void scanFilterVisibility() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).hasSize(65);
}
Expand All @@ -105,7 +105,7 @@ public void setExcludedPackages() {

@Test
@DisplayName("it finds correct number of methods")
public void scanFilterExcludedPackages() throws IOException {
void scanFilterExcludedPackages() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).allSatisfy(e -> assertThat(e.getSignature()).doesNotContain("com.example.demo.additional"));
}
Expand All @@ -123,7 +123,7 @@ public void setAnnotationFilter() {

@Test
@DisplayName("it finds correct number of methods")
public void scanFilterAnnotation() throws IOException {
void scanFilterAnnotation() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).allSatisfy(each -> assertThat(each.getDeclaringType()).contains("Controller"));
}
Expand All @@ -141,7 +141,7 @@ public void setFilters() {

@Test
@DisplayName("it finds correct number of methods")
public void scanFilterAdditionalPackage() throws IOException {
void scanFilterAdditionalPackage() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).hasSize(19);
}
Expand All @@ -160,7 +160,7 @@ public void setFilter() {

@Test
@DisplayName("it finds correct number of methods")
public void scanFilterGetterSetter() throws IOException {
void scanFilterGetterSetter() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).hasSize(50);
}
Expand All @@ -177,7 +177,7 @@ public void setPackages() {

@Test
@DisplayName("it finds methods successfully")
public void scanRecursively() throws IOException {
void scanRecursively() throws IOException {
List<Method> actual = scanner.scan().getMethods();
assertThat(actual).isNotEmpty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,20 @@ public void prepareMatcher() {

@Test
@DisplayName("it returns true for types prefixed by the given package")
public void prefixed() {
void prefixed() {
assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.Clazz"))).isTrue();
assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.included.Clazz"))).isTrue();
}

@Test
@DisplayName("it returns false for empty string")
public void emptyString() {
void emptyString() {
assertThat(matcher.matches(withClazzNameWithPackage(""))).isFalse();
}

@Test
@DisplayName("it returns false for types not prefixed by the given package")
public void notPrefixed() {
void notPrefixed() {
assertThat(matcher.matches(withClazzNameWithPackage("com.example.Clazz"))).isFalse();
assertThat(matcher.matches(withClazzNameWithPackage("com.com.example.demo.Clazz"))).isFalse();
}
Expand All @@ -104,27 +104,27 @@ public void prepareMatcher() {

@Test
@DisplayName("it returns true for types prefixed by first given package")
public void firstPackage() {
void firstPackage() {
assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.Clazz"))).isTrue();
assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.included.Clazz"))).isTrue();
}

@Test
@DisplayName("it returns true for types prefixed by second given package")
public void secondPackage() {
void secondPackage() {
assertThat(matcher.matches(withClazzNameWithPackage("com.example.test.Clazz"))).isTrue();
assertThat(matcher.matches(withClazzNameWithPackage("com.example.test.included.Clazz"))).isTrue();
}

@Test
@DisplayName("it returns false for empty string")
public void emptyString() {
void emptyString() {
assertThat(matcher.matches(withClazzNameWithPackage(""))).isFalse();
}

@Test
@DisplayName("it returns false for types not prefixed by either packages")
public void notPrefixed() {
void notPrefixed() {
assertThat(matcher.matches(withClazzNameWithPackage("com.example.Clazz"))).isFalse();
assertThat(matcher.matches(withClazzNameWithPackage("com.com.example.demo.Clazz"))).isFalse();
}
Expand All @@ -147,27 +147,27 @@ public void prepareMatcher() {

@Test
@DisplayName("it returns true for types prefixed by the given packages")
public void prefixed() {
void prefixed() {
assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.Clazz"))).isTrue();
assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.included.Clazz"))).isTrue();
}

@Test
@DisplayName("it returns false for empty string")
public void emptyString() {
void emptyString() {
assertThat(matcher.matches(withClazzNameWithPackage(""))).isFalse();
}

@Test
@DisplayName("it returns false for types prefixed by the excludePackages")
public void excludedPackages() {
void excludedPackages() {
assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.excluded.Clazz"))).isFalse();
assertThat(matcher.matches(withClazzNameWithPackage("com.example.demo.excluded.test.Clazz"))).isFalse();
}

@Test
@DisplayName("it returns false for types not prefixed by the given packages")
public void notPrefixed() {
void notPrefixed() {
assertThat(matcher.matches(withClazzNameWithPackage("com.com.example.demo.Clazz"))).isFalse();
}
}
Expand All @@ -189,7 +189,7 @@ public void prepareMatcher() {

@Test
@DisplayName("it returns true for packages prefixed by the given option")
public void matchingPackages() {
void matchingPackages() {
assertThat(matcher.matches(
withAnnotations("com.example.demo.Clazz", "com.example.annotation")
)).isTrue();
Expand All @@ -200,7 +200,7 @@ public void matchingPackages() {

@Test
@DisplayName("it returns true for packages that has extra annotations")
public void extraAnnotation() {
void extraAnnotation() {
assertThat(matcher.matches(
withAnnotations(
"com.example.demo.Clazz",
Expand All @@ -211,23 +211,23 @@ public void extraAnnotation() {

@Test
@DisplayName("it returns false for packages not prefixed by the given option")
public void notPrefixed() {
void notPrefixed() {
assertThat(matcher.matches(
withAnnotations("com.example.Clazz", "com.example.annotation")
)).isFalse();
}

@Test
@DisplayName("it returns false for packages not annotated with given annotation")
public void notExact() {
void notExact() {
assertThat(matcher.matches(
withAnnotations("com.example.demo.Clazz", "com.com.example.annotation")
)).isFalse();
}

@Test
@DisplayName("it returns false for packages with annotation prefixed by the given annotation")
public void prefixedAnnotation() {
void prefixedAnnotation() {
assertThat(matcher.matches(
withAnnotations("com.example.demo.Clazz", "com.example.annotation.test")
)).isFalse();
Expand All @@ -252,7 +252,7 @@ public void prepareMatcher() {

@Test
@DisplayName("it returns true for matching packages and annotations")
public void matched() {
void matched() {
assertThat(matcher.matches(
withAnnotations("com.example.demo.Clazz", "com.example.annotation")
)).isTrue();
Expand All @@ -272,15 +272,15 @@ public void matched() {

@Test
@DisplayName("it returns true for additional packages without annotations")
public void additionalPackageWithoutAnnotation() {
void additionalPackageWithoutAnnotation() {
assertThat(matcher.matches(
withClazzNameWithPackage("com.example.demo.additional..Clazz")
)).isTrue();
}

@Test
@DisplayName("it returns false for unmatched type")
public void unmatched() {
void unmatched() {
assertThat(matcher.matches(
withAnnotations("com.example.Clazz", "com.example.annotation")
)).isFalse();
Expand Down Expand Up @@ -314,25 +314,25 @@ public void prepareMatcher() {

@Test
@DisplayName("it returns true for protected methods")
public void protectedMethods() {
void protectedMethods() {
assertThat(matcher.matches(withModifiers(Opcodes.ACC_PROTECTED))).isTrue();
}

@Test
@DisplayName("it returns false for public methods")
public void publicMethods() {
void publicMethods() {
assertThat(matcher.matches(withModifiers(Opcodes.ACC_PUBLIC))).isTrue();
}

@Test
@DisplayName("it returns false for private methods")
public void privateMethods() {
void privateMethods() {
assertThat(matcher.matches(withModifiers(Opcodes.ACC_PRIVATE))).isFalse();
}

@Test
@DisplayName("it returns false for package-private methods")
public void packagePrivateMethods() {
void packagePrivateMethods() {
assertThat(matcher.matches(withModifiers(0))).isFalse();
}
}
Expand Down
Loading

0 comments on commit 4e58035

Please sign in to comment.