killbill-notification-test 1.9.1 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Jarfile +7 -5
- data/VERSION +1 -1
- data/killbill-notification-test.gemspec +1 -1
- data/lib/notification_test/api.rb +13 -73
- data/lib/notification_test.rb +1 -1
- data/pom.xml +3 -1
- data/spec/notification_test/base_plugin_spec.rb +17 -45
- data/spec/spec_helper.rb +0 -6
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0db53e3909623cdf3274547e58608289005d1d5
|
4
|
+
data.tar.gz: 22b6a208a5a0804e834143c7e455f084d1677fce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c84fe0b6dc580e16b69b765224b5cbcafb687a11c2bc6a0b61cde2c248054bb93b70601681b6ac207c42b91fccc0d6ff30d9b45d129129f564ce5396006cc213
|
7
|
+
data.tar.gz: 7d3b00f30338ca4bbd18201f492537563e7dbb5451b26de74822c471008e5dcdc220fa1489b9afe5e0eb4086b4c6648375e1f19ce67dffc6133db35cb8081791
|
data/Jarfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
jar 'org.kill-bill.billing:killbill-api', '0.9.
|
2
|
-
jar 'org.kill-bill.billing.plugin:killbill-plugin-api-notification', '0.7.
|
3
|
-
jar 'org.kill-bill.billing.plugin:killbill-plugin-api-payment', '0.7.
|
4
|
-
jar 'org.kill-bill.billing.plugin:killbill-plugin-api-currency', '0.7.
|
5
|
-
jar 'org.kill-bill.billing:killbill-
|
1
|
+
jar 'org.kill-bill.billing:killbill-api', '0.9.6'
|
2
|
+
jar 'org.kill-bill.billing.plugin:killbill-plugin-api-notification', '0.7.4'
|
3
|
+
jar 'org.kill-bill.billing.plugin:killbill-plugin-api-payment', '0.7.4'
|
4
|
+
jar 'org.kill-bill.billing.plugin:killbill-plugin-api-currency', '0.7.4'
|
5
|
+
jar 'org.kill-bill.billing.plugin:killbill-plugin-api-retry', '0.7.4'
|
6
|
+
jar 'org.kill-bill.billing.plugin:killbill-plugin-api-invoice', '0.7.4'
|
7
|
+
jar 'org.kill-bill.billing:killbill-util:tests', '0.11.3'
|
6
8
|
jar 'javax.servlet:javax.servlet-api', '3.0.1'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.9.
|
1
|
+
1.9.2
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
|
23
23
|
s.rdoc_options << '--exclude' << '.'
|
24
24
|
|
25
|
-
s.add_dependency 'killbill', '~> 3.1.
|
25
|
+
s.add_dependency 'killbill', '~> 3.1.4'
|
26
26
|
|
27
27
|
s.add_development_dependency 'jbundler', '~> 0.4.1'
|
28
28
|
s.add_development_dependency 'rake', '>= 10.0.0'
|
@@ -1,86 +1,26 @@
|
|
1
|
-
require 'date'
|
2
|
-
|
3
|
-
require 'killbill'
|
4
|
-
require 'killbill/notification'
|
5
|
-
|
6
|
-
=begin
|
7
|
-
class Killbill::Plugin::Model::ExtBusEvent
|
8
|
-
def to_s
|
9
|
-
"type = #{@event_type}, object_type = #{@object_type} : object_id = #{@object_id}, account_id = #{@account_id}, tenant_id = #{@tenant_id}"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
=end
|
13
|
-
|
14
|
-
|
15
1
|
module NotificationTest
|
16
2
|
class NotificationPlugin < Killbill::Plugin::Notification
|
17
3
|
|
18
|
-
|
19
|
-
def start_plugin
|
20
|
-
super
|
21
|
-
end
|
22
|
-
|
23
|
-
def initialize(*args)
|
24
|
-
super(*args)
|
25
|
-
@tag_definition = nil
|
26
|
-
end
|
27
|
-
|
28
4
|
def on_event(event)
|
29
|
-
|
30
|
-
print "ENTER #{event.to_s}, class = #{event.class}"
|
31
|
-
|
32
5
|
if event.event_type == :ACCOUNT_CREATION
|
33
|
-
|
34
|
-
# Retrieve account and update email
|
35
|
-
#
|
36
|
-
print "before get_account_by_id..."
|
37
|
-
account = @kb_apis.account_user_api.get_account_by_id(event.object_id, @kb_apis.create_context)
|
38
|
-
|
39
|
-
print "before update account..."
|
40
|
-
updated_account = Killbill::Plugin::Model::Account.new
|
41
|
-
updated_account.id=account.id
|
42
|
-
updated_account.email="plugintest@plugin.com"
|
43
|
-
@kb_apis.account_user_api.update_account(updated_account, @kb_apis.create_context)
|
44
|
-
|
45
|
-
print "before tag definition creation..."
|
46
|
-
@tag_definition = @kb_apis.tag_user_api.create_tag_definition("NotificationPlugin", "Tag for test NotificationTest", @kb_apis.create_context)
|
47
|
-
|
48
|
-
print "before tag creation... #{@tag_definition.inspect}"
|
49
|
-
@kb_apis.tag_user_api.add_tag(event.account_id, :ACCOUNT, @tag_definition.id, @kb_apis.create_context)
|
50
|
-
|
6
|
+
write_event :TAG_CREATION, :ACCOUNT, event.object_id, event.account_id, event.tenant_id
|
51
7
|
elsif event.event_type == :ACCOUNT_CHANGE
|
52
|
-
|
53
|
-
|
54
|
-
#
|
55
|
-
#
|
56
|
-
|
57
|
-
account = @kb_apis.account_user_api.get_account_by_id(event.object_id, @kb_apis.create_context)
|
58
|
-
validate(account.email, "plugintest@plugin.com")
|
59
|
-
|
60
|
-
|
61
|
-
elsif event.event_type == :SUBSCRIPTION_CREATION
|
62
|
-
elsif event.event_type == :INVOICE_CREATION
|
63
|
-
elsif event.event_type == :SUBSCRIPTION_CANCEL
|
64
|
-
elsif event.event_type == :PAYMENT_SUCCESS
|
65
|
-
elsif event.event_type == :TAG_CREATION
|
66
|
-
|
67
|
-
print "before getTagsForAccount.."
|
68
|
-
tags = @kb_apis.tag_user_api.get_tags_for_account(event.account_id, @kb_apis.create_context)
|
69
|
-
validate(tags.size, 1)
|
70
|
-
validate(tags.get(0).tag_definition_id, @tag_definition)
|
8
|
+
write_event :TAG_DELETION, :ACCOUNT, event.object_id, event.account_id, event.tenant_id
|
9
|
+
else
|
10
|
+
@logger.warn "Unexpected event type #{event.event_type} for object #{event.object_type}"
|
11
|
+
# Error: unexpected event. Notify the test by sending a bogus event
|
12
|
+
write_event :SUBSCRIPTION_UNCANCEL, :SUBSCRIPTION, 'f2e50cd0-faec-11e3-a3ac-0800200c9a66', 'f2e50cd0-faec-11e3-a3ac-0800200c9a66', 'f2e50cd0-faec-11e3-a3ac-0800200c9a66'
|
71
13
|
end
|
72
|
-
|
73
|
-
print "EXIT #{event.to_s}"
|
74
|
-
|
75
14
|
end
|
76
15
|
|
77
|
-
|
78
|
-
|
79
|
-
|
16
|
+
private
|
17
|
+
|
18
|
+
def write_event(event_type, object_type, object_id, account_id, tenant_id)
|
19
|
+
file_name = "/var/tmp/killbill-notification-test.txt"
|
20
|
+
content = "#{event_type}-#{object_type}-#{object_id}-#{account_id}-#{tenant_id}"
|
80
21
|
|
81
|
-
|
82
|
-
puts
|
83
|
-
$stdout.flush
|
22
|
+
# Append the content to make sure we fail in case we receive multiple events
|
23
|
+
File.open(file_name, 'a') { |f| f.puts content }
|
84
24
|
end
|
85
25
|
end
|
86
26
|
end
|
data/lib/notification_test.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
require 'killbill'
|
2
2
|
require 'notification_test/api'
|
data/pom.xml
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<!--
|
3
3
|
~ Copyright 2010-2013 Ning, Inc.
|
4
|
+
~ Copyright 2014 Groupon, Inc
|
5
|
+
~ Copyright 2014 The Billing Project, LLC
|
4
6
|
~
|
5
7
|
~ Ning licenses this file to you under the Apache License, version 2.0
|
6
8
|
~ (the "License"); you may not use this file except in compliance with the
|
@@ -25,7 +27,7 @@
|
|
25
27
|
<groupId>org.kill-bill.billing.plugin.ruby</groupId>
|
26
28
|
<artifactId>notification-test-plugin</artifactId>
|
27
29
|
<packaging>pom</packaging>
|
28
|
-
<version>1.9.
|
30
|
+
<version>1.9.2</version>
|
29
31
|
<name>notification-test-plugin</name>
|
30
32
|
<description></description>
|
31
33
|
<scm>
|
@@ -1,56 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'logger'
|
3
|
-
require 'tempfile'
|
4
3
|
|
5
4
|
require 'notification_test'
|
6
5
|
|
7
|
-
class FakeJavaUserAccountApi
|
8
|
-
# Returns an account where we specify the currency for the report group
|
9
|
-
def get_account_by_id(id, context)
|
10
|
-
account = Killbill::Plugin::Model::Account.new
|
11
|
-
account.id=id
|
12
|
-
account
|
13
|
-
end
|
14
|
-
|
15
|
-
def update_account(updated_account, context)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class FakeTagUserApi
|
20
|
-
def add_tag(account_id, object_type, tag_definition_id, context)
|
21
|
-
end
|
22
|
-
|
23
|
-
def create_tag_definition(type, desc, context)
|
24
|
-
end
|
25
|
-
|
26
|
-
def get_tags_for_account(account_id, context)
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
6
|
describe NotificationTest::NotificationPlugin do
|
33
|
-
before(:each) do
|
34
7
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
kb_apis = Killbill::Plugin::KillbillApi.new("foo", svcs)
|
8
|
+
before(:each) do
|
9
|
+
kb_apis = Killbill::Plugin::KillbillApi.new("killbill-notification-test", {})
|
39
10
|
|
40
|
-
@plugin
|
41
|
-
@plugin.logger
|
11
|
+
@plugin = NotificationTest::NotificationPlugin.new
|
12
|
+
@plugin.logger = Logger.new(STDOUT)
|
42
13
|
@plugin.kb_apis = kb_apis
|
43
14
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
@kb_event
|
50
|
-
@kb_event.event_type=event_type
|
51
|
-
@kb_event.object_type=object_type
|
52
|
-
@kb_event.account_id=account_id
|
53
|
-
@kb_event.tenant_id=tenant_id
|
15
|
+
@kb_event = Killbill::Plugin::Model::ExtBusEvent.new
|
16
|
+
@kb_event.event_type = :INVOICE_CREATION
|
17
|
+
@kb_event.object_type = :INVOICE
|
18
|
+
@kb_event.object_id = "9f73c8e9-188a-4603-a3ba-2ce684411fb9"
|
19
|
+
@kb_event.account_id = "a86ed6d4-c0bd-4a44-b49a-5ec29c3b314a"
|
20
|
+
@kb_event.tenant_id = "b86fd6d4-c0bd-4a44-b49a-5ec29c3b3765"
|
54
21
|
end
|
55
22
|
|
56
23
|
it "should start and stop correctly" do
|
@@ -58,8 +25,13 @@ describe NotificationTest::NotificationPlugin do
|
|
58
25
|
@plugin.stop_plugin
|
59
26
|
end
|
60
27
|
|
61
|
-
it "should should test
|
28
|
+
it "should should test receiving an event" do
|
29
|
+
file_name = '/var/tmp/killbill-notification-test.txt'
|
30
|
+
|
62
31
|
output = @plugin.on_event(@kb_event)
|
63
|
-
|
32
|
+
output.should be_nil
|
64
33
|
|
34
|
+
File.file?(file_name).should be_true
|
35
|
+
File.delete file_name
|
36
|
+
end
|
65
37
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: killbill-notification-test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Killbill core team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: killbill
|
@@ -16,12 +16,12 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.1.
|
19
|
+
version: 3.1.4
|
20
20
|
requirement: !ruby/object:Gem::Requirement
|
21
21
|
requirements:
|
22
22
|
- - ~>
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 3.1.
|
24
|
+
version: 3.1.4
|
25
25
|
prerelease: false
|
26
26
|
type: :runtime
|
27
27
|
- !ruby/object:Gem::Dependency
|