Skip to content

Commit

Permalink
More asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
lshala committed Jan 17, 2025
1 parent b39f758 commit 99d17ac
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ import de.fraunhofer.aisec.cpg.graph.builder.translationResult
import de.fraunhofer.aisec.cpg.graph.builder.translationUnit
import de.fraunhofer.aisec.cpg.graph.calls
import de.fraunhofer.aisec.cpg.graph.conceptNodes
import de.fraunhofer.aisec.cpg.graph.methods
import de.fraunhofer.aisec.cpg.graph.operationNodes
import de.fraunhofer.aisec.cpg.graph.statements.expressions.MemberCallExpression
import de.fraunhofer.aisec.cpg.graph.statements.expressions.Reference
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertIs
import kotlin.test.assertNotNull

class RestApiConceptTest {
Expand All @@ -54,10 +58,14 @@ class RestApiConceptTest {
assertNotNull(concept)
assertNotNull(operation)

val createMethod = result.methods.firstOrNull()
assertEquals(createMethod, concept.underlyingNode)
assertEquals(operation.concept, concept)
assertEquals("POST", operation.httpMethod.name)
val memberCall = operation.underlyingNode
assertNotNull(memberCall)
assertIs<MemberCallExpression>(memberCall)
assertIs<Reference>(memberCall.arguments.first())
}
}

Expand All @@ -74,9 +82,10 @@ fun getRestApiTranslationResult() =
}
}

val createMethod = controller.methods.first()
val apiConcept =
this@translationResult.newRestApiConcept(
underlyingNode = controller,
underlyingNode = createMethod,
apiUrl = "/example/api/{id}",
role = ApiRole.CONSUMER,
)
Expand Down

0 comments on commit 99d17ac

Please sign in to comment.