Testing and learning design pattern in java