Skip to content

Commit

Permalink
http-client-java, update test to fill exact param (microsoft#4770)
Browse files Browse the repository at this point in the history
for Azure/cadl-ranch#755, as some tests validate
the exact value of some parameter/property.

for the 2 file with only format change, I guess the reason is Alan
enabled spotless on emitter Java code (so `mvn package` would
automatically format the code)
  • Loading branch information
weidongxu-microsoft authored and swatikumar committed Nov 5, 2024
1 parent e3694dd commit 9a5bedd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ public class AccessTests {

@Test
public void test() {
publicClient.publicDecoratorInPublic("");
publicClient.noDecoratorInPublic("");
publicClient.publicDecoratorInPublic("sample");
publicClient.noDecoratorInPublic("sample");

internalClient.internalDecoratorInInternal("");
internalClient.noDecoratorInInternal("");
internalClient.publicDecoratorInInternal("");
internalClient.internalDecoratorInInternal("sample");
internalClient.noDecoratorInInternal("sample");
internalClient.publicDecoratorInInternal("sample");

sharedClient.publicMethod("");
sharedClient.internalWithResponse("", null).getValue().toObject(SharedModel.class);
sharedClient.publicMethod("sample");
sharedClient.internalWithResponse("sample", null).getValue().toObject(SharedModel.class);

relativeClient.operation("");
relativeClient.operation("Madge");
AbstractModel abstractModel = relativeClient.discriminator("real");
Assertions.assertTrue(abstractModel instanceof RealModel);
Assertions.assertInstanceOf(RealModel.class, abstractModel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void testValid() {
public void testInvalid() {
ApiKeyClient client = new ApiKeyClientBuilder()
// AzureKeyCredentialPolicy from core requires HTTPS
.addPolicy(new AzureKeyCredentialPolicy("x-ms-api-key", new AzureKeyCredential("valid-key")))
.addPolicy(new AzureKeyCredentialPolicy("x-ms-api-key", new AzureKeyCredential("invalid-key")))
.buildClient();

// assert HttpResponseException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public void testManagedIdentityManager() {
Map<String, UserAssignedIdentity> userAssignedIdentityMap = new HashMap<>();
userAssignedIdentityMap.put(USER_ASSIGNED_IDENTITIES_KEY, new UserAssignedIdentity());
resource.update()
.withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)
.withUserAssignedIdentities(userAssignedIdentityMap))
.withIdentity(
new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)
.withUserAssignedIdentities(userAssignedIdentityMap))
.apply();
Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, resource.identity().type());
Assertions.assertNotNull(resource.identity().principalId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

package com.routes;

import java.util.List;
import java.util.Set;

import com.azure.core.http.policy.HttpLogDetailLevel;
import com.azure.core.http.policy.HttpLogOptions;
import java.util.List;
import java.util.Set;
import org.junit.jupiter.api.Test;

public class RouteTests {
Expand Down Expand Up @@ -79,10 +78,10 @@ public void testQueryExpansionExplode() {

@Test
public void buildQueryParametersQueryContinuationExplode() {
var client = new RoutesClientBuilder().httpLogOptions(new HttpLogOptions()
.setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)
.setAllowedQueryParamNames(Set.of("fixed", "param"))
).buildQueryParametersQueryContinuationExplodeClient();
var client = new RoutesClientBuilder()
.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)
.setAllowedQueryParamNames(Set.of("fixed", "param")))
.buildQueryParametersQueryContinuationExplodeClient();

client.primitive("a");

Expand Down

0 comments on commit 9a5bedd

Please sign in to comment.