Skip to content

Commit

Permalink
Merge db3035d into 37d7635
Browse files Browse the repository at this point in the history
  • Loading branch information
icougil committed Nov 3, 2019
2 parents 37d7635 + db3035d commit 182c2d8
Show file tree
Hide file tree
Showing 45 changed files with 236 additions and 198 deletions.
12 changes: 7 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ sourceSets {
inttest {
java.srcDir 'src/inttest/java'
resources.srcDir 'src/inttest/resources'
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
compileClasspath += sourceSets.test.compileClasspath
runtimeClasspath += sourceSets.test.runtimeClasspath
}
}

Expand All @@ -165,6 +165,9 @@ task inttest(type: Test) {

setTestClassesDirs(files(sourceSets.inttest.output))
classpath = sourceSets.inttest.runtimeClasspath

useJUnitPlatform()

mustRunAfter test
}

Expand Down Expand Up @@ -205,8 +208,7 @@ dependencyManagement {
}

test {
useJUnitPlatform {
}
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
Expand Down Expand Up @@ -272,10 +274,10 @@ dependencies {
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("org.springframework.restdocs:spring-restdocs-mockmvc")
testCompile("org.springframework.security:spring-security-test")
testImplementation("junit:junit")
testImplementation("org.junit.jupiter:junit-jupiter:${jUnit5Version}")
testImplementation("org.junit.jupiter:junit-jupiter-params:${jUnit5Version}")
testImplementation("org.mockito:mockito-junit-jupiter:${mockitoVersion}")
testImplementation("org.junit.jupiter:junit-jupiter-migrationsupport:${jUnit5Version}")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:${jUnit5Version}")
testCompile("com.h2database:h2:${h2Version}")
testCompile("com.jayway.jsonpath:json-path:${jsonPath}")
Expand Down
10 changes: 5 additions & 5 deletions src/inttest/java/com/faforever/api/AbstractIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import com.github.jasminb.jsonapi.ResourceConverter;
import com.github.jasminb.jsonapi.exceptions.DocumentSerializationException;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.internal.util.collections.Sets;
import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -30,7 +30,7 @@
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.RequestPostProcessor;
Expand All @@ -44,7 +44,7 @@

import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;

@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@ActiveProfiles(ApplicationProfile.INTEGRATION_TEST)
@Import(OAuthHelper.class)
Expand All @@ -67,7 +67,7 @@ public abstract class AbstractIntegrationTest {
protected ObjectMapper objectMapper;
protected ResourceConverter resourceConverter;

@Before
@BeforeEach
public void setUp() {
this.mockMvc = MockMvcBuilders
.webAppContextSetup(this.context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import com.faforever.api.security.AuditService;
import com.faforever.api.security.OAuthScope;
import com.faforever.api.utils.FileHandlingHelper;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -136,7 +136,7 @@ public void cannotDeleteWithoutScope() throws Exception {
verify(auditServiceSpy, times(0)).logMessage(any());
}

@After
@AfterEach
public void tearDown() throws Exception {
Files.deleteIfExists(Paths.get("build/cache/avatars/avatar1.png"));
Files.deleteIfExists(Paths.get("build/cache/avatars/avatar3.png"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.faforever.api.error.ErrorCode;
import com.faforever.api.player.PlayerRepository;
import com.faforever.api.security.FafUserDetails;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.security.core.context.SecurityContextHolder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.faforever.commons.api.dto.Avatar;
import com.faforever.commons.api.dto.AvatarAssignment;
import com.faforever.commons.api.dto.Player;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.security.test.context.support.WithUserDetails;
import org.springframework.test.context.jdbc.Sql;
Expand Down
3 changes: 2 additions & 1 deletion src/inttest/java/com/faforever/api/data/BanTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import com.faforever.commons.api.dto.BanLevel;
import com.faforever.commons.api.dto.ModerationReport;
import com.faforever.commons.api.dto.Player;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
Expand Down
2 changes: 1 addition & 1 deletion src/inttest/java/com/faforever/api/data/ClanElideTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.faforever.api.player.PlayerRepository;
import lombok.SneakyThrows;
import org.json.JSONObject;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.security.test.context.support.WithUserDetails;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.faforever.api.AbstractIntegrationTest;
import com.faforever.api.data.domain.GroupPermission;
import com.faforever.api.security.OAuthScope;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.security.test.context.support.WithUserDetails;
import org.springframework.test.context.jdbc.Sql;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.faforever.api.AbstractIntegrationTest;
import com.faforever.api.data.domain.GroupPermission;
import com.faforever.api.security.OAuthScope;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.faforever.api.AbstractIntegrationTest;
import com.faforever.api.data.domain.GroupPermission;
import com.faforever.api.security.OAuthScope;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.security.test.context.support.WithUserDetails;
import org.springframework.test.context.jdbc.Sql;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.faforever.api.AbstractIntegrationTest;
import com.faforever.api.data.domain.GroupPermission;
import com.faforever.api.security.OAuthScope;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.security.test.context.support.WithUserDetails;
import org.springframework.test.context.jdbc.Sql;
Expand Down
2 changes: 1 addition & 1 deletion src/inttest/java/com/faforever/api/data/TeamkillTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.faforever.api.AbstractIntegrationTest;
import com.faforever.api.data.domain.GroupPermission;
import com.faforever.api.security.OAuthScope;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.faforever.commons.api.dto.Tutorial;
import com.faforever.commons.api.dto.TutorialCategory;
import com.jayway.jsonpath.JsonPath;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
Expand Down
2 changes: 1 addition & 1 deletion src/inttest/java/com/faforever/api/data/UserNoteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.faforever.api.data.domain.GroupPermission;
import com.faforever.api.player.PlayerRepository;
import com.faforever.api.security.OAuthScope;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.jdbc.Sql;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.faforever.api.data.domain.VotingQuestion;
import com.faforever.api.security.OAuthScope;
import com.faforever.api.voting.VotingQuestionRepository;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.faforever.api.deployment;

import com.faforever.api.AbstractIntegrationTest;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.jdbc.Sql;

Expand All @@ -19,7 +19,7 @@ public class ExeUploadControllerTest extends AbstractIntegrationTest {
private MockMultipartFile file;
private static final String SUPER_SECRET = "banana";

@Before
@BeforeEach
public void setUp() {
super.setUp();
file = new MockMultipartFile("file", "ForgedAlliance.exe", "application/octet-stream", new byte[]{ 1, 2 ,3, 4 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.faforever.api.security.OAuthScope;
import com.google.common.collect.Lists;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.faforever.api.leaderboard;

import com.faforever.api.AbstractIntegrationTest;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;
import org.springframework.test.web.servlet.MvcResult;
Expand Down
6 changes: 3 additions & 3 deletions src/inttest/java/com/faforever/api/login/LoginTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.faforever.api.AbstractIntegrationTest;
import org.jetbrains.annotations.NotNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
Expand All @@ -18,7 +18,7 @@ public class LoginTest extends AbstractIntegrationTest {
private MultiValueMap<String, String> params;

@Override
@Before
@BeforeEach
public void setUp() {
super.setUp();
params = new LinkedMultiValueMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import com.faforever.commons.api.dto.ModerationReportStatus;
import com.faforever.commons.api.dto.Player;
import com.google.common.collect.Sets;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.security.test.context.support.WithAnonymousUser;
import org.springframework.test.context.jdbc.Sql;
Expand Down Expand Up @@ -41,7 +41,7 @@ public class ModerationReportTest extends AbstractIntegrationTest {
private Set<Player> reportedUsers;

@Override
@Before
@BeforeEach
public void setUp() {
super.setUp();
Player reporter = (Player) new Player().setId("1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.faforever.api.security.FafTokenType;
import com.faforever.api.security.OAuthScope;
import com.google.common.collect.ImmutableMap;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.HttpHeaders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
import com.faforever.api.data.domain.PlayerAchievement;
import com.faforever.api.error.ErrorCode;
import org.hamcrest.CoreMatchers;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.migrationsupport.rules.ExpectedExceptionSupport;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;

import java.util.Optional;

Expand All @@ -28,7 +29,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
@ExtendWith({MockitoExtension.class, ExpectedExceptionSupport.class})
public class EventsServiceTest {

private static final int PLAYER_ID = 1;
Expand All @@ -47,7 +48,7 @@ private static PlayerAchievement createPlayerAchievement(Integer currentSteps, A
return playerAchievement;
}

@Before
@BeforeEach
public void setUp() throws Exception {
instance = new AchievementService(achievementRepository, playerAchievementRepository);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,30 @@
import com.faforever.api.achievements.AchievementUpdateRequest.Operation;
import com.faforever.api.data.domain.AchievementState;
import com.yahoo.elide.jsonapi.models.JsonApiDocument;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;

import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;


@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class PlayerAchievementsControllerTest {

private AchievementsController instance;

@Mock
private AchievementService achievementService;

@Before
@BeforeEach
public void setUp() throws Exception {
instance = new AchievementsController(achievementService);
}
Expand Down Expand Up @@ -59,10 +60,11 @@ public void update() throws Exception {
assertThat(result.getData().get(), hasSize(6));
}

@Test(expected = UnsupportedOperationException.class)
@Test
public void updateReveledUnsupported() throws Exception {
AchievementUpdateRequest[] updateRequests = {new AchievementUpdateRequest(1, "111", Operation.REVEAL, 1)};

instance.update(updateRequests);
assertThrows(UnsupportedOperationException.class, () -> instance.update(updateRequests));

}
}
Loading

0 comments on commit 182c2d8

Please sign in to comment.