-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c401851
commit 6afa9ae
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
typespec-tests/src/test/java/com/azure/arm/models/resources/ArmResourceTest.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,22 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.arm.models.resources; | ||
|
||
import com.azure.arm.models.resources.models.TopLevelTrackedResource; | ||
import org.utils.ArmUtils; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ArmResourceTest { | ||
|
||
private final ResourcesManager manager = ResourcesManager.authenticate( | ||
ArmUtils.createTestHttpPipeline(), | ||
ArmUtils.getAzureProfile()); | ||
|
||
@Test | ||
public void testTopLevel() { | ||
TopLevelTrackedResource resource = manager.topLevelTrackedResources().getByResourceGroup("test-rg", "top"); | ||
Assertions.assertEquals("topLevel", resource.type()); | ||
} | ||
} |
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. | ||
|
||
package org.utils; | ||
|
||
import com.azure.core.http.HttpPipeline; | ||
import com.azure.core.http.HttpPipelineBuilder; | ||
import com.azure.core.http.policy.AddDatePolicy; | ||
import com.azure.core.http.policy.AddHeadersFromContextPolicy; | ||
import com.azure.core.http.policy.HttpLogDetailLevel; | ||
import com.azure.core.http.policy.HttpLogOptions; | ||
import com.azure.core.http.policy.HttpLoggingPolicy; | ||
import com.azure.core.http.policy.HttpPipelinePolicy; | ||
import com.azure.core.http.policy.RequestIdPolicy; | ||
import com.azure.core.http.policy.RetryPolicy; | ||
import com.azure.core.http.policy.UserAgentPolicy; | ||
import com.azure.core.management.AzureEnvironment; | ||
import com.azure.core.management.profile.AzureProfile; | ||
|
||
import java.time.temporal.ChronoUnit; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public final class ArmUtils { | ||
|
||
private final static AzureProfile AZURE_PROFILE = new AzureProfile( | ||
"00000000-0000-0000-0000-000000000000", | ||
"00000000-0000-0000-0000-000000000000", | ||
new AzureEnvironment(Map.of("resourceManagerEndpointUrl", "http://localhost:3000"))); | ||
|
||
private ArmUtils() { | ||
} | ||
|
||
public static HttpPipeline createTestHttpPipeline() { | ||
List<HttpPipelinePolicy> policies = new ArrayList<>(); | ||
policies.add(new UserAgentPolicy()); | ||
policies.add(new AddHeadersFromContextPolicy()); | ||
policies.add(new RequestIdPolicy()); | ||
policies.add(new RetryPolicy("Retry-After", ChronoUnit.SECONDS)); | ||
policies.add(new AddDatePolicy()); | ||
// no ArmChallengeAuthenticationPolicy | ||
policies.add(new HttpLoggingPolicy(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))); | ||
return new HttpPipelineBuilder() | ||
.policies(policies.toArray(new HttpPipelinePolicy[0])) | ||
.build(); | ||
} | ||
|
||
public static AzureProfile getAzureProfile() { | ||
return AZURE_PROFILE; | ||
} | ||
} |