Added java code with test