Skip to content

Commit 0e561ac

Browse files
Add e2e tests for putFlattenReadOnlyModel, putFlattenUnknownModel, and withRelativeNextLink (#10361)
- [x] Add `testPageWithRelativeNextLink` test to `PageTests.java` - [x] Add changelog entry for `@typespec/http-client-java` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com> Co-authored-by: Weidong Xu <weidxu@microsoft.com>
1 parent 622804c commit 0e561ac

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
3+
changeKind: feature
4+
packages:
5+
- "@typespec/http-client-java"
6+
---
7+
8+
Add test case for `withRelativeNextLink`, `FlattenUnknownModel`, `FlattenReadOnlyModel` scenario.

packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/clientgenerator/core/flattenproperty/FlattenClientTests.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
import azure.clientgenerator.core.flattenproperty.models.ChildFlattenModel;
77
import azure.clientgenerator.core.flattenproperty.models.ChildModel;
88
import azure.clientgenerator.core.flattenproperty.models.FlattenModel;
9+
import azure.clientgenerator.core.flattenproperty.models.FlattenUnknownModel;
910
import azure.clientgenerator.core.flattenproperty.models.NestedFlattenModel;
11+
import azure.clientgenerator.core.flattenproperty.models.Solution;
12+
import azure.clientgenerator.core.flattenproperty.models.SolutionProperties;
13+
import org.junit.jupiter.api.Assertions;
1014
import org.junit.jupiter.api.Test;
1115

1216
public class FlattenClientTests {
@@ -19,4 +23,24 @@ public void testFlattenModel() {
1923
flattenClient.putNestedFlattenModel(
2024
new NestedFlattenModel("foo", new ChildFlattenModel("bar", new ChildModel("test", 10))));
2125
}
26+
27+
@Test
28+
public void testPutFlattenUnknownModel() {
29+
// flatten is ignored for unknown (non-model) type properties
30+
FlattenUnknownModel result = flattenClient.putFlattenUnknownModel(new FlattenUnknownModel("foo"));
31+
Assertions.assertEquals("test", result.getName());
32+
Assertions.assertNotNull(result.getProperties());
33+
}
34+
35+
@Test
36+
public void testPutFlattenReadOnlyModel() {
37+
// flatten with all read-only properties; input only contains writable fields
38+
Solution result = flattenClient.putFlattenReadOnlyModel(new Solution("foo"));
39+
Assertions.assertEquals("foo", result.getName());
40+
SolutionProperties properties = result.getProperties();
41+
Assertions.assertNotNull(properties);
42+
Assertions.assertEquals("solution1", properties.getSolutionId());
43+
Assertions.assertEquals("Solution Title", properties.getTitle());
44+
Assertions.assertEquals("Solution Content", properties.getContent());
45+
}
2246
}

packages/http-client-java/generator/http-client-generator-test/src/test/java/azure/core/page/PageTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,9 @@ public void testPageRequestBody() {
4747
public void testPageNextLinkReInjectedParameters() {
4848
Assertions.assertEquals(2, client.withParameterizedNextLink("name", true).stream().count());
4949
}
50+
51+
@Test
52+
public void testPageWithRelativeNextLink() {
53+
Assertions.assertEquals(2, client.withRelativeNextLink().stream().count());
54+
}
5055
}

0 commit comments

Comments
 (0)