use of org.jboss.pnc.dto.Environment in project bacon by project-ncl.
the class PigTest method shouldCreateProduct.
@Test
@Order(1)
void shouldCreateProduct() throws IOException {
final Path configFile = CONFIG_LOCATION;
replaceSuffixInConfigFile(configFile.resolve("build-config.yaml"));
final Product product = Product.builder().id(UNIVERSAL_ID).name(PRODUCT_NAME).abbreviation(PRODUCT_ABBREVIATION).build();
final ProductVersion productVersion = ProductVersion.builder().id(UNIVERSAL_ID).version(VERSION).product(product).build();
final ProductMilestone productMilestone = ProductMilestone.builder().id(UNIVERSAL_ID).productVersion(productVersion).version(MILESTONE).build();
final ProductVersion productVersionWithCurrentMilestone = productVersion.toBuilder().currentProductMilestone(productMilestone).build();
final GroupConfiguration groupConfig = GroupConfiguration.builder().id(UNIVERSAL_ID).name(GROUP_NAME).productVersion(productVersionWithCurrentMilestone).build();
final Project project = Project.builder().id(UNIVERSAL_ID).name(PROJECT_NAME).build();
final SCMRepository scmRepository = SCMRepository.builder().id(UNIVERSAL_ID).internalUrl(SCM_URL).preBuildSyncEnabled(true).build();
final Environment environment = Environment.builder().id(UNIVERSAL_ID).deprecated(false).build();
final BuildConfiguration buildConfig = BuildConfiguration.builder().id(UNIVERSAL_ID).name(BC_NAME).buildScript(BUILD_SCRIPT).scmRevision(SCM_REVISION).creationTime(Instant.now()).modificationTime(Instant.now()).scmRepository(scmRepository).environment(environment).project(project).productVersion(productVersionWithCurrentMilestone).build();
final GroupConfiguration groupConfigWithBuildConfig = groupConfig.toBuilder().buildConfigs(Collections.singletonMap(UNIVERSAL_ID, buildConfig)).build();
wmock.list(PRODUCT, new Page<Product>());
wmock.creation(PRODUCT, product);
wmock.list(PRODUCT_VERSIONS.apply(UNIVERSAL_ID), new Page<ProductVersion>());
wmock.creation(PRODUCT_VERSION, productVersion);
wmock.list(PRODUCT_VERSION_MILESTONES.apply(UNIVERSAL_ID), new Page<ProductMilestone>());
wmock.creation(PRODUCT_MILESTONE, productMilestone);
wmock.update(PRODUCT_VERSION, productVersion, productVersionWithCurrentMilestone);
wmock.list(GROUP_CONFIG, new Page<GroupConfiguration>());
wmock.creation(GROUP_CONFIG, groupConfig);
wmock.list(GROUP_CONFIG_BUILD_CONFIGS.apply(UNIVERSAL_ID), new Page<BuildConfiguration>());
wmock.list(BUILD_CONFIG, new Page<BuildConfiguration>());
wmock.list(PROJECT, new Page<Project>());
wmock.creation(PROJECT, project);
wmock.list(SCM_REPOSITORY, new Page<SCMRepository>());
wmock.creation(SCM_REPOSITORY_CREATE, RepositoryCreationResponse.builder().repository(scmRepository).build());
wmock.get(ENVIRONMENT, environment);
wmock.creation(BUILD_CONFIG, buildConfig);
wmock.list(BUILD_CONFIG_DEPENDENCIES.apply(UNIVERSAL_ID), new Page<BuildConfiguration>());
wmock.get(BUILD_CONFIG, buildConfig);
wmock.creation(BUILD_CONFIG, buildConfig);
wmock.scenario("add BC to GC").getEntity(GROUP_CONFIG, groupConfig).when().post(GROUP_CONFIG_BUILD_CONFIGS.apply(UNIVERSAL_ID)).then().getEntity(GROUP_CONFIG, groupConfigWithBuildConfig);
ExecutionResult output = executeAndGetResult("pig", "configure", configFile.toString());
assertThat(output.getOutput()).contains("name: \"Product Foobar " + SUFFIX + "\"");
}
use of org.jboss.pnc.dto.Environment in project bacon by project-ncl.
the class PncEntitiesImporter method checkForDeprecatedEnvironments.
private void checkForDeprecatedEnvironments(List<BuildConfigData> configs) {
log.debug("Checking for deprecated environments");
Set<String> fetched = new HashSet<>();
Set<String> deprecated = new HashSet<>();
for (BuildConfigData config : configs) {
String envId = config.getEnvironmentId();
// skip if we already downloaded the environment
if (fetched.contains(envId)) {
if (deprecated.contains(envId)) {
log.warn("BuildConfig with the name: " + config.getName() + " is using deprecated environment. (NOTE: changing to updated environment may cause rebuilds)");
}
continue;
}
Environment env = getEnvironment(envId);
fetched.add(envId);
if (env.isDeprecated()) {
log.warn("BuildConfig with the name: " + config.getName() + " is using deprecated environment. (NOTE: changing to updated environment may cause rebuilds)");
deprecated.add(envId);
}
}
}
use of org.jboss.pnc.dto.Environment in project pnc by project-ncl.
the class EnvironmentEndpointTest method shouldSaveEnvironmentAndDeprecateOldOnes.
@Test
@InSequence(30)
public void shouldSaveEnvironmentAndDeprecateOldOnes() throws ClientException {
EnvironmentClient client = new EnvironmentClient(RestClientConfiguration.asSystem());
Environment.Builder environmentBuilder = Environment.builder().name("OpenJDK 14.0; Mvn 3.6.5").description("OpenJDK 14.0; Mvn 3.6.5").systemImageRepositoryUrl("quay.io/rh-newcastle").systemImageType(SystemImageType.DOCKER_IMAGE);
Environment envVers10 = client.createNew(environmentBuilder.systemImageId("builder-rhel-7-j14-mvn3.6.5:1.0").build());
String envVers10Id = envVers10.getId();
Environment envVers10RetrievedFromDB = client.getSpecific(envVers10Id);
Assertions.assertThat(envVers10RetrievedFromDB.getName()).isEqualTo("OpenJDK 14.0; Mvn 3.6.5");
Assertions.assertThat(envVers10RetrievedFromDB.getSystemImageId()).isEqualTo("builder-rhel-7-j14-mvn3.6.5:1.0");
Assertions.assertThat(envVers10RetrievedFromDB.isDeprecated()).isEqualTo(false);
Environment envVers11 = client.createNew(environmentBuilder.systemImageId("builder-rhel-7-j14-mvn3.6.5:1.1").build());
String envVers11Id = envVers11.getId();
Environment envVers11RetrievedFromDB = client.getSpecific(envVers11Id);
Assertions.assertThat(envVers11RetrievedFromDB.getName()).isEqualTo("OpenJDK 14.0; Mvn 3.6.5");
Assertions.assertThat(envVers11RetrievedFromDB.getSystemImageId()).isEqualTo("builder-rhel-7-j14-mvn3.6.5:1.1");
Assertions.assertThat(envVers11RetrievedFromDB.isDeprecated()).isEqualTo(false);
Environment envVers12 = client.createNew(environmentBuilder.systemImageId("builder-rhel-7-j14-mvn3.6.5:1.2").build());
String envVers12Id = envVers12.getId();
Environment envVers12RetrievedFromDB = client.getSpecific(envVers12Id);
Assertions.assertThat(envVers12RetrievedFromDB.getName()).isEqualTo("OpenJDK 14.0; Mvn 3.6.5");
Assertions.assertThat(envVers12RetrievedFromDB.getSystemImageId()).isEqualTo("builder-rhel-7-j14-mvn3.6.5:1.2");
Assertions.assertThat(envVers12RetrievedFromDB.isDeprecated()).isEqualTo(false);
envVers10RetrievedFromDB = client.getSpecific(envVers10Id);
envVers11RetrievedFromDB = client.getSpecific(envVers11Id);
Assertions.assertThat(envVers12RetrievedFromDB.getName()).isEqualTo(envVers10RetrievedFromDB.getName());
Assertions.assertThat(envVers12RetrievedFromDB.getName()).isEqualTo(envVers11RetrievedFromDB.getName());
Assertions.assertThat(envVers12RetrievedFromDB.isDeprecated()).isEqualTo(false);
Assertions.assertThat(envVers11RetrievedFromDB.isDeprecated()).isEqualTo(true);
Assertions.assertThat(envVers10RetrievedFromDB.isDeprecated()).isEqualTo(true);
}
use of org.jboss.pnc.dto.Environment in project pnc by project-ncl.
the class EnvironmentEndpointTest method testGetSpecificEnvironment.
@Test
@InSequence(20)
public void testGetSpecificEnvironment() throws ClientException {
EnvironmentClient client = new EnvironmentClient(RestClientConfiguration.asAnonymous());
Environment environment = client.getSpecific(environmentId);
// from DatabaseDataInitializer
assertThat(environment.getName()).isEqualTo("Demo Environment 1");
}
use of org.jboss.pnc.dto.Environment in project pnc by project-ncl.
the class EnvironmentEndpointTest method testGetAllEnvironments.
@Test
@InSequence(10)
public void testGetAllEnvironments() throws RemoteResourceException {
EnvironmentClient client = new EnvironmentClient(RestClientConfiguration.asAnonymous());
RemoteCollection<Environment> all = client.getAll();
// from DatabaseDataInitializer
assertThat(all).hasSize(2);
}
Aggregations