Do you know that line of code is causing the exception or event the array that is causing the out of bounds error? It looks like there is a lot of stuff going on and just a quick read, I can't really tell what is going on. Little tip if you don't know where the exception is going on, a decent debug method is called probing. All it is, is putting println statements in your code to see how far the code makes it before breaking or even printing out array values to make sure that they are correct.
I actually figured out my error was due to a logic bug the X and Y were supposed to be switched. fixed that and switched one of the test method and all works now