diff --git a/unit-picker/src/main/kotlin/cc/unitmesh/pick/builder/unittest/ClassTestCodeBuilder.kt b/unit-picker/src/main/kotlin/cc/unitmesh/pick/builder/unittest/ClassTestCodeBuilder.kt index e16a65c4..e0581cad 100644 --- a/unit-picker/src/main/kotlin/cc/unitmesh/pick/builder/unittest/ClassTestCodeBuilder.kt +++ b/unit-picker/src/main/kotlin/cc/unitmesh/pick/builder/unittest/ClassTestCodeBuilder.kt @@ -56,18 +56,19 @@ class ClassTestIns( override fun unique(): Instruction { val input = StringBuilder() - input.append(specs.joinToString("\n")) + input.append(specs.joinToString("\n") { "- $it" }) + input.append("\n") if (coreFrameworks.isNotEmpty()) { - input.append("Core frameworks: ${coreFrameworks.joinToString(", ")}\n") + input.append("- You are working on a project that uses ${coreFrameworks.joinToString(", ")}\n") } if (testFrameworks.isNotEmpty()) { - input.append("Test frameworks: ${testFrameworks.joinToString(", ")}\n") + input.append("- This project uses ${testFrameworks.joinToString(", ")} to test code.\n") } - if (coreFrameworks.contains("Spring Boot")) { - input.append("Use appropriate Spring test annotations such as `@MockBean`, `@Autowired`, `@WebMvcTest`, `@DataJpaTest`, `@AutoConfigureTestDatabase`, `@AutoConfigureMockMvc`, `@SpringBootTest` etc.") + if (coreFrameworks.contains("Spring Boot") || coreFrameworks.contains("Spring Boot Web")) { + input.append("- Use appropriate Spring test annotations such as `@MockBean`, `@Autowired`, `@WebMvcTest`, `@DataJpaTest`, `@AutoConfigureTestDatabase`, `@AutoConfigureMockMvc`, `@SpringBootTest` etc.") } if (relatedCode.isNotEmpty()) { diff --git a/unit-picker/src/main/kotlin/cc/unitmesh/pick/project/ProjectLibrary.kt b/unit-picker/src/main/kotlin/cc/unitmesh/pick/project/ProjectLibrary.kt index af7a63aa..f1f80bac 100644 --- a/unit-picker/src/main/kotlin/cc/unitmesh/pick/project/ProjectLibrary.kt +++ b/unit-picker/src/main/kotlin/cc/unitmesh/pick/project/ProjectLibrary.kt @@ -30,17 +30,16 @@ object ProjectLibrary { val testStack = TestStack() deps.forEach { dep -> + val name = dep.depName SpringLibrary.SPRING_MVC.forEach { - it.coords.forEach { coord -> - if (dep.name.contains(coord)) { - testStack.coreFrameworks.putIfAbsent(it.shortText, true) - } + if (name.contains(it.coords)) { + testStack.coreFrameworks.putIfAbsent(it.shortText, true) } } SpringLibrary.SPRING_DATA.forEach { it.coords.forEach { coord -> - if (dep.name.contains(coord)) { + if (name.contains(coord)) { testStack.coreFrameworks.putIfAbsent(it.shortText, true) } } diff --git a/unit-picker/src/main/kotlin/cc/unitmesh/pick/project/SpringLibrary.kt b/unit-picker/src/main/kotlin/cc/unitmesh/pick/project/SpringLibrary.kt index c73f1563..e1e4302d 100644 --- a/unit-picker/src/main/kotlin/cc/unitmesh/pick/project/SpringLibrary.kt +++ b/unit-picker/src/main/kotlin/cc/unitmesh/pick/project/SpringLibrary.kt @@ -7,28 +7,39 @@ object SpringLibrary { // Spring private val SPRING_MVC_MAVEN = "org.springframework:spring-webmvc" private val SPRING_WEBFLUX_MAVEN = "org.springframework:spring-webflux" + private val SPRING_BOOT_WEB = "org.springframework.boot:spring-boot-starter-web" + private val SPRING_BOOT = "org.springframework.boot:spring-boot-starter" // Spring Data private val REACTOR_MAVEN = "io.projectreactor:reactor-core" private val MONGO_REACTIVE_STREAMS_MAVEN = "org.mongodb:mongodb-driver-reactivestreams" private val SPRING_DATA_COMMONS_MAVEN = "org.springframework.data:spring-data-commons" private val JPA_MAVEN = "org.springframework.data:spring-data-jpa" + private val JPA_BOOT_MAVEN = "org.springframework.boot:spring-boot-starter-data-jpa" + private val CASSANDRA_MAVEN = "org.springframework.data:spring-data-cassandra" private val COUCHBASE_MAVEN = "org.springframework.data:spring-data-couchbase" + private val JDBC_MAVEN = "org.springframework.data:spring-data-jdbc" + private val JDBC_BOOT_MAVEN = "org.springframework.data:spring-data-mongodb" private val MONGO_MAVEN = "org.springframework.data:spring-data-mongodb" + private val MONGO_BOOT_MAVEN = "org.springframework.boot:spring-boot-starter-data-mongodb" + private val NEO4J_MAVEN = "org.springframework.data:spring-data-neo4j" private val R2DBC_MAVEN = "org.springframework.data:spring-data-r2dbc" private val REDIS_MAVEN = "org.springframework.data:spring-data-redis" val SPRING_DATA = listOf( SpringDataLibraryDescriptor("JPA ", listOf(JPA_MAVEN)), + SpringDataLibraryDescriptor("JPA SPRING BOOT", listOf(JPA_MAVEN, REACTOR_MAVEN)), SpringDataLibraryDescriptor("CASSANDRA", listOf(CASSANDRA_MAVEN)), SpringDataLibraryDescriptor("REACTIVE CASSANDRA", listOf(CASSANDRA_MAVEN, REACTOR_MAVEN)), SpringDataLibraryDescriptor("COUCHBASE", listOf(COUCHBASE_MAVEN)), SpringDataLibraryDescriptor("REACTIVE COUCHBASE", listOf(COUCHBASE_MAVEN, REACTOR_MAVEN)), SpringDataLibraryDescriptor("JDBC", listOf(JDBC_MAVEN)), + SpringDataLibraryDescriptor("JDBC SPRING BOOT", listOf(JDBC_BOOT_MAVEN)), SpringDataLibraryDescriptor("MONGO", listOf(MONGO_MAVEN)), + SpringDataLibraryDescriptor("MONGO SPRING BOOT", listOf(MONGO_BOOT_MAVEN)), SpringDataLibraryDescriptor( "REACTIVE MONGO", listOf(MONGO_MAVEN, REACTOR_MAVEN, MONGO_REACTIVE_STREAMS_MAVEN) @@ -40,6 +51,8 @@ object SpringLibrary { val SPRING_MVC = listOf( LibraryDescriptor("Spring MVC", SPRING_MVC_MAVEN), - LibraryDescriptor("Spring WebFlux", SPRING_WEBFLUX_MAVEN) + LibraryDescriptor("Spring WebFlux", SPRING_WEBFLUX_MAVEN), + LibraryDescriptor("Spring Boot", SPRING_BOOT), + LibraryDescriptor("Spring Boot Web", SPRING_BOOT) ) } \ No newline at end of file