Commit a7891948f4cfdab393760434ec09df40a290a040

Authored by Diego Camarinha
Committed by João M. M. da Silva
1 parent 878bb309

[Mezuro] Completed throwable model refactoring.

plugins/mezuro/lib/kalibro/error.rb
... ... @@ -1,21 +0,0 @@
1   -class Kalibro::Error < Kalibro::Model
2   -
3   - attr_accessor :error_class, :message, :stack_trace_element, :cause
4   -
5   - def stack_trace_element=(value)
6   - @stack_trace_element = Kalibro::StackTraceElement.to_objects_array value
7   - end
8   -
9   - def stack_trace
10   - @stack_trace_element
11   - end
12   -
13   - def stack_trace=(stack_trace)
14   - @stack_trace_element = stack_trace
15   - end
16   -
17   - def cause=(cause_value)
18   - @cause = Kalibro::Error.to_object cause_value
19   - end
20   -
21   -end
plugins/mezuro/lib/kalibro/throwable.rb 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +class Kalibro::Throwable < Kalibro::Model
  2 +
  3 + attr_accessor :target_string, :message, :cause, :stack_trace_element
  4 +
  5 + def stack_trace_element=(value)
  6 + @stack_trace_element = Kalibro::StackTraceElement.to_objects_array value
  7 + end
  8 +
  9 + def stack_trace
  10 + @stack_trace_element
  11 + end
  12 +
  13 + def stack_trace=(stack_trace)
  14 + @stack_trace_element = stack_trace
  15 + end
  16 +
  17 + def cause=(cause_value)
  18 + @cause = Kalibro::Throwable.to_object cause_value
  19 + end
  20 +
  21 +end
... ...
plugins/mezuro/test/fixtures/error_fixtures.rb
... ... @@ -1,20 +0,0 @@
1   -require File.dirname(__FILE__) + '/stack_trace_element_fixtures'
2   -
3   -class ErrorFixtures
4   -
5   - def self.error
6   - Kalibro::Error.new error_hash
7   - end
8   -
9   - def self.error_hash
10   - {
11   - :error_class => 'java.lang.Exception',
12   - :message => 'Error message from ErrorTest',
13   - :stack_trace_element => [
14   - StackTraceElementFixtures.stack_trace_element_hash('my method 1', 42),
15   - StackTraceElementFixtures.stack_trace_element_hash('my method 2', 84)
16   - ]
17   - }
18   - end
19   -
20   -end
plugins/mezuro/test/fixtures/throwable_fixtures.rb 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +require File.dirname(__FILE__) + '/stack_trace_element_fixtures'
  2 +
  3 +class ThrowableFixtures
  4 +
  5 + def self.throwable
  6 + Kalibro::Throwable.new throwable_hash
  7 + end
  8 +
  9 + def self.throwable_hash
  10 + {
  11 + :target_string => 'Target String',
  12 + :message => 'Throwable message from ThrowableTest',
  13 + :stack_trace_element => [
  14 + StackTraceElementFixtures.stack_trace_element_hash('my method 1', 42),
  15 + StackTraceElementFixtures.stack_trace_element_hash('my method 2', 84)
  16 + ]
  17 + }
  18 + end
  19 +
  20 +end
... ...
plugins/mezuro/test/unit/kalibro/error_test.rb
... ... @@ -1,20 +0,0 @@
1   -require "test_helper"
2   -
3   -require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/error_fixtures"
4   -
5   -class ErrorTest < ActiveSupport::TestCase
6   -
7   - def setup
8   - @hash = ErrorFixtures.error_hash
9   - @error = ErrorFixtures.error
10   - end
11   -
12   - should 'create error from hash' do
13   - assert_equal @hash[:message], Kalibro::Error.new(@hash).message
14   - end
15   -
16   - should 'convert error to hash' do
17   - assert_equal @hash, @error.to_hash
18   - end
19   -
20   -end
plugins/mezuro/test/unit/kalibro/throwable_test.rb 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +require "test_helper"
  2 +
  3 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/throwable_fixtures"
  4 +
  5 +class ThrowableTest < ActiveSupport::TestCase
  6 +
  7 + def setup
  8 + @hash = ThrowableFixtures.throwable_hash
  9 + @throwable = ThrowableFixtures.throwable
  10 + end
  11 +
  12 + should 'create throwable from hash' do
  13 + assert_equal @hash[:message], Kalibro::Throwable.new(@hash).message
  14 + end
  15 +
  16 + should 'convert throwable to hash' do
  17 + assert_equal @hash, @throwable.to_hash
  18 + end
  19 +
  20 +end
... ...