use of org.jboss.pnc.dto.ProjectRef in project pnc by project-ncl.
the class DeserializerTest method testDTOAsRefDeserialization3.
@Test
public void testDTOAsRefDeserialization3() throws IOException {
String json = "{" + " \"id\":122," + " \"name\":\"mtest180719\"," + " \"description\":null," + " \"issueTrackerUrl\":null," + " \"projectUrl\":null," + " \"buildConfigs\":[" + " {" + " \"id\":134," + " \"name\":\"mtest1907252\"," + " \"description\":null," + " \"buildScript\":\"mvn clean deploy\"," + " \"scmRevision\":\"master\"," + " \"creationTime\":\"2019-07-25T09:32:44.206Z\"," + " \"modificationTime\":\"2019-08-14T11:37:51.355Z\"," + " \"archived\":false," + " \"buildType\":\"MVN\"" + " }" + " ]" + " }";
ObjectMapper mapper = provider.getContext(null);
ProjectRef obj = mapper.readValue(json, ProjectRef.class);
}
use of org.jboss.pnc.dto.ProjectRef in project pnc by project-ncl.
the class RemoteBuildTest method getOrCreateBuildConfiguration.
private BuildConfiguration getOrCreateBuildConfiguration(String buildConfigurationName, String buildScript, String scmRevision, Map<String, String> genericParameters, String projectId, String repositoryConfigurationId, String buildEnvironmentId) throws RemoteResourceException {
RemoteCollection<BuildConfiguration> existing = buildConfigurationRestClient.getAll(Optional.empty(), Optional.of("name==" + buildConfigurationName));
Iterator<BuildConfiguration> it = existing.iterator();
if (!it.hasNext()) {
ProjectRef project = ProjectRef.refBuilder().id(projectId).build();
SCMRepository repository = SCMRepository.builder().id(repositoryConfigurationId).build();
Environment environment = Environment.builder().id(buildEnvironmentId).build();
BuildConfiguration buildConfiguration = BuildConfiguration.builder().name(buildConfigurationName).project(project).scmRepository(repository).scmRevision(scmRevision).environment(environment).buildScript(buildScript).parameters(genericParameters).build();
BuildConfiguration created = buildConfigurationRestClient.createNew(buildConfiguration);
return created;
} else {
return it.next();
}
}
use of org.jboss.pnc.dto.ProjectRef in project pnc by project-ncl.
the class BuildBCRevisionFetcher method mapFromAuditedBuildConfig.
@BeforeMapping
public void mapFromAuditedBuildConfig(BuildRecord build, @MappingTarget Build.Builder dtoBuilder) {
Integer id = build.getBuildConfigurationId();
Integer revision = build.getBuildConfigurationRev();
// If somebody before us already set the BCA we don't need to query it from DB again
BuildConfigurationAudited bca = build.getBuildConfigurationAudited();
if (bca == null) {
bca = bcAuditedRepository.queryById(new IdRev(id, revision));
}
BuildConfigurationRevisionRef bcRevision = bcRevisionMapper.toRef(bca);
ProjectRef project = projectMapper.toRef(bca.getProject());
Environment environment = environmentMapper.toRef(bca.getBuildEnvironment());
SCMRepository scmRepository = scmRepositoryMapper.toRef(bca.getRepositoryConfiguration());
dtoBuilder.buildConfigRevision(bcRevision);
dtoBuilder.project(project);
dtoBuilder.environment(environment);
dtoBuilder.scmRepository(scmRepository);
}
use of org.jboss.pnc.dto.ProjectRef in project pnc by project-ncl.
the class BuildConfigurationPatchTest method shouldReplaceRef.
@Test
public void shouldReplaceRef() throws PatchBuilderException, IOException, JsonPatchException {
ProjectRef project = ProjectRef.refBuilder().id("1").name("Project 1").build();
ProjectRef newProject = ProjectRef.refBuilder().id("2").name("Project 2").build();
BuildConfiguration buildConfiguration = BuildConfiguration.builder().id("1").name("BC 1").project(project).build();
String patchString = new BuildConfigurationPatchBuilder().replaceProject(newProject).replaceName("Build Configuration 1").getJsonPatch();
BuildConfiguration updatedBuildConfiguration = applyPatch(buildConfiguration, patchString);
Assert.assertEquals(newProject, updatedBuildConfiguration.getProject());
}
use of org.jboss.pnc.dto.ProjectRef in project bacon by project-ncl.
the class PncEntitiesImporter method generatePncBuildConfig.
/**
* @param buildConfig PiG buildconfig to generate
* @param existing if present, we'll use it as the buildconfig to modify if null: we'll use a fresh buildconfig
* object
*
* @return BuildConfiguration generated
*/
private BuildConfiguration generatePncBuildConfig(BuildConfig buildConfig, BuildConfiguration existing) {
ProjectRef project = getOrGenerateProject(buildConfig.getProject());
SCMRepository repository = getOrGenerateRepository(buildConfig);
Environment environment = Environment.builder().id(buildConfig.getEnvironmentId()).build();
BuildConfiguration.Builder builder = BuildConfiguration.builder();
if (existing != null) {
builder = existing.toBuilder();
}
return builder.productVersion(version).parameters(buildConfig.getGenericParameters(null, false)).name(buildConfig.getName()).project(project).environment(environment).scmRepository(repository).scmRevision(buildConfig.getScmRevision()).buildScript(buildConfig.getBuildScript()).buildType(BuildType.valueOf(buildConfig.getBuildType())).brewPullActive(buildConfig.getBrewPullActive()).build();
}
Aggregations