Sha256: 03f456c29cacfacd6d00dce98ad251aac65ec0c53e9725aea8b50f1debaa6332

Contents?: true

Size: 1.59 KB

Versions: 33

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'

describe Killbill::Plugin::Api::InvoicePluginApi do

  before(:all) do
    logger            = ::Logger.new(STDOUT)
    @invoicePluginApi = Killbill::Plugin::Api::InvoicePluginApi.new('Killbill::Plugin::InvoiceTest', {'logger' => logger, "root" => "/a/b/plugin_name/1.2.3"})
  end

  it 'should add items' do
    invoice = create_invoice

    items = @invoicePluginApi.get_additional_invoice_items(invoice, java.lang.Boolean::FALSE, java.util.ArrayList.new, nil)
    items.size.should == 2

    items.get(0).invoice_id.should == invoice.id
    items.get(0).amount.compareTo(java.math.BigDecimal.new('7')).should == 0
    items.get(0).invoice_item_type.should == org.killbill.billing.invoice.api.InvoiceItemType::TAX

    items.get(1).invoice_id.should == invoice.id
    items.get(1).amount.compareTo(java.math.BigDecimal.new('200')).should == 0
    items.get(1).invoice_item_type.should == org.killbill.billing.invoice.api.InvoiceItemType::EXTERNAL_CHARGE
  end

  private

  def create_invoice
    invoice_id = java.util.UUID.random_uuid

    invoice = org.mockito.Mockito.mock(org.killbill.billing.invoice.api.Invoice.java_class)
    org.mockito.Mockito.when(invoice.getId).thenReturn(invoice_id)

    item = org.mockito.Mockito.mock(org.killbill.billing.invoice.api.InvoiceItem.java_class)
    org.mockito.Mockito.when(item.getInvoiceId).thenReturn(invoice_id)
    org.mockito.Mockito.when(item.getAmount).thenReturn(java.math.BigDecimal.new('100'))

    items = java.util.ArrayList.new
    items.add(item)
    org.mockito.Mockito.when(invoice.getInvoiceItems).thenReturn(items)

    invoice
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
killbill-9.4.1 spec/killbill/invoice_plugin_api_spec.rb
killbill-8.3.6 spec/killbill/invoice_plugin_api_spec.rb
killbill-9.4.0 spec/killbill/invoice_plugin_api_spec.rb
killbill-9.3.2 spec/killbill/invoice_plugin_api_spec.rb
killbill-9.3.1 spec/killbill/invoice_plugin_api_spec.rb
killbill-8.3.5 spec/killbill/invoice_plugin_api_spec.rb
killbill-9.3.0 spec/killbill/invoice_plugin_api_spec.rb
killbill-9.2.2 spec/killbill/invoice_plugin_api_spec.rb
killbill-8.3.4 spec/killbill/invoice_plugin_api_spec.rb
killbill-8.3.3 spec/killbill/invoice_plugin_api_spec.rb
killbill-9.2.1 spec/killbill/invoice_plugin_api_spec.rb
killbill-9.2.0 spec/killbill/invoice_plugin_api_spec.rb
killbill-8.3.2 spec/killbill/invoice_plugin_api_spec.rb
killbill-8.3.1 spec/killbill/invoice_plugin_api_spec.rb
killbill-8.3.0 spec/killbill/invoice_plugin_api_spec.rb
killbill-8.2.0 spec/killbill/invoice_plugin_api_spec.rb
killbill-8.1.0 spec/killbill/invoice_plugin_api_spec.rb
killbill-7.0.6 spec/killbill/invoice_plugin_api_spec.rb
killbill-8.0.1 spec/killbill/invoice_plugin_api_spec.rb
killbill-8.0.0 spec/killbill/invoice_plugin_api_spec.rb