yieldbot/marceline — pull request #6 by markmandel (2014-07-03 08:59:49+00:00)
Title: Easy Testing of Trident Functions without firing up a LocalCluster

Admittedly, there are actually two things in this pull request, and if you really hate the changes in the 2nd part, let me know, and I'll revert them (but I think they are valid, and will explain why).

1st:
I wanted a way to test a Trident Function without having to fire up a whole topology + local cluster to do so. You can now do that. If you are happy with this, I expect I will move on to Filters, etc. It should be somewhat similar.

There are more examples in `marceline/testing/functions.clj`, but for a taste, you can now do:

```clojure
(t/deftridentfn t-double
[tuple coll]
(t/emit-fn coll (* 2 (first tuple))))

(deftest test-run-function
(is (= [[4]] (run-function t-double :a 2))))
```

Without having to fire up a local cluster.

2nd:
This may well be controversial. I ripped out all of the functions in the protocol `ClojureTridentTuple`, and implementations, except for `get`, and I modified `get`.

`first`, `nth`, `count`, are already implemented by Clojure for an ArrayList out of the box, and the implementing code behind a TridentTuple already accounts of people using it directly like a AraryList anyway. `vals` is redundant, as the implementing code of `getValues()` is `return this`.

I removed the `not-found` option from `get` because a `TridentTupleView` and the `MockTridentTuple` both fire exceptions when a field can't be found, so it was broken to begin with.

I've updated all the tests with these changes, and the tests all pass.

I just also noticed that IntelliJ accidentally formatted trident.clj. Let me know if you want me to pick out the whitespace changes.

Looking forward to your feedback.