Skip to content

Commit 1f44c70

Browse files
eng, sync 7470 (#3118)
1 parent 9fee24d commit 1f44c70

162 files changed

Lines changed: 255 additions & 430 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ typespec-tests/package-lock.json
102102

103103
# ApiView properties files
104104
/typespec-tests/src/main/resources/META-INF/*apiview_properties.json
105+
/typespec-tests/src/main/resources/META-INF/*metadata.json
105106

106107
# typespec-extension
107108
/typespec-extension/src/*

core

Submodule core updated 107 files

fluent-tests/Initialize-Tests.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ $job = @(
125125
"--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false https://raw.githubusercontent.com/Azure/azure-rest-api-specs/da0cfefaa0e6c237e1e3819f1cb2e11d7606878d/specification/storage/resource-manager/readme.md --tag=package-2021-01 --java.namespace=com.azure.mgmtlitetest.storage",
126126
"--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/advisor/resource-manager/readme.md --tag=package-2020-01 --java.namespace=com.azure.mgmtlitetest.advisor",
127127

128-
# pageable + LRO
129-
"--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/mediaservices/resource-manager/readme.md --tag=package-account-2023-01 --java.namespace=com.azure.mgmtlitetest.mediaservices",
130128
"--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/resources/resource-manager/readme.md --tag=package-policy-2020-09 --java.namespace=com.azure.mgmtlitetest.policy",
131129
# UUID subscriptionId
132130
"--version=$AUTOREST_CORE_VERSION $FLUENTLITE_ARGUMENTS --regenerate-pom=false --input-file=https://raw.githubusercontent.com/Azure/azure-rest-api-specs/0a2eb0d14f5132fcfd30222d584acf67713332ea/specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/containerregistry.json --namespace=com.azure.mgmtlitetest.containerregistrylite",

fluent-tests/src/test/java/com/azure/mgmttest/LiteCompilationTests.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
import com.azure.mgmtlitetest.containerregistrylite.ContainerRegistryManager;
2020
import com.azure.mgmtlitetest.emptybytearrayinclients.implementation.DpsCertificatesClientImpl;
2121
import com.azure.mgmtlitetest.managednetworkfabric.models.CommonPostActionResponseForStateUpdate;
22-
import com.azure.mgmtlitetest.mediaservices.MediaServicesManager;
23-
import com.azure.mgmtlitetest.mediaservices.models.LiveEventStatus;
24-
import com.azure.mgmtlitetest.mediaservices.models.MediaService;
25-
import com.azure.mgmtlitetest.mediaservices.models.SyncStorageKeysInput;
2622
import com.azure.mgmtlitetest.pageablewithinheritance.fluent.SavingsPlansClient;
2723
import com.azure.mgmtlitetest.pageablewithinheritance.fluent.models.SavingsPlanModelInner;
2824
import com.azure.mgmtlitetest.resources.ResourceManager;
@@ -153,13 +149,6 @@ public void testConfigurable() {
153149
.authenticate(new EnvironmentCredentialBuilder().build(), new AzureProfile(AzureEnvironment.AZURE));
154150
}
155151

156-
public void testMediaServices() {
157-
MediaServicesManager mediaServicesManager = mock(MediaServicesManager.class);
158-
159-
MediaService mediaService = mediaServicesManager.mediaservices().getById(anyString());
160-
mediaService.syncStorageKeys(any(SyncStorageKeysInput.class));
161-
}
162-
163152
public void testModelFlatten() {
164153
ExtendedProductInner extendedProduct = new ExtendedProductInner();
165154
extendedProduct.uri();
@@ -194,11 +183,6 @@ public void testSubscriptionIdUuid() {
194183
String subscriptionId = manager.serviceClient().getSubscriptionId();
195184
}
196185

197-
public void testLroPageable() {
198-
MediaServicesManager manager = mock(MediaServicesManager.class);
199-
PagedIterable<LiveEventStatus> eventStatuses = manager.liveEvents().listGetStatus(anyString(), anyString(), anyString());
200-
}
201-
202186
public void testModelExtendsErrorResponse() {
203187
CommonPostActionResponseForStateUpdate actionResponse = mock(CommonPostActionResponseForStateUpdate.class);
204188
ManagementError error = actionResponse.error();

fluent-tests/src/test/java/com/azure/mgmttest/RuntimeTests.java

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import com.azure.core.http.rest.PagedIterable;
1515
import com.azure.core.management.AzureEnvironment;
1616
import com.azure.core.management.Region;
17-
import com.azure.core.management.ResourceAuthorIdentityType;
1817
import com.azure.core.management.exception.ManagementError;
1918
import com.azure.core.management.exception.ManagementException;
2019
import com.azure.core.management.http.policy.ArmChallengeAuthenticationPolicy;
@@ -32,9 +31,6 @@
3231
import com.azure.mgmtlitetest.botservice.models.Site;
3332
import com.azure.mgmtlitetest.managednetworkfabric.fluent.models.CommonPostActionResponseForDeviceUpdateInner;
3433
import com.azure.mgmtlitetest.managednetworkfabric.models.ConfigurationState;
35-
import com.azure.mgmtlitetest.mediaservices.MediaServicesManager;
36-
import com.azure.mgmtlitetest.mediaservices.models.MediaService;
37-
import com.azure.mgmtlitetest.mediaservices.models.StorageAccountType;
3834
import com.azure.mgmtlitetest.resources.ResourceManager;
3935
import com.azure.mgmtlitetest.resources.fluent.models.GenericResourceInner;
4036
import com.azure.mgmtlitetest.resources.models.ResourceGroup;
@@ -81,7 +77,6 @@
8177
import java.lang.reflect.Modifier;
8278
import java.nio.file.Files;
8379
import java.util.Arrays;
84-
import java.util.Collections;
8580
import java.util.HashMap;
8681
import java.util.List;
8782
import java.util.Map;
@@ -295,9 +290,6 @@ public void testStorage() {
295290
Assertions.assertTrue(blobService.deleteRetentionPolicy().enabled());
296291
Assertions.assertEquals(3, blobService.deleteRetentionPolicy().days());
297292

298-
// test media services for SystemData
299-
testMediaServices(storageAccount);
300-
301293
// test advisor as it is an extension, which requires a base resource
302294
// disabled as generate is async and it takes too long for a new resource
303295
//testAdvisor(storageAccount);
@@ -308,29 +300,6 @@ public void testStorage() {
308300
}
309301
}
310302

311-
private void testMediaServices(StorageAccount storageAccount) {
312-
MediaServicesManager mediaservicesManager = authenticateMediaServicesManager();
313-
314-
String rgName = "rg1-weidxu-fluentlite";
315-
String msName = "ms1weidxulite";
316-
317-
MediaService mediaService = mediaservicesManager.mediaservices().define(msName)
318-
.withRegion(Region.US_EAST)
319-
.withExistingResourceGroup(rgName)
320-
.withStorageAccounts(Collections.singletonList(
321-
new com.azure.mgmtlitetest.mediaservices.models.StorageAccount()
322-
.withId(storageAccount.id())
323-
.withType(StorageAccountType.PRIMARY)))
324-
.create();
325-
326-
Assertions.assertNotNull(mediaService.systemData());
327-
Assertions.assertNotNull(mediaService.systemData().createdBy());
328-
Assertions.assertNotNull(mediaService.systemData().createdAt());
329-
Assertions.assertEquals(ResourceAuthorIdentityType.APPLICATION, mediaService.systemData().createdByType());
330-
331-
mediaservicesManager.mediaservices().deleteById(mediaService.id());
332-
}
333-
334303
private void testAdvisor(StorageAccount storageAccount) {
335304
AdvisorManager advisorManager = authenticateAdvisorManager();
336305

@@ -408,12 +377,6 @@ private AdvisorManager authenticateAdvisorManager() {
408377
.authenticate(new EnvironmentCredentialBuilder().build(), new AzureProfile(AzureEnvironment.AZURE));
409378
}
410379

411-
private MediaServicesManager authenticateMediaServicesManager() {
412-
return MediaServicesManager.configure()
413-
.withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
414-
.authenticate(new EnvironmentCredentialBuilder().build(), new AzureProfile(AzureEnvironment.AZURE));
415-
}
416-
417380
@Test
418381
public void testOverload() {
419382
// simple API

typespec-tests/Generate.ps1

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ $generateScript = {
6565
} elseif ($tspFile -match "arm.tsp") {
6666
# for mgmt, do not generate tests due to random mock values
6767
$tspOptions += " --option ""@azure-tools/typespec-java.generate-tests=false"""
68+
# test service-name
69+
$tspOptions += " --option ""@azure-tools/typespec-java.service-name=Arm Resource Provider"""
6870
# also test generating from specific api-version
6971
$tspOptions += " --option ""@azure-tools/typespec-java.api-version=2023-11-01"""
7072
# exclude preview from service versions
@@ -74,10 +76,12 @@ $generateScript = {
7476
} elseif ($tspFile -match "arm-stream-style-serialization.tsp") {
7577
# for mgmt, do not generate tests due to random mock values
7678
$tspOptions += " --option ""@azure-tools/typespec-java.generate-tests=false"""
79+
# test service-name
80+
$tspOptions += " --option ""@azure-tools/typespec-java.service-name=Arm Resource Provider"""
7781
} elseif ($tspFile -match "subclient.tsp") {
7882
$tspOptions += " --option ""@azure-tools/typespec-java.enable-subclient=true"""
7983
# test for include-api-view-properties
80-
$tspOptions += " --option ""@typespec/http-client-java.include-api-view-properties=false"""
84+
$tspOptions += " --option ""@azure-tools/typespec-java.include-api-view-properties=false"""
8185
}
8286

8387
# Test customization for one of the TypeSpec definitions - naming.tsp
@@ -89,25 +93,27 @@ $generateScript = {
8993
$tspTrace = "--trace import-resolution --trace projection --trace typespec-java"
9094
$tspCommand = "npx --no-install tsp compile $tspFile $tspOptions $tspTrace"
9195

96+
# output of "tsp compile" seems trigger powershell error or exit, hence the "2>&1"
9297
$timer = [Diagnostics.Stopwatch]::StartNew()
93-
Invoke-Expression $tspCommand >$null 2>&1
98+
$generateOutput = Invoke-Expression $tspCommand 2>&1
9499
$timer.Stop()
95100

96101
$global:ExitCode = $global:ExitCode -bor $LASTEXITCODE
97102

98103
if ($LASTEXITCODE -ne 0) {
99104
Write-Host "
100-
========================
101-
$tspCommand
102-
========================
103-
FAILED (Time elapsed: $($timer.ToString()))
105+
========================
106+
$tspCommand
107+
========================
108+
FAILED (Time elapsed: $($timer.ToString()))
109+
$([String]::Join("`n", $generateOutput))
104110
"
105111
} else {
106112
Write-Host "
107-
========================
108-
$tspCommand
109-
========================
110-
SUCCEEDED (Time elapsed: $($timer.ToString()))
113+
========================
114+
$tspCommand
115+
========================
116+
SUCCEEDED (Time elapsed: $($timer.ToString()))
111117
"
112118
}
113119

typespec-tests/src/main/java/tsptest/armresourceprovider/ArmResourceProviderManager.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
import java.util.Map;
3232
import java.util.Objects;
3333
import java.util.stream.Collectors;
34-
import tsptest.armresourceprovider.fluent.ArmResourceProviderClient;
35-
import tsptest.armresourceprovider.implementation.ArmResourceProviderClientBuilder;
34+
import tsptest.armresourceprovider.fluent.ArmClient;
35+
import tsptest.armresourceprovider.implementation.ArmClientBuilder;
3636
import tsptest.armresourceprovider.implementation.ChildExtensionResourceInterfacesImpl;
3737
import tsptest.armresourceprovider.implementation.ChildResourcesInterfacesImpl;
3838
import tsptest.armresourceprovider.implementation.CustomTemplateResourceInterfacesImpl;
@@ -67,24 +67,24 @@ public final class ArmResourceProviderManager {
6767

6868
private ModelInterfaceSameNames modelInterfaceSameNames;
6969

70-
private final ArmResourceProviderClient clientObject;
70+
private final ArmClient clientObject;
7171

7272
private ArmResourceProviderManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) {
7373
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
7474
Objects.requireNonNull(profile, "'profile' cannot be null.");
75-
this.clientObject = new ArmResourceProviderClientBuilder().pipeline(httpPipeline)
75+
this.clientObject = new ArmClientBuilder().pipeline(httpPipeline)
7676
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
7777
.subscriptionId(profile.getSubscriptionId())
7878
.defaultPollInterval(defaultPollInterval)
7979
.buildClient();
8080
}
8181

8282
/**
83-
* Creates an instance of ArmResourceProvider service API entry point.
83+
* Creates an instance of Arm Resource Provider service API entry point.
8484
*
8585
* @param credential the credential to use.
8686
* @param profile the Azure profile for client.
87-
* @return the ArmResourceProvider service API instance.
87+
* @return the Arm Resource Provider service API instance.
8888
*/
8989
public static ArmResourceProviderManager authenticate(TokenCredential credential, AzureProfile profile) {
9090
Objects.requireNonNull(credential, "'credential' cannot be null.");
@@ -93,11 +93,11 @@ public static ArmResourceProviderManager authenticate(TokenCredential credential
9393
}
9494

9595
/**
96-
* Creates an instance of ArmResourceProvider service API entry point.
96+
* Creates an instance of Arm Resource Provider service API entry point.
9797
*
9898
* @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential.
9999
* @param profile the Azure profile for client.
100-
* @return the ArmResourceProvider service API instance.
100+
* @return the Arm Resource Provider service API instance.
101101
*/
102102
public static ArmResourceProviderManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
103103
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
@@ -219,11 +219,11 @@ public Configurable withDefaultPollInterval(Duration defaultPollInterval) {
219219
}
220220

221221
/**
222-
* Creates an instance of ArmResourceProvider service API entry point.
222+
* Creates an instance of Arm Resource Provider service API entry point.
223223
*
224224
* @param credential the credential to use.
225225
* @param profile the Azure profile for client.
226-
* @return the ArmResourceProvider service API instance.
226+
* @return the Arm Resource Provider service API instance.
227227
*/
228228
public ArmResourceProviderManager authenticate(TokenCredential credential, AzureProfile profile) {
229229
Objects.requireNonNull(credential, "'credential' cannot be null.");
@@ -373,12 +373,12 @@ public ModelInterfaceSameNames modelInterfaceSameNames() {
373373
}
374374

375375
/**
376-
* Gets wrapped service client ArmResourceProviderClient providing direct access to the underlying auto-generated
377-
* API implementation, based on Azure REST API.
376+
* Gets wrapped service client ArmClient providing direct access to the underlying auto-generated API
377+
* implementation, based on Azure REST API.
378378
*
379-
* @return Wrapped service client ArmResourceProviderClient.
379+
* @return Wrapped service client ArmClient.
380380
*/
381-
public ArmResourceProviderClient serviceClient() {
381+
public ArmClient serviceClient() {
382382
return this.clientObject;
383383
}
384384
}

typespec-tests/src/main/java/tsptest/armresourceprovider/fluent/ArmResourceProviderClient.java renamed to typespec-tests/src/main/java/tsptest/armresourceprovider/fluent/ArmClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import java.time.Duration;
99

1010
/**
11-
* The interface for ArmResourceProviderClient class.
11+
* The interface for ArmClient class.
1212
*/
13-
public interface ArmResourceProviderClient {
13+
public interface ArmClient {
1414
/**
1515
* Gets Service host.
1616
*

typespec-tests/src/main/java/tsptest/armresourceprovider/fluent/models/CustomTemplateResourceInner.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import com.azure.json.JsonWriter;
1313
import java.io.IOException;
1414
import java.util.Map;
15-
import tsptest.armresourceprovider.models.CustomTemplateResourcePropertiesAnonymousEmptyModel;
15+
import tsptest.armresourceprovider.models.AnonymousEmptyModel;
1616
import tsptest.armresourceprovider.models.Dog;
1717
import tsptest.armresourceprovider.models.EmptyModel;
1818
import tsptest.armresourceprovider.models.ManagedServiceIdentity;
@@ -206,7 +206,7 @@ public CustomTemplateResourceInner withNamedEmptyModel(EmptyModel namedEmptyMode
206206
*
207207
* @return the anonymousEmptyModel value.
208208
*/
209-
public CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel() {
209+
public AnonymousEmptyModel anonymousEmptyModel() {
210210
return this.innerProperties() == null ? null : this.innerProperties().anonymousEmptyModel();
211211
}
212212

@@ -216,8 +216,7 @@ public CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel()
216216
* @param anonymousEmptyModel the anonymousEmptyModel value to set.
217217
* @return the CustomTemplateResourceInner object itself.
218218
*/
219-
public CustomTemplateResourceInner
220-
withAnonymousEmptyModel(CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel) {
219+
public CustomTemplateResourceInner withAnonymousEmptyModel(AnonymousEmptyModel anonymousEmptyModel) {
221220
if (this.innerProperties() == null) {
222221
this.innerProperties = new CustomTemplateResourceProperties();
223222
}

typespec-tests/src/main/java/tsptest/armresourceprovider/fluent/models/CustomTemplateResourceProperties.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import com.azure.json.JsonToken;
1212
import com.azure.json.JsonWriter;
1313
import java.io.IOException;
14-
import tsptest.armresourceprovider.models.CustomTemplateResourcePropertiesAnonymousEmptyModel;
14+
import tsptest.armresourceprovider.models.AnonymousEmptyModel;
1515
import tsptest.armresourceprovider.models.Dog;
1616
import tsptest.armresourceprovider.models.EmptyModel;
1717
import tsptest.armresourceprovider.models.PriorityModel;
@@ -40,7 +40,7 @@ public final class CustomTemplateResourceProperties implements JsonSerializable<
4040
/*
4141
* The anonymousEmptyModel property.
4242
*/
43-
private CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel;
43+
private AnonymousEmptyModel anonymousEmptyModel;
4444

4545
/*
4646
* The priority property.
@@ -107,7 +107,7 @@ public CustomTemplateResourceProperties withNamedEmptyModel(EmptyModel namedEmpt
107107
*
108108
* @return the anonymousEmptyModel value.
109109
*/
110-
public CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel() {
110+
public AnonymousEmptyModel anonymousEmptyModel() {
111111
return this.anonymousEmptyModel;
112112
}
113113

@@ -117,8 +117,7 @@ public CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel()
117117
* @param anonymousEmptyModel the anonymousEmptyModel value to set.
118118
* @return the CustomTemplateResourceProperties object itself.
119119
*/
120-
public CustomTemplateResourceProperties
121-
withAnonymousEmptyModel(CustomTemplateResourcePropertiesAnonymousEmptyModel anonymousEmptyModel) {
120+
public CustomTemplateResourceProperties withAnonymousEmptyModel(AnonymousEmptyModel anonymousEmptyModel) {
122121
this.anonymousEmptyModel = anonymousEmptyModel;
123122
return this;
124123
}
@@ -215,7 +214,7 @@ public static CustomTemplateResourceProperties fromJson(JsonReader jsonReader) t
215214
deserializedCustomTemplateResourceProperties.namedEmptyModel = EmptyModel.fromJson(reader);
216215
} else if ("anonymousEmptyModel".equals(fieldName)) {
217216
deserializedCustomTemplateResourceProperties.anonymousEmptyModel
218-
= CustomTemplateResourcePropertiesAnonymousEmptyModel.fromJson(reader);
217+
= AnonymousEmptyModel.fromJson(reader);
219218
} else if ("priority".equals(fieldName)) {
220219
deserializedCustomTemplateResourceProperties.priority = PriorityModel.fromValue(reader.getInt());
221220
} else if ("provisioningState".equals(fieldName)) {

0 commit comments

Comments
 (0)