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

refactor: AssertJ best practices #61

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.Set;
import java.util.stream.Collectors;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;

class ExternalFlowModelsTest {
@Test
Expand All @@ -45,8 +45,8 @@ void listFlowModelsOptimized() {
taint = taint.stream().filter(ExternalFlowModelsTest::filterModels).collect(Collectors.toSet());

// Ensure that there are no unchecked values
assertEquals(0, value.size(), "All value models should be optimized");
assertEquals(0, taint.size(), "All taint models should be optimized");
assertThat(value.size()).as("All value models should be optimized").isEqualTo(0);
assertThat(taint.size()).as("All taint models should be optimized").isEqualTo(0);
}

static boolean filterModels(ExternalFlowModels.FlowModel model) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.HashSet;
import java.util.Set;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;

class ExternalSinkModelsTest {

Expand All @@ -37,7 +37,7 @@ void listSinkModelsOptimized() {
// Remove all optimized sink flow models
models.removeAll(optimizedModels.getSinkModels());

assertEquals(0, models.size(), "All sink models should be optimized");
assertThat(models.size()).as("All sink models should be optimized").isEqualTo(0);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.openrewrite.test.RewriteTest;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.openrewrite.java.Assertions.java;

class CursorUtilTest implements RewriteTest {
Expand All @@ -35,7 +34,7 @@ private static final class FindCursorForTreeTestVisitor extends JavaVisitor<Exec
public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext executionContext) {
Option<Cursor> found = CursorUtil.findCursorForTree(getCursor(), method.getArguments().get(0));

assertTrue(found.isSome(), "Cursor for the sub-tree tree not found");
assertThat(found.isSome()).as("Cursor for the sub-tree tree not found").isTrue();
assertThat(found.some().<J>getValue()).isEqualTo(method.getArguments().get(0));
assertThat(found.some().dropParentUntil(J.MethodInvocation.class::isInstance).<J>getValue()).isEqualTo(method);
assertThat(found.some().dropParentUntil(J.CompilationUnit.class::isInstance)).isNotNull();
Expand Down
Loading