From ad12f6ca593b8b20ad0c8e9746af07045cc68f78 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Thu, 17 Oct 2024 11:55:55 +0800 Subject: [PATCH] http-client-java, update test to fill exact param --- .../core/access/AccessTests.java | 18 +++++++++--------- .../com/authentication/apikey/ApiKeyTests.java | 2 +- .../ManagedIdentityManagerTests.java | 5 +++-- .../src/test/java/com/routes/RouteTests.java | 13 ++++++------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/clientgenerator/core/access/AccessTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/clientgenerator/core/access/AccessTests.java index ca6a4b5a99..27ca5c4872 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/clientgenerator/core/access/AccessTests.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/_specs_/azure/clientgenerator/core/access/AccessTests.java @@ -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); } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/apikey/ApiKeyTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/apikey/ApiKeyTests.java index 1e1990f4ac..f37ada1aab 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/apikey/ApiKeyTests.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/authentication/apikey/ApiKeyTests.java @@ -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 diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/azure/resourcemanager/models/commontypes/managedidentity/ManagedIdentityManagerTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/azure/resourcemanager/models/commontypes/managedidentity/ManagedIdentityManagerTests.java index b024596c92..662048094b 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/azure/resourcemanager/models/commontypes/managedidentity/ManagedIdentityManagerTests.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/azure/resourcemanager/models/commontypes/managedidentity/ManagedIdentityManagerTests.java @@ -45,8 +45,9 @@ public void testManagedIdentityManager() { Map 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()); diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/routes/RouteTests.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/routes/RouteTests.java index 69e74b19cb..fccff5c34d 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/routes/RouteTests.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/routes/RouteTests.java @@ -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 { @@ -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");