Skip to content

Commit 28c9936

Browse files
committed
Refactor - split presentation and logic layer
1 parent 8bf5dc1 commit 28c9936

20 files changed

+5189
-2064
lines changed

impl/pom.xml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
23
<modelVersion>4.0.0</modelVersion>
34
<parent>
45
<groupId>org.jboss.test-audit</groupId>
@@ -10,6 +11,10 @@
1011
<packaging>jar</packaging>
1112
<name>Test Audit Utils Implementation</name>
1213

14+
<properties>
15+
<freemarker.version>2.3.21</freemarker.version>
16+
</properties>
17+
1318
<dependencies>
1419
<dependency>
1520
<groupId>junit</groupId>
@@ -22,6 +27,11 @@
2227
<artifactId>jboss-test-audit-api</artifactId>
2328
<version>${project.version}</version>
2429
</dependency>
30+
<dependency>
31+
<groupId>org.freemarker</groupId>
32+
<artifactId>freemarker</artifactId>
33+
<version>${freemarker.version}</version>
34+
</dependency>
2535
</dependencies>
2636

2737
<build>
@@ -30,10 +40,10 @@
3040
<plugin>
3141
<groupId>org.apache.maven.plugins</groupId>
3242
<artifactId>maven-compiler-plugin</artifactId>
33-
<version>2.0.2</version>
43+
<version>2.5.1</version>
3444
<configuration>
35-
<source>1.6</source>
36-
<target>1.6</target>
45+
<source>1.7</source>
46+
<target>1.7</target>
3747
<compilerArgument>-proc:none</compilerArgument>
3848
</configuration>
3949
</plugin>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package org.jboss.test.audit.model;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
/**
7+
* @author Tomas Remes
8+
*/
9+
public class Assertion extends SectionElement {
10+
11+
private String id = "";
12+
private String note;
13+
private boolean testable;
14+
private boolean implied;
15+
private String status;
16+
private Group group;
17+
private List<Test> tests;
18+
19+
public Assertion(String id, String text, String note, boolean testable, boolean implied, Group group, Section section) {
20+
super(text, section);
21+
this.id = id;
22+
this.note = note;
23+
this.testable = testable;
24+
this.implied = implied;
25+
this.group = group;
26+
this.tests = new ArrayList<>();
27+
}
28+
29+
public String getId() {
30+
return id;
31+
}
32+
33+
public void setId(String id) {
34+
this.id = id;
35+
}
36+
37+
public List<Test> getTests() {
38+
return tests;
39+
}
40+
41+
public boolean isTestable() {
42+
return testable;
43+
}
44+
45+
public void setTestable(boolean testable) {
46+
this.testable = testable;
47+
}
48+
49+
public String getNote() {
50+
return note;
51+
}
52+
53+
public void setNote(String note) {
54+
this.note = note;
55+
}
56+
57+
public Group getGroup() {
58+
return group;
59+
}
60+
61+
public void setGroup(Group group) {
62+
this.group = group;
63+
}
64+
65+
public boolean isImplied() {
66+
return implied;
67+
}
68+
69+
public void setImplied(boolean implied) {
70+
this.implied = implied;
71+
}
72+
73+
public String getStatus() {
74+
return status;
75+
}
76+
77+
public void setStatus(String status) {
78+
this.status = status;
79+
}
80+
81+
public void addTest(Test test){
82+
tests.add(test);
83+
}
84+
85+
@Override
86+
public String toString() {
87+
return this.getId() + " " + this.getText() + " " + this.getNote() + " " + this.getStatus() + " " + this.isImplied() + " " + this.isTestable();
88+
}
89+
90+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.jboss.test.audit.model;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
/**
7+
* @author Tomas Remes
8+
*/
9+
public class Group extends SectionElement {
10+
11+
12+
private List<Assertion> assertions;
13+
14+
public Group(String text, Section section){
15+
super(text, section);
16+
this.assertions = new ArrayList<>();
17+
}
18+
19+
public List<Assertion> getAssertions() {
20+
return assertions;
21+
}
22+
23+
public void addAssertion(Assertion assertion){
24+
assertions.add(assertion);
25+
}
26+
27+
@Override
28+
public String toString(){
29+
return super.getText();
30+
}
31+
32+
33+
34+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.jboss.test.audit.model;
2+
3+
/**
4+
* @author Tomas Remes
5+
*/
6+
public class Link {
7+
8+
private final Provider provider;
9+
private final String url;
10+
11+
public Link(Provider provider, String url) {
12+
this.provider = provider;
13+
this.url = url;
14+
}
15+
16+
public Provider getProvider() {
17+
return provider;
18+
}
19+
20+
public String getUrl() {
21+
return url;
22+
}
23+
24+
public static enum Provider{
25+
GITHUB, SVN, FISHEYE;
26+
27+
}
28+
29+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package org.jboss.test.audit.model;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
/**
7+
* @author Tomas Remes
8+
*/
9+
public class Section {
10+
11+
private String id;
12+
private String title;
13+
private int level;
14+
private String originalId;
15+
private List<SectionElement> sectionElements;
16+
17+
public Section(String id, String title, int level, String originalId) {
18+
this.id = id;
19+
this.title = title;
20+
this.level = level;
21+
this.originalId = originalId;
22+
this.sectionElements = new ArrayList<>();
23+
}
24+
25+
public int getLevel() {
26+
return level;
27+
}
28+
29+
public void setLevel(int level) {
30+
this.level = level;
31+
}
32+
33+
public String getTitle() {
34+
return title;
35+
}
36+
37+
public void setTitle(String title) {
38+
this.title = title;
39+
}
40+
41+
public String getId() {
42+
return id;
43+
}
44+
45+
public void setId(String id) {
46+
this.id = id;
47+
}
48+
49+
public List<SectionElement> getSectionElements() {
50+
return sectionElements;
51+
}
52+
53+
public String getOriginalId() {
54+
return originalId;
55+
}
56+
57+
public void setOriginalId(String originalId) {
58+
this.originalId = originalId;
59+
}
60+
61+
@Override
62+
public String toString() {
63+
return this.getId() + " " + this.getTitle() + " " + this.getLevel();
64+
}
65+
66+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.jboss.test.audit.model;
2+
3+
/**
4+
* @author Tomas Remes
5+
*/
6+
public class SectionElement {
7+
8+
private String text;
9+
10+
private Section section;
11+
12+
public SectionElement(String text, Section section){
13+
this.text = text;
14+
this.section = section;
15+
}
16+
17+
public String getText() {
18+
return text;
19+
}
20+
21+
public void setText(String text) {
22+
this.text = text;
23+
}
24+
25+
public Section getSection() {
26+
return section;
27+
}
28+
29+
public void setSection(Section section) {
30+
this.section = section;
31+
}
32+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package org.jboss.test.audit.model;
2+
3+
/**
4+
* @author Tomas Remes
5+
*/
6+
public class TableData {
7+
8+
private final Section section;
9+
private final int assertions;
10+
private final int testable;
11+
private final int tested;
12+
private final int testCount;
13+
private final int unimplemented;
14+
private final int implemented;
15+
private final double coverage;
16+
17+
public TableData(Section section, int assertions, int testable, int tested, int unimplemented, int implemented,
18+
double coverage) {
19+
this(section, assertions, testable, tested, 0, unimplemented, implemented, coverage);
20+
}
21+
22+
public TableData(Section section, int assertions, int testable, int tested, int testCount, int unimplemented,
23+
int implemented, double coverage) {
24+
this.section = section;
25+
this.assertions = assertions;
26+
this.testable = testable;
27+
this.tested = tested;
28+
this.testCount = testCount;
29+
this.unimplemented = unimplemented;
30+
this.implemented = implemented;
31+
this.coverage = coverage;
32+
33+
}
34+
35+
public double getCoverage() {
36+
return coverage;
37+
}
38+
39+
public Section getSection() {
40+
return section;
41+
}
42+
43+
public int getAssertions() {
44+
return assertions;
45+
}
46+
47+
public int getTestable() {
48+
return testable;
49+
}
50+
51+
public int getTested() {
52+
return tested;
53+
}
54+
55+
public int getUnimplemented() {
56+
return unimplemented;
57+
}
58+
59+
public int getImplemented() {
60+
return implemented;
61+
}
62+
63+
public int getTestCount() {
64+
return testCount;
65+
}
66+
67+
public String displayCoverage() {
68+
69+
return this.assertions > 0 ? String.valueOf(((double) Math.round(this.coverage * 100) / 100)) : "";
70+
}
71+
72+
public String coverageForGraph() {
73+
74+
return String.valueOf(((double) Math.round(this.coverage * 100) / 100)).replace(",", ".");
75+
}
76+
77+
}

0 commit comments

Comments
 (0)