Search in sources :

Example 1 with AuthenticationModuleConfig

use of org.jboss.pnc.common.json.moduleconfig.AuthenticationModuleConfig in project pnc by project-ncl.

the class ModuleConfigJsonTest method deserializationTest.

@Test
public void deserializationTest() throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    PncConfigProvider<AuthenticationModuleConfig> pncProvider = new PncConfigProvider<>(AuthenticationModuleConfig.class);
    pncProvider.registerProvider(mapper);
    mapper.registerSubtypes(PNCModuleGroup.class);
    ModuleConfigJson config = mapper.readValue(loadConfig("testConfigNoSpaces.json"), ModuleConfigJson.class);
    assertNotNull(config);
    assertEquals(1, config.getConfigs().size());
    PNCModuleGroup group = (PNCModuleGroup) config.getConfigs().get(0);
    assertEquals(2, group.getConfigs().size());
}
Also used : AuthenticationModuleConfig(org.jboss.pnc.common.json.moduleconfig.AuthenticationModuleConfig) PncConfigProvider(org.jboss.pnc.common.json.moduleprovider.PncConfigProvider) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 2 with AuthenticationModuleConfig

use of org.jboss.pnc.common.json.moduleconfig.AuthenticationModuleConfig in project pnc by project-ncl.

the class ModuleConfigJsonTest method serializationTest.

@Test
public void serializationTest() throws IOException {
    ModuleConfigJson moduleConfigJson = new ModuleConfigJson("pnc-config");
    JenkinsBuildDriverModuleConfig jenkinsBuildDriverModuleConfig = new JenkinsBuildDriverModuleConfig("user", "pass");
    IndyRepoDriverModuleConfig indyRepoDriverModuleConfig = new IndyRepoDriverModuleConfig();
    indyRepoDriverModuleConfig.setBuildRepositoryAllowSnapshots(true);
    indyRepoDriverModuleConfig.setDefaultRequestTimeout(100);
    List<String> ignoredPatternsMaven = new ArrayList<>(2);
    ignoredPatternsMaven.add(".*/maven-metadata\\.xml$");
    ignoredPatternsMaven.add(".*\\.sha1$");
    IgnoredPatterns ignoredPatterns = new IgnoredPatterns();
    ignoredPatterns.setMaven(ignoredPatternsMaven);
    IgnoredPathPatterns ignoredPathPatterns = new IgnoredPathPatterns();
    ignoredPathPatterns.setPromotion(ignoredPatterns);
    indyRepoDriverModuleConfig.setIgnoredPathPatterns(ignoredPathPatterns);
    PNCModuleGroup pncGroup = new PNCModuleGroup();
    pncGroup.addConfig(jenkinsBuildDriverModuleConfig);
    pncGroup.addConfig(indyRepoDriverModuleConfig);
    moduleConfigJson.addConfig(pncGroup);
    ObjectMapper mapper = new ObjectMapper();
    PncConfigProvider<AuthenticationModuleConfig> pncProvider = new PncConfigProvider<>(AuthenticationModuleConfig.class);
    pncProvider.registerProvider(mapper);
    ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
    mapper.writeValue(byteOutStream, moduleConfigJson);
    assertEquals(loadConfig("testConfigNoSpaces.json"), byteOutStream.toString());
}
Also used : JenkinsBuildDriverModuleConfig(org.jboss.pnc.common.json.moduleconfig.JenkinsBuildDriverModuleConfig) IndyRepoDriverModuleConfig(org.jboss.pnc.common.json.moduleconfig.IndyRepoDriverModuleConfig) ArrayList(java.util.ArrayList) AuthenticationModuleConfig(org.jboss.pnc.common.json.moduleconfig.AuthenticationModuleConfig) PncConfigProvider(org.jboss.pnc.common.json.moduleprovider.PncConfigProvider) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IgnoredPatterns(org.jboss.pnc.common.json.moduleconfig.IndyRepoDriverModuleConfig.IgnoredPatterns) IgnoredPathPatterns(org.jboss.pnc.common.json.moduleconfig.IndyRepoDriverModuleConfig.IgnoredPathPatterns) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 AuthenticationModuleConfig (org.jboss.pnc.common.json.moduleconfig.AuthenticationModuleConfig)2 PncConfigProvider (org.jboss.pnc.common.json.moduleprovider.PncConfigProvider)2 Test (org.junit.Test)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ArrayList (java.util.ArrayList)1 IndyRepoDriverModuleConfig (org.jboss.pnc.common.json.moduleconfig.IndyRepoDriverModuleConfig)1 IgnoredPathPatterns (org.jboss.pnc.common.json.moduleconfig.IndyRepoDriverModuleConfig.IgnoredPathPatterns)1 IgnoredPatterns (org.jboss.pnc.common.json.moduleconfig.IndyRepoDriverModuleConfig.IgnoredPatterns)1 JenkinsBuildDriverModuleConfig (org.jboss.pnc.common.json.moduleconfig.JenkinsBuildDriverModuleConfig)1