48 lines
1.4 KiB
Kotlin
48 lines
1.4 KiB
Kotlin
package com.securityc4po.api.pentest
|
|
|
|
import com.securityc4po.api.BaseEntity
|
|
import com.securityc4po.api.configuration.BC_BAD_CAST_TO_ABSTRACT_COLLECTION
|
|
import com.securityc4po.api.configuration.MESSAGE_BAD_CAST_TO_ABSTRACT_COLLECTION
|
|
import com.securityc4po.api.pentest.comment.Comment
|
|
import com.securityc4po.api.pentest.finding.Finding
|
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
|
|
import org.springframework.data.mongodb.core.mapping.Document
|
|
|
|
@Document(collection = "pentests")
|
|
open class PentestEntity(
|
|
data: Pentest
|
|
) : BaseEntity<Pentest>(data)
|
|
|
|
fun PentestEntity.toPentest(): Pentest {
|
|
return Pentest(
|
|
this.data.id,
|
|
this.data.projectId,
|
|
this.data.category,
|
|
this.data.refNumber,
|
|
this.data.status,
|
|
this.data.enabled,
|
|
this.data.findingIds,
|
|
this.data.commentIds,
|
|
this.data.timeSpent
|
|
)
|
|
}
|
|
|
|
fun PentestEntity.toCompletedPentest(): CompletedPentest {
|
|
return CompletedPentest(
|
|
this.data.id,
|
|
this.data.projectId,
|
|
this.data.category,
|
|
this.data.refNumber,
|
|
this.data.status,
|
|
mutableListOf<Finding>(),
|
|
mutableListOf<Comment>()
|
|
)
|
|
}
|
|
|
|
@SuppressFBWarnings(BC_BAD_CAST_TO_ABSTRACT_COLLECTION, MESSAGE_BAD_CAST_TO_ABSTRACT_COLLECTION)
|
|
fun List<PentestEntity>.toPentests(): List<Pentest> {
|
|
return this.map {
|
|
it.toPentest()
|
|
}
|
|
}
|