mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
proper java to ruby conversions and specs
proper java to ruby convertion and specs missing ruby conversions add missing timestamp= method added usec method missing constants added usec, tv_usec, year methods clean ruby_to_hash_with_metadata method rework boolean cast add BigDecimal missing import reworked Ruby to JAva type conversion better nil objects handling and better debug trace
This commit is contained in:
parent
a43709e8fb
commit
72637f5bc3
8 changed files with 297 additions and 97 deletions
|
@ -196,7 +196,41 @@ describe LogStash::Event do
|
|||
it "should warn on invalid timestamp object" do
|
||||
LogStash::Event.logger = logger
|
||||
expect(logger).to receive(:warn).once.with(/^Unrecognized/)
|
||||
LogStash::Event.new(TIMESTAMP => Object.new)
|
||||
LogStash::Event.new(TIMESTAMP => Array.new)
|
||||
end
|
||||
end
|
||||
|
||||
context "to_hash" do
|
||||
let (:source_hash) { {"a" => 1, "b" => [1, 2, 3, {"h" => 1, "i" => "baz"}], "c" => {"d" => "foo", "e" => "bar", "f" => [4, 5, "six"]}} }
|
||||
let (:source_hash_with_matada) { source_hash.merge({"@metadata" => {"a" => 1, "b" => 2}}) }
|
||||
subject { LogStash::Event.new(source_hash_with_matada) }
|
||||
|
||||
it "should include @timestamp and @version" do
|
||||
h = subject.to_hash
|
||||
expect(h).to include("@timestamp")
|
||||
expect(h).to include("@version")
|
||||
expect(h).not_to include("@metadata")
|
||||
end
|
||||
|
||||
it "should include @timestamp and @version and @metadata" do
|
||||
h = subject.to_hash_with_metadata
|
||||
expect(h).to include("@timestamp")
|
||||
expect(h).to include("@version")
|
||||
expect(h).to include("@metadata")
|
||||
end
|
||||
|
||||
it "should produce valid deep Ruby hash without metadata" do
|
||||
h = subject.to_hash
|
||||
h.delete("@timestamp")
|
||||
h.delete("@version")
|
||||
expect(h).to eq(source_hash)
|
||||
end
|
||||
|
||||
it "should produce valid deep Ruby hash with metadata" do
|
||||
h = subject.to_hash_with_metadata
|
||||
h.delete("@timestamp")
|
||||
h.delete("@version")
|
||||
expect(h).to eq(source_hash_with_matada)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue