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.
---

Reply via email to