-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Automation] Generate Fluent Lite from deviceprovisioningservices# #21149
Changes from 1 commit
3d7a599
5888f20
5fac79f
d1467b1
b494f45
2cc0455
82c868e
fe22e34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.resourcemanager.deviceprovisioningservices; | ||
|
||
import com.azure.core.credential.TokenCredential; | ||
import com.azure.core.http.HttpClient; | ||
import com.azure.core.http.HttpPipeline; | ||
import com.azure.core.http.policy.HttpLogOptions; | ||
import com.azure.core.http.policy.HttpPipelinePolicy; | ||
import com.azure.core.http.policy.RetryPolicy; | ||
import com.azure.core.management.AzureEnvironment; | ||
import com.azure.core.management.profile.AzureProfile; | ||
import com.azure.identity.DefaultAzureCredentialBuilder; | ||
import com.azure.resourcemanager.resources.ResourceManager; | ||
import com.azure.resourcemanager.resources.fluentcore.utils.HttpPipelineProvider; | ||
import com.azure.resourcemanager.resources.fluentcore.utils.ResourceManagerUtils; | ||
import com.azure.resourcemanager.test.ResourceManagerTestBase; | ||
import com.azure.resourcemanager.test.utils.TestDelayProvider; | ||
|
||
import java.time.temporal.ChronoUnit; | ||
import java.util.List; | ||
|
||
public class DeviceProvisioningResourceManagementTestBase extends ResourceManagerTestBase | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, I don't think you need this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha. I had been modeling my test code on the Key Vault Resource Management SDK, but is there a more recent control plane SDK that I should model my test code on? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added a few recently Though I think your digitaltwins is nearest in your case. |
||
{ | ||
ResourceManager resourceManager; | ||
IotDpsManager iotDpsManager; | ||
String resourceGroupName = ""; | ||
String provisioningServiceName = ""; | ||
|
||
@Override | ||
protected HttpPipeline buildHttpPipeline( | ||
TokenCredential credential, | ||
AzureProfile profile, | ||
HttpLogOptions httpLogOptions, | ||
List<HttpPipelinePolicy> policies, | ||
HttpClient httpClient) { | ||
return HttpPipelineProvider.buildHttpPipeline( | ||
credential, | ||
profile, | ||
null, | ||
httpLogOptions, | ||
null, | ||
new RetryPolicy("Retry-After", ChronoUnit.SECONDS), | ||
policies, | ||
httpClient); | ||
} | ||
|
||
@Override | ||
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) { | ||
resourceGroupName = generateRandomResourceName("javacsmrg", 15); | ||
provisioningServiceName = generateRandomResourceName("java-deviceprovisioning-", 20); | ||
|
||
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode())); | ||
|
||
//IotDpsManager iotDpsManager = buildManager(IotDpsManager.class, httpPipeline, profile); | ||
iotDpsManager = | ||
IotDpsManager | ||
.authenticate(new DefaultAzureCredentialBuilder().build(), new AzureProfile(AzureEnvironment.AZURE)); | ||
|
||
resourceManager = | ||
ResourceManager | ||
.authenticate(new DefaultAzureCredentialBuilder().build(), new AzureProfile(AzureEnvironment.AZURE)) | ||
.withDefaultSubscription(); | ||
} | ||
|
||
@Override | ||
protected void cleanUpResources() { | ||
resourceManager.resourceGroups().beginDeleteByName(resourceGroupName); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,64 +3,24 @@ | |
|
||
package com.azure.resourcemanager.deviceprovisioningservices; | ||
|
||
import com.azure.core.management.AzureEnvironment; | ||
import com.azure.core.management.Region; | ||
import com.azure.core.management.profile.AzureProfile; | ||
import com.azure.core.test.TestBase; | ||
import com.azure.core.test.annotation.DoNotRecord; | ||
import com.azure.identity.DefaultAzureCredentialBuilder; | ||
import com.azure.resourcemanager.deviceprovisioningservices.fluent.models.ProvisioningServiceDescriptionInner; | ||
import com.azure.resourcemanager.deviceprovisioningservices.models.NameAvailabilityInfo; | ||
import com.azure.resourcemanager.deviceprovisioningservices.models.OperationInputs; | ||
import com.azure.resourcemanager.deviceprovisioningservices.models.ProvisioningServiceDescription; | ||
import com.azure.resourcemanager.resources.ResourceManager; | ||
import com.azure.resourcemanager.resources.models.ResourceGroup; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class DeviceProvisioningResourceManagementTests extends TestBase { | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class DeviceProvisioningResourceManagementTests extends DeviceProvisioningResourceManagementTestBase | ||
{ | ||
private static final Region DEFAULT_REGION = Region.US_WEST_CENTRAL; | ||
|
||
@Test | ||
@DoNotRecord(skipInPlayback = true) | ||
public void CreateAndDelete() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Follow Java convention, else build will fail. |
||
String testName = "testingDPSCreateUpdate"; | ||
String resourceGroupName = testName; | ||
String provisioningServiceName = testName; | ||
|
||
ResourceManager resourceManager = ResourceManager | ||
.authenticate(new DefaultAzureCredentialBuilder().build(), new AzureProfile(AzureEnvironment.AZURE)) | ||
.withDefaultSubscription(); | ||
|
||
IotDpsManager iotDpsManager = IotDpsManager | ||
.authenticate(new DefaultAzureCredentialBuilder().build(), new AzureProfile(AzureEnvironment.AZURE)); | ||
|
||
ResourceGroup group = resourceManager.resourceGroups() | ||
.define(resourceGroupName) | ||
.withRegion(DEFAULT_REGION) | ||
.create(); | ||
|
||
Assertions.assertNotNull(group); | ||
|
||
NameAvailabilityInfo nameAvailabilityInfo = | ||
iotDpsManager | ||
.iotDpsResources() | ||
.checkProvisioningServiceNameAvailability(new OperationInputs().withName(testName)); | ||
|
||
if (nameAvailabilityInfo.nameAvailable() != null && !nameAvailabilityInfo.nameAvailable()) | ||
{ | ||
// it exists, so test deleting it | ||
iotDpsManager.iotDpsResources().delete(testName, resourceGroupName, null); | ||
|
||
// check the name is now available | ||
nameAvailabilityInfo = iotDpsManager | ||
.iotDpsResources() | ||
.checkProvisioningServiceNameAvailability(new OperationInputs().withName(testName)); | ||
|
||
assertTrue(nameAvailabilityInfo.nameAvailable()); | ||
if (skipInPlayback()) { | ||
return; | ||
} | ||
|
||
// try to create a DPS service | ||
|
@@ -75,6 +35,6 @@ public void CreateAndDelete() { | |
|
||
assertNotNull(updatedProvisioningServiceDescriptionInner); | ||
assertEquals(Constants.DefaultSku.NAME, updatedProvisioningServiceDescriptionInner.sku().name().toString()); | ||
assertEquals(testName, updatedProvisioningServiceDescriptionInner.name()); | ||
assertEquals(provisioningServiceName, updatedProvisioningServiceDescriptionInner.name()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better not to include this.
If you really really need this, you need to put it in a profile, as this
azure-resourcemanager-test
is not released to maven.