Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
Fix checkstyles and tests

Signed-off-by: stelios maurommatakis <steliosmavr@cytech.gr>
  • Loading branch information
Stelios123 committed Apr 25, 2024
1 parent ee1fc9b commit 2f8e730
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
./gradlew :uiTest
url: http://127.0.0.1:8082
reportName: ui-test-fails-report-linux
- os: macOS-latest
- os: macos-13
runIde: |
mkdir -p build/reports
./gradlew :runIdeForUiTests > build/reports/idea.log &
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public RadDiscussion findDiscussion(String commentId) {
}
}

public record Edit(RadAuthor author, String body, Instant timestamp, List<Embed> embeds) {}
public record Edit(RadAuthor author, String body, Instant timestamp, List<Embed> embeds) { }

public record Merge(RadAuthor author, String commit, Instant timestamp, String revision) { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ protected RadProject getProjectInfo(GitRepository repo) {
return api.fetchRadProject(projectId);
}

protected static GitRemote findRadRemote(GitRepository repo, String radProjectId) {
public GitRemote findRadRemote(GitRepository repo, String radProjectId) {
if (Strings.isNullOrEmpty(radProjectId)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,22 @@ public void filterList(PatchListSearchValue plsv) {
p.id.toLowerCase().contains(search) ||
Strings.nullToEmpty(p.author.id).toLowerCase().contains(search) ||
Strings.nullToEmpty(p.author.alias).toLowerCase().contains(search) ||
Strings.nullToEmpty(p.title).toLowerCase().contains(searchFilter) ||
Strings.nullToEmpty(p.title).toLowerCase().contains(searchFilter.toLowerCase().trim()) ||
Strings.nullToEmpty(p.getLatestNonEmptyRevisionDescription()).toLowerCase().contains(search));
}
if (!Strings.isNullOrEmpty(plsv.project)) {
patchesStream = patchesStream.filter(p -> p.repo.getRoot().getName().equals(projectFilter));
}
if (!Strings.isNullOrEmpty(peerAuthorFilter)) {
patchesStream = patchesStream.filter(p -> Strings.nullToEmpty(p.author.alias).contains(peerAuthorFilter) ||
p.author.id.contains(peerAuthorFilter));
patchesStream = patchesStream.filter(p -> Strings.nullToEmpty(p.author.alias).equals(peerAuthorFilter) ||
p.author.id.equals(peerAuthorFilter));
}
if (!Strings.isNullOrEmpty(stateFilter)) {
patchesStream = patchesStream.filter(p -> p.state != null && p.state.label.equals(stateFilter));
}
if (!Strings.isNullOrEmpty(labelFilter)) {
patchesStream = patchesStream.filter(p -> p.labels.stream().anyMatch(l -> Strings.nullToEmpty(l).toLowerCase().contains(labelFilter)));
patchesStream = patchesStream.filter(p -> p.labels.stream().anyMatch(l ->
Strings.nullToEmpty(l).toLowerCase().contains(labelFilter.toLowerCase().trim())));
}
List<RadPatch> filteredPatches = patchesStream.collect(Collectors.toList());
model.addAll(filteredPatches);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ public List<RadPatch> fetchPatches(String projectId, GitRepository repo) {
if (radProject == null) {
return List.of();
}
final var identity = getCurrentIdentity();
var self = identity == null ? null : identity.toRadAuthor();
final var myIdentity = getCurrentIdentity();
var self = myIdentity == null ? null : myIdentity.toRadAuthor();
var node = getSeedNode();
var states = Arrays.stream(RadPatch.State.values()).map(e -> e.status).toList();
var allPatches = new ArrayList<RadPatch>();
Expand Down Expand Up @@ -216,8 +216,8 @@ public RadPatch fetchPatch(String projectId, GitRepository repo, String patchId)
if (radProject == null) {
return null;
}
final var identity = getCurrentIdentity();
final var self = identity == null ? null : identity.toRadAuthor();
final var myIdentity = getCurrentIdentity();
final var self = myIdentity == null ? null : myIdentity.toRadAuthor();
final var node = getSeedNode();
final var url = node.url + "/api/v1/projects/" + projectId + "/patches/" + patchId;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import java.io.IOException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutionException;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -274,11 +274,11 @@ public static List<RadProject> getTestProjects() {
}

public static List<RadPatch> getTestPatches() {
var revision = new RadPatch.Revision("testRevision", "testDescription", "", "",
List.of(), List.of(), Instant.now(), List.of(), List.of(new RadPatch.Review("1",
new RadAuthor(AUTHOR), RadPatch.Review.Verdict.ACCEPT, "test", List.of(), Instant.now())), new RadAuthor(UUID.randomUUID().toString()));
var revision = new RadPatch.Revision("testRevision", new RadAuthor(AUTHOR), "testDescription", List.of(), List.of(), "", "",
List.of(), Instant.now(), new ArrayList<>(), List.of(new RadPatch.Review("1",
new RadAuthor(AUTHOR), RadPatch.Review.Verdict.ACCEPT, "test", List.of(), Instant.now())));

var radPatch = new RadPatch("c5df12", new RadProject("test-rad-project", "test-rad-project", "", "main", List.of()), new RadAuthor(AUTHOR),
var radPatch = new RadPatch("c5df12", new RadProject("test-rad-project", "test-rad-project", "", "main", List.of(AUTHOR)), new RadAuthor(AUTHOR),
"testPatch", new RadAuthor(AUTHOR), "testTarget",
List.of("tag1", "tag2"), RadPatch.State.OPEN, List.of(revision));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void setUpToolWindow() throws InterruptedException, IOException {
patch = new RadPatch(patches.get(0));
patch.repo = firstRepo;
patch.project = getProject();
patch.defaultBranch = projects.get(0).defaultBranch;
patch.radProject.defaultBranch = projects.get(0).defaultBranch;
when(httpClient.execute(any())).thenAnswer((i) -> {
var req = (HttpGet) i.getArgument(0);
final StringEntity se;
Expand All @@ -81,7 +81,7 @@ public void setUpToolWindow() throws InterruptedException, IOException {
se = new StringEntity(RadicleProjectApi.MAPPER.writeValueAsString(pps));
} else if (req.getURI().getPath().endsWith(ISSUES_URL)) {
se = new StringEntity("[]");
} else if (req.getURI().getPath().endsWith(PROJECTS_URL + "/" + patch.projectId + PATCHES_URL + "/" + patch.id)) {
} else if (req.getURI().getPath().endsWith(PROJECTS_URL + "/" + patch.radProject.id + PATCHES_URL + "/" + patch.id)) {
// request to re-fetch the patch
var fetchedPatch = new RadPatch(patch);
fetchedPatch.project = null;
Expand Down Expand Up @@ -137,7 +137,7 @@ public void testPatchInfoPanel() {
// find the labels for branches, something like <default_branch> <- <patch_branch>
var branchLabels = UIUtil.findComponentsOfType((JPanel) allPanels[0], JLabel.class);
assertThat(branchLabels).hasSizeGreaterThanOrEqualTo(3);
assertThat(branchLabels.get(0).getText()).isEqualTo(patch.defaultBranch);
assertThat(branchLabels.get(0).getText()).isEqualTo(patch.radProject.defaultBranch);
assertThat(branchLabels.get(2).getText()).contains(patch.id);

// find patch title and id labels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -996,8 +996,9 @@ private RadPatch.Revision createRevision(String id, String description, GitCommi
discussions.add(discussion);
var review = new RadPatch.Review(UUID.randomUUID().toString(), new RadAuthor("fakeDid"),
RadPatch.Review.Verdict.ACCEPT, REVIEW_SUMMARY, List.of(), Instant.now());
return new RadPatch.Revision(id, description, base, commit.getId().asString(),
List.of("branch"), List.of(), Instant.now(), discussions, List.of(review), new RadAuthor(UUID.randomUUID().toString()));

return new RadPatch.Revision(id, new RadAuthor(UUID.randomUUID().toString()), description, List.of(), List.of(), base, commit.getId().asString(),
List.of("branch"), Instant.now(), discussions, List.of(review));
}

private RadDiscussion createDiscussion(String id, String authorId, String body, List<Embed> embedList) {
Expand Down

0 comments on commit 2f8e730

Please sign in to comment.