<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. 
 *  
 */


$.ajaxSetup({
    async: false
});

var cdv;

$(function(){
    

    setTimeout(function(){

        cdv = wd.cdv.cdv({
            isServerSide: false
        });
        
        
        // Register tests
        
        cdv.registerTest({
            id: 1,
            type: "query",
            name: "Test 1",
            group: "CDV Sample Tests",
            createdBy: "Pedro",
            createdAt: 1339430893246,
            validation: [ 
            {
                cdaFile: "/plugin-samples/cda/cdafiles/sql-jndi.cda", 
                dataAccessId: "1" , 
                parameters: {}
            },
            {
                cdaFile: "/plugin-samples/cda/cdafiles/sql-jndi.cda", 
                dataAccessId: "1" , 
                parameters: {
                    status:"Cancelled"
                }
            }
            ],
            validations: 
            [
            {
                validationName: "Test Existence",
                validationType: "custom",
                validationFunction:  function(rs, conf) {
            
                
                    var _conf = {
                        testAll: true
                    };
                    conf = _.extend({},_conf,conf);
                    var exists = !!conf.testAll;

                    exists = _.reduce(_.map(rs,function(r){
                        return r.resultset.length > 0
                    }),function(prev, curr, exists){
                        return conf.testAll ? (curr && prev) : (curr || prev);
                    });

                    return exists ? "OK" : "ERROR";
        
                }
            },
            {
                validationName: "Test Existence 2",
                validationType: "custom",
                validationFunction:  function(rs, conf) {
            
                
                    var _conf = {
                        testAll: true
                    };
                    conf = _.extend({},_conf,conf);
                    var exists = !!conf.testAll;

                    exists = _.reduce(_.map(rs,function(r){
                        return r.resultset.length > 0
                    }),function(prev, curr, exists){
                        return conf.testAll ? (curr && prev) : (curr || prev);
                    });

                    return exists ? "ERROR" : "OK";
        
                }
            }
            ],
            executionTimeValidation: {
                expected: 100,
                warnPercentage: 0.30,
                errorPercentage: 0.70,
                errorOnLow: true
            },

            cron: "0 2 * * ? *" 
        });



        cdv.registerTest({
            id: 2,
            type: "query",
            name: "Test 2",
            group: "CDV Sample Tests",
            createdBy: "Pedro",
            createdAt: 1339430893246,
            validation: [ 
            {
                cdaFile: "/plugin-samples/cda/cdafiles/mondrian-jndi.cda", 
                dataAccessId: "1" , 
                parameters: {}
            },
            {
                cdaFile: "/plugin-samples/cda/cdafiles/mondrian-jndi.cda", 
                dataAccessId: "1" , 
                parameters: {
                    status:"Cancelled"
                }
            }
            ],
            validations: 
            [{
                validationName: "Test Existence",
                validationType: "custom",
                validationFunction:  function(rs, conf) {
            
                    var _conf = {
                        testAll: true
                    };
                    conf = _.extend({},_conf,conf);
                    var exists = !!conf.testAll;

                    exists = _.reduce(_.map(rs,function(r){
                        return r.resultset.length > 0
                    }),function(prev, curr, exists){
                        return conf.testAll ? (curr && prev) : (curr || prev);
                    });
                    return exists ? "ERROR" : "OK";
        
                }
            }],
            executionTimeValidation: {
                expected: 100,
                warnPercentage: 0.30,
                errorPercentage: 0.70,
                errorOnLow: true
            },

            cron: "0 2 * * ? *" 
        });


        
        // Test 1: List
        $(".results").text(JSON.stringify( cdv.listTestsFlatten("CDV Sample Tests")  ));
        
        // Call again to make sure we're not overriding something
        //$(".results").text(JSON.stringify( cdv.listTestsFlatten("CDV Sample Tests")  ));
        
        
        
        // Test 2: Execute a test
        
        /*
        var callback = function(result){
            $(".results").text(JSON.stringify(result));
        }
        
        cdv.runTest(cdv.getTest("CDV Sample Tests","Test 1") , {
            callback: callback
        });
        */
        
        
            
    },100)
    
<commit_msg>- CDV playground points to test execution<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. 
 *  
 */


$.ajaxSetup({
    async: false
});

var cdv;

$(function(){
    

    setTimeout(function(){

        cdv = wd.cdv.cdv({
            isServerSide: false
        });
        
        
        // Register tests
        
        cdv.registerTest({
            id: 1,
            type: "query",
            name: "Test 1",
            group: "CDV Sample Tests",
            createdBy: "Pedro",
            createdAt: 1339430893246,
            validation: [ 
            {
                cdaFile: "/plugin-samples/cda/cdafiles/sql-jndi.cda", 
                dataAccessId: "1" , 
                parameters: {}
            },
            {
                cdaFile: "/plugin-samples/cda/cdafiles/sql-jndi.cda", 
                dataAccessId: "1" , 
                parameters: {
                    status:"Cancelled"
                }
            }
            ],
            validations: 
            [
            {
                validationName: "Test Existence",
                validationType: "custom",
                validationFunction:  function(rs, conf) {
            
                
                    var _conf = {
                        testAll: true
                    };
                    conf = _.extend({},_conf,conf);
                    var exists = !!conf.testAll;

                    exists = _.reduce(_.map(rs,function(r){
                        return r.resultset.length > 0
                    }),function(prev, curr, exists){
                        return conf.testAll ? (curr && prev) : (curr || prev);
                    });

                    return exists ? "OK" : "ERROR";
        
                }
            },
            {
                validationName: "Test Existence 2",
                validationType: "custom",
                validationFunction:  function(rs, conf) {
            
                
                    var _conf = {
                        testAll: true
                    };
                    conf = _.extend({},_conf,conf);
                    var exists = !!conf.testAll;

                    exists = _.reduce(_.map(rs,function(r){
                        return r.resultset.length > 0
                    }),function(prev, curr, exists){
                        return conf.testAll ? (curr && prev) : (curr || prev);
                    });

                    return exists ? "ERROR" : "OK";
        
                }
            }
            ],
            executionTimeValidation: {
                expected: 100,
                warnPercentage: 0.30,
                errorPercentage: 0.70,
                errorOnLow: true
            },

            cron: "0 2 * * ? *" 
        });



        cdv.registerTest({
            id: 2,
            type: "query",
            name: "Test 2",
            group: "CDV Sample Tests",
            createdBy: "Pedro",
            createdAt: 1339430893246,
            validation: [ 
            {
                cdaFile: "/plugin-samples/cda/cdafiles/mondrian-jndi.cda", 
                dataAccessId: "1" , 
                parameters: {}
            },
            {
                cdaFile: "/plugin-samples/cda/cdafiles/mondrian-jndi.cda", 
                dataAccessId: "1" , 
                parameters: {
                    status:"Cancelled"
                }
            }
            ],
            validations: 
            [{
                validationName: "Test Existence",
                validationType: "custom",
                validationFunction:  function(rs, conf) {
            
                    var _conf = {
                        testAll: true
                    };
                    conf = _.extend({},_conf,conf);
                    var exists = !!conf.testAll;

                    exists = _.reduce(_.map(rs,function(r){
                        return r.resultset.length > 0
                    }),function(prev, curr, exists){
                        return conf.testAll ? (curr && prev) : (curr || prev);
                    });
                    return exists ? "ERROR" : "OK";
        
                }
            }],
            executionTimeValidation: {
                expected: 100,
                warnPercentage: 0.30,
                errorPercentage: 0.70,
                errorOnLow: true
            },

            cron: "0 2 * * ? *" 
        });


        
        // Test 1: List
        //$(".results").text(JSON.stringify( cdv.listTestsFlatten("CDV Sample Tests")  ));
        
        // Call again to make sure we're not overriding something
        //$(".results").text(JSON.stringify( cdv.listTestsFlatten("CDV Sample Tests")  ));
        
        
        
        // Test 2: Execute a test
        
        
        var callback = function(result){
            $(".results").text(JSON.stringify(result));
        }
        
        cdv.runTest(cdv.getTest("CDV Sample Tests","Test 1") , {
            callback: callback
        });
        
        
        
            
    },100)
    

{'fraction_non_alphanumeric': 0.10849236641221374, 'fraction_numerical': 0.013358778625954198, 'mean_word_length': 0.933050534857986, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1445808', 'n_tokens_mistral': 2858, 'n_tokens_neox': 2557, 'n_words': 550}