Skip to content

Commit

Permalink
rescructure cpg-neo4j tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peckto committed Jul 21, 2023
1 parent bb95e9e commit a629375
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class Application : Callable<Int> {
* point to a file, is a directory or point to a hidden file or the paths does not have the
* same top level path.
*/
private fun setupTranslationConfiguration(): TranslationConfiguration {
fun setupTranslationConfiguration(): TranslationConfiguration {
val translationConfiguration =
TranslationConfiguration.builder()
.topLevel(topLevel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,35 @@
*/
package de.fraunhofer.aisec.cpg_vis_neo4j

import de.fraunhofer.aisec.cpg.TranslationConfiguration
import de.fraunhofer.aisec.cpg.TranslationManager
import de.fraunhofer.aisec.cpg.TranslationResult
import de.fraunhofer.aisec.cpg.graph.declarations.FunctionDeclaration
import de.fraunhofer.aisec.cpg.graph.functions
import java.io.File
import java.nio.file.Paths
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import org.junit.jupiter.api.Tag
import picocli.CommandLine

@Tag("integration")
class ApplicationTest {

private var translationResult: TranslationResult? = null

@Test
@Throws(InterruptedException::class)
fun testPush() {
val topLevel = Paths.get("src").resolve("test").resolve("resources").toAbsolutePath()
val path = topLevel.resolve("client.cpp").toAbsolutePath()
val file = File(path.toString())
assert(file.exists() && !file.isDirectory && !file.isHidden)
val translationConfiguration =
TranslationConfiguration.builder()
.sourceLocations(file)
.topLevel(topLevel.toFile())
.defaultPasses()
.defaultLanguages()
.debugParser(true)
.build()
val translationManager =
TranslationManager.builder().config(translationConfiguration).build()
translationResult = translationManager.analyze().get()

assertEquals(31, translationResult.functions.size)
val cmd = CommandLine(Application::class.java)
cmd.parseArgs(path.toString())
val application = cmd.getCommand<Application>()

val application = Application()
val translationConfiguration = application.setupTranslationConfiguration()
val translationResult =
TranslationManager.builder().config(translationConfiguration).build().analyze().get()

assertEquals(31, translationResult.functions.size)

application.pushToNeo4j(translationResult!!)
application.pushToNeo4j(translationResult)

val sessionAndSessionFactoryPair = application.connect()

Expand Down

0 comments on commit a629375

Please sign in to comment.