### Question:
IdentityGroup extends IdentityPrincipal<IdentityGroup> { @Override public ListenableFuture<Boolean> unmap(IdentityService service) throws IOException { ListenableFuture<Operation> deleteGroup = service.deleteGroup(groupResourceName.get()); return Futures.transform( deleteGroup, new Function<Operation, Boolean>() { @Override @Nullable public Boolean apply(@Nullable Operation input) { try { validateOperation(input); return true; } catch (IOException e) { logger.log(Level.WARNING, String.format("Failed to delete Group %s", groupKey), e); return false; } } }, getExecutor()); } IdentityGroup(Builder buider); ImmutableSet<Membership> getMembers(); EntityKey getGroupKey(); @Override Kind getKind(); @Override ListenableFuture<Boolean> unmap(IdentityService service); @Override ListenableFuture<IdentityGroup> sync(
      IdentityGroup previouslySynced, IdentityService service); @Override int hashCode(); @Override boolean equals(Object obj); static final ImmutableMap<String, String> GROUP_LABELS; }### Answer:
@Test public void testUnmap() throws IOException, InterruptedException, ExecutionException { Set<Membership> members = Collections.singleton( new Membership().setPreferredMemberKey(new EntityKey().setId("user@domain.com"))); IdentityGroup group = new IdentityGroup.Builder() .setGroupIdentity("domain\\group1") .setGroupKey(GROUP_KEY) .setMembers(members) .setGroupResourceName("groups/id1") .build(); when(mockIdentityService.deleteGroup("groups/id1")) .thenReturn(Futures.immediateFuture(new Operation().setDone(true))); ListenableFuture<Boolean> unmap = group.unmap(mockIdentityService); assertTrue(unmap.get()); }
@Test public void testUnmapFails() throws IOException, InterruptedException, ExecutionException { Set<Membership> members = Collections.singleton( new Membership().setPreferredMemberKey(new EntityKey().setId("user@domain.com"))); IdentityGroup group = new IdentityGroup.Builder() .setGroupIdentity("domain\\group1") .setGroupKey(GROUP_KEY) .setMembers(members) .setGroupResourceName("groups/id1") .build(); when(mockIdentityService.deleteGroup("groups/id1")) .thenReturn(Futures.immediateFailedFuture(new IOException("error deleting group"))); ListenableFuture<Boolean> unmap = group.unmap(mockIdentityService); thrown.expectCause(isA(IOException.class)); unmap.get(); }