use of org.commonjava.maven.ext.common.model.Project in project pom-manipulation-ext by release-engineering.
the class JSONManipulatorTest method updateURL.
@Test
public void updateURL() throws ManipulationException, IOException {
String modifyPath = "$.repository.url";
File target = tf.newFile();
FileUtils.copyFile(pluginFile, target);
Project project = new Project(null, target, null);
jsonManipulator.internalApplyChanges(project, new JSONState.JSONOperation(target.getName(), modifyPath, "https://maven.repository.redhat.com/ga/"));
assertTrue(FileUtils.readFileToString(target).contains("https://maven.repository.redhat.com/ga/"));
assertFalse(FileUtils.contentEquals(pluginFile, target));
}
use of org.commonjava.maven.ext.common.model.Project in project pom-manipulation-ext by release-engineering.
the class DistributionEnforcingManipulatorTest method applyTest.
@SuppressWarnings("unused")
private void applyTest(final Set<Model> models, final Set<Model> expectChanged) throws Exception {
final List<Project> projects = new ArrayList<>();
final Map<String, Model> manipulatedModels = new HashMap<>();
for (final Model model : models) {
final Project project = new Project(model);
projects.add(project);
manipulatedModels.put(ga(model), model);
}
final Set<Project> changed = manipulator.applyChanges(projects);
if (expectChanged != null && !expectChanged.isEmpty()) {
assertThat(changed.isEmpty(), equalTo(false));
for (final Model model : expectChanged) {
assertThat(changed.contains(new Project(model)), equalTo(true));
}
} else {
assertThat(changed.isEmpty(), equalTo(true));
}
}
use of org.commonjava.maven.ext.common.model.Project in project pom-manipulation-ext by release-engineering.
the class VersioningCalculatorTest method incrementExistingSerialSuffix_TwoProjects_UsingRepositoryMetadata_DifferentAvailableIncrements.
@Test
public void incrementExistingSerialSuffix_TwoProjects_UsingRepositoryMetadata_DifferentAvailableIncrements() throws Exception {
final String v = "1.2.0.GA";
final String os = "-foo-1";
final String ns = "foo-10";
final Model m1 = new Model();
m1.setGroupId(GROUP_ID);
m1.setArtifactId(ARTIFACT_ID);
m1.setVersion(v + os);
final Project p1 = new Project(m1);
final String a2 = ARTIFACT_ID + "-dep";
final Model m2 = new Model();
m2.setGroupId(GROUP_ID);
m2.setArtifactId(a2);
m2.setVersion(v + os);
final Project p2 = new Project(m2);
final Properties props = new Properties();
props.setProperty(VersioningState.INCREMENT_SERIAL_SUFFIX_SYSPROP.getCurrent(), "foo-0");
final Map<ProjectRef, String[]> versionMap = new HashMap<>();
versionMap.put(new SimpleProjectRef(p1.getGroupId(), p1.getArtifactId()), new String[] { "1.2.0.GA-foo-3", "1.2.0.GA-foo-2", "1.2.0.GA-foo-9" });
versionMap.put(new SimpleProjectRef(p2.getGroupId(), p2.getArtifactId()), new String[] { "1.2.0.GA-foo-3", "1.2.0.GA-foo-2" });
setupSession(props, versionMap);
final Map<ProjectVersionRef, String> result = modder.calculateVersioningChanges(Arrays.asList(p1, p2), session);
assertThat(result.get(new SimpleProjectVersionRef(GROUP_ID, ARTIFACT_ID, v + os)), equalTo(v + "-" + ns));
assertThat(result.get(new SimpleProjectVersionRef(GROUP_ID, a2, v + os)), equalTo(v + "-" + ns));
}
use of org.commonjava.maven.ext.common.model.Project in project pom-manipulation-ext by release-engineering.
the class VersioningCalculatorTest method incrementExistingSerialSuffix_TwoProjects_UsingRepositoryMetadata_AvailableOnlyForOne.
@Test
public void incrementExistingSerialSuffix_TwoProjects_UsingRepositoryMetadata_AvailableOnlyForOne() throws Exception {
final String v = "1.2.0.GA";
final String os = "-foo-1";
final String ns = "foo-10";
final Model m1 = new Model();
m1.setGroupId(GROUP_ID);
m1.setArtifactId(ARTIFACT_ID);
m1.setVersion(v + os);
final Project p1 = new Project(m1);
final String a2 = ARTIFACT_ID + "-dep";
final Model m2 = new Model();
m2.setGroupId(GROUP_ID);
m2.setArtifactId(a2);
m2.setVersion(v + os);
final Project p2 = new Project(m2);
final Properties props = new Properties();
props.setProperty(VersioningState.INCREMENT_SERIAL_SUFFIX_SYSPROP.getCurrent(), "foo-0");
setupSession(props, "1.2.0.GA-foo-3", "1.2.0.GA-foo-2", "1.2.0.GA-foo-9");
final Map<ProjectVersionRef, String> result = modder.calculateVersioningChanges(Arrays.asList(p1, p2), session);
assertThat(result.get(new SimpleProjectVersionRef(GROUP_ID, ARTIFACT_ID, v + os)), equalTo(v + "-" + ns));
assertThat(result.get(new SimpleProjectVersionRef(GROUP_ID, a2, v + os)), equalTo(v + "-" + ns));
}
use of org.commonjava.maven.ext.common.model.Project in project pom-manipulation-ext by release-engineering.
the class PropertiesUtilsTest method testUpdateNestedProperties2.
@Test
public void testUpdateNestedProperties2() throws Exception {
Project pP = getProject();
ManipulationSession session = createUpdateSession();
assertTrue(updateProperties(session, pP, false, "version.hibernate.osgi", "5.0.4.Final-redhat-1") == PropertiesUtils.PropertyUpdate.FOUND);
assertFalse(updateProperties(session, pP, false, "version.scala", "2.11.7") == PropertiesUtils.PropertyUpdate.FOUND);
}
Aggregations