File tree Expand file tree Collapse file tree
section-10-unit-testing-quick-start/00-starting-project
main/java/com/luv2code/junitdemo Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <project xmlns =" http://maven.apache.org/POM/4.0.0"
3+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
5+ <modelVersion >4.0.0</modelVersion >
6+
7+ <groupId >com.luv2code</groupId >
8+ <artifactId >junitdemo</artifactId >
9+ <version >1.0</version >
10+
11+ <properties >
12+ <maven .compiler.source>23</maven .compiler.source>
13+ <maven .compiler.target>23</maven .compiler.target>
14+ </properties >
15+
16+ </project >
Original file line number Diff line number Diff line change 1+ package com .luv2code .junitdemo ;
2+
3+ import java .util .List ;
4+
5+ public class DemoUtils {
6+
7+ private String academy = "Luv2Code Academy" ;
8+ private String academyDuplicate = academy ;
9+ private String [] firstThreeLettersOfAlphabet = {"A" , "B" , "C" };
10+ private List <String > academyInList = List .of ("luv" , "2" , "code" );
11+
12+ public List <String > getAcademyInList () {
13+ return academyInList ;
14+ }
15+
16+ public String getAcademy () {
17+ return academy ;
18+ }
19+
20+ public String getAcademyDuplicate () {
21+ return academyDuplicate ;
22+ }
23+
24+ public String [] getFirstThreeLettersOfAlphabet () {
25+ return firstThreeLettersOfAlphabet ;
26+ }
27+
28+ public int add (int a , int b ) {
29+ return a + b ;
30+ }
31+
32+ public int multiply (int a , int b ) {
33+ return a * b ;
34+ }
35+
36+ public Object checkNull (Object obj ) {
37+ if (obj != null ) {
38+ return obj ;
39+ }
40+ return null ;
41+ }
42+
43+ public Boolean isGreater (int n1 , int n2 ) {
44+ if (n1 > n2 ) {
45+ return true ;
46+ }
47+ return false ;
48+ }
49+
50+ public String throwException (int a ) throws Exception {
51+ if (a < 0 ) {
52+ throw new Exception ("Value should be greater than or equal to 0" );
53+ }
54+ return "Value is greater than or equal to 0" ;
55+ }
56+
57+ public void checkTimeout () throws InterruptedException {
58+ System .out .println ("I am going to sleep" );
59+ Thread .sleep (2000 );
60+ System .out .println ("Sleeping over" );
61+ }
62+
63+ }
You can’t perform that action at this time.
0 commit comments