text:
'use strict';

var test                 = require('selenium-webdriver/testing'),
  register_new_user_func = require('../../lib/register_new_user'),
  login_user_func        = require('../../lib/login_with_user'),
  open_page_func         = require('../../lib/open_page'),
  submit_form_func       = require('../../lib/submit_form'),
  check_elements_func    = require('../../lib/check_elements'),
  By                     = require('selenium-webdriver').By,
  config                 = require('../../lib/config'),
  application_host       = config.get_application_host(),
  expect                 = require('chai').expect,
  Bluebird               = require('bluebird'),
  add_new_user_func      = require('../../lib/add_new_user'),
  user_info_func         = require('../../lib/user_info'),
  new_department_form_id = '#add_new_department_form',
  department_edit_form_id = '#department_edit_form';

/*
 *  Scenario:
 *    * register new account
 *    * check that /settings/departments/ page shows readonly list of departments
 *    * ensure that the list of departments has links for every department
 *    ** to edit department
 *    ** see details of its manager
 *    ** there is a link to Bulk department update page
 *    * create new department by pressing "Add new department" button on the /settings/departments/ page
 *    ** ensure that user is landed on department read only list page
 *    ** use A as a name and ensure it appears in the begining of the list
 *    * create another new department starting with "Z"
 *    ** ensure that it is located at the end of the list
 *
 * */

describe('Check departments list page', function(){
  var driver;

  this.timeout( config.get_execution_timeout() );

  it("Register new account", function(done){
    register_new_user_func({
      application_host : application_host,
    })
    .then(function(data){
      driver = data.driver;
      done();
    });
  });

  it("Open page with department list and ensure it has read-only list", function(done){
    open_page_func({
      url    : application_host + 'settings/departments/',
      driver : driver,
    })
    .then(function(){
      return driver.findElements(By.css('tr[data-vpp-department-list-mode="readonly"]'));
    })
    .then(function(inputs){
      expect(inputs.length).to.be.eql(1);
      done();
    });
  });

  it("Ensure list of departments has links for editing each individual one", function(done){
    driver
      .findElements(By.css('a[href*="/settings/departments/edit/"]'))
      .then(function(links){
        expect(links.length).to.be.eql(2, "We expect to have two edit links per department");
        done();
      })
  });

  it("Ensure department has a link to its Manager edit page", function(done){
    driver
      .findElements(By.css('a[href*="/users/edit/"]'))
      .then(function(links){
        expect(links.length).to.be.eql(1, "There exist one link to manager per department");
        return links[0].getAttribute('href');
      })
      .then(function(href){
        expect(href).to.match(/\/users\/edit\/\d+\/$/, "Link to manager indeed contains ID");
        done();
      });
  });

  it('Add new "AAA" department', function(done){
    driver.findElement(By.css('#add_new_department_btn'))
      .then(function(el){
        return el.click();
      })
      .then(function(){

        // This is very important line when working with Bootstrap modals!
        driver.sleep(1000);

        submit_form_func({
          driver      : driver,
          form_params : [{
            selector : new_department_form_id+' input[name="name__new"]',
            value : 'AAA',
          },{
            selector        : new_department_form_id+' select[name="allowance__new"]',
            option_selector : 'option[value="15"]',
            value : '15',
          }],
          submit_button_selector : new_department_form_id+' button[type="submit"]',
          message : /Changes to departments were saved/,
        })
        .then(function(){ done() });
      });
  });

  it('Ensure that user is landed on department read only list page', function(done){
    driver
      .getCurrentUrl()
      .then(function(url){
        expect(url).to.match(/\/settings\/departments\/$/, 'Ensure the landing page is department list');
        done();
      });
  });

  it('Ensure that newly added department AAA is on top of the list', function(done){
    driver
      .findElements(By.css('a[data-vpp-department-name="1"]'))
      .then(function(els){ return Bluebird.map(els, function(el){ return el.getText() }) })
      .then(function(texts){
        expect(texts).to.have.eql(['AAA', 'Sales'], 'Check the order of names');
        done();
      });
  });

  it('Add new "ZZZ" department', function(done){
    driver.findElement(By.css('#add_new_department_btn'))
      .then(function(el){ return el.click() })
      .then(function(){

        // This is very important line when working with Bootstrap modals!
        driver.sleep(1000);

        submit_form_func({
          driver      : driver,
          form_params : [{
            selector : new_department_form_id+' input[name="name__new"]',
            value : 'ZZZ',
          },{
            selector        : new_department_form_id+' select[name="allowance__new"]',
            option_selector : 'option[value="15"]',
            value : '15',
          }],
          submit_button_selector : new_department_form_id+' button[type="submit"]',
          message : /Changes to departments were saved/,
        })
        .then(function(){ done() });
      });
  });

  it('Ensure that departments respect alphabetical order', function(done){
    driver
      .findElements(By.css('a[data-vpp-department-name="1"]'))
      .then(function(els){ return Bluebird.map(els, function(el){ return el.getText() }) })
      .then(function(texts){
        expect(texts).to.have.eql(['AAA', 'Sales', 'ZZZ'], 'Check the order of names');
        done();
      });
  });

  after(function(done){
    driver.quit().then(function(){ done(); });
  });
});

/*
 *  Scenario:
 *    * create new company account
 *    * create additional user B
 *    * go to existing department
 *    * try to edit name, manager - to be user B, allowance to be 5 and tick the "include public holidays" checkbox
 *    * ensure user stays on the department edit oage after changes were saved
 *    * try to remove the department by pressing Delete button on current page
 *    ** ensure that system prevents form doint it complaining that there are people in this department
 *    * create new department and move both users A and B into it
 *
 *    * delete the original department and make sure it is gone
 *    * go to details of newly added department and check the link 'Employees from department'
 *
 * */

describe("Edit individual department via department details page", function(){
  var driver, email_A, email_B, user_id_A, user_id_B, department_edit_page_url,
    new_department_id;

  this.timeout( config.get_execution_timeout() );

  it("Register new account", function(done){
    register_new_user_func({
      application_host : application_host,
    })
    .then(function(data){
      email_A = data.email;
      driver  = data.driver;
      done();
    });
  });

  it("Create second user B", function(done){
    add_new_user_func({
      application_host : application_host,
      driver           : driver,
    })
    .then(function(data){
      email_B = data.new_user_email;
      done();
    });
  });

  it("Obtain information about user A", function(done){
    user_info_func({
      driver : driver,
      email  : email_A,
    })
    .then(function(data){
      user_id_A = data.user.id;
      done();
    });
  });

  it("Obtain information about user B", function(done){
    user_info_func({
      driver : driver,
      email  : email_B,
    })
    .then(function(data){
      user_id_B = data.user.id;
      done();
    });
  });

  it("Open page with department list and click first department in the list", function(done){
    open_page_func({
      url    : application_host + 'settings/departments/',
      driver : driver,
    })
    .then(function(){
      driver
        .findElements(By.css('a[href*="/settings/departments/edit/"]'))
        .then(function(links){ return links[0].click() })
        .then(function(){ done() });
    });
  });

  it('... save edit page URL', function(done){
    driver
      .getCurrentUrl()
      .then(function(url){
        department_edit_page_url = url;
        done();
      });
  });

  it('Edit department', function(done){
    submit_form_func({
      driver      : driver,
      form_params : [{
        selector : department_edit_form_id+' input[name="name"]',
        value : 'Fantastic name',
      },{
        selector        : department_edit_form_id+' select[name="allowance"]',
        option_selector : 'option[value="5"]',
        value           : '5',
      },{
        selector        : department_edit_form_id+' select[name="boss_id"]',
        option_selector : 'option[value="'+user_id_B+'"]',
        value           : user_id_B,
      },{
        selector : 'input[name="include_public_holidays"]',
        tick     : true,
        value    : 'on',
      }],
      submit_button_selector : department_edit_form_id+' button[type="submit"]',
      message : /Department .* was updated/,
    })
    .then(function(){ done() });
  });

  it('Ensure that chnages were applied', function(done){
    check_elements_func({
      driver            : driver,
      elements_to_check : [{
        selector : department_edit_form_id+' input[name="name"]',
        value : 'Fantastic name',
      },{
        selector        : department_edit_form_id+' select[name="allowance"]',
        option_selector : 'option[value="5"]',
        value           : '5',
      },{
        selector        : department_edit_form_id+' select[name="boss_id"]',
        option_selector : 'option[value="'+user_id_B+'"]',
        value           : user_id_B+"",
      },{
        selector : 'input[name="include_public_holidays"]',
        tick     : false,
        value    : 'off',
      }],
    })
    .then(function(){ done() });
  });

  it('Ensure that user stays on the same page after updating department details', function(done){
    driver
      .getCurrentUrl()
      .then(function(url){
        expect(url).to.be.eql(department_edit_page_url);
        done()
      });
  });

  it('Try to remove the department by pressing Delete button on current page', function(done){
    driver
      .findElement(By.css('button#remove_btn'))
      .then(function(btn){ return btn.click() })
      .then(function(){ done() });
  });

  it('Ensure that system prevents deleting department', function(done){
    driver
      .findElement( By.css('div.alert') )
      .then(function(el){ return el.getText() })
      .then(function(txt){
        expect(txt).to.match(
          /Cannot remove department .+ as it still has 2 users/,
          'App complains about non empty department'
        );
        done();
      });
  });

  it('Go to departments list by clicking on corresponding link', function(done){
    driver
      .findElement(By.css('a[data-vpp-all-departments-link="1"]'))
      .then(function(link){ return link.click() })
      .then(function(){ done() });
  });

  it('Add new "AAA" department', function(done){
    driver
      .findElement(By.css('#add_new_department_btn'))
      .then(function(el){ return el.click() })
      .then(function(){

        // This is very important line when working with Bootstrap modals!
        driver.sleep(1000);

        submit_form_func({
          driver      : driver,
          form_params : [{
            selector : new_department_form_id+' input[name="name__new"]',
            value : 'AAA',
          },{
            selector        : new_department_form_id+' select[name="allowance__new"]',
            option_selector : 'option[value="15"]',
            value : '15',
          }],
          submit_button_selector : new_department_form_id+' button[type="submit"]',
          message : /Changes to departments were saved/,
        })
        .then(function(){ done() });
      });
  });

  it('Fetch newly added department ID', function(done){
    driver
      .findElements(By.css('a[data-vpp-department-name="1"]'))
      // We know that newly added attribute is in the top of the list as it starts with "A"
      .then(function(links){ return links[0].getAttribute('href')})
      .then(function(href){
        new_department_id = href.match(/settings\/departments\/edit\/(\d+)\//)[1];
        expect(new_department_id).to.match(/^\d+$/, 'The department ID is number');
        done();
      });
  });

  it("Open user A details page", function(done){
    open_page_func({
      url    : application_host + 'users/edit/'+user_id_A+'/',
      driver : driver,
    })
    .then(function(){ done() });
  });

  it('... and move her to newly added department', function(done){
    submit_form_func({
      driver      : driver,
      form_params : [{
        selector        : 'select[name="department"]',
        option_selector : 'option[value="'+new_department_id+'"]',
        value           : new_department_id,
      }],
      submit_button_selector : 'button#save_changes_btn',
      message : /Details for .+ were updated/,
    })
    .then(function(){ done() });
  });

  it('Ensure that chnages were applied', function(done){
    check_elements_func({
      driver            : driver,
      elements_to_check : [{
        selector : 'select[name="department"]',
        value    : new_department_id,
      }],
    })
    .then(function(){ done() });
  });

  it("Open user B details page", function(done){
    open_page_func({
      url    : application_host + 'users/edit/'+user_id_B+'/',
      driver : driver,
    })
    .then(function(){ done() });
  });

  it('... and move her to newly added department', function(done){
    submit_form_func({
      driver      : driver,
      form_params : [{
        selector        : 'select[name="department"]',
        option_selector : 'option[value="'+new_department_id+'"]',
        value           : new_department_id,
      }],
      submit_button_selector : 'button#save_changes_btn',
      message : /Details for .+ were updated/,
    })
    .then(function(){ done() });
  });

  it('Ensure that chnages were applied', function(done){
    check_elements_func({
      driver            : driver,
      elements_to_check : [{
        selector : 'select[name="department"]',
        value    : new_department_id,
      }],
    })
    .then(function(){ done() });
  });

  it('Go to the very first department details page', function(done){
    open_page_func({
      url    : department_edit_page_url,
      driver : driver,
    })
    .then(function(){ done() });
  });

  it('Remove the department by pressing Delete button', function(done){
    driver
      .findElement(By.css('button#remove_btn'))
      .then(function(btn){ return btn.click() })
      .then(function() { return driver.findElement( By.css('div.alert') ) })
      .then(function(el){ return el.getText() })
      .then(function(txt){
        expect(txt).to.match(/Department was successfully removed/);
        done();
      })
  });

  it('Ensure that we have landed on correct page', function(done){
    driver
      .getCurrentUrl()
      .then(function(url){
        expect(url).to.match(/\/settings\/departments\/$/, 'The URL points to departments page');
        done();
      });
  });

  after(function(done){
    driver.quit().then(function(){ done(); });
  });
});

/*
 *  Scenario (edditing secondary supervisers)
 *  * create new account with user A
 *  * go to departments details page and invoke "add secondary supervisors"
 *    popup window, ensure it has link to "Add new employee" page
 *  * create two additional users B and C
 *  * go to any department details page and ensure that user A is its manager
 *  * ensure that "secondary supervisors" section is empty
 *  * click "add supervisers" button and ensure that popup witndow
 *    has only user B and C in the list
 *  * tick user B and save changes
 *  * observe that user B appeares on the list of secondary supervisers
 *  * open "add supervisors" pop up again and ensure that user B has tick
 *    next to it and user C does not have it
 *  * tick user C and un-tick user B and save changes
 *  * observe that "secondary spervisors" section now contains only user C
 *  * Click on "Remove" button next to user C and observe that it disappeares
 *    from "secondary supervisors" section after page is reloaded
 *
 * */

describe('CRUD for department secondary supervisers', function(){

  var driver, email_A, email_B, email_C, user_id_A, user_id_B, user_id_C,
    department_edit_page_url;

  this.timeout( config.get_execution_timeout() );

  it("Register new account", function(done){
    register_new_user_func({
      application_host : application_host,
    })
    .then(function(data){
      email_A = data.email;
      driver  = data.driver;
      done();
    });
  });

  it("Obtain information about user A", function(done){
    user_info_func({
      driver : driver,
      email  : email_A,
    })
    .then(function(data){
      user_id_A = data.user.id;
      done();
    });
  });

  it('Go to departments details page', function(done){
    open_page_func({
      url    : application_host + 'settings/departments/',
      driver : driver,
    })
    .then(function(){
      driver
        .findElements(By.css('a[href*="/settings/departments/edit/"]'))
        // Click on the very first link as we have just one department
        .then(function(links){ return links[0].click() })
        .then(function(){ done() });
    });
  });

  it('... save edit page URL', function(done){
    driver
      .getCurrentUrl()
      .then(function(url){
        department_edit_page_url = url;
        done();
      });
  });

  it('Invoke "Add secondary supervisers" pop-up window', function(done){
    driver
      .findElement(By.css('a[data-vpp-add-new-secondary-supervisor="1"]'))
      .then(function(btn){ return btn.click() })
      .then(function(){
        driver.sleep(1000);
        return driver.findElement(By.css('a[data-vpp-add-supervisor-modal-add-new-user="1"]'))
      })
      .then(function(link){ return link.getText() })
      .then(function(text){
        expect(text).to.match(/Add new employee/);
        done();
      });
  });

  it("Create second user B", function(done){
    add_new_user_func({
      application_host : application_host,
      driver           : driver,
    })
    .then(function(data){
      email_B = data.new_user_email;
      done();
    });
  });

  it("Obtain information about user B", function(done){
    user_info_func({
      driver : driver,
      email  : email_B,
    })
    .then(function(data){
      user_id_B = data.user.id;
      done();
    });
  });

  it("Create second user C", function(done){
    add_new_user_func({
      application_host : application_host,
      driver           : driver,
    })
    .then(function(data){
      email_C = data.new_user_email;
      done();
    });
  });

  it("Obtain information about user C", function(done){
    user_info_func({
      driver : driver,
      email  : email_C,
    })
    .then(function(data){
      user_id_C = data.user.id;
      done();
    });
  });

  it('Go to any department details page', function(done){
    open_page_func({
      url    : department_edit_page_url,
      driver : driver,
    })
    .then(function(){ done() });
  });

  it('... and ensure that user A is its manager', function(done){
    check_elements_func({
      driver            : driver,
      elements_to_check : [{
        selector : 'select#manager_id',
        value    : String(user_id_A),
      }],
    })
    .then(function(){ done() });
  });

  it('Ensure that "secondary supervisors" section is empty', function(done){
    driver
      .findElements(By.css('button[name="remove_supervisor_id"]'))
      .then(function(els){
        expect(els.length).to.be.eql(0, 'No remove buttons for supervisers as there are not any');
        done();
      });
  });

  it('click "add supervisers" button and ensure that popup witndow '+
    'has only user B and C in the list',
    function(done){

    driver
      .findElement(By.css('a[data-vpp-add-new-secondary-supervisor="1"]'))
      .then(function(btn){ return btn.click() })
      .then(function(){
        driver.sleep(1000);
        return driver.findElements(By.css('input[name="supervisor_id"]'))
      })
      .then(function(els){ return Bluebird.map(els, function(el){return el.getAttribute('value')})})
      .then(function(vals){
        expect(vals.sort()).to.be.eql([user_id_B, user_id_C].map(function(e){return String(e)}).sort(), 'User list is expected');
        done();
      });
  });

  it('tick user B and save changes', function(done){
    submit_form_func({
      driver      : driver,
      form_params : [{
        selector : 'input[name="supervisor_id"][value="'+user_id_B+'"]',
        tick     : true,
        value    : 'on',
      }],
      submit_button_selector : 'button[name="do_add_supervisors"]',
      message : /Supervisors were added to department/,
    })
    .then(function(){ done() });
  });

  it('Observe that user B appeares on the list of secondary supervisers', function(done){
    driver
      .findElements(By.css('button[name="remove_supervisor_id"]'))
      .then(function(els){
        expect(els.length).to.be.eql(1, 'No remove buttons for supervisers as there are not any');
        return els[0].getAttribute('value');
      })
      .then(function(val){
        expect(val).to.be.eql(String(user_id_B), 'It is indeed user B');
        done();
      });
  });

  it('Open "add supervisors" pop up again and ensure that user B has tick next to it and user C does not have it', function(done){
    driver
      .findElement(By.css('a[data-vpp-add-new-secondary-supervisor="1"]'))
      .then( btn => btn.click() )
      .then( () => driver.sleep(1000) )
      .then( () => check_elements_func({
          driver : driver,
          elements_to_check : [{
            selector : `input[name="supervisor_id"][value="${ user_id_B }"]`,
            tick     : true,
            value    : 'on',
          }],
        })
      )
      .then( () => check_elements_func({
          driver : driver,
          elements_to_check : [{
            selector : `input[name="supervisor_id"][value="${ user_id_C }"]`,
            tick     : true,
            value    : 'off',
          }],
        })
      )
      .then(() => done());
  });

  it('Tick user C and un-tick user B and save changes', function(done){
    submit_form_func({
      driver      : driver,
      form_params : [{
        selector : 'input[name="supervisor_id"][value="'+user_id_B+'"]',
        tick     : true,
      },{
        selector : 'input[name="supervisor_id"][value="'+user_id_C+'"]',
        tick     : true,
      }],
      submit_button_selector : 'button[name="do_add_supervisors"]',
      message : /Supervisors were added to department/,
    })
    .then(() => done());
  });

  it('Observe that "secondary spervisors" section now contains only user C', function(done) {
    driver
      .findElements(By.css('button[name="remove_supervisor_id"]'))
      .then(els => {
        expect(els.length).to.be.eql(1, 'No remove buttons for supervisers as there are not any');
        return els[0].getAttribute('value');
      })
      .then(val => {
        expect(val).to.be.eql(String(user_id_C), 'It is indeed user C');
        done();
      });
  });

  it('Click on "Remove" button next to user C and observe that it disappeares from "secondary supervisors" section after page is reloaded', function(done){
    driver
      .findElement(By.css(`button[name="remove_supervisor_id"][value="${ user_id_C }"]`))
      .then(el => el.click())
      .then(() => driver.findElements(By.css('button[name="remove_supervisor_id"]')))
      .then(els => {
        expect(els.length, 'There is no users in secondary supervisers section').to.be.eql(0);
        done();
      });
  });

  after(function(done){
    driver.quit().then(() => done());
  });

});


text:
<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">

  <title>wtf.ext.sharedance.Sharedance</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />

         Home

         Trees

         Indices

         Help

Visit WTF Online

        Package wtf ::
        Package ext ::
        Module sharedance ::
        Class Sharedance

[hide private]

[frames] | no frames]

Class Sharedance

source code

object --+
         |
        Sharedance

Sharedance API

        Instance Methods
        [hide private]

          __init__(self,
        conns)

      Initialization

            source code

          store(self,
        key,
        data)

      Store an item

            source code

          fetch(self,
        key)

      Fetch an item

            source code

          delete(self,
        key)

      Delete a key

            source code

          check(self,
        key=None,
        content=None,
        fetch=None)

      Check the servers for functionality

            source code

          _get_conn(self,
        key)

      Determine connector based on the weighted list

            source code

Inherited from object:
      __delattr__,
      __format__,
      __getattribute__,
      __hash__,
      __new__,
      __reduce__,
      __reduce_ex__,
      __repr__,
      __setattr__,
      __sizeof__,
      __str__,
      __subclasshook__

        Instance Variables
        [hide private]

      <tt class="rst-docutils literal">tuple</tt>

        _weighted

      Weighted list of connectors

      <tt class="rst-docutils literal">tuple</tt>

        conns

      List of connectors

        Properties
        [hide private]

Inherited from object:
      __class__

        Method Details
        [hide private]

__init__(self,
        conns)

(Constructor)

  	source code

  Initialization

Parameters:

conns (<tt class="rst-docutils literal">iterable</tt>) - List of sharedance connectors

Overrides:
        object.__init__

         Home

         Trees

         Indices

         Help

Visit WTF Online

redpajama_set_name: RedPajamaGithub


text:
package org.kie.workbench.common.stunner.core.rule.handler.impl;

import java.util.Optional;

import javax.enterprise.context.ApplicationScoped;

import org.kie.workbench.common.stunner.core.rule.RuleEvaluationHandler;
import org.kie.workbench.common.stunner.core.rule.RuleViolations;
import org.kie.workbench.common.stunner.core.rule.context.CardinalityContext;
import org.kie.workbench.common.stunner.core.rule.impl.Occurrences;
import org.kie.workbench.common.stunner.core.rule.violations.CardinalityMaxRuleViolation;
import org.kie.workbench.common.stunner.core.rule.violations.CardinalityMinRuleViolation;
import org.kie.workbench.common.stunner.core.rule.violations.DefaultRuleViolations;
import org.kie.workbench.common.stunner.core.validation.Violation;

@ApplicationScoped
public class CardinalityEvaluationHandler implements RuleEvaluationHandler<Occurrences, CardinalityContext> {

    @Override
    public Class<Occurrences> getRuleType() {
        return Occurrences.class;
    }

    @Override
    public Class<CardinalityContext> getContextType() {
        return CardinalityContext.class;
    }

    @Override
    public boolean accepts(final Occurrences rule,
                           final CardinalityContext context) {
        return context.getRoles().contains(rule.getRole());
    }

    @Override
    public RuleViolations evaluate(final Occurrences rule,
                                   final CardinalityContext context) {
        final DefaultRuleViolations results = new DefaultRuleViolations();
        final int minOccurrences = rule.getMinOccurrences();
        final int maxOccurrences = rule.getMaxOccurrences();
        final int candidatesCount = context.getCandidateCount();
        final Optional<CardinalityContext.Operation> operation = context.getOperation();
        final Violation.Type type = operation
                .filter(CardinalityContext.Operation.ADD::equals)
                .isPresent() ? Violation.Type.ERROR : Violation.Type.WARNING;
        final int count = !operation.isPresent() ? candidatesCount :
                (operation.get().equals(CardinalityContext.Operation.ADD) ? candidatesCount + 1 : candidatesCount - 1);
        if (count < minOccurrences) {
            results.addViolation(new CardinalityMinRuleViolation(context.getRoles().toString(),
                                                                 minOccurrences,
                                                                 candidatesCount,
                                                                 type));
        } else if (maxOccurrences > -1 && count > maxOccurrences) {
            results.addViolation(new CardinalityMaxRuleViolation(context.getRoles().toString(),
                                                                 maxOccurrences,
                                                                 candidatesCount,
                                                                 type));
        }
        return results;
    }
}


text:
package com.avanza.astrix.remoting.client;

import com.avanza.astrix.core.remoting.RoutingKey;

/**
 *
 * @author Elias Lindholm (elilin)
 *
 */
public class RoutedServiceInvocationRequest {

	private final AstrixServiceInvocationRequest request;
	private final RoutingKey routingkey;

	public RoutedServiceInvocationRequest(
			AstrixServiceInvocationRequest request, RoutingKey routingkey) {
		this.request = request;
		this.routingkey = routingkey;
	}

	public AstrixServiceInvocationRequest getRequest() {
		return request;
	}

	public RoutingKey getRoutingkey() {
		return routingkey;
	}

}


text:
const electronApp = require('electron').remote.app;

export class app implements ssf.App {
  static ready() {
    return Promise.resolve();
  }

  static setBadgeCount(count: number) {
    electronApp.setBadgeCount(count);
  }
}


text:
suite('ASTNode', function() {
  setup(function() {
    Blockly.defineBlocksWithJsonArray([{
      "type": "input_statement",
      "message0": "%1 %2 %3 %4",
      "args0": [
        {
          "type": "field_input",
          "name": "NAME",
          "text": "default"
        },
        {
          "type": "field_input",
          "name": "NAME",
          "text": "default"
        },
        {
          "type": "input_value",
          "name": "NAME"
        },
        {
          "type": "input_statement",
          "name": "NAME"
        }
      ],
      "previousStatement": null,
      "nextStatement": null,
      "colour": 230,
      "tooltip": "",
      "helpUrl": ""
    },
    {
      "type": "value_input",
      "message0": "%1",
      "args0": [
        {
          "type": "input_value",
          "name": "NAME"
        }
      ],
      "colour": 230,
      "tooltip": "",
      "helpUrl": ""
    },
    {
      "type": "field_input",
      "message0": "%1",
      "args0": [
        {
          "type": "field_input",
          "name": "NAME",
          "text": "default"
        }
      ],
      "output": null,
      "colour": 230,
      "tooltip": "",
      "helpUrl": ""
    }
    ]);
    this.workspace = new Blockly.Workspace();
    this.cursor = this.workspace.cursor;
    var statementInput1 = this.workspace.newBlock('input_statement');
    var statementInput2 = this.workspace.newBlock('input_statement');
    var statementInput3 = this.workspace.newBlock('input_statement');
    var statementInput4 = this.workspace.newBlock('input_statement');
    var fieldWithOutput = this.workspace.newBlock('field_input');
    var valueInput = this.workspace.newBlock('value_input');

    statementInput1.nextConnection.connect(statementInput2.previousConnection);
    statementInput1.inputList[0].connection
        .connect(fieldWithOutput.outputConnection);
    statementInput2.inputList[1].connection
        .connect(statementInput3.previousConnection);

    this.blocks = {
      statementInput1: statementInput1,
      statementInput2: statementInput2,
      statementInput3: statementInput3,
      statementInput4: statementInput4,
      fieldWithOutput: fieldWithOutput,
      valueInput: valueInput
    };
    sinon.stub(Blockly, "getMainWorkspace").returns(new Blockly.Workspace());
  });
  teardown(function() {
    delete Blockly.Blocks['input_statement'];
    delete Blockly.Blocks['field_input'];
    delete Blockly.Blocks['value_input'];

    this.workspace.dispose();
    sinon.restore();
  });

  suite('HelperFunctions', function() {
    test('findPreviousEditableField_', function() {
      var input = this.blocks.statementInput1.inputList[0];
      var field = input.fieldRow[1];
      var prevField = input.fieldRow[0];
      var node = Blockly.ASTNode.createFieldNode(prevField);
      var editableField = node.findPreviousEditableField_(field, input);
      assertEquals(editableField.getLocation(), prevField);
    });

    test('findPreviousEditableFieldLast_', function() {
      var input = this.blocks.statementInput1.inputList[0];
      var field = input.fieldRow[0];
      var node = Blockly.ASTNode.createFieldNode(field);
      var editableField = node.findPreviousEditableField_(field, input, true);
      assertEquals(editableField.getLocation(), input.fieldRow[1]);
    });

    test('findNextForInput_', function() {
      var input = this.blocks.statementInput1.inputList[0];
      var input2 = this.blocks.statementInput1.inputList[1];
      var connection = input.connection;
      var node = Blockly.ASTNode.createConnectionNode(connection);
      var newASTNode = node.findNextForInput_(input);
      assertEquals(newASTNode.getLocation(), input2.connection);
    });

    test('findPrevForInput_', function() {
      var input = this.blocks.statementInput1.inputList[0];
      var input2 = this.blocks.statementInput1.inputList[1];
      var connection = input2.connection;
      var node = Blockly.ASTNode.createConnectionNode(connection);
      var newASTNode = node.findPrevForInput_(input2);
      assertEquals(newASTNode.getLocation(), input.connection);
    });

    test('findNextForField_', function() {
      var field = this.blocks.statementInput1.inputList[0].fieldRow[0];
      var field2 = this.blocks.statementInput1.inputList[0].fieldRow[1];
      var node = Blockly.ASTNode.createFieldNode(field);
      var newASTNode = node.findNextForField_(field);
      assertEquals(newASTNode.getLocation(), field2);
    });

    test('findPrevForField_', function() {
      var field = this.blocks.statementInput1.inputList[0].fieldRow[0];
      var field2 = this.blocks.statementInput1.inputList[0].fieldRow[1];
      var node = Blockly.ASTNode.createFieldNode(field2);
      var newASTNode = node.findPrevForField_(field2);
      assertEquals(newASTNode.getLocation(), field);
    });

    test('navigateBetweenStacks_Forward', function() {
      var node = new Blockly.ASTNode(
          Blockly.ASTNode.types.NEXT, this.blocks.statementInput1.nextConnection);
      var newASTNode = node.navigateBetweenStacks_(true);
      assertEquals(newASTNode.getLocation(), this.blocks.statementInput4);
    });

    test('navigateBetweenStacks_Backward', function() {
      var node = new Blockly.ASTNode(
          Blockly.ASTNode.types.BLOCK, this.blocks.statementInput4);
      var newASTNode = node.navigateBetweenStacks_(false);
      assertEquals(newASTNode.getLocation(), this.blocks.statementInput1);
    });
    test('getOutAstNodeForBlock_', function() {
      var node = new Blockly.ASTNode(
          Blockly.ASTNode.types.BLOCK, this.blocks.statementInput2);
      var newASTNode = node.getOutAstNodeForBlock_(this.blocks.statementInput2);
      assertEquals(newASTNode.getLocation(), this.blocks.statementInput1);
    });
    test('getOutAstNodeForBlock_OneBlock', function() {
      var node = new Blockly.ASTNode(
          Blockly.ASTNode.types.BLOCK, this.blocks.statementInput4);
      var newASTNode = node.getOutAstNodeForBlock_(this.blocks.statementInput4);
      assertEquals(newASTNode.getLocation(), this.blocks.statementInput4);
    });
    test('findFirstFieldOrInput_', function() {
      var node = new Blockly.ASTNode(
          Blockly.ASTNode.types.BLOCK, this.blocks.statementInput4);
      var field = this.blocks.statementInput4.inputList[0].fieldRow[0];
      var newASTNode = node.findFirstFieldOrInput_(this.blocks.statementInput4);
      assertEquals(newASTNode.getLocation(), field);
    });

  });

  suite('NavigationFunctions', function() {
    suite('Next', function() {
      setup(function() {
        Blockly.defineBlocksWithJsonArray([{
          "type": "top_connection",
          "message0": "",
          "previousStatement": null,
          "colour": 230,
          "tooltip": "",
          "helpUrl": ""
        },
        {
          "type": "fields_and_input",
          "message0": "%1 hi %2 %3 %4",
          "args0": [
            {
              "type": "field_input",
              "name": "NAME",
              "text": "default"
            },
            {
              "type": "input_dummy"
            },
            {
              "type": "field_input",
              "name": "NAME",
              "text": "default"
            },
            {
              "type": "input_value",
              "name": "NAME"
            }
          ],
          "previousStatement": null,
          "nextStatement": null,
          "colour": 230,
          "tooltip": "",
          "helpUrl": ""
        },
        {
          "type": "two_fields",
          "message0": "%1 hi",
          "args0": [
            {
              "type": "field_input",
              "name": "NAME",
              "text": "default"
            }
          ],
          "colour": 230,
          "tooltip": "",
          "helpUrl": ""
        },
        {
          "type": "fields_and_input2",
          "message0": "%1 %2 %3 hi %4 bye",
          "args0": [
            {
              "type": "input_value",
              "name": "NAME"
            },
            {
              "type": "field_input",
              "name": "NAME",
              "text": "default"
            },
            {
              "type": "input_value",
              "name": "NAME"
            },
            {
              "type": "input_statement",
              "name": "NAME"
            }
          ],
          "colour": 230,
          "tooltip": "",
          "helpUrl": ""
        }]);

        this.singleBlockWorkspace = new Blockly.Workspace();

        var noNextConnection = this.workspace.newBlock('top_connection');
        var fieldAndInputs = this.workspace.newBlock('fields_and_input');
        var twoFields = this.workspace.newBlock('two_fields');
        var fieldAndInputs2 = this.workspace.newBlock('fields_and_input2');
        var singleBlock = this.singleBlockWorkspace.newBlock('two_fields');

        this.blocks.noNextConnection = noNextConnection;
        this.blocks.fieldAndInputs = fieldAndInputs;
        this.blocks.twoFields = twoFields;
        this.blocks.fieldAndInputs2 = fieldAndInputs2;
        this.blocks.singleBlock = singleBlock;

      });
      teardown(function() {
        delete this.blocks.noNextConnection;
        delete this.blocks.fieldAndInputs;
        delete this.blocks.twoFields;
        delete this.blocks.fieldAndInputs2;
        delete this.blocks.singleBlock;

        delete Blockly.Blocks['fields_and_input2'];
        delete Blockly.Blocks['two_fields'];
        delete Blockly.Blocks['fields_and_input'];
        delete Blockly.Blocks['top_connection'];
      });

      test('fromPreviousToBlock', function() {
        var prevConnection = this.blocks.statementInput1.previousConnection;
        var node = Blockly.ASTNode.createConnectionNode(prevConnection);
        var nextNode = node.next();
        assertEquals(nextNode.getLocation(), this.blocks.statementInput1);
      });
      test('fromBlockToNext', function() {
        var nextConnection = this.blocks.statementInput1.nextConnection;
        var node = Blockly.ASTNode.createBlockNode(this.blocks.statementInput1);
        var nextNode = node.next();
        assertEquals(nextNode.getLocation(), nextConnection);
      });
      test('fromBlockToNull', function() {
        var node = Blockly.ASTNode.createBlockNode(this.blocks.noNextConnection);
        var nextNode = node.next();
        assertEquals(nextNode, null);
      });
      test('fromNextToPrevious', function() {
        var nextConnection = this.blocks.statementInput1.nextConnection;
        var prevConnection = this.blocks.statementInput2.previousConnection;
        var node = Blockly.ASTNode.createConnectionNode(nextConnection);
        var nextNode = node.next();
        assertEquals(nextNode.getLocation(), prevConnection);
      });
      test('fromNextToNull', function() {
        var nextConnection = this.blocks.statementInput2.nextConnection;
        var node = Blockly.ASTNode.createConnectionNode(nextConnection);
        var nextNode = node.next();
        assertEquals(nextNode, null);
      });
      test('fromInputToInput', function() {
        var input = this.blocks.statementInput1.inputList[0];
        var inputConnection = this.blocks.statementInput1.inputList[1].connection;
        var node = Blockly.ASTNode.createInputNode(input);
        var nextNode = node.next();
        assertEquals(nextNode.getLocation(), inputConnection);
      });
      test('fromInputToStatementInput', function() {
        var input = this.blocks.fieldAndInputs2.inputList[1];
        var inputConnection = this.blocks.fieldAndInputs2.inputList[2].connection;
        var node = Blockly.ASTNode.createInputNode(input);
        var nextNode = node.next();
        assertEquals(nextNode.getLocation(), inputConnection);
      });
      test('fromInputToField', function() {
        var input = this.blocks.fieldAndInputs2.inputList[0];
        var field = this.blocks.fieldAndInputs2.inputList[1].fieldRow[0];
        var node = Blockly.ASTNode.createInputNode(input);
        var nextNode = node.next();
        assertEquals(nextNode.getLocation(), field);
      });
      test('fromInputToNull', function() {
        var input = this.blocks.fieldAndInputs2.inputList[2];
        var node = Blockly.ASTNode.createInputNode(input);
        var nextNode = node.next();
        assertEquals(nextNode, null);
      });
      test('fromOutputToBlock', function() {
        var output = this.blocks.fieldWithOutput.outputConnection;
        var node = Blockly.ASTNode.createConnectionNode(output);
        var nextNode = node.next();
        assertEquals(nextNode.getLocation(), this.blocks.fieldWithOutput);
      });
      test('fromFieldToInput', function() {
        var field = this.blocks.statementInput1.inputList[0].fieldRow[1];
        var inputConnection = this.blocks.statementInput1.inputList[0].connection;
        var node = Blockly.ASTNode.createFieldNode(field);
        var nextNode = node.next();
        assertEquals(nextNode.getLocation(), inputConnection);
      });
      test('fromFieldToField', function() {
        var field = this.blocks.fieldAndInputs.inputList[0].fieldRow[0];
        var node = Blockly.ASTNode.createFieldNode(field);
        var field2 = this.blocks.fieldAndInputs.inputList[1].fieldRow[0];
        var nextNode = node.next();
        assertEquals(nextNode.getLocation(), field2);
      });
      test('fromFieldToNull', function() {
        var field = this.blocks.twoFields.inputList[0].fieldRow[0];
        var node = Blockly.ASTNode.createFieldNode(field);
        var nextNode = node.next();
        assertEquals(nextNode, null);
      });
      test('fromStackToStack', function() {
        var node = Blockly.ASTNode.createStackNode(this.blocks.statementInput1);
        var nextNode = node.next();
        assertEquals(nextNode.getLocation(), this.blocks.statementInput4);
        assertEquals(nextNode.getType(), Blockly.ASTNode.types.STACK);
      });
      test('fromStackToNull', function() {
        var node = Blockly.ASTNode.createStackNode(this.blocks.singleBlock);
        var nextNode = node.next();
        assertEquals(nextNode, null);
      });
    });

    suite('Previous', function() {
      setup(function() {
        Blockly.defineBlocksWithJsonArray([{
          "type": "start_block",
          "message0": "",
          "nextStatement": null,
          "colour": 230,
          "tooltip": "",
          "helpUrl": ""
        },
        {
          "type": "fields_and_input",
          "message0": "%1 hi %2 %3 %4",
          "args0": [
            {
              "type": "field_input",
              "name": "NAME",
              "text": "default"
            },
            {
              "type": "input_dummy"
            },
            {
              "type": "field_input",
              "name": "NAME",
              "text": "default"
            },
            {
              "type": "input_value",
              "name": "NAME"
            }
          ],
          "previousStatement": null,
          "nextStatement": null,
          "colour": 230,
          "tooltip": "",
          "helpUrl": ""
        },
        {
          "type": "fields_and_input2",
          "message0": "%1 %2 %3 hi %4 bye",
          "args0": [
            {
              "type": "input_value",
              "name": "NAME"
            },
            {
              "type": "field_input",
              "name": "NAME",
              "text": "default"
            },
            {
              "type": "input_value",
              "name": "NAME"
            },
            {
              "type": "input_statement",
              "name": "NAME"
            }
          ],
          "colour": 230,
          "tooltip": "",
          "helpUrl": ""
        }]);

        var noPrevConnection = this.workspace.newBlock('start_block');
        var fieldsAndInputs = this.workspace.newBlock('fields_and_input');
        var fieldsAndInputs2 = this.workspace.newBlock('fields_and_input2');

        this.blocks.noPrevConnection = noPrevConnection;
        this.blocks.fieldsAndInputs = fieldsAndInputs;
        this.blocks.fieldsAndInputs2 = fieldsAndInputs2;
      });
      teardown(function() {
        delete this.blocks.noPrevConnection;
        delete this.blocks.fieldAndInputs;
        delete this.blocks.fieldsAndInputs2;

        delete Blockly.Blocks['fields_and_input2'];
        delete Blockly.Blocks['start_block'];
        delete Blockly.Blocks['fields_and_input'];
      });

      test('fromPreviousToNull', function() {
        var prevConnection = this.blocks.statementInput1.previousConnection;
        var node = Blockly.ASTNode.createConnectionNode(prevConnection);
        var prevNode = node.prev();
        assertEquals(prevNode, null);
      });
      test('fromPreviousToNext', function() {
        var prevConnection = this.blocks.statementInput2.previousConnection;
        var node = Blockly.ASTNode.createConnectionNode(prevConnection);
        var prevNode = node.prev();
        var nextConnection = this.blocks.statementInput1.nextConnection;
        assertEquals(prevNode.getLocation(), nextConnection);
      });
      test('fromPreviousToInput', function() {
        var prevConnection = this.blocks.statementInput3.previousConnection;
        var node = Blockly.ASTNode.createConnectionNode(prevConnection);
        var prevNode = node.prev();
        assertEquals(prevNode, null);
      });
      test('fromBlockToPrevious', function() {
        var node = Blockly.ASTNode.createBlockNode(this.blocks.statementInput1);
        var prevNode = node.prev();
        var prevConnection = this.blocks.statementInput1.previousConnection;
        assertEquals(prevNode.getLocation(), prevConnection);
      });
      test('fromBlockToNull', function() {
        var node = Blockly.ASTNode.createBlockNode(this.blocks.noPrevConnection);
        var prevNode = node.prev();
        assertEquals(prevNode, null);
      });
      test('fromBlockToOutput', function() {
        var node = Blockly.ASTNode.createBlockNode(this.blocks.fieldWithOutput);
        var prevNode = node.prev();
        var outputConnection = this.blocks.fieldWithOutput.outputConnection;
        assertEquals(prevNode.getLocation(), outputConnection);
      });
      test('fromNextToBlock', function() {
        var nextConnection = this.blocks.statementInput1.nextConnection;
        var node = Blockly.ASTNode.createConnectionNode(nextConnection);
        var prevNode = node.prev();
        assertEquals(prevNode.getLocation(), this.blocks.statementInput1);
      });
      test('fromInputToField', function() {
        var input = this.blocks.statementInput1.inputList[0];
        var node = Blockly.ASTNode.createInputNode(input);
        var prevNode = node.prev();
        assertEquals(prevNode.getLocation(), input.fieldRow[1]);
      });
      test('fromInputToNull', function() {
        var input = this.blocks.fieldsAndInputs2.inputList[0];
        var node = Blockly.ASTNode.createInputNode(input);
        var prevNode = node.prev();
        assertEquals(prevNode, null);
      });
      test('fromInputToInput', function() {
        var input = this.blocks.fieldsAndInputs2.inputList[2];
        var inputConnection = this.blocks.fieldsAndInputs2.inputList[1].connection;
        var node = Blockly.ASTNode.createInputNode(input);
        var prevNode = node.prev();
        assertEquals(prevNode.getLocation(), inputConnection);
      });
      test('fromOutputToNull', function() {
        var output = this.blocks.fieldWithOutput.outputConnection;
        var node = Blockly.ASTNode.createConnectionNode(output);
        var prevNode = node.prev();
        assertEquals(prevNode, null);
      });
      test('fromFieldToNull', function() {
        var field = this.blocks.statementInput1.inputList[0].fieldRow[0];
        var node = Blockly.ASTNode.createFieldNode(field);
        var prevNode = node.prev();
        assertEquals(prevNode, null);
      });
      test('fromFieldToInput', function() {
        var field = this.blocks.fieldsAndInputs2.inputList[1].fieldRow[0];
        var inputConnection = this.blocks.fieldsAndInputs2.inputList[0].connection;
        var node = Blockly.ASTNode.createFieldNode(field);
        var prevNode = node.prev();
        assertEquals(prevNode.getLocation(), inputConnection);
      });
      test('fromFieldToField', function() {
        var field = this.blocks.fieldsAndInputs.inputList[1].fieldRow[0];
        var field2 = this.blocks.fieldsAndInputs.inputList[0].fieldRow[0];
        var node = Blockly.ASTNode.createFieldNode(field);
        var prevNode = node.prev();
        assertEquals(prevNode.getLocation(), field2);
      });
      test('fromStackToStack', function() {
        var node = Blockly.ASTNode.createStackNode(this.blocks.statementInput4);
        var prevNode = node.prev();
        assertEquals(prevNode.getLocation(), this.blocks.statementInput1);
        assertEquals(prevNode.getType(), Blockly.ASTNode.types.STACK);
      });
    });

    suite('In', function() {
      setup(function() {
        Blockly.defineBlocksWithJsonArray([{
          "type": "dummy_input",
          "message0": "Hello",
          "colour": 230,
          "tooltip": "",
          "helpUrl": ""
        },
        {
          "type": "dummy_inputValue",
          "message0": "Hello %1  %2",
          "args0": [
            {
              "type": "input_dummy"
            },
            {
              "type": "input_value",
              "name": "NAME"
            }
          ],
          "colour": 230,
          "tooltip": "",
          "helpUrl": ""
        }]);
        var dummyInput = this.workspace.newBlock('dummy_input');
        var dummyInputValue = this.workspace.newBlock('dummy_inputValue');
        var fieldWithOutput2 = this.workspace.newBlock('field_input');

        this.blocks.dummyInput = dummyInput;
        this.blocks.dummyInputValue = dummyInputValue;
        this.blocks.fieldWithOutput2 = fieldWithOutput2;
        this.emptyWorkspace = new Blockly.Workspace();
      });
      teardown(function() {
        delete this.blocks.dummyInput;
        delete this.blocks.dummyInputValue;
        delete this.blocks.fieldWithOutput2;
        delete this.emptyWorkspace;

        delete Blockly.Blocks['dummy_input'];
        delete Blockly.Blocks['dummy_inputValue'];
      });

      test('fromInputToOutput', function() {
        var input = this.blocks.statementInput1.inputList[0];
        var node = Blockly.ASTNode.createInputNode(input);
        var inNode = node.in();
        var outputConnection = this.blocks.fieldWithOutput.outputConnection;
        assertEquals(inNode.getLocation(), outputConnection);
      });
      test('fromInputToNull', function() {
        var input = this.blocks.statementInput2.inputList[0];
        var node = Blockly.ASTNode.createInputNode(input);
        var inNode = node.in();
        assertEquals(inNode, null);
      });
      test('fromInputToPrevious', function() {
        var input = this.blocks.statementInput2.inputList[1];
        var previousConnection = this.blocks.statementInput3.previousConnection;
        var node = Blockly.ASTNode.createInputNode(input);
        var inNode = node.in();
        assertEquals(inNode.getLocation(), previousConnection);
      });
      test('fromBlockToInput', function() {
        var input = this.blocks.valueInput.inputList[0];
        var node = Blockly.ASTNode.createBlockNode(this.blocks.valueInput);
        var inNode = node.in();
        assertEquals(inNode.getLocation(), input.connection);
      });
      test('fromBlockToField', function() {
        var node = Blockly.ASTNode.createBlockNode(this.blocks.statementInput1);
        var inNode = node.in();
        var field = this.blocks.statementInput1.inputList[0].fieldRow[0];
        assertEquals(inNode.getLocation(), field);
      });
      test('fromBlockToPrevious', function() {
        var prevConnection = this.blocks.statementInput4.previousConnection;
        var node = Blockly.ASTNode.createStackNode(this.blocks.statementInput4);
        var inNode = node.in();
        assertEquals(inNode.getLocation(), prevConnection);
        assertEquals(inNode.getType(), Blockly.ASTNode.types.PREVIOUS);
      });
      test('fromBlockToNull_DummyInput', function() {
        var node = Blockly.ASTNode.createBlockNode(this.blocks.dummyInput);
        var inNode = node.in();
        assertEquals(inNode, null);
      });
      test('fromBlockToInput_DummyInputValue', function() {
        var node = Blockly.ASTNode.createBlockNode(this.blocks.dummyInputValue);
        var inputConnection = this.blocks.dummyInputValue.inputList[1].connection;
        var inNode = node.in();
        assertEquals(inNode.getLocation(), inputConnection);
      });
      test('fromOuputToNull', function() {
        var output = this.blocks.fieldWithOutput.outputConnection;
        var node = Blockly.ASTNode.createConnectionNode(output);
        var inNode = node.in();
        assertEquals(inNode, null);
      });
      test('fromFieldToNull', function() {
        var field = this.blocks.statementInput1.inputList[0].fieldRow[0];
        var node = Blockly.ASTNode.createFieldNode(field);
        var inNode = node.in();
        assertEquals(inNode, null);
      });
      test('fromWorkspaceToStack', function() {
        var coordinate = new Blockly.utils.Coordinate(100, 100);
        var node = Blockly.ASTNode.createWorkspaceNode(this.workspace, coordinate);
        var inNode = node.in();
        assertEquals(inNode.getLocation(), this.workspace.getTopBlocks()[0]);
        assertEquals(inNode.getType(), Blockly.ASTNode.types.STACK);
      });
      test('fromWorkspaceToNull', function() {
        var coordinate = new Blockly.utils.Coordinate(100, 100);
        var node = Blockly.ASTNode.createWorkspaceNode(
            this.emptyWorkspace, coordinate);
        var inNode = node.in();
        assertEquals(inNode, null);
      });
      test('fromStackToPrevious', function() {
        var node = Blockly.ASTNode.createStackNode(this.blocks.statementInput1);
        var previous = this.blocks.statementInput1.previousConnection;
        var inNode = node.in();
        assertEquals(inNode.getLocation(), previous);
        assertEquals(inNode.getType(), Blockly.ASTNode.types.PREVIOUS);
      });
      test('fromStackToOutput', function() {
        var node = Blockly.ASTNode.createStackNode(this.blocks.fieldWithOutput2);
        var output = this.blocks.fieldWithOutput2.outputConnection;
        var inNode = node.in();
        assertEquals(inNode.getLocation(), output);
        assertEquals(inNode.getType(), Blockly.ASTNode.types.OUTPUT);
      });
      test('fromStackToBlock', function() {
        var node = Blockly.ASTNode.createStackNode(this.blocks.dummyInput);
        var inNode = node.in();
        assertEquals(inNode.getLocation(), this.blocks.dummyInput);
        assertEquals(inNode.getType(), Blockly.ASTNode.types.BLOCK);
      });
    });

    suite('Out', function() {
      setup(function() {
        Blockly.defineBlocksWithJsonArray([{
          "type": "start_block",
          "message0": "",
          "nextStatement": null,
          "colour": 230,
          "tooltip": "",
          "helpUrl": ""
        },
        {
          "type": "output_next",
          "message0": "",
          "output": null,
          "colour": 230,
          "tooltip": "",
          "helpUrl": "",
          "nextStatement": null
        }]);
        var noPrevConnection = this.workspace.newBlock('start_block');
        var secondBlock = this.workspace.newBlock('input_statement');
        var outputNextBlock = this.workspace.newBlock('output_next');
        var fieldWithOutput2 = this.workspace.newBlock('field_input');

        noPrevConnection.nextConnection.connect(secondBlock.previousConnection);
        secondBlock.inputList[0].connection
            .connect(outputNextBlock.outputConnection);
        this.blocks.noPrevConnection = noPrevConnection;
        this.blocks.secondBlock = secondBlock;
        this.blocks.outputNextBlock = outputNextBlock;
        this.blocks.fieldWithOutput2 = fieldWithOutput2;
      });
      teardown(function() {
        delete this.blocks.noPrevConnection;
        delete this.blocks.secondBlock;
        delete this.blocks.outputNextBlock;
        delete this.blocks.fieldWithOutput2;

        delete Blockly.Blocks['start_block'];
        delete Blockly.Blocks['output_next'];
      });

      test('fromInputToBlock', function() {
        var input = this.blocks.statementInput1.inputList[0];
        var node = Blockly.ASTNode.createInputNode(input);
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.BLOCK);
        chai.assert.equal(outNode.getLocation(), this.blocks.statementInput1);
      });
      test('fromOutputToInput', function() {
        var output = this.blocks.fieldWithOutput.outputConnection;
        var node = Blockly.ASTNode.createConnectionNode(output);
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.INPUT);
        chai.assert.equal(outNode.getLocation(),
            this.blocks.statementInput1.inputList[0].connection);
      });
      test('fromOutputToStack', function() {
        var output = this.blocks.fieldWithOutput2.outputConnection;
        var node = Blockly.ASTNode.createConnectionNode(output);
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.STACK);
        chai.assert.equal(outNode.getLocation(), this.blocks.fieldWithOutput2);
      });
      test('fromFieldToBlock', function() {
        var field = this.blocks.statementInput1.inputList[0].fieldRow[0];
        var node = Blockly.ASTNode.createFieldNode(field);
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.BLOCK);
        chai.assert.equal(outNode.getLocation(), this.blocks.statementInput1);
      });
      test('fromStackToWorkspace', function() {
        var stub = sinon.stub(this.blocks.statementInput4,
            "getRelativeToSurfaceXY").returns({x: 10, y:10});
        var node = Blockly.ASTNode.createStackNode(this.blocks.statementInput4);
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.WORKSPACE);
        chai.assert.equal(outNode.wsCoordinate_.x, 10);
        chai.assert.equal(outNode.wsCoordinate_.y, -10);
        stub.restore();
      });
      test('fromPreviousToInput', function() {
        var previous = this.blocks.statementInput3.previousConnection;
        var inputConnection = this.blocks.statementInput2.inputList[1].connection;
        var node = Blockly.ASTNode.createConnectionNode(previous);
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.INPUT);
        chai.assert.equal(outNode.getLocation(), inputConnection);
      });
      test('fromPreviousToStack', function() {
        var previous = this.blocks.statementInput2.previousConnection;
        var node = Blockly.ASTNode.createConnectionNode(previous);
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.STACK);
        chai.assert.equal(outNode.getLocation(), this.blocks.statementInput1);
      });
      test('fromNextToInput', function() {
        var next = this.blocks.statementInput3.nextConnection;
        var inputConnection = this.blocks.statementInput2.inputList[1].connection;
        var node = Blockly.ASTNode.createConnectionNode(next);
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.INPUT);
        chai.assert.equal(outNode.getLocation(), inputConnection);
      });
      test('fromNextToStack', function() {
        var next = this.blocks.statementInput2.nextConnection;
        var node = Blockly.ASTNode.createConnectionNode(next);
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.STACK);
        chai.assert.equal(outNode.getLocation(), this.blocks.statementInput1);
      });
      test('fromNextToStack_NoPreviousConnection', function() {
        var next = this.blocks.secondBlock.nextConnection;
        var node = Blockly.ASTNode.createConnectionNode(next);
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.STACK);
        chai.assert.equal(outNode.getLocation(), this.blocks.noPrevConnection);
      });
      /**
       * This is where there is a block with both an output connection and a
       * next connection attached to an input.
       */
      test('fromNextToInput_OutputAndPreviousConnection', function() {
        var next = this.blocks.outputNextBlock.nextConnection;
        var node = Blockly.ASTNode.createConnectionNode(next);
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.INPUT);
        chai.assert.equal(outNode.getLocation(),
            this.blocks.secondBlock.inputList[0].connection);
      });
      test('fromBlockToStack', function() {
        var node = Blockly.ASTNode.createBlockNode(this.blocks.statementInput2);
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.STACK);
        chai.assert.equal(outNode.getLocation(), this.blocks.statementInput1);
      });
      test('fromBlockToInput', function() {
        var input = this.blocks.statementInput2.inputList[1].connection;
        var node = Blockly.ASTNode.createBlockNode(this.blocks.statementInput3);
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.INPUT);
        chai.assert.equal(outNode.getLocation(), input);
      });
      test('fromTopBlockToStack', function() {
        var node = Blockly.ASTNode.createBlockNode(this.blocks.statementInput1);
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.STACK);
        chai.assert.equal(outNode.getLocation(), this.blocks.statementInput1);
      });
      test('fromBlockToStack_OutputConnection', function() {
        var node = Blockly.ASTNode.createBlockNode(this.blocks.fieldWithOutput2);
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.STACK);
        chai.assert.equal(outNode.getLocation(), this.blocks.fieldWithOutput2);
      });
      test('fromBlockToInput_OutputConnection', function() {
        var node = Blockly.ASTNode.createBlockNode(this.blocks.outputNextBlock);
        var inputConnection = this.blocks.secondBlock.inputList[0].connection;
        var outNode = node.out();
        chai.assert.equal(outNode.getType(), Blockly.ASTNode.types.INPUT);
        chai.assert.equal(outNode.getLocation(), inputConnection);
      });
    });

    suite('createFunctions', function() {
      test('createFieldNode', function() {
        var field = this.blocks.statementInput1.inputList[0].fieldRow[0];
        var node = Blockly.ASTNode.createFieldNode(field);
        assertEquals(node.getLocation(), field);
        assertEquals(node.getType(), Blockly.ASTNode.types.FIELD);
        assertFalse(node.isConnection());
      });
      test('createConnectionNode', function() {
        var prevConnection = this.blocks.statementInput4.previousConnection;
        var node = Blockly.ASTNode.createConnectionNode(prevConnection);
        assertEquals(node.getLocation(), prevConnection);
        assertEquals(node.getType(), Blockly.ASTNode.types.PREVIOUS);
        assertTrue(node.isConnection());
      });
      test('createInputNode', function() {
        var input = this.blocks.statementInput1.inputList[0];
        var node = Blockly.ASTNode.createInputNode(input);
        assertEquals(node.getLocation(), input.connection);
        assertEquals(node.getType(), Blockly.ASTNode.types.INPUT);
        assertTrue(node.isConnection());
      });
      test('createWorkspaceNode', function() {
        var coordinate = new Blockly.utils.Coordinate(100, 100);
        var node = Blockly.ASTNode
            .createWorkspaceNode(this.workspace, coordinate);
        assertEquals(node.getLocation(), this.workspace);
        assertEquals(node.getType(), Blockly.ASTNode.types.WORKSPACE);
        assertEquals(node.getWsCoordinate(), coordinate);
        assertFalse(node.isConnection());
      });
      test('createStatementConnectionNode', function() {
        var nextConnection = this.blocks.statementInput1.inputList[1].connection;
        var inputConnection = this.blocks.statementInput1.inputList[1].connection;
        var node = Blockly.ASTNode.createConnectionNode(nextConnection);
        assertEquals(node.getLocation(), inputConnection);
        assertEquals(node.getType(), Blockly.ASTNode.types.INPUT);
        assertTrue(node.isConnection());
      });
    });
  });
});


text:
layout: default
title: Hacks
---

{% for entry in site.hacks %}

{{ entry.name }}

{% assign content_length = entry.content escape | strip_newlines | size %}
{% if content_length > 0 %}

{{entry.content|markdownify}}

{% endif %}

{% if entry.guide %}

      {% avatar user=entry.guide %}

{% endif %}
{% for member in entry.members %}
{% if member != entry.guide %}

      {% avatar user=member %}

{% endif %}
{% endfor %}

{% else %}

No hacks yet 😭

    Register your hack!

{% endfor %}

  Take a look at hacks from previous years: 2017

<link href="https://fonts.googleapis.com/css?family=Fira+Mono" rel="stylesheet">


text:
var Steps = antd.Steps;
var Step = Steps.Step;
var container = document.getElementById('components-steps-demo-status');

var steps = [{
  status: 'finish',
  title: '已完成',
  description: '这里是多信息的描述啊'
}, {
  status: 'process',
  title: '进行中',
  description: '这里是多信息的耶哦耶哦哦耶哦耶'
}, {
  status: 'wait',
  title: '又一个待运行',
  description: '描述啊描述啊'
}, {
  status: 'wait',
  title: '待运行',
  description: '这里是多信息的描述啊'
}].map(function(s, i) {
  return (
    <Step key={i} title={s.title} status={s.status} description={s.description} />
  );
});

React.render(<Steps>{steps}</Steps>, container);

      自定义状态

可以使用 status 定义每个步骤的状态。


text:
<?php

/**
 * @namespace
 */

namespace Solarium\QueryType\Analysis\RequestBuilder;

use Solarium\QueryType\Analysis\Query\Field as QueryField;
use Solarium\Core\Client\Request;
use Solarium\Core\Query\QueryInterface;

/**
 * Build a field analysis request
 */
class Field extends RequestBuilder
{

    /**
     * Build request for an analysis field query
     *
     * @param  QueryInterface|QueryField $query
     * @return Request
     */
    public function build(QueryInterface $query)
    {
        $request = parent::build($query);

        $request->addParam('analysis.fieldvalue', $query->getFieldValue());
        $request->addParam('analysis.fieldname', $query->getFieldName());
        $request->addParam('analysis.fieldtype', $query->getFieldType());

        return $request;
    }

}


text:
from __future__ import unicode_literals

from django.db import migrations, models

class Migration(migrations.Migration):

    dependencies = [
        ('groups', '0002_auto_20170912_1958'),
    ]

    operations = [
        migrations.AlterField(
            model_name='group',
            name='name',
            field=models.CharField(max_length=50, unique=True),
        ),
    ]


text:
using UnityEngine;
using System.Collections;

public class Item : MonoBehaviour {
	// must be defined in inspector
	public ItemDB.ItemType itemType;
	// TODO more variables for specific item description
	private bool PickedUP = false;
	public ItemGenerator itemGen;
	void Start()
	{
		// init with velocity for visual effect
		GetComponent<Rigidbody> ().velocity = new Vector3 (0, 5, 0);
		GetComponent<Rigidbody> ().angularVelocity = new Vector3 (1, 1, 5);
		// add a simple callback

	}

	// Use this for initialization
	void OnTriggerEnter(Collider other){
		if (other.tag == TagList.Player && !PickedUP) {
			PickedUP = true;
			Debug.Log ("destroy item pick up by player");

			other.GetComponent<PlayerBuffStatus>().UpdateBuff(itemType);

			Destroy(gameObject);
		}
	}

	void OnDestroy() {
		if (itemGen)
			itemGen.ItemDestroyHandler();
	}

}


text:
package com.geth1b.coding.skills.lc;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;

/**
 * @author geth1b
 */
public class _036_ValidSudoku_Test {
  private _036_ValidSudoku solution;
  private char[][] board;

  @Before public void setUp() {
    solution = new _036_ValidSudoku();
    board = new char[][] {
      "53..7....".toCharArray(),
      "6..195...".toCharArray(),
      ".98....6.".toCharArray(),
      "8...6...3".toCharArray(),
      "4..8.3..1".toCharArray(),
      "7...2...6".toCharArray(),
      ".6....28.".toCharArray(),
      "...419..5".toCharArray(),
      "....8..79".toCharArray()
    };
  }

  @Test public void isValidSudokuTrue() {
    assertTrue(solution.isValidSudoku(board));
  }

  @Test public void isValidSudokuRowFalse() {
    board[0][7] = '3';
    assertFalse(solution.isValidSudoku(board));
  }

  @Test public void isValidSudokuColFalse() {
    board[6][3] = '1';
    assertFalse(solution.isValidSudoku(board));
  }

  @Test public void isValidSudokuBoxFalse() {
    board[7][7] = '2';
    assertFalse(solution.isValidSudoku(board));
  }

}


text:
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 331388 $ -->

<refentry xml:id="function.apc-bin-dumpfile" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>apc_bin_dumpfile</refname>
  <refpurpose>Output a binary dump of cached files and user variables to a file</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>int</type><methodname>apc_bin_dumpfile</methodname>
   <methodparam><type>array</type><parameter>files</parameter></methodparam>
   <methodparam><type>array</type><parameter>user_vars</parameter></methodparam>
   <methodparam><type>string</type><parameter>filename</parameter></methodparam>
   <methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
   <methodparam choice="opt"><type>resource</type><parameter>context</parameter><initializer>NULL</initializer></methodparam>
  </methodsynopsis>
  <para>
   Outputs a binary dump of the given files and user variables from the APC
   cache to the named file.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <variablelist>
   <varlistentry>
    <term><parameter>files</parameter></term>
    <listitem>
     <para>
      The file names being dumped.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>user_vars</parameter></term>
    <listitem>
     <para>
      The user variables being dumped.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>filename</parameter></term>
    <listitem>
     <para>
      The filename where the dump is being saved.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>flags</parameter></term>
    <listitem>
     <para>
      Flags passed to the <parameter>filename</parameter> stream. See the
      <function>file_put_contents</function> documentation for details.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>context</parameter></term>
    <listitem>
     <para>
      The context passed to the <parameter>filename</parameter> stream. See the
      <function>file_put_contents</function> documentation for details.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   The number of bytes written to the file, otherwise
   &false; if APC is not enabled, <parameter>filename</parameter> is an invalid file name,
   <parameter>filename</parameter> can't be opened, the file dump can't be completed
   (e.g., the hard drive is out of disk space), or an unknown error was encountered.
  </para>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <simplelist>
   <member><function>apc_bin_dump</function></member>
   <member><function>apc_bin_load</function></member>
  </simplelist>
 </refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->


text:
layout: post
microblog: true
date: 2009-05-19 03:00 +0300
guid: http://desparoz.micro.blog/2009/05/19/t1851593607.html
---
Australian Democrats relaunching. Launch new web campaign against Australian internet censorship. [www.nointernetcensorship.com](http://www.nointernetcensorship.com)


text:
<!DOCTYPE html>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>CodeRay output</title>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

define.class("$ui/view", function ($ui$, view, label, button, $widgets$, colorpicker) {

        function componentToHex(c) {
                c = Math.floor(c);
                var hex = c.toString(16);
                return hex.length === 1 ? "0" + hex : hex;
        }

        function rgbToHex(r, g, b) {
                return "#" + componentToHex(r * 255) + componentToHex(g * 255) + componentToHex(b * 255);
        }

        function hexToRgb(hex) {
                hex += '';
                // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
                var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
                hex = hex.replace(shorthandRegex, function(m, r, g, b) {
                        return r + r + g + g + b + b;
                });

                var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
                return result ? vec4(
                        parseInt(result[1], 16) / 255,
                        parseInt(result[2], 16) / 255,
                        parseInt(result[3], 16) / 255,
                        1
                ) : null;
        }

        this.attributes = {
                config:Config({type:Object}),
                lightname:Config({type:String})
        }

        this.flex = 0;
        this.bgcolor = NaN;
        this.flexdirection = "column";

        this.init = this.onconfig = function() {
                if (this._config) {
                        this.lightname = this._config.name
                }
        }

        this.render = function() {
                var controls = []
                var id = this.config.id;

                if ('on' in this._config.state) {
                        controls.push(
                                view({},
                                        button({text:"on", click:function() { this.rpc.iot.update(id, 'on', true); }.bind(this) }),
                                        button({text:"off", click:function() { this.rpc.iot.update(id, 'on', false); }.bind(this) }))
                        )
                }

                if ('color' in this._config.state) {
                        controls.push(
                                colorpicker({
                                        colorwheel:true,
                                        colorsliders:false,
                                        colorbox:false,
                                        value: vec4(hexToRgb(this._config.state.color.value)),
                                        valuechange:function(color) {
                                                var hex = rgbToHex(color[0], color[1], color[2]);
                                                this.rpc.iot.update(id, 'color', hex);
                                        }.bind(this)
                                })
                        )
                }

                return [
                        label({text:this.lightname}),
                        controls
                ]
        }

});


text:
package android.studio.imports.templates.recipe;

import org.jetbrains.annotations.NotNull;

/**
 * A single instruction in a recipe. Each implementation corresponds to a tag in
 * recipe.xml
 */
interface RecipeInstruction {

    void execute(@NotNull RecipeExecutor executor) throws TemplateProcessingException;
}


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Write your site description here. It will be used as your sites meta description as well!">

    <title>Wheat7 Blog</title>

    <link rel="canonical" href="http://localhost:4000/">

    <link rel="stylesheet" href="/css/bootstrap.min.css">

    <link rel="stylesheet" href="/css/clean-blog.css">

    <link rel="stylesheet" href="/css/syntax.css">

    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href='//fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
    <link href='//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>

    <link type="application/atom+xml" rel="alternate" href="http://localhost:4000/feed.xml" title="Wheat7 Blog" />

            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                Toggle navigation

            </button>
            Wheat7 Blog

                    Home

                    About

                    Contact

Wheat7 Blog

                    Share Something..

            麦田哥的小站重新上线了!

Posted by Wheat7 on November 20, 2016

Copyright © Wheat7 2016