Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run dependency tests in project pipeline #721

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ default List<PlatformConfiguration> getPlatformConfigurations()

List<MetamodelDependency> getMetamodelDependencies();

default Boolean getRunDependencyTests()
{
return null;
}

@Deprecated
default List<ArtifactGeneration> getArtifactGenerations()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class ProjectConfigurationUpdater
private String groupId;
private String artifactId;
private boolean platformConfigurationsIsSet = false;
private Boolean runDependencyTests;
private MutableList<PlatformConfiguration> platformConfigurations;
private final MutableSet<ProjectDependency> projectDependenciesToAdd = Sets.mutable.empty();
private final MutableSet<ProjectDependency> projectDependenciesToRemove = Sets.mutable.empty();
Expand All @@ -66,6 +67,12 @@ public ProjectConfigurationUpdater withProjectId(String projectId)
return this;
}

public ProjectConfigurationUpdater withRunDependencyTests(boolean runDependencyTests)
{
setRunDependencyTests(runDependencyTests);
return this;
}

// Project type

public ProjectType getProjectType()
Expand Down Expand Up @@ -175,6 +182,16 @@ public ProjectConfigurationUpdater withArtifactId(String artifactId)
return this;
}

public void setRunDependencyTests(boolean runDependencyTests)
{
this.runDependencyTests = runDependencyTests;
}

public boolean getRunDependencyTests()
{
return this.runDependencyTests;
}

// Project dependencies to add

public Set<ProjectDependency> getProjectDependenciesToAdd()
Expand Down Expand Up @@ -417,6 +434,8 @@ else if (this.projectStructureExtensionVersion != null || newProjectType == Proj
// Artifact id
String newArtifactId = (this.artifactId == null) ? configuration.getArtifactId() : this.artifactId;

Boolean newRunDependencyTests = (this.runDependencyTests == null) ? configuration.getRunDependencyTests() : this.runDependencyTests;

// Project dependencies
List<ProjectDependency> newProjectDependencies;
if (this.projectDependenciesToAdd.isEmpty() && this.projectDependenciesToRemove.isEmpty())
Expand Down Expand Up @@ -509,6 +528,12 @@ public List<MetamodelDependency> getMetamodelDependencies()
return newMetamodelDependencies;
}

@Override
public Boolean getRunDependencyTests()
{
return newRunDependencyTests;
}

@Override
public List<ArtifactGeneration> getArtifactGenerations()
{
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class SimpleProjectConfiguration implements ProjectConfiguration
{
private final String projectId;
private ProjectType projectType;
private Boolean runDepenedencyTests;
private ProjectStructureVersion projectStructureVersion;
private List<PlatformConfiguration> platformConfigurations;
private String groupId;
Expand All @@ -40,7 +41,7 @@ public class SimpleProjectConfiguration implements ProjectConfiguration
private List<MetamodelDependency> metamodelDependencies;
private List<ArtifactGeneration> artifactGeneration;

private SimpleProjectConfiguration(String projectId, ProjectType projectType, ProjectStructureVersion projectStructureVersion, List<PlatformConfiguration> platformConfigurations, String groupId, String artifactId, List<ProjectDependency> projectDependencies, List<MetamodelDependency> metamodelDependencies, List<ArtifactGeneration> artifactGeneration)
private SimpleProjectConfiguration(String projectId, ProjectType projectType, Boolean runDependencyTests, ProjectStructureVersion projectStructureVersion, List<PlatformConfiguration> platformConfigurations, String groupId, String artifactId, List<ProjectDependency> projectDependencies, List<MetamodelDependency> metamodelDependencies, List<ArtifactGeneration> artifactGeneration)
{
this.projectId = projectId;
this.projectType = projectType;
Expand All @@ -51,11 +52,12 @@ private SimpleProjectConfiguration(String projectId, ProjectType projectType, Pr
this.projectDependencies = (projectDependencies == null) ? Collections.emptyList() : projectDependencies;
this.metamodelDependencies = (metamodelDependencies == null) ? Collections.emptyList() : metamodelDependencies;
this.artifactGeneration = (artifactGeneration == null) ? Collections.emptyList() : artifactGeneration;
this.runDepenedencyTests = runDependencyTests;
}

SimpleProjectConfiguration(ProjectConfiguration config)
{
this(config.getProjectId(), config.getProjectType(), config.getProjectStructureVersion(), config.getPlatformConfigurations(), config.getGroupId(), config.getArtifactId(), config.getProjectDependencies(), config.getMetamodelDependencies(), config.getArtifactGenerations());
this(config.getProjectId(), config.getProjectType(), config.getRunDependencyTests(), config.getProjectStructureVersion(), config.getPlatformConfigurations(), config.getGroupId(), config.getArtifactId(), config.getProjectDependencies(), config.getMetamodelDependencies(), config.getArtifactGenerations());
}

@Override
Expand All @@ -75,6 +77,17 @@ public void setProjectType(ProjectType projectType)
this.projectType = projectType;
}

@Override
public Boolean getRunDependencyTests()
{
return this.runDepenedencyTests;
}

public void setRunDepenedencyTests(Boolean runDepenedencyTests)
{
this.runDepenedencyTests = runDepenedencyTests;
}

@Override
public ProjectStructureVersion getProjectStructureVersion()
{
Expand Down Expand Up @@ -162,6 +175,7 @@ public void setArtifactGeneration(List<ArtifactGeneration> artifactGeneration)
static SimpleProjectConfiguration newConfiguration(
@JsonProperty("projectId") String projectId,
@JsonProperty("projectType") ProjectType projectType,
@JsonProperty("runDependencyTests") Boolean runDepenedencyTests,
@JsonProperty("projectStructureVersion") @JsonDeserialize(as = SimpleProjectStructureVersion.class) ProjectStructureVersion projectStructureVersion,
@JsonProperty("platformConfigurations") @JsonDeserialize(contentAs = SimplePlatformConfiguration.class) List<PlatformConfiguration> platforms,
@JsonProperty("groupId") String groupId,
Expand All @@ -170,18 +184,23 @@ static SimpleProjectConfiguration newConfiguration(
@JsonProperty("metamodelDependencies") @JsonDeserialize(contentAs = SimpleMetamodelDependency.class) List<MetamodelDependency> metamodelDependencies,
@Deprecated @JsonProperty("artifactGenerations") @JsonDeserialize(contentAs = SimpleArtifactGeneration.class) List<ArtifactGeneration> artifactGenerations)
{
return new SimpleProjectConfiguration(projectId, projectType, projectStructureVersion, platforms, groupId, artifactId, projectDependencies, metamodelDependencies, artifactGenerations);
return new SimpleProjectConfiguration(projectId, projectType, runDepenedencyTests, projectStructureVersion, platforms, groupId, artifactId, projectDependencies, metamodelDependencies, artifactGenerations);
}

@Deprecated
static SimpleProjectConfiguration newConfiguration(String projectId, ProjectStructureVersion projectStructureVersion, String groupId, String artifactId, List<ProjectDependency> projectDependencies, List<MetamodelDependency> metamodelDependencies, List<ArtifactGeneration> artifactGenerations)
{
return newConfiguration(projectId, ProjectType.MANAGED, projectStructureVersion, null, groupId, artifactId, projectDependencies, metamodelDependencies, artifactGenerations);
return newConfiguration(projectId, ProjectType.MANAGED, null, projectStructureVersion, null, groupId, artifactId, projectDependencies, metamodelDependencies, artifactGenerations);
}

static SimpleProjectConfiguration newConfiguration(String projectId, ProjectStructureVersion projectStructureVersion, List<PlatformConfiguration> platforms, String groupId, String artifactId, List<ProjectDependency> projectDependencies, List<MetamodelDependency> metamodelDependencies, List<ArtifactGeneration> artifactGenerations)
{
return newConfiguration(projectId, ProjectType.MANAGED, projectStructureVersion, platforms, groupId, artifactId, projectDependencies, metamodelDependencies, artifactGenerations);
return newConfiguration(projectId, ProjectType.MANAGED, null, projectStructureVersion, platforms, groupId, artifactId, projectDependencies, metamodelDependencies, artifactGenerations);
}

static SimpleProjectConfiguration newConfiguration(String projectId, ProjectStructureVersion projectStructureVersion, Boolean runDepenedencyTests, List<PlatformConfiguration> platforms, String groupId, String artifactId, List<ProjectDependency> projectDependencies, List<MetamodelDependency> metamodelDependencies, List<ArtifactGeneration> artifactGenerations)
{
return newConfiguration(projectId, ProjectType.MANAGED, runDepenedencyTests, projectStructureVersion, platforms, groupId, artifactId, projectDependencies, metamodelDependencies, artifactGenerations);
}

public static class SimpleProjectStructureVersion extends ProjectStructureVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@
import org.apache.maven.model.Dependency;
import org.codehaus.plexus.util.xml.Xpp3Dom;

import java.util.Optional;
import java.util.function.Consumer;

public class LegendJUnitTestGenerationPluginMavenHelper extends AbstractLegendMavenPluginHelper
{
public Boolean runDependencyTests;
public LegendJUnitTestGenerationPluginMavenHelper(String groupId, String artifactId, String version, Dependency generationExtensionsCollection, Boolean runDependencyTests)
{
super(groupId, artifactId, version, "generate-test-sources", "generate-junit-tests", generationExtensionsCollection);
this.runDependencyTests = runDependencyTests;
}

public LegendJUnitTestGenerationPluginMavenHelper(String groupId, String artifactId, String version, Dependency generationExtensionsCollection)
{
super(groupId, artifactId, version, "generate-test-sources", "generate-junit-tests", generationExtensionsCollection);
Expand All @@ -34,5 +42,22 @@ protected void configurePlugin(MavenProjectStructure projectStructure, Consumer<
{
configConsumer.accept(MavenPluginTools.newDom("packagePrefix", groupId));
}
if (this.runDependencyTests != null && this.runDependencyTests == true)
{
configConsumer.accept(MavenPluginTools.newDom("runDependencyTests", "true"));
}
}

protected void addDependencies(MavenProjectStructure projectStructure, Consumer<? super Dependency> dependencyConsumer)
{
if(this.runDependencyTests != null && this.runDependencyTests == true)
{
super.addDependencies(projectStructure, dependencyConsumer);
if (projectStructure instanceof MultiModuleMavenProjectStructure)
{
MultiModuleMavenProjectStructure multiModuleProjectStructure = (MultiModuleMavenProjectStructure) projectStructure;
dependencyConsumer.accept(multiModuleProjectStructure.getModuleWithProjectVersionDependency(multiModuleProjectStructure.getEntitiesModuleName()));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ org.finos.legend.sdlc.server.project.ProjectStructureV0Factory
org.finos.legend.sdlc.server.project.ProjectStructureV11Factory
org.finos.legend.sdlc.server.project.ProjectStructureV12Factory
org.finos.legend.sdlc.server.project.ProjectStructureV13Factory
org.finos.legend.sdlc.server.project.ProjectStructureV14Factory
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class TestProjectStructureFactory
@Test
public void testFactoryWithV0_V11_V12_V13()
{
assertFactoryWithV0(ProjectStructureFactory.newFactory(Lists.mutable.with(new ProjectStructureV0Factory(), new ProjectStructureV11Factory(), new ProjectStructureV12Factory(), new ProjectStructureV13Factory())));
assertFactoryWithV0(ProjectStructureFactory.newFactory(Lists.mutable.with(new ProjectStructureV0Factory(), new ProjectStructureV11Factory(), new ProjectStructureV12Factory(), new ProjectStructureV13Factory(), new ProjectStructureV14Factory())));
}

@Test
Expand Down Expand Up @@ -68,7 +68,7 @@ protected void assertSupportsVersions(ProjectStructureFactory factory, IntIterab

private void assertFactoryWithV0(ProjectStructureFactory factory)
{
assertSupportsVersions(factory, 0, 11, 12, 13);
assertSupportsVersions(factory, 0, 11, 12, 13, 14);

ProjectStructure structure = factory.newProjectStructure(null, null);
Assert.assertEquals(0, structure.getVersion());
Expand Down
Loading
Loading