Skip to content

Commit

Permalink
chore(repo): update ktlint to v1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
clementguillot committed Nov 4, 2024
1 parent 945d46f commit 4b3badb
Show file tree
Hide file tree
Showing 54 changed files with 251 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import org.nxcloudce.server.domain.run.usecase.CleanupRun
import org.nxcloudce.server.domain.run.usecase.CleanupRunRequest
import java.time.LocalDateTime

class CleanupCommand(private val cleanupRun: CleanupRun) : QuarkusApplication {
class CleanupCommand(
private val cleanupRun: CleanupRun,
) : QuarkusApplication {
companion object {
private val logger = Logger.getLogger(CleanupCommand::class.java)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import org.nxcloudce.server.presentation.dto.VerifyClientBundleDto
import org.nxcloudce.server.technical.ServerConfiguration

@Path("/client/verify")
class ClientController(private val serverConfiguration: ServerConfiguration) {
class ClientController(
private val serverConfiguration: ServerConfiguration,
) {
@Operation(
summary = "Verifies the version of the `nx-cloud-client-bundle`, returns a download URL if needed",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import org.nxcloudce.server.technical.GzipJsonDecoder

@Path("/heartbeat")
@Authenticated
class HeartbeatController(private val gzipJsonDecoder: GzipJsonDecoder) {
class HeartbeatController(
private val gzipJsonDecoder: GzipJsonDecoder,
) {
companion object {
private val logger = Logger.getLogger(HeartbeatController::class.java)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import org.nxcloudce.server.presentation.dto.IdDto
@Path("/private/create-org")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
class OrganizationController(private val createOrganization: CreateOrganization) {
class OrganizationController(
private val createOrganization: CreateOrganization,
) {
@Operation(
summary = "Create a public cloud counterpart for a private cloud org",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ class RunController(
startRun(
StartRunRequest(
hashes = startRunDto.hashes.map { Hash(it) },
workspaceId = WorkspaceId(identity.deferredIdentity.awaitSuspending().principal.name),
workspaceId =
WorkspaceId(
identity.deferredIdentity
.awaitSuspending()
.principal.name,
),
canPut = isReadWriteContext(),
),
) { response ->
Expand All @@ -54,7 +59,8 @@ class RunController(
@Path("/runs/end")
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
suspend fun end(request: ByteArray): RunSummaryDto =
gzipJsonDecoder.from(request, RunDto.End::class)
gzipJsonDecoder
.from(request, RunDto.End::class)
.let { dto ->
endRun(
EndRunRequest(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package org.nxcloudce.server.presentation.dto

data class IdDto(val id: String)
data class IdDto(
val id: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ data class RemoteArtifactListDto(
)
}

data class RemoteArtifact(val artifactId: String, val artifactUrls: Url) {
data class RemoteArtifact(
val artifactId: String,
val artifactUrls: Url,
) {
data class Url(
val get: String?,
val put: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import org.nxcloudce.server.domain.metric.usecase.SaveMetricsRequest
import org.nxcloudce.server.domain.workspace.model.WorkspaceId

@RegisterForReflection
data class TaskRunnerMetricDto(val entries: Collection<PerformanceEntry>) {
data class TaskRunnerMetricDto(
val entries: Collection<PerformanceEntry>,
) {
data class PerformanceEntry(
val durationMs: Int,
val success: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ sealed class VerifyClientBundleDto(
val url: String?,
val version: String?,
) {
class ValidVerifyClientBundleDto :
VerifyClientBundleDto(true, null, null)
class ValidVerifyClientBundleDto : VerifyClientBundleDto(true, null, null)

class InvalidVerifyClientBundleDto(url: String, version: String) :
VerifyClientBundleDto(false, url, version)
class InvalidVerifyClientBundleDto(
url: String,
version: String,
) : VerifyClientBundleDto(false, url, version)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import org.nxcloudce.server.domain.workspace.usecase.GetWorkspaceAccessTokenRequ
import java.security.Principal

@Startup
class SecurityContextFilter(private val getWorkspaceAccessToken: GetWorkspaceAccessToken) {
class SecurityContextFilter(
private val getWorkspaceAccessToken: GetWorkspaceAccessToken,
) {
@ServerRequestFilter(preMatching = true)
suspend fun preMatchingFilter(requestContext: ContainerRequestContext) {
val apiKey = requestContext.headers.getFirst("authorization")
Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/test/kotlin/org/nxcloudce/server/TestUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import java.util.zip.GZIPOutputStream

fun prepareWorkspaceAndAccessToken(): String {
val response =
RestAssured.given()
RestAssured
.given()
.header("Content-Type", "application/json")
.body(
CreateOrgAndWorkspaceDto(
workspaceName = "test-workspace",
installationSource = "junit",
nxInitDate = null,
),
)
.post("/create-org-and-workspace")
).post("/create-org-and-workspace")
.`as`(InitWorkspaceDto::class.java)

return response.token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class ClientControllerTest {
@Test
fun `should return a valid bundle if the version matches`() {
given()
.`when`().get("/client/verify?version=dummy-version")
.`when`()
.get("/client/verify?version=dummy-version")
.then()
.statusCode(200)
.body(
Expand All @@ -26,7 +27,8 @@ class ClientControllerTest {
@Test
fun `should return an invalid bundle if the version is empty or different`() {
given()
.`when`().get("/client/verify")
.`when`()
.get("/client/verify")
.then()
.statusCode(200)
.body(
Expand All @@ -38,7 +40,8 @@ class ClientControllerTest {
`is`(equalTo("dummy-version")),
)
given()
.`when`().get("/client/verify?version=not-matching")
.`when`()
.get("/client/verify?version=not-matching")
.then()
.statusCode(200)
.body(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class HeartbeatControllerTest {
runGroup = "junit",
logs = null,
),
)
.`when`()
).`when`()
.post("/heartbeat")
.then()
.statusCode(200)
Expand All @@ -58,8 +57,7 @@ class HeartbeatControllerTest {
dispatcher,
objectMapper,
),
)
.`when`()
).`when`()
.post("/heartbeat/logs")
.then()
.statusCode(200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class MetricControllerTest {
),
),
),
)
.`when`()
).`when`()
.post("/save-metrics")
.then()
.statusCode(200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ class PingControllerTest {
@Test
fun testHelloEndpoint() {
given()
.`when`().get("/ping")
.`when`()
.get("/ping")
.then()
.statusCode(200).body(`is`(""))
.statusCode(200)
.body(`is`(""))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ class RunControllerTest {
clientInstanceId = UUID.randomUUID(),
clientInstanceSource = "CLOUD_RUNNER",
),
)
.`when`()
).`when`()
.post("/v2/runs/start")
.then()
.log().body()
.log()
.body()
.statusCode(200)
.body(
"artifacts.size()",
Expand Down Expand Up @@ -107,8 +107,7 @@ class RunControllerTest {
dispatcher,
objectMapper,
),
)
.`when`()
).`when`()
.post("/runs/end")
.then()
.statusCode(200)
Expand Down Expand Up @@ -140,8 +139,7 @@ class RunControllerTest {
dispatcher,
objectMapper,
),
)
.`when`()
).`when`()
.post("/runs/end")
.then()
.statusCode(200)
Expand Down Expand Up @@ -173,8 +171,7 @@ class RunControllerTest {
dispatcher,
objectMapper,
),
)
.`when`()
).`when`()
.post("/runs/end")
.then()
.statusCode(200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class WorkspaceControllerTest {
orgId = newOrg.id.value,
name = "new workspace",
),
)
.`when`()
).`when`()
.post("/private/create-workspace")
.then()
.statusCode(200)
Expand All @@ -47,8 +46,7 @@ class WorkspaceControllerTest {
installationSource = "junit",
nxInitDate = null,
),
)
.`when`()
).`when`()
.post("/create-org-and-workspace")
.then()
.statusCode(200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,8 @@ class GzipJsonDecoderTest {
}.toThrow<Exception>()
}

data class DummyClass(val stringProperty: String, val intProperty: Int)
data class DummyClass(
val stringProperty: String,
val intProperty: Int,
)
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ quarkusPlatformArtifactId=quarkus-bom
quarkusPlatformVersion=3.15.1
## Gradle plugins
jnxplusGradlePluginVersion=0.4.0
ktlintVersion=1.2.1
ktlintVersion=1.4.0
spotlessVersion=6.25.0
## Dependencies
atriumVersion=1.2.0
Expand Down
6 changes: 5 additions & 1 deletion libs/server/domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ tasks.withType<Test> {

configure<JacocoTaskExtension> {
excludeClassLoaders = listOf("*QuarkusClassLoader")
destinationFile = layout.buildDirectory.file("jacoco-quarkus.exec").get().asFile
destinationFile =
layout.buildDirectory
.file("jacoco-quarkus.exec")
.get()
.asFile
}

tasks.jacocoTestReport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import org.nxcloudce.server.domain.metric.usecase.SaveMetrics
import org.nxcloudce.server.domain.metric.usecase.SaveMetricsRequest
import org.nxcloudce.server.domain.metric.usecase.SaveMetricsResponse

class SaveMetricsImpl(private val taskRunnerMetricRepository: TaskRunnerMetricRepository) :
SaveMetrics {
class SaveMetricsImpl(
private val taskRunnerMetricRepository: TaskRunnerMetricRepository,
) : SaveMetrics {
override suspend fun <T> invoke(
request: SaveMetricsRequest,
presenter: (SaveMetricsResponse) -> T,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package org.nxcloudce.server.domain.metric.model
import org.nxcloudce.server.domain.workspace.model.WorkspaceId
import java.time.LocalDateTime

class TaskRunnerMetric private constructor(builder: Builder) {
class TaskRunnerMetric private constructor(
builder: Builder,
) {
companion object {
operator fun invoke(block: Builder.() -> Unit): TaskRunnerMetric {
val builder = Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import org.nxcloudce.server.domain.workspace.model.WorkspaceId

interface SaveMetrics : UseCase<SaveMetricsRequest, SaveMetricsResponse>

data class SaveMetricsRequest(val metrics: Collection<Metric>) {
data class SaveMetricsRequest(
val metrics: Collection<Metric>,
) {
data class Metric(
val workspaceId: WorkspaceId,
val durationMs: Int,
Expand All @@ -17,4 +19,6 @@ data class SaveMetricsRequest(val metrics: Collection<Metric>) {
)
}

data class SaveMetricsResponse(val metrics: Collection<TaskRunnerMetric>)
data class SaveMetricsResponse(
val metrics: Collection<TaskRunnerMetric>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import org.nxcloudce.server.domain.organization.usecase.CreateOrganization
import org.nxcloudce.server.domain.organization.usecase.CreateOrganizationRequest
import org.nxcloudce.server.domain.organization.usecase.CreateOrganizationResponse

class CreateOrganizationImpl(private val orgGateway: OrganizationRepository) : CreateOrganization {
class CreateOrganizationImpl(
private val orgGateway: OrganizationRepository,
) : CreateOrganization {
override suspend operator fun <T> invoke(
request: CreateOrganizationRequest,
presenter: (CreateOrganizationResponse) -> T,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package org.nxcloudce.server.domain.organization.model

@JvmInline value class OrganizationId(val value: String)
@JvmInline value class OrganizationId(
val value: String,
)

data class Organization(val id: OrganizationId, val name: String)
data class Organization(
val id: OrganizationId,
val name: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import org.nxcloudce.server.domain.organization.model.Organization

interface CreateOrganization : UseCase<CreateOrganizationRequest, CreateOrganizationResponse>

data class CreateOrganizationRequest(val name: String)
data class CreateOrganizationRequest(
val name: String,
)

data class CreateOrganizationResponse(val organization: Organization)
data class CreateOrganizationResponse(
val organization: Organization,
)
Loading

0 comments on commit 4b3badb

Please sign in to comment.