Skip to content

Commit

Permalink
Merge pull request OSGP#89 from OSGP/dependabot/gradle/com.diffplug.s…
Browse files Browse the repository at this point in the history
…potless-7.0.1

Bump com.diffplug.spotless from 6.25.0 to 7.0.1
  • Loading branch information
loesimmens authored Jan 9, 2025
2 parents 2921bf8 + 10a9cbe commit 3490163
Show file tree
Hide file tree
Showing 41 changed files with 70 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import org.springframework.test.annotation.DirtiesContext
"\${kafka.consumers.command.topic}",
"\${kafka.consumers.pre-shared-key.topic}",
"\${kafka.producers.command-feedback.topic}",
"\${kafka.producers.device-message.topic}"
"\${kafka.producers.device-message.topic}",
]
)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
Expand Down Expand Up @@ -89,7 +89,7 @@ class CoapMessageHandlingTest {
Instant.now(),
Command.CommandType.PSK,
null,
Command.CommandStatus.PENDING
Command.CommandStatus.PENDING,
)
)
commandRepository.save(
Expand All @@ -100,7 +100,7 @@ class CoapMessageHandlingTest {
Instant.now(),
Command.CommandType.PSK_SET,
null,
Command.CommandStatus.PENDING
Command.CommandStatus.PENDING,
)
)

Expand All @@ -124,7 +124,7 @@ class CoapMessageHandlingTest {
Instant.now(),
Command.CommandType.PSK,
null,
Command.CommandStatus.IN_PROGRESS
Command.CommandStatus.IN_PROGRESS,
)
)
commandRepository.save(
Expand All @@ -135,7 +135,7 @@ class CoapMessageHandlingTest {
Instant.now(),
Command.CommandType.PSK_SET,
null,
Command.CommandStatus.IN_PROGRESS
Command.CommandStatus.IN_PROGRESS,
)
)

Expand Down Expand Up @@ -164,7 +164,7 @@ class CoapMessageHandlingTest {
Instant.now(),
Command.CommandType.PSK,
null,
Command.CommandStatus.IN_PROGRESS
Command.CommandStatus.IN_PROGRESS,
)
)
commandRepository.save(
Expand All @@ -175,7 +175,7 @@ class CoapMessageHandlingTest {
Instant.now(),
Command.CommandType.PSK_SET,
null,
Command.CommandStatus.IN_PROGRESS
Command.CommandStatus.IN_PROGRESS,
)
)

Expand Down Expand Up @@ -204,7 +204,7 @@ class CoapMessageHandlingTest {
Instant.now(),
Command.CommandType.REBOOT,
null,
Command.CommandStatus.PENDING
Command.CommandStatus.PENDING,
)
commandRepository.save(pendingCommand)

Expand All @@ -222,7 +222,7 @@ class CoapMessageHandlingTest {
val savedCommand =
commandRepository.findFirstByDeviceIdAndStatusOrderByTimestampIssuedAsc(
DEVICE_ID,
Command.CommandStatus.IN_PROGRESS
Command.CommandStatus.IN_PROGRESS,
)

assertThat(savedCommand).isNotNull()
Expand All @@ -244,7 +244,7 @@ class CoapMessageHandlingTest {
Instant.now(),
Command.CommandType.REBOOT,
"reboot",
Command.CommandStatus.IN_PROGRESS
Command.CommandStatus.IN_PROGRESS,
)
commandRepository.save(commandInProgress)

Expand All @@ -261,7 +261,7 @@ class CoapMessageHandlingTest {
val savedCommand =
commandRepository.findFirstByDeviceIdAndStatusOrderByTimestampIssuedAsc(
DEVICE_ID,
Command.CommandStatus.SUCCESSFUL
Command.CommandStatus.SUCCESSFUL,
)

assertThat(savedCommand).isNotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ import org.springframework.kafka.test.context.EmbeddedKafka
import org.springframework.test.annotation.DirtiesContext

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@EmbeddedKafka(
topics = ["\${kafka.producers.device-message.topic}"],
)
@EmbeddedKafka(topics = ["\${kafka.producers.device-message.topic}"])
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
class DeviceCredentialsRetrievalTest {
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.springframework.util.ResourceUtils
object IntegrationTestHelper {
fun createKafkaConsumer(
embeddedKafkaBroker: EmbeddedKafkaBroker,
topic: String
topic: String,
): Consumer<String, SpecificRecordBase> {
val testProperties = KafkaTestUtils.consumerProps("testGroup", "true", embeddedKafkaBroker)
val consumerFactory =
Expand All @@ -32,7 +32,7 @@ object IntegrationTestHelper {
StringDeserializer(),
AvroDeserializer(
listOf(DeviceMessage.getClassSchema(), CommandFeedback.getClassSchema(), Firmwares.getClassSchema())
)
),
)
val consumer = consumerFactory.createConsumer()
embeddedKafkaBroker.consumeFromAnEmbeddedTopic(consumer, topic)
Expand All @@ -57,7 +57,7 @@ object IntegrationTestHelper {
ProducerConfig.LINGER_MS_CONFIG to 1,
ProducerConfig.BUFFER_MEMORY_CONFIG to "33554432",
ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG to StringSerializer::class.java,
ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG to AvroSerializer::class.java
ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG to AvroSerializer::class.java,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class MakiCommandHandlingTest {
val savedCommand =
commandRepository.findFirstByDeviceIdAndStatusOrderByTimestampIssuedAsc(
DEVICE_ID,
org.gxf.crestdeviceservice.command.entity.Command.CommandStatus.PENDING
org.gxf.crestdeviceservice.command.entity.Command.CommandStatus.PENDING,
)

assertThat(savedCommand).isNotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ import org.springframework.test.annotation.DirtiesContext
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@EmbeddedKafka(
topics = ["\${kafka.producers.device-message.topic}"],
)
@EmbeddedKafka(topics = ["\${kafka.producers.device-message.topic}"])
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
@EnableConfigurationProperties(KafkaProducerProperties::class)
class MessageHandlingTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.springframework.stereotype.Service
class CommandConsumer(
private val commandService: CommandService,
private val commandFeedbackService: CommandFeedbackService,
private val pskService: PskService
private val pskService: PskService,
) {
private val logger = KotlinLogging.logger {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ class Command(
IN_PROGRESS,
SUCCESSFUL,
ERROR,
CANCELLED
CANCELLED,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import org.gxf.crestdeviceservice.firmware.service.FirmwareService
import org.springframework.stereotype.Component

@Component
class FirmwareCommandGenerator(
private val firmwareService: FirmwareService,
) : CommandGenerator {
class FirmwareCommandGenerator(private val firmwareService: FirmwareService) : CommandGenerator {
override fun generateCommandString(command: Command): String {
requireNotNull(command.commandValue) { "commandValue should have a firmware name" }
val deviceId = command.deviceId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object CommandFeedbackMapper {
fun commandEntityToCommandFeedback(
command: Command,
status: ExternalCommandStatus,
message: String
message: String,
): CommandFeedback =
CommandFeedback.newBuilder()
.setDeviceId(command.deviceId)
Expand All @@ -26,7 +26,7 @@ object CommandFeedbackMapper {
fun externalCommandToCommandFeedback(
command: ExternalCommand,
status: ExternalCommandStatus,
message: String
message: String,
): CommandFeedback =
CommandFeedback.newBuilder()
.setDeviceId(command.deviceId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object CommandMapper {
timestampIssued = externalCommand.timestamp,
type = commandNameToType(externalCommand.command),
status = status,
commandValue = externalCommand.value
commandValue = externalCommand.value,
)
} catch (exception: IllegalArgumentException) {
throw CommandValidationException("Command unknown: ${externalCommand.command}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ interface CommandRepository : CrudRepository<Command, UUID> {

fun findAllByDeviceIdAndStatusOrderByTimestampIssuedAsc(
deviceId: String,
status: Command.CommandStatus
status: Command.CommandStatus,
): List<Command>

fun findAllByDeviceIdAndTypeAndStatusOrderByTimestampIssuedAsc(
deviceId: String,
type: Command.CommandType,
status: Command.CommandStatus
status: Command.CommandStatus,
): List<Command>
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.gxf.crestdeviceservice.model.ErrorUrc.Companion.getMessageFromCode

abstract class CommandResultHandler(
private val commandService: CommandService,
private val commandFeedbackService: CommandFeedbackService
private val commandFeedbackService: CommandFeedbackService,
) {
private val logger = KotlinLogging.logger {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.springframework.stereotype.Component
@Component
class FirmwareCommandResultHandler(
val commandService: CommandService,
val commandFeedbackService: CommandFeedbackService
val commandFeedbackService: CommandFeedbackService,
) : CommandResultHandler(commandService, commandFeedbackService) {

private val successUrc = "OTA:SUC"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.springframework.stereotype.Component
class PskSetCommandResultHandler(
val pskService: PskService,
val commandService: CommandService,
val commandFeedbackService: CommandFeedbackService
val commandFeedbackService: CommandFeedbackService,
) : CommandResultHandler(commandService, commandFeedbackService) {

private val logger = KotlinLogging.logger {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.springframework.stereotype.Service
@Service
class CommandFeedbackService(
private val kafkaTemplate: KafkaTemplate<String, SpecificRecordBase>,
kafkaProducerProperties: KafkaProducerProperties
kafkaProducerProperties: KafkaProducerProperties,
) {
private val topic = kafkaProducerProperties.commandFeedback.topic

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.springframework.stereotype.Service
@Service
class CommandResultService(
private val commandService: CommandService,
private val commandResultHandlersByType: Map<Command.CommandType, CommandResultHandler>
private val commandResultHandlersByType: Map<Command.CommandType, CommandResultHandler>,
) {
private val logger = KotlinLogging.logger {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.springframework.stereotype.Service
@Service
class CommandService(
private val commandRepository: CommandRepository,
private val commandFeedbackService: CommandFeedbackService
private val commandFeedbackService: CommandFeedbackService,
) {
private val logger = KotlinLogging.logger {}

Expand All @@ -42,7 +42,7 @@ class CommandService(
private fun deviceHasNewerSameCommand(
deviceId: String,
commandType: Command.CommandType,
timestampNewCommand: Instant
timestampNewCommand: Instant,
): Boolean {
val latestCommandInDatabase = getLatestCommandInDatabase(deviceId, commandType) ?: return false

Expand All @@ -55,7 +55,7 @@ class CommandService(
.findAllByDeviceIdAndTypeAndStatusOrderByTimestampIssuedAsc(
deviceId,
commandType,
Command.CommandStatus.IN_PROGRESS
Command.CommandStatus.IN_PROGRESS,
)
.isNotEmpty()

Expand Down Expand Up @@ -93,7 +93,7 @@ class CommandService(
fun getFirstCommandInProgressForDevice(deviceId: String) =
commandRepository.findFirstByDeviceIdAndStatusOrderByTimestampIssuedAsc(
deviceId,
Command.CommandStatus.IN_PROGRESS
Command.CommandStatus.IN_PROGRESS,
)

fun getAllPendingCommandsForDevice(deviceId: String) =
Expand All @@ -102,7 +102,7 @@ class CommandService(
fun getAllCommandsInProgressForDevice(deviceId: String) =
commandRepository.findAllByDeviceIdAndStatusOrderByTimestampIssuedAsc(
deviceId,
Command.CommandStatus.IN_PROGRESS
Command.CommandStatus.IN_PROGRESS,
)

fun saveCommand(command: Command) = commandRepository.save(command)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class KafkaConfiguration(private val kafkaProperties: KafkaProperties, private v
DefaultKafkaConsumerFactory(
kafkaProperties.buildConsumerProperties(sslBundles),
StringDeserializer(),
AvroDeserializer(listOf(DeviceCredentials.getClassSchema(), Command.getClassSchema()))
AvroDeserializer(listOf(DeviceCredentials.getClassSchema(), Command.getClassSchema())),
)

@Bean
Expand All @@ -45,6 +45,6 @@ class KafkaConfiguration(private val kafkaProperties: KafkaProperties, private v
DefaultKafkaProducerFactory(
kafkaProperties.buildProducerProperties(sslBundles),
StringSerializer(),
AvroSerializer()
AvroSerializer(),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import org.springframework.boot.context.properties.ConfigurationProperties
class KafkaProducerProperties(
val deviceMessage: KafkaProducerTopicProperties,
val commandFeedback: KafkaProducerTopicProperties,
val firmware: KafkaProducerTopicKeyProperties
val firmware: KafkaProducerTopicKeyProperties,
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class IncomingDeviceCredentialsConsumer(
private val deviceService: DeviceService,
private val pskService: PskService,
private val pskDecryptionService: PskDecryptionService,
private val commandService: CommandService
private val commandService: CommandService,
) {
private val logger = KotlinLogging.logger {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes

@Controller
@RequestMapping("/web/firmware")
class FirmwareController(
val firmwareService: FirmwareService,
val firmwareProducerService: FirmwareProducerService,
) {
class FirmwareController(val firmwareService: FirmwareService, val firmwareProducerService: FirmwareProducerService) {
private val logger = KotlinLogging.logger {}
private val redirectUrl = "redirect:/web/firmware"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class RspController(private val commandService: CommandService) {
timestampIssued = Instant.now(),
type = commandType,
status = Command.CommandStatus.PENDING,
commandValue = null
commandValue = null,
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DownlinkService(
private val pskService: PskService,
private val commandService: CommandService,
private val messageProperties: MessageProperties,
commandGenerators: List<CommandGenerator>
commandGenerators: List<CommandGenerator>,
) {

private val logger = KotlinLogging.logger {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.springframework.stereotype.Service
@Service
class MessageProducerService(
private val kafkaTemplate: KafkaTemplate<String, SpecificRecordBase>,
private val kafkaProducerProperties: KafkaProducerProperties
private val kafkaProducerProperties: KafkaProducerProperties,
) {
private val logger = KotlinLogging.logger {}

Expand All @@ -28,7 +28,7 @@ class MessageProducerService(
deviceId = message["ID"].toString()
timestamp = Instant.now().toEpochMilli()
payload = message.toString()
}
},
)
}
}
Loading

0 comments on commit 3490163

Please sign in to comment.