<commit_before>describe Mixins::EmsCommonAngular do
  context '.retrieve_event_stream_selection' do
    let(:network_controller) { EmsNetworkController.new }
    let(:ems_nuage) { FactoryGirl.create(:ems_nuage_network_with_authentication) }
    let(:ems_openstack) { FactoryGirl.create(:ems_openstack_with_authentication) }

    it 'when amqp' do
      ems_nuage.endpoints << Endpoint.create(:role => 'amqp', :hostname => 'hostname')
      network_controller.instance_variable_set(:@ems, ems_nuage)

      expect(network_controller.send(:retrieve_event_stream_selection)).to eq('amqp')
    end

    it 'when ceilometer' do
      ems_openstack.endpoints << Endpoint.create(:role => 'ceilometer', :hostname => 'hostname')
      network_controller.instance_variable_set(:@ems, ems_openstack)

      expect(network_controller.send(:retrieve_event_stream_selection)).to eq('ceilometer')
    end

    it 'when ceilometer and amqp has empty hostname' do
      ems_nuage.endpoints << Endpoint.create(:role => 'ceilometer', :hostname => 'hostname')
      ems_nuage.endpoints << Endpoint.create(:role => 'amqp')
      network_controller.instance_variable_set(:@ems, ems_nuage)

      expect(network_controller.send(:retrieve_event_stream_selection)).to eq('ceilometer')
    end

    it 'when amqp and ceilometer has empty hostname' do
      ems_nuage.endpoints << Endpoint.create(:role => 'ceilometer')
      ems_nuage.endpoints << Endpoint.create(:role => 'amqp', :hostname => 'hostname')
      network_controller.instance_variable_set(:@ems, ems_nuage)

      expect(network_controller.send(:retrieve_event_stream_selection)).to eq('amqp')
    end

    it 'none when amqp and ceilometer have empty hostnames' do
      ems_nuage.endpoints << Endpoint.create(:role => 'ceilometer')
      ems_nuage.endpoints << Endpoint.create(:role => 'amqp')
      network_controller.instance_variable_set(:@ems, ems_nuage)

      expect(network_controller.send(:retrieve_event_stream_selection)).to eq('none')
    end

    it 'ceilometer when openstack provider when amqp and ceilometer have nil endpoints' do
      network_controller.instance_variable_set(:@ems, ems_openstack)

      expect(network_controller.send(:retrieve_event_stream_selection)).to eq('ceilometer')
    end

    it 'when none' do
      network_controller.instance_variable_set(:@ems, ems_nuage)

      expect(network_controller.send(:retrieve_event_stream_selection)).to eq('none')
    end
  end
end
<commit_msg>Remove default endpoints for :ems_nuage_network_with_authentication<commit_after>describe Mixins::EmsCommonAngular do
  context '.retrieve_event_stream_selection' do
    let(:network_controller) { EmsNetworkController.new }
    let(:ems_nuage) { FactoryGirl.create(:ems_nuage_network_with_authentication) }
    let(:ems_openstack) { FactoryGirl.create(:ems_openstack_with_authentication) }

    it 'when amqp' do
      # remove default endpoints
      ems_nuage.endpoints = []
      ems_nuage.endpoints << Endpoint.create(:role => 'amqp', :hostname => 'hostname')
      network_controller.instance_variable_set(:@ems, ems_nuage)

      expect(network_controller.send(:retrieve_event_stream_selection)).to eq('amqp')
    end

    it 'when ceilometer' do
      ems_openstack.endpoints << Endpoint.create(:role => 'ceilometer', :hostname => 'hostname')
      network_controller.instance_variable_set(:@ems, ems_openstack)

      expect(network_controller.send(:retrieve_event_stream_selection)).to eq('ceilometer')
    end

    it 'when ceilometer and amqp has empty hostname' do
      # remove default endpoints
      ems_nuage.endpoints = []
      ems_nuage.endpoints << Endpoint.create(:role => 'ceilometer', :hostname => 'hostname')
      ems_nuage.endpoints << Endpoint.create(:role => 'amqp')
      network_controller.instance_variable_set(:@ems, ems_nuage)

      expect(network_controller.send(:retrieve_event_stream_selection)).to eq('ceilometer')
    end

    it 'when amqp and ceilometer has empty hostname' do
      # remove default endpoints
      ems_nuage.endpoints = []
      ems_nuage.endpoints << Endpoint.create(:role => 'ceilometer')
      ems_nuage.endpoints << Endpoint.create(:role => 'amqp', :hostname => 'hostname')
      network_controller.instance_variable_set(:@ems, ems_nuage)

      expect(network_controller.send(:retrieve_event_stream_selection)).to eq('amqp')
    end

    it 'none when amqp and ceilometer have empty hostnames' do
      # remove default endpoints
      ems_nuage.endpoints = []
      ems_nuage.endpoints << Endpoint.create(:role => 'ceilometer')
      ems_nuage.endpoints << Endpoint.create(:role => 'amqp')
      network_controller.instance_variable_set(:@ems, ems_nuage)

      expect(network_controller.send(:retrieve_event_stream_selection)).to eq('none')
    end

    it 'ceilometer when openstack provider when amqp and ceilometer have nil endpoints' do
      network_controller.instance_variable_set(:@ems, ems_openstack)

      expect(network_controller.send(:retrieve_event_stream_selection)).to eq('ceilometer')
    end

    it 'when none' do
      # remove default endpoints
      ems_nuage.endpoints = []
      network_controller.instance_variable_set(:@ems, ems_nuage)

      expect(network_controller.send(:retrieve_event_stream_selection)).to eq('none')
    end
  end
end

{'fraction_non_alphanumeric': 0.1095166163141994, 'fraction_numerical': 0.0, 'mean_word_length': 4.617179215270413, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 27, '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': '3132705', 'n_tokens_mistral': 1648, 'n_tokens_neox': 1590, 'n_words': 292}