Search in sources :

Example 11 with Project

use of com.google.api.services.cloudresourcemanager.model.Project in project google-cloud-intellij by GoogleCloudPlatform.

the class ProjectLoaderTest method loadUserProjects_sortsProjects_byName.

@Test
public void loadUserProjects_sortsProjects_byName() {
    Project aProject = new Project();
    aProject.setName("a project");
    aProject.setProjectId("The ID");
    mockListProjectsResponse(Arrays.asList(testProject1, testProject2, aProject));
    projectLoader.loadUserProjectsInBackground(mockUser);
    verify(mockFutureCallback).onSuccess(Arrays.asList(aProject, testProject1, testProject2));
}
Also used : Project(com.google.api.services.cloudresourcemanager.model.Project) Test(org.junit.Test)

Example 12 with Project

use of com.google.api.services.cloudresourcemanager.model.Project in project google-cloud-intellij by GoogleCloudPlatform.

the class ProjectLoaderTest method setUp.

@Before
public void setUp() {
    when(mockGoogleApiClientFactory.getCloudResourceManagerClient(any())).thenReturn(mockCloudResourceManager);
    when(projectLoader.loadUserProjectsInBackground(any())).then((Answer<ListenableFuture<List<Project>>>) invocation -> {
        @SuppressWarnings("unchecked") ListenableFuture<List<Project>> result = (ListenableFuture<List<Project>>) invocation.callRealMethod();
        Futures.addCallback(result, mockFutureCallback);
        return result;
    });
    testProject1 = new Project();
    testProject1.setName("test-project");
    testProject1.setProjectId("test-project-ID");
    testProject2 = new Project();
    testProject2.setName("test-project-2");
    testProject2.setProjectId("test-project-2-ID");
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Arrays(java.util.Arrays) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Mock(org.mockito.Mock) CloudResourceManager(com.google.api.services.cloudresourcemanager.CloudResourceManager) Answer(org.mockito.stubbing.Answer) ArgumentCaptor(org.mockito.ArgumentCaptor) CredentialedUser(com.google.cloud.tools.intellij.login.CredentialedUser) Spy(org.mockito.Spy) CloudToolsRule(com.google.cloud.tools.intellij.testing.CloudToolsRule) Before(org.junit.Before) Project(com.google.api.services.cloudresourcemanager.model.Project) IOException(java.io.IOException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Truth.assertThat(com.google.common.truth.Truth.assertThat) GoogleApiClientFactory(com.google.cloud.tools.intellij.resources.GoogleApiClientFactory) FutureCallback(com.google.common.util.concurrent.FutureCallback) Mockito.verify(org.mockito.Mockito.verify) TestService(com.google.cloud.tools.intellij.testing.TestService) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) Rule(org.junit.Rule) Collections(java.util.Collections) ListProjectsResponse(com.google.api.services.cloudresourcemanager.model.ListProjectsResponse) Project(com.google.api.services.cloudresourcemanager.model.Project) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) List(java.util.List) Before(org.junit.Before)

Aggregations

Project (com.google.api.services.cloudresourcemanager.model.Project)12 IOException (java.io.IOException)4 List (java.util.List)4 TestIamPermissionsResponse (com.google.api.services.cloudresourcemanager.model.TestIamPermissionsResponse)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 Before (org.junit.Before)3 Test (org.junit.Test)3 CloudResourceManager (com.google.api.services.cloudresourcemanager.CloudResourceManager)2 ListProjectsResponse (com.google.api.services.cloudresourcemanager.model.ListProjectsResponse)2 CredentialedUser (com.google.cloud.tools.intellij.login.CredentialedUser)2 GoogleApiClientFactory (com.google.cloud.tools.intellij.resources.GoogleApiClientFactory)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)2 ArrayList (java.util.ArrayList)2 Answer (org.mockito.stubbing.Answer)2 Strings (com.google.api.client.repackaged.com.google.common.base.Strings)1 CloudToolsRule (com.google.cloud.tools.intellij.testing.CloudToolsRule)1 TestService (com.google.cloud.tools.intellij.testing.TestService)1 ThreadUtil (com.google.cloud.tools.intellij.util.ThreadUtil)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 Futures (com.google.common.util.concurrent.Futures)1