Skip to content

Commit

Permalink
refactor: AssertJ best practices
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek and TeamModerne committed Jul 10, 2024
1 parent e7fc8c2 commit 4c7849b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/openrewrite/javascript/Assertions.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static Consumer<SourceSpec<JS.CompilationUnit>> isFullyParsed() {
new JavaScriptIsoVisitor<Integer>() {
@Override
public Space visitSpace(Space space, Space.Location loc, Integer integer) {
assertThat(space.getWhitespace().trim()).isEmpty();
assertThat(space.getWhitespace()).isBlank();
return super.visitSpace(space, loc, integer);
}
}.visit(cu, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.List;
import java.util.Objects;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.assertj.core.api.Assertions.assertThat;

class TypeScriptSignatureBuilderTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.openrewrite.javascript;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.ExpectedToFail;
import org.openrewrite.InMemoryExecutionContext;
Expand Down Expand Up @@ -58,8 +57,8 @@ private String getSourcePath() {
@Test
void className() {
JavaType.FullyQualified clazz = TypeUtils.asFullyQualified(this.firstMethodParameter("clazz"));
Assertions.assertThat(clazz).isNotNull();
Assertions.assertThat(clazz.getFullyQualifiedName()).isEqualTo(getSourcePath() + ".A");
assertThat(clazz).isNotNull();
assertThat(clazz.getFullyQualifiedName()).isEqualTo(getSourcePath() + ".A");
}

@Test
Expand Down Expand Up @@ -209,7 +208,7 @@ JavaType.Method methodType(String methodName) {
.filter(m -> m.getName().equals(methodName))
.findFirst()
.orElseThrow(() -> new IllegalStateException("Expected to find matching method named " + methodName));
Assertions.assertThat(type.getDeclaringType().toString()).isEqualTo("%s.TypeScriptTypeGoat", getSourcePath());
assertThat(type.getDeclaringType().toString()).isEqualTo("%s.TypeScriptTypeGoat", getSourcePath());
return type;
}

Expand All @@ -222,7 +221,7 @@ JavaType.Variable firstField(String fieldName) {
.filter(m -> m.getName().equals(fieldName))
.findFirst()
.orElseThrow(() -> new IllegalStateException("Expected to find matching member named " + fieldName));
Assertions.assertThat(type.getOwner().toString()).isEqualTo("%s.TypeScriptTypeGoat", getSourcePath());
assertThat(type.getOwner().toString()).isEqualTo("%s.TypeScriptTypeGoat", getSourcePath());
return type;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import java.util.function.BiConsumer;
import java.util.function.Function;

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

public class V8InteropTests {
Expand Down Expand Up @@ -126,7 +128,7 @@ public void testTypeIdentityInDifferentFiles() {
assertSame(inOtherFile.get(), type);
}
});
assertTrue(checked.get());
assertThat(checked.get()).isTrue();
}
}

Expand Down

0 comments on commit 4c7849b

Please sign in to comment.