### Question:
DelfiAuthenticationService implements AuthenticationService { @Override public UserGroups getUserGroups(String authorizationToken, String partition) { log.debug("Fetch user groups: {}, {}, {}", authorizationToken, portalProperties.getAppKey(), partition); checkPreconditions(authorizationToken, partition); UserGroups userGroups = delfiEntitlementsClient .getUserGroups(authorizationToken, portalProperties.getAppKey(), partition); log.debug("Finished fetching user groups. User groups: {}", userGroups == null ? null : userGroups.toString()); return userGroups; }  @Override UserGroups getUserGroups(String authorizationToken, String partition); @Override void checkAuthentication(String authorizationToken, String partition); @Override Map<String, String> getGroupEmailToName(String authorizationToken, String partition);  }### Answer:
@Test public void shouldGetUserGroups() { UserGroups expectedUserGroups = new UserGroups(); when(delfiPortalProperties.getAppKey()).thenReturn(APP_KEY); when(delfiEntitlementsClient.getUserGroups(eq(AUTH), eq(APP_KEY), eq(PARTITION))).thenReturn(expectedUserGroups); UserGroups userGroups = delfiAuthenticationService.getUserGroups(AUTH, PARTITION); assertEquals(expectedUserGroups, userGroups); }
@Test public void shouldFailIfNoAuthToken() { when(delfiPortalProperties.getAppKey()).thenReturn(APP_KEY); String authToken = null; Throwable thrown = catchThrowable( () -> delfiAuthenticationService.getUserGroups(authToken, PARTITION)); Assertions.assertThat(thrown) .isInstanceOf(OsduException.class) .hasMessageContaining("Missing authorization token"); }