Add ktlint plugin
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package be.simplenotes.persistance
|
||||
|
||||
import be.simplenotes.config.DataSourceConfig
|
||||
import be.simplenotes.persistance.utils.DbType
|
||||
import be.simplenotes.persistance.utils.type
|
||||
import be.simplenotes.config.DataSourceConfig
|
||||
import me.liuwj.ktorm.database.Database
|
||||
import me.liuwj.ktorm.database.asIterable
|
||||
import me.liuwj.ktorm.database.use
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package be.simplenotes.persistance
|
||||
|
||||
import be.simplenotes.config.DataSourceConfig
|
||||
import be.simplenotes.persistance.utils.DbType
|
||||
import be.simplenotes.persistance.utils.type
|
||||
import be.simplenotes.config.DataSourceConfig
|
||||
import org.flywaydb.core.Flyway
|
||||
import javax.sql.DataSource
|
||||
|
||||
|
||||
+14
-12
@@ -10,7 +10,6 @@ import org.mapstruct.ReportingPolicy
|
||||
import java.time.LocalDateTime
|
||||
import java.util.*
|
||||
|
||||
|
||||
/**
|
||||
* This is an abstract class because kotlin default methods in interface are not seen as default in kapt
|
||||
* @see [KT-25960](https://youtrack.jetbrains.com/issue/KT-25960)
|
||||
@@ -35,7 +34,11 @@ internal abstract class NoteConverter {
|
||||
|
||||
fun toPersistedNote(entity: NoteEntity, tags: Tags) = PersistedNote(
|
||||
NoteMetadata(title = entity.title, tags = tags),
|
||||
entity.markdown, entity.html, entity.updatedAt, entity.uuid, entity.public
|
||||
entity.markdown,
|
||||
entity.html,
|
||||
entity.updatedAt,
|
||||
entity.uuid,
|
||||
entity.public
|
||||
)
|
||||
|
||||
@Mappings(
|
||||
@@ -46,15 +49,15 @@ internal abstract class NoteConverter {
|
||||
abstract fun toExportedNote(entity: NoteEntity, tags: Tags): ExportedNote
|
||||
|
||||
fun toEntity(note: Note, uuid: UUID, userId: Int, updatedAt: LocalDateTime) = NoteEntity {
|
||||
this.title = note.meta.title
|
||||
this.markdown = note.markdown
|
||||
this.html = note.html
|
||||
this.uuid = uuid
|
||||
this.deleted = false
|
||||
this.public = false
|
||||
this.user.id = userId
|
||||
this.updatedAt = updatedAt
|
||||
}
|
||||
this.title = note.meta.title
|
||||
this.markdown = note.markdown
|
||||
this.html = note.html
|
||||
this.uuid = uuid
|
||||
this.deleted = false
|
||||
this.public = false
|
||||
this.user.id = userId
|
||||
this.updatedAt = updatedAt
|
||||
}
|
||||
|
||||
@Mappings(
|
||||
Mapping(target = ".", source = "note"),
|
||||
@@ -73,7 +76,6 @@ internal abstract class NoteConverter {
|
||||
|
||||
@Mapping(target = "deleted", source = "trash")
|
||||
abstract fun toEntity(exportedNote: ExportedNote): NoteEntity
|
||||
|
||||
}
|
||||
|
||||
typealias Tags = List<String>
|
||||
|
||||
+2
-3
@@ -1,11 +1,11 @@
|
||||
package be.simplenotes.persistance.notes
|
||||
|
||||
import be.simplenotes.persistance.converters.NoteConverter
|
||||
import be.simplenotes.persistance.repositories.NoteRepository
|
||||
import be.simplenotes.types.ExportedNote
|
||||
import be.simplenotes.types.Note
|
||||
import be.simplenotes.types.PersistedNote
|
||||
import be.simplenotes.types.PersistedNoteMetadata
|
||||
import be.simplenotes.persistance.converters.NoteConverter
|
||||
import be.simplenotes.persistance.repositories.NoteRepository
|
||||
import me.liuwj.ktorm.database.Database
|
||||
import me.liuwj.ktorm.dsl.*
|
||||
import me.liuwj.ktorm.entity.*
|
||||
@@ -211,5 +211,4 @@ internal class NoteRepositoryImpl(private val db: Database, private val converte
|
||||
.filter { it.noteUuid inList map { note -> note.uuid } }
|
||||
.groupByTo(HashMap(), { it.note.uuid }, { it.name })
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package be.simplenotes.persistance.users
|
||||
|
||||
import be.simplenotes.types.PersistedUser
|
||||
import be.simplenotes.types.User
|
||||
import be.simplenotes.persistance.converters.UserConverter
|
||||
import be.simplenotes.persistance.repositories.UserRepository
|
||||
import be.simplenotes.types.PersistedUser
|
||||
import be.simplenotes.types.User
|
||||
import me.liuwj.ktorm.database.Database
|
||||
import me.liuwj.ktorm.dsl.*
|
||||
import me.liuwj.ktorm.entity.any
|
||||
|
||||
+8
-7
@@ -26,10 +26,14 @@ internal class NoteConverterTest {
|
||||
}
|
||||
val tags = listOf("a", "b")
|
||||
val note = converter.toNote(entity, tags)
|
||||
val expectedNote = Note(NoteMetadata(
|
||||
title = "title",
|
||||
tags = tags,
|
||||
), markdown = "md", html = "html")
|
||||
val expectedNote = Note(
|
||||
NoteMetadata(
|
||||
title = "title",
|
||||
tags = tags,
|
||||
),
|
||||
markdown = "md",
|
||||
html = "html"
|
||||
)
|
||||
assertThat(note).isEqualTo(expectedNote)
|
||||
}
|
||||
|
||||
@@ -77,7 +81,6 @@ internal class NoteConverterTest {
|
||||
)
|
||||
assertThat(note).isEqualTo(expectedNote)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Nested
|
||||
@@ -162,7 +165,5 @@ internal class NoteConverterTest {
|
||||
.hasFieldOrPropertyWithValue("updatedAt", exportedNote.updatedAt)
|
||||
.hasFieldOrPropertyWithValue("deleted", true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package be.simplenotes.persistance.converters
|
||||
|
||||
import be.simplenotes.persistance.users.UserEntity
|
||||
import be.simplenotes.types.PersistedUser
|
||||
import be.simplenotes.types.User
|
||||
import be.simplenotes.persistance.users.UserEntity
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mapstruct.factory.Mappers
|
||||
|
||||
+1
-2
@@ -1,14 +1,13 @@
|
||||
package be.simplenotes.persistance.notes
|
||||
|
||||
import be.simplenotes.config.DataSourceConfig
|
||||
import be.simplenotes.persistance.DbMigrations
|
||||
import be.simplenotes.persistance.converters.NoteConverter
|
||||
import be.simplenotes.persistance.migrationModule
|
||||
import be.simplenotes.persistance.persistanceModule
|
||||
import be.simplenotes.config.DataSourceConfig
|
||||
import be.simplenotes.persistance.repositories.NoteRepository
|
||||
import be.simplenotes.persistance.repositories.UserRepository
|
||||
import be.simplenotes.types.*
|
||||
import be.simplenotes.types.*
|
||||
import me.liuwj.ktorm.database.Database
|
||||
import me.liuwj.ktorm.dsl.eq
|
||||
import me.liuwj.ktorm.entity.filter
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package be.simplenotes.persistance.users
|
||||
|
||||
import be.simplenotes.types.User
|
||||
import be.simplenotes.persistance.repositories.UserRepository
|
||||
import be.simplenotes.config.DataSourceConfig
|
||||
import be.simplenotes.persistance.DbMigrations
|
||||
import be.simplenotes.persistance.migrationModule
|
||||
import be.simplenotes.persistance.persistanceModule
|
||||
import be.simplenotes.config.DataSourceConfig
|
||||
import be.simplenotes.persistance.repositories.UserRepository
|
||||
import be.simplenotes.types.User
|
||||
import me.liuwj.ktorm.database.*
|
||||
import me.liuwj.ktorm.dsl.*
|
||||
import me.liuwj.ktorm.entity.*
|
||||
|
||||
Reference in New Issue
Block a user