### Question:
RangerVirtualGroupService { public String getRangerVirtualGroup(Stack stack) { Optional<LdapView> ldapView = ldapConfigService.get(stack.getEnvironmentCrn(), stack.getName()); String virtualGroupsEnvironmentCrn = environmentConfigProvider.getParentEnvironmentCrn(stack.getEnvironmentCrn()); String adminGroup = ldapView.orElseThrow(() -> new CloudbreakServiceException("Ranger admin group not found.")) .getAdminGroup(); LOGGER.debug("Admin Group:", adminGroup); VirtualGroupRequest virtualGroupRequest = new VirtualGroupRequest(virtualGroupsEnvironmentCrn, adminGroup); return virtualGroupService.getVirtualGroup(virtualGroupRequest, UmsRight.RANGER_ADMIN.getRight()); }  String getRangerVirtualGroup(Stack stack);  }### Answer:
@Test(expected = CloudbreakServiceException.class) public void getRangerVirtualGroupTestFailed() { when(ldapConfigService.get(anyString(), anyString())).thenReturn(Optional.empty()); when(environmentConfigProvider.getParentEnvironmentCrn(anyString())).thenReturn(TestConstants.CRN); Stack stack = new Stack(); stack.setEnvironmentCrn(TestConstants.CRN); stack.setName("datalake-stack"); Assert.assertEquals("_c_environments_adminranger", underTest.getRangerVirtualGroup(stack)); }
@Test public void getRangerVirtualGroupTestSuccess() { Mockito.when(virtualGroupService.getVirtualGroup( any(), any())) .thenReturn("_c_environments_adminranger"); LdapView ldapView = LdapView.LdapViewBuilder.aLdapView().withProtocol("") .withAdminGroup("admin<>") .build(); when(ldapConfigService.get(anyString(), anyString())).thenReturn(Optional.of(ldapView)); when(environmentConfigProvider.getParentEnvironmentCrn(anyString())).thenReturn(TestConstants.CRN); Stack stack = new Stack(); stack.setEnvironmentCrn(TestConstants.CRN); stack.setName("datalake-stack"); Assert.assertEquals("_c_environments_adminranger", underTest.getRangerVirtualGroup(stack)); }