Skip to content
Permalink
Browse files
forge: refactor HostUser constructor to static methods
Reviewed-by: rwestberg
  • Loading branch information
edvbld committed Oct 19, 2020
1 parent 89235b5 commit 5fa4d6e3fea8dbc33343ddbd53df0812cd52b100
Showing with 151 additions and 142 deletions.
  1. +2 −2 bots/checkout/src/test/java/org/openjdk/skara/bots/checkout/CheckoutBotTests.java
  2. +2 −2 bots/forward/src/test/java/org/openjdk/skara/bots/forward/ForwardBotTests.java
  3. +1 −1 bots/hgbridge/src/test/java/org/openjdk/skara/bots/hgbridge/BridgeBotTests.java
  4. +14 −14 bots/merge/src/test/java/org/openjdk/skara/bots/merge/MergeBotTests.java
  5. +5 −5 bots/mirror/src/test/java/org/openjdk/skara/bots/mirror/MirrorBotTests.java
  6. +3 −3 bots/pr/src/test/java/org/openjdk/skara/bots/pr/VetoTests.java
  7. +1 −1 bots/tester/src/test/java/org/openjdk/skara/bots/tester/InMemoryHost.java
  8. +23 −23 bots/tester/src/test/java/org/openjdk/skara/bots/tester/StateTests.java
  9. +36 −36 bots/tester/src/test/java/org/openjdk/skara/bots/tester/TestWorkItemTests.java
  10. +2 −2 bots/topological/src/test/java/org/openjdk/skara/bots/topological/TopologicalBotTests.java
  11. +3 −3 forge/src/main/java/org/openjdk/skara/forge/github/GitHubHost.java
  12. +1 −1 forge/src/main/java/org/openjdk/skara/forge/gitlab/GitLabHost.java
  13. +6 −6 forge/src/main/java/org/openjdk/skara/forge/gitlab/GitLabMergeRequest.java
  14. +27 −18 host/src/main/java/org/openjdk/skara/host/HostUser.java
  15. +7 −7 issuetracker/src/main/java/org/openjdk/skara/issuetracker/jira/JiraHost.java
  16. +9 −9 issuetracker/src/main/java/org/openjdk/skara/issuetracker/jira/JiraIssue.java
  17. +4 −4 issuetracker/src/main/java/org/openjdk/skara/issuetracker/jira/JiraProject.java
  18. +1 −1 test/src/main/java/org/openjdk/skara/test/CensusBuilder.java
  19. +4 −4 test/src/main/java/org/openjdk/skara/test/HostCredentials.java
@@ -58,7 +58,7 @@ private static void populate(Repository r) throws IOException {
@Test
void simpleConversion(TestInfo testInfo) throws IOException {
try (var tmp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));
var marksLocalDir = tmp.path().resolve("marks.git");
Files.createDirectories(marksLocalDir);
var marksLocalRepo = Repository.init(marksLocalDir, VCS.GIT);
@@ -90,7 +90,7 @@ void simpleConversion(TestInfo testInfo) throws IOException {
@Test
void update(TestInfo testInfo) throws IOException {
try (var tmp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));
var marksLocalDir = tmp.path().resolve("marks.git");
Files.createDirectories(marksLocalDir);
var marksLocalRepo = Repository.init(marksLocalDir, VCS.GIT);
@@ -41,7 +41,7 @@ class ForwardBotTests {
@Test
void mirrorMasterBranches(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -78,7 +78,7 @@ void mirrorMasterBranches(TestInfo testInfo) throws IOException {
@Test
void mirrorDifferentBranches(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -68,7 +68,7 @@ static class TestExporterConfig extends ExporterConfig {
this.source(source);
this.destinations(List.of(destination));

var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));
var marksLocalRepo = Repository.init(marksRepoPath.resolve("marks.git"), VCS.GIT);

var initialFile = marksLocalRepo.root().resolve("init.txt");
@@ -42,7 +42,7 @@ class MergeBotTests {
@Test
void mergeMasterBranch(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -117,7 +117,7 @@ void mergeMasterBranch(TestInfo testInfo) throws IOException {
@Test
void successfulDependency(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory(false)) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -206,7 +206,7 @@ void successfulDependency(TestInfo testInfo) throws IOException {
@Test
void failedDependency(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory(false)) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -298,7 +298,7 @@ void failedDependency(TestInfo testInfo) throws IOException {
@Test
void failingMergeTest(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -369,7 +369,7 @@ void failingMergeTest(TestInfo testInfo) throws IOException {
@Test
void failingPrerequisite(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -438,7 +438,7 @@ void failingPrerequisite(TestInfo testInfo) throws IOException {
var fromLocalRepo2 = Repository.init(fromDir2, VCS.GIT);
var fromHostedRepo2 = new TestHostedRepository(host, "test-2", fromLocalRepo2);

var host2 = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host2 = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));
var toDir2 = temp.path().resolve("to2.git");
var toLocalRepo2 = Repository.init(toDir2, VCS.GIT);
var toGitConfig2 = toDir2.resolve(".git").resolve("config");
@@ -501,7 +501,7 @@ void failingPrerequisite(TestInfo testInfo) throws IOException {
@Test
void failingMergeShouldResultInOnlyOnePR(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -572,7 +572,7 @@ void failingMergeShouldResultInOnlyOnePR(TestInfo testInfo) throws IOException {
@Test
void resolvedMergeConflictShouldResultInIntegrateCommand(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -684,7 +684,7 @@ public ZonedDateTime now() {
@Test
void testMergeHourly(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -799,7 +799,7 @@ void testMergeHourly(TestInfo testInfo) throws IOException {
@Test
void testMergeDaily(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -920,7 +920,7 @@ void testMergeDaily(TestInfo testInfo) throws IOException {
@Test
void testMergeWeekly(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -1041,7 +1041,7 @@ void testMergeWeekly(TestInfo testInfo) throws IOException {
@Test
void testMergeMonthly(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -1162,7 +1162,7 @@ void testMergeMonthly(TestInfo testInfo) throws IOException {
@Test
void testMergeYearly(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -1289,7 +1289,7 @@ void testMergeYearly(TestInfo testInfo) throws IOException {
@Test
void mergeAfterDivergedStorage(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -40,7 +40,7 @@ class MirrorBotTests {
@Test
void mirrorMasterBranch(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -77,7 +77,7 @@ void mirrorMasterBranch(TestInfo testInfo) throws IOException {
@Test
void mirrorMultipleBranches(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -123,7 +123,7 @@ void mirrorMultipleBranches(TestInfo testInfo) throws IOException {
@Test
void mirrorMultipleTags(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -168,7 +168,7 @@ void mirrorMultipleTags(TestInfo testInfo) throws IOException {
@Test
void mirrorRemovingBranch(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -223,7 +223,7 @@ void mirrorRemovingBranch(TestInfo testInfo) throws IOException {
@Test
void mirrorSelectedBranches(TestInfo testInfo) throws IOException {
try (var temp = new TemporaryDirectory()) {
var host = TestHost.createNew(List.of(new HostUser(0, "duke", "J. Duke")));
var host = TestHost.createNew(List.of(HostUser.create(0, "duke", "J. Duke")));

var fromDir = temp.path().resolve("from.git");
var fromLocalRepo = Repository.init(fromDir, VCS.GIT);
@@ -37,9 +37,9 @@

class VetoTests {
private static HostUser createUser(int id) {
return new HostUser(id,
String.format("noname_%d", id),
String.format("No Name %d", id));
return HostUser.create(id,
String.format("noname_%d", id),
String.format("No Name %d", id));
}

private static class Comments {
@@ -29,7 +29,7 @@
import java.util.*;

class InMemoryHost implements Forge {
HostUser currentUserDetails = new HostUser(0, "openjdk", "openjdk [bot]");
HostUser currentUserDetails = HostUser.create(0, "openjdk", "openjdk [bot]");
Map<String, Set<HostUser>> groups;

@Override

2 comments on commit 5fa4d6e

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 5fa4d6e Oct 19, 2020

Choose a reason for hiding this comment

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

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 5fa4d6e Oct 20, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.