Search in sources :

Example 1 with Configurable

use of com.azure.resourcemanager.appservice.AppServiceManager.Configurable 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)

Aggregations

TokenCredential (com.azure.core.credential.TokenCredential)1 AppServiceManager (com.azure.resourcemanager.appservice.AppServiceManager)1 Configurable (com.azure.resourcemanager.appservice.AppServiceManager.Configurable)1 FunctionApp (com.azure.resourcemanager.appservice.models.FunctionApp)1 FunctionApps (com.azure.resourcemanager.appservice.models.FunctionApps)1 Test (org.junit.jupiter.api.Test)1