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(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(), mutableListOf() ) } @SuppressFBWarnings(BC_BAD_CAST_TO_ABSTRACT_COLLECTION, MESSAGE_BAD_CAST_TO_ABSTRACT_COLLECTION) fun List.toPentests(): List { return this.map { it.toPentest() } }