Default mapper
As a user I would like to be able to map the gradle model into the application model to be able to differentiate between subprojects as dependencies an ‘external’ dependencies.
Total Runs | Success Rate | Failures | Errors | Skipped | Total time (ms) |
---|---|---|---|---|---|
1 | 100.0% | 0 | 0 | 0 | 0.022 seconds |
TestSubject:
- io.github.gregoranders.idea.gradle.dependencies.model.DefaultMapper
- io.github.gregoranders.idea.gradle.dependencies.model.api.Mapper
Issues:
See:
- io.github.gregoranders.idea.gradle.dependencies.model.Mapper
- io.github.gregoranders.idea.gradle.dependencies.model.DefaultMapper
Features
should returned mapped model
Result: PASS Time: 0.019 seconds
- Given a project with a subproject as a dependency
Dependency subDependency = ImmutableDependency.of('subDependencyGroup', 'subDependencyName', 'subDependencyVersion')
Configuration subConfiguration = ImmutableConfiguration.of('subConfigurationName', Set.of(subDependency))
Project subProject = ImmutableProject.of('subProjectGroup', 'subProjectName', 'subProjectDescription', 'subProjectVersion', 'subProjectPath', Set.of(subConfiguration), Set.of())
Dependency dependencySub = ImmutableDependency.of('subProjectGroup', 'subProjectName', 'subProjectVersion')
Dependency dependencyOne = ImmutableDependency.of('subProjectGroup', 'subProjectName', 'dependencyVersion')
Dependency dependencyTwo = ImmutableDependency.of('subProjectGroup', 'dependencyName', 'dependencyVersion')
Dependency dependencyThree = ImmutableDependency.of('dependencyGroup', 'dependencyName', 'dependencyVersion')
Configuration configuration = ImmutableConfiguration.of('configurationName', new LinkedHashSet([dependencySub, dependencyOne, dependencyTwo, dependencyThree]))
Project project = ImmutableProject.of('projectGroup', 'projectName', null, 'projectVersion', 'projectPath', Set.of(configuration), Set.of(subProject))
- When the unit under test maps this project
def mappedProject = testSubject.map(project)
- Then the project should match the expectations
mappedProject.group() == 'projectGroup'
mappedProject.name() == 'projectName'
mappedProject.description() == ''
mappedProject.version() == 'projectVersion'
mappedProject.path() == 'projectPath'
mappedProject.subProjects().size() == 1
mappedProject.configurations().size() == 1
mappedProject.configurations()[0].name() == 'configurationName'
- And the mapped subProject dependency should be marked as a subProject dependency and match the expected values
mappedProject.configurations().forEach(config -> {
assert config.dependencies()[0].group() == 'subProjectGroup'
assert config.dependencies()[0].name() == 'subProjectName'
assert config.dependencies()[0].version() == 'subProjectVersion'
assert config.dependencies()[0].isSubProject()
})
- And the other dependencies should not
mappedProject.configurations().forEach(config -> {
assert !config.dependencies()[1].isSubProject()
assert !config.dependencies()[2].isSubProject()
assert !config.dependencies()[3].isSubProject()
})
- And no exceptions should be thrown
noExceptionThrown()