Dependencies model builder
As a user I would like to be able to get a custom model from a Gradle build to collect dependencies.
Total Runs | Success Rate | Failures | Errors | Skipped | Total time (ms) |
---|---|---|---|---|---|
4 | 100.0% | 0 | 0 | 0 | 0.245 seconds |
TestSubject:
Issues:
See:
- https://gradle.org
- https://github.com/bmuschko/tooling-api-custom-model
- https://docs.gradle.org/current/javadoc/org/gradle/tooling/provider/model/ToolingModelBuilder.html
- io.github.gregoranders.idea.gradle.dependencies.gradle.tooling.DependenciesModelBuilder
Features
- should return true when invoked with io.github.gregoranders.idea.gradle.dependencies.gradle.tooling.model.api.Project as the modelName
- should return false when invoked with io.github.gregoranders.idea.gradle.dependencies.gradle.tooling.model.api.Configuration as the modelName
- should return false when invoked with io.github.gregoranders.idea.gradle.dependencies.gradle.tooling.model.api.Dependency as the modelName
- should return project model
should return true when invoked with io.github.gregoranders.idea.gradle.dependencies.gradle.tooling.model.api.Project as the modelName
Result: PASS Time: 0
- Expect should return appropriate result when invoked
testSubject.canBuild(modelName) == expectedResult
- Where
modelName | expectedResult | ||
---|---|---|---|
io.github.gregoranders.idea.gradle.dependencies.gradle.tooling.model.api.Project | true | 0 | (PASS) |
should return false when invoked with io.github.gregoranders.idea.gradle.dependencies.gradle.tooling.model.api.Configuration as the modelName
Result: PASS Time: 0
- Expect should return appropriate result when invoked
testSubject.canBuild(modelName) == expectedResult
- Where
modelName | expectedResult | ||
---|---|---|---|
io.github.gregoranders.idea.gradle.dependencies.gradle.tooling.model.api.Configuration | false | 0 | (PASS) |
should return false when invoked with io.github.gregoranders.idea.gradle.dependencies.gradle.tooling.model.api.Dependency as the modelName
Result: PASS Time: 0
- Expect should return appropriate result when invoked
testSubject.canBuild(modelName) == expectedResult
- Where
modelName | expectedResult | ||
---|---|---|---|
io.github.gregoranders.idea.gradle.dependencies.gradle.tooling.model.api.Dependency | false | 0 | (PASS) |
should return project model
Result: PASS Time: 0.146 seconds
- Given a mocked Project
Project mockedProject = Mock()
- And a mocked ConfigurationContainer
ConfigurationContainer mockedConfigurationsContainer = Mock()
- And a mocked Configuration
Configuration mockedConfiguration = Mock()
- And a mocked DependencySet
DependencySet mockedDependencySet = Mock()
- And a mocked Dependency
Dependency mockedDependency = Mock()
- When buildAll is invoked on the unit under test with the mocked project as a parameter
def project = (testSubject.buildAll('test', mockedProject) as io.github.gregoranders.idea.gradle.dependencies.gradle.tooling.model.api.Project)
- Then all assumptions should be satisfied
interaction {
1 * mockedDependency.getGroup() >> 'testDependencyGroup'
1 * mockedDependency.getName() >> 'testDependencyName'
1 * mockedDependency.getVersion() >> 'testDependencyVersion'
1 * mockedDependencySet.stream() >> Stream.of(mockedDependency)
1 * mockedConfiguration.getDependencies() >> mockedDependencySet
1 * mockedConfiguration.getName() >> 'testConfigurationName'
1 * mockedConfigurationsContainer.stream() >> Stream.of(mockedConfiguration)
1 * mockedProject.getConfigurations() >> mockedConfigurationsContainer
1 * mockedProject.getGroup() >> 'testProjectGroup'
1 * mockedProject.getName() >> 'testProjectName'
1 * mockedProject.getDescription() >> 'testProjectDescription'
1 * mockedProject.getVersion() >> 'testProjectVersion'
1 * mockedProject.getPath() >> 'testProjectPath'
1 * mockedProject.getSubprojects() >> Set.of()
}
- And a project model should be returned
project instanceof io.github.gregoranders.idea.gradle.dependencies.gradle.tooling.model.api.Project
- And it should have the name set to “testProjectGroup”
project.group() == 'testProjectGroup'
- And it should have the name set to “testProjectName”
project.name() == 'testProjectName'
- And it should have the description set to “testProjectDescription”
project.description() == 'testProjectDescription'
- And it should have the version set to “testProjectVersion”
project.version() == 'testProjectVersion'
- And it should have the path set to “testProjectPath”
project.path() == 'testProjectPath'
- And it should contain one configuration
project.configurations().size() == 1
- And this configuration should have the name “testConfigurationName”
project.configurations()[0].name() == 'testConfigurationName'
- And it should contain one dependency
project.configurations()[0].dependencies().size() == 1
- And this dependency should have the name of “testDependencyName”
project.configurations()[0].dependencies()[0].name() == 'testDependencyName'
- And it should have the group of “testDependencyGroup”
project.configurations()[0].dependencies()[0].group() == 'testDependencyGroup'
- And it should have the version of “testDependencyVersion”
project.configurations()[0].dependencies()[0].version() == 'testDependencyVersion'
- And no exceptions should be thrown
noExceptionThrown()