Skip to content

Commit

Permalink
stage1_testServiceAccountsList refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
msilc committed May 9, 2024
1 parent 1daece5 commit 336fa98
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions iam/snippets/src/test/java/ServiceAccountTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@

import com.google.cloud.iam.admin.v1.IAMClient;
import com.google.cloud.testing.junit4.MultipleAttemptsRule;
import com.google.common.collect.Lists;
import com.google.iam.admin.v1.ServiceAccount;
import com.google.iam.admin.v1.ServiceAccountKey;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -94,7 +94,14 @@ public void stage1_testServiceAccountsList() throws IOException {
IAMClient.ListServiceAccountsPagedResponse response =
ListServiceAccounts.listServiceAccounts(PROJECT_ID);

assertTrue(response.iterateAll().iterator().hasNext());
AtomicBoolean containsAccount = new AtomicBoolean(false);
response.iterateAll().forEach(account -> {
if (account.getName().contains(SERVICE_ACCOUNT)) {
containsAccount.set(true);
}
});

assertTrue(containsAccount.get());
}

@Test
Expand Down

0 comments on commit 336fa98

Please sign in to comment.