Skip to content

Commit

Permalink
"#82: JUnit 4 to JUnit 5 migration"
Browse files Browse the repository at this point in the history
  • Loading branch information
galovics committed Sep 14, 2022
1 parent f8c48bf commit cbd6814
Show file tree
Hide file tree
Showing 79 changed files with 246 additions and 233 deletions.
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ subprojects {
implementation "org.springframework:spring-context:5.3.22"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.13.4"

testImplementation "junit:junit:4.13.2"
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testImplementation "org.assertj:assertj-core:3.23.1"
testImplementation "org.springframework:spring-test:5.3.22"
testImplementation "org.mockito:mockito-core:4.8.0"
testImplementation "org.mockito:mockito-junit-jupiter:4.8.0"
}

checkstyle {
Expand All @@ -65,6 +67,10 @@ subprojects {
showProgress = false
}

test {
useJUnitPlatform()
}

//<editor-fold desc="Uploading to central">
apply plugin: 'signing'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import java.util.List;

import io.redskap.swagger.brake.cli.options.handler.CliOptionHandler;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.core.env.Environment;

@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class CliOptionsProviderTest {
@Mock
private List<CliOptionHandler> handlers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import io.redskap.swagger.brake.cli.options.CliOption;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ApiFilenameHandlerTest {
private ApiFilenameHandler underTest = new ApiFilenameHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import io.redskap.swagger.brake.cli.options.CliOption;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ArtifactIdHandlerTest {
private ArtifactIdHandler underTest = new ArtifactIdHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import io.redskap.swagger.brake.runner.ArtifactPackaging;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ArtifactPackagingHandlerTest {
private ArtifactPackagingHandler underTest = new ArtifactPackagingHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import io.redskap.swagger.brake.cli.options.CliOption;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class BetaApiExtensionNameHandlerTest {
private BetaApiExtensionNameHandler underTest = new BetaApiExtensionNameHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import io.redskap.swagger.brake.cli.options.CliOption;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class CurrentArtifactVersionHandlerTest {
private CurrentArtifactVersionHandler underTest = new CurrentArtifactVersionHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static org.assertj.core.api.Assertions.assertThat;

import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class DeprecatedApiDeletionAllowedHandlerTest {
private DeprecatedApiDeletionAllowedHandler underTest = new DeprecatedApiDeletionAllowedHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import com.google.common.base.Joiner;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ExcludedPathsHandlerTest {
private ExcludedPathsHandler underTest = new ExcludedPathsHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import io.redskap.swagger.brake.cli.options.CliOption;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class GroupIdHandlerTest {
private GroupIdHandler underTest = new GroupIdHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import io.redskap.swagger.brake.cli.options.CliOption;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class MavenRepoPasswordHandlerTest {
private MavenRepoPasswordHandler underTest = new MavenRepoPasswordHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import io.redskap.swagger.brake.cli.options.CliOption;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class MavenRepoUrlHandlerTest {
private MavenRepoUrlHandler underTest = new MavenRepoUrlHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import io.redskap.swagger.brake.cli.options.CliOption;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class MavenRepoUsernameHandlerTest {
private MavenRepoUsernameHandler underTest = new MavenRepoUsernameHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import io.redskap.swagger.brake.cli.options.CliOption;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class MavenSnapshotRepoUrlHandlerTest {
private MavenSnapshotRepoUrlHandler underTest = new MavenSnapshotRepoUrlHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import io.redskap.swagger.brake.cli.options.CliOption;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class NewApiPathHandlerTest {
private NewApiPathHandler underTest = new NewApiPathHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import io.redskap.swagger.brake.cli.options.CliOption;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class OldApiPathHandlerTest {
private OldApiPathHandler underTest = new OldApiPathHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import io.redskap.swagger.brake.runner.Options;
import io.redskap.swagger.brake.runner.OutputFormat;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class OutputFormatsHandlerTest {
private OutputFormatsHandler underTest = new OutputFormatsHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import io.redskap.swagger.brake.cli.options.CliOption;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class OutputPathHandlerTest {
private OutputPathHandler underTest = new OutputPathHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import io.redskap.swagger.brake.cli.options.CliOption;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
3 changes: 1 addition & 2 deletions swagger-brake/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ dependencies {
implementation "com.fasterxml.jackson.core:jackson-databind:2.13.4"
implementation "com.github.spullara.mustache.java:compiler:0.9.10"
implementation "org.apache.httpcomponents:httpclient:4.5.13"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import io.redskap.swagger.brake.core.model.Response;
import io.swagger.v3.oas.models.responses.ApiResponse;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;

@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class ApiResponseTransformerTest {
@Mock
private MediaTypeTransformer mediaTypeTransformer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import io.redskap.swagger.brake.core.model.store.SchemaStore;
import io.redskap.swagger.brake.core.model.store.StoreProvider;
import io.swagger.v3.oas.models.media.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class SchemaTransformerTest {
private SchemaTransformer underTest;

@Before
@BeforeEach
public void setUp() {
underTest = new SchemaTransformer(new TypeRefNameResolver());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import io.redskap.swagger.brake.core.rule.request.parameter.constraint.ArrayConstrainedValue;
import io.redskap.swagger.brake.core.rule.request.parameter.constraint.ConstraintChange;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ArrayMaxItemsConstraintTest {
private ArrayMaxItemsConstraint underTest = new ArrayMaxItemsConstraint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import io.redskap.swagger.brake.core.rule.request.parameter.constraint.ArrayConstrainedValue;
import io.redskap.swagger.brake.core.rule.request.parameter.constraint.ConstraintChange;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ArrayMinItemsConstraintTest {
private ArrayMinItemsConstraint underTest = new ArrayMinItemsConstraint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import io.redskap.swagger.brake.core.rule.request.parameter.constraint.ArrayConstrainedValue;
import io.redskap.swagger.brake.core.rule.request.parameter.constraint.ConstraintChange;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class ArrayUniqueItemsConstraintTest {
private ArrayUniqueItemsConstraint underTest = new ArrayUniqueItemsConstraint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import io.redskap.swagger.brake.core.rule.request.parameter.constraint.ConstraintChange;
import io.redskap.swagger.brake.core.rule.request.parameter.constraint.NumberConstrainedValue;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class NumberMaximumConstraintTest {
private NumberMaximumConstraint underTest = new NumberMaximumConstraint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import io.redskap.swagger.brake.core.rule.request.parameter.constraint.ConstraintChange;
import io.redskap.swagger.brake.core.rule.request.parameter.constraint.NumberConstrainedValue;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class NumberMinimumConstraintTest {
private NumberMinimumConstraint underTest = new NumberMinimumConstraint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import io.redskap.swagger.brake.core.rule.request.parameter.constraint.ConstraintChange;
import io.redskap.swagger.brake.core.rule.request.parameter.constraint.StringConstrainedValue;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class StringMaxLengthConstraintTest {
private StringMaxLengthConstraint underTest = new StringMaxLengthConstraint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import io.redskap.swagger.brake.core.rule.request.parameter.constraint.ConstraintChange;
import io.redskap.swagger.brake.core.rule.request.parameter.constraint.StringConstrainedValue;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class StringMinLengthConstraintTest {
private StringMinLengthConstraint underTest = new StringMinLengthConstraint();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
package io.redskap.swagger.brake.core.util;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class PathNormalizerTest {

@Test(expected = IllegalArgumentException.class)
@Test
public void testNormalizePathSlashesThrowsExceptionWhenNullGiven() {
// given
// when
PathNormalizer.normalizePathSlashes(null);
assertThatThrownBy(() -> PathNormalizer.normalizePathSlashes(null)).isExactlyInstanceOf(IllegalArgumentException.class);
// then exception thrown
}

@Test(expected = IllegalArgumentException.class)
@Test
public void testNormalizePathSlashesThrowsExceptionWhenBlankGiven() {
// given
// when
PathNormalizer.normalizePathSlashes(" ");
assertThatThrownBy(() -> PathNormalizer.normalizePathSlashes(" ")).isExactlyInstanceOf(IllegalArgumentException.class);
// then exception thrown
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import io.redskap.swagger.brake.core.rule.beta.StandardApiToBetaApiBreakingChange;
import io.redskap.swagger.brake.integration.AbstractSwaggerBrakeIntTest;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class BetaApiIntTest extends AbstractSwaggerBrakeIntTest {
@Test
public void testBetaApiAdditionDoesntTriggerABreak() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import io.redskap.swagger.brake.core.BreakingChange;
import io.redskap.swagger.brake.integration.AbstractSwaggerBrakeIntTest;
import io.redskap.swagger.brake.runner.Options;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class ExcludedPathsIntTest extends AbstractSwaggerBrakeIntTest {
@Test
public void testExcludedPathsWorksCorrectlyForExactMatch() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

import io.redskap.swagger.brake.core.BreakingChange;
import io.redskap.swagger.brake.integration.AbstractSwaggerBrakeIntTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class NoBreakingChangeIntTest extends AbstractSwaggerBrakeIntTest {
@Test
public void testNoBreakingChangeWorksCorrectly() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

import io.redskap.swagger.brake.core.BreakingChange;
import io.redskap.swagger.brake.integration.AbstractSwaggerBrakeIntTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
public class RecursiveSchemaNoBreakingChangeIntTest extends AbstractSwaggerBrakeIntTest {
@Test
public void testNoBreakingChangeWorksCorrectly() {
Expand Down
Loading

0 comments on commit cbd6814

Please sign in to comment.