Search in sources :

Example 1 with TDUser

use of com.treasuredata.client.model.TDUser in project td-client-java by treasure-data.

the class TestTDClient method listUsers.

@Test
public void listUsers() throws Exception {
    TDUserList userList = client.listUsers();
    for (TDUser user : userList.getUsers()) {
        logger.trace("user: {}", user);
    }
    logger.trace("{} user(s)", userList.getUsers().size());
}
Also used : TDUserList(com.treasuredata.client.model.TDUserList) TDUser(com.treasuredata.client.model.TDUser) Test(org.junit.Test)

Example 2 with TDUser

use of com.treasuredata.client.model.TDUser in project td-client-java by treasure-data.

the class TestTDClient method getUser.

@Test
public void getUser() throws Exception {
    TDUser user = client.getUser();
    logger.trace("user: {}", user);
}
Also used : TDUser(com.treasuredata.client.model.TDUser) Test(org.junit.Test)

Example 3 with TDUser

use of com.treasuredata.client.model.TDUser in project td-client-java by treasure-data.

the class TestTDClient method getUserMocked.

@Test
public void getUserMocked() throws Exception {
    client = mockClient();
    String expectedUserJson = "{\"id\":300,\"first_name\":\"Freda\",\"last_name\":\"Schuster\",\"email\":\"1elvie.hackett@example.com\",\"phone\":\"(650) 469-3644\",\"gravatar_url\":\"https://secure.gravatar.com/avatar/0e36aa63098c5a05b4dde8ac867eb116?size=80\",\"administrator\":true,\"created_at\":\"2016-06-09T01:34:59Z\",\"updated_at\":\"2016-06-09T01:34:59Z\",\"name\":\"Freda Schuster\",\"account_owner\":true}";
    TDUser expectedUser = ObjectMappers.compactMapper().readValue(expectedUserJson, TDUser.class);
    server.enqueue(new MockResponse().setBody(expectedUserJson));
    TDUser user = client.getUser();
    assertThat(user, is(expectedUser));
    RecordedRequest recordedRequest = server.takeRequest();
    assertThat(recordedRequest.getPath(), is("/v3/user/show"));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) TDUser(com.treasuredata.client.model.TDUser) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

TDUser (com.treasuredata.client.model.TDUser)3 Test (org.junit.Test)3 TDUserList (com.treasuredata.client.model.TDUserList)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)1