diff --git a/tests/test-networks-artifact.R b/tests/test-networks-artifact.R index 253e08ba..2ad9a643 100644 --- a/tests/test-networks-artifact.R +++ b/tests/test-networks-artifact.R @@ -212,3 +212,89 @@ patrick::with_parameters_test_that("Network construction of an empty 'comments-o "directed: FALSE" = list(test.directed = FALSE), "directed: TRUE" = list(test.directed = TRUE) )) + +test_that("Network construction with commit-interactions as relation, artifact type 'file'", { + ## configuration object for the datapath + proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, "file") + proj.conf$update.value("commit.interactions", TRUE) + proj.conf$update.value("commits.filter.untracked.files", FALSE) + proj.conf$update.value("commits.filter.base.artifact", FALSE) + proj.data = ProjectData$new(project.conf = proj.conf) + + net.conf = NetworkConf$new() + net.conf$update.value("artifact.relation", "interaction") + + network.builder = NetworkBuilder$new(project.data = proj.data, network.conf = net.conf) + network.built = network.builder$get.artifact.network() + ## build the expected nbetwork + vertices = data.frame( + name = c("test2.c", "test.c"), + kind = "Interaction", + type = TYPE.ARTIFACT + ) + edges = data.frame( + from = c("test2.c", "test2.c", "test.c", "test2.c"), + to = c("test2.c", "test2.c", "test.c", "test2.c"), + func = c("test2.c", "test2.c", "test.c", "test2.c"), + hash = c("0a1a5c523d835459c42f33e863623138555e2526", + "418d1dc4929ad1df251d2aeb833dd45757b04a6f", + "5a5ec9675e98187e1e92561e1888aa6f04faa338", + "d01921773fae4bed8186b0aa411d6a2f7a6626e6"), + base.hash = c("3a0ed78458b3976243db6829f63eba3eead26774", + "0a1a5c523d835459c42f33e863623138555e2526", + "72c8dd25d3dd6d18f46e2b26a5f5b1e2e8dc28d0", + "0a1a5c523d835459c42f33e863623138555e2526"), + base.func = c("test2.c", "test2.c", "test.c", "test2.c"), + base.author = c("Olaf", "Thomas", "Björn", "Thomas"), + interacting.author = c("Thomas", "Karl", "Olaf", "Thomas"), + weight = c(1, 1, 1, 1), + type = c(TYPE.EDGES.INTRA, TYPE.EDGES.INTRA, TYPE.EDGES.INTRA, TYPE.EDGES.INTRA), + relation = c("interaction", "interaction", "interaction", "interaction") + ) + network = igraph::graph.data.frame(edges, directed = FALSE, vertices = vertices) + + expect_true(igraph::identical_graphs(network.built, network)) +}) + +test_that("Network construction with commit-interactions as relation, artifact type 'function'", { + ## configuration object for the datapath + proj.conf = ProjectConf$new(CF.DATA, CF.SELECTION.PROCESS, CASESTUDY, "function") + proj.conf$update.value("commit.interactions", TRUE) + proj.conf$update.value("commits.filter.untracked.files", FALSE) + proj.conf$update.value("commits.filter.base.artifact", FALSE) + proj.data = ProjectData$new(project.conf = proj.conf) + + net.conf = NetworkConf$new() + net.conf$update.value("artifact.relation", "interaction") + + network.builder = NetworkBuilder$new(project.data = proj.data, network.conf = net.conf) + network.built = network.builder$get.artifact.network() + ## build the expected nbetwork + vertices = data.frame( + name = c("test2.c", "test.c"), + kind = "Interaction", + type = TYPE.ARTIFACT + ) + edges = data.frame( + from = c("test2.c", "test2.c", "test.c", "test2.c"), + to = c("test2.c", "test2.c", "test.c", "test2.c"), + hash = c("0a1a5c523d835459c42f33e863623138555e2526", + "418d1dc4929ad1df251d2aeb833dd45757b04a6f", + "5a5ec9675e98187e1e92561e1888aa6f04faa338", + "d01921773fae4bed8186b0aa411d6a2f7a6626e6"), + file = c("test2.c", "test2.c", "test.c", "test2.c"), + base.hash = c("3a0ed78458b3976243db6829f63eba3eead26774", + "0a1a5c523d835459c42f33e863623138555e2526", + "72c8dd25d3dd6d18f46e2b26a5f5b1e2e8dc28d0", + "0a1a5c523d835459c42f33e863623138555e2526"), + base.file = c("test2.c", "test2.c", "test.c", "test2.c"), + base.author = c("Olaf", "Thomas", "Björn", "Thomas"), + interacting.author = c("Thomas", "Karl", "Olaf", "Thomas"), + weight = c(1, 1, 1, 1), + type = c(TYPE.EDGES.INTRA, TYPE.EDGES.INTRA, TYPE.EDGES.INTRA, TYPE.EDGES.INTRA), + relation = c("interaction", "interaction", "interaction", "interaction") + ) + network = igraph::graph.data.frame(edges, directed = FALSE, vertices = vertices) + + expect_true(igraph::identical_graphs(network.built, network)) +})