-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for JsonBUtil.writeType()
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
http-generator-core/src/test/java/io/avaje/http/generator/core/JsonBUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.avaje.http.generator.core; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.StringWriter; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class JsonBUtilTest { | ||
|
||
@Test | ||
void writeType() { | ||
UType uType = UType.parse("my.pack.Foo"); | ||
var sw = new StringWriter(); | ||
JsonBUtil.writeType(uType, new Append(sw)); | ||
|
||
assertThat(sw.toString()).isEqualTo("Foo.class)"); | ||
} | ||
|
||
@Test | ||
void writeType_generic() { | ||
UType uType = UType.parse("my.pack.Some<java.lang.String>"); | ||
var sw = new StringWriter(); | ||
JsonBUtil.writeType(uType, new Append(sw)); | ||
|
||
assertThat(sw.toString()).isEqualTo("Types.newParameterizedType(Some.class, String.class))"); | ||
} | ||
|
||
@Test | ||
void writeType_genericWithWildcard() { | ||
UType uType = UType.parse("my.pack.Some<java.lang.String, ?>"); | ||
var sw = new StringWriter(); | ||
JsonBUtil.writeType(uType, new Append(sw)); | ||
|
||
assertThat(sw.toString()).isEqualTo("Types.newParameterizedType(Some.class, String.class, Object.class))"); | ||
} | ||
|
||
@Test | ||
void writeType_genericWithMultiple() { | ||
UType uType = UType.parse("my.pack.Some<java.lang.String, my.other.Foo>"); | ||
var sw = new StringWriter(); | ||
JsonBUtil.writeType(uType, new Append(sw)); | ||
|
||
assertThat(sw.toString()).isEqualTo("Types.newParameterizedType(Some.class, String.class, Foo.class))"); | ||
} | ||
} |