Skip to content

Commit

Permalink
Merge branch 'master' into 357
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarus committed Feb 19, 2020
2 parents ae1caa2 + 37d6b95 commit 3223d51
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 35 deletions.
23 changes: 23 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,24 @@ SOFTWARE.
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand All @@ -235,6 +253,11 @@ SOFTWARE.
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
</plugins>
<pluginManagement>
<plugins>
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/jpeek/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import org.cactoos.text.TextOf;
import org.hamcrest.collection.IsEmptyIterable;
import org.hamcrest.core.IsNot;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.IsTrue;

Expand Down Expand Up @@ -135,7 +135,7 @@ public void isXsdDocumented() throws IOException {
elements,
populated
).affirm();
for (final XML element: elements) {
for (final XML element : elements) {
new Assertion<>(
String.format(
"element '%s' must have a documentation",
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/jpeek/DefaultBaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;

/**
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/jpeek/IndexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import org.cactoos.text.TextOf;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;

/**
Expand All @@ -44,7 +44,7 @@ public final class IndexTest {
*/
private String xml;

@Before
@BeforeEach
public void setUp() throws IOException {
final Path output = Files.createTempDirectory("").resolve("x2");
final Path input = Paths.get(".");
Expand Down
30 changes: 21 additions & 9 deletions src/test/java/org/jpeek/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import org.cactoos.Scalar;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.IsTrue;
import org.llorllale.cactoos.matchers.Throws;
Expand All @@ -54,18 +54,30 @@ public void createsXmlReports() throws IOException {
).affirm();
}

@Test(expected = ParameterException.class)
public void crashesIfInvalidInput() throws IOException {
Main.main("hello");
@Test
public void crashesIfInvalidInput() {
new Assertion<>(
"Must throw an exception if parameter is invalid",
() -> {
Main.main("hello");
return "";
}, new Throws<>(ParameterException.class)
).affirm();
}

@Test(expected = IllegalStateException.class)
@Test
public void crashesIfNoOverwriteAndTargetExists() throws IOException {
final Path target = Files.createTempDirectory("");
Main.main(
"--sources", Paths.get(".").toString(),
"--target", target.toString()
);
new Assertion<>(
"Must throw an exception if target exists and no overwrite",
() -> {
Main.main(
"--sources", Paths.get(".").toString(),
"--target", target.toString()
);
return "";
}, new Throws<>(IllegalStateException.class)
).affirm();
}

@Test
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/jpeek/MatrixTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import org.cactoos.text.TextOf;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;

/**
Expand All @@ -44,7 +44,7 @@ public final class MatrixTest {
*/
private String xml;

@Before
@BeforeEach
public void setUp() throws IOException {
final Path output = Files.createTempDirectory("").resolve("x2");
final Path input = Paths.get(".");
Expand Down
29 changes: 14 additions & 15 deletions src/test/java/org/jpeek/MetricsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,19 @@
* @checkstyle JavadocVariableCheck (500 lines)
* @checkstyle MagicNumberCheck (500 lines)
* @todo #118:30min Add test for LCC with "IndirectlyRelatedPairs" and others.
* In "IndirectlyRelatedPairs" all methods exist in one transitive closure,
* so the result should be {@code 1d}.
* Also, all classes without transitive relations
* should have the same LCC metric as TCC metric.
* Before do it we have to fix puzzles in LCC.xml.
* In "IndirectlyRelatedPairs" all methods exist in one transitive closure, so
* the result should be {@code 1d}. Also, all classes without transitive
* relations should have the same LCC metric as TCC metric. Before do it we have
* to fix puzzles in LCC.xml.
* @todo #323:30min This test is fully written against JUnit 4 API.
* Migrate this parametrized test to junit 5, so it won't import any classes from junit 4 anymore.
*/
@RunWith(Parameterized.class)
@SuppressWarnings(
{
"PMD.AvoidDuplicateLiterals",
"PMD.ExcessiveMethodLength",
"PMD.UseUnderscoresInNumericLiterals"
}
)
@SuppressWarnings({
"PMD.AvoidDuplicateLiterals",
"PMD.ExcessiveMethodLength",
"PMD.UseUnderscoresInNumericLiterals"
})
public final class MetricsTest {

@Parameterized.Parameter
Expand Down Expand Up @@ -118,9 +117,9 @@ public static Collection<Object[]> targets() {
new Object[] {"WithoutAttributes", "NHD", 0.0d},
new Object[] {"OneMethodCreatesLambda", "NHD", 0.0d},
new Object[] {"MethodsWithDiffParamTypes", "CCM", 0.0476d},
new Object[]{"Foo", "SCOM", 0.5d},
new Object[]{"MethodsWithDiffParamTypes", "SCOM", 0.2381d},
new Object[]{"OverloadMethods", "SCOM", 0.75d},
new Object[] {"Foo", "SCOM", 0.5d},
new Object[] {"MethodsWithDiffParamTypes", "SCOM", 0.2381d},
new Object[] {"OverloadMethods", "SCOM", 0.75d},
new Object[] {"TwoCommonAttributes", "SCOM", 0.0d},
new Object[] {"NoMethods", "SCOM", Double.NaN},
new Object[] {"OneVoidMethodWithoutParams", "SCOM", 0.0d},
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/jpeek/ReportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.nio.file.Path;
import org.cactoos.text.TextOf;
import org.jpeek.skeleton.Skeleton;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.IsTrue;
import org.xembly.Directives;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/jpeek/ReportWithStatisticsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;

/**
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/org/jpeek/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@
* Tests.
*
* @since 0.1
* @todo #323:30min Migrate the tests in the sub-packages: org.jpeek.metrics,
* org.jpeek.skeleton and org.jpeek.web to junit 5, so they won't
* import any classes from junit 4 anymore. Then, we should find a way to
* exclude junit 4 from project dependecy, so they won't be imported anymore.
*/
package org.jpeek;

1 comment on commit 3223d51

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 3223d51 Feb 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 308-016448ee disappeared from src/main/java/org/jpeek/Main.java, that's why I closed #357. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.