Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix github service tests #155

Merged
67 commits merged into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
84b3514
Testing...
kaladay Aug 2, 2022
6cacbcb
Another test...
kaladay Aug 2, 2022
3603833
Shouldn't really change anything should it?
kaladay Aug 2, 2022
1e45241
Trying newer mockito.
kaladay Aug 2, 2022
fd6b2b4
Try without deepmock
kaladay Aug 2, 2022
cbd34d9
Remove all deep stubs
kaladay Aug 2, 2022
9174e72
Add back limited deep stubs.
kaladay Aug 2, 2022
3dc587e
Without spring extension.
kaladay Aug 2, 2022
ee213fb
fix github service tests
Aug 3, 2022
002c5e2
instantiate test collections after stubbing
Aug 3, 2022
8ba0fe6
downgrade github-api
Aug 3, 2022
5d96deb
increment github-api version
Aug 3, 2022
88b9503
reorder setup again
Aug 3, 2022
4d963a3
minor reorder of test properties
Aug 3, 2022
06055d8
replace deep stubs with more mocks
Aug 3, 2022
2f7ca49
remove redundant extensions
Aug 3, 2022
ffec614
use long primitive for mock value
Aug 3, 2022
64d98e3
try doReturn stubbing
Aug 3, 2022
920f919
doReturn long primitive
Aug 3, 2022
e85d9c3
remove unused import
Aug 3, 2022
0d6296c
add byte buddy dependency back
Aug 3, 2022
e867063
use string value of for repository get id stubbing
Aug 3, 2022
da76900
try not using a constant
Aug 3, 2022
f3898dd
reinitialize ids before each
Aug 3, 2022
fef576f
revert some changes
Aug 3, 2022
033543f
trye surefire configuration parallel none
Aug 3, 2022
0bdc8c3
disable fork reuse of maven surefire plugin
Aug 3, 2022
166578a
Explicitly set default settings.
kaladay Aug 3, 2022
fda0f9f
try with return value
Aug 3, 2022
aa5a753
try reflection for repository id
Aug 3, 2022
9e678e6
Add some debugging data
kaladay Aug 3, 2022
9249c24
revert changes
Aug 3, 2022
c800d24
fix inconsistencies
Aug 3, 2022
e1e2572
Merge branch 'tech_debt_fixes-experiment' into test_debt_fixes_experi…
Aug 3, 2022
bf72942
downgrade github-api
Aug 3, 2022
79979ae
Merge branch 'test_debt_fixes_experiment_fixes' of github.com:TAMULib…
Aug 3, 2022
ca85fef
add paged iterable import back
Aug 3, 2022
bda5b00
remove debug lines
Aug 3, 2022
b7513fc
upgrade github-api version again
Aug 3, 2022
7581326
use latest bytebuddy dependencies
Aug 3, 2022
7159b33
use latest mockito
Aug 3, 2022
feb327e
try doReturn for getId
Aug 3, 2022
a28bf20
return string for id
Aug 3, 2022
c194cfa
try thenAnswer
Aug 3, 2022
eb4a54e
thenAnswer Long for getId
Aug 3, 2022
ac6e64a
try reflection and call real method
Aug 3, 2022
de98dfb
try extraInterfaces
Aug 3, 2022
3b19396
try stubOnly
Aug 3, 2022
08fe1e2
trry init bytebuddy agent
Aug 3, 2022
ca8f53a
comment out and disable untestable code
Aug 3, 2022
dc62aea
try reflection on ghobject
Aug 3, 2022
324c02e
move getId call real method to test
Aug 3, 2022
55934b6
add polymorphic method to avoid GHObject getId stubbing issue
Aug 3, 2022
d601087
init mocks before each
Aug 3, 2022
da83510
try without extension
Aug 3, 2022
e5d46a1
try waiting a long while
Aug 3, 2022
efd7a94
wait a second before each
Aug 3, 2022
fba3ea7
reorder stubbing
Aug 3, 2022
00e6301
mock properties once
Aug 3, 2022
44f9db2
stub once
Aug 3, 2022
772c76f
cleanup
Aug 3, 2022
07d5995
reorder stubbing
Aug 3, 2022
054ea0e
replace GHObject removing WithBridgeMethods annotation from getId
Aug 3, 2022
b26fed6
add findbugs annotation dependency
Aug 3, 2022
000d0a5
replace deprecated asList
Aug 3, 2022
f2447a4
use mockito extension and annotation
Aug 3, 2022
1698c47
move GHObject to tests and cleanup pom
Aug 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 50 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,67 @@
</dependency>

<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.6.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</exclusion>
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>4.6.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.12.13</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<version>1.12.13</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.infradna.tool</groupId>
<artifactId>bridge-method-annotation</artifactId>
<version>1.23</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.1</version>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ public List<Sprint> getActiveSprintsByScopeId(final String scopeId) throws Excep
logger.info("Fetching active sprints for remote project with scope id " + scopeId);
GHRepository repo = github.getRepositoryById(scopeId);
String productName = repo.getName();
return repo.listProjects(ProjectStateFilter.OPEN).asList().stream()
return repo.listProjects(ProjectStateFilter.OPEN).toList().stream()
.flatMap(project -> getActiveSprintsForProject(project, productName))
.collect(Collectors.toList());
}

@Override
public List<Sprint> getAdditionalActiveSprints() throws Exception {
GHOrganization organization = github.getOrganization(ORGANIZATION);
return organization.listProjects(ProjectStateFilter.OPEN).asList().stream()
return organization.listProjects(ProjectStateFilter.OPEN).toList().stream()
.flatMap(project -> getActiveSprintsForProject(project, toProductName(project)))
.collect(Collectors.toList());
}
Expand All @@ -55,8 +55,8 @@ private Stream<Sprint> getActiveSprintsForProject(GHProject project, String prod
}

private Map<String, List<Card>> getCards(GHProject project) throws IOException {
return project.listColumns().asList().stream()
.flatMap(column -> exceptionHandlerWrapper(column, c -> c.listCards().asList().stream()))
return project.listColumns().toList().stream()
.flatMap(column -> exceptionHandlerWrapper(column, c -> c.listCards().toList().stream()))
.map(card -> Pair.of(card, exceptionHandlerWrapper(card, c -> c.getContent())))
// Card without contents is a note
.filter(p -> Objects.nonNull(p.getValue()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public List<Sprint> getActiveSprintsByScopeId(final String scopeId) throws Excep
logger.info("Fetching active sprints for remote project with scope id " + scopeId);
GHRepository repo = github.getRepositoryById(scopeId);
String productName = repo.getName();
return repo.listProjects(ProjectStateFilter.OPEN).asList().stream()
return repo.listProjects(ProjectStateFilter.OPEN).toList().stream()
.filter(this::isSprintProject)
.map(p -> toSprint(p, productName))
.collect(Collectors.toList());
Expand All @@ -37,7 +37,7 @@ public List<Sprint> getActiveSprintsByScopeId(final String scopeId) throws Excep
@Override
public List<Sprint> getAdditionalActiveSprints() throws Exception {
return github.getOrganization(ORGANIZATION)
.listProjects(ProjectStateFilter.OPEN).asList().stream()
.listProjects(ProjectStateFilter.OPEN).toList().stream()
.filter(this::isSprintProject)
.map(p -> toSprint(p, ORGANIZATION))
.collect(Collectors.toList());
Expand All @@ -58,8 +58,8 @@ private Sprint toSprint(GHProject project, String productName) {
}

private List<Card> getCards(GHProject project) {
return exceptionHandlerWrapper(project, i -> i.listColumns().asList().stream())
.flatMap(c -> exceptionHandlerWrapper(c, i -> i.listCards().asList().stream()))
return exceptionHandlerWrapper(project, i -> i.listColumns().toList().stream())
.flatMap(c -> exceptionHandlerWrapper(c, i -> i.listCards().toList().stream()))
.map(c -> Pair.of(c, exceptionHandlerWrapper(c, i -> i.getContent())))
// Card without contents is a note
.filter(e -> Objects.nonNull(e.getValue()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs;
Expand All @@ -25,7 +24,6 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;

import edu.tamu.app.ProductApplication;
Expand All @@ -41,7 +39,6 @@
@SpringBootTest(classes = { ProductApplication.class }, webEnvironment=WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
@AutoConfigureRestDocs(outputDir = "target/generated-snippets")
@ExtendWith(SpringExtension.class)
public class ActiveSprintsCacheControllerIntegrationTest extends AbstractRepoTest {

private static final String TEST_MEMBER_ID = "Test Member ID";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@
import java.util.List;
import java.util.Optional;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.kohsuke.github.GitHubBuilder;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -44,10 +40,12 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;

import edu.tamu.app.ProductApplication;
import edu.tamu.app.cache.service.ActiveSprintsScheduledCacheService;
import edu.tamu.app.cache.service.ProductsStatsScheduledCacheService;
Expand All @@ -69,7 +67,6 @@
@SpringBootTest(classes = { ProductApplication.class }, webEnvironment=WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
@AutoConfigureRestDocs(outputDir = "target/generated-snippets")
@ExtendWith(SpringExtension.class)
public class InternalRequestControllerIntegrationTest extends AbstractRepoTest {

private static long currentId = 0L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.kohsuke.github.GitHubBuilder;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -28,7 +27,6 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;

Expand All @@ -40,8 +38,8 @@
import edu.tamu.app.cache.service.RemoteProjectsScheduledCacheService;
import edu.tamu.app.model.RemoteProjectManager;
import edu.tamu.app.model.ServiceType;
import edu.tamu.app.model.repo.RemoteProjectManagerRepo;
import edu.tamu.app.model.repo.AbstractRepoTest;
import edu.tamu.app.model.repo.RemoteProjectManagerRepo;
import edu.tamu.app.service.manager.GitHubProjectService;
import edu.tamu.app.service.manager.VersionOneService;
import edu.tamu.weaver.response.ApiResponse;
Expand All @@ -50,7 +48,6 @@
@SpringBootTest(classes = { ProductApplication.class }, webEnvironment=WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
@AutoConfigureRestDocs(outputDir = "target/generated-snippets")
@ExtendWith(SpringExtension.class)
public class RemoteProjectManagerControllerIntegrationTest extends AbstractRepoTest {

private static long currentId = 0L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import edu.tamu.app.ProductApplication;
import edu.tamu.app.model.Estimate;
import edu.tamu.app.model.repo.EstimateRepo;

@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = { ProductApplication.class }, webEnvironment = WebEnvironment.RANDOM_PORT)
public class EstimateMappingServiceTest {

Expand Down
3 changes: 0 additions & 3 deletions src/test/java/edu/tamu/app/model/ProductTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.kohsuke.github.GitHub;
import org.kohsuke.github.GitHubBuilder;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import edu.tamu.app.ProductApplication;
import edu.tamu.app.cache.service.ActiveSprintsScheduledCacheService;
Expand All @@ -25,7 +23,6 @@
import edu.tamu.app.service.manager.VersionOneService;
import edu.tamu.app.service.ticketing.SugarService;

@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = { ProductApplication.class }, webEnvironment = WebEnvironment.RANDOM_PORT)
public class ProductTest extends AbstractModelTest {

Expand Down
3 changes: 0 additions & 3 deletions src/test/java/edu/tamu/app/model/repo/EstimateRepoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.kohsuke.github.GitHub;
import org.kohsuke.github.GitHubBuilder;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import edu.tamu.app.ProductApplication;
import edu.tamu.app.cache.service.ActiveSprintsScheduledCacheService;
Expand All @@ -31,7 +29,6 @@
import edu.tamu.app.service.manager.VersionOneService;
import edu.tamu.app.service.ticketing.SugarService;

@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = { ProductApplication.class }, webEnvironment = WebEnvironment.RANDOM_PORT)
public class EstimateRepoTest extends AbstractRepoTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.kohsuke.github.GitHub;
import org.kohsuke.github.GitHubBuilder;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import edu.tamu.app.ProductApplication;
import edu.tamu.app.cache.service.ActiveSprintsScheduledCacheService;
Expand All @@ -31,7 +29,6 @@
import edu.tamu.app.service.manager.VersionOneService;
import edu.tamu.app.service.ticketing.SugarService;

@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = { ProductApplication.class }, webEnvironment = WebEnvironment.RANDOM_PORT)
public class InternalRequestRepoTest extends AbstractRepoTest {

Expand Down
5 changes: 1 addition & 4 deletions src/test/java/edu/tamu/app/model/repo/ProductRepoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.kohsuke.github.GitHub;
import org.kohsuke.github.GitHubBuilder;
import org.mockito.Mock;
Expand All @@ -22,7 +21,6 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import edu.tamu.app.ProductApplication;
import edu.tamu.app.cache.service.ActiveSprintsScheduledCacheService;
Expand All @@ -37,10 +35,9 @@
import edu.tamu.app.service.registry.ManagementBeanRegistry;
import edu.tamu.app.service.ticketing.SugarService;

@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = { ProductApplication.class }, webEnvironment = WebEnvironment.RANDOM_PORT)
public class ProductRepoTest extends AbstractRepoTest {

private static final RemoteProjectManager TEST_REMOTE_PROJECT_MANAGER1 = new RemoteProjectManager(TEST_REMOTE_PROJECT_MANAGER_NAME1, ServiceType.VERSION_ONE, TEST_PROJECT_URL1, TEST_PROJECT_TOKEN1);

private static final RemoteProjectInfo TEST_REMOTE_PROJECT_INFO1 = new RemoteProjectInfo(TEST_PROJECT_SCOPE1, TEST_REMOTE_PROJECT_MANAGER1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.mockito.Mockito;
import org.springframework.test.context.junit.jupiter.SpringExtension;


@ExtendWith(SpringExtension.class)
public class AbstractRequetTest {

Expand Down