-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mgmt, add live tests for arg (#20079)
- Loading branch information
1 parent
9c5d7bf
commit 6e2f14d
Showing
3 changed files
with
71 additions
and
0 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
52 changes: 52 additions & 0 deletions
52
...sourcegraph/src/test/java/com/azure/resourcemanager/resourcegraph/ResourceGraphTests.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,52 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
// Code generated by Microsoft (R) AutoRest Code Generator. | ||
|
||
package com.azure.resourcemanager.resourcegraph; | ||
|
||
import com.azure.core.management.AzureEnvironment; | ||
import com.azure.core.management.profile.AzureProfile; | ||
import com.azure.core.test.TestBase; | ||
import com.azure.core.test.annotation.DoNotRecord; | ||
import com.azure.core.util.Configuration; | ||
import com.azure.identity.DefaultAzureCredentialBuilder; | ||
import com.azure.resourcemanager.resourcegraph.models.QueryRequest; | ||
import com.azure.resourcemanager.resourcegraph.models.QueryRequestOptions; | ||
import com.azure.resourcemanager.resourcegraph.models.QueryResponse; | ||
import com.azure.resourcemanager.resourcegraph.models.ResultFormat; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class ResourceGraphTests extends TestBase { | ||
|
||
@Test | ||
@DoNotRecord(skipInPlayback = true) | ||
public void queryTest() { | ||
// requires a Azure Subscription | ||
String subscriptionId = Configuration.getGlobalConfiguration().get(Configuration.PROPERTY_AZURE_SUBSCRIPTION_ID); | ||
|
||
ResourceGraphManager manager = ResourceGraphManager | ||
.authenticate(new DefaultAzureCredentialBuilder().build(), new AzureProfile(AzureEnvironment.AZURE)); | ||
|
||
QueryRequest queryRequest = new QueryRequest() | ||
.withSubscriptions(Collections.singletonList(subscriptionId)) | ||
.withQuery("Resources | project name, type | limit 5 | order by name asc"); | ||
// table format | ||
queryRequest.withOptions(new QueryRequestOptions().withResultFormat(ResultFormat.TABLE)); | ||
QueryResponse response = manager.resourceProviders().resources(queryRequest); | ||
|
||
Assertions.assertNotNull(response.data()); | ||
Assertions.assertTrue(response.data() instanceof Map); | ||
|
||
// object array format | ||
queryRequest.withOptions(new QueryRequestOptions().withResultFormat(ResultFormat.OBJECT_ARRAY)); | ||
response = manager.resourceProviders().resources(queryRequest); | ||
|
||
Assertions.assertNotNull(response.data()); | ||
Assertions.assertTrue(response.data() instanceof List); | ||
} | ||
} |