@Test
public void authenticateShouldReturnNullWhenNoMatchingUserExists() throws AuthenticationException {

    final Principal principalMock = mock(Principal.class);
    when(principalMock.getName())
            .thenReturn("username");
    final String token = new JsonWebToken().createToken(principalMock, null, IdentityProvider.LOCAL);
    final ContainerRequest containerRequestMock = mock(ContainerRequest.class);
    when(containerRequestMock.getRequestHeader(eq(HttpHeaders.AUTHORIZATION)))
            .thenReturn(Collections.singletonList("Bearer " + token));
    final JwtAuthenticationService authService = new JwtAuthenticationService(containerRequestMock);
    assertThat(authService.authenticate()).isNull();
}