@Test public void testCreateVirtualGroupsWithNonExistingGroups() { doThrow(new StatusRuntimeException(Status.NOT_FOUND)) .when(grpcUmsClient).getWorkloadAdministrationGroupName(anyString(), eq(ACCOUNT_ID), eq(Optional.empty()), anyString(), eq(ENV_CRN)); when(grpcUmsClient.setWorkloadAdministrationGroupName(anyString(), eq(ACCOUNT_ID), eq(Optional.empty()), anyString(), eq(ENV_CRN))).thenReturn(MOCK_VIRTUAL_GROUP); Map<UmsRight, String> result = virtualGroupService.createVirtualGroups(ACCOUNT_ID, ENV_CRN); assertEquals(UmsRight.values().length, result.size()); verify(grpcUmsClient, times(UmsRight.values().length)).setWorkloadAdministrationGroupName(crnCaptor.capture(), eq(ACCOUNT_ID), eq(Optional.empty()), rightCaptor.capture(), eq(ENV_CRN)); assertEquals(INTERNAL_ACTOR_CRN, crnCaptor.getValue()); for (UmsRight umsRight : UmsRight.values()) { assertEquals(MOCK_VIRTUAL_GROUP, result.get(umsRight)); assertTrue(rightCaptor.getAllValues().contains(umsRight.getRight())); } }
public Map<UmsRight, String> createVirtualGroups(String accountId, String environmentCrn) { Map<UmsRight, String> virtualGroups = new HashMap<>(); for (UmsRight right : UmsRight.values()) { virtualGroups.put(right, createOrGetVirtualGroup(accountId, environmentCrn, right.getRight())); } return virtualGroups; }
VirtualGroupService { public Map<UmsRight, String> createVirtualGroups(String accountId, String environmentCrn) { Map<UmsRight, String> virtualGroups = new HashMap<>(); for (UmsRight right : UmsRight.values()) { virtualGroups.put(right, createOrGetVirtualGroup(accountId, environmentCrn, right.getRight())); } return virtualGroups; } }
VirtualGroupService { public Map<UmsRight, String> createVirtualGroups(String accountId, String environmentCrn) { Map<UmsRight, String> virtualGroups = new HashMap<>(); for (UmsRight right : UmsRight.values()) { virtualGroups.put(right, createOrGetVirtualGroup(accountId, environmentCrn, right.getRight())); } return virtualGroups; }  }
VirtualGroupService { public Map<UmsRight, String> createVirtualGroups(String accountId, String environmentCrn) { Map<UmsRight, String> virtualGroups = new HashMap<>(); for (UmsRight right : UmsRight.values()) { virtualGroups.put(right, createOrGetVirtualGroup(accountId, environmentCrn, right.getRight())); } return virtualGroups; }  Map<UmsRight, String> createVirtualGroups(String accountId, String environmentCrn); String getVirtualGroup(VirtualGroupRequest virtualGroupRequest, String right); void cleanupVirtualGroups(String accountId, String environmentCrn); }
VirtualGroupService { public Map<UmsRight, String> createVirtualGroups(String accountId, String environmentCrn) { Map<UmsRight, String> virtualGroups = new HashMap<>(); for (UmsRight right : UmsRight.values()) { virtualGroups.put(right, createOrGetVirtualGroup(accountId, environmentCrn, right.getRight())); } return virtualGroups; }  Map<UmsRight, String> createVirtualGroups(String accountId, String environmentCrn); String getVirtualGroup(VirtualGroupRequest virtualGroupRequest, String right); void cleanupVirtualGroups(String accountId, String environmentCrn);  }