Tuesday, February 11, 2020

Spock: Expect two calls from one method with specific results.

This is probably nothing new to many people, but it was a very pleasant surprise to me, so I'm posting here in case there are others as clueless as I. 

Here's the situation. I've got a method under test, in Spock. (Yay! Groovy!) There is a mocked class that has a method that will be called twice, so we want to expect that, and we need to specify the return results because they are used by the method under test. In some scenarios, the expected params are known and easy to construct in the test, like a String literal. This is the easy one.



However, in some scenarios, the expected params are more difficult to construct in the test code, and I still want to expect the two calls in a specific order and with specific return values—which, again, are used downstream.

This is where I was stumped.  My very limited Spock skills came back to haunt me, and Google failed to hide my ignorance. No worries: I'm working on a project with the brilliant (and helpful) developers from Object Partners, and Neal Buesing came up with this little gem.


Needless to say, it worked like a charm, and kept me from cluttering up the test with a ton of code to construct the complex objects that would have been needed.


So, if you're reading and didn't know about this trick, tuck it away for later, and you won't have to admit to the world that you were stumped.

Friday, February 7, 2020

Pass me another cup of Kafka Kool-Aid

Ok, I admit it.  I have thoroughly imbibed the event-driven Kool-Aid.

It all started with a new job. This new job would involve Java development (I miss Groovy), and we were going to be using something called "Kafka". So, before the job began, I started looking into Kafka. I soon made the connection that my good friend, Tim Berglund, works for the company founded by the creators of Kafka, Confluent.  Tim and his colleagues have produced a seemingly endless supply of resources to help people like me understand this amazing new world. (Hmm... I wonder if there is a name for a barista who makes Kool-Aid instead of coffee?)

Anyhow, after watching several of the short Confluent videos, I graduated to conference recordings from Kafka Summit. Wow!  It was like I'd reached the Kool-Aid bottling plant! So much good information by such good presenters. I can't wait to attend one of these in person!

Then the job started.  To my surprise, I found that I'd be working with consultants from Object Partners.  I was familiar with OPI (as we affectionately call them) from the good ol' days of Grails, so it was great to know that they were also working in this amazing space.  I guess someone at OPI knows how to pick great technologies!

The team from OPI has been a tremendous help and encouraged me to dive right in.  So, I have.  I'm currently working on my first Kafka Streams story, and having a blast!

There are so many other great resources and friendly, helpful, and brilliant people that I could talk about. I hope to write more here, as I continue to learn and enjoy this refreshing beverage.  For now, I'll just pour another cup and get back to coding.

Monday, January 27, 2014

And the winners are…

Congratulations to the five winners of Grails 2: A Quick-Start Guide!  We had some very clever entries, but we only have 5 books to give away, so we had to make some hard choices.  The winners are: 
If you are one of the winners, please send a Twitter direct message to @daveklein with your shipping address. 

Thank you to all who participated!

Dave

Monday, January 20, 2014

Win a copy of Grails 2: A Quick-Start Guide!

Now that Grails 2: A Quick-Start Guide (affectionately known as GQuick2) is in print, we are looking to helpful blog readers (and Twitter readers) for help in getting the word out. Participating readers will have a chance at winning a paper copy!


From now until Monday, January 28, you can enter the GQuick2 Twitter Giveaway.

We are giving away five copies of the book. To enter:

  1. Post a tweet mentioning the book and linking to its page on the Pragmatic Bookshelf site. For your convenience, here is a link you can use: http://bitly.com/GQuick2
  2. Tweets will be judged based on creativity and uniqueness.
  3. On Monday, the 28th, we will announce the top five tweeters based on those criteria, and each of them will get a paper copy of the book!

You are welcome to tweet more than once.  Each tweet will be entered in the contest and evaluated.  So, put on your thinking caps, get a cup of coffee to get those creative juices flowing and start tweeting! 

Thursday, January 16, 2014

Introducing Grails 2: A Quick-Start Guide

Now there’s a great way to get up to speed quickly with Grails 2.3!  Grails 2: A Quick-Start Guide is finally done and available.

It’s the same fun, fast-paced tutorial that garnered reviews like “Mr. Klein's easy writing style and terrific examples gave me a clear understanding of the power of Grails and allowed me to see for myself what all of the buzz is about. Great book. Highly recommended” and “The best 200 pages of technical literature I have ever read. This is a true 'No Fluff Just Stuff' book.”

We’re still working through the process of building an app from start to finish, but now we're doing it entirely with Grails 2.3.  So, if you're looking to get started with this powerful and popular web framework — or want to help another developer get up to speed — you really should take a look at Grails 2: A Quick-Start Guide.  On the publisher's site, at bit.ly/GQuick2, you can view the table of contents and even download one of the first chapters.

So, check it out and let us know what you think.

Thanks!
Dave and Ben

Monday, December 12, 2011

Grails: A Quick-Start Guide is back

No, there isn’t a second edition (yet). But some may have noticed that the ebook of Grails: A Quick-Start Guide (or GQuick) was no longer available on The Pragmatic Programmers’ site. The thought was that it was becoming obsolete. But after several requests from developers who are still getting started with the Grails 1.x framework, the publisher decided to make it available for a while longer.

Once Grails 2.0 is out and beginning to be widely adopted, GQuick will probably be retired. But for now, it remains one of the best options for developers wanting to quickly take advantage of the powerful Grails framework.

The publisher is no longer printing copies of GQuick, but if you really want a copy of the dead-tree edition, you can find one on Amazon.com. (The price seems to be climbing, though. Currently, new copies are going for $54.39, and used copies for $48.85.)

For those who have asked, I am working on a Grails 2 intro book (publisher to be determined). Stay tuned.

Tuesday, July 19, 2011

CocoaConf, And My Anniversary

For the past few months, my sons and I have been working on a different kind of project: We are putting on a conference for developers on Apple platforms, such as iPhone, iPad, and Mac. It’s called CocoaConf.

The first CocoaConf is being held in Columbus OH, on August 12 - 13, 2011. We have an exciting line-up of speakers, including Daniel Steinberg, Bill Dudney, Chris Adamson, Christopher Judd, and Dave Koziol.

We will be having three tracks for the two days; this will include an all day hands-on iPhone workshop on the first day. It's shaping up to be a very exciting event.

The idea for this conference came when my #3 son, Solomon, began learning Mac programming using the book Beginning Mac Programming by Tim Isted. Taking inspiration from my favorite conference series of all time — No Fluff, Just Stuff — we began tossing around ideas. The NFJS events are known for a capped size so that they don't feel crowded, and for a focus on technical content, without the vendor hype and special events that other conferences tend to have. So that's what we are doing for CocoaConf.

I hadn't blogged about CocoaConf here since it has nothing to do with my usual topics, Groovy and Grails (although the CocoaConf site is being developed in Grails). But today I am going ahead with this post, so that I have a place to explain a crazy (but fun) idea.

You see, 26 years ago today, my beautiful wife, Debbie, said “I do.” And today, we are celebrating this 26th anniversary with a one-day-only CocoaConf discount of 26% off the current early-bird rate of $350. That's a $91 savings for today (July 19th) only! So: If you are interested in developing for the iPhone/iPad or Mac and can make it out to Columbus in August, you can now sign up for CocoaConf for only $259 — but only for today, July 19, 2011. Just go to http://cocoaconf.com/register and use the coupon code “ANNIVERSARY”.

I don't know if anyone will take advantage of this deal, but I thought it would be a fun way to celebrate 26 wonderful years of marriage to my amazing wife. She is the second best thing God has ever done for me!

(And finally, I'll leave you with a bit of child exploitation. Here's our #13, Joshua, telling us where he's headed in August.)