Search in sources :

Example 11 with ReleaseIdImpl

use of org.kie.util.maven.support.ReleaseIdImpl in project drools by kiegroup.

the class KieModuleRepoTest method storingNewProjectsCausesOldProjectEvictionFromKieModuleRepoTest.

@Test
public void storingNewProjectsCausesOldProjectEvictionFromKieModuleRepoTest() throws Exception {
    // setup
    setCacheSize(maxSizeGaCacheField, null, 3);
    // to test oldKieModules caching
    setCacheSize(maxSizeGaVersionsCacheField, null, 2);
    final ReleaseIdImpl[] releaseIds = new ReleaseIdImpl[7];
    for (int i = 0; i < releaseIds.length; ++i) {
        final String artifactId = Character.toString((char) ('A' + i));
        releaseIds[i] = new ReleaseIdImpl("org", artifactId, "1.0");
    }
    // store
    for (int i = 0; i < releaseIds.length; ++i) {
        final InternalKieModule kieModule = mock(InternalKieModule.class);
        when(kieModule.getReleaseId()).thenReturn(releaseIds[i]);
        when(kieModule.getCreationTimestamp()).thenReturn(10l);
        kieModuleRepo.store(kieModule);
        // store module 2 times to trigger storage to oldKieModules
        kieModuleRepo.store(kieModule);
    }
    final int numKieModules = countKieModules(kieModuleRepo.kieModules);
    assertEquals("KieModuleRepo cache should not grow past " + KieModuleRepo.MAX_SIZE_GA_CACHE + ": ", KieModuleRepo.MAX_SIZE_GA_CACHE, numKieModules);
    final int oldKieModulesSize = kieModuleRepo.oldKieModules.size();
    final int max = KieModuleRepo.MAX_SIZE_GA_CACHE * KieModuleRepo.MAX_SIZE_GA_VERSIONS_CACHE;
    assertTrue("KieModuleRepot old KieModules map is not limited in it's growth: " + oldKieModulesSize + " > " + max, oldKieModulesSize <= max);
}
Also used : ReleaseIdImpl(org.kie.util.maven.support.ReleaseIdImpl) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) Test(org.junit.Test)

Example 12 with ReleaseIdImpl

use of org.kie.util.maven.support.ReleaseIdImpl in project drools by kiegroup.

the class ReleaseIdTest method testResolveVersionPomModelNull.

@Test
public void testResolveVersionPomModelNull() {
    final ReleaseIdImpl releaseId = new ReleaseIdImpl("groupId", "artifactId", "${project.version}");
    Assertions.assertThat(releaseId.getVersion()).isEqualTo("${project.version}");
}
Also used : ReleaseIdImpl(org.kie.util.maven.support.ReleaseIdImpl) Test(org.junit.Test)

Example 13 with ReleaseIdImpl

use of org.kie.util.maven.support.ReleaseIdImpl in project drools by kiegroup.

the class ReleaseIdTest method testResolveVersionNoProperty.

@Test
public void testResolveVersionNoProperty() {
    final ReleaseIdImpl releaseId = new ReleaseIdImpl("groupId", "artifactId", "1.0.0");
    Assertions.assertThat(releaseId.getVersion()).isEqualTo("1.0.0");
}
Also used : ReleaseIdImpl(org.kie.util.maven.support.ReleaseIdImpl) Test(org.junit.Test)

Example 14 with ReleaseIdImpl

use of org.kie.util.maven.support.ReleaseIdImpl in project drools by kiegroup.

the class KieBuilderImpl method writePomAndKModule.

public void writePomAndKModule() {
    addMetaInfBuilder();
    if (pomXml != null) {
        ReleaseIdImpl g = (ReleaseIdImpl) releaseId;
        trgMfs.write(g.getPomXmlPath(), pomXml, true);
        trgMfs.write(g.getPomPropertiesPath(), generatePomProperties(releaseId).getBytes(IoUtils.UTF8_CHARSET), true);
    }
    if (kModuleModel != null && hasXmlSupport()) {
        trgMfs.write(KieModuleModelImpl.KMODULE_JAR_PATH, kModuleModel.toXML().getBytes(IoUtils.UTF8_CHARSET), true);
    }
}
Also used : ReleaseIdImpl(org.kie.util.maven.support.ReleaseIdImpl)

Example 15 with ReleaseIdImpl

use of org.kie.util.maven.support.ReleaseIdImpl in project drools by kiegroup.

the class InJarArtifactResolver method getArtifactDependecies.

@Override
public List<DependencyDescriptor> getArtifactDependecies(String artifactName) {
    ReleaseId releaseId = new ReleaseIdImpl(artifactName);
    PomParser pomParser = buildPomParser(releaseId);
    return pomParser != null ? pomParser.getPomDirectDependencies(DependencyFilter.COMPILE_FILTER) : emptyList();
}
Also used : ReleaseIdImpl(org.kie.util.maven.support.ReleaseIdImpl) ReleaseId(org.kie.api.builder.ReleaseId)

Aggregations

ReleaseIdImpl (org.kie.util.maven.support.ReleaseIdImpl)16 Test (org.junit.Test)9 ReleaseId (org.kie.api.builder.ReleaseId)8 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)5 KieModule (org.kie.api.builder.KieModule)3 ArrayList (java.util.ArrayList)2 CyclicBarrier (java.util.concurrent.CyclicBarrier)2 ExecutorService (java.util.concurrent.ExecutorService)2 KieBuilder (org.kie.api.builder.KieBuilder)2 KieFileSystem (org.kie.api.builder.KieFileSystem)2 ComparableVersion (org.kie.api.builder.ReleaseIdComparator.ComparableVersion)2 File (java.io.File)1 IOException (java.io.IOException)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1 Field (org.dmg.pmml.Field)1