Skip to content

Commit 00fcc47

Browse files
Merge branch 'http-client-java_versioning-non-dpg' of https://github.com/weidongxu-microsoft/typespec into http-client-java_versioning-non-dpg
2 parents 2fe0045 + 7648f09 commit 00fcc47

File tree

1 file changed

+39
-7
lines changed
  • packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned

1 file changed

+39
-7
lines changed

packages/http-client-java/generator/http-client-generator-test/src/test/java/tsptest/armversioned/ArmVersionedTests.java

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,70 @@
33

44
package tsptest.armversioned;
55

6+
import com.azure.core.management.Region;
67
import com.azure.core.util.Context;
78
import org.mockito.Mockito;
89
import tsptest.armversioned.fluent.models.TopLevelArmResourceInner;
10+
import tsptest.armversioned.models.TopLevelArmResource;
911

1012
public class ArmVersionedTests {
1113

1214
// only to test compilation
1315
public void testVersionedApi() {
1416
ArmVersionedManager manager = Mockito.mock(ArmVersionedManager.class);
15-
TopLevelArmResourceInner resource = Mockito.mock(TopLevelArmResourceInner.class);
17+
TopLevelArmResourceInner resourceInner = Mockito.mock(TopLevelArmResourceInner.class);
1618

1719
// API without optional parameter
1820
// this API exists in all versions
19-
manager.serviceClient().getTopLevelArmResources().createOrUpdate("resourceGroup", "resourceName", resource);
2021
manager.topLevelArmResources().list();
22+
2123
manager.topLevelArmResources().action("resourceGroup", "resourceName");
2224

23-
// API in 2024-12-01
2425
manager.serviceClient()
2526
.getTopLevelArmResources()
26-
.createOrUpdate("resourceGroup", "resourceName", resource, "parameter", "newParameter", Context.NONE);
27+
.createOrUpdate("resourceGroup", "resourceName", resourceInner);
28+
TopLevelArmResource resource = manager.topLevelArmResources()
29+
.define("resourceName")
30+
.withRegion(Region.US_WEST3)
31+
.withExistingResourceGroup("resourceGroup")
32+
.create();
33+
34+
resource.update().apply();
35+
36+
// API in 2024-12-01
2737
manager.topLevelArmResources().list("parameter", "newParameter", Context.NONE);
2838
manager.topLevelArmResources()
2939
.actionWithResponse("resourceGroup", "resourceName", "parameter", "newParameter", Context.NONE);
3040

41+
manager.serviceClient()
42+
.getTopLevelArmResources()
43+
.createOrUpdate("resourceGroup", "resourceName", resourceInner, "parameter", "newParameter", Context.NONE);
44+
manager.topLevelArmResources()
45+
.define("resourceName")
46+
.withRegion(Region.US_WEST3)
47+
.withExistingResourceGroup("resourceGroup")
48+
.withParameter("parameter")
49+
.create();
50+
51+
resource.update().withParameter("parameter").apply();
52+
3153
// API in 2023-12-01
3254
// this op will be generated, if tspconfig has "advanced-versioning" option
3355
// REST API allow adding optional parameter to operation
34-
manager.serviceClient()
35-
.getTopLevelArmResources()
36-
.createOrUpdate("resourceGroup", "resourceName", resource, "parameter", Context.NONE);
3756
manager.topLevelArmResources().list("parameter", Context.NONE);
3857
manager.topLevelArmResources().actionWithResponse("resourceGroup", "resourceName", "parameter", Context.NONE);
58+
59+
manager.serviceClient()
60+
.getTopLevelArmResources()
61+
.createOrUpdate("resourceGroup", "resourceName", resourceInner, "parameter", Context.NONE);
62+
manager.topLevelArmResources()
63+
.define("resourceName")
64+
.withRegion(Region.US_WEST3)
65+
.withExistingResourceGroup("resourceGroup")
66+
.withParameter("parameter")
67+
.withNewParameter("newParameter")
68+
.create();
69+
70+
resource.update().withParameter("parameter").withNewParameter("newParameter").apply();
3971
}
4072
}

0 commit comments

Comments
 (0)