Search in sources :

Example 51 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration in project bacon by project-ncl.

the class BuildConfigMappingTest method testBuildCategorySet.

@Test
void testBuildCategorySet() {
    Map<String, String> parameters = new HashMap<>();
    parameters.put("BUILD_CATEGORY", "SERVICE");
    BuildConfiguration buildConfiguration = BuildConfiguration.builder().parameters(parameters).build();
    BuildConfigMapping.setBuildConfigFieldsBasedOnParameters(buildConfiguration, buildConfig);
    assertEquals("SERVICE", buildConfig.getBuildCategory());
    // make sure no other parameters are set
    assertTrue(buildConfig.getAlignmentParameters().size() == 0);
    assertNull(buildConfig.getBuildPodMemory());
    assertNull(buildConfig.getPigYamlMetadata());
    assertNull(buildConfig.getBrewBuildName());
    assertTrue(buildConfig.getExtraRepositories().size() == 0);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Example 52 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration in project bacon by project-ncl.

the class BuildConfigMappingTest method testExtraRepositoriesSet.

@Test
void testExtraRepositoriesSet() {
    Map<String, String> parameters = new HashMap<>();
    parameters.put("EXTRA_REPOSITORIES", "hello\nworld");
    BuildConfiguration buildConfiguration = BuildConfiguration.builder().parameters(parameters).build();
    BuildConfigMapping.setBuildConfigFieldsBasedOnParameters(buildConfiguration, buildConfig);
    assertTrue(buildConfig.getExtraRepositories().contains("hello"));
    assertTrue(buildConfig.getExtraRepositories().contains("world"));
    assertTrue(buildConfig.getExtraRepositories().size() == 2);
    // make sure no other parameters are set
    assertTrue(buildConfig.getAlignmentParameters().size() == 0);
    assertNull(buildConfig.getBuildPodMemory());
    assertNull(buildConfig.getBuildCategory());
    assertNull(buildConfig.getPigYamlMetadata());
    assertNull(buildConfig.getBrewBuildName());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Example 53 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration in project bacon by project-ncl.

the class BuildConfigMappingTest method testEntireMapping.

@Test
void testEntireMapping() {
    EasyRandom easyRandom = new EasyRandom();
    BuildConfiguration buildConfiguration = easyRandom.nextObject(BuildConfiguration.class);
    BuildConfig bc = BuildConfigMapping.toBuildConfig(buildConfiguration);
    assertEquals(buildConfiguration.getName(), bc.getName());
    assertEquals(buildConfiguration.getProject().getName(), bc.getProject());
    assertEquals(buildConfiguration.getBuildScript(), bc.getBuildScript());
    assertEquals(buildConfiguration.getScmRepository().getExternalUrl(), bc.getScmUrl());
    assertEquals(buildConfiguration.getScmRevision(), bc.getScmRevision());
    assertEquals(buildConfiguration.getDescription(), bc.getDescription());
    assertEquals(buildConfiguration.getEnvironment().getSystemImageId(), bc.getSystemImageId());
    assertEquals(buildConfiguration.getDependencies().keySet(), new HashSet(bc.getDependencies()));
    assertEquals(buildConfiguration.getBrewPullActive(), bc.getBrewPullActive());
    assertEquals(buildConfiguration.getBuildType().toString(), bc.getBuildType());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfig(org.jboss.pnc.bacon.pig.impl.config.BuildConfig) EasyRandom(org.jeasy.random.EasyRandom) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 54 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration in project bacon by project-ncl.

the class BuildConfigMappingTest method testBrewBuildNameSet.

@Test
void testBrewBuildNameSet() {
    Map<String, String> parameters = new HashMap<>();
    parameters.put("BREW_BUILD_NAME", "testme");
    BuildConfiguration buildConfiguration = BuildConfiguration.builder().parameters(parameters).build();
    BuildConfigMapping.setBuildConfigFieldsBasedOnParameters(buildConfiguration, buildConfig);
    assertEquals("testme", buildConfig.getBrewBuildName());
    // make sure no other parameters are set
    assertTrue(buildConfig.getAlignmentParameters().size() == 0);
    assertNull(buildConfig.getBuildPodMemory());
    assertNull(buildConfig.getBuildCategory());
    assertNull(buildConfig.getPigYamlMetadata());
    assertTrue(buildConfig.getExtraRepositories().size() == 0);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Example 55 with BuildConfiguration

use of org.jboss.pnc.dto.BuildConfiguration in project pnc by project-ncl.

the class DeserializerTest method testDTOAsRefDeserialization2.

@Test
public void testDTOAsRefDeserialization2() throws IOException {
    String json = "{" + "      \"name\":\"mtest190826\"," + "      \"environment\":{" + "         \"id\":8," + "         \"name\":\"OpenJDK 1.8.0; Mvn 3.5.2\"," + "         \"description\":\"OpenJDK 1.8.0; Mvn 3.5.2\"," + "         \"systemImageRepositoryUrl\":\"docker-registry-default.cloud.registry.upshift.redhat.com\"," + "         \"systemImageId\":\"newcastle/builder-rhel-7-j8-mvn3.5.2:latest\"," + "         \"attributes\":{" + "            \"JDK\":\"1.8.0\"," + "            \"MAVEN\":\"3.5.2\"," + "            \"OS\":\"Linux\"" + "         }," + "         \"systemImageType\":\"DOCKER_IMAGE\"," + "         \"deprecated\":false" + "      }," + "      \"buildType\":\"MVN\"," + "      \"buildScript\":\"mvn clean deploy\"," + "      \"parameters\":{      }," + "      \"dependencies\":{}," + "      \"scmRevision\":\"master\"," + "      \"project\":{" + "         \"id\":122," + "         \"name\":\"mtest180719\"," + "         \"description\":null," + "         \"issueTrackerUrl\":null," + "         \"projectUrl\":null," + "         \"buildConfigs\":{" + "            \"134\": {" + "               \"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\"" + "            }" + "         }" + "      }," + "      \"groupConfigs\":{}" + "   }";
    ObjectMapper mapper = provider.getContext(null);
    BuildConfiguration obj = mapper.readValue(json, BuildConfiguration.class);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)90 Test (org.junit.Test)65 ContainerTest (org.jboss.pnc.test.category.ContainerTest)45 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)31 HashMap (java.util.HashMap)17 InSequence (org.jboss.arquillian.junit.InSequence)17 Build (org.jboss.pnc.dto.Build)13 GroupBuild (org.jboss.pnc.dto.GroupBuild)12 SCMRepository (org.jboss.pnc.dto.SCMRepository)10 Test (org.junit.jupiter.api.Test)10 BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)9 Instant (java.time.Instant)8 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)7 BuildStatus (org.jboss.pnc.enums.BuildStatus)7 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 ArrayList (java.util.ArrayList)4 BuildConfigurationRevision (org.jboss.pnc.dto.BuildConfigurationRevision)4 HashSet (java.util.HashSet)3