Github user rafaelweingartner commented on the pull request: https://github.com/apache/cloudstack/pull/1206#issuecomment-164482127 @nitin-maharana I do not agree with you. Take a look at the size of the method âallocVolumeâ, there are more than 100 lines, that is terrible to write a test case. We should start creating little chunks of code, test them as unit, and then we can write integration tests. Something like this would do: protected String getVolumeNameFromCommand(CreateVolumeCmd cmd){ String userSpecifiedName = cmd.getVolumeName(); if (userSpecifiedName == null || userSpecifiedName.isEmpty()) { userSpecifiedName = getRandomVolumeName(); } return userSpecifiedName; } After that, you can write test cases to check if the method âgetVolumeNameFromCommandâ is doing its job as expected. That means, one test to check if it calls âgetRandomVolumeNameâ and returns the value of that call when âcmd.getVolumeName()â returns null and other when it returns empty. I would also add a third test case to check if the method cmd.getVolumeName() returns something that is not empty, if that value is properly returned. Having said that, I would also ask, is â â (string with a lot of space empty for you?) Because, for me empty is ââ, this â â is blank, and this way we have another test case to write a make sure everything is proper coded. For Java, empty is "", which means if cmd.getVolumeName() returns " ", that is the value that will be used.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---