### Question:
DefaultSecurityContext implements SecurityContext { @Override public Optional<String> agentUserId() { return agentUserId; } DefaultSecurityContext(final String userId, final String teamId, final String agentUserId,
            final String appId);  DefaultSecurityContext(final String userId, final String teamId);  DefaultSecurityContext(final String userId); @Override @Deprecated String principal(); @Override Optional<String> userId(); @Override Optional<String> teamId(); @Override Optional<String> agentUserId(); @Override Optional<String> appId();  }### Answer:
@Test public void shouldReturnAgentUserId_withAgentInContext() { final String userId = randomId(); final String teamId = randomBoolean() ? null : randomId(); final String agentUserId = randomId(); final String appId = randomBoolean() ? null : randomId(); final DefaultSecurityContext context = new DefaultSecurityContext(userId, teamId, agentUserId, appId); final Optional<String> returnedAgentUserId = context.agentUserId(); assertEquals(Optional.of(agentUserId), returnedAgentUserId); }
@Test public void shouldReturnEmptyAgentUserId_withNoAgentInContext() { final String userId = randomId(); final String teamId = randomBoolean() ? null : randomId(); final DefaultSecurityContext context = new DefaultSecurityContext(userId, teamId); assertEquals(Optional.empty(), context.agentUserId()); }