@Test
public void testGetExpirationTime() throws Throwable {

    BasicAuthenticationService basicAuthenticationService = new BasicAuthenticationService();
    AuthenticationRequest authRequest = new AuthenticationRequest();
    authRequest.sessionExpirationSeconds = null;
    long expectedSec = Instant.now().getEpochSecond() + BasicAuthenticationService.AUTH_TOKEN_EXPIRATION_SECONDS;
    long result = basicAuthenticationService.getExpirationTime(authRequest);
    assertEquals(expectedSec, TimeUnit.MICROSECONDS.toSeconds(result));
    authRequest.sessionExpirationSeconds = (long) 0;
    result = basicAuthenticationService.getExpirationTime(authRequest);
    expectedSec = Instant.now().getEpochSecond();
    assertEquals(expectedSec, TimeUnit.MICROSECONDS.toSeconds(result));
    authRequest.sessionExpirationSeconds = (long) -1;
    result = basicAuthenticationService.getExpirationTime(authRequest);
    expectedSec = Instant.now().getEpochSecond() - 1;
    assertEquals(expectedSec, TimeUnit.MICROSECONDS.toSeconds(result));
    authRequest.sessionExpirationSeconds = UPPER_SESSION_LIMIT - 1;
    result = basicAuthenticationService.getExpirationTime(authRequest);
    expectedSec = Instant.now().getEpochSecond() + UPPER_SESSION_LIMIT - 1;
    assertEquals(expectedSec, TimeUnit.MICROSECONDS.toSeconds(result));
    authRequest.sessionExpirationSeconds = UPPER_SESSION_LIMIT;
    result = basicAuthenticationService.getExpirationTime(authRequest);
    expectedSec = Instant.now().getEpochSecond() + UPPER_SESSION_LIMIT;
    assertEquals(expectedSec, TimeUnit.MICROSECONDS.toSeconds(result));
    authRequest.sessionExpirationSeconds = UPPER_SESSION_LIMIT + 1;
    result = basicAuthenticationService.getExpirationTime(authRequest);
    expectedSec = Instant.now().getEpochSecond() + UPPER_SESSION_LIMIT;
    assertEquals(expectedSec, TimeUnit.MICROSECONDS.toSeconds(result));
}