use of com.azure.resourcemanager.appservice.AppServiceManager in project vividus by vividus-framework.
the class FunctionServiceTests method shouldExecuteAFunction.
@Test
void shouldExecuteAFunction() {
try (MockedStatic<AppServiceManager> appServiceMock = mockStatic(AppServiceManager.class);
MockedConstruction<ResponseCapturingHttpPipelinePolicy> policy = mockConstruction(ResponseCapturingHttpPipelinePolicy.class)) {
when(azureProfile.getEnvironment()).thenReturn(azureEnvironment);
when(azureEnvironment.getActiveDirectoryEndpoint()).thenReturn(ENDPOINT);
Configurable configurable = mock(Configurable.class);
appServiceMock.when(AppServiceManager::configure).thenReturn(configurable);
when(configurable.withLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)).thenReturn(configurable);
when(configurable.withPolicy(any(ResponseCapturingHttpPipelinePolicy.class))).thenReturn(configurable);
AppServiceManager serviceManager = mock(AppServiceManager.class);
when(configurable.authenticate(any(TokenCredential.class), eq(azureProfile))).thenReturn(serviceManager);
FunctionApps functionApps = mock(FunctionApps.class);
when(serviceManager.functionApps()).thenReturn(functionApps);
FunctionApp functionApp = mock(FunctionApp.class);
when(functionApps.getByResourceGroup(RESOURCE_GROUP, FUNCTION_APP)).thenReturn(functionApp);
functionService.triggerFunction(RESOURCE_GROUP, FUNCTION_APP, FUNCTION, PAYLOAD);
verify(azureProfile).getEnvironment();
verify(azureEnvironment).getActiveDirectoryEndpoint();
verify(functionApp).triggerFunction(FUNCTION, PAYLOAD);
verify(policy.constructed().get(0)).getResponses();
}
}
use of com.azure.resourcemanager.appservice.AppServiceManager in project azure-maven-plugins by microsoft.
the class AzureAppService method checkNameAvailability.
@AzureOperation(name = "appservice.check_name", params = "name", type = AzureOperation.Type.SERVICE)
public CheckNameAvailabilityResultEntity checkNameAvailability(String subscriptionId, String name) {
final AppServiceManager azureResourceManager = getAppServiceManager(subscriptionId);
final ResourceNameAvailabilityInner result = azureResourceManager.webApps().manager().serviceClient().getResourceProviders().checkNameAvailability(name, CheckNameResourceTypes.MICROSOFT_WEB_SITES);
return new CheckNameAvailabilityResultEntity(result.nameAvailable(), result.reason().toString(), result.message());
}
Aggregations