|
3 | 3 |
|
4 | 4 | package tsptest.armversioned; |
5 | 5 |
|
| 6 | +import com.azure.core.management.Region; |
6 | 7 | import com.azure.core.util.Context; |
7 | 8 | import org.mockito.Mockito; |
8 | 9 | import tsptest.armversioned.fluent.models.TopLevelArmResourceInner; |
| 10 | +import tsptest.armversioned.models.TopLevelArmResource; |
9 | 11 |
|
10 | 12 | public class ArmVersionedTests { |
11 | 13 |
|
12 | 14 | // only to test compilation |
13 | 15 | public void testVersionedApi() { |
14 | 16 | ArmVersionedManager manager = Mockito.mock(ArmVersionedManager.class); |
15 | | - TopLevelArmResourceInner resource = Mockito.mock(TopLevelArmResourceInner.class); |
| 17 | + TopLevelArmResourceInner resourceInner = Mockito.mock(TopLevelArmResourceInner.class); |
16 | 18 |
|
17 | 19 | // API without optional parameter |
18 | 20 | // this API exists in all versions |
19 | | - manager.serviceClient().getTopLevelArmResources().createOrUpdate("resourceGroup", "resourceName", resource); |
20 | 21 | manager.topLevelArmResources().list(); |
| 22 | + |
21 | 23 | manager.topLevelArmResources().action("resourceGroup", "resourceName"); |
22 | 24 |
|
23 | | - // API in 2024-12-01 |
24 | 25 | manager.serviceClient() |
25 | 26 | .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 |
27 | 37 | manager.topLevelArmResources().list("parameter", "newParameter", Context.NONE); |
28 | 38 | manager.topLevelArmResources() |
29 | 39 | .actionWithResponse("resourceGroup", "resourceName", "parameter", "newParameter", Context.NONE); |
30 | 40 |
|
| 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 | + |
31 | 53 | // API in 2023-12-01 |
32 | 54 | // this op will be generated, if tspconfig has "advanced-versioning" option |
33 | 55 | // REST API allow adding optional parameter to operation |
34 | | - manager.serviceClient() |
35 | | - .getTopLevelArmResources() |
36 | | - .createOrUpdate("resourceGroup", "resourceName", resource, "parameter", Context.NONE); |
37 | 56 | manager.topLevelArmResources().list("parameter", Context.NONE); |
38 | 57 | 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(); |
39 | 71 | } |
40 | 72 | } |
0 commit comments