cloudstack-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CLOUDSTACK-9132) API createVolume takes empty string for name parameter
Date Mon, 14 Dec 2015 16:18:46 GMT

    [ https://issues.apache.org/jira/browse/CLOUDSTACK-9132?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15056209#comment-15056209
] 

ASF GitHub Bot commented on CLOUDSTACK-9132:
--------------------------------------------

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.



> API createVolume takes empty string for name parameter
> ------------------------------------------------------
>
>                 Key: CLOUDSTACK-9132
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9132
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the default.) 
>          Components: API
>            Reporter: Nitin Kumar Maharana
>
> Steps to Reproduce:
> ================
> Create a volume using createVolume API where parameter name is empty.
> It creates a volume with empty name.
> But the name parameter is mandatory.(Issue)
> Expected Behaviour:
> ================
> It shouldn't create a volume with an empty name. Error should be returned.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message