Converting Java test to Scala