Refactored code to read annotations and added @ExpectedException annotation.