killbill-notification-test 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3187df3d89096e2e1d40d6d63f95ae26ba9efc7b
4
+ data.tar.gz: c49721c1765d979e2a4c97f110cc1b274b087aba
5
+ SHA512:
6
+ metadata.gz: 2385acd5e2ebcfa5cc438c2c406e1fe534e8c7f9c56d38917204130e9d35b6a9b0b981ef6e2bdf431dfe7425eb0ba90e141514a5d89bc085fb5adb4f1410c0d9
7
+ data.tar.gz: b117cf5050008ceca2062137ef987a2d14004c7176eaacd5efa5afb07af9840b887d7db94ee69b167211d666e0a27df0ea27baa8071edfa839c9d73ac2861113
data/.gitignore ADDED
@@ -0,0 +1,25 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+ build
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+ .idea/
20
+ .jbundler
21
+ Jarfile.lock
22
+ Gemfile.lock
23
+ *.swp
24
+ killbill-notification-test
25
+ pom.xml.asc
data/.travis.yml ADDED
@@ -0,0 +1,19 @@
1
+ language: ruby
2
+
3
+ notifications:
4
+ email:
5
+ - kill-bill-commits@googlegroups.com
6
+
7
+ rvm:
8
+ - jruby-19mode
9
+ - jruby-20mode
10
+ - jruby-head
11
+
12
+ jdk:
13
+ - openjdk6
14
+ - openjdk7
15
+ - oraclejdk7
16
+
17
+ matrix:
18
+ allow_failures:
19
+ - rvm: jruby-head
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ #gem 'killbill', :path => '../killbill-plugin-framework-ruby'
data/Jarfile ADDED
@@ -0,0 +1,6 @@
1
+ jar 'org.kill-bill.billing:killbill-api', '0.8.2-SNAPSHOT'
2
+ jar 'org.kill-bill.billing.plugin:killbill-plugin-api-notification', '0.6.4-SNAPSHOT'
3
+ jar 'org.kill-bill.billing.plugin:killbill-plugin-api-payment', '0.6.4-SNAPSHOT'
4
+ jar 'org.kill-bill.billing.plugin:killbill-plugin-api-currency', '0.6.4-SNAPSHOT'
5
+ jar 'org.kill-bill.billing:killbill-util:tests', '0.9.0-SNAPSHOT'
6
+ jar 'javax.servlet:javax.servlet-api', '3.0.1'
data/README.md ADDED
@@ -0,0 +1,7 @@
1
+ killbill-notification-test-plugin
2
+ =================================
3
+
4
+ Plugin to test the Kill Bill NotificationPlugin API.
5
+
6
+
7
+ Release builds are available on [Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.ning.killbill.ruby%22%20AND%20a%3A%22notification-test-plugin%22) with coordinates `com.ning.killbill.ruby:notification-test-plugin`.
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env rake
2
+
3
+ # Install tasks to build and release the plugin
4
+ require 'bundler/setup'
5
+ Bundler::GemHelper.install_tasks
6
+
7
+ # Install test tasks
8
+ require 'rspec/core/rake_task'
9
+ desc "Run RSpec"
10
+ RSpec::Core::RakeTask.new
11
+
12
+ # Install tasks to package the plugin for Killbill
13
+ require 'killbill/rake_task'
14
+ Killbill::PluginHelper.install_tasks
15
+
16
+ # Run tests by default
17
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,30 @@
1
+ version = File.read(File.expand_path('../VERSION', __FILE__)).strip
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'killbill-notification-test'
5
+ s.version = version
6
+ s.summary = 'Plugin to test notification plugin api'
7
+ s.description = 'Killbill Plugin to test notification plugin api'
8
+
9
+ s.required_ruby_version = '>= 1.9.3'
10
+
11
+ s.license = 'Apache License (2.0)'
12
+
13
+ s.author = 'Killbill core team'
14
+ s.email = 'killbilling-users@googlegroups.com'
15
+ s.homepage = 'http://www.killbilling.org'
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.bindir = 'bin'
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ s.rdoc_options << '--exclude' << '.'
24
+
25
+ s.add_dependency 'killbill', '~> 3.0.0'
26
+
27
+ s.add_development_dependency 'jbundler', '~> 0.4.1'
28
+ s.add_development_dependency 'rake', '>= 10.0.0'
29
+ s.add_development_dependency 'rspec', '~> 2.12.0'
30
+ end
@@ -0,0 +1,3 @@
1
+ mainClass=NotificationTest::NotificationPlugin
2
+ require=notification_test
3
+ pluginType=NOTIFICATION
@@ -0,0 +1,2 @@
1
+
2
+ require 'notification_test/api'
@@ -0,0 +1,86 @@
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
+ module NotificationTest
16
+ class NotificationPlugin < Killbill::Plugin::Notification
17
+
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
+ def on_event(event)
29
+
30
+ print "ENTER #{event.to_s}, class = #{event.class}"
31
+
32
+ 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
+
51
+ elsif event.event_type == :ACCOUNT_CHANGE
52
+
53
+ #
54
+ # Verify new email
55
+ #
56
+ print "before get_account_by_id..."
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)
71
+ end
72
+
73
+ print "EXIT #{event.to_s}"
74
+
75
+ end
76
+
77
+ def validate(value, expected)
78
+ print "VALIDATION Got #{value} : expected #{expected}"
79
+ end
80
+
81
+ def print(msg)
82
+ puts "******************************************* NotificationTestPlugin #{msg}"
83
+ $stdout.flush
84
+ end
85
+ end
86
+ end
data/pom.xml ADDED
@@ -0,0 +1,36 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ ~ Copyright 2010-2013 Ning, Inc.
4
+ ~
5
+ ~ Ning licenses this file to you under the Apache License, version 2.0
6
+ ~ (the "License"); you may not use this file except in compliance with the
7
+ ~ License. You may obtain a copy of the License at:
8
+ ~
9
+ ~ http://www.apache.org/licenses/LICENSE-2.0
10
+ ~
11
+ ~ Unless required by applicable law or agreed to in writing, software
12
+ ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ ~ License for the specific language governing permissions and limitations
15
+ ~ under the License.
16
+ -->
17
+
18
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19
+ <parent>
20
+ <groupId>org.sonatype.oss</groupId>
21
+ <artifactId>oss-parent</artifactId>
22
+ <version>5</version>
23
+ </parent>
24
+ <modelVersion>4.0.0</modelVersion>
25
+ <groupId>org.kill-bill.ruby</groupId>
26
+ <artifactId>notification-test-plugin</artifactId>
27
+ <packaging>pom</packaging>
28
+ <version>1.0.0</version>
29
+ <name>notification-test-plugin</name>
30
+ <description></description>
31
+ <scm>
32
+ <connection>scm:git:git://github.com/killbill/killbill-notification-test-plugin.git</connection>
33
+ <url>https://github.com/killbill/killbill-notification-test-plugin/</url>
34
+ <developerConnection>scm:git:git@github.com:killbill/killbill-notification-test-plugin.git</developerConnection>
35
+ </scm>
36
+ </project>
data/release.sh ADDED
@@ -0,0 +1,41 @@
1
+ set -e
2
+
3
+ if [ "GNU" != "$(tar --help | grep GNU | head -1 | awk '{print $1}')" ]; then
4
+ echo "Unable to release: make sure to use GNU tar"
5
+ exit 1
6
+ fi
7
+
8
+ if $(ruby -e'require "java"'); then
9
+ # Good
10
+ echo "Detected JRuby"
11
+ else
12
+ echo "Unable to release: make sure to use JRuby"
13
+ exit 1
14
+ fi
15
+
16
+ VERSION=`grep -E '<version>([0-9]+\.[0-9]+\.[0-9]+)</version>' pom.xml | sed 's/[\t \n]*<version>\(.*\)<\/version>[\t \n]*/\1/'`
17
+ if [ "$VERSION" != "$(cat $PWD/VERSION)" ]; then
18
+ echo "Unable to release: make sure the versions in pom.xml and VERSION match"
19
+ exit 1
20
+ fi
21
+
22
+ echo "Cleaning up"
23
+ rake killbill:clean ; rake build
24
+
25
+ echo "Pushing the gem to Rubygems"
26
+ rake release
27
+
28
+ echo "Building artifact"
29
+ rake killbill:package
30
+
31
+ ARTIFACT="$PWD/pkg/killbill-notification-test-$VERSION.tar.gz"
32
+ echo "Pushing $ARTIFACT to Maven Central"
33
+ mvn gpg:sign-and-deploy-file \
34
+ -DgroupId=org.kill-bill.ruby \
35
+ -DartifactId=notification-test-plugin \
36
+ -Dversion=$VERSION \
37
+ -Dpackaging=tar.gz \
38
+ -DrepositoryId=ossrh-releases \
39
+ -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
40
+ -Dfile=$ARTIFACT \
41
+ -DpomFile=pom.xml
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+ require 'logger'
3
+ require 'tempfile'
4
+
5
+ require 'notification_test'
6
+
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
+ describe NotificationTest::NotificationPlugin do
33
+ before(:each) do
34
+
35
+ svcs = {:account_user_api => FakeJavaUserAccountApi.new,
36
+ :tag_user_api => FakeTagUserApi.new }
37
+
38
+ kb_apis = Killbill::Plugin::KillbillApi.new("foo", svcs)
39
+
40
+ @plugin = NotificationTest::NotificationPlugin.new
41
+ @plugin.logger = Logger.new(STDOUT)
42
+ @plugin.kb_apis = kb_apis
43
+
44
+ account_id = "a86ed6d4-c0bd-4a44-b49a-5ec29c3b314a"
45
+ object_id = "9f73c8e9-188a-4603-a3ba-2ce684411fb9"
46
+ event_type = "INVOICE_CREATION"
47
+ object_type = "INVOICE"
48
+ tenant_id = "b86fd6d4-c0bd-4a44-b49a-5ec29c3b3765"
49
+ @kb_event = Killbill::Plugin::Model::ExtBusEvent.new
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
54
+ end
55
+
56
+ it "should start and stop correctly" do
57
+ @plugin.start_plugin
58
+ @plugin.stop_plugin
59
+ end
60
+
61
+ it "should should test charge" do
62
+ output = @plugin.on_event(@kb_event)
63
+ end
64
+
65
+ end
@@ -0,0 +1,16 @@
1
+ require 'bundler'
2
+
3
+ require 'killbill'
4
+ require 'rspec'
5
+
6
+ RSpec.configure do |config|
7
+ config.color_enabled = true
8
+ config.tty = true
9
+ config.formatter = 'documentation'
10
+ end
11
+
12
+ class Object
13
+ def blank?
14
+ respond_to?(:empty?) ? empty? : !self
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: killbill-notification-test
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Killbill core team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: killbill
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 3.0.0
25
+ prerelease: false
26
+ type: :runtime
27
+ - !ruby/object:Gem::Dependency
28
+ name: jbundler
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.1
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: 0.4.1
39
+ prerelease: false
40
+ type: :development
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 10.0.0
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: 10.0.0
53
+ prerelease: false
54
+ type: :development
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.12.0
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: 2.12.0
67
+ prerelease: false
68
+ type: :development
69
+ description: Killbill Plugin to test notification plugin api
70
+ email: killbilling-users@googlegroups.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - .gitignore
76
+ - .travis.yml
77
+ - Gemfile
78
+ - Jarfile
79
+ - README.md
80
+ - Rakefile
81
+ - VERSION
82
+ - killbill-notification-test.gemspec
83
+ - killbill.properties
84
+ - lib/notification_test.rb
85
+ - lib/notification_test/api.rb
86
+ - pom.xml
87
+ - release.sh
88
+ - spec/notification_test/base_plugin_spec.rb
89
+ - spec/spec_helper.rb
90
+ homepage: http://www.killbilling.org
91
+ licenses:
92
+ - Apache License (2.0)
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options:
96
+ - --exclude
97
+ - .
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: 1.9.3
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.1.9
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Plugin to test notification plugin api
116
+ test_files:
117
+ - spec/notification_test/base_plugin_spec.rb
118
+ - spec/spec_helper.rb