BAEL-3973 (#9061)
This commit is contained in:
parent
d090c9b059
commit
89fd7872c4
3
gradle/gradle-employee-app/.gitignore
vendored
Normal file
3
gradle/gradle-employee-app/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/.idea
|
||||||
|
/.gradle
|
||||||
|
/build
|
38
gradle/gradle-employee-app/build.gradle
Normal file
38
gradle/gradle-employee-app/build.gradle
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
plugins {
|
||||||
|
id 'java-library'
|
||||||
|
id 'application'
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'application'
|
||||||
|
mainClassName = 'employee.EmployeeApp'
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
|
||||||
|
println 'This is executed during configuration phase'
|
||||||
|
|
||||||
|
task configured {
|
||||||
|
println 'The project is configured'
|
||||||
|
}
|
||||||
|
|
||||||
|
task wrapper(type: Wrapper){
|
||||||
|
gradleVersion = '5.3.1'
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
|
||||||
|
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
|
||||||
|
testImplementation('junit:junit:4.13')
|
||||||
|
testRuntime('junit:junit:4.13')
|
||||||
|
}
|
||||||
|
test {
|
||||||
|
useJUnit()
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
package employee;
|
||||||
|
|
||||||
|
public class Employee {
|
||||||
|
|
||||||
|
String name;
|
||||||
|
String emailAddress;
|
||||||
|
int yearOfBirth;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package employee;
|
||||||
|
|
||||||
|
public class EmployeeApp {
|
||||||
|
|
||||||
|
public static void main(String[] args){
|
||||||
|
|
||||||
|
Employee employee = new Employee();
|
||||||
|
employee.name = "John";
|
||||||
|
employee.emailAddress = "john@baeldung.com";
|
||||||
|
employee.yearOfBirth = 1978;
|
||||||
|
System.out.println("Name: " + employee.name);
|
||||||
|
System.out.println("Email Address: " + employee.emailAddress);
|
||||||
|
System.out.println("Year Of Birth:" + employee.yearOfBirth);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package employee;
|
||||||
|
|
||||||
|
import employee.Employee;
|
||||||
|
import org.junit.*;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
public class EmployeeAppTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testData(){
|
||||||
|
|
||||||
|
Employee testEmp = this.getEmployeeTest();
|
||||||
|
|
||||||
|
assertEquals(testEmp.name, "John");
|
||||||
|
assertEquals(testEmp.emailAddress, "john@baeldung.com");
|
||||||
|
assertEquals(testEmp.yearOfBirth, 1978);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Employee getEmployeeTest(){
|
||||||
|
|
||||||
|
Employee employee = new Employee();
|
||||||
|
employee.name = "John";
|
||||||
|
employee.emailAddress = "john@baeldung.com";
|
||||||
|
employee.yearOfBirth = 1978;
|
||||||
|
|
||||||
|
return employee;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
rootProject.name = 'gradletutorial'
|
rootProject.name = 'gradletutorial'
|
||||||
|
|
||||||
|
|
||||||
include 'greeting-library'
|
include 'greeting-library'
|
||||||
include 'greeting-library-java'
|
include 'greeting-library-java'
|
||||||
include 'greeter'
|
include 'greeter'
|
||||||
include 'gradletaskdemo'
|
include 'gradletaskdemo'
|
||||||
include 'junit5'
|
include 'junit5'
|
||||||
|
include 'gradle-employee-app'
|
||||||
|
|
||||||
println 'This will be executed during the initialization phase.'
|
println 'This will be executed during the initialization phase.'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user