11package entity ;
22
33import java .nio .file .Path ;
4+ import java .util .ArrayList ;
45import java .util .List ;
56import java .util .Map ;
67
78
8- public class FileEntity {
9+ public class ClassEntity {
910 private Path path ;
10- private int totalLines ;
1111 private List <MethodEntity > methods ;
12- private Map <String , Boolean > imports ;
12+ // private Map<String, Boolean> imports;
13+ private ArrayList <String > imports ;
14+ private String className ;
1315
14- public FileEntity (Path path ) {
16+ public ClassEntity (Path path ) {
1517 this .path = path ;
1618 }
1719
@@ -23,16 +25,18 @@ public void setMethods(List<MethodEntity> methods) {
2325 this .methods = methods ;
2426 }
2527
26- public void setImports (Map <String , Boolean > imports ) {
28+ public void setImports (ArrayList <String > imports ) {
2729 this .imports = imports ;
2830 }
2931
30- public int getTotalLines () {
31- return totalLines ;
32+ public long getTotalImports () {
33+ return imports . stream (). distinct (). count () ;
3234 }
3335
34- public void setTotalLines (int totalLines ) {
35- this .totalLines = totalLines ;
36+ public int getTotalMethods (){return methods .size ();}
37+
38+ public long getTotalMethodStatement () {
39+ return methods .stream ().mapToLong (i -> i .getTotalStatements ()).sum ();
3640 }
3741
3842 public long getTestMethodWithoutAnnotationCount () {
@@ -55,10 +59,24 @@ public boolean isHasTestInFileName() {
5559 return false ;
5660 }
5761
62+ public boolean isHasTestInClassName () {
63+ String name = className .toLowerCase ();
64+ if (name .startsWith ("test" ) || name .startsWith ("tests" ) || name .endsWith ("test" ) || name .endsWith ("tests" ))
65+ return true ;
66+ else
67+ return false ;
68+ }
69+
5870 public String getFileName () {
5971 return path .getFileName ().toString ();
6072 }
6173
74+ public String getClassName () {
75+ return className ;
76+ }
77+
78+ public void setClassName (String className ){this .className = className ;}
79+
6280 public String getFileNameWithoutExtension () {
6381 String fileName = path .getFileName ().toString ().substring (0 ,path .getFileName ().toString ().toLowerCase ().lastIndexOf (".java" ));
6482 return fileName ;
@@ -69,31 +87,31 @@ public long getTotalTestMethods() {
6987 }
7088
7189 public boolean getHas_junitframeworkTest () {
72- return imports .get ( "junit.framework.Test" );
90+ return imports .stream (). anyMatch ( i -> i . equals ( "junit.framework.Test" ) );
7391 }
7492
7593 public boolean getHas_junitframeworkTestCase () {
76- return imports .get ( "junit.framework.TestCase" );
94+ return imports .stream (). anyMatch ( i -> i . equals ( "junit.framework.TestCase" ) );
7795 }
7896
7997 public boolean getHas_orgjunitTest () {
80- return imports .get ( "org.junit.Test" );
98+ return imports .stream (). anyMatch ( i -> i . equals ( "org.junit.Test" ) );
8199 }
82100
83101 public boolean getHas_androidtestAndroidTestCase () {
84- return imports .get ( "android.test.AndroidTestCase" );
102+ return imports .stream (). anyMatch ( i -> i . equals ( "android.test.AndroidTestCase" ) );
85103 }
86104
87105 public boolean getHas_androidtestInstrumentationTestCase () {
88- return imports .get ( "android.test.InstrumentationTestCase" );
106+ return imports .stream (). anyMatch ( i -> i . equals ( "android.test.InstrumentationTestCase" ) );
89107 }
90108
91109 public boolean getHas_androidtestActivityInstrumentationTestCase2 () {
92- return imports .get ( "android.test.ActivityInstrumentationTestCase2" );
110+ return imports .stream (). anyMatch ( i -> i . equals ( "android.test.ActivityInstrumentationTestCase2" ) );
93111 }
94112
95113 public boolean getHas_orgjunitAssert () {
96- return imports .get ( "org.junit.Assert" );
114+ return imports .stream (). anyMatch ( i -> i . equals ( "org.junit.Assert" ) );
97115 }
98116
99117 public String getRelativeFilePath () {
0 commit comments