use of org.jboss.pnc.dto.User in project pnc by project-ncl.
the class BuildEndpointTest method shouldFilterByBuildConfigurationNameAndUserId.
@Test
public void shouldFilterByBuildConfigurationNameAndUserId() throws Exception {
BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
String buildConfigName = DatabaseDataInitializer.PNC_PROJECT_BUILD_CFG_ID;
String username = "pnc-admin";
String rsql = "user.username==" + username;
BuildsFilterParameters filter = new BuildsFilterParameters();
filter.setBuildConfigName(buildConfigName);
List<Build> builds = new ArrayList<>(client.getAll(filter, null, Optional.empty(), Optional.of(rsql)).getAll());
assertThat(builds).hasSize(2);
assertThat(builds.stream().map(Build::getBuildConfigRevision).map(BuildConfigurationRevisionRef::getName).allMatch(name -> name.equals(buildConfigName)));
assertThat(builds.stream().map(Build::getUser).map(User::getUsername).allMatch(name -> name.equals(username)));
}
use of org.jboss.pnc.dto.User 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();
}
use of org.jboss.pnc.dto.User 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);
}
use of org.jboss.pnc.dto.User in project pnc by project-ncl.
the class BuildStatusChangedTest method getBuild.
private Build getBuild() {
ProjectRef projectRef = ProjectRef.refBuilder().id("1").name("A").description("desc").projectUrl("url1").issueTrackerUrl("url2").build();
SCMRepository scmRepository = SCMRepository.builder().id("1").internalUrl("url1").externalUrl("url2").preBuildSyncEnabled(true).build();
Environment buildEnvironment = Environment.builder().id("1").name("jdk8").description("desc").systemImageRepositoryUrl("url").systemImageId("11").systemImageType(SystemImageType.DOCKER_IMAGE).deprecated(true).build();
User user = User.builder().id("1").username("user").build();
BuildConfigurationRevisionRef buildConfigurationRevisionRef = BuildConfigurationRevisionRef.refBuilder().id("1").rev(1).name("name").buildScript("true").scmRevision("awqs21").build();
return Build.builder().project(projectRef).scmRepository(scmRepository).environment(buildEnvironment).user(user).buildConfigRevision(buildConfigurationRevisionRef).status(BuildStatus.BUILDING).buildContentId("build-42").temporaryBuild(true).build();
}
use of org.jboss.pnc.dto.User in project pnc by project-ncl.
the class ArtifactProviderImpl method store.
@Override
@RolesAllowed(SYSTEM_USER)
public org.jboss.pnc.dto.Artifact store(org.jboss.pnc.dto.Artifact restEntity) throws DTOValidationException {
org.jboss.pnc.model.User currentUser = userService.currentUser();
User user = userMapper.toDTO(currentUser);
Instant now = Instant.now();
return super.store(restEntity.toBuilder().creationUser(user).modificationUser(user).creationTime(now).modificationTime(now).build());
}
Aggregations