Search in sources :

Example 1 with AppServiceManager

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();
    }
}
Also used : AppServiceManager(com.azure.resourcemanager.appservice.AppServiceManager) FunctionApps(com.azure.resourcemanager.appservice.models.FunctionApps) Configurable(com.azure.resourcemanager.appservice.AppServiceManager.Configurable) TokenCredential(com.azure.core.credential.TokenCredential) FunctionApp(com.azure.resourcemanager.appservice.models.FunctionApp) Test(org.junit.jupiter.api.Test)

Example 2 with AppServiceManager

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());
}
Also used : AppServiceManager(com.azure.resourcemanager.appservice.AppServiceManager) ResourceNameAvailabilityInner(com.azure.resourcemanager.appservice.fluent.models.ResourceNameAvailabilityInner) CheckNameAvailabilityResultEntity(com.microsoft.azure.toolkit.lib.common.entity.CheckNameAvailabilityResultEntity) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Aggregations

AppServiceManager (com.azure.resourcemanager.appservice.AppServiceManager)2 TokenCredential (com.azure.core.credential.TokenCredential)1 Configurable (com.azure.resourcemanager.appservice.AppServiceManager.Configurable)1 ResourceNameAvailabilityInner (com.azure.resourcemanager.appservice.fluent.models.ResourceNameAvailabilityInner)1 FunctionApp (com.azure.resourcemanager.appservice.models.FunctionApp)1 FunctionApps (com.azure.resourcemanager.appservice.models.FunctionApps)1 CheckNameAvailabilityResultEntity (com.microsoft.azure.toolkit.lib.common.entity.CheckNameAvailabilityResultEntity)1 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)1 Test (org.junit.jupiter.api.Test)1