Skip to content
This repository was archived by the owner on Aug 11, 2025. It is now read-only.
Open
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
24 changes: 8 additions & 16 deletions src/test/java/com/squareup/javapoet/JavaFileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,14 @@ private TypeSpec importStaticTypeSpec(String name) {
+ "}\n");
}

@Test
public void recordNoField() {
@Test public void recordNoField() {
String source = JavaFile.builder("com.squareup.tacos", TypeSpec.recordBuilder("Taco").build())
.skipJavaLangImports(true).build().toString();
assertThat(source).isEqualTo(
"" + "package com.squareup.tacos;\n" + "\n" + "record Taco() {\n" + "}\n" + "");
}

@Test
public void recordTwoField() {
@Test public void recordTwoField() {
String source = JavaFile
.builder("com.squareup.tacos",
TypeSpec.recordBuilder("Taco")
Expand All @@ -305,8 +303,7 @@ public void recordTwoField() {
+ "record Taco(String name, Integer code) {\n" + "}\n" + "");
}

@Test
public void recordTwoAnnotatedFields() {
@Test public void recordTwoAnnotatedFields() {
AnnotationSpec annotationSpec = AnnotationSpec.builder(ClassName.get("com.squareup.tacos", "Spicy")).build();
String source = JavaFile
.builder("com.squareup.tacos",
Expand Down Expand Up @@ -930,8 +927,7 @@ private TypeSpec.Builder childTypeBuilder() {
.build());
}

@Test
public void avoidClashes_parentChild_superclass_type() {
@Test public void avoidClashes_parentChild_superclass_type() {
String source = JavaFile.builder("com.squareup.javapoet",
childTypeBuilder().superclass(Parent.class).build())
.build()
Expand All @@ -951,8 +947,7 @@ public void avoidClashes_parentChild_superclass_type() {
+ "}\n");
}

@Test
public void avoidClashes_parentChild_superclass_typeMirror() {
@Test public void avoidClashes_parentChild_superclass_typeMirror() {
String source = JavaFile.builder("com.squareup.javapoet",
childTypeBuilder().superclass(getElement(Parent.class).asType()).build())
.build()
Expand All @@ -972,8 +967,7 @@ public void avoidClashes_parentChild_superclass_typeMirror() {
+ "}\n");
}

@Test
public void avoidClashes_parentChild_superinterface_type() {
@Test public void avoidClashes_parentChild_superinterface_type() {
String source = JavaFile.builder("com.squareup.javapoet",
childTypeBuilder().addSuperinterface(ParentInterface.class).build())
.build()
Expand All @@ -994,8 +988,7 @@ public void avoidClashes_parentChild_superinterface_type() {
+ "}\n");
}

@Test
public void avoidClashes_parentChild_superinterface_typeMirror() {
@Test public void avoidClashes_parentChild_superinterface_typeMirror() {
String source = JavaFile.builder("com.squareup.javapoet",
childTypeBuilder().addSuperinterface(getElement(ParentInterface.class).asType()).build())
.build()
Expand Down Expand Up @@ -1031,8 +1024,7 @@ class Optional {
}

// Regression test for case raised here: https://github.com/square/javapoet/issues/77#issuecomment-519972404
@Test
public void avoidClashes_mapEntry() {
@Test public void avoidClashes_mapEntry() {
String source = JavaFile.builder("com.squareup.javapoet",
TypeSpec.classBuilder("MapType")
.addMethod(MethodSpec.methodBuilder("optionalString")
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/squareup/javapoet/MethodSpecTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ abstract static class AbstractClassWithPrivateAnnotation {
"}\n");
}

private static CodeBlock named(String format, Map<String, ?> args){
private static CodeBlock named(String format, Map<String, ?> args) {
return CodeBlock.builder().addNamed(format, args).build();
}

Expand Down