-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Process Iterable same way as Collection type (#9709)
* Process Iterable same way as Collection type Fixes #9256 * add missed file * Move IterableEndpoint fixture and test into their own package The endpoint generator testing setup requires a separate package for each test to avoid interference between tests. This is because the generator in the tests emits all classes per package. * Fix IterableEndpointGenerationTest Co-authored-by: Nikolai Gorokhov <nikolai@vaadin.com> Co-authored-by: Anton Platonov <platosha@gmail.com>
- Loading branch information
1 parent
c58d5f1
commit eeffced
Showing
7 changed files
with
165 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
35 changes: 35 additions & 0 deletions
35
...com/vaadin/flow/server/connect/generator/endpoints/iterableendpoint/IterableEndpoint.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,35 @@ | ||
/* | ||
* Copyright 2000-2021 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package com.vaadin.flow.server.connect.generator.endpoints.iterableendpoint; | ||
|
||
import java.util.Arrays; | ||
|
||
import com.vaadin.flow.server.connect.Endpoint; | ||
import com.vaadin.flow.server.connect.auth.AnonymousAllowed; | ||
|
||
@Endpoint | ||
@AnonymousAllowed | ||
public class IterableEndpoint { | ||
|
||
public static class Foo { | ||
public String bar = "bar"; | ||
} | ||
|
||
public Iterable<Foo> getFoos() { | ||
return Arrays.asList(new Foo(), new Foo()); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...w/server/connect/generator/endpoints/iterableendpoint/IterableEndpointGenerationTest.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,39 @@ | ||
/* | ||
* Copyright 2000-2021 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package com.vaadin.flow.server.connect.generator.endpoints.iterableendpoint; | ||
|
||
import com.vaadin.flow.server.connect.generator.endpoints.AbstractEndpointGenerationTest; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.Collections; | ||
|
||
/** | ||
* com.vaadin.flow.server.connect.generator.endpoints.iterableendpoint.IterableEndpointGenerationTest, created on 21/12/2020 23.00 | ||
* @author nikolaigorokhov | ||
*/ | ||
public class IterableEndpointGenerationTest extends AbstractEndpointGenerationTest { | ||
|
||
public IterableEndpointGenerationTest() { | ||
super(Collections.singletonList(IterableEndpoint.class)); | ||
} | ||
|
||
@Test | ||
public void should_ConvertIterableIntoArrayInTS() { | ||
verifyOpenApiObjectAndGeneratedTs(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...din/flow/server/connect/generator/endpoints/iterableendpoint/expected-IterableEndpoint.ts
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,18 @@ | ||
/** | ||
* This module is generated from IterableEndpoint.java | ||
* All changes to this file are overridden. Please consider to make changes in the corresponding Java file if necessary. | ||
* @module IterableEndpoint | ||
*/ | ||
|
||
// @ts-ignore | ||
import client from './connect-client.default'; | ||
import Foo from './com/vaadin/flow/server/connect/generator/endpoints/iterableendpoint/IterableEndpoint/Foo'; | ||
|
||
function _getFoos(): Promise<Array<Foo>> { | ||
return client.call('IterableEndpoint', 'getFoos'); | ||
} | ||
export {_getFoos as getFoos}; | ||
|
||
export const IterableEndpoint = Object.freeze({ | ||
getFoos: _getFoos, | ||
}); |
8 changes: 8 additions & 0 deletions
8
...erator/endpoints/iterableendpoint/expected-model-iterableendpoint.IterableEndpoint.Foo.ts
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,8 @@ | ||
/** | ||
* This module is generated from com.vaadin.flow.server.connect.generator.endpoints.iterableendpoint.IterableEndpoint.Foo. | ||
* All changes to this file are overridden. Please consider to make changes in the corresponding Java file if necessary. | ||
*/ | ||
|
||
export default interface Foo { | ||
bar: string; | ||
} |