<commit_before>package net.nemerosa.ontrack.boot.graphql

import net.nemerosa.ontrack.model.structure.NameDescription
import net.nemerosa.ontrack.model.structure.ValidationRunStatusID
import org.junit.Test

class BranchBuildsFilterQLIT extends AbstractQLITSupport {

    @Test
    void 'Default filter with validation stamp'() {
        def branch = doCreateBranch()
        def build = doCreateBuild(branch, NameDescription.nd('1', ''))
        doValidateBuild(build, 'VS', ValidationRunStatusID.STATUS_PASSED)

        def data = run("""{
            branches (id: ${branch.id}) {
                builds(filter: {withValidationStamp: "VS"}) {
                    edges {
                        node {
                            name
                        }
                    }
                }
            }
        }""")
        assert data.branches.first().builds.edges.node.name.flatten() == [build.name]

        data = run("""{
            branches (id: ${branch.id}) {
                builds(filter: {withValidationStamp: "NONE"}) {
                    edges {
                        node {
                            name
                        }
                    }
                }
            }
        }""")
        assert data.branches.first().builds.edges.node.name.flatten() == []
    }

    @Test
    void 'Default filter with validation stamp and returning validation runs'() {
        def branch = doCreateBranch()
        def build = doCreateBuild(branch, NameDescription.nd('1', ''))
        doValidateBuild(build, 'VS', ValidationRunStatusID.STATUS_PASSED)

        def data = run("""{
            branches (id: ${branch.id}) {
                builds(filter: {withValidationStamp: "VS"}) {
                    edges {
                        node {
                            name
                            validationRuns {
                                validationRunStatuses {
                                    statusID {
                                        id
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }""")
        assert data.branches.first().builds.edges.node.name.flatten() == [build.name]
        assert data.branches.first().builds.edges.node.validationRuns.validationRunStatuses.statusID.id.flatten() == ['PASSED']
    }

}
<commit_msg>#458 Build filter: with validation stamp status<commit_after>package net.nemerosa.ontrack.boot.graphql

import net.nemerosa.ontrack.model.structure.NameDescription
import net.nemerosa.ontrack.model.structure.ValidationRunStatusID
import org.junit.Test

class BranchBuildsFilterQLIT extends AbstractQLITSupport {

    @Test
    void 'Default filter with validation stamp'() {
        def branch = doCreateBranch()
        def build = doCreateBuild(branch, NameDescription.nd('1', ''))
        doValidateBuild(build, 'VS', ValidationRunStatusID.STATUS_PASSED)

        def data = run("""{
            branches (id: ${branch.id}) {
                builds(filter: {withValidationStamp: "VS"}) {
                    edges {
                        node {
                            name
                        }
                    }
                }
            }
        }""")
        assert data.branches.first().builds.edges.node.name.flatten() == [build.name]

        data = run("""{
            branches (id: ${branch.id}) {
                builds(filter: {withValidationStamp: "NONE"}) {
                    edges {
                        node {
                            name
                        }
                    }
                }
            }
        }""")
        assert data.branches.first().builds.edges.node.name.flatten() == []
    }

    @Test
    void 'Default filter with validation stamp and returning validation runs'() {
        def branch = doCreateBranch()
        def build = doCreateBuild(branch, NameDescription.nd('1', ''))
        doValidateBuild(build, 'VS', ValidationRunStatusID.STATUS_PASSED)

        def data = run("""{
            branches (id: ${branch.id}) {
                builds(filter: {withValidationStamp: "VS"}) {
                    edges {
                        node {
                            name
                            validationRuns {
                                validationRunStatuses {
                                    statusID {
                                        id
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }""")
        assert data.branches.first().builds.edges.node.name.flatten() == [build.name]
        assert data.branches.first().builds.edges.node.validationRuns.validationRunStatuses.statusID.id.flatten() == ['PASSED']
    }

    @Test
    void 'Default filter with validation stamp status'() {
        def branch = doCreateBranch()
        def vs = doCreateValidationStamp(branch, NameDescription.nd('VS', ''))
        doValidateBuild(doCreateBuild(branch, NameDescription.nd('1', '')), vs, ValidationRunStatusID.STATUS_FAILED)
        doValidateBuild(doCreateBuild(branch, NameDescription.nd('2', '')), vs, ValidationRunStatusID.STATUS_PASSED)

        def data = run("""{
            branches (id: ${branch.id}) {
                builds(filter: {withValidationStamp: "VS", withValidationStampStatus: "PASSED"}) {
                    edges {
                        node {
                            name
                        }
                    }
                }
            }
        }""")
        assert data.branches.first().builds.edges.node.name.flatten() == ['2']
    }

}

{'fraction_non_alphanumeric': 0.10720471077242813, 'fraction_numerical': 0.0017319016279875303, 'mean_word_length': 1.2611589663273297, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2566454', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1408, 'n_words': 246}