<commit_before>require 'spec_helper'

SONAR_PROPERTIES = "/usr/local/sonar/conf/sonar.properties"

describe 'sonarqube' do

  context "when installing version 3", :compile do
    let(:params) {{ :version => '3.7.4' }}
    it { should contain_wget__fetch('download-sonar').with_source('http://dist.sonar.codehaus.org/sonar-3.7.4.zip') }
  end

  context "when installing version 4", :compile do
    let(:params) {{ :version => '4.1.2' }}
    it { should contain_wget__fetch('download-sonar').with_source('http://dist.sonar.codehaus.org/sonarqube-4.1.2.zip') }
  end

  context "when crowd configuration is supplied", :compile do
    let(:params) { { :crowd => {
      'application' => 'crowdapplication',
      'service_url' => 'crowdserviceurl',
      'password'    => '<PASSWORD>',
    } } }

    it { should contain_sonarqube__plugin('sonar-crowd-plugin').with_ensure('present') }

    it { should contain_file(SONAR_PROPERTIES) }
    it 'should generate sonar.properties config for crowd' do
      content = subject.resource('file', SONAR_PROPERTIES).send(:parameters)[:content]<commit_msg>provide missing variables for ci build<commit_after>require 'spec_helper'

SONAR_PROPERTIES = "/usr/local/sonar/conf/sonar.properties"

describe 'sonarqube' do

  let(:facts) {{
    :kernel => 'linux',
    :architecture => 'amd64',
    :operatingsystem => 'CentOS',
    :http_proxy => '',
    :maven_version => '3.0.5',
  }}

  context "when installing version 3", :compile do
    let(:params) {{ :version => '3.7.4' }}
    it { should contain_wget__fetch('download-sonar').with_source('http://dist.sonar.codehaus.org/sonar-3.7.4.zip') }
  end

  context "when installing version 4", :compile do
    let(:params) {{ :version => '4.1.2' }}
    it { should contain_wget__fetch('download-sonar').with_source('http://dist.sonar.codehaus.org/sonarqube-4.1.2.zip') }
  end

  context "when crowd configuration is supplied", :compile do
    let(:params) { { :crowd => {
      'application' => 'crowdapplication',
      'service_url' => 'crowdserviceurl',
      'password'    => '<PASSWORD>',
    } } }

    it { should contain_sonarqube__plugin('sonar-crowd-plugin').with_ensure('present') }

    it { should contain_file(SONAR_PROPERTIES) }
    it 'should generate sonar.properties config for crowd' do
      content = subject.resource('file', SONAR_PROPERTIES).send(:parameters)[:content]
{'fraction_non_alphanumeric': 0.16035353535353536, 'fraction_numerical': 0.013888888888888888, 'mean_word_length': 3.9832285115303985, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2852094', 'n_tokens_mistral': 819, 'n_tokens_neox': 786, 'n_words': 150}