Search in sources :

Example 1 with AzureSubscriptionEndpointCreationRequest

use of com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionEndpointCreationService.AzureSubscriptionEndpointCreationRequest in project photon-model by vmware.

the class AzureSubscriptionEndpointCreationServiceTest method testSubscriptionEndpointCreation.

@Test
public void testSubscriptionEndpointCreation() throws Throwable {
    AzureSubscriptionEndpointCreationRequest request = new AzureSubscriptionEndpointCreationRequest();
    request.resourceReference = UriUtils.buildUri(this.host, this.eaEndPointLink);
    request.subscriptionId = SUBSCRIPTION_ID;
    request.accountId = ACCOUNT_ID;
    Operation endPointCreationOp = Operation.createPatch(this.host, AzureSubscriptionEndpointCreationService.SELF_LINK);
    endPointCreationOp.setBody(request);
    TestRequestSender sender = new TestRequestSender(this.host);
    EndpointState subscriptionEndpoint = sender.sendAndWait(endPointCreationOp, EndpointState.class);
    // Assert the subscriptionEndpoint created
    Assert.assertEquals(this.eaEndPointLink, subscriptionEndpoint.parentLink);
    Assert.assertNotNull(subscriptionEndpoint.endpointProperties.get(EndpointConfigRequest.USER_LINK_KEY));
    Assert.assertEquals(SUBSCRIPTION_ID, subscriptionEndpoint.endpointProperties.get(EndpointConfigRequest.USER_LINK_KEY));
    ComputeState cs = getServiceSynchronously(subscriptionEndpoint.computeLink, ComputeState.class);
    Assert.assertNotNull(cs.customProperties.get(AzureConstants.AZURE_ACCOUNT_OWNER_EMAIL_ID));
    Assert.assertEquals(ACCOUNT_ID, cs.customProperties.get(AzureConstants.AZURE_ACCOUNT_OWNER_EMAIL_ID));
    Assert.assertNotNull(cs.customProperties.get(AzureConstants.AZURE_SUBSCRIPTION_ID_KEY));
    Assert.assertEquals(SUBSCRIPTION_ID, cs.customProperties.get(AzureConstants.AZURE_SUBSCRIPTION_ID_KEY));
}
Also used : AzureSubscriptionEndpointCreationRequest(com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionEndpointCreationService.AzureSubscriptionEndpointCreationRequest) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) TestRequestSender(com.vmware.xenon.common.test.TestRequestSender) Operation(com.vmware.xenon.common.Operation) Test(org.junit.Test)

Example 2 with AzureSubscriptionEndpointCreationRequest

use of com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionEndpointCreationService.AzureSubscriptionEndpointCreationRequest in project photon-model by vmware.

the class AzureSubscriptionEndpointsEnumerationService method createSubscriptionEndpointCreationRequest.

private AzureSubscriptionEndpointCreationRequest createSubscriptionEndpointCreationRequest(AzureSubscriptionEndpointsEnumerationContext context, AzureSubscription subscription) {
    AzureSubscriptionEndpointCreationRequest request = new AzureSubscriptionEndpointCreationRequest();
    request.accountId = subscription.parentEntityId;
    request.subscriptionId = subscription.entityId;
    request.resourceReference = UriUtils.extendUri(ClusterUtil.getClusterUri(getHost(), ServiceTypeCluster.INVENTORY_SERVICE), context.parent.endpointLink);
    return request;
}
Also used : AzureSubscriptionEndpointCreationRequest(com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionEndpointCreationService.AzureSubscriptionEndpointCreationRequest)

Aggregations

AzureSubscriptionEndpointCreationRequest (com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionEndpointCreationService.AzureSubscriptionEndpointCreationRequest)2 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)1 EndpointState (com.vmware.photon.controller.model.resources.EndpointService.EndpointState)1 Operation (com.vmware.xenon.common.Operation)1 TestRequestSender (com.vmware.xenon.common.test.TestRequestSender)1 Test (org.junit.Test)1