mirror of
https://github.com/ysoftdevs/gradle-training.git
synced 2026-03-19 07:44:28 +01:00
initial import of project
This commit is contained in:
21
05-jdepend/build.gradle
Normal file
21
05-jdepend/build.gradle
Normal file
@@ -0,0 +1,21 @@
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'jdepend'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile group: 'org.testng', name: 'testng', version: '6.+'
|
||||
}
|
||||
|
||||
test {
|
||||
useTestNG()
|
||||
}
|
||||
|
||||
tasks.withType(JDepend) {
|
||||
reports {
|
||||
xml.enabled false
|
||||
text.enabled true
|
||||
}
|
||||
}
|
||||
14
05-jdepend/src/main/java/com/ysoft/circle/Circulator.java
Normal file
14
05-jdepend/src/main/java/com/ysoft/circle/Circulator.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.ysoft.circle;
|
||||
|
||||
// Create circular dependency for JDepend
|
||||
import com.ysoft.training.Calculator;
|
||||
|
||||
public class Circulator {
|
||||
|
||||
public int compute() {
|
||||
Calculator calc = new Calculator();
|
||||
calc.add(1);
|
||||
return calc.getCounter();
|
||||
}
|
||||
}
|
||||
|
||||
37
05-jdepend/src/main/java/com/ysoft/training/Calculator.java
Normal file
37
05-jdepend/src/main/java/com/ysoft/training/Calculator.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.ysoft.training;
|
||||
|
||||
// Generate Checkstyle warning - unused import
|
||||
import java.util.Date;
|
||||
|
||||
// Circular dependency for JDepend
|
||||
import com.ysoft.circle.Circulator;
|
||||
|
||||
public class Calculator {
|
||||
|
||||
/** Internal counter */
|
||||
private int counter;
|
||||
|
||||
public Calculator() {
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
|
||||
public int getCounter() {
|
||||
return counter;
|
||||
}
|
||||
|
||||
public int getCirculator() {
|
||||
Circulator circ = new Circulator();
|
||||
return circ.compute();
|
||||
}
|
||||
|
||||
public void add(int i) {
|
||||
|
||||
// Generate PMD warning
|
||||
if (i==1) {
|
||||
}
|
||||
|
||||
counter += i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.ysoft.training;
|
||||
|
||||
import com.ysoft.training.Calculator;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class TestCalculator {
|
||||
|
||||
@Test
|
||||
public void testAdd() {
|
||||
Calculator calc = new Calculator();
|
||||
calc.add(1);
|
||||
Assert.assertEquals(calc.getCounter(), 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user