Skip to content

Commit

Permalink
Upgrade ktlint-maven-plugin to 3.0.0 (bumps ktlint from 0.39.0 to 1.0…
Browse files Browse the repository at this point in the history
….0 (#96)

* Upgrade ktlint-maven-plugin to 3.0.0 (bumps ktlint from 0.39.0 to 1.0.0)

Improved ktlint handling:

- runs at `verify` phase (instead of compile)
- at default, only performs `check`
- format can be run with `mvn ktlint:format@ktlint-format`
- want to skip ktlint (and other quality steps)?: use `-Dquality.skip`

* Apply ktlint needed changes

Happy ktlint, happy flock?

---------

Co-authored-by: Julius van Dis <[email protected]>
Co-authored-by: Willem Veelenturf <[email protected]>
  • Loading branch information
3 people authored Jan 20, 2024
1 parent 9013ddb commit 4a11c1c
Show file tree
Hide file tree
Showing 198 changed files with 3,175 additions and 2,297 deletions.
1 change: 1 addition & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--add-opens java.base/java.lang=ALL-UNNAMED
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ import org.springframework.context.annotation.Import

@Configuration
@SpringBootApplication(
exclude = arrayOf(
RepositoryRestMvcAutoConfiguration::class,
UserDetailsServiceAutoConfiguration::class
)
exclude =
arrayOf(
RepositoryRestMvcAutoConfiguration::class,
UserDetailsServiceAutoConfiguration::class,
),
)
@Import(
WebMvcConfig::class,
WebSecurityConfig::class,
ApplicationConfiguration::class
ApplicationConfiguration::class,
)
class Application : SpringBootServletInitializer()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories
UserConfiguration::class,
MemberConfiguration::class,
LanguageIsoConfiguration::class,
WorkspaceConfiguration::class
WorkspaceConfiguration::class,
)
class ApplicationConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ import org.springframework.stereotype.Component
@Import(
UserLoadData::class,
MemberLoadData::class,
WorkspaceLoadData::class
WorkspaceLoadData::class,
)
class ApplicationData(
userAuthorityService: UserAuthorityService,
userAccountService: UserAccountService,
userLoadData: UserLoadData,
memberLoadData: MemberLoadData,
workspaceLoadData: WorkspaceLoadData
workspaceLoadData: WorkspaceLoadData,
) {

init {
val all = userAuthorityService
.allAuthorities()
.map { it.toName() }
.toSet()
val all =
userAuthorityService
.allAuthorities()
.map { it.toName() }
.toSet()
userAccountService
.createUserAccountPassword(UserAccountPasswordForm(name = "Test", email = "[email protected]", password = "test", authorities = all))
userLoadData.load(10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package community.flock.eco.application.example.authorities
import community.flock.eco.core.authorities.Authority

enum class ExampleAuthority : Authority {
SUPER_USER
SUPER_USER,
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@ import org.springframework.web.servlet.resource.PathResourceResolver
import java.io.IOException

class WebMvcConfig : WebMvcConfigurer {

override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/static/")
.resourceChain(true)
.addResolver(object : PathResourceResolver() {
@Throws(IOException::class)
override fun getResource(resourcePath: String, location: Resource): Resource {
val requestedResource = location.createRelative(resourcePath)
return if (requestedResource.exists() && requestedResource.isReadable())
requestedResource
else
ClassPathResource("/static/index.html")
}
})
.addResolver(
object : PathResourceResolver() {
@Throws(IOException::class)
override fun getResource(
resourcePath: String,
location: Resource,
): Resource {
val requestedResource = location.createRelative(resourcePath)
return if (requestedResource.exists() && requestedResource.isReadable()) {
requestedResource
} else {
ClassPathResource("/static/index.html")
}
}
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ import org.springframework.security.web.authentication.www.BasicAuthenticationFi
class WebSecurityConfig(
private val userAuthorityService: UserAuthorityService,
private val userSecurityService: UserSecurityService,
private val userKeyTokenFilter: UserKeyTokenFilter
private val userKeyTokenFilter: UserKeyTokenFilter,
) : WebSecurityConfigurerAdapter() {

override fun configure(http: HttpSecurity) {

userAuthorityService.addAuthority(ExampleAuthority::class.java)

http
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping("/_ah")
class HealthController {

@GetMapping("/health")
fun health(): String {
return "OK"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ import org.springframework.stereotype.Component

@Component
class WorkspaceUserProviderImp() : WorkspaceUserProvider {

override fun findWorkspaceUsers(ref: String): WorkspaceUser? = createUser(ref)

override fun findWorkspaceUsers(refs: List<String>): Iterable<WorkspaceUser> = refs
.map { createUser(it) }
override fun findWorkspaceUsers(refs: List<String>): Iterable<WorkspaceUser> =
refs
.map { createUser(it) }

override fun findRoles(): List<String> = listOf("MANAGER", "ADMIN", "USER")
}

fun createUser(ref: String) = WorkspaceUser(
id = ref,
name = "Name $ref"
)
fun createUser(ref: String) =
WorkspaceUser(
id = ref,
name = "Name $ref",
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package community.flock.eco.application.multi_tenant
package community.flock.eco.application.multitenant

import community.flock.eco.application.multi_tenant.config.WebMvcConfig
import community.flock.eco.application.multi_tenant.config.WebSecurityConfig
import community.flock.eco.application.multitenant.config.WebMvcConfig
import community.flock.eco.application.multitenant.config.WebSecurityConfig
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration
Expand All @@ -12,15 +12,16 @@ import org.springframework.context.annotation.Import

@Configuration
@SpringBootApplication(
exclude = arrayOf(
RepositoryRestMvcAutoConfiguration::class,
SecurityAutoConfiguration::class
)
exclude =
arrayOf(
RepositoryRestMvcAutoConfiguration::class,
SecurityAutoConfiguration::class,
),
)
@Import(
WebMvcConfig::class,
WebSecurityConfig::class,
ApplicationConfiguration::class
ApplicationConfiguration::class,
)
class Application : SpringBootServletInitializer()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package community.flock.eco.application.multi_tenant
package community.flock.eco.application.multitenant

import community.flock.eco.feature.multi_tenant.MultiTenantConfiguration
import community.flock.eco.feature.multitenant.MultiTenantConfiguration
import community.flock.eco.feature.user.UserConfiguration
import org.springframework.boot.autoconfigure.domain.EntityScan
import org.springframework.context.annotation.ComponentScan
Expand All @@ -13,11 +13,11 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories
@EntityScan
@ComponentScan(
basePackages = [
"community.flock.eco.application.multi_tenant.controllers"
]
"community.flock.eco.application.multitenant.controllers",
],
)
@Import(
UserConfiguration::class,
MultiTenantConfiguration::class
MultiTenantConfiguration::class,
)
class ApplicationConfiguration
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package community.flock.eco.application.multi_tenant.config
package community.flock.eco.application.multitenant.config

import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

class WebMvcConfig() : WebMvcConfigurer {

override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
registry.addResourceHandler("/ui/**")
.addResourceLocations("/index.html", "classpath:/index.html")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package community.flock.eco.application.multi_tenant.config
package community.flock.eco.application.multitenant.config

import community.flock.eco.feature.multi_tenant.filters.MultiTenantFilter
import community.flock.eco.feature.multitenant.filters.MultiTenantFilter
import community.flock.eco.feature.user.filters.UserKeyTokenFilter
import community.flock.eco.feature.user.services.UserAuthorityService
import community.flock.eco.feature.user.services.UserSecurityService
Expand All @@ -18,7 +18,6 @@ import org.springframework.security.web.authentication.www.BasicAuthenticationFi
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
class WebSecurityConfig : WebSecurityConfigurerAdapter() {

@Autowired
lateinit var userAuthorityService: UserAuthorityService

Expand All @@ -32,7 +31,6 @@ class WebSecurityConfig : WebSecurityConfigurerAdapter() {
lateinit var multiTenantFilter: MultiTenantFilter

override fun configure(http: HttpSecurity) {

http
.csrf().disable()
http
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package community.flock.eco.application.multi_tenant.controllers
package community.flock.eco.application.multitenant.controllers

import community.flock.eco.feature.multi_tenant.model.MultiTenantKeyValue
import community.flock.eco.feature.multi_tenant.services.MultiTenantKeyValueService
import community.flock.eco.feature.multi_tenant.services.MultiTenantSchemaService
import community.flock.eco.feature.multitenant.model.MultiTenantKeyValue
import community.flock.eco.feature.multitenant.services.MultiTenantKeyValueService
import community.flock.eco.feature.multitenant.services.MultiTenantSchemaService
import community.flock.eco.feature.user.forms.UserAccountPasswordForm
import community.flock.eco.feature.user.services.UserAccountService
import liquibase.integration.spring.MultiTenantSpringLiquibase
Expand All @@ -26,8 +26,9 @@ class RegistrationController(
private val userAccountService: UserAccountService,
) {
@PostMapping("/register")
fun register(@RequestBody input: RegistrationInput) {

fun register(
@RequestBody input: RegistrationInput,
) {
// Find all tenants
val tenant = multiTenantSchemaService.createMultiTenant(input.tenantName)
multiTenantSchemaService.createTenant(input.tenantName)
Expand All @@ -40,16 +41,16 @@ class RegistrationController(
userAccountService.createUserAccountPassword(
UserAccountPasswordForm(
email = input.email,
password = "password"
)
password = "password",
),
)

// Create Tenant Key Value
multiTenantKeyValueService.save(
MultiTenantKeyValue(
key = "NAME",
value = tenant.name
)
value = tenant.name,
),
)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package community.flock.eco.application.multi_tenant
package community.flock.eco.application.multitenant

import com.fasterxml.jackson.databind.ObjectMapper
import community.flock.eco.feature.multi_tenant.graphql.kotlin.TenantInput
import community.flock.eco.feature.multi_tenant.services.MultiTenantSchemaService
import community.flock.eco.feature.multitenant.graphql.kotlin.TenantInput
import community.flock.eco.feature.multitenant.services.MultiTenantSchemaService
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
Expand All @@ -19,7 +19,6 @@ import kotlin.test.assertTrue
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
class CreateMultiTenantTest {

@Autowired
lateinit var mockMvc: MockMvc

Expand All @@ -31,17 +30,17 @@ class CreateMultiTenantTest {

@Test
fun createTenant() {

val input = TenantInput(
tenantName = UUID.randomUUID().toString().replace("-", "_"),
)
val input =
TenantInput(
tenantName = UUID.randomUUID().toString().replace("-", "_"),
)

mockMvc.perform(
MockMvcRequestBuilders
.post("/api/tenants/create")
.content(objectMapper.writeValueAsBytes(input))
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON),
)
.andDo(MockMvcResultHandlers.print())
.andExpect(status().isNoContent)
Expand Down
Loading

0 comments on commit 4a11c1c

Please sign in to comment.