Refactoring: remove ownImports method

This commit is contained in:
Nikolay Krasko
2019-10-22 17:14:13 +03:00
parent 6d5dc6ea9a
commit e1a5a55972
5 changed files with 5 additions and 27 deletions
@@ -67,10 +67,4 @@ public class DelegatingTestClassModel extends TestClassModel {
public Collection<AnnotationModel> getAnnotations() {
return delegate.getAnnotations();
}
@NotNull
@Override
public Collection<Class<?>> getOwnImports() {
return delegate.getOwnImports();
}
}
@@ -236,12 +236,6 @@ public class SimpleTestClassModel extends TestClassModel {
return annotations;
}
@NotNull
@Override
public Collection<Class<?>> getOwnImports() {
return annotations.stream().map(AnnotationModel::getAnnotation).collect(Collectors.toSet());
}
private class TestAllFilesPresentMethodModel extends TestMethodModel {
@NotNull
@Override
@@ -146,12 +146,6 @@ public class SingleClassTestModel extends TestClassModel {
return annotations;
}
@NotNull
@Override
public Collection<Class<?>> getOwnImports() {
return annotations.stream().map(AnnotationModel::getAnnotation).collect(Collectors.toSet());
}
private class TestAllFilesPresentMethodModel extends TestMethodModel {
@NotNull
@Override
@@ -120,10 +120,7 @@ class TestGenerator(
override val annotations: Collection<AnnotationModel>
get() = emptyList()
override val ownImports: Collection<Class<*>>
get() = emptyList()
override val imports: Collection<Class<*>>
override val imports: Set<Class<*>>
get() = super.imports
}
}
@@ -24,20 +24,19 @@ interface TestEntityModel {
}
interface ClassModel : TestEntityModel {
val ownImports: Collection<Class<*>>
val innerTestClasses: Collection<TestClassModel>
val methods: Collection<MethodModel>
val isEmpty: Boolean
val dataPathRoot: String?
val annotations: Collection<AnnotationModel>
val imports: Collection<Class<*>>
val imports: Set<Class<*>>
}
abstract class TestClassModel : ClassModel {
override val imports: Collection<Class<*>>
override val imports: Set<Class<*>>
get() {
return mutableListOf<Class<*>>().also { allImports ->
allImports.addAll(ownImports)
return mutableSetOf<Class<*>>().also { allImports ->
annotations.mapTo(allImports) { it.annotation }
methods.flatMapTo(allImports) { it.imports() }
innerTestClasses.flatMapTo(allImports) { it.imports }
}