-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathTestFile.java
More file actions
94 lines (76 loc) · 2.93 KB
/
TestFile.java
File metadata and controls
94 lines (76 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package testsmell;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class TestFile {
private String app, testFilePath, productionFilePath;
private List<AbstractSmell> testSmells;
public String getApp() {
return app;
}
public String getProductionFilePath() {
return productionFilePath;
}
public String getTestFilePath() {
return testFilePath;
}
public List<AbstractSmell> getTestSmells() {
return testSmells;
}
public boolean getHasProductionFile() {
return ((productionFilePath != null && !productionFilePath.isEmpty()));
}
public TestFile(String app, String testFilePath, String productionFilePath) {
this.app = app;
this.testFilePath = testFilePath;
this.productionFilePath = productionFilePath;
this.testSmells = new ArrayList<>();
}
public void addSmell(AbstractSmell smell) {
testSmells.add(smell);
}
public String getTagName(){
return testFilePath.split(String.format("\\%s", File.separator))[4];
}
public String getTestFileName(){
int lastIndex = testFilePath.lastIndexOf(File.separator);
return testFilePath.substring(lastIndex+1,testFilePath.length());
}
public String getTestFileNameWithoutExtension(){
int lastIndex = getTestFileName().lastIndexOf(".");
return getTestFileName().substring(0,lastIndex);
}
public String getProductionFileNameWithoutExtension(){
int lastIndex = getProductionFileName().lastIndexOf(".");
if(lastIndex==-1)
return "";
return getProductionFileName().substring(0,lastIndex);
}
public String getProductionFileName(){
int lastIndex = productionFilePath.lastIndexOf(File.separator);
if(lastIndex==-1)
return "";
return productionFilePath.substring(lastIndex+1,productionFilePath.length());
}
public String getRelativeTestFilePath() {
String[] splitString = testFilePath.split(String.format("\\%s", File.separator));
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < 5; i++) {
stringBuilder.append(splitString[i] + File.separator);
}
return testFilePath.substring(stringBuilder.toString().length()).replace(File.separator, "/");
}
public String getRelativeProductionFilePath() {
if (!StringUtils.isEmpty(productionFilePath)) {
String[] splitString = productionFilePath.split(String.format("\\%s", File.separator));
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < 5; i++) {
stringBuilder.append(splitString[i] + File.separator);
}
return productionFilePath.substring(stringBuilder.toString().length()).replace(File.separator, "/");
} else {
return "";
}
}
}