Search in sources :

Example 1 with UserClient

use of org.jboss.pnc.client.UserClient in project pnc by project-ncl.

the class UserEndpointTest method testGetUser.

@Test
public void testGetUser() throws ClientException {
    // when
    UserClient client = new UserClient(RestClientConfiguration.asUser());
    User user = client.getCurrentUser();
    // then
    assertThat(user).isNotNull();
    assertThat(user.getUsername()).isNotNull();
    assertThat(user.getId()).isNotNull();
    // when
    client = new UserClient(RestClientConfiguration.asSystem());
    user = client.getCurrentUser();
    // then
    assertThat(user).isNotNull();
    assertThat(user.getUsername()).isNotNull();
    assertThat(user.getId()).isNotNull();
}
Also used : UserClient(org.jboss.pnc.client.UserClient) User(org.jboss.pnc.dto.User) Test(org.junit.Test) ContainerTest(org.jboss.pnc.test.category.ContainerTest)

Example 2 with UserClient

use of org.jboss.pnc.client.UserClient in project pnc by project-ncl.

the class UserEndpointTest method testGetAllBuilds.

@Test
public void testGetAllBuilds() throws ClientException {
    UserClient client = new UserClient(RestClientConfiguration.asUser());
    BuildClient buildClient = new BuildClient(RestClientConfiguration.asAnonymous());
    BuildsFilterParameters params = new BuildsFilterParameters();
    params.setLatest(false);
    params.setRunning(false);
    RemoteCollection<Build> remoteBuilds = buildClient.getAllByStatusAndLogContaining(BuildStatus.SUCCESS, "fox");
    User user = remoteBuilds.iterator().next().getUser();
    RemoteCollection<Build> builds = client.getBuilds(user.getId(), params);
    assertThat(builds).isNotNull();
    assertThat(builds.size()).isGreaterThanOrEqualTo(1);
}
Also used : UserClient(org.jboss.pnc.client.UserClient) User(org.jboss.pnc.dto.User) Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) BuildsFilterParameters(org.jboss.pnc.rest.api.parameters.BuildsFilterParameters) Test(org.junit.Test) ContainerTest(org.jboss.pnc.test.category.ContainerTest)

Aggregations

UserClient (org.jboss.pnc.client.UserClient)2 User (org.jboss.pnc.dto.User)2 ContainerTest (org.jboss.pnc.test.category.ContainerTest)2 Test (org.junit.Test)2 BuildClient (org.jboss.pnc.client.BuildClient)1 Build (org.jboss.pnc.dto.Build)1 BuildsFilterParameters (org.jboss.pnc.rest.api.parameters.BuildsFilterParameters)1