### Question:
SecurityChecker { public static void checkAnyTeam() { if (!SecurityContextHolder.get().teamId().isPresent()) { throw new CredentialsMissingException(); } }  static void checkUser(final String userId); static void checkTeam(final String teamId); static void checkAnyUser(); static void checkAnyTeam();  }### Answer:
@Test public void shouldPassAnyTeamCheck_withTeamIdInSecurityContext() { when(mockSecurityContext.teamId()).thenReturn(Optional.of(randomId())); Exception thrownException = null; try { SecurityChecker.checkAnyTeam(); } catch (final Exception e) { thrownException = e; } assertNull(thrownException); }
@Test public void shouldNotPassAnyTeamCheck_withNoTeamIdInSecurityContext() { when(mockSecurityContext.teamId()).thenReturn(Optional.empty()); CredentialsMissingException thrownException = null; try { SecurityChecker.checkAnyTeam(); } catch (final CredentialsMissingException e) { thrownException = e; } assertNotNull(thrownException); }