fun testHealthItemShouldNotBeShownTwice()

in src/test-integration/kotlin/org/jetbrains/teamcity/github/GitHubWebHookSuggestionTest.kt [155:189]


    fun testHealthItemShouldNotBeShownTwice() {
        val p1 = myFixture.createProject("P1")
        val p2 = myFixture.createProject("P2", p1)

        registerBuildType("BT1", p1, "Ant")

        val bt21 = registerBuildType("BT21", p2, "Ant")
        val bt22 = registerBuildType("BT22", p2, "Ant")

        val vcs = addGitVcsRoot(p1, "https://github.com/%owner%/%name%")

        p2.addParameter(SimpleParameter("owner", "A"))
        p2.addParameter(SimpleParameter("name", "B"))

        bt21.addVcsRoot(vcs)
        bt22.addVcsRoot(vcs)

        addGitHubConnection(p2)

        val allBTs = p1.buildTypes

        then(Util.getVcsRootsWhereHookCanBeInstalled(allBTs, myOAuthConnectionsManager!!).map { it.second }.toSet()).containsExactlyElementsOf((bt21.vcsRootInstances + bt22.vcsRootInstances).toSet())

        val consumer = report(allBTs)

        then(consumer.global).isEmpty()
        then(consumer.project.keys).containsOnly(p2)
        then(consumer.project[p2]).hasSize(1)

        then(consumer.vcsRoot).isEmpty() // Vcs Root belongs to parent project which does not have connection

        then(consumer.buildType.keys).containsOnly(bt21, bt22)
        then(consumer.buildType[bt21]).hasSize(1)
        then(consumer.buildType[bt22]!! + consumer.buildType[bt21]!!).hasSize(1)
    }