Skip to content

Commit ee29e03

Browse files
committed
a test
1 parent 71e6d5d commit ee29e03

File tree

6 files changed

+44
-6
lines changed

6 files changed

+44
-6
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ dependency-reduced-pom.xml
1616
*avaje-processors.txt
1717
*controllers.txt
1818
tests/test-sigma/io.avaje.jsonb.spi.JsonbExtension
19+
tests/test-sigma/*.txt
1920
tests/test-javalin-jsonb/*.txt
21+
tests/test-nima-jsonb/*.txt

http-generator-core/src/main/java/io/avaje/http/generator/core/BaseProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private void writeClientAdapter(ControllerReader reader) {
189189
if (reader.beanType().getInterfaces().isEmpty()
190190
&& "java.lang.Object".equals(reader.beanType().getSuperclass().toString())) {
191191
new TestClientWriter(reader).write();
192-
clientFQNs.add(reader.beanType().getQualifiedName().toString() + "$TestAPI");
192+
clientFQNs.add(reader.beanType().getQualifiedName().toString() + "TestAPI");
193193
}
194194
} catch (final IOException e) {
195195
logError(reader.beanType(), "Failed to write $Route class " + e);

http-generator-core/src/main/java/io/avaje/http/generator/core/TestClientWriter.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class TestClientWriter {
4646
writer =
4747
new Append(
4848
new FileWriter(
49-
APContext.getBuildResource("testAPI/" + originName + "$TestAPI.txt").toFile()));
49+
APContext.getBuildResource("testAPI/" + originName + "TestAPI.txt").toFile()));
5050
}
5151

5252
protected String initPackageName(String originName) {
@@ -95,7 +95,7 @@ private void writeClassStart() {
9595
writer.append("@Client(\"%s\")", reader.path()).eol();
9696
writer
9797
.append(
98-
"%sinterface %s$TestAPI {",
98+
"%sinterface %sTestAPI {",
9999
reader.beanType().getModifiers().contains(Modifier.PUBLIC) ? "public " : "", shortName)
100100
.eol()
101101
.eol();
@@ -118,8 +118,7 @@ private void writeRoute(MethodReader method) {
118118

119119
TypeMirror returnType = method.returnType();
120120
var isJstache = ProcessingContext.isJstacheTemplate(returnType);
121-
writer.append(" ");
122-
AnnotationCopier.copyAnnotations(writer, method.element(), true);
121+
AnnotationCopier.copyAnnotations(writer, method.element(), " ", true);
123122

124123
var returnTypeStr = PrimitiveUtil.wrap(UType.parse(returnType).shortType());
125124

tests/test-jex/pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@
9696
<scope>test</scope>
9797
</dependency>
9898

99+
<dependency>
100+
<groupId>io.avaje</groupId>
101+
<artifactId>avaje-http-jex-generator</artifactId>
102+
<version>${project.version}</version>
103+
</dependency>
104+
105+
<dependency>
106+
<groupId>io.avaje</groupId>
107+
<artifactId>avaje-http-client-generator</artifactId>
108+
<version>${project.version}</version>
109+
</dependency>
99110
</dependencies>
100111

101112
<build>
@@ -121,6 +132,11 @@
121132
<artifactId>avaje-http-jex-generator</artifactId>
122133
<version>${project.version}</version>
123134
</path>
135+
<path>
136+
<groupId>io.avaje</groupId>
137+
<artifactId>avaje-http-client-generator</artifactId>
138+
<version>${project.version}</version>
139+
</path>
124140
<path>
125141
<groupId>io.avaje</groupId>
126142
<artifactId>avaje-jsonb-generator</artifactId>

tests/test-jex/src/test/java/org/example/web/HelloControllerTest.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@Import(Violation.class)
1717
class HelloControllerTest extends BaseWebTest {
1818

19-
final static HttpClient client = client();
19+
static final HttpClient client = client();
2020

2121
@Test
2222
void getHello() {
@@ -26,8 +26,24 @@ void getHello() {
2626
assertEquals("rob", hello.name);
2727
}
2828

29+
@Test
30+
void getHelloClient() {
31+
final HelloDto hello = client.create(HelloControllerTestAPI.class).getHello().body();
32+
33+
assertEquals(42, hello.id);
34+
assertEquals("rob", hello.name);
35+
}
36+
2937
@Test
3038
void getPlain() {
39+
final HttpResponse<String> res = client.create(HelloControllerTestAPI.class).getText();
40+
41+
assertEquals("something", res.body());
42+
assertThat(res.headers().firstValue("content-type").orElseThrow()).startsWith("text/plain;");
43+
}
44+
45+
@Test
46+
void getPlainClient() {
3147
final HttpResponse<String> res = client.request().path("plain").GET().asString();
3248

3349
assertEquals("something", res.body());

tests/test-nima/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
<artifactId>helidon-http-media-jsonb</artifactId>
4444
<version>${helidon.version}</version>
4545
</dependency>
46+
<dependency>
47+
<groupId>io.avaje</groupId>
48+
<artifactId>avaje-http-helidon-generator</artifactId>
49+
<version>${project.version}</version>
50+
</dependency>
4651
</dependencies>
4752

4853
<build>

0 commit comments

Comments
 (0)