use of com.azure.resourcemanager.appservice.models.FunctionApps 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();
}
}
Aggregations