### Question:
TeamAspect { @Before("@annotation(team)") public void checkTeamInSecurityContext(final Team team) { if (!team.optional()) { SecurityChecker.checkAnyTeam(); } }  @Before("@annotation(team)") void checkTeamInSecurityContext(final Team team);  }### Answer:
@Test public void shouldCheckForAnyTeamInSecurityContext_withMandatoryTeam() { mockStatic(SecurityChecker.class); final TeamAspect aspect = new TeamAspect(); final Team mockTeam = mock(Team.class); when(mockTeam.optional()).thenReturn(false); aspect.checkTeamInSecurityContext(mockTeam); verifyStatic(SecurityChecker.class); SecurityChecker.checkAnyTeam(); }
@Test public void shouldNotCheckForAnyTeamInSecurityContext_withOptionalTeam() { mockStatic(SecurityChecker.class); final TeamAspect aspect = new TeamAspect(); final Team mockTeam = mock(Team.class); when(mockTeam.optional()).thenReturn(true); aspect.checkTeamInSecurityContext(mockTeam); verifyZeroInteractions(SecurityChecker.class); }