This commit is contained in:
sasam0320 2020-04-25 07:32:20 +02:00 committed by GitHub
parent d090c9b059
commit 89fd7872c4
6 changed files with 98 additions and 1 deletions

3
gradle/gradle-employee-app/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/.idea
/.gradle
/build

View 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()
}

View File

@ -0,0 +1,9 @@
package employee;
public class Employee {
String name;
String emailAddress;
int yearOfBirth;
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -1,10 +1,10 @@
rootProject.name = 'gradletutorial'
include 'greeting-library'
include 'greeting-library-java'
include 'greeter'
include 'gradletaskdemo'
include 'junit5'
include 'gradle-employee-app'
println 'This will be executed during the initialization phase.'