Skip to content

Commit

Permalink
Solves smell code: JUnit5 test classes and methods should have defaul…
Browse files Browse the repository at this point in the history
…t package visibility
  • Loading branch information
damianszczepanik committed Jan 1, 2024
1 parent 13a886f commit 5603807
Show file tree
Hide file tree
Showing 45 changed files with 121 additions and 115 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<version>0.8.11</version>
<executions>
<execution>
<goals>
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/pl/szczepanik/silencio/GenericTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public abstract class GenericTest {
protected Reader input;

@AfterEach
public void closeStreams() throws IOException {
void closeStreams() throws IOException {
if (input != null) {
input.close();
}
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/pl/szczepanik/silencio/api/FormatTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class FormatTest extends GenericTest {

@Test
public void shouldReturnFormatName() {
void shouldReturnFormatName() {

// given
String formatName = "sunnyFormat";
Expand All @@ -28,7 +28,7 @@ public void shouldReturnFormatName() {
}

@Test
public void shouldNotAllowForEmptyName() {
void shouldNotAllowForEmptyName() {

// when
String emptyName = StringUtils.EMPTY;
Expand All @@ -40,7 +40,7 @@ public void shouldNotAllowForEmptyName() {
}

@Test
public void shouldEqualsWhenNameIsEqual() {
void shouldEqualsWhenNameIsEqual() {

// given
Format one = new StubFormat("one");
Expand All @@ -54,7 +54,7 @@ public void shouldEqualsWhenNameIsEqual() {
}

@Test
public void shouldNotEqualsWhenNameIsNotEqual() {
void shouldNotEqualsWhenNameIsNotEqual() {

// given
Format one = new StubFormat("one");
Expand All @@ -68,7 +68,7 @@ public void shouldNotEqualsWhenNameIsNotEqual() {
}

@Test
public void shouldEqualsWithAnyObject() {
void shouldEqualsWithAnyObject() {

// when
Format one = Format.JSON;
Expand All @@ -79,7 +79,7 @@ public void shouldEqualsWithAnyObject() {
}

@Test
public void shouldNotEqualsWithNull() {
void shouldNotEqualsWithNull() {

// when
Format one = Format.JSON;
Expand All @@ -92,7 +92,7 @@ public void shouldNotEqualsWithNull() {
}

@Test
public void shouldReturnHashCodeOfName() {
void shouldReturnHashCodeOfName() {

// given
String name = "crazyName";
Expand All @@ -105,7 +105,7 @@ public void shouldReturnHashCodeOfName() {
}

@Test
public void shouldReturnValidFormat() {
void shouldReturnValidFormat() {

// given
String formatName = "some, some, some";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class BlankTest extends GenericTest {

@Test
public void shouldReturnEmptyValue() {
void shouldReturnEmptyValue() {

// given
Converter blank = new BlankConverter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class NumberSequenceConverterTest extends GenericTest {

@Test
public void shouldReturnValueWhenPassingNull() {
void shouldReturnValueWhenPassingNull() {

// given
Converter blank = new NumberSequenceConverter();
Expand All @@ -33,7 +33,7 @@ public void shouldReturnValueWhenPassingNull() {
}

@Test
public void shouldReturnSameNumbersWhenPassingEqualsValues() {
void shouldReturnSameNumbersWhenPassingEqualsValues() {

// given having 2 values with the same value (compareTo returns true) but different reference
Converter blank = new NumberSequenceConverter();
Expand All @@ -53,7 +53,7 @@ public void shouldReturnSameNumbersWhenPassingEqualsValues() {
}

@Test
public void shouldReturnDifferentNumberWhenPassingDifferentValue() {
void shouldReturnDifferentNumberWhenPassingDifferentValue() {

Converter blank = new NumberSequenceConverter();
Key key = new Key("funnyKey");
Expand All @@ -72,7 +72,7 @@ public void shouldReturnDifferentNumberWhenPassingDifferentValue() {
}

@Test
public void shouldReturnSameNumberWhenPassingSameReference() {
void shouldReturnSameNumberWhenPassingSameReference() {

// given
Converter blank = new NumberSequenceConverter();
Expand All @@ -90,7 +90,7 @@ public void shouldReturnSameNumberWhenPassingSameReference() {
}

@Test
public void shouldClearHistoryOnInit() {
void shouldClearHistoryOnInit() {

// given
Converter blank = new NumberSequenceConverter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class StringConverterTest extends GenericTest {

@Test
public void shouldReturnEmptyValue() {
void shouldReturnEmptyValue() {

// given
String pattern = "constant";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class WikipediaConverterTest extends GenericTest {
private static final String INVALID_HTML_PAGE = "This does not look like valid HTML page";

@Test
public void shouldFailWhenServerReturnsInvalidPage() throws IOException {
void shouldFailWhenServerReturnsInvalidPage() throws IOException {

// given
Converter wikipedia = new WikipediaConverter();
Expand All @@ -62,7 +62,7 @@ public void shouldFailWhenServerReturnsInvalidPage() throws IOException {
}

@Test
public void shouldConvertWholeFile() throws IOException {
void shouldConvertWholeFile() throws IOException {

// given
Converter converter = new WikipediaConverter();
Expand Down Expand Up @@ -106,7 +106,7 @@ public void shouldConvertWholeFile() throws IOException {
}

@Test
public void shouldClearHistoryOnInit() {
void shouldClearHistoryOnInit() {

// given
Converter blank = new WikipediaConverter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class AbstractProcessorTest extends GenericTest {

@Test
public void shouldReturnPassedFormat() {
void shouldReturnPassedFormat() {

// given
Converter[] converters = { new StubConverter() };
Expand All @@ -31,7 +31,7 @@ public void shouldReturnPassedFormat() {
}

@Test
public void shouldFailWhenBuildFromEmptyFormat() {
void shouldFailWhenBuildFromEmptyFormat() {

// given
Converter[] converters = { new StubConverter() };
Expand All @@ -46,7 +46,7 @@ public void shouldFailWhenBuildFromEmptyFormat() {
}

@Test
public void shouldFailWhenBuildFromNullConfiguration() {
void shouldFailWhenBuildFromNullConfiguration() {

// given
Format format = Format.PROPERTIES;
Expand All @@ -59,7 +59,7 @@ public void shouldFailWhenBuildFromNullConfiguration() {
}

@Test
public void shouldFailWhenBuildFromEmptyConverter() {
void shouldFailWhenBuildFromEmptyConverter() {

// given
Format format = Format.PROPERTIES;
Expand All @@ -72,7 +72,7 @@ public void shouldFailWhenBuildFromEmptyConverter() {
}

@Test
public void shouldFailOnProcessWhenConvertersAreNotSet() {
void shouldFailOnProcessWhenConvertersAreNotSet() {

// given
Format format = Format.PROPERTIES;
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/pl/szczepanik/silencio/core/BuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class BuilderTest extends GenericTest {

@Test
public void shouldHoldPassedFormat() {
void shouldHoldPassedFormat() {

// given
Format format = new StubFormat("builderFormat");
Expand All @@ -38,7 +38,7 @@ public void shouldHoldPassedFormat() {
}

@Test
public void shouldAppendPassedValues_NxN() {
void shouldAppendPassedValues_NxN() {

// given
Format format = Format.JSON;
Expand All @@ -57,7 +57,7 @@ public void shouldAppendPassedValues_NxN() {
}

@Test
public void shouldAppendPassedValues_1xN() {
void shouldAppendPassedValues_1xN() {

// given
Format format = Format.JSON;
Expand All @@ -76,7 +76,7 @@ public void shouldAppendPassedValues_1xN() {
}

@Test
public void shouldAppendPassedValues_1x1() {
void shouldAppendPassedValues_1x1() {

// given
Format format = Format.JSON;
Expand All @@ -99,7 +99,7 @@ public void shouldAppendPassedValues_1x1() {
}

@Test
public void shouldAppendPassedValues_0xN() {
void shouldAppendPassedValues_0xN() {

// given
Format format = Format.JSON;
Expand All @@ -118,7 +118,7 @@ public void shouldAppendPassedValues_0xN() {
}

@Test
public void shouldAppendPassedValues_0x1() {
void shouldAppendPassedValues_0x1() {

// given
Format format = Format.JSON;
Expand All @@ -137,7 +137,7 @@ public void shouldAppendPassedValues_0x1() {
}

@Test
public void shouldFailWhenPassingInvalidFormat() {
void shouldFailWhenPassingInvalidFormat() {

// when
Format format = new StubFormat("tr!cky");
Expand All @@ -152,7 +152,7 @@ public void shouldFailWhenPassingInvalidFormat() {
}

@Test
public void shouldClearExecutions() {
void shouldClearExecutions() {

// given
Builder builder = new Builder(Format.XML);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static Collection<Format> data() {

@MethodSource("data")
@ParameterizedTest(name = "\"{0}\"")
public void buildSupportsAllFormats(Format format) {
void buildSupportsAllFormats(Format format) {

initDataWithNameTest(format);
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class ConfigurationTest extends GenericTest {

@Test
public void shouldReturnPassedExecutions() {
void shouldReturnPassedExecutions() {

// given
Execution[] executions = { new Execution(new PositiveDecision(), new StubConverter()) };
Expand All @@ -27,7 +27,7 @@ public void shouldReturnPassedExecutions() {
}

@Test
public void shouldFailWhenPassingEmtptyExecution() {
void shouldFailWhenPassingEmtptyExecution() {

// given
Execution[] executors = {};
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/pl/szczepanik/silencio/core/ExecutionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class ExecutionTest extends GenericTest {

@Test
public void shouldReturnPassedValues() {
void shouldReturnPassedValues() {

// given
Decision[] decisions = { new PositiveDecision() };
Expand All @@ -32,7 +32,7 @@ public void shouldReturnPassedValues() {
}

@Test
public void shouldFailWhenPassingEmtptyDecisions() {
void shouldFailWhenPassingEmtptyDecisions() {

// given
Decision[] decisions = {};
Expand All @@ -45,7 +45,7 @@ public void shouldFailWhenPassingEmtptyDecisions() {
}

@Test
public void shouldFailWhenPassingNullDecisions() {
void shouldFailWhenPassingNullDecisions() {

// given
Decision[] decisions = { null };
Expand All @@ -58,7 +58,7 @@ public void shouldFailWhenPassingNullDecisions() {
}

@Test
public void shouldFailWhenPassingEmtptyConverter() {
void shouldFailWhenPassingEmtptyConverter() {

// given
Decision[] decisions = { new PositiveDecision() };
Expand All @@ -71,7 +71,7 @@ public void shouldFailWhenPassingEmtptyConverter() {
}

@Test
public void shouldFailWhenPassingNullConverter() {
void shouldFailWhenPassingNullConverter() {

// given
Decision[] decisions = { new PositiveDecision() };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class IntegrityExceptionTest extends GenericTest {

@Test
public void constructorWithMessageReturnsPassedMessage() {
void constructorWithMessageReturnsPassedMessage() {

// given
final String message = " brrrr";
Expand All @@ -24,7 +24,7 @@ public void constructorWithMessageReturnsPassedMessage() {
}

@Test
public void constructorWithMessageAndCauseReturnsPassedMessageAndCause() {
void constructorWithMessageAndCauseReturnsPassedMessageAndCause() {

// given
final String message = " brrrr";
Expand Down
Loading

0 comments on commit 5603807

Please sign in to comment.