-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add possibility to check for overriding methods to domain and lang
Resolves: #1198 Signed-off-by: Roland Weisleder <[email protected]>
- Loading branch information
1 parent
789706f
commit c8563d9
Showing
8 changed files
with
212 additions
and
2 deletions.
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
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
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
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
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
59 changes: 59 additions & 0 deletions
59
archunit/src/test/java/com/tngtech/archunit/core/domain/JavaMethodTest.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,59 @@ | ||
package com.tngtech.archunit.core.domain; | ||
|
||
import org.junit.Test; | ||
|
||
import static com.tngtech.archunit.core.domain.TestUtils.importMethod; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class JavaMethodTest { | ||
|
||
@Test | ||
public void isOverriding_returns_true_for_implemented_interface_method() { | ||
assertThat(importMethod(SomeClass.class, "doSomething").isOverriding()).isTrue(); | ||
} | ||
|
||
@Test | ||
public void isOverriding_returns_false_for_interface_method() { | ||
assertThat(importMethod(SomeInterface.class, "doSomething").isOverriding()).isFalse(); | ||
} | ||
|
||
@Test | ||
public void isOverriding_returns_true_for_overriding_method_of_java_lang_Object() { | ||
assertThat(importMethod(SomeClass.class, "toString").isOverriding()).isTrue(); | ||
} | ||
|
||
@Test | ||
public void isOverriding_returns_false_for_non_overriding_method() { | ||
assertThat(importMethod(SomeClass.class, "doSomethingElse").isOverriding()).isFalse(); | ||
} | ||
|
||
@Test | ||
public void isOverriding_returns_false_for_non_overriding_overloaded_method() { | ||
assertThat(importMethod(SomeClass.class, "doSomething", Object.class).isOverriding()).isFalse(); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
private interface SomeInterface { | ||
|
||
void doSomething(); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
private static class SomeClass implements SomeInterface { | ||
|
||
@Override | ||
public void doSomething() { | ||
} | ||
|
||
public void doSomething(Object o) { | ||
} | ||
|
||
public void doSomethingElse() { | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return super.toString(); | ||
} | ||
} | ||
} |
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
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