Search in sources :

Example 31 with SimpleProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project pom-manipulation-ext by release-engineering.

the class Project method modelKey.

public static ProjectVersionRef modelKey(final Model model) throws ManipulationException {
    String g = model.getGroupId();
    String v = model.getVersion();
    if (g == null || v == null) {
        final Parent p = model.getParent();
        if (p == null) {
            throw new ManipulationException("Invalid model: " + model + " Cannot find groupId and/or version!");
        }
        if (g == null) {
            g = p.getGroupId();
        }
        if (v == null) {
            v = p.getVersion();
        }
    }
    final String a = model.getArtifactId();
    return new SimpleProjectVersionRef(g, a, v);
}
Also used : Parent(org.apache.maven.model.Parent) ManipulationException(org.commonjava.maven.ext.common.ManipulationException) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)

Example 32 with SimpleProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project pom-manipulation-ext by release-engineering.

the class HttpErrorTranslatorTest method testTranslateVersionsWith404.

@Test
public void testTranslateVersionsWith404() {
    List<ProjectVersionRef> gavs = new ArrayList<ProjectVersionRef>() {

        {
            add(new SimpleProjectVersionRef("com.example", "example", "1.0"));
            add(new SimpleProjectVersionRef("org.commonjava", "example", "1.1"));
        }
    };
    try {
        versionTranslator.translateVersions(gavs);
        fail("Failed to throw RestException when server failed to respond.");
    } catch (RestException ex) {
    // Pass
    }
}
Also used : ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ArrayList(java.util.ArrayList) RestException(org.commonjava.maven.ext.io.rest.exception.RestException) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) Test(org.junit.Test)

Example 33 with SimpleProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project pom-manipulation-ext by release-engineering.

the class RESTParametersVersionSuffixTest method testVerifySuffix.

@Test
public void testVerifySuffix() {
    this.versionTranslator = new DefaultTranslator(mockServer.getUrl(), RestProtocol.PNC13, 0, Translator.CHUNK_SPLIT_COUNT, "", suffix);
    List<ProjectVersionRef> gavs = new ArrayList<ProjectVersionRef>() {

        {
            add(new SimpleProjectVersionRef("com.example", "example", "1.0"));
        }
    };
    versionTranslator.translateVersions(gavs);
    assertTrue(suffix.equals(gavSchema.versionSuffix));
}
Also used : ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ArrayList(java.util.ArrayList) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) Test(org.junit.Test)

Example 34 with SimpleProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project pom-manipulation-ext by release-engineering.

the class RESTParametersVersionSuffixTest method testVerifyNoSuffix.

@Test
public void testVerifyNoSuffix() {
    this.versionTranslator = new DefaultTranslator(mockServer.getUrl(), RestProtocol.PNC13, 0, Translator.CHUNK_SPLIT_COUNT, "", "");
    List<ProjectVersionRef> gavs = new ArrayList<ProjectVersionRef>() {

        {
            add(new SimpleProjectVersionRef("com.example", "example", "1.0"));
        }
    };
    versionTranslator.translateVersions(gavs);
    assertTrue(gavSchema.versionSuffix == null);
}
Also used : ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ArrayList(java.util.ArrayList) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) Test(org.junit.Test)

Example 35 with SimpleProjectVersionRef

use of org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef in project pom-manipulation-ext by release-engineering.

the class VersionTranslatorTest method testTranslateVersions.

@Test
public void testTranslateVersions() {
    List<ProjectVersionRef> gavs = new ArrayList<ProjectVersionRef>() {

        {
            add(new SimpleProjectVersionRef("com.example", "example", "1.0"));
            add(new SimpleProjectVersionRef("com.example", "example-dep", "2.0"));
            add(new SimpleProjectVersionRef("org.commonjava", "example", "1.0"));
            add(new SimpleProjectVersionRef("org.commonjava", "example", "1.1"));
        }
    };
    Map<ProjectVersionRef, String> actualResult = versionTranslator.translateVersions(gavs);
    Map<ProjectVersionRef, String> expectedResult = new HashMap<ProjectVersionRef, String>() {

        {
            put(new SimpleProjectVersionRef("com.example", "example", "1.0"), "1.0-redhat-1");
            put(new SimpleProjectVersionRef("com.example", "example-dep", "2.0"), "2.0-redhat-1");
            put(new SimpleProjectVersionRef("org.commonjava", "example", "1.0"), "1.0-redhat-1");
            put(new SimpleProjectVersionRef("org.commonjava", "example", "1.1"), "1.1-redhat-1");
        }
    };
    assertThat(actualResult, is(expectedResult));
}
Also used : HashMap(java.util.HashMap) ProjectVersionRef(org.commonjava.maven.atlas.ident.ref.ProjectVersionRef) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) ArrayList(java.util.ArrayList) SimpleProjectVersionRef(org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef) Test(org.junit.Test)

Aggregations

SimpleProjectVersionRef (org.commonjava.maven.atlas.ident.ref.SimpleProjectVersionRef)49 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)41 Test (org.junit.Test)36 ArrayList (java.util.ArrayList)22 HashMap (java.util.HashMap)11 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)11 TestDownload (org.commonjava.maven.galley.testing.core.transport.job.TestDownload)11 Model (org.apache.maven.model.Model)9 RestException (org.commonjava.maven.ext.io.rest.exception.RestException)9 Transfer (org.commonjava.maven.galley.model.Transfer)9 SimpleLocation (org.commonjava.maven.galley.model.SimpleLocation)7 MavenProject (org.apache.maven.project.MavenProject)6 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)6 URI (java.net.URI)5 LinkedHashMap (java.util.LinkedHashMap)5 Dependency (org.apache.maven.model.Dependency)5 DependencyManagement (org.apache.maven.model.DependencyManagement)5 JoinString (org.commonjava.maven.atlas.ident.util.JoinString)5 Map (java.util.Map)4 Project (org.commonjava.maven.ext.common.model.Project)4