-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
395 additions
and
13 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
154 changes: 154 additions & 0 deletions
154
core/src/test/java/org/jetbrains/academy/test/system/core/TestJavaClass.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,154 @@ | ||
package org.jetbrains.academy.test.system.core; | ||
|
||
import org.jetbrains.academy.test.system.core.models.Visibility; | ||
import org.jetbrains.academy.test.system.core.models.classes.ClassType; | ||
import org.jetbrains.academy.test.system.core.models.classes.TestClass; | ||
import org.jetbrains.academy.test.system.core.models.method.TestMethod; | ||
import org.jetbrains.academy.test.system.core.models.variable.TestVariable; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static java.util.Collections.emptyList; | ||
|
||
public class TestJavaClass { | ||
private static TestClass javaClassTestClass; | ||
|
||
@BeforeAll | ||
static void beforeAll() { | ||
javaClassTestClass = new TestClass( | ||
"JavaClass", | ||
"org.jetbrains.academy.test.system.core.testData.java", | ||
Visibility.PUBLIC, | ||
ClassType.CLASS, | ||
List.of( | ||
new TestVariable( | ||
"PUBLIC_CONSTANT", | ||
"int", | ||
"1", | ||
Visibility.PUBLIC, | ||
true, | ||
false, | ||
false, | ||
true | ||
), | ||
new TestVariable( | ||
"PRIVATE_CONSTANT", | ||
"int", | ||
"2", | ||
Visibility.PRIVATE, | ||
true, | ||
false, | ||
false, | ||
true | ||
), | ||
new TestVariable( | ||
"publicStaticVar", | ||
"int", | ||
"3", | ||
Visibility.PUBLIC, | ||
false, | ||
false, | ||
true, | ||
false | ||
), | ||
new TestVariable( | ||
"privateStaticVar", | ||
"int", | ||
"4", | ||
Visibility.PRIVATE, | ||
false, | ||
false, | ||
true, | ||
false | ||
), | ||
new TestVariable( | ||
"publicVar", | ||
"String", | ||
"publicVar", | ||
Visibility.PUBLIC, | ||
false, | ||
false, | ||
false, | ||
false | ||
), | ||
new TestVariable( | ||
"privateVar", | ||
"String", | ||
"privateVar", | ||
Visibility.PRIVATE, | ||
false, | ||
false, | ||
false, | ||
false | ||
), | ||
new TestVariable( | ||
"customClass", | ||
"CustomJavaClass", | ||
null, | ||
Visibility.PUBLIC, | ||
false, | ||
false, | ||
false, | ||
false | ||
), | ||
new TestVariable( | ||
"primaryConstructorVar", | ||
"String", | ||
null, | ||
Visibility.PUBLIC, | ||
false, | ||
true, | ||
false, | ||
false | ||
) | ||
), | ||
List.of( | ||
new TestMethod( | ||
"publicMethod", | ||
"void", | ||
emptyList(), | ||
Visibility.PUBLIC | ||
), | ||
new TestMethod( | ||
"privateMethod", | ||
"void", | ||
emptyList(), | ||
Visibility.PRIVATE | ||
), | ||
new TestMethod( | ||
"calculateSum", | ||
"double", | ||
List.of( | ||
new TestVariable("a", "double"), | ||
new TestVariable("b", "double") | ||
), | ||
Visibility.PUBLIC | ||
), | ||
new TestMethod( | ||
"getString", | ||
"String", | ||
List.of(new TestVariable("string", "String")), | ||
Visibility.PRIVATE | ||
), | ||
new TestMethod( | ||
"processList", | ||
"List", | ||
List.of(new TestVariable("list", "List")), | ||
Visibility.PUBLIC | ||
) | ||
), | ||
false, | ||
emptyList(), | ||
emptyList() | ||
); | ||
} | ||
|
||
@Test | ||
public void javaClassTest() { | ||
Class<?> clazz = javaClassTestClass.checkBaseDefinition(); | ||
javaClassTestClass.checkFieldsDefinition(clazz, true); | ||
javaClassTestClass.checkDeclaredMethods(clazz); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
core/src/test/java/org/jetbrains/academy/test/system/core/testData/java/CustomJavaClass.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,4 @@ | ||
package org.jetbrains.academy.test.system.core.testData.java; | ||
|
||
public class CustomJavaClass { | ||
} |
46 changes: 46 additions & 0 deletions
46
core/src/test/java/org/jetbrains/academy/test/system/core/testData/java/JavaClass.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,46 @@ | ||
package org.jetbrains.academy.test.system.core.testData.java; | ||
|
||
import java.util.List; | ||
|
||
public class JavaClass { | ||
|
||
public static final int PUBLIC_CONSTANT = 1; | ||
private static final int PRIVATE_CONSTANT = 2; | ||
|
||
public static int publicStaticVar = 3; | ||
private static int privateStaticVar = 4; | ||
|
||
public String publicVar = "publicVar"; | ||
private String privateVar = "privateVar"; | ||
|
||
public CustomJavaClass customClass = null; | ||
|
||
public String primaryConstructorVar; | ||
|
||
public JavaClass(String primaryVar) { | ||
this.primaryConstructorVar = primaryVar; | ||
} | ||
|
||
public void publicMethod() { | ||
System.out.println("Public instance method called!"); | ||
} | ||
|
||
private void privateMethod() { | ||
System.out.println("Private instance method called!"); | ||
} | ||
|
||
public double calculateSum(double a, double b) { | ||
return a + b; | ||
} | ||
|
||
private String getString(String string) { | ||
return string; | ||
} | ||
|
||
public List<String> processList(List<String> list) { | ||
for (String item : list) { | ||
System.out.println("Processing item: " + item); | ||
} | ||
return List.of("item1", "item2", "item3"); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
core/src/test/kotlin/org/jetbrains/academy/test/system/core/JavaClassTests.kt
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,14 @@ | ||
package org.jetbrains.academy.test.system.core | ||
|
||
import org.jetbrains.academy.test.system.core.testData.java.javaClassTestClass | ||
import org.junit.jupiter.api.Test | ||
|
||
class JavaClassTests { | ||
|
||
@Test | ||
fun javaClassTest() { | ||
val clazz = javaClassTestClass.checkBaseDefinition() | ||
javaClassTestClass.checkFieldsDefinition(clazz) | ||
javaClassTestClass.checkDeclaredMethods(clazz) | ||
} | ||
} |
Oops, something went wrong.