@Test
public void testGetUserToken() {

    ZMSClient client = createClient(systemAdminUser);
    ZMSRDLGeneratedClient c = Mockito.mock(ZMSRDLGeneratedClient.class);
    client.setZMSRDLGeneratedClient(c);
    UserToken token = new UserToken().setToken("token").setHeader("header");
    Mockito.when(c.getUserToken("user.johndoe", "service1", true))
            .thenReturn(token)
            .thenThrow(new ResourceException(403))
            .thenThrow(new NullPointerException());
    UserToken tokenCheck = client.getUserToken("user.johndoe", "service1", true);
    assertNotNull(tokenCheck);
    assertEquals(tokenCheck.getToken(), "token");
    try {
        client.getUserToken("user.johndoe", "service1", true);
        fail();
    } catch (ZMSClientException ex) {
        assertEquals(ex.getCode(), 403);
    }
    try {
        client.getUserToken("user.johndoe", "service1", true);
        fail();
    } catch (ZMSClientException ex) {
        assertEquals(ex.getCode(), 400);
    }
}