Search in sources :

Example 46 with Subscription

use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.

the class ContainerRegistryMvpModelTest method testListContainerRegistries.

@Test
public void testListContainerRegistries() throws IOException {
    List<Subscription> subscriptions = new ArrayList<Subscription>();
    Subscription sub1 = mock(Subscription.class);
    when(sub1.getId()).thenReturn("1");
    Subscription sub2 = mock(Subscription.class);
    when(sub2.getId()).thenReturn("2");
    Subscription sub3 = mock(Subscription.class);
    when(sub3.getId()).thenReturn("3");
    when(mvpModel.getSelectedSubscriptions()).thenReturn(subscriptions);
    ContainerRegistryMvpModel mockModel = spy(containerRegistryMvpModel);
    when(authMethodManagerMock.getAzureClient(anyString())).thenReturn(azureMock);
    when(registriesMock.list()).thenReturn(new PagedList<Registry>() {

        @Override
        public Page<Registry> nextPage(String nextPageLink) throws RestException, IOException {
            return null;
        }
    });
    mockModel.listContainerRegistries(false);
    verify(mockModel, times(0)).listRegistryBySubscriptionId(anyString(), eq(false));
    subscriptions.add(sub1);
    subscriptions.add(sub2);
    subscriptions.add(sub3);
    mockModel.listContainerRegistries(false);
    verify(mockModel, times(3)).listRegistryBySubscriptionId(anyString(), eq(false));
    reset(mockModel);
    mockModel.listContainerRegistries(true);
    verify(mockModel, times(3)).listRegistryBySubscriptionId(anyString(), eq(true));
}
Also used : ArrayList(java.util.ArrayList) RestException(com.microsoft.rest.RestException) Page(com.microsoft.azure.Page) Registry(com.microsoft.azure.management.containerregistry.Registry) Mockito.anyString(org.mockito.Mockito.anyString) IOException(java.io.IOException) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 47 with Subscription

use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.

the class AppServiceInfoAdvancedPanel method onSubscriptionChanged.

private void onSubscriptionChanged(final ItemEvent e) {
    // TODO: @wangmi try subscription mechanism? e.g. this.selectorGroup.subscribe(this.selectSubscription)
    if (e.getStateChange() == ItemEvent.SELECTED || e.getStateChange() == ItemEvent.DESELECTED) {
        final Subscription subscription = (Subscription) e.getItem();
        this.selectorGroup.setSubscription(subscription);
        this.textName.setSubscription(subscription);
        this.selectorRegion.setSubscription(subscription);
        this.selectorServicePlan.setSubscription(subscription);
    }
}
Also used : Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 48 with Subscription

use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.

the class AzureExplorer method getTitle.

private String getTitle() {
    try {
        final AzureAccount az = Azure.az(AzureAccount.class);
        final Account account = az.account();
        final List<Subscription> subscriptions = account.getSelectedSubscriptions();
        if (subscriptions.size() == 1) {
            return String.format("Azure(%s)", subscriptions.get(0).getName());
        }
    } catch (final Exception ignored) {
    }
    return "Azure";
}
Also used : Account(com.microsoft.azure.toolkit.lib.auth.Account) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 49 with Subscription

use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.

the class AbstractSpringCloudAppInfoPanel method onSubscriptionChanged.

private void onSubscriptionChanged(final ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED || e.getStateChange() == ItemEvent.DESELECTED) {
        final Subscription subscription = (Subscription) e.getItem();
        this.getSelectorCluster().setSubscription(subscription);
    }
}
Also used : Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 50 with Subscription

use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by microsoft.

the class SpringCloudDeploymentConfigurationPanel method onSubscriptionChanged.

private void onSubscriptionChanged(final ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED || e.getStateChange() == ItemEvent.DESELECTED) {
        final Subscription subscription = (Subscription) e.getItem();
        this.selectorCluster.setSubscription(subscription);
    }
}
Also used : Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Aggregations

Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)130 ResourceGroup (com.microsoft.azure.toolkit.lib.common.model.ResourceGroup)26 Region (com.microsoft.azure.toolkit.lib.common.model.Region)18 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)18 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)15 ArrayList (java.util.ArrayList)14 IOException (java.io.IOException)10 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 Project (com.intellij.openapi.project.Project)8 Azure (com.microsoft.azure.toolkit.lib.Azure)8 IAppServicePlan (com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan)8 IWebApp (com.microsoft.azure.toolkit.lib.appservice.service.IWebApp)8 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)8 HashMap (java.util.HashMap)8 List (java.util.List)8 StringUtils (org.apache.commons.lang3.StringUtils)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 Point (org.eclipse.swt.graphics.Point)8 GridData (org.eclipse.swt.layout.GridData)8 Combo (org.eclipse.swt.widgets.Combo)8