File tree Expand file tree Collapse file tree 5 files changed +66
-8
lines changed
main/java/dev/restate/sdk/gen
test/java/dev/restate/sdk
sdk-http-vertx/src/test/kotlin/dev/restate/sdk/http/vertx Expand file tree Collapse file tree 5 files changed +66
-8
lines changed Original file line number Diff line number Diff line change @@ -90,12 +90,9 @@ public Component fromTypeElement(TypeElement element) {
90
90
? virtualObjectAnnotation .name ()
91
91
: workflowAnnotation .name ();
92
92
if (componentName .isEmpty ()) {
93
- // Use FQCN
94
- // With this logic we make sure we flatten subclasses names
95
- String simpleComponentName =
96
- targetFqcn .toString ().substring (targetPkg .length ()).replaceAll (Pattern .quote ("." ), "" );
93
+ // Use simple class name, flattening subclasses names
97
94
componentName =
98
- targetPkg .length () > 0 ? targetPkg + "." + simpleComponentName : simpleComponentName ;
95
+ targetFqcn . toString (). substring ( targetPkg .length ()). replaceAll ( Pattern . quote ( "." ), "" ) ;
99
96
}
100
97
101
98
// Compute handlers
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2023 - Restate Software, Inc., Restate GmbH
2
+ //
3
+ // This file is part of the Restate Java SDK,
4
+ // which is released under the MIT license.
5
+ //
6
+ // You can find a copy of the license in file LICENSE in the root
7
+ // directory of this repository or package, or at
8
+ // https://github.com/restatedev/sdk-java/blob/main/LICENSE
9
+ package dev .restate .sdk ;
10
+
11
+ import dev .restate .sdk .annotation .Handler ;
12
+ import dev .restate .sdk .annotation .Service ;
13
+
14
+ @ Service (name = "MyExplicitName" )
15
+ public interface GreeterWithExplicitName {
16
+ @ Handler
17
+ String greet (Context context , String request );
18
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2023 - Restate Software, Inc., Restate GmbH
2
+ //
3
+ // This file is part of the Restate Java SDK,
4
+ // which is released under the MIT license.
5
+ //
6
+ // You can find a copy of the license in file LICENSE in the root
7
+ // directory of this repository or package, or at
8
+ // https://github.com/restatedev/sdk-java/blob/main/LICENSE
9
+ package dev .restate .sdk ;
10
+
11
+ import dev .restate .sdk .annotation .Handler ;
12
+ import dev .restate .sdk .annotation .Service ;
13
+
14
+ @ Service
15
+ public interface GreeterWithoutExplicitName {
16
+ @ Handler
17
+ String greet (Context context , String request );
18
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2023 - Restate Software, Inc., Restate GmbH
2
+ //
3
+ // This file is part of the Restate Java SDK,
4
+ // which is released under the MIT license.
5
+ //
6
+ // You can find a copy of the license in file LICENSE in the root
7
+ // directory of this repository or package, or at
8
+ // https://github.com/restatedev/sdk-java/blob/main/LICENSE
9
+ package dev .restate .sdk ;
10
+
11
+ import static org .assertj .core .api .Assertions .assertThat ;
12
+
13
+ import org .junit .jupiter .api .Test ;
14
+
15
+ public class NameInferenceTest {
16
+
17
+ @ Test
18
+ void expectedName () {
19
+ assertThat (CodegenTestServiceGreeterClient .COMPONENT_NAME )
20
+ .isEqualTo ("CodegenTestServiceGreeter" );
21
+ assertThat (GreeterWithoutExplicitNameClient .COMPONENT_NAME )
22
+ .isEqualTo ("GreeterWithoutExplicitName" );
23
+ assertThat (MyExplicitNameClient .COMPONENT_NAME ).isEqualTo ("MyExplicitName" );
24
+ }
25
+ }
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ internal class RestateHttpEndpointTest {
56
56
@Timeout(value = 1 , timeUnit = TimeUnit .SECONDS )
57
57
@Test
58
58
fun endpointWithBlockingService (vertx : Vertx ): Unit =
59
- greetTest(vertx, BlockingGreeter ::class .qualifiedName !! ) { it.with (BlockingGreeter ()) }
59
+ greetTest(vertx, BlockingGreeter ::class .simpleName !! ) { it.with (BlockingGreeter ()) }
60
60
61
61
private fun greetTest (
62
62
vertx : Vertx ,
@@ -169,7 +169,7 @@ internal class RestateHttpEndpointTest {
169
169
HttpMethod .POST ,
170
170
endpointPort,
171
171
" localhost" ,
172
- " /invoke/" + BlockingGreeter ::class .java.canonicalName + " /unknownMethod" )
172
+ " /invoke/" + BlockingGreeter ::class .java.simpleName + " /unknownMethod" )
173
173
.coAwait()
174
174
175
175
// Prepare request header
@@ -218,7 +218,7 @@ internal class RestateHttpEndpointTest {
218
218
219
219
assertThat(discoveryResponse.components)
220
220
.map<String > { it.fullyQualifiedComponentName }
221
- .containsOnly(BlockingGreeter ::class .java.canonicalName )
221
+ .containsOnly(BlockingGreeter ::class .java.simpleName )
222
222
}
223
223
224
224
fun encode (msg : MessageLite ): Buffer {
You can’t perform that action at this time.
0 commit comments