Search in sources :

Example 1 with ResourceGroup

use of com.azure.resourcemanager.resources.models.ResourceGroup in project terra-cloud-resource-lib by DataBiosphere.

the class AzureResponseLoggerTest method testRecordEvent.

@Test
public void testRecordEvent() {
    // Send an Azure request to list resource groups
    List<ResourceGroup> resourceGroups = setUpResourceManager().resourceGroups().list().stream().collect(Collectors.toList());
    // Verify AzureResponseLogger was invoked
    verify(mockOperationAnnotator).recordOperation(operationDataCaptor.capture());
    // Verify OperationData values
    OperationData operationData = operationDataCaptor.getValue();
    assertThat(operationData.duration().toMillis(), Matchers.greaterThan(0L));
    assertTrue(operationData.tryCount().isPresent());
    assertEquals(OptionalInt.of(200), operationData.httpStatusCode());
    assertEquals(ResourceManagerOperation.AZURE_RESOURCE_MANAGER_UNKNOWN_OPERATION, operationData.cloudOperation());
    assertThat(operationData.requestData().entrySet(), Matchers.hasItem(Map.entry("requestMethod", new JsonPrimitive("GET"))));
    assertThat(operationData.requestData().keySet(), Matchers.hasItem("requestUrl"));
    // For good measure verify the Azure response contains our test resource group
    assertThat(resourceGroups.stream().map(ResourceGroup::name).collect(Collectors.toList()), Matchers.hasItem(AzureIntegrationUtils.DEFAULT_AZURE_RESOURCE_GROUP));
}
Also used : OperationData(bio.terra.cloudres.common.OperationData) JsonPrimitive(com.google.gson.JsonPrimitive) ResourceGroup(com.azure.resourcemanager.resources.models.ResourceGroup) Test(org.junit.jupiter.api.Test)

Aggregations

OperationData (bio.terra.cloudres.common.OperationData)1 ResourceGroup (com.azure.resourcemanager.resources.models.ResourceGroup)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 Test (org.junit.jupiter.api.Test)1